try{let 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]=`8c564627-6488-4374-b5eb-382af098f0ba`,e._sentryDebugIdIdentifier=`sentry-dbid-8c564627-6488-4374-b5eb-382af098f0ba`)}catch{}import"./rolldown-runtime-eb2nym32.js";import{r as e}from"./vendor-misc-hfpbxrii.js";import{Hi as t,Ri as n,Yi as r,Zi as i,aa as a,ia as o,ig as s,na as c,xi as l}from"./entry.client-dr7r6s9a.js";import{I as u,L as d}from"./workspace-leaf-files-mc5sghv7.js";import{t as f}from"./selectors-jy7eaal3.js";import{t as p}from"./BasePlugin-nelnyp3q.js";import{n as m}from"./actions-khgs3p0j.js";var h=l(),g=e();n();var _=class extends p{accountsService;stateKey=d;actions=g.FamilyAction;familyActionType=g.FamilyActionType;familySelectors=(0,g.promoteFamilySelectors)(e=>f(e,this.stateKey));familySagaManager;xblTokenProvider;acceptableLanguageProvider;cVProvider;interceptors;logger;constructor(e,t,n,r,i,a,o){super(e,u,o),this.xblTokenProvider=t,this.acceptableLanguageProvider=n,this.cVProvider=r,this.interceptors=i,this.logger=a,this.reduxEnvironment.registerReducer(this.stateKey,g.familyReducer),this.accountsService=new g.XboxAccountsService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,this.interceptors),this.familySagaManager=new g.FamilySagaManager(this.accountsService,this.logger)}destroy(){this.reduxEnvironment.removeReducer(this.stateKey)}*handleActions(){let e=this;yield r([this.familySagaManager.watchForActions(),t(m.UpdateUser,function*(t){try{t?.user?.xuid?yield i([e,e.fetchUserFamilyInfo],t.user.xuid):e.logger.debug(`User is not signed in or has no user family settings`)}catch(t){let n=s(t);e.logger.warn(`Failed to fetch user family settings`,n)}})])}fetchUserFamilyInfo(e){let t=this;return new Promise((n,i)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){if((yield o(t.familySelectors.getCurrentXuid))===e){let e=(0,h.getDataOrPrevious)(yield o(t.familySelectors.getCurrentXuidFamilyInfoStateLCE)),r=(0,h.getDataOrPrevious)(yield o(t.familySelectors.getCurrentIsManagedUserStateLCE));if(e)return n({familyUserData:e,isManagedUser:r})}yield r([c(t.actions.fetchUserFamily.start(e)),a(t=>t.type===g.FamilyActionType.FetchUserFamilyComplete&&t.xuid===e)]);let s=yield o(t.familySelectors.getCurrentXuidFamilyInfoStateLCE);if((0,h.isError)(s)){t.logger.error(`Failed to get user family info in FamilyPlugin`,s.error),i(s.error);return}let l=(0,h.getDataOrPrevious)(s);if(!l){let e=`selectors.getUserFamilyInfo returned undefined but did not have an error.This should never happen and is likely an issue with xbox-family`;t.logger.error(e),i(Error(e));return}let u=yield o(t.familySelectors.getCurrentIsManagedUserStateLCE);if((0,h.isError)(u)){t.logger.error(`Failed to get user isManagedUser in FamilyPlugin`,u.error),i(u.error);return}n({familyUserData:l,isManagedUser:(0,h.getDataOrPrevious)(u)})}))}};export{_ as FamilyPlugin};