UNPKG

@thumbmarkjs/thumbmarkjs

Version:

![GitHub package.json dynamic](https://img.shields.io/github/package-json/version/ilkkapeltola/thumbmarkjs) ![NPM Version](https://img.shields.io/npm/v/@thumbmarkjs/thumbmarkjs) ![NPM Downloads](https://img.shields.io/npm/dm/%40thumbmarkjs%2Fthumbmarkjs

3 lines (2 loc) 28.5 kB
const e=2592e5,t="thumbmark",n="https://api.thumbmarkjs.com",o={exclude:[],include:[],stabilize:["private","iframe"],logging:!0,timeout:5e3,cache_api_call:!0,cache_lifetime_in_ms:0,performance:!1,experimental:!1,property_name_factory:e=>`${t}_${e}`};let r={...o};function i(e,t){r[e]=t}const a={private:[{exclude:["canvas"],browsers:["firefox","safari>=17","brave"]},{exclude:["audio"],browsers:["samsungbrowser","safari"]},{exclude:["fonts"],browsers:["firefox"]},{exclude:["audio.sampleHash","hardware.deviceMemory","header.acceptLanguage.q","system.hardwareConcurrency","plugins"],browsers:["brave"]},{exclude:["tls.extensions"],browsers:["firefox","chrome","safari"]},{exclude:["header.acceptLanguage"],browsers:["edge","chrome"]}],iframe:[{exclude:["system.applePayVersion","system.cookieEnabled"],browsers:["safari"]},{exclude:["permissions"]}],vpn:[{exclude:["ip"]}]};function s(e){let t=0;for(let n=0;n<e.length;++n)t+=Math.abs(e[n]);return t}function c(e,t,n){let o=[];for(let t=0;t<e[0].data.length;t++){let n=[];for(let o=0;o<e.length;o++)n.push(e[o].data[t]);o.push(l(n))}const r=new Uint8ClampedArray(o);return new ImageData(r,t,n)}function l(e){if(0===e.length)return 0;const t={};for(const n of e)t[n]=(t[n]||0)+1;let n=e[0];for(const e in t)t[e]>t[n]&&(n=parseInt(e,10));return n}function u(e){return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),(e^=e>>>16)>>>0}const m=new Uint32Array([597399067,2869860233,951274213,2716044179]);function d(e,t){return e<<t|e>>>32-t}function h(e,t=0){var n;if(t=t?0|t:0,"string"==typeof e&&(n=e,e=(new TextEncoder).encode(n).buffer),!(e instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");const o=new Uint32Array([t,t,t,t]);!function(e,t){const n=e.byteLength/16|0,o=new Uint32Array(e,0,4*n);for(let e=0;e<n;e++){const n=o.subarray(4*e,4*(e+1));n[0]=Math.imul(n[0],m[0]),n[0]=d(n[0],15),n[0]=Math.imul(n[0],m[1]),t[0]=t[0]^n[0],t[0]=d(t[0],19),t[0]=t[0]+t[1],t[0]=Math.imul(t[0],5)+1444728091,n[1]=Math.imul(n[1],m[1]),n[1]=d(n[1],16),n[1]=Math.imul(n[1],m[2]),t[1]=t[1]^n[1],t[1]=d(t[1],17),t[1]=t[1]+t[2],t[1]=Math.imul(t[1],5)+197830471,n[2]=Math.imul(n[2],m[2]),n[2]=d(n[2],17),n[2]=Math.imul(n[2],m[3]),t[2]=t[2]^n[2],t[2]=d(t[2],15),t[2]=t[2]+t[3],t[2]=Math.imul(t[2],5)+2530024501,n[3]=Math.imul(n[3],m[3]),n[3]=d(n[3],18),n[3]=Math.imul(n[3],m[0]),t[3]=t[3]^n[3],t[3]=d(t[3],13),t[3]=t[3]+t[0],t[3]=Math.imul(t[3],5)+850148119}}(e,o),function(e,t){const n=e.byteLength/16|0,o=e.byteLength%16,r=new Uint32Array(4),i=new Uint8Array(e,16*n,o);switch(o){case 15:r[3]=r[3]^i[14]<<16;case 14:r[3]=r[3]^i[13]<<8;case 13:r[3]=r[3]^i[12],r[3]=Math.imul(r[3],m[3]),r[3]=d(r[3],18),r[3]=Math.imul(r[3],m[0]),t[3]=t[3]^r[3];case 12:r[2]=r[2]^i[11]<<24;case 11:r[2]=r[2]^i[10]<<16;case 10:r[2]=r[2]^i[9]<<8;case 9:r[2]=r[2]^i[8],r[2]=Math.imul(r[2],m[2]),r[2]=d(r[2],17),r[2]=Math.imul(r[2],m[3]),t[2]=t[2]^r[2];case 8:r[1]=r[1]^i[7]<<24;case 7:r[1]=r[1]^i[6]<<16;case 6:r[1]=r[1]^i[5]<<8;case 5:r[1]=r[1]^i[4],r[1]=Math.imul(r[1],m[1]),r[1]=d(r[1],16),r[1]=Math.imul(r[1],m[2]),t[1]=t[1]^r[1];case 4:r[0]=r[0]^i[3]<<24;case 3:r[0]=r[0]^i[2]<<16;case 2:r[0]=r[0]^i[1]<<8;case 1:r[0]=r[0]^i[0],r[0]=Math.imul(r[0],m[0]),r[0]=d(r[0],15),r[0]=Math.imul(r[0],m[1]),t[0]=t[0]^r[0]}}(e,o),function(e,t){t[0]=t[0]^e.byteLength,t[1]=t[1]^e.byteLength,t[2]=t[2]^e.byteLength,t[3]=t[3]^e.byteLength,t[0]=t[0]+t[1]|0,t[0]=t[0]+t[2]|0,t[0]=t[0]+t[3]|0,t[1]=t[1]+t[0]|0,t[2]=t[2]+t[0]|0,t[3]=t[3]+t[0]|0,t[0]=u(t[0]),t[1]=u(t[1]),t[2]=u(t[2]),t[3]=u(t[3]),t[0]=t[0]+t[1]|0,t[0]=t[0]+t[2]|0,t[0]=t[0]+t[3]|0,t[1]=t[1]+t[0]|0,t[2]=t[2]+t[0]|0,t[3]=t[3]+t[0]|0}(e,o);const r=new Uint8Array(o.buffer);return Array.from(r).map((e=>e.toString(16).padStart(2,"0"))).join("")}const p=280;async function f(e){for(var t;!document.body;)await g(50);const n=document.createElement("iframe");n.setAttribute("frameBorder","0");const o=n.style;o.setProperty("position","fixed"),o.setProperty("display","block","important"),o.setProperty("visibility","visible"),o.setProperty("border","0"),o.setProperty("opacity","0"),n.src="about:blank",document.body.appendChild(n);const r=n.contentDocument||(null===(t=n.contentWindow)||void 0===t?void 0:t.document);if(!r)throw new Error("Iframe document is not accessible");e({iframe:r}),setTimeout((()=>{document.body.removeChild(n)}),0)}function g(e,t){return new Promise((n=>setTimeout(n,e,t)))}const w=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],v=["monospace","sans-serif","serif"];function y(e,t){if(!e)throw new Error("Canvas context not supported");return e.font=`72px ${t}`,e.measureText("WwMmLli0Oo").width}function S(){var e;const t=document.createElement("canvas"),n=null!==(e=t.getContext("webgl"))&&void 0!==e?e:t.getContext("experimental-webgl");if(n&&"getParameter"in n)try{const e=(n.getParameter(n.VENDOR)||"").toString(),t=(n.getParameter(n.RENDERER)||"").toString();let o={vendor:e,renderer:t,version:(n.getParameter(n.VERSION)||"").toString(),shadingLanguageVersion:(n.getParameter(n.SHADING_LANGUAGE_VERSION)||"").toString()};if(!t.length||!e.length){const e=n.getExtension("WEBGL_debug_renderer_info");if(e){const t=(n.getParameter(e.UNMASKED_VENDOR_WEBGL)||"").toString(),r=(n.getParameter(e.UNMASKED_RENDERER_WEBGL)||"").toString();t&&(o.vendorUnmasked=t),r&&(o.rendererUnmasked=r)}}return o}catch(e){}return"undefined"}function b(){const e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}const E=(e,t,n,o)=>{const r=(n-t)/o;let i=0;for(let n=0;n<o;n++){i+=e(t+(n+.5)*r)}return i*r};function P(e,t){const n={};return t.forEach((t=>{const o=function(e){if(0===e.length)return null;const t={};e.forEach((e=>{const n=String(e);t[n]=(t[n]||0)+1}));let n=e[0],o=1;return Object.keys(t).forEach((e=>{t[e]>o&&(n=e,o=t[e])})),n}(e.map((e=>t in e?e[t]:void 0)).filter((e=>void 0!==e)));o&&(n[t]=o)})),n}const M=["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"];function x(){var e,t,n,o,r,i;if("undefined"==typeof navigator)return{name:"unknown",version:"unknown"};const a=navigator.userAgent,s=[/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>EdgA|EdgiOS|Edg)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>OPR|OPX)\/(?<version>\d+(?:\.\d+)+)/,/Opera[\s\/](?<version>\d+(?:\.\d+)+)/,/Opera Mini\/(?<version>\d+(?:\.\d+)+)/,/Opera Mobi\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Vivaldi)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Brave)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>CriOS)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>FxiOS)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Chrome|Chromium)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Firefox|Waterfox|Iceweasel|IceCat)\/(?<version>\d+(?:\.\d+)+)/,/Version\/(?<version1>[\d.]+).*Safari\/[\d.]+|(?<name>Safari)\/(?<version2>[\d.]+)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)+)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)+)/],c={edg:"Edge",edga:"Edge",edgios:"Edge",opr:"Opera",opx:"Opera",crios:"Chrome",fxios:"Firefox",samsung:"SamsungBrowser",vivaldi:"Vivaldi",brave:"Brave"};for(const l of s){const s=a.match(l);if(s){let a=null===(e=s.groups)||void 0===e?void 0:e.name,u=(null===(t=s.groups)||void 0===t?void 0:t.version)||(null===(n=s.groups)||void 0===n?void 0:n.version1)||(null===(o=s.groups)||void 0===o?void 0:o.version2);if(a||!(null===(r=s.groups)||void 0===r?void 0:r.version1)&&!(null===(i=s.groups)||void 0===i?void 0:i.version2)||(a="Safari"),!a&&l.source.includes("Opera Mini")&&(a="Opera Mini"),!a&&l.source.includes("Opera Mobi")&&(a="Opera Mobi"),!a&&l.source.includes("Opera")&&(a="Opera"),!a&&s[1]&&(a=s[1]),!u&&s[2]&&(u=s[2]),a){return{name:c[a.toLowerCase()]||a,version:u||"unknown"}}}}return{name:"unknown",version:"unknown"}}function C(){if("undefined"==typeof navigator||!navigator.userAgent)return!1;const e=navigator.userAgent;return/Mobi|Android|iPhone|iPod|IEMobile|Opera Mini|Opera Mobi|webOS|BlackBerry|Windows Phone/i.test(e)&&!/iPad/i.test(e)}function A(){let e=[];const t={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(t).forEach((n=>{t[n].forEach((t=>{matchMedia(`(${n}: ${t})`).matches&&e.push(`${n}: ${t}`)}))})),e}function _(){if("https:"===window.location.protocol&&"function"==typeof window.ApplePaySession)try{const e=window.ApplePaySession.supportsVersion;for(let t=15;t>0;t--)if(e(t))return t}catch(e){return 0}return 0}const I="SamsungBrowser"!==x().name?1:3;let T,R=null;function k(e){const t=[];return function e(n){if(n&&n.toJSON&&"function"==typeof n.toJSON&&(n=n.toJSON()),void 0===n)return;if("number"==typeof n)return isFinite(n)?""+n:"null";if("object"!=typeof n)return JSON.stringify(n);let o,r;if(Array.isArray(n)){for(r="[",o=0;o<n.length;o++)o&&(r+=","),r+=e(n[o])||"null";return r+"]"}if(null===n)return"null";if(-1!==t.indexOf(n))throw new TypeError("Converting circular structure to JSON");const i=t.push(n)-1,a=Object.keys(n).sort();for(r="",o=0;o<a.length;o++){const t=a[o],i=e(n[t]);i&&(r&&(r+=","),r+=JSON.stringify(t)+":"+i)}return t.splice(i,1),"{"+r+"}"}(e)||""}const O=["𝔄","𝔅","ℭ","𝔇","𝔈","𝔉","𝔸","𝔹","ℂ","𝔻","𝔼","𝔽"],L=["β","ψ","λ","ε","ζ","α","ξ","μ","ρ","φ","κ","τ","η","σ","ι","ω","γ","ν","χ","δ","θ","π","υ","ο"];function D(e,t){return`<math><mrow>${t}</mrow></math>`}function N(){let e="<mo>∏</mo>";return O.forEach(((t,n)=>{const o=2*n,r=L.slice(o,o+2);2===r.length&&(e+=`<mmultiscripts><mi>${t}</mi><none/><mi>${r[1]}</mi><mprescripts></mprescripts><mi>${r[0]}</mi><none/></mmultiscripts>`)})),D(0,`<munderover><mmultiscripts>${e}</mmultiscripts></munderover>`)}function B(){const e=[];return O.forEach(((t,n)=>{const o=2*n,r=L.slice(o,o+2);2===r.length&&e.push(D(0,`<mmultiscripts><mi>${t}</mi><none/><mi>${r[1]}</mi><mprescripts></mprescripts><mi>${r[0]}</mi><none/></mmultiscripts>`))})),e}const $={audio:async function(){return async function(){return new Promise(((e,t)=>{try{const t=44100,n=5e3,o=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,n,t),r=o.createBufferSource(),i=o.createOscillator();i.frequency.value=1e3;const a=o.createDynamicsCompressor();let c;a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,i.connect(a),a.connect(o.destination),i.start(),o.oncomplete=t=>{c=t.renderedBuffer.getChannelData(0),e({sampleHash:s(c),maxChannels:o.destination.maxChannelCount,channelCountMode:r.channelCountMode})},o.startRendering()}catch(e){console.error("Error creating audio fingerprint:",e),t(e)}}))}()},canvas:async function(){return new Promise((e=>{const t=Array.from({length:3},(()=>function(){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return new ImageData(1,1);e.width=p,e.height=20;const n=t.createLinearGradient(0,0,e.width,e.height);n.addColorStop(0,"red"),n.addColorStop(1/6,"orange"),n.addColorStop(2/6,"yellow"),n.addColorStop(.5,"green"),n.addColorStop(4/6,"blue"),n.addColorStop(5/6,"indigo"),n.addColorStop(1,"violet"),t.fillStyle=n,t.fillRect(0,0,e.width,e.height);const o="Random Text WMwmil10Oo";t.font="23.123px Arial",t.fillStyle="black",t.fillText(o,-5,15),t.fillStyle="rgba(0, 0, 255, 0.5)",t.fillText(o,-3.3,17.7),t.beginPath(),t.moveTo(0,0),t.lineTo(2*e.width/7,e.height),t.strokeStyle="white",t.lineWidth=2,t.stroke();const r=t.getImageData(0,0,e.width,e.height);return r}()));e({commonPixelsHash:h(c(t,p,20).data.toString()).toString()})}))},fonts:async function(e){return new Promise(((e,t)=>{try{f((async({iframe:t})=>{const n=t.createElement("canvas").getContext("2d"),o=v.map((e=>y(n,e)));let r={};w.forEach((e=>{const t=y(n,e);o.includes(t)||(r[e]=t)})),e(r)}))}catch(e){t({error:"unsupported"})}}))},hardware:function(){return new Promise(((e,t)=>{const n=void 0!==navigator.deviceMemory?navigator.deviceMemory:0,o=window.performance&&window.performance.memory?window.performance.memory:0;e({videocard:S(),architecture:b(),deviceMemory:n.toString()||"undefined",jsHeapSizeLimit:o.jsHeapSizeLimit||0})}))},locales:function(){return new Promise((e=>{e({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))},math:function(){return new Promise((e=>{e({acos:Math.acos(.5),asin:E(Math.asin,-1,1,97),cos:E(Math.cos,0,Math.PI,97),largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),sin:E(Math.sin,-Math.PI,Math.PI,97),tan:E(Math.tan,0,2*Math.PI,97)})}))},permissions:async function(e){const t=(null==e?void 0:e.permissions_to_check)||M;return P(await Promise.all(Array.from({length:3},(()=>async function(e){const t={};for(const n of e)try{const e=await navigator.permissions.query({name:n});t[n]=e.state.toString()}catch(e){}return t}(t)))),t)},plugins:async function(){const e=[];if(navigator.plugins)for(let t=0;t<navigator.plugins.length;t++){const n=navigator.plugins[t];e.push([n.name,n.filename,n.description].join("|"))}return new Promise((t=>{t({plugins:e})}))},screen:function(){return new Promise((e=>{const t={is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:A()};C()&&navigator.maxTouchPoints>0&&(t.resolution=function(){const e=window.screen.width,t=window.screen.height,n=Math.max(e,t).toString(),o=Math.min(e,t).toString();return`${n}x${o}`}()),e(t)}))},system:function(){return new Promise((e=>{const t=x();e({platform:window.navigator.platform,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:t.name,version:t.version},mobile:C(),applePayVersion:_(),cookieEnabled:window.navigator.cookieEnabled})}))},webgl:async function(){"undefined"!=typeof document&&(T=document.createElement("canvas"),T.width=200,T.height=100,R=T.getContext("webgl"));try{if(!R)throw new Error("WebGL not supported");const e=Array.from({length:I},(()=>function(){try{if(!R)throw new Error("WebGL not supported");const e="\n attribute vec2 position;\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n }\n ",t="\n precision mediump float;\n void main() {\n gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color\n }\n ",n=R.createShader(R.VERTEX_SHADER),o=R.createShader(R.FRAGMENT_SHADER);if(!n||!o)throw new Error("Failed to create shaders");if(R.shaderSource(n,e),R.shaderSource(o,t),R.compileShader(n),!R.getShaderParameter(n,R.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+R.getShaderInfoLog(n));if(R.compileShader(o),!R.getShaderParameter(o,R.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+R.getShaderInfoLog(o));const r=R.createProgram();if(!r)throw new Error("Failed to create shader program");if(R.attachShader(r,n),R.attachShader(r,o),R.linkProgram(r),!R.getProgramParameter(r,R.LINK_STATUS))throw new Error("Shader program linking failed: "+R.getProgramInfoLog(r));R.useProgram(r);const i=137,a=new Float32Array(4*i),s=2*Math.PI/i;for(let e=0;e<i;e++){const t=e*s;a[4*e]=0,a[4*e+1]=0,a[4*e+2]=Math.cos(t)*(T.width/2),a[4*e+3]=Math.sin(t)*(T.height/2)}const c=R.createBuffer();R.bindBuffer(R.ARRAY_BUFFER,c),R.bufferData(R.ARRAY_BUFFER,a,R.STATIC_DRAW);const l=R.getAttribLocation(r,"position");R.enableVertexAttribArray(l),R.vertexAttribPointer(l,2,R.FLOAT,!1,0,0),R.viewport(0,0,T.width,T.height),R.clearColor(0,0,0,1),R.clear(R.COLOR_BUFFER_BIT),R.drawArrays(R.LINES,0,2*i);const u=new Uint8ClampedArray(T.width*T.height*4);R.readPixels(0,0,T.width,T.height,R.RGBA,R.UNSIGNED_BYTE,u);return new ImageData(u,T.width,T.height)}catch(e){return new ImageData(1,1)}finally{R&&(R.bindBuffer(R.ARRAY_BUFFER,null),R.useProgram(null),R.viewport(0,0,R.drawingBufferWidth,R.drawingBufferHeight),R.clearColor(0,0,0,0))}}()));return{commonPixelsHash:h(c(e,T.width,T.height).data.toString()).toString()}}catch(e){return{webgl:"unsupported"}}}},V={webrtc:async function(){return new Promise((e=>{try{const t=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!t)return void e({supported:!1,error:"WebRTC not supported"});const n=new t({iceCandidatePoolSize:1,iceServers:[]});n.createDataChannel("");(async()=>{try{const t={offerToReceiveAudio:!0,offerToReceiveVideo:!0},o=await n.createOffer(t);await n.setLocalDescription(o);const r=o.sdp||"",i=[...new Set((r.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,""))))].sort(),a=e=>{const t=r.match(new RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(" "):[]},s=(e,t)=>t.map((t=>{const n=new RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,"g"),o=[...r.matchAll(n)];if(!o.length)return null;const i={};return o.forEach((t=>{const[n,o,r]=t,a=r.split("/");"rtpmap"===o?(i.mimeType=`${e}/${a[0]}`,i.clockRate=+a[1],"audio"===e&&(i.channels=+a[2]||1)):"rtcp-fb"===o?(i.feedbackSupport=i.feedbackSupport||[],i.feedbackSupport.push(r)):"fmtp"===o&&(i.sdpFmtpLine=r)})),i})).filter(Boolean),c=s("audio",a("audio")),l=s("video",a("video")),u={audio:{count:c.length,hash:h(k(c))},video:{count:l.length,hash:h(k(l))},extensionsHash:h(k(i))},m=await new Promise((e=>{const t=setTimeout((()=>{n.removeEventListener("icecandidate",o),n.close(),e({supported:!0,...u,timeout:!0})}),3e3),o=r=>{const i=r.candidate;i&&i.candidate&&(clearTimeout(t),n.removeEventListener("icecandidate",o),n.close(),e({supported:!0,...u,candidateType:i.type||""}))};n.addEventListener("icecandidate",o)}));e({details:m,hash:h(k(m))})}catch(t){n.close(),e({supported:!0,error:`WebRTC offer failed: ${t.message}`})}})()}catch(t){e({supported:!1,error:`WebRTC error: ${t.message}`})}}))},mathml:async function(){return new Promise((e=>{try{f((async({iframe:t})=>{try{if(!function(e){try{const t=e.createElement("math");t.innerHTML="<mrow><mi>x</mi></mrow>",t.style.position="absolute",t.style.visibility="hidden",e.body.appendChild(t);const n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch(e){return!1}}(t))return void e({supported:!1,error:"MathML not supported"});const n=[D("integral","<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>"),D("fraction","<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>"),D("matrix","<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>"),N(),...B()],o=[];let r="";n.forEach(((e,n)=>{const i=function(e,t){try{const n=t.createElement("math");n.innerHTML=e.replace(/<\/?math>/g,""),n.style.whiteSpace="nowrap",n.style.position="absolute",n.style.visibility="hidden",n.style.top="-9999px",t.body.appendChild(n);const o=n.getBoundingClientRect(),r=(t.defaultView||window).getComputedStyle(n),i={dimensions:{width:o.width,height:o.height},fontInfo:{fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontStyle:r.fontStyle,lineHeight:r.lineHeight,fontVariant:r.fontVariant||"normal",fontStretch:r.fontStretch||"normal",fontSizeAdjust:r.fontSizeAdjust||"none",textRendering:r.textRendering||"auto",fontFeatureSettings:r.fontFeatureSettings||"normal",fontVariantNumeric:r.fontVariantNumeric||"normal",fontKerning:r.fontKerning||"auto"}};return t.body.removeChild(n),i}catch(e){return{error:e.message}}}(e,t);o.push({width:i.dimensions.width,height:i.dimensions.height}),0===n&&i.fontInfo&&(r=h(k(i.fontInfo)))}));const i={fontStyleHash:r,dimensions:o};e({details:i,hash:h(k(i))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))},speech:async function(){return new Promise((e=>{try{if("undefined"==typeof window||!window.speechSynthesis||"function"!=typeof window.speechSynthesis.getVoices)return void e({supported:!1,error:"Speech Synthesis API not supported"});let t=!1,n=null;const o=o=>{if(!t){t=!0,n&&clearTimeout(n);try{const t=o.map((e=>{const t=e=>e.replace(/\\/g,"\\\\").replace(/,/g,"\\,");return[t(e.voiceURI||""),t(e.name||""),t(e.lang||""),e.localService?"1":"0",e.default?"1":"0"].join(",")}));t.sort();const n={voiceCount:o.length,voicesHash:h(k(t))};e({details:n,hash:h(k(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},r=window.speechSynthesis.getVoices();if(r.length>0)return void o(r);n=setTimeout((()=>{const e=window.speechSynthesis.getVoices();o(e)}),800);const i=()=>{window.speechSynthesis.removeEventListener("voiceschanged",i);const e=window.speechSynthesis.getVoices();o(e)};window.speechSynthesis.addEventListener("voiceschanged",i)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},F={},j={timeout:"true"},U=(e,t,n)=>{F[e]=t};function W(){return"1.6.1"}function H(e,t){var n;let o=x();if("unknown"===o.name&&e.system&&"object"==typeof e.system&&!Array.isArray(e.system)){const t=e.system.browser;if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;o={name:e.name||"unknown",version:e.version||"unknown"}}}const r=o.name.toLowerCase(),i=o.version.split(".")[0]||"0",s=parseInt(i,10),c=[...(null==t?void 0:t.exclude)||[]],l=(null==t?void 0:t.stabilize)||[],u=(null==t?void 0:t.include)||[];for(const e of l){const t=a[e];if(t)for(const e of t){const t=!("browsers"in e),o=!t&&(null===(n=e.browsers)||void 0===n?void 0:n.some((e=>{const t=e.match(/(.+?)(>=)(\d+)/);if(t){const[,e,,n]=t,o=parseInt(n,10);return r===e&&s>=o}return r===e})));(t||o)&&c.push(...e.exclude)}}return function e(t,n=""){const o={};for(const[r,i]of Object.entries(t)){const t=n?`${n}.${r}`:r;if("object"!=typeof i||Array.isArray(i)||null===i){const e=c.some((e=>t.startsWith(e))),n=u.some((e=>t.startsWith(e)));e&&!n||(o[r]=i)}else{const n=e(i,t);Object.keys(n).length>0&&(o[r]=n)}}return o}(e)}const G="visitor_id";function z(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(G)}const J=`${t}_${G}`;function K(e,t){try{localStorage.setItem(z(t),e)}catch(e){}}const Y="cache";function q(e){try{const t=localStorage.getItem(e.property_name_factory(Y)),n=JSON.parse(t);return n||{}}catch(e){}return{}}function X(t){return t.cache_lifetime_in_ms>e?Date.now()+e:Date.now()+t.cache_lifetime_in_ms}let Z=null,Q=null;const ee=(e,t)=>{if(e.cache_api_call){if(Q)return Promise.resolve(Q);const t=function(e){const t=q(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse;return}(e);if(t)return Promise.resolve(t)}if(Z)return Z;const o=`${e.api_endpoint||n}/thumbmark`,r=function(e){try{const t=z(e);let n=localStorage.getItem(t);return n||t===J||(n=localStorage.getItem(J),n&&K(n,e)),n}catch(e){return null}}(e),i={components:t,options:e,clientHash:h(k(t)),version:"1.6.1"};r&&(i.visitorId=r);const a=fetch(o,{method:"POST",headers:{"x-api-key":e.api_key,Authorization:"custom-authorized","Content-Type":"application/json"},body:JSON.stringify(i)}).then((e=>{if(!e.ok){if(403===e.status)throw new Error("INVALID_API_KEY");throw new Error(`HTTP error! status: ${e.status}`)}return e.json()})).then((t=>(t.visitorId&&t.visitorId!==r&&K(t.visitorId,e),Q=t,function(e,t){if(!e.cache_api_call||!e.cache_lifetime_in_ms)return;!function(e,t){const n={...q(e),...t};try{localStorage.setItem(e.property_name_factory(Y),JSON.stringify(n))}catch(e){}}(e,{apiResponseExpiry:X(e),apiResponse:t})}(e,t),Z=null,t))).catch((e=>{if(console.error("Error fetching pro data",e),Z=null,"INVALID_API_KEY"===e.message)throw e;return null})),s=e.timeout||5e3,c=new Promise((e=>{setTimeout((()=>{e({info:{timed_out:!0},version:"1.6.1"})}),s)}));return Z=Promise.race([a,c]),Z};async function te(e){var t;const r={...o,...e},i=r.logging&&!sessionStorage.getItem("_tmjs_l")&&Math.random()<1e-4,a={...$,...F},{elapsed:s,resolvedComponents:c}=await ne(a,r);let l={},u={};if(i||r.experimental){const{elapsed:e,resolvedComponents:t}=await ne(V,r);l=t,u=e}const m=r.api_key?ee(r,c):null;let d=null;if(m)try{d=await m}catch(e){if(e instanceof Error&&"INVALID_API_KEY"===e.message)return{error:"Invalid API key or quota exceeded",components:{},info:{},version:"1.6.1",thumbmark:""};throw e}const p={...s,...u},f=r.performance?{elapsed:p}:{},g=H((null==d?void 0:d.components)||{},r),w={...c,...g},v=(null==d?void 0:d.info)||{uniqueness:{score:"api only"}},y=null!==(t=null==d?void 0:d.thumbmark)&&void 0!==t?t:h(k(w));i&&async function(e,t,o,r={}){var i;const a=`${n}/log`,s={thumbmark:e,components:t,experimental:r,version:"1.6.1",options:o,path:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.pathname};sessionStorage.setItem("_tmjs_l","1");try{await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(e){}}(y,w,r,l).catch((()=>{}));return{...(null==d?void 0:d.visitorId)&&{visitorId:d.visitorId},thumbmark:y,components:w,info:v,version:"1.6.1",...f,...Object.keys(l).length>0&&r.experimental&&{experimental:l}}}async function ne(e,t){const n={...o,...t},r=Object.entries(e).filter((([e])=>{var t;return!(null===(t=null==n?void 0:n.exclude)||void 0===t?void 0:t.includes(e))})).filter((([e])=>{var t,o,r,i;return(null===(t=null==n?void 0:n.include)||void 0===t?void 0:t.some((e=>e.includes("."))))?null===(o=null==n?void 0:n.include)||void 0===o?void 0:o.some((t=>t.startsWith(e))):0===(null===(r=null==n?void 0:n.include)||void 0===r?void 0:r.length)||(null===(i=null==n?void 0:n.include)||void 0===i?void 0:i.includes(e))})),i=r.map((([e])=>e)),a=r.map((([e,n])=>n(t))),s=await function(e,t,n){return Promise.all(e.map((e=>{const o=performance.now();return Promise.race([e.then((e=>({value:e,elapsed:performance.now()-o}))),(r=t,i=n,new Promise((e=>{setTimeout((()=>e(i)),r)}))).then((e=>({value:e,elapsed:performance.now()-o})))]);var r,i})))}(a,(null==n?void 0:n.timeout)||5e3,j),c={},l={};s.forEach(((e,t)=>{var n;null!=e.value&&(l[i[t]]=e.value,c[i[t]]=null!==(n=e.elapsed)&&void 0!==n?n:0)}));const u=H(l,n);return{elapsed:c,resolvedComponents:u}}async function oe(){return(await te(r)).components}async function re(e){try{const t=await te(r);return e?{hash:t.thumbmark.toString(),data:t.components}:t.thumbmark.toString()}catch(e){throw e}}async function ie(){try{const{elapsed:e,resolvedComponents:t}=await ne($,r);return{...t,elapsed:e}}catch(e){throw e}}class ae{constructor(e){this.options={...o,...e}}async get(e){return te({...this.options,...e})}getVersion(){return"1.6.1"}includeComponent(e,t){U(e,t)}}export{ae as Thumbmark,H as filterThumbmarkData,re as getFingerprint,oe as getFingerprintData,ie as getFingerprintPerformance,te as getThumbmark,W as getVersion,U as includeComponent,i as setOption,a as stabilizationExclusionRules,k as stableStringify}; //# sourceMappingURL=thumbmark.esm.js.map