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]=`c558fef6-1e31-43a1-b49c-1e1c656d963e`,e._sentryDebugIdIdentifier=`sentry-dbid-c558fef6-1e31-43a1-b49c-1e1c656d963e`)}catch{}import"./rolldown-runtime-eb2nym32.js";import{Ga as e,If as t,pd as n}from"./entry.client-dr7r6s9a.js";import{t as r}from"./BatchFetchCacheAdaptor-jppkke5o.js";var i={sourceId:`titleId`,productId:`details.productId`,xboxTitleId:`details.xboxTitleId`},a=class a extends r{static createTitleCache(t,r,a){return new e({name:`TitleInfoCache+${r.toLowerCase()}+${t}`,version:1,tables:Object.fromEntries(n.map(e=>[`TitleInfo+${e}`,{keyPath:i[e],indexes:null,cacheTimeMs:a}]))})}titleManagerAdaptor;queryInvalidator;titleCache;constructor(e,t,n,r,i,o){let s=a.createTitleCache(e,t,r);super(s,o),this.titleCache=s,this.titleManagerAdaptor=n,this.queryInvalidator=i}async fetchTitleInfoById(e,t,n){return this.fetchCacheWithBatch(e,t,n)}async fetchTitles(e,t,n){let r=await this.titleManagerAdaptor.fetchTitles(e,t,n);for(let e of r.results)await this.updateTitleInfo(e,n);return r}async fetchTitleInputConfiguration(e,t){return this.titleManagerAdaptor.fetchTitleInputConfiguration(e,t)}async fetchMruTitles(e,t,n){return this.titleManagerAdaptor.fetchMruTitles(e,t,n)}async preloadCache(e){let t=n.map(t=>{let n=e[t];if(n&&n.length>0){let e=this.titleCache.getTable(t);if(e)return e.setValues(n)}return Promise.resolve()});return Promise.all(t)}addSingleEntryToCache(e,t){let n=this.titleCache.getTable(t);n&&n.setValue(e)}async updateTitleInfo(e,t){await this.updateCache(e.titleId,e,`sourceId`,t),await this.updateCache(e.details.productId,e,`productId`,t),await this.updateCache(e.details.xboxTitleId.toString(),e,`xboxTitleId`,t)}async refreshTitleInfo(e,t,n){await this.refreshCache(e,t,n);let r=await this.getCachedValue(e,t);r!==null&&await this.updateTitleInfo(r.value,n)}getTableNameForParams(e,t,n){return`TitleInfo+${t}`}onCacheUpdated(e,t,n){this.queryInvalidator(e,t)}async fetchFromSource(e,t,n){return this.titleManagerAdaptor.fetchTitleInfoById(e,t,n)}async fetchManyFromSource(e,n,r){let i=await this.titleManagerAdaptor.fetchTitleInfosByIds(e,n,r),a={values:new Map,errors:new Map};switch(n){case`sourceId`:for(let e of i)a.values.set(e.titleId,e);break;case`productId`:for(let e of i)a.values.set(e.details.productId,e);break;case`xboxTitleId`:for(let e of i)a.values.set(e.details.xboxTitleId.toString(),e);break;default:throw Error(`Unsupported idType: ${n}`)}if(i.length!==e.length)for(let r of e)a.values.has(r)||a.errors.set(r,new t(`TitleInfo`,r,`TitleInfo not found for id: ${r}, idType: ${n}`));return a}getBatchOptions(e,t){return{dbBatchConfig:{batch:!0,maxBatchSize:50},remoteBatchConfig:{batch:!0,windowMs:10,maxBatchSize:100}}}};export{a as TitleManagerAdaptorIndexedDbWrapper};