!function(){"use strict";const t=216e5;function e(t){return t?t.startsWith("0x")||t.startsWith("0X")?t.slice(2,4).toUpperCase():t.slice(0,2).toUpperCase():""}function n(t){if(!t)return null;if(Array.isArray(t))return t;if("string"==typeof t)try{const e=JSON.parse(t);return Array.isArray(e)?e:null}catch{return null}return null}self.onmessage=s=>{const{type:o,payload:r}=s.data;if("compute"!==o)return void self.postMessage({type:"error",error:`Unknown message type: ${o}`});const a=performance.now();try{const{packets:s,nodeHashes:o}=r,c=function(s,o){const r=Date.now(),a=r-6048e5,c=new Map;for(const t of o){const n=e(t);n&&(c.has(n)||c.set(n,new Set),c.get(n).add(t))}const f=new Map,i=new Map;for(const t of o)f.set(t,new Map),i.set(t,r);for(const l of s){const s=l.timestamp??0,o=s>1e12?s:1e3*s;if(o<a)continue;const r=new Set,p=n(l.forwarded_path??l.original_path);if(p&&p.length>0)for(const t of p){const e=String(t).toUpperCase();c.has(e)&&r.add(e)}if((!p||0===p.length)&&l.src_hash){const t=e(l.src_hash);c.has(t)&&r.add(t)}if(r.size>0){const e=Math.floor((o-a)/t),n=Math.max(0,Math.min(27,e));for(const t of r){const e=c.get(t);for(const t of e){const e=f.get(t);e.set(n,(e.get(n)||0)+1),o<i.get(t)&&i.set(t,o)}}}}const p=new Map;for(const e of o){const n=f.get(e),s=i.get(e);if(0===n.size){p.set(e,[]);continue}const o=Math.max(0,Math.floor((s-a)/t)),r=[];for(let e=o;e<28;e++)r.push({idx:e-o,count:n.get(e)||0,timestamp:a+e*t});p.set(e,r)}return p}(s,o),f=performance.now()-a,i={type:"result",payload:{sparklineEntries:Array.from(c.entries())},computeTimeMs:f,packetCount:s.length,nodeCount:o.length};self.postMessage(i)}catch(c){const t={type:"error",error:c instanceof Error?c.message:"Unknown error in sparkline worker"};self.postMessage(t)}}}();
