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]=`a2f8f796-5877-4d11-9a47-dd0589c9f335`,e._sentryDebugIdIdentifier=`sentry-dbid-a2f8f796-5877-4d11-9a47-dd0589c9f335`)}catch{}import"./rolldown-runtime-eb2nym32.js";import{Ri as e,Yi as t,Zi as n,dm as r,ia as i,ig as a,xi as o,ym as s}from"./entry.client-dr7r6s9a.js";import{A as c,j as l}from"./workspace-leaf-files-mc5sghv7.js";import{t as u}from"./selectors-jy7eaal3.js";import{t as d}from"./BasePlugin-nelnyp3q.js";import{t as f}from"./dist-eblctkno.js";r();var p=o(),m=f();e();var h=[],g=class extends d{titleService;titleStorageService;displayCatalogMetadataService;collectionsService;stateKey=l;titleActionType=m.TitleActionType;hasConsumedSignInAction=!1;actions=m.TitleAction;decoratorType=m.TitleDecoratorType;filterType=m.TitleFilterType;titleSelectors=(0,m.promoteTitleSelectors)(e=>u(e,this.stateKey));titleSagaManager;commonSelectors;xblTokenProvider;acceptableLanguageProvider;marketAndLocaleProvider;cVProvider;interceptors;logger;constructor(e,t,n,r,i,a,o,s,l){super(e,c,l),this.commonSelectors=t,this.xblTokenProvider=n,this.acceptableLanguageProvider=r,this.marketAndLocaleProvider=i,this.cVProvider=a,this.interceptors=o,this.logger=s,this.reduxEnvironment.registerReducer(this.stateKey,m.titleReducer),this.titleService=new m.XblTitleService(this.xblTokenProvider,this.acceptableLanguageProvider,this.marketAndLocaleProvider,this.cVProvider,this.interceptors,this.logger),this.titleStorageService=new m.XblTitleStorageService(this.xblTokenProvider,this.acceptableLanguageProvider,this.marketAndLocaleProvider,this.cVProvider,this.interceptors,this.logger),this.displayCatalogMetadataService=new m.DisplayCatalogMetadataService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,this.marketAndLocaleProvider,this.interceptors),this.collectionsService=new m.CollectionsService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,i,o),this.titleSagaManager=new m.TitleSagaManager(this.titleService,this.displayCatalogMetadataService,this.collectionsService,this.titleSelectors,this.logger)}destroy(){this.reduxEnvironment.removeReducer(this.stateKey)}*handleActions(){yield t([this.titleSagaManager.watchForActions()])}shouldFetchTitleHistory(){let e=this;return new Promise((t,n)=>e.reduxEnvironment.sagaMiddleware.run(e.name,function*(){try{let n=yield i(e.commonSelectors.getCurrentUser);if(!n?.xuid){t(!0);return}if((0,p.isContent)(yield i(e.titleSelectors.getUserTitleHistory,n.xuid))){t(!1);return}t(!0)}catch(e){n(e)}}))}isTitleHistoryInfoUpToDate(e,t){let n=this;return new Promise((r,a)=>n.reduxEnvironment.sagaMiddleware.run(n.name,function*(){try{r(yield i(n.titleSelectors.isTitleHistoryInfoUpToDate,e,t))}catch(e){a(e)}}))}getUserTitleHistoryInfo(e,t){let n=this;return new Promise((r,a)=>n.reduxEnvironment.sagaMiddleware.run(n.name,function*(){try{let a=yield i(n.titleSelectors.getUserTitleHistoryInfoLCE,e,t);r(n.unwrapLCEContent(a)??null)}catch(e){a(e)}}))}fetchGameSaves(e){let t=this;return new Promise((r,o)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){let c=yield i(t.commonSelectors.getCurrentUser);if(!c?.xuid){let e=`commonSelectors.getCurrentUser returned null. Cannot fetch game saves from title connected storage without a user`;t.logger.error(e),o(Error(e));return}try{r((yield n([t.titleStorageService,t.titleStorageService.getConnectedStorage],c.xuid,e)).blobs)}catch(e){if(e instanceof s&&(`status`in e.response&&e.response.status===404||`statusCode`in e.response&&e.response.statusCode===404))return r(h);let n=a(e);t.logger.error(`titleStorageService.getConnectedStorage failed due to error: ${n.message}`),o(n)}}))}deleteAllGameSaves(e){let t=this;return new Promise((r,o)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){let s=yield i(t.commonSelectors.getCurrentUser);if(!s?.xuid){let e=`commonSelectors.getCurrentUser returned null. Cannot delete title connected storage without a user`;t.logger.error(e),o(Error(e));return}try{yield n([t.titleStorageService,t.titleStorageService.deleteConnectedStorage],s.xuid,e)}catch(e){let n=a(e);t.logger.error(`titleSelectors.deleteAllGameSaves failed due to error: ${n.message}`),o(n);return}r()}))}};export{g as TitlesPlugin};