globalThis.PerformanceDetectManager=globalThis.PerformanceDetectManager||{},globalThis.PerformanceDetectManager.requestAvailability=()=>(globalThis.PerformanceDetectManager.instance||(globalThis.PerformanceDetectManager.instance=globalThis.document.createElement("performance-detect"),globalThis.document.body.appendChild(globalThis.PerformanceDetectManager.instance)),globalThis.PerformanceDetectManager.instance);export const DeviceDetails=globalThis.PerformanceDetectManager.requestAvailability();class PerformanceDetect extends HTMLElement{constructor(){super(),this.details=this.updateDetails()}static get tag(){return"performance-detect"}async badDevice(){for(const[e,t]of Object.entries(await this.details))if(t)return!0;return!1}getDetails(e=null){switch(e){case"memory":return this.details.lowMemory;case"processor":return this.details.lowProcessor;case"battery":return this.details.lowBattery;case"connection":return this.details.poorConnection;case"data":return this.details.dataSaver}return this.details}async updateDetails(){let e={lowMemory:!1,lowProcessor:!1,lowBattery:!1,poorConnection:!1,dataSaver:!1};return navigator&&(navigator.deviceMemory&&globalThis.navigator.deviceMemory<1&&(e.lowMemory=!0),navigator.hardwareConcurrency&&globalThis.navigator.hardwareConcurrency<2&&(e.lowProcessor=!0),navigator.getBattery&&globalThis.navigator.getBattery().then((function(t){!t.charging&&t.level<.25&&(e.lowBattery=!0)})),globalThis.navigator.connection&&globalThis.navigator.connection.effectiveType&&["slow-2g","2g","3g"].includes(navigator.connection.effectiveType)&&(e.poorConnection=!0),navigator.connection&&globalThis.navigator.connection.saveData&&(e.dataSaver=!0)),e}}customElements.define(PerformanceDetect.tag,PerformanceDetect);export{PerformanceDetect};