import{gL as L,dw as w,bP as y,O as g}from"./index-BuFgUdF6.js";function A(r){if(Array.isArray(r))return r;if(typeof r=="string"&&r.startsWith("["))try{const s=JSON.parse(r);return Array.isArray(s)?s:[]}catch{return[]}return[]}function C(r,s,x){const M=L(Array.from(s,t=>[t,t])),c=new Map,i=new Map;for(const t of r){const p=t.route??t.route_type;if(!w(p))continue;const a=A(t.original_path);if(a.length===0)continue;const o=a.map(e=>e.toUpperCase());if(!t.transmitted&&o.length>=2){const e=o[o.length-2];if(e){const n=M.get(e);n&&i.set(n,(i.get(n)??0)+1)}}if(o.some(e=>y(e,x)))for(const e of o){if(e===x)continue;const n=M.get(e);n&&c.set(n,(c.get(n)??0)+1)}}let u=0,f=0;for(const t of s)u=Math.max(u,c.get(t)??0),f=Math.max(f,i.get(t)??0);const S=new Map;let h=0,m=0,d=0;for(const t of s){const p=c.get(t)??0,a=i.get(t)??0,o=u>0?Math.round(p/u*100):0,l=f>0?Math.round(a/f*100):0,e=o+l;S.set(t,{hash:t,listenerCount:p,loudCount:a,listenerScore:o,loudScore:l,blendedScore:e}),h=Math.max(h,o),m=Math.max(m,l),d=Math.max(d,e)}return{scores:S,maxListenerScore:h,maxLoudScore:m,maxBlendedScore:d}}const O={YELLOW:g.amber,GREEN:g.green,RED:g.red,GRAY:"#505050"};export{O as L,C as c};
