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]=`55f3b28c-959f-4286-9725-eca4e82544fc`,e._sentryDebugIdIdentifier=`sentry-dbid-55f3b28c-959f-4286-9725-eca4e82544fc`)}catch{}import"./rolldown-runtime-eb2nym32.js";import{b as e,y as t}from"./vendor-misc-hfpbxrii.js";import{If as n}from"./entry.client-dr7r6s9a.js";import"./workspace-leaf-files-mc5sghv7.js";var r=class{configuration;get logger(){return this.configuration.getLogger(`TitleManager`)}constructor(e){this.configuration=e}async fetchTitleInfosByIds(e,t,n={version:2}){if(!e.length)return this.logger.warn(`fetchTitleInfosByIds received an empty list of ids`),[];let r=await this.configuration.playService.fetchTitleInfosByIds(this.configuration.streamUser,e,t,n);return this.normalizeProductIds(r.results),r.results}async fetchTitles(e,t,n={version:2}){let r=await this.configuration.playService.fetchTitles(this.configuration.streamUser,e,t.token,n);return this.normalizeProductIds(r.results),r}async fetchMruTitles(e,t,n={version:2}){let r=await this.configuration.playService.fetchMruTitles(this.configuration.streamUser,e,t.token,n);return this.normalizeProductIds(r.results),this.logger.info(`Enumerated ${r.results.length} MRU titles`),r}async fetchActiveTitlesForUser(e){let t=await this.configuration.playService.fetchActiveTitlesForUser(e);return this.logger.info(`retrieved ${t.length} active titles for user`),t}async fetchTitleWaitTime(e,t){let n=await this.configuration.playService.fetchTitleWaitTime(e,t);return this.logger.info(`title wait time: ${n}`),n}async fetchTitleInputConfigurations(e,t){return e.length?await this.configuration.playService.fetchTitleInputConfigurations(this.configuration.streamUser,e,t):(this.logger.warn(`getTitleInputConfigurations received an empty list of ids`),[])}normalizeProductIds(e){e.forEach(e=>{e.details.productId&&(e.details.productId=e.details.productId.toUpperCase())})}},i=class{paramsToBatcherMap=new Map;getTitleManager;constructor(e){this.getTitleManager=e}async fetchTitleInfoById(e,t,r){let i=await this.getBatcher(t,r).fetch(e);if(!i)throw new n(`TitleInfo`,e,`TitleInfo not found for id: ${e}, idType: ${t}`);return i}getBatcher=(n,r)=>{let i=`${n}:${r?.version??`default`}`;if(this.paramsToBatcherMap.has(i))return this.paramsToBatcherMap.get(i);let a=t({fetcher:this.createFetcher(n,r),resolver:this.createResolver(n),scheduler:e({windowMs:10,maxBatchSize:100}),name:`fetchTitleInfosByIds-${i}`});return this.paramsToBatcherMap.set(i,a),a};createFetcher=(e,t)=>n=>this.getTitleManager().fetchTitleInfosByIds(n,e,t);createResolver=e=>(t,n)=>{switch(e){case`xboxTitleId`:return t.find(e=>e.details.xboxTitleId.toString()===n);case`productId`:return t.find(e=>e.details.productId===n);case`sourceId`:return t.find(e=>e.titleId===n);default:return}}},a=class{fetchTitleInfosByIdsBatcher;titleManager;titleManagerConfig;constructor(e){this.titleManagerConfig=e}async fetchTitleInfoById(e,t,n){return this.getFetchTitleInfosByIdsBatcher().fetchTitleInfoById(e,t,n)}async fetchTitleInfosByIds(e,t,n){return this.getTitleManager().fetchTitleInfosByIds(e,t,n)}async fetchTitles(e,t,n){return this.getTitleManager().fetchTitles(e,t,n)}async fetchTitleInputConfiguration(e,t){this.titleManager||=new r(this.titleManagerConfig);let n=await this.getTitleManager().fetchTitleInputConfigurations([e],t);if(n.length!==0)return n[0]}async refreshTitleInfo(e,t,n){}async fetchMruTitles(e,t,n){return this.getTitleManager().fetchMruTitles(e,t,n)}async updateTitleInfo(e,t){}getTitleManager(){return this.titleManager||=new r(this.titleManagerConfig),this.titleManager}getFetchTitleInfosByIdsBatcher(){return this.fetchTitleInfosByIdsBatcher||=new i(this.getTitleManager.bind(this)),this.fetchTitleInfosByIdsBatcher}};export{a as TitleManagerAdaptor};