!function(){"use strict";self.onmessage=e=>{const{type:t,payload:o}=e.data;if("compute"!==t)return;const r=performance.now();try{const e=function(e,t,o,r,s,n,a){const l=e.length;if(0===l)return null;const c=new Uint32Array(l),f=new Int32Array(l);let i=0;for(let U=0;U<l;U++){const t=e[U];t>=s&&t<=n&&o[U]>0&&(c[i]=U,f[i]=Math.floor((t-s)/300),i++)}if(0===i)return null;const p=new Map;for(let U=0;U<i;U++){const e=f[U];let t=p.get(e);t||(t=[],p.set(e,t)),t.push(U)}const u=new Float64Array(i);if("share"===a)for(let U=0;U<i;U++)u[U]=o[c[U]];else for(const[,U]of p){let e=0,o=0;for(const s of U){const r=t[c[s]];e+=r,r>o&&(o=r)}const r=e/3e5*100;if(o>0)for(const s of U)u[s]=t[c[s]]/o*r}let m=e[c[0]],y=e[c[0]];for(let U=1;U<i;U++){const t=e[c[U]];t<m&&(m=t),t>y&&(y=t)}const M=n-s||1,w=new Float64Array(i);for(let U=0;U<i;U++)w[U]=u[U];w.sort();const h=w[0],g=w[i-1],A=w[Math.floor(.05*i)],T=w[Math.floor(.5*i)],V=w[Math.min(Math.ceil(.95*i),i-1)],d=new Map;for(let U=0;U<i;U++){const e=Math.round(100*u[U])/100;d.set(e,(d.get(e)??0)+1)}const b=d.size,F=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/i*100}));let k;if("share"===a)k=200;else{const e=5,t=Math.ceil(g/e)*e;k=t<=10?10:t+e}const x=new Float32Array(2*i),v=new Float32Array(i),z=new Uint8Array(i),S=new Float32Array(i);for(let U=0;U<i;U++){const t=c[U],o=(e[t]-s)/M,n=1-Math.max(0,Math.min(k,u[U]))/k;x[2*U]=o,x[2*U+1]=n,v[U]=u[U],z[U]=r[t]<255?r[t]:255,S[U]=e[t]}return{points:x,rawValues:v,packetTypes:z,timestamps:S,count:i,minTime:m,maxTime:y,minValue:0,maxValue:k,rawMinValue:h,rawMaxValue:g,p5:A,p50:T,p95:V,uniqueValues:b,topValues:F}}(o.timestamps,o.airtimeMs,o.byteSizes,o.packetTypes,o.startTs,o.endTs,o.mode);if(!e){const e={type:"error",error:"No packets in time range"};return void self.postMessage(e)}const t={type:"result",payload:e,computeTimeMs:performance.now()-r},s=[e.points.buffer,e.rawValues.buffer,e.packetTypes.buffer,e.timestamps.buffer];self.postMessage(t,s)}catch(s){const e={type:"error",error:s instanceof Error?s.message:String(s)};self.postMessage(e)}}}();
