export interface MapPoint {x:number;y:number} export function fitNetworkMapCamera(points:readonly MapPoint[],width:number,height:number) { const valid=points.filter(p=>Number.isFinite(p.x)&&Number.isFinite(p.y)) if(!valid.length||width<=0||height<=0)return {pan:{x:0,y:0},zoom:1} const xs=valid.map(p=>p.x),ys=valid.map(p=>p.y),left=Math.min(...xs)-120,right=Math.max(...xs)+120,top=Math.min(...ys)-100,bottom=Math.max(...ys)+100 const zoom=Math.max(.2,Math.min(3,width/(right-left),height/(bottom-top))) return {pan:{x:(left+right)/2-width/(2*zoom),y:(top+bottom)/2-height/(2*zoom)},zoom} }