async function o(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("").slice(0,32)}function i(){try{const e=document.createElement("canvas");e.width=240,e.height=60;const t=e.getContext("2d");return t?(t.textBaseline="top",t.font="16px Arial",t.fillStyle="#f60",t.fillRect(0,0,240,60),t.fillStyle="#069",t.fillText("CBT-fp-1.0 ✓",4,12),t.fillStyle="rgba(102,204,0,0.7)",t.fillText("CBT-fp-1.0 ✓",6,16),e.toDataURL().slice(-128)):"no-canvas"}catch{return"canvas-error"}}let a=null;async function l(){var r,c;if(a)return a;const e=localStorage.getItem("cbt_fp");if(e&&/^[a-f0-9]{32}$/.test(e))return a=e,e;const t=[navigator.userAgent,navigator.language,`${screen.width}x${screen.height}x${screen.colorDepth}`,new Date().getTimezoneOffset().toString(),((r=navigator.hardwareConcurrency)==null?void 0:r.toString())??"?",((c=navigator.deviceMemory)==null?void 0:c.toString())??"?",i()],n=await o(t.join("|"));try{localStorage.setItem("cbt_fp",n)}catch{}return a=n,n}export{l as getDeviceFingerprint};
