@zeniai/web-app-ui 5.3.62-dev → 5.3.62-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 (71) hide show
  1. package/dist/assets/{AccountMappingScreen-DwM3_WTC.js → AccountMappingScreen-Br9WdaHc.js} +1 -1
  2. package/dist/assets/{ActualMatchingMatchDetailScreen---3NQIlW.js → ActualMatchingMatchDetailScreen-DIn78iaK.js} +1 -1
  3. package/dist/assets/{AddressRoutes-CRWje5aU.js → AddressRoutes-Bs2su6QC.js} +1 -1
  4. package/dist/assets/{AddressScreen-DwDn6adU.js → AddressScreen-ChRwBMyD.js} +1 -1
  5. package/dist/assets/{AiCfoScreen-CmI1WP3p.js → AiCfoScreen-BoGQRrg3.js} +1 -1
  6. package/dist/assets/{AppDrawer-CqAnDatC.js → AppDrawer-DbFNEZx2.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-uF3lLPXa.js → BillPayApprovalRoutes-Ct7bUe2K.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-CxGXv0Eb.js → BillPayRoutes-B9u5uZwl.js} +1 -1
  9. package/dist/assets/{BusinessVerificationPageScreen-CWJBny4J.js → BusinessVerificationPageScreen-e_hf599B.js} +1 -1
  10. package/dist/assets/{CardsAiCfoScreen-DTmIk225.js → CardsAiCfoScreen-DX5yBLLe.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-CBA-C6S5.js → ChargeCardRoutes-C0BDIoz6.js} +1 -1
  12. package/dist/assets/{CompanyPassportScreen-C0r5_u0C.js → CompanyPassportScreen-BlEcfU7b.js} +1 -1
  13. package/dist/assets/{ConnectionAuthScreen-D97ZGKWy.js → ConnectionAuthScreen-DXkk-oNs.js} +1 -1
  14. package/dist/assets/{CustomerOnboardingAuthScreen-DREpIR3e.js → CustomerOnboardingAuthScreen-AEs3yg3Y.js} +1 -1
  15. package/dist/assets/{CustomerOnboardingRoutes-BFK8USjA.js → CustomerOnboardingRoutes-CYJxOgEd.js} +1 -1
  16. package/dist/assets/{DashboardRoutes-CIiFmVuR.js → DashboardRoutes-g9OAwtyP.js} +1 -1
  17. package/dist/assets/{DefaultTenantHome-BWhhfpNZ.js → DefaultTenantHome-8TPWmCiF.js} +1 -1
  18. package/dist/assets/{DomesticWireDetailScreen-C8g5HYbF.js → DomesticWireDetailScreen-DjZA-xGp.js} +1 -1
  19. package/dist/assets/{DrawerScreen-jGeXohet.js → DrawerScreen-D1drFQnx.js} +1 -1
  20. package/dist/assets/{EntityDetailRoutes-DDbPZyaE.js → EntityDetailRoutes-BecZC3rR.js} +1 -1
  21. package/dist/assets/{ExpenseAutomationRoutes-BhSlFN1-.js → ExpenseAutomationRoutes-CoBNGWYF.js} +1 -1
  22. package/dist/assets/{FeaturePreviewScreen-t-KcIePh.js → FeaturePreviewScreen-BOIyRrPg.js} +1 -1
  23. package/dist/assets/{HubSpotOAuthCallbackScreen-B9Xsd5UE.js → HubSpotOAuthCallbackScreen-CjBFKEJv.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-BQHOoyRc.js → InvoicingRoutes-BF9bJVNE.js} +1 -1
  25. package/dist/assets/{MagicLinkRoutes-CfUJpVA_.js → MagicLinkRoutes-BJpvsEO6.js} +1 -1
  26. package/dist/assets/{MagicLinkSignInScreen-BR70G8WN.js → MagicLinkSignInScreen-CZf88rgm.js} +1 -1
  27. package/dist/assets/{MobileAppDrawer-DqgtjBKX.js → MobileAppDrawer-BzxL_djZ.js} +1 -1
  28. package/dist/assets/{NotFoundScreen-C2GrPpNy.js → NotFoundScreen-CQm7D9go.js} +1 -1
  29. package/dist/assets/{NotificationRoutes-C1V1-m3K.js → NotificationRoutes-BFU33ioz.js} +1 -1
  30. package/dist/assets/{OAuthConsentScreen-UVKKdhYW.js → OAuthConsentScreen-DWoFdp0W.js} +1 -1
  31. package/dist/assets/{PandLWithForecastRoutes-x9MBz-SJ.js → PandLWithForecastRoutes-CMfowbmP.js} +1 -1
  32. package/dist/assets/{PaymentLinkScreen-BtszXnNs.js → PaymentLinkScreen-DVDDW9Xr.js} +1 -1
  33. package/dist/assets/{PeopleRoutes-By-929Rc.js → PeopleRoutes-Cd8MqER4.js} +1 -1
  34. package/dist/assets/{PerformanceRoutes-DwUVercL.js → PerformanceRoutes-E86W1j7a.js} +1 -1
  35. package/dist/assets/{QBOConnectionScreen-Chdjbcg8.js → QBOConnectionScreen-Os4Qkt_2.js} +1 -1
  36. package/dist/assets/{ReimbursementApprovalRoutes-DVM8rE5F.js → ReimbursementApprovalRoutes-BUfIlnAM.js} +1 -1
  37. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-Bf1LI70e.js → ReimbursementApprovalRuleDetailScreen-Si973dRZ.js} +1 -1
  38. package/dist/assets/{ReimbursementRoutes-ByU4nWbt.js → ReimbursementRoutes-B2UGt9Xo.js} +1 -1
  39. package/dist/assets/{ReportsRoutes-Be1H67SI.js → ReportsRoutes-URtyqRNi.js} +1 -1
  40. package/dist/assets/{RewardsRoutes-iweGs61q.js → RewardsRoutes-xF2koJkH.js} +1 -1
  41. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-HIrqgD7A.js → ScheduleDetailsPrepaidExpensesScreen-dZQw9m0s.js} +1 -1
  42. package/dist/assets/{ScreenRoutes-CFuAOQvL.js → ScreenRoutes-DivUQ8Cf.js} +2 -2
  43. package/dist/assets/{SettingsRoutes-CYdVWZYv.js → SettingsRoutes-DySQSZO0.js} +1 -1
  44. package/dist/assets/{SetupPagesScreen-BccJSzRN.js → SetupPagesScreen-Ctwh4sou.js} +1 -1
  45. package/dist/assets/{SignInScreen-DM0sUU51.js → SignInScreen-CMjQX-Bq.js} +1 -1
  46. package/dist/assets/{SignOutScreen-Bs1NyDBL.js → SignOutScreen-DiORNgD0.js} +1 -1
  47. package/dist/assets/{TaskListScreen-DQj6h_q_.js → TaskListScreen-2YfVihcw.js} +1 -1
  48. package/dist/assets/{TaskRoutes-DY92MrHK.js → TaskRoutes-ClUIKKHH.js} +1 -1
  49. package/dist/assets/{TransactionDetailRoutes-BFj2-oES.js → TransactionDetailRoutes-FefIagFG.js} +1 -1
  50. package/dist/assets/{TransactionDetailScreen-fc6wRDCa.js → TransactionDetailScreen-DG9WnSFK.js} +1 -1
  51. package/dist/assets/{TransactionListRoutes-DoEWtZb8.js → TransactionListRoutes-DJGbjFDn.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-BwZlVh2U.js → TreasuryRoutes-qpLhCja3.js} +1 -1
  53. package/dist/assets/{VendorsRoutes-rWAhbgUX.js → VendorsRoutes-ry-2tBPT.js} +1 -1
  54. package/dist/assets/{WiseConfirmationScreen-twAmgAST.js → WiseConfirmationScreen-FC1WiW4f.js} +1 -1
  55. package/dist/assets/{ZeniAccountRoutes-BqSVR2HC.js → ZeniAccountRoutes-CnC3I2P3.js} +1 -1
  56. package/dist/assets/{ZeniAccountStatementScreen-xKZWX655.js → ZeniAccountStatementScreen-BkDHVJBF.js} +1 -1
  57. package/dist/assets/{analyticsHelper-DHPcRAai.js → analyticsHelper-CyJSZC50.js} +1 -1
  58. package/dist/assets/{getLocaleForTenant-YgJPw-1W.js → getLocaleForTenant-CqonawWC.js} +1 -1
  59. package/dist/assets/{index-DOXJLxdR.js → index-BFK4rLhv.js} +5 -5
  60. package/dist/assets/{routePaths-C1OqXYGB.js → routePaths-BpLibSFl.js} +1 -1
  61. package/dist/assets/{useActualMatchingMatchDetail-6t8vcRTI.js → useActualMatchingMatchDetail-DuLHKjLq.js} +1 -1
  62. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-BO7_rPaJ.js → useAiCfoDashboardSuggestedQuestionsChips-BZ908ypV.js} +1 -1
  63. package/dist/assets/{useAskAiCfoHostNavButtonProps-BvhP40c_.js → useAskAiCfoHostNavButtonProps-0MZcMlGZ.js} +1 -1
  64. package/dist/assets/{useChargeCardPusherEvents-2nVivR1x.js → useChargeCardPusherEvents-BxJ5Xbwu.js} +1 -1
  65. package/dist/assets/{useEmailConnectResultRefresh-QqukN5jp.js → useEmailConnectResultRefresh-BgnlRFeW.js} +1 -1
  66. package/dist/assets/{useInitialThreadRequest-uu8NipM7.js → useInitialThreadRequest-DCnYqu0o.js} +1 -1
  67. package/dist/assets/{useTaskManagerAccess-DxrmaJfc.js → useTaskManagerAccess-DR584Qqx.js} +1 -1
  68. package/dist/assets/{useTaskManagerPusherEvents-D5Hm7um3.js → useTaskManagerPusherEvents-BwxBoB_w.js} +1 -1
  69. package/dist/assets/{withTransactionSidePanel-C1wVwRW0.js → withTransactionSidePanel-BaNmmFC5.js} +1 -1
  70. package/dist/index.html +1 -1
  71. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{j as a}from"./liveblocks-CIxx6Ub6.js";import{a as r}from"./sentry-BCPOyc0G.js";import{u as P,h as L,i as _,j as E,t as Z,l as O,s as H,g as W,N as B,n as oe,o as j}from"./core-Caq7Zbsp.js";import{a9 as tt,k as S,ar as R,U as m,cd as it,ce as ot,cf as at,cg as st,ch as ct,ci as rt,cj as lt,ck as dt,cl as ut,cm as gt,cn as mt,co as vt,p as X,cp as pt,cq as St,z as G,af as ce,cr as ft,cs as ht,ct as It,cu as Ct,cv as Et,cw as kt,cx as yt,cy as xt,cz as bt,cA as jt,W as Dt,aj as un,cB as Pt,cC as Lt,cD as At,cE as $t,cF as wt,cG as Ft,cH as _t,cI as Rt,cJ as Tt,cK as Ot,cL as Mt,t as qe,l as $e,cM as Nt,cN as Ut,cO as Bt,cP as Vt,cQ as Ht,cR as qt,cS as zt}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import{A as Q}from"./AddressScreen-DwDn6adU.js";import M from"./NotFoundScreen-C2GrPpNy.js";import{ZQ as Qt,ZR as Kt,vp as ze,ZS as K,vS as re,ZT as we,ZU as le,wt as be,wA as Gt,wF as gn,ZV as Fe,wx as mn,y7 as Qe,vR as Ke,ZW as Zt,ZX as vn,wQ as je,ZY as de,wU as Wt,ZZ as Xt,Z_ as pn,wX as Sn,z2 as Jt,Z$ as Se,_0 as Ge,_1 as fn,vP as Yt,_2 as ei,vJ as ni,_3 as ti,yk as ii,_4 as hn,yt as Ze,_5 as oi,yq as ai,_6 as _e,gh as Re,_7 as te,_8 as ie,xa as si,vX as We,w0 as In,v_ as ci,vU as ri,x3 as li,w2 as di,xc as ui,_9 as De,xl as Cn,xj as J,xh as ue,xg as gi,_a as En,yz as Xe,_b as mi,vQ as kn,_c as Te,fF as fe,wb as Pe,w8 as Le,wl as yn,wk as Oe,w5 as vi,we as xn,wn as ae,VC as bn,vT as Me,wi as pi,wj as Si,wh as fi,_d as hi,wV as Ii,wR as jn,_e as Dn,vD as Je,_f as Ci,vz as Ei,_g as ki,yF as yi,yJ as q,yE as xi,xN as he,_h as bi,_i as Pn,yS as Ye,_j as ji,yP as Di,_k as Ln,xQ as Pi,xR as V,xU as Li,_l as An,y2 as ke,_m as Ai,xb as $n,U8 as wn,_n as $i,yc as wi,_o as Fn,_p as Fi,_q as _i,_r as Ri,zH as Ti,_s as Oi,_t as _n,yZ as Rn,_u as Tn,zF as ye,_v as Mi,zC as Ni,_w as Ui,_x as Bi,_y as Vi,_z as Hi,_A as qi,_B as en,_C as zi,eg as Qi,zL as Ki,_D as Ne,xv as Gi,xq as Zi,_E as ge,xG as On,xy as me,xx as Wi,xB as Mn,_F as Xi,xw as Ji,_G as Nn,z3 as Un,zu as nn,zp as Yi,_H as eo,z4 as no,_I as to,zv as io,zz as oo,_J as Ue,wv as Bn,zg as ao,ww as so,_K as co,_L as Vn,c8 as ro,ms as lo,mt as uo,_M as tn,wu as ve,gl as go,mz as mo,zm as Hn,zX as vo,zj as qn,uX as po,zU as on,uL as So,zR as an,hS as fo,UB as sn,UC as ho,Gh as zn,hK as Io,_N as Co,Vr as Eo,_O as ko,A0 as xe,A1 as yo,_P as xo,_Q as Qn,z_ as bo,_R as jo,_S as Do,yg as Po,_T as Lo}from"./zeni-epic-state-DROyxOLw.js";import{M as Ao}from"./MobileAppDrawer-DqgtjBKX.js";import{q as pe}from"./QBOConnectionScreen-Chdjbcg8.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DxrmaJfc.js";import"./empty-CviwvzhB.js";import"./pdf-lib-WBpN-CHj.js";import"./index-Bi5Vnzzf.js";import"./url-CdxI2rEH.js";import"./index-BggnOuo1.js";import"./decodeURIComponentSafe-DmjyT4t5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9091bdc6-d761-4883-8449-a83066fb69c6",t._sentryDebugIdIdentifier="sentry-dbid-9091bdc6-d761-4883-8449-a83066fb69c6")}catch{}})();const $=({event:t,isReady:e=!0})=>e?a.jsx(tt,{analytics:S,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function $o(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,items:f,nextCursor:h,auditLogEntityRouteOptions:k,auditLogListSortFieldOptions:I}=E(Qt),y=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,C=r.useCallback(((A,U)=>{const T=Kt(b,A,U,k);T!=null&&(S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(T))}),[k,e,b]);r.useEffect((()=>{const A=setTimeout((()=>d(o)),300);return()=>clearTimeout(A)}),[o]),r.useEffect((()=>{i&&t(ze({filters:y,keepExistingListItems:!1,sort:u}))}),[i,y,u,t]);const D=g==="Not-Started"||g==="In-Progress"&&f.length===0,x=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),a.jsx(it,{auditLogEntityRouteOptions:k,auditLogListSortFieldOptions:I,entries:f,hasMore:p,isLoading:D,isLoadingMore:x,searchValue:o,sortState:l,onEntityLinkClick:C,onLoadMore:()=>{p&&h!=null&&t(ze({cursor:h,filters:y,keepExistingListItems:!0,sort:u}))},onSearchChange:s,onSortChange:v})]})}function Ie(t,e=!1){const n=P(),i=E((c=>K(c).productNextCursor!=null)),o=E((c=>K(c).productNextCursor)),s=E((c=>K(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&s!=="Not-Started"||n(re({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&s!=="In-Progress"&&i&&o!=null&&n(re({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,s,i,o])}function Y(t,e,n,i){const[o,s]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),s((v=>v+1)))}),[c,e]),o}const wo=new Set(["plan"]),Fo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?o=>{i!==""&&t(mn({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(Fe({id:i,localData:o}))},onSaveEdit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(gn({id:i}))},onSubFamilyLifecycleAction:(o,s)=>{i!==""&&t(Gt({action:s,id:o,parentItemId:i}))}}}))(ot);function _o(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=_(),[o]=Z(),{areTenantIdsInSync:s}=R(),c=(d=o.get("kind"))!=null&&wo.has(d)?d:"plan";var d;const l=E((y=>we(y,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(le({id:n})),()=>{t(le({id:n}))})),[t,n]),r.useEffect((()=>{s&&t(be({id:n,kind:c}))}),[s,n,c,t]);const g=r.useCallback((y=>t(be({cacheOverride:!0,id:y,kind:c}))),[t,c]),p=Y(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;Ie(s,!0);const[h,k]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&k(n)}),[n,f]);const I=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),a.jsx(Fo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:I,view:l},p)]})}const Ro=new Set(["addon","charge","plan"]),To=new Set(["plan"]),Oo=O((function(t,e){const n=we(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,s=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(le({id:o})),e.navigate(`${n}/catalog`)},onChange:c=>{t(Fe({id:o,localData:c}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(gn({id:o}))}}}))(at);function Mo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=_(),[o]=Z(),{areTenantIdsInSync:s}=R(),c=n!=null,d=o.get("type"),l=d!=null&&Ro.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&To.has(u)?u:"plan";var u;const g=E((p=>we(p,n)));return Ie(s,!0),r.useEffect((()=>{s&&t(be({id:n,kind:v}))}),[s,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(Fe({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const p=g.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(le({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),a.jsx(Oo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const No={addons:"addon",all:"item",charges:"charge",plans:"plan"},Uo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",o=e.activeTab==="all",s=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&s.length===0,isLoadingMore:c==="In-Progress"&&s.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",s=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:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=No[e.activeTab];S.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(mn({action:Zt(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(Ke({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(re({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));s!=null&&t(i?Ke({cursor:s,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):re({cursor:s,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(st);function Bo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),p=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]),k=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),I=E((A=>K(A))),y=I.planFilters.search,b=I.planSort,C=I.planNextCursor,D=I.productNextCursor,x=I.fetchState==="Completed",w=I.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(o)),300);return()=>clearTimeout(A)}),[o]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:h,productFilters:k,planSort:p,productSort:p}))}),[i,t,h,k,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==b?.field||p?.dir!==b?.dir)&&t(Qe({cacheOverride:!0,planFilters:h,productFilters:k,planSort:p,productSort:p}))}),[y,b,i,t,h,k,f,p]),N(I.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogPage,isReady:x}),a.jsx(Uo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:k,sort:p,planNextCursor:C,productNextCursor:D,runningCatalogItemActionId:w,onSearchChange:s,onTabChange:d,onSortChange:g})]})}const Vo=O((function(t,e){const n=vn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",s=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(de({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(Xt({id:i,localData:c}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:o}),t(Wt({id:i}))}}}))(ct);function Ho(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),{fetchState:s,savedCouponId:c}=E((d=>vn(d,n)));return r.useEffect((()=>{o&&t(je({id:n}))}),[o,n,t]),r.useEffect((()=>{if(s==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(de({id:n}))}}),[s,c,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCouponFormPage}),a.jsx(Vo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const qo=O((function(t){const e=pn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(fn(o))},onSubmit:()=>{const o=ei(t.localData);S.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(ni(o))}}}))(lt);function zo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),[i]=Z(),{areTenantIdsInSync:o}=R(),s=i.get("customerId"),c=E((C=>pn(C))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(Sn),g=E((C=>Jt(C))),p=E(Se),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,k=f||h,I=g.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(Ge()),()=>{t(Ge())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||s==null||s===""||l.customerId!==""||(y.current=!0,t(fn({...l,customerId:s})))}),[s,l,t]),r.useEffect((()=>{o&&t(Yt({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const C=b.current;if(b.current=d,C!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:I}),k?a.jsx(rt,{}):a.jsx(qo,{navigate:e,tenantEmailDomain:n})]})}const Qo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(dt);function Ko(){const t=P(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((d=>ti(d,n??""))),c=s.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(ii({id:n}))}),[o,n,t]),N(s.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),a.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:s})]})}const Go=O((function(t){const e=hn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(ai({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Zo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,creditNoteListFetchState:I}=E((b=>{const C=hn(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,creditNoteListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ze({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:y}),a.jsx(Go,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(oi(b)),onSortChange:v})]})}const Kn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Wo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:o=>{t(De({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(J(ue)),t(gi({id:i}))},onOpenAddress:()=>{const o=Kn(e.tenantEmailDomain??"",ue,i),s=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(De({id:i,localData:o})),t(Cn({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(ui({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,s,c)=>t(di({body:c,customerId:i,email:o,subject:s})),onSubscriptionClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(vt);function Xo(){const t=P(),e=L(),n=W(),{customer_id:i,tenantEmailDomain:o}=_(),{areTenantIdsInSync:s}=R(),c=E((T=>_e(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,p]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const k=f===i,{plaidTokenFetchState:I,promotionalCreditSubmitState:y}=c,{paymentMethodSaveState:b,setupIntentFetchState:C,stripeConnected:D}=c.record,x=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;x.current!=="Error"&&T==="Error"&&t(Re({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),x.current=T}),[t,c.record.sendLinkState.fetchState]);const w=C.fetchState==="Error"?C.error?.message??"Failed to start card setup.":b.fetchState==="Error"?b.error?.message??"Failed to save payment method.":I.fetchState==="Error"?I.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(te()),t(ie()),()=>{t(te()),t(ie())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{s&&i!=null&&t(si({id:i}))}),[s,i,t]),r.useEffect((()=>{s&&i!=null&&D&&t(We({customerId:i}))}),[s,i,t,D]);const A=r.useCallback((T=>t(In({id:T}))),[t]),U=Y(c.fetchState,c.isFormLoading,i,A);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),a.jsx(Wo,{customerId:i??"",editView:c,hasLoadedRecord:k,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(te()),i!=null&&D&&t(We({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ie()),p(!0)}},U),a.jsx(gt,{errorMessage:w,isCreatingSetupIntent:C.fetchState==="In-Progress",isSaving:b.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:b.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:D,onChooseCard:()=>{i!=null&&t(ri({customerId:i}))},onClose:()=>{u(!1),t(te())},onSavePaymentMethod:T=>{i!=null&&t(ci({customerId:i,data:T}))}}),a.jsx(mt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:g,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ie())},onSubmit:({amount:T,description:ne})=>{i!=null&&t(li({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ne}))}})]})}const Jo=O((function(t,e){const n=_e(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",s=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(En({id:i})),t(J(ue)),e.navigate(`${n}/customers`)},onChange:c=>{t(De({id:i,localData:c}))},onOpenAddress:()=>{const c=Kn(e.tenantEmailDomain??"",ue,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:o}),t(Cn({id:i}))}}}))(pt);function Yo(){const t=P(),e=L(),n=W(),{customer_id:i,tenantEmailDomain:o}=_(),{areTenantIdsInSync:s}=R(),{fetchState:c,savedCustomerId:d}=E((l=>_e(l,i)));return r.useEffect((()=>{s&&i!=null&&t(In({id:i}))}),[s,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(En({id:i}))}}),[c,d,i,t,e,o]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerFormPage}),a.jsx(Jo,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ea=O((function(t){const e=Se(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{S.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(kn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(St);function na(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,customerListFetchState:I}=E((b=>{const C=Se(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,customerListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:y}),a.jsx(ea,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(mi(b)),onSortChange:v})]})}const Ae=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ta=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:o,sessionId:s,view:c}=e,d=s==null?void 0:c.diagnosticsBySession[s],l=d?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:d?.items??[],errorMessage:l==="Error"?d?.fetch.error?.message:void 0,expired:d?.expired??!1,filters:o,hasMore:d?.nextCursor!=null,isLoading:l==="Not-Started"||l==="In-Progress",isLoadingMore:l==="In-Progress"&&(d?.items.length??0)>0,session:Ae(c,s)}}),(function(t,e){const{filters:n,navigate:i,sessionId:o,tenantEmailDomain:s,view:c}=e,d=o==null?void 0:c.diagnosticsBySession[o],l=Ae(c,o),v=c.actionStateByKind.retry?.fetchState==="In-Progress",u=c.actionStateByKind.rollback?.fetchState==="In-Progress",g=l?.status==="done"&&l.rollback_available_until!=null&&new Date(l.rollback_available_until).getTime()>Date.now()&&!u;return{onBack:()=>i(`/${s}/invoicing/data_import`),onDownloadError:()=>{t(Re({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&d?.nextCursor!=null&&t(Le({...n,cursor:d.nextCursor,sessionId:o}))},onRetry:l?.status!=="failed"||v?void 0:()=>{o!=null&&t(Oe(o))},onRollback:g?()=>{o!=null&&t(yn(o))}:void 0}}))(ft);function ia(){const t=P(),e=L(),{sessionId:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),[s,c]=r.useState({}),d=E(Te),l=E(fe),v=r.useMemo((()=>{const k=G.getSignedInUser();return{userId:k?.userId??"",sessionId:k?.zeniSessionId??"",tenantId:l.tenantId}}),[l.tenantId]),u=Ae(d,n),g=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Pe(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const k=setTimeout((()=>{t(Le({...s,sessionId:n}))}),300);return()=>clearTimeout(k)}),[o,t,s,n]);const p=u?.status==="scanning"||u?.status==="importing";r.useEffect((()=>{if(!o||n==null||!p)return;const k=setInterval((()=>{t(Pe(n)),t(Le({...s,sessionId:n}))}),3e3);return()=>clearInterval(k)}),[o,t,s,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const k=new URLSearchParams;s.moduleId!=null&&k.set("module_id",s.moduleId),s.level!=null&&k.set("level",s.level),s.outcome!=null&&k.set("outcome",s.outcome),s.search!=null&&s.search.trim()!==""&&k.set("search",s.search.trim());const I=k.toString();return`${ce?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${I===""?"":`?${I}`}`}),[s,n]),h=g?.fetch.fetchState??"Not-Started";return N(h)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:u!=null&&h!=="Not-Started"}),a.jsx(ta,{authParams:v,csvDownloadUrl:f,filters:s,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Gn=t=>`invoicing_active_migration:${t}`,se=(t,e)=>{if(t!=null&&t!=="")try{const n=Gn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},oa=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:s}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||s.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:s}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=s=>{const c=s??null;t(ae(c)),se(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:s}),o(s)},onNewImport:()=>{S.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),o()},onRetrySession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:s}),t(Oe(s)),o(s)},onRollbackSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:s}),t(yn(s))},onViewSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:s}),n(`/${i}/invoicing/data_import/${encodeURIComponent(s)}`)}}}))(ht);function aa(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),o=E(Te);r.useEffect((()=>{i&&(t(vi()),t(xn()))}),[i,t]);const s=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:s}),a.jsx(oa,{navigate:e,tenantEmailDomain:n,view:o})]})}const sa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:o,settings:s,templatesDownloadUrl:c,view:d}=e,{actionStateByKind:l,sessionDetail:v,sessions:u}=d,g=o.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?v[n]:void 0;return{authParams:i,templatesDownloadUrl:c,chargebeeConnected:s?.chargebee_connected===!0||(g?.isValid??!1),chargebeeConnectorAvailable:g!=null,chargebeeSite:s?.chargebee_site,connectError:l.connect?.error?.message,connecting:l.connect?.fetchState==="In-Progress",retrying:l.retry?.fetchState==="In-Progress",session:p??u.find((f=>f.id===n)),starting:l.start?.fetchState==="In-Progress",uploading:l.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Re({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{S.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(fi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Oe(n))},onSaveLater:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Si(n))},onUpload:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(pi({files:s}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(It);function ca(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),o=E(Sn),s=E(fe),c=r.useMemo((()=>{const I=G.getSignedInUser();return{userId:I?.userId??"",sessionId:I?.zeniSessionId??"",tenantId:s.tenantId}}),[s.tenantId]),d=`${ce?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,l=s.companyId??G.getSignedInUserTenant(n??"")?.companyId,v=E((I=>bn(I,l))),u=E(Te),{activeMigrationSessionId:g}=u,p=g??void 0,f=p!=null?u.sessionDetail[p]??u.sessions.find((I=>I.id===p)):void 0;r.useEffect((()=>{i&&(t(Me()),t(xn()))}),[i,t]),r.useEffect((()=>{if(g!=null)return;const I=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Gn(y))}catch{return null}})(n);I!=null&&t(ae(I))}),[g,t,n]),r.useEffect((()=>{se(n,g)}),[g,n]);const h=f?.status,k=h==="scanning"||h==="importing";return r.useEffect((()=>{if(!i||p==null||!k)return;const I=setInterval((()=>{t(Pe(p))}),3e3);return()=>clearInterval(I)}),[i,p,k,t]),r.useEffect((()=>{h==="done"&&(t(ae(null)),se(n,null))}),[t,h,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportMigratePage}),a.jsx(sa,{activeId:p,authParams:c,integrationsView:v,navigate:e,settings:o,templatesDownloadUrl:d,tenantEmailDomain:n,view:u,onBack:()=>{t(ae(null)),se(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ra=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:o=>{t(jn({action:o,id:i}))},onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(Ii({data:o,id:i}))}}}))(Ct);function la(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((h=>hi(h,n))),c=s.actionState.fetchState==="In-Progress",d=s.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(de({id:n})),()=>{t(de({id:n}))})),[n,t]),r.useEffect((()=>{o&&t(je({id:n}))}),[o,n,t]);const p=r.useCallback((h=>t(je({cacheOverride:!0,id:h}))),[t]),f=Y(s.fetchState,s.isFormLoading,n,p);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),a.jsx(ra,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:s.discountLifecycleActionOptions,editView:s,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const da=O((function(t){const e=Dn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(jn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Ei({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Et);function ua(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,couponListFetchState:I,runningDiscountActionId:y}=E((C=>{const D=Dn(C);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),H),b=I==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:b}),a.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,runningDiscountActionId:y,onSearchChange:s,onStatusChange:C=>t(Ci(C)),onSortChange:v})]})}const ga=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:s=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:s,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(s)}`)},onCancel:o?()=>t(q({action:"cancel",id:i})):void 0,onResolve:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(yt);function ma(){const t=P(),e=L(),{case_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((x=>ki(x,n??""))),c=s.fetchState==="Completed",d=s.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[p,f]=r.useState(),[h,k]=r.useState(!1),I=r.useCallback((()=>{v("idle"),g(!1),f(void 0),k(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(yi({id:n})),v("idle"),g(!1);const x=s.emailPreview.preview;f(x==null?void 0:{body:x.body,cc:x.cc,subject:x.subject,to:x.to}),k(!0)}),[n,t,s.emailPreview.preview]),b=r.useCallback((x=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:x,id:n})))}),[n,t,l]),C=r.useMemo((()=>s.emailPreview.preview==null?void 0:{bodyToken:s.emailPreview.preview.bodyToken,renderedHtmlTemplate:s.emailPreview.preview.renderedHtmlTemplate,subjectToken:s.emailPreview.preview.subjectToken}),[s.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(xi({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(he({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),k(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),g(!1),f(void 0),k(!1))}),[o]),r.useEffect((()=>{h&&p==null&&s.emailPreview.preview!=null&&f({body:s.emailPreview.preview.body,cc:s.emailPreview.preview.cc,subject:s.emailPreview.preview.subject,to:s.emailPreview.preview.to})}),[s.emailPreview.preview,p,h]),r.useEffect((()=>{l==="pending"&&(s.actionState.fetchState!=="In-Progress"?u&&s.actionState.fetchState==="Completed"?(n!=null&&t(bi({id:n})),I()):u&&s.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,I,t,l,u,s.actionState.fetchState]);const D=d!=null&&s.linkedInvoice?.id===d?s.linkedInvoice.dunningAttempts:void 0;return N(s.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),a.jsx(ga,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:s,dunningAttempts:D,onSendEmail:y}),a.jsx(kt,{initialDraft:p,isPreviewLoading:s.emailPreview.fetchState==="Not-Started"||s.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:I,onSend:b,open:h,preview:C,previewErrorMessage:s.emailPreview.fetchState==="Error"?s.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?s.actionState.error?.message:void 0})]})}const va=O((function(t){const e=Pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(q({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(xt);function pa(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,dunningCaseListFetchState:I}=E((b=>{const C=Pn(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,dunningCaseListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningListPage,isReady:y}),a.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(ji(b)),onSortChange:v})]})}const Sa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{S.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Li({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
1
+ import{j as a}from"./liveblocks-CIxx6Ub6.js";import{a as r}from"./sentry-BCPOyc0G.js";import{u as P,h as L,i as _,j as E,t as Z,l as O,s as H,g as W,N as B,n as oe,o as j}from"./core-Caq7Zbsp.js";import{a9 as tt,k as S,ar as R,U as m,cd as it,ce as ot,cf as at,cg as st,ch as ct,ci as rt,cj as lt,ck as dt,cl as ut,cm as gt,cn as mt,co as vt,p as X,cp as pt,cq as St,z as G,af as ce,cr as ft,cs as ht,ct as It,cu as Ct,cv as Et,cw as kt,cx as yt,cy as xt,cz as bt,cA as jt,W as Dt,aj as un,cB as Pt,cC as Lt,cD as At,cE as $t,cF as wt,cG as Ft,cH as _t,cI as Rt,cJ as Tt,cK as Ot,cL as Mt,t as qe,l as $e,cM as Nt,cN as Ut,cO as Bt,cP as Vt,cQ as Ht,cR as qt,cS as zt}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import{A as Q}from"./AddressScreen-ChRwBMyD.js";import M from"./NotFoundScreen-CQm7D9go.js";import{ZQ as Qt,ZR as Kt,vp as ze,ZS as K,vS as re,ZT as we,ZU as le,wt as be,wA as Gt,wF as gn,ZV as Fe,wx as mn,y7 as Qe,vR as Ke,ZW as Zt,ZX as vn,wQ as je,ZY as de,wU as Wt,ZZ as Xt,Z_ as pn,wX as Sn,z2 as Jt,Z$ as Se,_0 as Ge,_1 as fn,vP as Yt,_2 as ei,vJ as ni,_3 as ti,yk as ii,_4 as hn,yt as Ze,_5 as oi,yq as ai,_6 as _e,gh as Re,_7 as te,_8 as ie,xa as si,vX as We,w0 as In,v_ as ci,vU as ri,x3 as li,w2 as di,xc as ui,_9 as De,xl as Cn,xj as J,xh as ue,xg as gi,_a as En,yz as Xe,_b as mi,vQ as kn,_c as Te,fF as fe,wb as Pe,w8 as Le,wl as yn,wk as Oe,w5 as vi,we as xn,wn as ae,VC as bn,vT as Me,wi as pi,wj as Si,wh as fi,_d as hi,wV as Ii,wR as jn,_e as Dn,vD as Je,_f as Ci,vz as Ei,_g as ki,yF as yi,yJ as q,yE as xi,xN as he,_h as bi,_i as Pn,yS as Ye,_j as ji,yP as Di,_k as Ln,xQ as Pi,xR as V,xU as Li,_l as An,y2 as ke,_m as Ai,xb as $n,U8 as wn,_n as $i,yc as wi,_o as Fn,_p as Fi,_q as _i,_r as Ri,zH as Ti,_s as Oi,_t as _n,yZ as Rn,_u as Tn,zF as ye,_v as Mi,zC as Ni,_w as Ui,_x as Bi,_y as Vi,_z as Hi,_A as qi,_B as en,_C as zi,eg as Qi,zL as Ki,_D as Ne,xv as Gi,xq as Zi,_E as ge,xG as On,xy as me,xx as Wi,xB as Mn,_F as Xi,xw as Ji,_G as Nn,z3 as Un,zu as nn,zp as Yi,_H as eo,z4 as no,_I as to,zv as io,zz as oo,_J as Ue,wv as Bn,zg as ao,ww as so,_K as co,_L as Vn,c8 as ro,ms as lo,mt as uo,_M as tn,wu as ve,gl as go,mz as mo,zm as Hn,zX as vo,zj as qn,uX as po,zU as on,uL as So,zR as an,hS as fo,UB as sn,UC as ho,Gh as zn,hK as Io,_N as Co,Vr as Eo,_O as ko,A0 as xe,A1 as yo,_P as xo,_Q as Qn,z_ as bo,_R as jo,_S as Do,yg as Po,_T as Lo}from"./zeni-epic-state-DROyxOLw.js";import{M as Ao}from"./MobileAppDrawer-BzxL_djZ.js";import{q as pe}from"./QBOConnectionScreen-Os4Qkt_2.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DR584Qqx.js";import"./empty-CviwvzhB.js";import"./pdf-lib-WBpN-CHj.js";import"./index-Bi5Vnzzf.js";import"./url-CdxI2rEH.js";import"./index-BggnOuo1.js";import"./decodeURIComponentSafe-DmjyT4t5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9091bdc6-d761-4883-8449-a83066fb69c6",t._sentryDebugIdIdentifier="sentry-dbid-9091bdc6-d761-4883-8449-a83066fb69c6")}catch{}})();const $=({event:t,isReady:e=!0})=>e?a.jsx(tt,{analytics:S,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function $o(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,items:f,nextCursor:h,auditLogEntityRouteOptions:k,auditLogListSortFieldOptions:I}=E(Qt),y=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,C=r.useCallback(((A,U)=>{const T=Kt(b,A,U,k);T!=null&&(S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(T))}),[k,e,b]);r.useEffect((()=>{const A=setTimeout((()=>d(o)),300);return()=>clearTimeout(A)}),[o]),r.useEffect((()=>{i&&t(ze({filters:y,keepExistingListItems:!1,sort:u}))}),[i,y,u,t]);const D=g==="Not-Started"||g==="In-Progress"&&f.length===0,x=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),a.jsx(it,{auditLogEntityRouteOptions:k,auditLogListSortFieldOptions:I,entries:f,hasMore:p,isLoading:D,isLoadingMore:x,searchValue:o,sortState:l,onEntityLinkClick:C,onLoadMore:()=>{p&&h!=null&&t(ze({cursor:h,filters:y,keepExistingListItems:!0,sort:u}))},onSearchChange:s,onSortChange:v})]})}function Ie(t,e=!1){const n=P(),i=E((c=>K(c).productNextCursor!=null)),o=E((c=>K(c).productNextCursor)),s=E((c=>K(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&s!=="Not-Started"||n(re({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&s!=="In-Progress"&&i&&o!=null&&n(re({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,s,i,o])}function Y(t,e,n,i){const[o,s]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),s((v=>v+1)))}),[c,e]),o}const wo=new Set(["plan"]),Fo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?o=>{i!==""&&t(mn({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(Fe({id:i,localData:o}))},onSaveEdit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(gn({id:i}))},onSubFamilyLifecycleAction:(o,s)=>{i!==""&&t(Gt({action:s,id:o,parentItemId:i}))}}}))(ot);function _o(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=_(),[o]=Z(),{areTenantIdsInSync:s}=R(),c=(d=o.get("kind"))!=null&&wo.has(d)?d:"plan";var d;const l=E((y=>we(y,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(le({id:n})),()=>{t(le({id:n}))})),[t,n]),r.useEffect((()=>{s&&t(be({id:n,kind:c}))}),[s,n,c,t]);const g=r.useCallback((y=>t(be({cacheOverride:!0,id:y,kind:c}))),[t,c]),p=Y(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;Ie(s,!0);const[h,k]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&k(n)}),[n,f]);const I=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),a.jsx(Fo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:I,view:l},p)]})}const Ro=new Set(["addon","charge","plan"]),To=new Set(["plan"]),Oo=O((function(t,e){const n=we(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,s=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(le({id:o})),e.navigate(`${n}/catalog`)},onChange:c=>{t(Fe({id:o,localData:c}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(gn({id:o}))}}}))(at);function Mo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=_(),[o]=Z(),{areTenantIdsInSync:s}=R(),c=n!=null,d=o.get("type"),l=d!=null&&Ro.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&To.has(u)?u:"plan";var u;const g=E((p=>we(p,n)));return Ie(s,!0),r.useEffect((()=>{s&&t(be({id:n,kind:v}))}),[s,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(Fe({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const p=g.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(le({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),a.jsx(Oo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const No={addons:"addon",all:"item",charges:"charge",plans:"plan"},Uo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",o=e.activeTab==="all",s=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&s.length===0,isLoadingMore:c==="In-Progress"&&s.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",s=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:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=No[e.activeTab];S.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{S.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(mn({action:Zt(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(Ke({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(re({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));s!=null&&t(i?Ke({cursor:s,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):re({cursor:s,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(st);function Bo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),p=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]),k=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),I=E((A=>K(A))),y=I.planFilters.search,b=I.planSort,C=I.planNextCursor,D=I.productNextCursor,x=I.fetchState==="Completed",w=I.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(o)),300);return()=>clearTimeout(A)}),[o]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:h,productFilters:k,planSort:p,productSort:p}))}),[i,t,h,k,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==b?.field||p?.dir!==b?.dir)&&t(Qe({cacheOverride:!0,planFilters:h,productFilters:k,planSort:p,productSort:p}))}),[y,b,i,t,h,k,f,p]),N(I.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogPage,isReady:x}),a.jsx(Uo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:k,sort:p,planNextCursor:C,productNextCursor:D,runningCatalogItemActionId:w,onSearchChange:s,onTabChange:d,onSortChange:g})]})}const Vo=O((function(t,e){const n=vn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",s=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(de({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(Xt({id:i,localData:c}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:o}),t(Wt({id:i}))}}}))(ct);function Ho(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),{fetchState:s,savedCouponId:c}=E((d=>vn(d,n)));return r.useEffect((()=>{o&&t(je({id:n}))}),[o,n,t]),r.useEffect((()=>{if(s==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(de({id:n}))}}),[s,c,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCouponFormPage}),a.jsx(Vo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const qo=O((function(t){const e=pn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(fn(o))},onSubmit:()=>{const o=ei(t.localData);S.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(ni(o))}}}))(lt);function zo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),[i]=Z(),{areTenantIdsInSync:o}=R(),s=i.get("customerId"),c=E((C=>pn(C))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(Sn),g=E((C=>Jt(C))),p=E(Se),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,k=f||h,I=g.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(Ge()),()=>{t(Ge())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||s==null||s===""||l.customerId!==""||(y.current=!0,t(fn({...l,customerId:s})))}),[s,l,t]),r.useEffect((()=>{o&&t(Yt({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const C=b.current;if(b.current=d,C!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:I}),k?a.jsx(rt,{}):a.jsx(qo,{navigate:e,tenantEmailDomain:n})]})}const Qo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(dt);function Ko(){const t=P(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((d=>ti(d,n??""))),c=s.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(ii({id:n}))}),[o,n,t]),N(s.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),a.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:s})]})}const Go=O((function(t){const e=hn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(ai({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Zo(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,creditNoteListFetchState:I}=E((b=>{const C=hn(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,creditNoteListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ze({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:y}),a.jsx(Go,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(oi(b)),onSortChange:v})]})}const Kn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Wo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:o=>{t(De({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(J(ue)),t(gi({id:i}))},onOpenAddress:()=>{const o=Kn(e.tenantEmailDomain??"",ue,i),s=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(De({id:i,localData:o})),t(Cn({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(ui({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,s,c)=>t(di({body:c,customerId:i,email:o,subject:s})),onSubscriptionClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(vt);function Xo(){const t=P(),e=L(),n=W(),{customer_id:i,tenantEmailDomain:o}=_(),{areTenantIdsInSync:s}=R(),c=E((T=>_e(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,p]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const k=f===i,{plaidTokenFetchState:I,promotionalCreditSubmitState:y}=c,{paymentMethodSaveState:b,setupIntentFetchState:C,stripeConnected:D}=c.record,x=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;x.current!=="Error"&&T==="Error"&&t(Re({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),x.current=T}),[t,c.record.sendLinkState.fetchState]);const w=C.fetchState==="Error"?C.error?.message??"Failed to start card setup.":b.fetchState==="Error"?b.error?.message??"Failed to save payment method.":I.fetchState==="Error"?I.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(te()),t(ie()),()=>{t(te()),t(ie())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{s&&i!=null&&t(si({id:i}))}),[s,i,t]),r.useEffect((()=>{s&&i!=null&&D&&t(We({customerId:i}))}),[s,i,t,D]);const A=r.useCallback((T=>t(In({id:T}))),[t]),U=Y(c.fetchState,c.isFormLoading,i,A);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),a.jsx(Wo,{customerId:i??"",editView:c,hasLoadedRecord:k,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(te()),i!=null&&D&&t(We({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ie()),p(!0)}},U),a.jsx(gt,{errorMessage:w,isCreatingSetupIntent:C.fetchState==="In-Progress",isSaving:b.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:b.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:D,onChooseCard:()=>{i!=null&&t(ri({customerId:i}))},onClose:()=>{u(!1),t(te())},onSavePaymentMethod:T=>{i!=null&&t(ci({customerId:i,data:T}))}}),a.jsx(mt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:g,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ie())},onSubmit:({amount:T,description:ne})=>{i!=null&&t(li({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ne}))}})]})}const Jo=O((function(t,e){const n=_e(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",s=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(s),onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(En({id:i})),t(J(ue)),e.navigate(`${n}/customers`)},onChange:c=>{t(De({id:i,localData:c}))},onOpenAddress:()=>{const c=Kn(e.tenantEmailDomain??"",ue,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:o}),t(Cn({id:i}))}}}))(pt);function Yo(){const t=P(),e=L(),n=W(),{customer_id:i,tenantEmailDomain:o}=_(),{areTenantIdsInSync:s}=R(),{fetchState:c,savedCustomerId:d}=E((l=>_e(l,i)));return r.useEffect((()=>{s&&i!=null&&t(In({id:i}))}),[s,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(En({id:i}))}}),[c,d,i,t,e,o]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerFormPage}),a.jsx(Jo,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ea=O((function(t){const e=Se(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{S.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(kn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(St);function na(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,customerListFetchState:I}=E((b=>{const C=Se(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,customerListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:y}),a.jsx(ea,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(mi(b)),onSortChange:v})]})}const Ae=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ta=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:o,sessionId:s,view:c}=e,d=s==null?void 0:c.diagnosticsBySession[s],l=d?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:d?.items??[],errorMessage:l==="Error"?d?.fetch.error?.message:void 0,expired:d?.expired??!1,filters:o,hasMore:d?.nextCursor!=null,isLoading:l==="Not-Started"||l==="In-Progress",isLoadingMore:l==="In-Progress"&&(d?.items.length??0)>0,session:Ae(c,s)}}),(function(t,e){const{filters:n,navigate:i,sessionId:o,tenantEmailDomain:s,view:c}=e,d=o==null?void 0:c.diagnosticsBySession[o],l=Ae(c,o),v=c.actionStateByKind.retry?.fetchState==="In-Progress",u=c.actionStateByKind.rollback?.fetchState==="In-Progress",g=l?.status==="done"&&l.rollback_available_until!=null&&new Date(l.rollback_available_until).getTime()>Date.now()&&!u;return{onBack:()=>i(`/${s}/invoicing/data_import`),onDownloadError:()=>{t(Re({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&d?.nextCursor!=null&&t(Le({...n,cursor:d.nextCursor,sessionId:o}))},onRetry:l?.status!=="failed"||v?void 0:()=>{o!=null&&t(Oe(o))},onRollback:g?()=>{o!=null&&t(yn(o))}:void 0}}))(ft);function ia(){const t=P(),e=L(),{sessionId:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),[s,c]=r.useState({}),d=E(Te),l=E(fe),v=r.useMemo((()=>{const k=G.getSignedInUser();return{userId:k?.userId??"",sessionId:k?.zeniSessionId??"",tenantId:l.tenantId}}),[l.tenantId]),u=Ae(d,n),g=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Pe(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const k=setTimeout((()=>{t(Le({...s,sessionId:n}))}),300);return()=>clearTimeout(k)}),[o,t,s,n]);const p=u?.status==="scanning"||u?.status==="importing";r.useEffect((()=>{if(!o||n==null||!p)return;const k=setInterval((()=>{t(Pe(n)),t(Le({...s,sessionId:n}))}),3e3);return()=>clearInterval(k)}),[o,t,s,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const k=new URLSearchParams;s.moduleId!=null&&k.set("module_id",s.moduleId),s.level!=null&&k.set("level",s.level),s.outcome!=null&&k.set("outcome",s.outcome),s.search!=null&&s.search.trim()!==""&&k.set("search",s.search.trim());const I=k.toString();return`${ce?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${I===""?"":`?${I}`}`}),[s,n]),h=g?.fetch.fetchState??"Not-Started";return N(h)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:u!=null&&h!=="Not-Started"}),a.jsx(ta,{authParams:v,csvDownloadUrl:f,filters:s,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Gn=t=>`invoicing_active_migration:${t}`,se=(t,e)=>{if(t!=null&&t!=="")try{const n=Gn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},oa=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:s}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||s.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:s}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=s=>{const c=s??null;t(ae(c)),se(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:s}),o(s)},onNewImport:()=>{S.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),o()},onRetrySession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:s}),t(Oe(s)),o(s)},onRollbackSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:s}),t(yn(s))},onViewSession:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:s}),n(`/${i}/invoicing/data_import/${encodeURIComponent(s)}`)}}}))(ht);function aa(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),o=E(Te);r.useEffect((()=>{i&&(t(vi()),t(xn()))}),[i,t]);const s=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:s}),a.jsx(oa,{navigate:e,tenantEmailDomain:n,view:o})]})}const sa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:o,settings:s,templatesDownloadUrl:c,view:d}=e,{actionStateByKind:l,sessionDetail:v,sessions:u}=d,g=o.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?v[n]:void 0;return{authParams:i,templatesDownloadUrl:c,chargebeeConnected:s?.chargebee_connected===!0||(g?.isValid??!1),chargebeeConnectorAvailable:g!=null,chargebeeSite:s?.chargebee_site,connectError:l.connect?.error?.message,connecting:l.connect?.fetchState==="In-Progress",retrying:l.retry?.fetchState==="In-Progress",session:p??u.find((f=>f.id===n)),starting:l.start?.fetchState==="In-Progress",uploading:l.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Re({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{S.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(fi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Oe(n))},onSaveLater:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Si(n))},onUpload:s=>{S.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(pi({files:s}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(It);function ca(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),o=E(Sn),s=E(fe),c=r.useMemo((()=>{const I=G.getSignedInUser();return{userId:I?.userId??"",sessionId:I?.zeniSessionId??"",tenantId:s.tenantId}}),[s.tenantId]),d=`${ce?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,l=s.companyId??G.getSignedInUserTenant(n??"")?.companyId,v=E((I=>bn(I,l))),u=E(Te),{activeMigrationSessionId:g}=u,p=g??void 0,f=p!=null?u.sessionDetail[p]??u.sessions.find((I=>I.id===p)):void 0;r.useEffect((()=>{i&&(t(Me()),t(xn()))}),[i,t]),r.useEffect((()=>{if(g!=null)return;const I=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Gn(y))}catch{return null}})(n);I!=null&&t(ae(I))}),[g,t,n]),r.useEffect((()=>{se(n,g)}),[g,n]);const h=f?.status,k=h==="scanning"||h==="importing";return r.useEffect((()=>{if(!i||p==null||!k)return;const I=setInterval((()=>{t(Pe(p))}),3e3);return()=>clearInterval(I)}),[i,p,k,t]),r.useEffect((()=>{h==="done"&&(t(ae(null)),se(n,null))}),[t,h,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportMigratePage}),a.jsx(sa,{activeId:p,authParams:c,integrationsView:v,navigate:e,settings:o,templatesDownloadUrl:d,tenantEmailDomain:n,view:u,onBack:()=>{t(ae(null)),se(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ra=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:o=>{t(jn({action:o,id:i}))},onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(Ii({data:o,id:i}))}}}))(Ct);function la(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((h=>hi(h,n))),c=s.actionState.fetchState==="In-Progress",d=s.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(de({id:n})),()=>{t(de({id:n}))})),[n,t]),r.useEffect((()=>{o&&t(je({id:n}))}),[o,n,t]);const p=r.useCallback((h=>t(je({cacheOverride:!0,id:h}))),[t]),f=Y(s.fetchState,s.isFormLoading,n,p);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),a.jsx(ra,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:s.discountLifecycleActionOptions,editView:s,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const da=O((function(t){const e=Dn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(jn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Ei({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Et);function ua(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,couponListFetchState:I,runningDiscountActionId:y}=E((C=>{const D=Dn(C);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),H),b=I==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:b}),a.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,runningDiscountActionId:y,onSearchChange:s,onStatusChange:C=>t(Ci(C)),onSortChange:v})]})}const ga=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:s=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:s,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(s)}`)},onCancel:o?()=>t(q({action:"cancel",id:i})):void 0,onResolve:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:o?()=>{S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(yt);function ma(){const t=P(),e=L(),{case_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((x=>ki(x,n??""))),c=s.fetchState==="Completed",d=s.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[p,f]=r.useState(),[h,k]=r.useState(!1),I=r.useCallback((()=>{v("idle"),g(!1),f(void 0),k(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(yi({id:n})),v("idle"),g(!1);const x=s.emailPreview.preview;f(x==null?void 0:{body:x.body,cc:x.cc,subject:x.subject,to:x.to}),k(!0)}),[n,t,s.emailPreview.preview]),b=r.useCallback((x=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),S.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:x,id:n})))}),[n,t,l]),C=r.useMemo((()=>s.emailPreview.preview==null?void 0:{bodyToken:s.emailPreview.preview.bodyToken,renderedHtmlTemplate:s.emailPreview.preview.renderedHtmlTemplate,subjectToken:s.emailPreview.preview.subjectToken}),[s.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(xi({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(he({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),k(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),g(!1),f(void 0),k(!1))}),[o]),r.useEffect((()=>{h&&p==null&&s.emailPreview.preview!=null&&f({body:s.emailPreview.preview.body,cc:s.emailPreview.preview.cc,subject:s.emailPreview.preview.subject,to:s.emailPreview.preview.to})}),[s.emailPreview.preview,p,h]),r.useEffect((()=>{l==="pending"&&(s.actionState.fetchState!=="In-Progress"?u&&s.actionState.fetchState==="Completed"?(n!=null&&t(bi({id:n})),I()):u&&s.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,I,t,l,u,s.actionState.fetchState]);const D=d!=null&&s.linkedInvoice?.id===d?s.linkedInvoice.dunningAttempts:void 0;return N(s.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),a.jsx(ga,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:s,dunningAttempts:D,onSendEmail:y}),a.jsx(kt,{initialDraft:p,isPreviewLoading:s.emailPreview.fetchState==="Not-Started"||s.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:I,onSend:b,open:h,preview:C,previewErrorMessage:s.emailPreview.fetchState==="Error"?s.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?s.actionState.error?.message:void 0})]})}const va=O((function(t){const e=Pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(q({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(xt);function pa(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,dunningCaseListFetchState:I}=E((b=>{const C=Pn(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,dunningCaseListFetchState:C.fetchState}}),H),y=I==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningListPage,isReady:y}),a.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onStatusChange:b=>t(ji(b)),onSortChange:v})]})}const Sa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{S.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Li({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
2
2
  `).map((s=>s.trim())).filter((s=>s!=="")).map((s=>({note:s}))):void 0,po_number:o.po_number!==""?o.po_number:null},invoiceId:i}))},onSendReminder:()=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onVoid:o=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))}}}))(bt);function fa(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=E((f=>Ln(f,n??""))),c=s.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const u=l===n;r.useEffect((()=>{o&&n!=null&&t(Pi({invoiceId:n}))}),[o,n,t]);const g=r.useCallback((f=>t(he({invoiceId:f}))),[t]),p=Y(s.actionState.fetchState,s.fetchState==="In-Progress",n,g);return N(c)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),a.jsx(Sa,{invoiceId:n??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:s},p)]})}const ha=O((function(t){const e=An(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{switch(o){case"recordPayment":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":t(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":t(V({action:"regenerate",invoiceId:i}));break;case"void":t(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,o)=>{S.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&t($n({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(jt);function Ia(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,invoiceListFetchState:I,voidingInvoiceId:y}=E((C=>{const D=An(C);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:C.invoicingInvoiceListState.sort,nextCursor:D.nextCursor,invoiceListFetchState:D.fetchState,voidingInvoiceId:D.runningActionId}}),H),b=I==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&t(ke({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(ke({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:b}),a.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,voidingInvoiceId:y,onSearchChange:s,onStatusChange:C=>{t(Ai(C)),t(ke({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function cn(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),i=Dt(),o=un(),[s,c]=r.useState(!1),{acceptTermsState:d,status:l}=E(wn),v=$i(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,g=p=>{c(p)};return l==="completed"?a.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?a.jsx(B,{to:`${u}/settings`,replace:!0}):a.jsxs(a.Fragment,{children:[a.jsx(Ao,{isAppContentDrawerOpen:s,handleDrawerToggle:g}),a.jsx(Pt,{analytics:S,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:o("invoicing_promo"),onAcceptClick:()=>{t(wi())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{g(!0)}})]})}const Ca=O((function(t,e){const n=Fn(t,e.invoiceId),{invoice:i,localData:o,reasonCodeOptions:s,submitState:c,typeOptions:d}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:o,reasonCodeOptions:s,typeOptions:d}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:o=>{t(Oi({localData:o}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Ti())}}}))(Lt);function Ea(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),{fetchState:s,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=E((f=>Fn(f,n??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{t(Fi()),g.current=null}),[t,n]),r.useEffect((()=>{o&&n!=null&&t(he({invoiceId:n}))}),[o,t,n]),r.useEffect((()=>{c!=null&&n!=null&&s==="Completed"&&g.current!==n&&(g.current=n,t(_i({localData:Ri(c)})))}),[t,s,c,n]);const p=r.useRef(v.fetchState);return r.useEffect((()=>{const f=p.current;p.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),a.jsx(Ca,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const ka=O((function(t){return{invoicingOverview:_n(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Rn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{S.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{S.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(At);function ya(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),s=E((c=>_n(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Rn(o))}),[i,t,o]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingOverviewPage,isReady:s}),a.jsx(ka,{navigate:e,selectedPeriod:o,tenantEmailDomain:n})]})}const xa=O((function(t){const e=Tn(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{S.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(Ni({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))($t);function ba(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,transactionListFetchState:I,transactions:y}=E((w=>{const A=Tn(w);return{activeType:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,transactionListFetchState:A.fetchState,transactions:A.transactions}}),H),b=I==="Completed",C=`/${n}/invoicing`,D=r.useCallback((w=>{const A=y.find((T=>T.id===w)),U=A?.linkedInvoices?.[0]?.invoiceID??A?.invoiceID;U!=null&&(S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${C}/invoices/${encodeURIComponent(U)}`))}),[e,C,y]),x=r.useCallback((w=>{const A=y.find((U=>U.id===w))?.customerID;A!=null&&(S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:A,fromScreen:"payments_list",toScreen:"customer"}),e(`${C}/customers/${encodeURIComponent(A)}`))}),[e,C,y]);return r.useEffect((()=>{const w=setTimeout((()=>d(o)),300);return()=>clearTimeout(w)}),[o]),r.useEffect((()=>{i&&t(ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(ye({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:b}),a.jsx(xa,{navigate:e,tenantEmailDomain:n,activeType:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,onSearchChange:s,onTypeChange:w=>{t(Mi(w)),t(ye({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:x,onViewTransactionInvoice:D})]})}const ja=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function rn(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:o}=R(),s=n!=null&&n!=="",c=E(Se),d=E((x=>Ui(x))),l=E(Bi),v=E((x=>Ln(x,n??""))),u=v.invoice,g=`/${i}/invoicing`,p=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Vi()),p.current=null,f.current=""}),[t,n]),r.useEffect((()=>{o&&t(s&&n!=null?he({invoiceId:n}):kn({filters:{},keepExistingListItems:!1}))}),[o,t,n,s]),r.useEffect((()=>{s&&u!=null&&n!=null&&v.fetchState==="Completed"&&p.current!==n&&(p.current=n,t(Hi({contextInvoiceId:n,localData:qi(u)})))}),[t,u,n,v.fetchState,s]),r.useEffect((()=>{if(s)return;const x=d.localData.customerId;x!==""&&x!==f.current&&(f.current=x,t($n({filters:{customerId:x},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(en({localData:{...d.localData,customerId:x,invoiceToLink:""}})))}),[t,d.localData,s]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const x=h.current;if(h.current=l.fetchState,x!=="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 k=r.useMemo((()=>c.customers.map((x=>({id:x.id,name:ja(x)})))),[c.customers]),I=E((x=>zi(x,d.localData.customerId))),y=r.useMemo((()=>I.map((x=>{return{amountDue:(w=x.amountDue,A=Qi.currencySymbol,_t("0,0.00",w,A)),amountDueValue:x.amountDue,id:x.id,label:x.invoiceNumber};var w,A}))),[I]),b=r.useMemo((()=>{if(!s||u==null)return;const x=u.currencyCode??"USD",w=u.amountDue?.amount??0;return{amountDue:wt("0,0.00",u.amountDue),amountDueValue:w,currencyCode:x,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,s]),C=s?`${g}/invoices/${encodeURIComponent(n??"")}`:`${g}/payments`,D=!s||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:D}),a.jsx(Ft,{customers:k,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:b,invoiceOptions:y,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:s?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(C)},onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(C)},onChange:x=>{t(en({localData:x}))},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:s?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(Ki(s?n??void 0:void 0))}})]})}const Zn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Da=O((function(t,e){const{editView:n}=e,i=n.subscription,o=i?.status,s=o!=null&&e.commercialEditAllowedFromStatuses.includes(o);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:s,charges:n.charges,coupons:n.coupons,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=="",s=(c,d)=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(Mn({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(ge({id:i,localData:c}))},onChangeTermEnd:o?c=>{const d=c?.trim()??"";d!==""&&s("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(J(me)),t(Wi({id:i}))},onOpenAddress:()=>{const c=Zn(e.tenantEmailDomain??"",me,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${n}/invoices`),onSaveEdit:c=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(ge({id:i,localData:c})),t(On({id:i}))},onCancelSubscription:o?c=>{s("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:o?(c,d)=>{c!=="pause"?s(c):s(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Rt);function Pa(){const t=P(),e=L(),n=W(),{subscription_id:i,tenantEmailDomain:o}=_(),{areTenantIdsInSync:s}=R(),c=E((y=>Ne(y,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed"&&!c.isFormLoading,[p,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=p===i;Ie(s),r.useEffect((()=>{s&&i!=null&&t(Gi({id:i}))}),[s,i,t]);const k=r.useCallback((y=>t(Zi({id:y}))),[t]),I=Y(c.fetchState,c.isFormLoading,i,k);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),a.jsx(Da,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:o},I)]})}const La=O((function(t,e){const n=Ne(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=null?"edit":"create";return{onCancel:()=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),t(Nn({id:i})),t(J(me)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:s=>{t(ge({id:i,localData:s}))},onOpenAddress:()=>{const s=Zn(e.tenantEmailDomain??"",me,i),c=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:o}),t(On({id:i}))}}}))(Tt);function Aa(){const t=P(),e=L(),n=W(),{subscription_id:i,tenantEmailDomain:o}=_(),[s]=Z(),{areTenantIdsInSync:c}=R(),d=s.get("customerId"),{fetchState:l,savedSubscriptionId:v}=E((p=>Xi(p,i))),u=E((p=>Ne(p,i).localData));Ie(c),r.useEffect((()=>{c&&t(Ji({subscriptionId:i}))}),[c,i,t]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,t(ge({id:i,localData:{...u,customerId:d}})))}),[d,i,u,t]),r.useEffect((()=>{if(l==="Completed"){const p=v??i,f=p!=null?`/${o}/invoicing/subscriptions/${encodeURIComponent(p)}`:`/${o}/invoicing/subscriptions`;e(f),t(Nn({id:i}))}}),[l,v,i,t,e,o]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),a.jsx(La,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:o})]})}const $a=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(o,s,c)=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:s,subscriptionId:o}),t(Mn({action:s,id:o,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{S.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{S.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(o,s)=>{const c=s?.trim()??"";c!==""&&i(o,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(o,s,c)=>{s!=="pause"?i(o,s):i(o,s,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(o,s)=>{i(o,"cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})},onSubscriptionClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:o}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(no({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ot);function wa(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),[o,s]=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:p,appliedSearch:f,appliedSort:h,nextCursor:k,subscriptionListFetchState:I,runningActionSubscriptionId:y}=E((D=>{const x=Un(D);return{activeStatus:x.activeTab,appliedSearch:x.filters.search,appliedSort:x.sort,nextCursor:x.nextCursor,subscriptionListFetchState:x.fetchState,runningActionSubscriptionId:x.runningActionId??null}}),H),b=I==="Completed";r.useEffect((()=>{const D=setTimeout((()=>d(o)),300);return()=>clearTimeout(D)}),[o]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]);const C=r.useRef(y);return r.useEffect((()=>{const D=C.current!=null&&y==null;C.current=y,D&&i&&t(Yi())}),[y,i,t]),N(I)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:b}),a.jsx($a,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:o,sortState:l,filters:g,sort:u,nextCursor:k,runningActionSubscriptionId:y,onSearchChange:s,onStatusChange:D=>t(eo(D)),onSortChange:v})]})}const Fa=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onInvoiceClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onSubscriptionClick:o=>{S.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onCapture:i!==""?()=>{S.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),t(oo({action:"capture",id:i}))}:void 0}}))(Mt);function _a(){const t=P(),e=L(),{tenantEmailDomain:n,transaction_id:i}=_(),{areTenantIdsInSync:o}=R(),s=E((d=>to(d,i??""))),c=s.fetchState==="Completed";return r.useEffect((()=>{o&&i!=null&&t(io({id:i}))}),[o,i,t]),N(s.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),a.jsx(Fa,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:s})]})}function Wn(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=t,s=P(),{areTenantIdsInSync:c}=R(),d=E(Ue),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||s(Bn()),n&&s(ao()))}),[c,s,e,n,o]),r.useEffect((()=>{e&&c&&l&&i&&s(so())}),[c,s,e,l,i]),{isQboConnected:l,qboView:d}}const Ra={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function ee(t){const e=P(),{areTenantIdsInSync:n}=R(),{tenantEmailDomain:i}=_(),{fetchState:o,fieldHelp:s,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=E(co),{configError:u,configFetchState:g,dunningScheduleActionOptions:p,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:k}=E(Vn),I=E(Ue);Wn({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(fe),b=t==="dunning"||t==="quickbooks",C=y.companyId??G.getSignedInUserTenant(i??"")?.companyId,D=E((F=>bn(F,C))),x=ro(y.userRole??[]),w=y.tenantId??"",A=G.getSignedInUser(),U={userId:A?.userId??"",sessionId:A?.zeniSessionId??"",tenantId:w},T=c?.fileId,ne=E((F=>T!=null&&T!==""?lo(F,T):void 0)),Be=E((F=>T!=null&&T!==""?uo(F,T):void 0)),Xn=T!=null&&T!==""&&ne!=null?{[T]:ne}:{},Jn=T!=null&&T!==""&&Be!=null?{[T]:Be}:{};r.useEffect((()=>(e(tn()),()=>{e(tn())})),[e]),r.useEffect((()=>{n&&(o!=="Not-Started"&&o!=="Error"||e(Me()))}),[n,e,o]),r.useEffect((()=>{n&&b&&g==="Not-Started"&&e(ve())}),[n,e,g,b]),r.useEffect((()=>{if(!n)return;const F=A?.userId;F!=null&&F!==""&&w!==""&&qe.shouldFetchActiveTenant(w)&&(qe.markActiveTenantFetchStarted(w),e(go(F,w,A?.zeniSessionId)))}),[n,e,A?.userId,A?.zeniSessionId,w]);const Yn=p.length>0||f.length>0,et=o==="Not-Started"||o==="In-Progress"&&l==null||b&&!Yn&&(g==="Not-Started"||g==="In-Progress"),nt=o==="Completed"&&(!b||g==="Completed"),Ve=D.externalConnections?.revenue?.find((F=>F.connectionName==="chargebee"))?.connectionId,Ce=ce?.invoicingMicroServiceBaseUrl,He=Ce!=null&&Ce.length>0?`${Ce}/1.0/webhooks/stripe`:"",Ee={deleteConnectionError:D.externalConnections?.deleteConnectionError?.message,deleteConnectionState:D.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:D,isAdmin:x,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:F=>e(an(F)),onDisconnect:(F,z)=>{w!==""&&e(Io(w,F,sn(z)))},onDisconnectStripe:()=>e(on()),onReconnectQBO:()=>{const F=y.tenantEmailDomain??i??"";pe.init("/connection/auth",F),pe.handleClick()},onRefreshQBO:()=>{D.integrations.refreshQBO.fetchState!=="In-Progress"&&e(zn())},onSaveChargeBeeCredentials:(F,z)=>{Ve!=null&&w!==""&&e(fo(w,Ve,sn("revenue"),ho("chargebee"),{api_key:F,site:z}))},saveChargeBeeError:D.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:D.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:He};return{authParams:U,deleteFileStatusById:Xn,fieldHelp:s,dunningScheduleActionOptions:p,filesEndPoint:ce?.fileMicroServiceBaseUrl??"",integrationsSectionProps:Ee,isInvoicingPageReady:nt,isLoading:et,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:k,qboView:I,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":b&&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:He,updateFileStatusById:Jn,onConnectStripe:F=>e(an(F)),onDeleteFile:F=>e(So(F,w)),onDisconnectStripe:()=>e(on()),onEditFileName:(F,z)=>e(po(F,z.split(".")[0],w)),onReconnectQBO:Ee.onReconnectQBO,onRefreshQBO:Ee.onRefreshQBO,onRetryQboSyncTask:F=>e(qn(F)),onSave:F=>{S.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(vo({settings:F,snackbarSection:Ra[t??""]}))},onStartQboBackfill:F=>e(Hn(F)),updateFilesEntity:F=>{S.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(mo({files:F}))}}}function ln({appContent:t}){const e=L(),n=W(),i=P(),{tenantEmailDomain:o}=_(),s=ee("branding"),c=E((v=>Co(v))),d=E((v=>Eo(xe,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(ko()),i(J(xe)))}),[c.saveState.fetchState,i]);const l=$e(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:s.isInvoicingPageReady}),a.jsx(Nt,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:s.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:s.deleteFileStatusById,filesEndPoint:s.filesEndPoint,isLoading:s.isLoading,isSaving:s.isSaving,localData:c.localData,logoFile:s.logoFile,saveErrorMessage:s.saveErrorMessage,settings:s.settings,updateFileStatusById:s.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(xo({localData:v}))},onDeleteFile:s.onDeleteFile,onEditFileName:s.onEditFileName,onOpenAddress:()=>{const v=`/${o}/invoicing/settings/branding/${xe}/`,u=X(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(yo()),updateFilesEntity:s.updateFilesEntity})]})}function Ta(){const t=L(),e=ee("dunning");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Ut,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Oa(){const t=L(),e=ee("integrations");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Bt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ma(){const t=L(),e=ee("payment-destination");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Vt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Na=O((function(t){const e=Qn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(Do({localData:e}))},onReset:()=>{t(jo())},onRetryTask:e=>{t(qn(e))},onSave:()=>{S.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(bo())},onStartBackfill:e=>{t(Hn(e))}}}))(Ht);function Ua(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),i=E(fe),{configFetchState:o,saveState:s,settingsFetchState:c}=E(Qn),d=$e(s.fetchState);return r.useEffect((()=>{d==="In-Progress"&&s.fetchState==="Completed"&&e("..")}),[e,d,s.fetchState]),r.useEffect((()=>{c!=="Not-Started"&&c!=="Error"||t(Me())}),[t,c]),r.useEffect((()=>{o==="Not-Started"&&t(ve())}),[o,t]),Wn({fetchSyncHealth:!0,loadAccountingPickers:!0}),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage}),a.jsx(Na,{onBackClick:()=>e(".."),onReconnect:()=>{pe.init("/connection/auth",i.tenantEmailDomain??n??""),pe.handleClick()},onRefresh:()=>t(zn())})]})}const Ba={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Va(){const t=un(),e=P(),n=L(),[i,o]=Z(),s=ee(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=E(Vn),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const p=Ba[g];o({},{replace:!0}),p!=null&&n(p,{replace:!0})}),[g,n,o]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:s.isInvoicingPageReady}),a.jsx(qt,{analytics:S,integrationsSectionProps:{...s.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:d,isLoading:s.isLoading,meetingUrl:t("invoicing_settings"),settings:s.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Po())}})]})}function dn(){return a.jsxs(oe,{children:[a.jsx(j,{index:!0,element:a.jsx(Va,{})}),a.jsx(j,{path:"payment-destination",element:a.jsx(Ma,{})}),a.jsx(j,{path:"branding",element:a.jsx(ln,{})}),a.jsx(j,{path:"branding/:addressType",element:a.jsx(ln,{appContent:a.jsx(Q,{isSubPage:!0,hideAddressBackButton:!0})})}),a.jsx(j,{path:"integrations",element:a.jsx(Oa,{})}),a.jsx(j,{path:"dunning",element:a.jsx(Ta,{})}),a.jsx(j,{path:"quickbooks",element:a.jsx(Ua,{})}),a.jsx(j,{path:"*",element:a.jsx(B,{to:"..",replace:!0})})]})}function Ss(){const t=P(),e=L(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=R(),{enableState:o,fetchState:s,status:c}=E(wn),d=$e(o.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=E((g=>Ue(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(s!=="Not-Started"?s!=="Error"||v.current||(v.current=!0,t(ve({cacheOverride:!1}))):t(ve({cacheOverride:!1})))}),[i,t,s]),r.useEffect((()=>{i&&u==="Not-Started"&&t(Bn())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&o.fetchState==="Completed"&&(e(`${l}/catalog`),t(Lo()))}),[d,o.fetchState,l,t,e]),c==null&&s!=="Error"?a.jsx(zt,{fetchState:"In-Progress"}):c==="not_started"?a.jsxs(oe,{children:[a.jsx(j,{path:"promo",element:a.jsx(cn,{})}),a.jsx(j,{path:"*",element:a.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?a.jsxs(oe,{children:[a.jsx(j,{path:"promo",element:a.jsx(cn,{})}),a.jsx(j,{path:"settings/*",element:a.jsx(dn,{})}),a.jsx(j,{path:"*",element:a.jsx(B,{to:`${l}/settings`,replace:!0})})]}):a.jsxs(oe,{children:[a.jsx(j,{path:"/",element:a.jsx(B,{to:"overview",replace:!0})}),a.jsx(j,{path:"overview",element:a.jsx(ya,{})}),a.jsx(j,{path:"promo",element:a.jsx(B,{to:`${l}/overview`,replace:!0})}),a.jsx(j,{path:"customers",element:a.jsx(na,{})}),a.jsx(j,{path:"customers/new",element:a.jsx(Yo,{})}),a.jsx(j,{path:"customers/new/:addressType",element:a.jsx(Q,{})}),a.jsx(j,{path:"customers/:customer_id",element:a.jsx(Xo,{})}),a.jsx(j,{path:"customers/:customer_id/:addressType",element:a.jsx(Q,{})}),a.jsx(j,{path:"subscriptions",element:a.jsx(wa,{})}),a.jsx(j,{path:"subscriptions/new",element:a.jsx(Aa,{})}),a.jsx(j,{path:"subscriptions/new/:addressType",element:a.jsx(Q,{})}),a.jsx(j,{path:"subscriptions/:subscription_id",element:a.jsx(Pa,{})}),a.jsx(j,{path:"subscriptions/:subscription_id/:addressType",element:a.jsx(Q,{})}),a.jsx(j,{path:"invoices",element:a.jsx(Ia,{})}),a.jsx(j,{path:"invoices/create",element:a.jsx(zo,{})}),a.jsx(j,{path:"invoices/:invoice_id",element:a.jsx(fa,{})}),a.jsx(j,{path:"invoices/:invoice_id/record-payment",element:a.jsx(rn,{})}),a.jsx(j,{path:"invoices/:invoice_id/issue-credit-note",element:a.jsx(Ea,{})}),a.jsx(j,{path:"payments",element:a.jsx(ba,{})}),a.jsx(j,{path:"payments/record",element:a.jsx(rn,{})}),a.jsx(j,{path:"payments/:transaction_id",element:a.jsx(_a,{})}),a.jsx(j,{path:"credits",element:a.jsx(Zo,{})}),a.jsx(j,{path:"credits/:credit_note_id",element:a.jsx(Ko,{})}),a.jsx(j,{path:"discounts",element:a.jsx(ua,{})}),a.jsx(j,{path:"discounts/new",element:a.jsx(Ho,{})}),a.jsx(j,{path:"discounts/:coupon_id",element:a.jsx(la,{})}),a.jsx(j,{path:"dunning",element:a.jsx(pa,{})}),a.jsx(j,{path:"dunning/:case_id",element:a.jsx(ma,{})}),a.jsx(j,{path:"catalog",element:a.jsx(Bo,{})}),a.jsx(j,{path:"catalog/new",element:a.jsx(Mo,{})}),a.jsx(j,{path:"catalog/:item_id",element:a.jsx(_o,{})}),a.jsx(j,{path:"settings/*",element:a.jsx(dn,{})}),a.jsx(j,{path:"audit_log",element:a.jsx($o,{})}),a.jsx(j,{path:"data_import",element:a.jsx(aa,{})}),a.jsx(j,{path:"data_import/migrate",element:a.jsx(ca,{})}),a.jsx(j,{path:"data_import/:sessionId",element:a.jsx(ia,{})}),a.jsx(j,{path:"*",element:a.jsx(M,{})})]})}export{Ss as default};
@@ -1,4 +1,4 @@
1
- import{j as t}from"./liveblocks-CIxx6Ub6.js";import{i as S,l as g,h as C,g as y,u as ee,t as te,j as E,N as ae,n as ne,o as p}from"./core-Caq7Zbsp.js";import{Uu as k,Uv as v,Uw as T,Jy as D,Jk as U,Ux as B,Uy as oe,Uz as ie,Jo as se,gi as $,Jv as le,Js as re}from"./zeni-epic-state-DROyxOLw.js";import{a2 as x,J as r,a3 as de,k as j,_ as G,a4 as ce,a5 as me,a6 as pe,p as J,N as ue,f as he,a7 as ge,F as xe,E as fe,e as we,a8 as be,a9 as Se,a0 as ye,aa as ke,ab as ve,ac as je,ad as $e}from"./index-DOXJLxdR.js";import{n as m}from"./mui-DI0hUuFr.js";import f from"./NotFoundScreen-C2GrPpNy.js";import{a as I}from"./sentry-BCPOyc0G.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="6de49a9c-e956-4832-85a2-fab455119f03",e._sentryDebugIdIdentifier="sentry-dbid-6de49a9c-e956-4832-85a2-fab455119f03")}catch{}})();const Ie=m.div`
1
+ import{j as t}from"./liveblocks-CIxx6Ub6.js";import{i as S,l as g,h as C,g as y,u as ee,t as te,j as E,N as ae,n as ne,o as p}from"./core-Caq7Zbsp.js";import{Uu as k,Uv as v,Uw as T,Jy as D,Jk as U,Ux as B,Uy as oe,Uz as ie,Jo as se,gi as $,Jv as le,Js as re}from"./zeni-epic-state-DROyxOLw.js";import{a2 as x,J as r,a3 as de,k as j,_ as G,a4 as ce,a5 as me,a6 as pe,p as J,N as ue,f as he,a7 as ge,F as xe,E as fe,e as we,a8 as be,a9 as Se,a0 as ye,aa as ke,ab as ve,ac as je,ad as $e}from"./index-BFK4rLhv.js";import{n as m}from"./mui-DI0hUuFr.js";import f from"./NotFoundScreen-CQm7D9go.js";import{a as I}from"./sentry-BCPOyc0G.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="6de49a9c-e956-4832-85a2-fab455119f03",e._sentryDebugIdIdentifier="sentry-dbid-6de49a9c-e956-4832-85a2-fab455119f03")}catch{}})();const Ie=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as u}from"./liveblocks-CIxx6Ub6.js";import{a as g}from"./sentry-BCPOyc0G.js";import{u as O,g as _,h as w,t as M,j as l,N as L}from"./core-Caq7Zbsp.js";import{z as r,E as P,G as V,T as A,k as N,U as $,$ as q,a0 as G,Y as R}from"./index-DOXJLxdR.js";import{fF as W,TZ as Y,Uq as Z,Uh as B,gi as H,gk as J,Um as K,gU as Q,dj as X,Ur as ee,Us as te}from"./zeni-epic-state-DROyxOLw.js";import{n as ne}from"./mui-DI0hUuFr.js";import{u as se}from"./useDeviceId-2NJBbYPM.js";import{f as ae}from"./analyticsHelper-DHPcRAai.js";import{t as ie}from"./getLocaleForTenant-YgJPw-1W.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="0ab82f79-c1f2-4b52-97be-58b8803cd4d3",t._sentryDebugIdIdentifier="sentry-dbid-0ab82f79-c1f2-4b52-97be-58b8803cd4d3")}catch{}})();const T=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Te(){const t=O(),a=_(),m=w(),[k]=M(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:C,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),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=>W(e))),b=l((e=>Y(e))),D=r.getSignedInUser(),v=P().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,f)))}),[n,p,t,i,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")),V.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),Q().then((()=>{const e=R();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin($.Event.loginSuccess,"email",X(o.productSettings))}),2e3))}),[h,S,y,s,o,b,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=g.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(I==="Completed"&&d!=null)return u.jsx(q,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return u.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!T(n,p)||f==null||I==="Error"){const e=a.state?.origin??"/",U=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:U,magicLinkExpired:!U&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
1
+ import{j as u}from"./liveblocks-CIxx6Ub6.js";import{a as g}from"./sentry-BCPOyc0G.js";import{u as O,g as _,h as w,t as M,j as l,N as L}from"./core-Caq7Zbsp.js";import{z as r,E as P,G as V,T as A,k as N,U as $,$ as q,a0 as G,Y as R}from"./index-BFK4rLhv.js";import{fF as W,TZ as Y,Uq as Z,Uh as B,gi as H,gk as J,Um as K,gU as Q,dj as X,Ur as ee,Us as te}from"./zeni-epic-state-DROyxOLw.js";import{n as ne}from"./mui-DI0hUuFr.js";import{u as se}from"./useDeviceId-2NJBbYPM.js";import{f as ae}from"./analyticsHelper-CyJSZC50.js";import{t as ie}from"./getLocaleForTenant-CqonawWC.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="0ab82f79-c1f2-4b52-97be-58b8803cd4d3",t._sentryDebugIdIdentifier="sentry-dbid-0ab82f79-c1f2-4b52-97be-58b8803cd4d3")}catch{}})();const T=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Te(){const t=O(),a=_(),m=w(),[k]=M(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:C,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),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=>W(e))),b=l((e=>Y(e))),D=r.getSignedInUser(),v=P().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,f)))}),[n,p,t,i,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")),V.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),Q().then((()=>{const e=R();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin($.Event.loginSuccess,"email",X(o.productSettings))}),2e3))}),[h,S,y,s,o,b,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=g.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(I==="Completed"&&d!=null)return u.jsx(q,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return u.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!T(n,p)||f==null||I==="Error"){const e=a.state?.origin??"/",U=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:U,magicLinkExpired:!U&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -1 +1 @@
1
- import{j as _}from"./liveblocks-CIxx6Ub6.js";import{a as m}from"./sentry-BCPOyc0G.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-Caq7Zbsp.js";import{fF as ne,T_ as Ue,T$ as se,g9 as Ne,fE as xe,U8 as Pe,U1 as Re,U2 as Ve,p$ as Le,gm as Oe,U5 as h,Ua as je,Ub as J,gn as Ze,Uc as ze,Eb as He,h1 as qe,cV as Ye,Ud as Ke,g8 as Qe,go as We}from"./zeni-epic-state-DROyxOLw.js";import{w as Je,i as Xe,F as ea,N as aa,c as ta,e as na,u as sa,f as c,g as oa,Q as ia,z as ra,d as da,n as ca,o as la,s as ua,q as ma,r as X,L as fa,D as ba,H as ha,p as S,k as ee,y as pa,K as ae,B as ga,C as Sa}from"./index-DOXJLxdR.js";import{D as Ea}from"./mui-DI0hUuFr.js";import{u as ka}from"./InboxNotificationsProvider-DcarX1j5.js";import{u as Ca}from"./useTaskManagerAccess-DxrmaJfc.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]="abe252d7-08e3-4a24-93c8-2bd04d638f9b",l._sentryDebugIdIdentifier="sentry-dbid-abe252d7-08e3-4a24-93c8-2bd04d638f9b")}catch{}})();const Ta=Je((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Me(),B=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>xe(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,U=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),x=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));m.useEffect((()=>{C&&T&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[C,T,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:be}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:he}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>h(e).totalUnreadCount)),Ce=t((e=>h(e).reducedFetchCountState)),R=t((e=>h(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>h(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>h(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>h(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:j,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Te}=ka();m.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(j===!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)}),[j,Z,z]),m.useEffect((()=>{C&&k&&!f&&L.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,f,L.fetchState,B.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(J({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(J({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},H=s!=null?ra.getSignedInUserTenant(s):null,q=t((e=>H?.tenantId!=null?Ze(e,H.tenantId):void 0)),b=[];fe===!1&&b.push("accounts_payable_aging"),be===!1&&b.push("accounts_receivable_aging"),b.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&b.push("rewards_card"),P===!1&&b.push("expense_automation_card");const Y=t((e=>ze(e,b).fetchState)),K=t((e=>He(e).fetchState)),ye=A&&(Y==="Completed"||Y==="Error")||U&&(K==="Completed"||K==="Error")||!A&&!U?void 0:"disabled",we=m.useMemo((()=>qe(o.userRole)),[o.userRole]),Ae=Ye(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&x.fetchState==="Completed"&&Ke(x.notificationSettings,p.userEmail,N,o,k),Q=da(),Fe=Q&&ca(a);return _.jsx(Ea,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:_.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:q!=null?[q]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:Q,onNotificationIconClick:()=>{i(!1);let e=R===0&&V>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&V>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),W=e.type,_e=ae(W)&&W!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),_e&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=ga(e.type);Sa(e.type)?(G!=null&&r(We()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(fa.TENANT_SWITCHING),i(!1),ba({dispatch:r,navigate:n,pathToNavigate:ha(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Qe({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:he,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Ba=l=>{const i=te(),s=t((E=>ne(E))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(E,n)=>{Xe(n)&&Ue(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ta,{...l,...a})};export{Ba as M};
1
+ import{j as _}from"./liveblocks-CIxx6Ub6.js";import{a as m}from"./sentry-BCPOyc0G.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-Caq7Zbsp.js";import{fF as ne,T_ as Ue,T$ as se,g9 as Ne,fE as xe,U8 as Pe,U1 as Re,U2 as Ve,p$ as Le,gm as Oe,U5 as h,Ua as je,Ub as J,gn as Ze,Uc as ze,Eb as He,h1 as qe,cV as Ye,Ud as Ke,g8 as Qe,go as We}from"./zeni-epic-state-DROyxOLw.js";import{w as Je,i as Xe,F as ea,N as aa,c as ta,e as na,u as sa,f as c,g as oa,Q as ia,z as ra,d as da,n as ca,o as la,s as ua,q as ma,r as X,L as fa,D as ba,H as ha,p as S,k as ee,y as pa,K as ae,B as ga,C as Sa}from"./index-BFK4rLhv.js";import{D as Ea}from"./mui-DI0hUuFr.js";import{u as ka}from"./InboxNotificationsProvider-DcarX1j5.js";import{u as Ca}from"./useTaskManagerAccess-DR584Qqx.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]="abe252d7-08e3-4a24-93c8-2bd04d638f9b",l._sentryDebugIdIdentifier="sentry-dbid-abe252d7-08e3-4a24-93c8-2bd04d638f9b")}catch{}})();const Ta=Je((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Me(),B=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>xe(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,U=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),x=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));m.useEffect((()=>{C&&T&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[C,T,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:be}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:he}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>h(e).totalUnreadCount)),Ce=t((e=>h(e).reducedFetchCountState)),R=t((e=>h(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>h(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>h(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>h(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:j,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Te}=ka();m.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(j===!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)}),[j,Z,z]),m.useEffect((()=>{C&&k&&!f&&L.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,f,L.fetchState,B.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(J({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(J({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},H=s!=null?ra.getSignedInUserTenant(s):null,q=t((e=>H?.tenantId!=null?Ze(e,H.tenantId):void 0)),b=[];fe===!1&&b.push("accounts_payable_aging"),be===!1&&b.push("accounts_receivable_aging"),b.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&b.push("rewards_card"),P===!1&&b.push("expense_automation_card");const Y=t((e=>ze(e,b).fetchState)),K=t((e=>He(e).fetchState)),ye=A&&(Y==="Completed"||Y==="Error")||U&&(K==="Completed"||K==="Error")||!A&&!U?void 0:"disabled",we=m.useMemo((()=>qe(o.userRole)),[o.userRole]),Ae=Ye(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&x.fetchState==="Completed"&&Ke(x.notificationSettings,p.userEmail,N,o,k),Q=da(),Fe=Q&&ca(a);return _.jsx(Ea,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:_.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:q!=null?[q]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:Q,onNotificationIconClick:()=>{i(!1);let e=R===0&&V>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&V>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),W=e.type,_e=ae(W)&&W!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),_e&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=ga(e.type);Sa(e.type)?(G!=null&&r(We()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(fa.TENANT_SWITCHING),i(!1),ba({dispatch:r,navigate:n,pathToNavigate:ha(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Qe({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:he,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Ba=l=>{const i=te(),s=t((E=>ne(E))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(E,n)=>{Xe(n)&&Ue(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ta,{...l,...a})};export{Ba as M};
@@ -1 +1 @@
1
- import{j as e}from"./liveblocks-CIxx6Ub6.js";import{h as r,l as n}from"./core-Caq7Zbsp.js";import{an as i}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import"./sentry-BCPOyc0G.js";import"./zeni-epic-state-DROyxOLw.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="3be885cb-07f5-4896-9ae7-ddcb5a1e09f4",o._sentryDebugIdIdentifier="sentry-dbid-3be885cb-07f5-4896-9ae7-ddcb5a1e09f4")}catch{}})();const a=n(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(i);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};
1
+ import{j as e}from"./liveblocks-CIxx6Ub6.js";import{h as r,l as n}from"./core-Caq7Zbsp.js";import{an as i}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import"./sentry-BCPOyc0G.js";import"./zeni-epic-state-DROyxOLw.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="3be885cb-07f5-4896-9ae7-ddcb5a1e09f4",o._sentryDebugIdIdentifier="sentry-dbid-3be885cb-07f5-4896-9ae7-ddcb5a1e09f4")}catch{}})();const a=n(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(i);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};
@@ -1 +1 @@
1
- import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-CIxx6Ub6.js";import ut from"./NotFoundScreen-C2GrPpNy.js";import{a as k}from"./sentry-BCPOyc0G.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 Y}from"./core-Caq7Zbsp.js";import{cA as It,U1 as J,fF as K,h1 as Tt,U5 as S,a0$ as Q,Ub as m,T$ as y,Ar as j,G8 as Ct,a10 as At,T_ as yt,Ud as Et,Aw as _t,a11 as $,br as F,gh as x,AA as z,a12 as Nt,cM as wt,cF as Bt}from"./zeni-epic-state-DROyxOLw.js";import{ar as xt,c as Ut,N as vt,f as Dt,at as Rt,dL as Gt,p as w,dM as Pt,w as Mt,dN as $t,i as Ft,a5 as jt}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-BvhP40c_.js";import{u as Lt}from"./useTaskManagerAccess-DxrmaJfc.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="6ef0b39a-6948-4438-8d28-e0fb0fcfeaf3",t._sentryDebugIdIdentifier="sentry-dbid-6ef0b39a-6948-4438-8d28-e0fb0fcfeaf3")}catch{}})();const Wt=(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)}))})),qt=bt((function(t,l){const n=J(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=K(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&Et(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:v}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(z("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t($([a],F())));let i=`/${h}/${r[1]}`;const T=w(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!wt(g)&&(i="not-found"),r[1].startsWith("bill")&&!Bt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(y(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(Q(a,s));const d=`../${a}`,r=w(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else v?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(z("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t($([i],F())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(y({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")),Wt(o,I).then((()=>{t($(o,F())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(y({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=w(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))(Mt($t)),Ht=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=Ut(),[I,v]=k.useState(!1),a=b((e=>J(e))),s=b((e=>K(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=b((e=>S(e).notificationDetailsByTab.tasks.fetchState)),L=b((e=>S(e).currentTab)),D=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=Gt().allUsers,{inboxNotifications:B,isLoading:E,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:W,isLoading:q,fetchMore:H,isFetchingMore:O,hasFetchedAll:X}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(Q(c)),c==null){const e=`../${L}`,p=w(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&&B!=null){const e=`dashboard_${s.companyId}`,p=B.filter((A=>A.roomId===e&&A.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(y({unreadCount:p},"comments"))}}),[E,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const P=E||G===!0||C!==!0||E||G===!0||C!==!0;k.useEffect((()=>{P&&R!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):P||R!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[P,R]),k.useEffect((()=>{o(y({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(v(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(E===!1&&q===!1&&B!=null&&W!=null){const e=`dashboard_${s.companyId}`,p=B.filter((u=>u.roomId===e)).filter((u=>Pt(u.kind))),A=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=W.find((dt=>{return dt.id===((U=u).kind==="thread"?U.threadId:"subjectId"in U?U.subjectId:void 0);var U}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(O||X===!0||H==null||H(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,O,C,X,q,B?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(Ft(p)){const A=yt(p.mode);if(A==="dashboard"&&o(y({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",A,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(f);return N.jsx(qt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(St,{children:[N.jsx(Y,{path:"/:selectedTab",element:N.jsx(Ht,{})}),N.jsx(Y,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
1
+ import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-CIxx6Ub6.js";import ut from"./NotFoundScreen-CQm7D9go.js";import{a as k}from"./sentry-BCPOyc0G.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 Y}from"./core-Caq7Zbsp.js";import{cA as It,U1 as J,fF as K,h1 as Tt,U5 as S,a0$ as Q,Ub as m,T$ as y,Ar as j,G8 as Ct,a10 as At,T_ as yt,Ud as Et,Aw as _t,a11 as $,br as F,gh as x,AA as z,a12 as Nt,cM as wt,cF as Bt}from"./zeni-epic-state-DROyxOLw.js";import{ar as xt,c as Ut,N as vt,f as Dt,at as Rt,dL as Gt,p as w,dM as Pt,w as Mt,dN as $t,i as Ft,a5 as jt}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-0MZcMlGZ.js";import{u as Lt}from"./useTaskManagerAccess-DR584Qqx.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="6ef0b39a-6948-4438-8d28-e0fb0fcfeaf3",t._sentryDebugIdIdentifier="sentry-dbid-6ef0b39a-6948-4438-8d28-e0fb0fcfeaf3")}catch{}})();const Wt=(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)}))})),qt=bt((function(t,l){const n=J(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=K(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&Et(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:v}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(z("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t($([a],F())));let i=`/${h}/${r[1]}`;const T=w(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!wt(g)&&(i="not-found"),r[1].startsWith("bill")&&!Bt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(y(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(Q(a,s));const d=`../${a}`,r=w(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else v?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(z("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t($([i],F())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(y({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")),Wt(o,I).then((()=>{t($(o,F())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(y({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=w(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))(Mt($t)),Ht=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=Ut(),[I,v]=k.useState(!1),a=b((e=>J(e))),s=b((e=>K(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=b((e=>S(e).notificationDetailsByTab.tasks.fetchState)),L=b((e=>S(e).currentTab)),D=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=Gt().allUsers,{inboxNotifications:B,isLoading:E,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:W,isLoading:q,fetchMore:H,isFetchingMore:O,hasFetchedAll:X}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(Q(c)),c==null){const e=`../${L}`,p=w(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&&B!=null){const e=`dashboard_${s.companyId}`,p=B.filter((A=>A.roomId===e&&A.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(y({unreadCount:p},"comments"))}}),[E,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const P=E||G===!0||C!==!0||E||G===!0||C!==!0;k.useEffect((()=>{P&&R!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):P||R!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[P,R]),k.useEffect((()=>{o(y({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(v(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(E===!1&&q===!1&&B!=null&&W!=null){const e=`dashboard_${s.companyId}`,p=B.filter((u=>u.roomId===e)).filter((u=>Pt(u.kind))),A=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=W.find((dt=>{return dt.id===((U=u).kind==="thread"?U.threadId:"subjectId"in U?U.subjectId:void 0);var U}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(O||X===!0||H==null||H(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,O,C,X,q,B?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(Ft(p)){const A=yt(p.mode);if(A==="dashboard"&&o(y({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",A,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(f);return N.jsx(qt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(St,{children:[N.jsx(Y,{path:"/:selectedTab",element:N.jsx(Ht,{})}),N.jsx(Y,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
@@ -1 +1 @@
1
- import{j as f}from"./liveblocks-CIxx6Ub6.js";import{a as r}from"./sentry-BCPOyc0G.js";import{u as j,g as A,j as o,N as C}from"./core-Caq7Zbsp.js";import{UE as P,fF as x,gm as z,UF as D,UG as M,UH as R,UI as F,pS as k,Tj as L}from"./zeni-epic-state-DROyxOLw.js";import{z as h,ai as I}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="e3455a42-91d2-4bba-97a0-8d29f99e4003",n._sentryDebugIdIdentifier="sentry-dbid-e3455a42-91d2-4bba-97a0-8d29f99e4003")}catch{}})();function ee(){const n=j(),a=A(),{params:t,error:i}=r.useMemo((()=>P(a.search)),[a.search]),w=r.useMemo((()=>new URLSearchParams(a.search).get("client_name")??t?.clientId??"Unknown Application"),[a.search,t]),p=h.isSignedIn(),s=h.getSignedInUser(),m=o((e=>x(e))),l=o((e=>z(e))),d=o((e=>e.tenantState.fetchState)),y=o(D),b=o(M),u=o(R),[S,U]=r.useState(null),[v,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(F())}),[n,a.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{p&&s!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(s.userId,s.zeniSessionId??void 0))))}),[p,s,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const _=r.useMemo((()=>{if(m?.tenantId!=null)return m.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[m?.tenantId,l]),c=S??_;return i!=null?f.jsx(I,{variant:"invalid_params",paramsError:i}):p?f.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:U,approveError:v??b,isApproving:y==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&s!=null&&c!=null&&n(L(s.userId,s.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.")}}}):f.jsx(C,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
1
+ import{j as f}from"./liveblocks-CIxx6Ub6.js";import{a as r}from"./sentry-BCPOyc0G.js";import{u as j,g as A,j as o,N as C}from"./core-Caq7Zbsp.js";import{UE as P,fF as x,gm as z,UF as D,UG as M,UH as R,UI as F,pS as k,Tj as L}from"./zeni-epic-state-DROyxOLw.js";import{z as h,ai as I}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="e3455a42-91d2-4bba-97a0-8d29f99e4003",n._sentryDebugIdIdentifier="sentry-dbid-e3455a42-91d2-4bba-97a0-8d29f99e4003")}catch{}})();function ee(){const n=j(),a=A(),{params:t,error:i}=r.useMemo((()=>P(a.search)),[a.search]),w=r.useMemo((()=>new URLSearchParams(a.search).get("client_name")??t?.clientId??"Unknown Application"),[a.search,t]),p=h.isSignedIn(),s=h.getSignedInUser(),m=o((e=>x(e))),l=o((e=>z(e))),d=o((e=>e.tenantState.fetchState)),y=o(D),b=o(M),u=o(R),[S,U]=r.useState(null),[v,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(F())}),[n,a.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{p&&s!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(s.userId,s.zeniSessionId??void 0))))}),[p,s,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const _=r.useMemo((()=>{if(m?.tenantId!=null)return m.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[m?.tenantId,l]),c=S??_;return i!=null?f.jsx(I,{variant:"invalid_params",paramsError:i}):p?f.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:U,approveError:v??b,isApproving:y==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&s!=null&&c!=null&&n(L(s.userId,s.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.")}}}):f.jsx(C,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
@@ -1 +1 @@
1
- import{j as n}from"./liveblocks-CIxx6Ub6.js";import{h as Y,u as G,g as z,i as Z,j as d,l as H,n as J,o as S}from"./core-Caq7Zbsp.js";import{fF as v,Ac as R,v5 as K,Vw as w,v0 as C,bq as Q,b$ as X,v1 as ee,Vx as ae,Ve as y,ei as te,E0 as se,Vy as oe,Eo as re,d_ as ne,dZ as ce}from"./zeni-epic-state-DROyxOLw.js";import{aj as ie,z as le,ar as de,at as me,W as fe,a9 as pe,k as M,aE as ue,p as he,N as Fe,f as ge}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import Ie from"./NotFoundScreen-C2GrPpNy.js";import{F as be}from"./FeaturePreviewScreen-t-KcIePh.js";import{a as F}from"./sentry-BCPOyc0G.js";import{u as Se}from"./useAskAiCfoHostNavButtonProps-BvhP40c_.js";import{u as ye}from"./useInitialThreadRequest-uu8NipM7.js";import{t as Ce}from"./routePaths-C1OqXYGB.js";import{M as Te}from"./MobileAppDrawer-DqgtjBKX.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DxrmaJfc.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]="169971b6-c4e3-4c7e-9097-347b2a2891e2",s._sentryDebugIdIdentifier="sentry-dbid-169971b6-c4e3-4c7e-9097-347b2a2891e2")}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=H((function(s){const e=ae(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:M}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(C(a)),T(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(re(a))},onForecastVsActualsCompareToggle:a=>{s(oe(a)),s(y({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(se(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=te(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=Ce(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=he(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(y({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(y({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(ue);function U(){const s=ie(),e=Y(),a=G(),o=z(),{forecastId:r,tenantEmailDomain:c}=Z(),[p,u]=F.useState(!1),[m,x]=F.useState(!1),g=le.getSignedInUser(),A=d((t=>v(t))),_=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>R(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),D=d((t=>t.profitAndLossState)),j=d((t=>t.reportUIOptionsState.selectedForecast)),k=t=>D.pandLByForecastID[t]!=null&&ee(t,D).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:I}=de();me({isDataReady:l});const{isAiCfoAccessEnabled:N,onAskAiCfoClick:V}=Se({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&I)u(!0),l||a(K());else if(l&&!m){x(!0);const t=((f,P,O)=>P!=null?f.forecasts.findIndex((b=>b.id===P)):O!=null?f.forecasts.findIndex((b=>b.id===O)):f.forecasts.length>0?0:-1)(i,r,j?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=j?.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&&!k(i.forecasts[t].id)&&I&&a(C(i.forecasts[t].id))}}),[p,u,a,l,i,m,x,R,C,I]);const E=fe(),B=E?.loggedInUserRole!=null&&Q(E.loggedInUserRole),$=ye(A?.companyId,{clearParams:l&&m}),[q,W]=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 L=t=>{W(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(pe,{analytics:M,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Te,{isAppContentDrawerOpen:q,handleDrawerToggle:L}),n.jsx(xe,{firstMonthOfFY:_,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:k,meetingUrl:X(h.toString()),hasTransactionAccess:B,isAiCfoAccessEnabled:N,onAskAiCfoClick:V,initialOpenThreadRequest:$,onClickMenuIcon:()=>{L(!0)}})]})}function Ze(){const s=d((c=>v(c))),{useFeatureGate:e}=Fe(),{isFeatureEnabled:a}=e(ge.isDebitCardFeatureEnabled),o=ne(a,s),r=ce(s);return o===!0||r===!0?n.jsx(be,{}):n.jsxs(J,{children:[n.jsx(S,{path:"/",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId/*",element:n.jsx(Ie,{})})]})}export{Ze as default};
1
+ import{j as n}from"./liveblocks-CIxx6Ub6.js";import{h as Y,u as G,g as z,i as Z,j as d,l as H,n as J,o as S}from"./core-Caq7Zbsp.js";import{fF as v,Ac as R,v5 as K,Vw as w,v0 as C,bq as Q,b$ as X,v1 as ee,Vx as ae,Ve as y,ei as te,E0 as se,Vy as oe,Eo as re,d_ as ne,dZ as ce}from"./zeni-epic-state-DROyxOLw.js";import{aj as ie,z as le,ar as de,at as me,W as fe,a9 as pe,k as M,aE as ue,p as he,N as Fe,f as ge}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import Ie from"./NotFoundScreen-CQm7D9go.js";import{F as be}from"./FeaturePreviewScreen-BOIyRrPg.js";import{a as F}from"./sentry-BCPOyc0G.js";import{u as Se}from"./useAskAiCfoHostNavButtonProps-0MZcMlGZ.js";import{u as ye}from"./useInitialThreadRequest-DCnYqu0o.js";import{t as Ce}from"./routePaths-BpLibSFl.js";import{M as Te}from"./MobileAppDrawer-BzxL_djZ.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DR584Qqx.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]="169971b6-c4e3-4c7e-9097-347b2a2891e2",s._sentryDebugIdIdentifier="sentry-dbid-169971b6-c4e3-4c7e-9097-347b2a2891e2")}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=H((function(s){const e=ae(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:M}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(C(a)),T(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(re(a))},onForecastVsActualsCompareToggle:a=>{s(oe(a)),s(y({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(se(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=te(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=Ce(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=he(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(y({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(y({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(ue);function U(){const s=ie(),e=Y(),a=G(),o=z(),{forecastId:r,tenantEmailDomain:c}=Z(),[p,u]=F.useState(!1),[m,x]=F.useState(!1),g=le.getSignedInUser(),A=d((t=>v(t))),_=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>R(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),D=d((t=>t.profitAndLossState)),j=d((t=>t.reportUIOptionsState.selectedForecast)),k=t=>D.pandLByForecastID[t]!=null&&ee(t,D).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:I}=de();me({isDataReady:l});const{isAiCfoAccessEnabled:N,onAskAiCfoClick:V}=Se({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&I)u(!0),l||a(K());else if(l&&!m){x(!0);const t=((f,P,O)=>P!=null?f.forecasts.findIndex((b=>b.id===P)):O!=null?f.forecasts.findIndex((b=>b.id===O)):f.forecasts.length>0?0:-1)(i,r,j?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=j?.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&&!k(i.forecasts[t].id)&&I&&a(C(i.forecasts[t].id))}}),[p,u,a,l,i,m,x,R,C,I]);const E=fe(),B=E?.loggedInUserRole!=null&&Q(E.loggedInUserRole),$=ye(A?.companyId,{clearParams:l&&m}),[q,W]=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 L=t=>{W(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(pe,{analytics:M,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Te,{isAppContentDrawerOpen:q,handleDrawerToggle:L}),n.jsx(xe,{firstMonthOfFY:_,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:k,meetingUrl:X(h.toString()),hasTransactionAccess:B,isAiCfoAccessEnabled:N,onAskAiCfoClick:V,initialOpenThreadRequest:$,onClickMenuIcon:()=>{L(!0)}})]})}function Ze(){const s=d((c=>v(c))),{useFeatureGate:e}=Fe(),{isFeatureEnabled:a}=e(ge.isDebitCardFeatureEnabled),o=ne(a,s),r=ce(s);return o===!0||r===!0?n.jsx(be,{}):n.jsxs(J,{children:[n.jsx(S,{path:"/",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId/*",element:n.jsx(Ie,{})})]})}export{Ze as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-CIxx6Ub6.js";import{a as p}from"./sentry-BCPOyc0G.js";import{I as d,J as r,aa as m,ae as f,af as h}from"./index-DOXJLxdR.js";import"./mui-DI0hUuFr.js";import{i as y}from"./core-Caq7Zbsp.js";import"./zeni-epic-state-DROyxOLw.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="66bdd2db-a060-4670-9d3a-ab2391de9900",e._sentryDebugIdIdentifier="sentry-dbid-66bdd2db-a060-4670-9d3a-ab2391de9900")}catch{}})();const g=d("div")`
1
+ import{j as a}from"./liveblocks-CIxx6Ub6.js";import{a as p}from"./sentry-BCPOyc0G.js";import{I as d,J as r,aa as m,ae as f,af as h}from"./index-BFK4rLhv.js";import"./mui-DI0hUuFr.js";import{i as y}from"./core-Caq7Zbsp.js";import"./zeni-epic-state-DROyxOLw.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.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]="66bdd2db-a060-4670-9d3a-ab2391de9900",e._sentryDebugIdIdentifier="sentry-dbid-66bdd2db-a060-4670-9d3a-ab2391de9900")}catch{}})();const g=d("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-CIxx6Ub6.js";import{Vs as re,fF as N,l$ as G,d_ as Y,dZ as le,Sj as J,UR as de,CX as Pe,Vt as q,CM as je,D5 as Le,C$ as ce,CQ as pe,D3 as ve,D0 as Te,Vu as ue,sq as Ve,g6 as Ae,gD as Fe,Vv as _,CU as me,CT as ge,D8 as Re,c8 as Oe}from"./zeni-epic-state-DROyxOLw.js";import{a2 as fe,N as Q,f as H,z as W,g as Ce,X as he,ag as ye,aA as be,aB as Ue,ac as Se,J as R,ah as De,G as K,aC as Ze,ar as Be,at as $e,a9 as ze,k as we,U as _e,p as He,aD as Ge,W as We}from"./index-DOXJLxdR.js";import{D as xe,n as M,S as Ie}from"./mui-DI0hUuFr.js";import ae from"./NotFoundScreen-C2GrPpNy.js";import{a as d}from"./sentry-BCPOyc0G.js";import{u as ee,i as Ke,j as g,h as Me,g as Xe,l as qe,n as se,o as z}from"./core-Caq7Zbsp.js";import{u as Ne}from"./useAskAiCfoHostNavButtonProps-BvhP40c_.js";import{M as Ye}from"./MobileAppDrawer-DqgtjBKX.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DxrmaJfc.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]="478a7d7d-443d-42a5-a23e-46d071ebc950",e._sentryDebugIdIdentifier="sentry-dbid-478a7d7d-443d-42a5-a23e-46d071ebc950")}catch{}})();const Je={overlayWidth:new Se(100,100,48)},te=K.getLocalizedStrings().peoplePage.invitePage,ne=K.getLocalizedStrings().common,Qe=({companyId:e,managersListView:t,companyPassportView:c,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const C=fe(),m=ee(),[O,U]=d.useState(!1),[k,S]=d.useState(!1),{userId:D}=Ke(),r=g((l=>re(l))),p=g((l=>N(l))),E=g((l=>G(l))),{useFeatureGate:x}=Q(),{isFeatureEnabled:I}=x(H.isDebitCardFeatureEnabled),P=Y(I,p),v=le(p),T=J(p),Z=de(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,w=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||c.fetchState!=="Completed"||e==null;if(W.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(q()),b()},V=()=>{O===!0?S(!0):h()},$=c.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=x(H.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(ce({peopleLocalData:l})),U(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(T))},onCloseClick:V,isLoading:w||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return d.useEffect((()=>{w===!1&&D!=null&&m(Pe(D))}),[w,D]),d.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(xe,{anchor:"right",open:i,PaperProps:{style:{width:Je.overlayWidth.valuePercentage(C),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:V,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-CIxx6Ub6.js";import{Vs as re,fF as N,l$ as G,d_ as Y,dZ as le,Sj as J,UR as de,CX as Pe,Vt as q,CM as je,D5 as Le,C$ as ce,CQ as pe,D3 as ve,D0 as Te,Vu as ue,sq as Ve,g6 as Ae,gD as Fe,Vv as _,CU as me,CT as ge,D8 as Re,c8 as Oe}from"./zeni-epic-state-DROyxOLw.js";import{a2 as fe,N as Q,f as H,z as W,g as Ce,X as he,ag as ye,aA as be,aB as Ue,ac as Se,J as R,ah as De,G as K,aC as Ze,ar as Be,at as $e,a9 as ze,k as we,U as _e,p as He,aD as Ge,W as We}from"./index-BFK4rLhv.js";import{D as xe,n as M,S as Ie}from"./mui-DI0hUuFr.js";import ae from"./NotFoundScreen-CQm7D9go.js";import{a as d}from"./sentry-BCPOyc0G.js";import{u as ee,i as Ke,j as g,h as Me,g as Xe,l as qe,n as se,o as z}from"./core-Caq7Zbsp.js";import{u as Ne}from"./useAskAiCfoHostNavButtonProps-0MZcMlGZ.js";import{M as Ye}from"./MobileAppDrawer-BzxL_djZ.js";import"./recharts-DKmpCGIA.js";import"./analytics-CiEh1qKr.js";import"./plaid-CXvI7t9H.js";import"./dnd-DwckO6rX.js";import"./stripe-cKAAJElX.js";import"./lottie-CrKh4Q_r.js";import"./lexical-mmp2B1vq.js";import"./pdf-BlhN83fm.js";import"./utils-rX2IEvjD.js";import"./InboxNotificationsProvider-DcarX1j5.js";import"./useTaskManagerAccess-DR584Qqx.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]="478a7d7d-443d-42a5-a23e-46d071ebc950",e._sentryDebugIdIdentifier="sentry-dbid-478a7d7d-443d-42a5-a23e-46d071ebc950")}catch{}})();const Je={overlayWidth:new Se(100,100,48)},te=K.getLocalizedStrings().peoplePage.invitePage,ne=K.getLocalizedStrings().common,Qe=({companyId:e,managersListView:t,companyPassportView:c,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const C=fe(),m=ee(),[O,U]=d.useState(!1),[k,S]=d.useState(!1),{userId:D}=Ke(),r=g((l=>re(l))),p=g((l=>N(l))),E=g((l=>G(l))),{useFeatureGate:x}=Q(),{isFeatureEnabled:I}=x(H.isDebitCardFeatureEnabled),P=Y(I,p),v=le(p),T=J(p),Z=de(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,w=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||c.fetchState!=="Completed"||e==null;if(W.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(q()),b()},V=()=>{O===!0?S(!0):h()},$=c.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=x(H.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(ce({peopleLocalData:l})),U(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(T))},onCloseClick:V,isLoading:w||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return d.useEffect((()=>{w===!1&&D!=null&&m(Pe(D))}),[w,D]),d.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(xe,{anchor:"right",open:i,PaperProps:{style:{width:Je.overlayWidth.valuePercentage(C),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:V,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;