(function(){"use strict";function k(f,L,y,x,i,u,N,z,E,U,m,o){const p=m*60/o,J=Math.floor(Date.now()/1e3),D=Math.floor(J/p)*p,_=D-m*60,d=new Array(o),w=new Array(o),A=new Array(o),I=new Array(o),R=new Array(o),W=new Float64Array(o),q=new Float64Array(o),O=new Uint32Array(o),F=new Array(o),G=new Array(o),M=new Array(o),X=new Array(o),h={},v={},g={},b={};let S=0,H=0,C=0;for(let t=0;t<o;t++){const n=_+t*p,e=n+p,a={bucket:t,start:n,end:e,count:0,airtime_ms:0,avg_snr:0,avg_rssi:0};d[t]={...a},w[t]={...a},A[t]={...a},I[t]={...a},R[t]={...a},F[t]=new Set,G[t]={start:n,end:e,bytesByType:{},totalBytes:0,countByType:{},totalCount:0},M[t]={start:n,end:e,bytesByType:{},totalBytes:0,countByType:{},totalCount:0},X[t]={start:n,end:e,bytesByType:{},totalBytes:0,countByType:{},totalCount:0}}const K=f.length;for(let t=0;t<K;t++){const n=f[t];if(n<_||n>D)continue;const e=Math.floor((n-_)/p);if(e<0||e>=o)continue;const a=L[t],B=i[t],V=u[t],j=N[t],s=x[t],c=y[t];if(B===1?(A[e].count++,A[e].airtime_ms+=a):B===2||V&&B!==1?(I[e].count++,I[e].airtime_ms+=a):j&&(R[e].count++,R[e].airtime_ms+=a),B!==1){d[e].count++,d[e].airtime_ms+=a,W[e]+=z[t],q[e]+=E[t],O[e]++;const r=U[t];F[e].has(r)||(F[e].add(r),w[e].count++,w[e].airtime_ms+=a);const l=G[e];l.bytesByType[s]=(l.bytesByType[s]??0)+c,l.totalBytes+=c,l.countByType[s]=(l.countByType[s]??0)+1,l.totalCount++,h[s]=(h[s]??0)+c,b[s]=(b[s]??0)+1,C+=c}if(B===2||V&&B!==1){const r=M[e];r.bytesByType[s]=(r.bytesByType[s]??0)+c,r.totalBytes+=c,r.countByType[s]=(r.countByType[s]??0)+1,r.totalCount++,v[s]=(v[s]??0)+c,S++}if(j){const r=X[e];r.bytesByType[s]=(r.bytesByType[s]??0)+c,r.totalBytes+=c,r.countByType[s]=(r.countByType[s]??0)+1,r.totalCount++,g[s]=(g[s]??0)+c,H++}}for(let t=0;t<o;t++)O[t]>0&&(d[t].avg_snr=W[t]/O[t],d[t].avg_rssi=q[t]/O[t]);const P=t=>Object.keys(t).map(n=>parseInt(n,10)).filter(n=>t[n]>0).sort((n,e)=>t[e]-t[n]),T=m/60;return{time_range_minutes:m,bucket_count:o,bucket_duration_seconds:p,start_time:_,end_time:D,received:d,unique_received:w,transmitted:A,forwarded:I,dropped:R,receivedBytesBuckets:G,receivedActiveTypes:P(h),receivedTotalByType:h,receivedCountByType:b,forwardedBytesBuckets:M,forwardedActiveTypes:P(v),forwardedTotalByType:v,forwardedRatePerHour:T>0?Math.round(S/T):0,totalForwardedCount:S,droppedBytesBuckets:X,droppedActiveTypes:P(g),droppedTotalByType:g,droppedRatePerHour:T>0?Math.round(H/T):0,totalDroppedCount:H,totalReceivedBytes:C,kbPerHour:T>0?Math.round(C/1024/T):0}}self.onmessage=f=>{const{type:L,payload:y}=f.data;if(L!=="compute")return;const x=performance.now();try{const i=k(y.timestamps,y.airtimeMs,y.byteSizes,y.payloadTypes,y.origins,y.transmitted,y.dropped,y.snrValues,y.rssiValues,y.hashIndices,y.rangeMinutes,y.bucketCount),u=performance.now()-x,N={type:"result",payload:i,computeTimeMs:u};self.postMessage(N)}catch(i){const u={type:"error",error:i instanceof Error?i.message:String(i)};self.postMessage(u)}}})();
