{"version":3,"sources":["node_modules/@datadog/browser-rum/esm/domain/replayStats.js"],"sourcesContent":["export const MAX_STATS_HISTORY = 1000;\nlet statsPerView;\nexport function getSegmentsCount(viewId) {\n return getOrCreateReplayStats(viewId).segments_count;\n}\nexport function addSegment(viewId) {\n getOrCreateReplayStats(viewId).segments_count += 1;\n}\nexport function addRecord(viewId) {\n getOrCreateReplayStats(viewId).records_count += 1;\n}\nexport function addWroteData(viewId, additionalBytesCount) {\n getOrCreateReplayStats(viewId).segments_total_raw_size += additionalBytesCount;\n}\nexport function getReplayStats(viewId) {\n return statsPerView === null || statsPerView === void 0 ? void 0 : statsPerView.get(viewId);\n}\nexport function resetReplayStats() {\n statsPerView = undefined;\n}\nfunction getOrCreateReplayStats(viewId) {\n if (!statsPerView) {\n statsPerView = new Map();\n }\n let replayStats;\n if (statsPerView.has(viewId)) {\n replayStats = statsPerView.get(viewId);\n } else {\n replayStats = {\n records_count: 0,\n segments_count: 0,\n segments_total_raw_size: 0\n };\n statsPerView.set(viewId, replayStats);\n if (statsPerView.size > MAX_STATS_HISTORY) {\n deleteOldestStats();\n }\n }\n return replayStats;\n}\nfunction deleteOldestStats() {\n if (!statsPerView) {\n return;\n }\n const toDelete = statsPerView.keys().next().value;\n if (toDelete) {\n statsPerView.delete(toDelete);\n }\n}\n"],"mappings":"AACA,IAAIA,EACG,SAASC,EAAiBC,EAAQ,CACvC,OAAOC,EAAuBD,CAAM,EAAE,cACxC,CACO,SAASE,EAAWF,EAAQ,CACjCC,EAAuBD,CAAM,EAAE,gBAAkB,CACnD,CACO,SAASG,EAAUH,EAAQ,CAChCC,EAAuBD,CAAM,EAAE,eAAiB,CAClD,CACO,SAASI,EAAaJ,EAAQK,EAAsB,CACzDJ,EAAuBD,CAAM,EAAE,yBAA2BK,CAC5D,CACO,SAASC,EAAeN,EAAQ,CACrC,OAAmEF,GAAa,IAAIE,CAAM,CAC5F,CAIA,SAASO,EAAuBC,EAAQ,CACjCC,IACHA,EAAe,IAAI,KAErB,IAAIC,EACJ,OAAID,EAAa,IAAID,CAAM,EACzBE,EAAcD,EAAa,IAAID,CAAM,GAErCE,EAAc,CACZ,cAAe,EACf,eAAgB,EAChB,wBAAyB,CAC3B,EACAD,EAAa,IAAID,EAAQE,CAAW,EAChCD,EAAa,KAAO,KACtBE,EAAkB,GAGfD,CACT,CACA,SAASC,GAAoB,CAC3B,GAAI,CAACF,EACH,OAEF,IAAMG,EAAWH,EAAa,KAAK,EAAE,KAAK,EAAE,MACxCG,GACFH,EAAa,OAAOG,CAAQ,CAEhC","names":["statsPerView","getSegmentsCount","viewId","getOrCreateReplayStats","addSegment","addRecord","addWroteData","additionalBytesCount","getReplayStats","getOrCreateReplayStats","viewId","statsPerView","replayStats","deleteOldestStats","toDelete"],"x_google_ignoreList":[0]}