osmgl 0.31.85 → 0.31.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +0,0 @@
1
- import {bf,ja,fa as fa$1,H as H$1,ef,Yd}from'./chunk-OCA36U5D.js';import*as zr from'polygon-clipping';var Oo=100,Xo=50,Yo=30,To=12e3,Do=60,ce=3,Bo=1e4,Ho=1e3,$o=2e3;function An(t){return t.provider==="network"?true:t.provider==="gps"||t.provider==="fused"?false:t.accuracyM!=null&&t.accuracyM>Yo}var At=t=>t.accuracyM!=null&&t.accuracyM>0?t.accuracyM:null,Me=t=>t.ageMs!=null&&t.ageMs>Bo,En=t=>t&&t.speedMps!=null&&t.speedMps>=0?t.speedMps:0;function me(t,n){let e=Math.max((n.timeMs-t.timeMs)/1e3,.001);return fa$1(t.pos,n.pos)<=Math.max(Do,1.5*En(t)+15)*e+(At(t)??0)+(At(n)??0)}var Pn=class{constructor(){this.last=null;this.lastGpsMs=-1/0;this.rejects=0;this.pending=null;this.norm=null;this.staleRun=0;this.staleLastMs=-1/0;this.streams=new Map;}skewMs(n){return this.streams.get(n??"?")?.skew??0}normalize(n){let e=n.ageMs;if(e==null||!Number.isFinite(e))return n;let o=n.provider??"?",r=this.streams.get(o);if(!r)r={timeMs:n.timeMs,ageMs:e,minAge:e,skew:0},this.streams.set(o,r);else {let s=n.timeMs-r.timeMs;s>0&&Math.abs(e-r.ageMs)<=Math.min(Ho,s/2)?(r.minAge=Math.min(r.minAge,e),r.skew=r.minAge>$o?r.minAge:0):r.minAge=e,r.timeMs=n.timeMs,r.ageMs=e;}let i=Math.min(r.skew,Math.max(0,e));return i>0?{...n,timeMs:n.timeMs+i,ageMs:e-i}:n}accept(n){let e=this.normalize(n);this.norm=e;let o=this.last,r=An(e),i=Me(e);o&&e.timeMs<=o.timeMs&&!i?(this.staleRun=e.timeMs>this.staleLastMs?this.staleRun+1:1,this.staleLastMs=e.timeMs,this.staleRun>=ce&&(this.last=o=null,this.lastGpsMs=-1/0,this.pending=null,this.rejects=0)):i||(this.staleRun=0);let s=e.timeMs-this.lastGpsMs<To,a=At(e),u="ok";if(o&&e.timeMs<=o.timeMs||i)u="stale";else if(r&&s)u="network";else if(s&&a!=null&&a>Oo)u="inaccurate";else if(o&&!r&&An(o))u="ok";else if(o){let l=(e.timeMs-o.timeMs)/1e3,c=At(o),m=Math.max(5,(En(e)+En(o))/2);s&&a!=null&&c!=null&&a>c+m*l?u="worse":me(o,e)||(u="jump");}if(u!=="ok"&&u!=="stale"&&u!=="network"){let l=this.pending;r&&l!=null&&!An(l)||(this.rejects=l&&e.timeMs>l.timeMs&&me(l,e)?this.rejects+1:1,this.pending=e,this.rejects>=ce&&(u="ok"));}return u==="ok"&&(this.last=e,this.rejects=0,this.pending=null,this.staleRun=0,r||(this.lastGpsMs=e.timeMs)),u}reset(){this.last=null,this.lastGpsMs=-1/0,this.rejects=0,this.pending=null,this.norm=null,this.staleRun=0,this.staleLastMs=-1/0,this.streams.clear();}},Go=80,Vo=150,jo=3,Ko=50,Uo=2,Wo=60,zo=25,qo=10,Zo=3,Jo=15,Qo=5e3;function he(t,n){let e=0,o=t.cum.length-1;for(;e+1<o;){let r=e+o>>1;t.cum[r]<=n?e=r:o=r;}return e}function fe(t,n,e,o){let r={dist:Math.max(0,e),off:1/0};if(t.coords.length<2)return r;let i=Math.max(0,he(t,Math.max(0,e))),s=Math.min(t.coords.length-2,he(t,Math.min(t.total,o)));for(let a=i;a<=s;a++){let u=ja(n,t.coords[a],t.coords[a+1],t.lat0),l=t.cum[a]+(t.cum[a+1]-t.cum[a])*u.t,c=Math.max(e,Math.min(o,l)),m=c===l?u.off:fa$1(n,t.positionAt(c));m<r.off&&(r={off:m,dist:c});}return r}var be=class{constructor(){this.dist=null;this.last=null;this.back=0;this.jumps=0;this.accurateMs=-1/0;}update(n,e){let o=At(e)??0,r=this.dist,i=this.last,s=i?Math.max(0,(e.timeMs-i.timeMs)/1e3):0,a=e.speedMps!=null&&e.speedMps>=0?e.speedMps:null,u,l,c=(Math.max(a??0,10)+10)*Math.max(s,1)*1.5+o+30;if(r==null)u=n.snap(e.pos,null);else {let b=r-Math.max(Go,o),d=Math.max(a??0,Zo)*Math.max(s,1)*1.5+o+Jo;u=fe(n,e.pos,b,r+d);let M=Vo+Math.max(a??0,10)*Math.min(s,10)*1.5;if(M>d){let g=fe(n,e.pos,b,r+M);g.off+qo<u.off&&(u=g);}}l=u.off;let m=o>Xo;if(r!=null&&u.off>Wo&&!m){let b=n.snap(e.pos,null);b.off<u.off&&(l=b.off,b.off<=Math.max(zo,o)&&(u=b));}if(m&&r!=null&&e.timeMs-this.accurateMs<Qo)return {dist:r,off:Math.max(0,l-o),speedMps:a??0,reversed:false};m||(this.accurateMs=e.timeMs);let h=u.dist,f=false;r!=null&&(m&&h<r?h=r:h<r?(this.jumps=0,r-h>=Ko?++this.back>=jo?(f=true,this.back=0):h=r:(this.back=0,h=r)):h-r>c?(this.back=0,++this.jumps<Uo?h=r:this.jumps=0):(this.back=0,this.jumps=0));let p=a??(r!=null&&s>0?Math.max(0,h-r)/s:0);return this.dist=h,this.last=e,{dist:h,off:l,speedMps:p,reversed:f}}reset(){this.dist=null,this.last=null,this.back=0,this.jumps=0,this.accurateMs=-1/0;}},pe=200,tr=1500,nr=500,er=.5,or=3,rr=15,de=class{constructor(){this.filter=new Pn;this.fix=null;this.provisional=false;this.from=null;this.t0=0;this.dur=0;this.lastPushMs=-1/0;this.held=false;}push(n,e){this.held=false;let o=this.filter.accept(n),r=o==="stale"&&this.fix==null&&Me(this.filter.norm??n);if(o!=="ok"&&!r)return false;let i=this.fix;if(i&&!this.provisional&&n.speedMps!=null&&n.speedMps>=0&&n.speedMps<er&&fa$1(i.pos,n.pos)<=Math.min(rr,Math.max(or,At(n)??0)))return this.held=true,false;let s=this.at(e),a=e-this.lastPushMs;return this.from=s,this.dur=s==null||this.provisional||fa$1(s,n.pos)>nr?0:Math.min(tr,Math.max(pe,Number.isFinite(a)?a:pe)),this.t0=e,this.fix=n,this.provisional=r,this.lastPushMs=e,true}at(n){let e=this.fix;if(!e)return null;let o=this.from;if(!o||this.dur<=0)return e.pos;let r=Math.min(1,Math.max(0,(n-this.t0)/this.dur));return [o[0]+(e.pos[0]-o[0])*r,o[1]+(e.pos[1]-o[1])*r]}get glideMs(){return this.dur}moving(n){return this.fix!=null&&this.dur>0&&n-this.t0<this.dur}reset(){this.filter.reset(),this.fix=null,this.provisional=false,this.from=null,this.dur=0,this.lastPushMs=-1/0,this.held=false;}};var sr=["arrow","arrow3d","sedan","pickup","suv"],Hs={arrow:"Стрелка",arrow3d:"3D-стрелка",sedan:"Седан",pickup:"Пикап",suv:"Внедорожник"};function $s(t){let n=(t||"").trim().toLowerCase();return sr.includes(n)?n:"arrow"}var kn={minPx:52,lift:.02,chamfer:.12},Yn={sedan:{length:4.6,width:.9,clearance:.26,color:"#d93a30",sections:[[0,.8,.62,.7,.66],[.14,.9,.8,.82,.84],[1.2,.9,.92,.8,.97],[2,.87,.96,.64,1.42],[2.52,.87,.96,.64,1.43],[2.62,.87,.96,.64,1.43],[3.05,.87,.96,.64,1.41],[3.8,.9,.98,.8,1.04],[4.46,.9,.96,.8,1],[4.6,.82,.8,.72,.84]],segs:"BBWRPRWBB",wheel:{r:.33,w:.22,axles:[.88,3.72]}},pickup:{length:5.3,width:.95,clearance:.36,color:"#2f9e4f",sections:[[0,.86,.8,.8,.84],[.14,.95,1,.88,1.04],[1.45,.95,1.1,.88,1.15],[2.08,.93,1.14,.74,1.8],[2.46,.93,1.14,.74,1.81],[2.56,.93,1.14,.74,1.81],[2.86,.93,1.14,.74,1.79],[2.9,.94,1.14,.8,1.22],[2.94,.95,1.14,.85,.74],[5.16,.95,1.14,.85,.74],[5.22,.95,1.12,.88,1.12],[5.3,.88,1,.82,1.02]],segs:"BBWRPRWDDDB",wheel:{r:.4,w:.26,axles:[1,4.32]}},suv:{length:4.8,width:.95,clearance:.32,color:"#f2b51d",sections:[[0,.86,.78,.8,.82],[.14,.95,.98,.88,1.02],[1.05,.95,1.06,.88,1.1],[1.78,.93,1.1,.8,1.72],[2.52,.93,1.1,.8,1.73],[2.62,.93,1.1,.8,1.73],[3.52,.93,1.1,.8,1.72],[3.62,.93,1.1,.8,1.72],[4.56,.93,1.1,.8,1.7],[4.72,.95,1.04,.88,1.1],[4.8,.88,.92,.82,.96]],segs:"BBWRPRPRWB",wheel:{r:.38,w:.25,axles:[.86,3.96]},rails:[2,4.3,.62,.07]}},Tt={length:3.5,outer:[[0,-2.2515],[1.7775,2.0145],[0,1.0072],[-1.7775,2.0145]],corners:[[.14,.14,.3846],[.1623,.367,.325],[.157,.157,.87],[.367,.1623,.325]],steps:8,base:.03,wall:.3,rim:[.14,.1],dome:[.1,.22],crown:.12,center:[0,.1],arc:[[1,0],[.96,.28],[.8,.6],[.6,.8],[.28,.96],[0,1]]},Sn={day:{high:"#3f7dff",top:"#2f6bff",low:"#2050d8",bevel:"#ffffff",side:"#1a3f9e"},night:{high:"#2c5ab8",top:"#2450b0",low:"#1c4098",bevel:"#e8eefc",side:"#163478",highGlow:[.24,.38,.5],topGlow:[.22,.36,.52],lowGlow:[.18,.32,.52],bevelGlow:[.36,.38,.44],sideGlow:[.13,.24,.5]}},Nn=[{name:"body",color:[0,0,0,1],metallic:0,roughness:.55},{name:"glass",color:[.1,.14,.19,1],metallic:0,roughness:.18},{name:"trim",color:[.13,.14,.16,1],metallic:0,roughness:.8},{name:"bed",color:[.22,.23,.25,1],metallic:0,roughness:.9},{name:"tire",color:[.09,.095,.1,1],metallic:0,roughness:.95},{name:"hub",color:[.74,.76,.79,1],metallic:0,roughness:.4},{name:"head",color:[1,.97,.86,1],metallic:0,roughness:.3,emissive:[.8,.76,.6]},{name:"tail",color:[.82,.1,.1,1],metallic:0,roughness:.3,emissive:[.45,.03,.03]},{name:"shadow",color:[0,0,0,.26],metallic:0,roughness:1,blend:true},{name:"shadow-soft",color:[0,0,0,.12],metallic:0,roughness:1,blend:true}];function Fn(t){let n=parseInt(t.slice(1),16);return [(n>>16&255)/255,(n>>8&255)/255,(n&255)/255,1]}function ir(){let t=Math.sqrt(3)/2;return [[0,1],[.5,t],[t,.5],[1,0],[t,-0.5],[.5,-t],[0,-1],[-0.5,-t],[-t,-0.5],[-1,0],[-t,.5],[-0.5,t]]}function ar(t){let n=(e,o,r,i)=>i?{name:e,color:Fn(o),metallic:0,roughness:r,emissive:i}:{name:e,color:Fn(o),metallic:0,roughness:r};return [n("top-high",t.high,.22,t.highGlow),n("top",t.top,.2,t.topGlow),n("top-low",t.low,.25,t.lowGlow),n("bevel",t.bevel,.3,t.bevelGlow),n("side",t.side,.35,t.sideGlow),Nn[8],Nn[9]]}var qt=class{constructor(n){this.parts=n.map(e=>({material:e,positions:[],normals:[]}));}part(n){for(let e of this.parts)if(e.material.name===n)return e;throw new Error(`nav-car: нет материала ${n}`)}tri(n,e,o,r,i){let s=o[0]-e[0],a=o[1]-e[1],u=o[2]-e[2],l=r[0]-e[0],c=r[1]-e[1],m=r[2]-e[2],h=a*m-u*c,f=u*l-s*m,p=s*c-a*l,b=Math.sqrt(h*h+f*f+p*p);if(b<1e-9)return;h/=b,f/=b,p/=b;let d=o,M=r;h*i[0]+f*i[1]+p*i[2]<0&&(d=r,M=o,h=-h,f=-f,p=-p);let g=this.part(n);for(let x of [e,d,M])g.positions.push(x[0],x[1],x[2]),g.normals.push(h,f,p);}quad(n,e,o,r,i,s,a=false){a?(this.tri(n,e,o,i,s),this.tri(n,o,r,i,s)):(this.tri(n,e,o,r,s),this.tri(n,e,r,i,s));}triN(n,e,o,r,i,s,a){let u=o[0]-e[0],l=o[1]-e[1],c=o[2]-e[2],m=r[0]-e[0],h=r[1]-e[1],f=r[2]-e[2],p=l*f-c*h,b=c*m-u*f,d=u*h-l*m;if(Math.sqrt(p*p+b*b+d*d)<1e-9)return;let g=i[0]+s[0]+a[0],x=i[1]+s[1]+a[1],L=i[2]+s[2]+a[2],R=o,_=r,v=s,S=a;p*g+b*x+d*L<0&&(R=r,_=o,v=a,S=s);let k=this.part(n);for(let[N,X]of [[e,i],[R,v],[_,S]])k.positions.push(N[0],N[1],N[2]),k.normals.push(X[0],X[1],X[2]);}quadN(n,e,o,r,i,s,a,u,l,c){c?(this.triN(n,e,o,i,s,a,l),this.triN(n,o,r,i,a,u,l)):(this.triN(n,e,o,r,s,a,u),this.triN(n,e,r,i,s,u,l));}fan(n,e,o){let r=0,i=0,s=0;for(let l of e)r+=l[0],i+=l[1],s+=l[2];let a=e.length,u=[r/a,i/a,s/a];for(let l=0;l<a;l++)this.tri(n,u,e[l],e[(l+1)%a],o);}box(n,e,o,r,i,s,a){let u=(l,c,m)=>[l,c,m];this.quad(n,u(e,o,r),u(i,o,r),u(i,o,a),u(e,o,a),[0,-1,0]),this.quad(n,u(e,s,r),u(i,s,r),u(i,s,a),u(e,s,a),[0,1,0]),this.quad(n,u(e,o,r),u(e,s,r),u(e,s,a),u(e,o,a),[-1,0,0]),this.quad(n,u(i,o,r),u(i,s,r),u(i,s,a),u(i,o,a),[1,0,0]),this.quad(n,u(e,o,r),u(i,o,r),u(i,s,r),u(e,s,r),[0,0,-1]),this.quad(n,u(e,o,a),u(i,o,a),u(i,s,a),u(e,s,a),[0,0,1]);}};function ur(t,n){let[,e,o,r,i]=n,s=t.clearance,a=kn.chamfer;return [[-e*.9,s],[e*.9,s],[e,s+a],[e,o],[r,i],[-r,i],[-e,o],[-e,s+a]]}function lr(t,n){return n===0?"trim":n===3||n===5?t==="W"||t==="R"?"glass":t==="D"?"bed":"body":n===4?t==="W"?"glass":t==="D"?"bed":"body":"body"}function cr(t){let n=Yn[t],e=Fn(n.color),o=new qt(Nn.map(g=>g.name==="body"?{...g,color:e}:g)),r=n.length/2,i=n.sections,s=i.map(g=>ur(n,g)),a=(g,x)=>[s[g][x][0],s[g][x][1],i[g][0]-r];for(let g=0;g+1<i.length;g++){let x=n.segs[g];for(let L=0;L<8;L++){let R=(L+1)%8,_=s[g][R][0]-s[g][L][0],v=s[g][R][1]-s[g][L][1];Math.abs(_)+Math.abs(v)<1e-9&&(_=s[g+1][R][0]-s[g+1][L][0],v=s[g+1][R][1]-s[g+1][L][1]),o.quad(lr(x,L),a(g,L),a(g,R),a(g+1,R),a(g+1,L),[v,-_,0],L>=5);}}let u=i.length-1;o.fan("body",s[0].map((g,x)=>a(0,x)),[0,0,-1]),o.fan("body",s[u].map((g,x)=>a(u,x)),[0,0,1]);let l=i[0],c=i[u],m=l[2]-.1,h=c[2]-.1;for(let g of [-1,1]){let x=g*(l[1]-.26);o.box("head",x-.15,m-.05,-r-.02,x+.15,m+.05,-r+.06);let L=g*(c[1]-.2);o.box("tail",L-.14,h-.05,r-.06,L+.14,h+.05,r+.02);}if(n.rails){let[g,x,L,R]=n.rails,_=0;for(let v of i)v[0]>=g&&v[0]<=x&&(_=Math.max(_,v[4]));for(let v of [-1,1])o.box("trim",v*L-.03,_-.01,g-r,v*L+.03,_+R,x-r);}let f=ir(),{r:p,w:b,axles:d}=n.wheel;for(let g of d){let x=g-r;for(let L of [-1,1]){let R=L*(n.width+.03),_=L*(n.width+.03-b),v=(k,N,X)=>[k,p+X*f[N%12][0],x+X*f[N%12][1]];for(let k=0;k<12;k++){let N=[0,f[k][0]+f[(k+1)%12][0],f[k][1]+f[(k+1)%12][1]];o.quad("tire",v(_,k,p),v(R,k,p),v(R,k+1,p),v(_,k+1,p),N);}let S=[L,0,0];o.fan("tire",Array.from({length:12},(k,N)=>v(R,N,p)),S),o.fan("hub",Array.from({length:12},(k,N)=>v(R+L*.012,N,p*.55)),S);}}let M=(g,x,L,R,_)=>{let v=[[L-_,x,-R],[L,x,-R+_],[L,x,R-_],[L-_,x,R],[-L+_,x,R],[-L,x,R-_],[-L,x,-R+_],[-L+_,x,-R]];o.fan(g,v,[0,1,0]);};return M("shadow-soft",.012,n.width+.3,r+.34,.5),M("shadow",.02,n.width+.1,r+.12,.3),o}function Le(){let t=Tt,n=t.outer,e=t.steps,o=[];for(let a=0;a<4;a++){let[u,l,c]=t.corners[a],m=n[a],h=n[(a+3)%4],f=n[(a+1)%4],p=m[0]+(h[0]-m[0])*u,b=m[1]+(h[1]-m[1])*u,d=m[0]+(f[0]-m[0])*l,M=m[1]+(f[1]-m[1])*l;for(let g=0;g<=e;g++){let x=g/e,L=1-x,R=L*L,_=x*x,v=2*c*(x*L),S=R+_+v;o.push([(R*p+_*d+v*m[0])/S,(R*b+_*M+v*m[1])/S]);}}let r=o.length,i=[];for(let a=0;a<r;a++){let u=o[a],l=o[(a+1)%r],c=l[0]-u[0],m=l[1]-u[1],h=Math.sqrt(c*c+m*m);i.push([m/h,-c/h]);}let s=[];for(let a=0;a<r;a++){let u=i[(a+r-1)%r],l=i[a],c=u[0]+l[0],m=u[1]+l[1],h=Math.sqrt(c*c+m*m);s.push([c/h,m/h]);}return {points:o,normals:s}}function xe(t,n,e,o){return Tt.arc.map(([r,i])=>{let s=r*o,a=i*e,u=Math.sqrt(s*s+a*a);return {inset:t+e*(1-r),y:n+o*i,nh:s/u,nv:a/u}})}function mr(t){let n=Tt,e=new qt(ar(t?Sn.night:Sn.day)),{points:o,normals:r}=Le(),i=o.length,s=(b,d)=>[o[d][0]-r[d][0]*b.inset,b.y,o[d][1]-r[d][1]*b.inset],a=(b,d)=>[r[d][0]*b.nh,b.nv,r[d][1]*b.nh],u=(b,d,M)=>{for(let g=0;g<i;g++){let x=(g+1)%i,L=o[g][0]+o[x][0]<0;e.quadN(b,s(d,g),s(d,x),s(M,x),s(M,g),a(d,g),a(d,x),a(M,x),a(M,g),L);}};u("side",{inset:0,y:n.base,nh:1,nv:0},{inset:0,y:n.wall,nh:1,nv:0});let l=xe(0,n.wall,n.rim[0],n.rim[1]);for(let b=0;b+1<l.length;b++)u("bevel",l[b],l[b+1]);let c=xe(n.rim[0],n.wall+n.rim[1],n.dome[0],n.dome[1]).slice(0,n.arc.length-1);for(let b=0;b+1<c.length;b++)u(b<2?"top-low":"top",c[b],c[b+1]);let m=c[c.length-1],h=[0,1,0],f=[n.center[0],m.y+n.crown,n.center[1]];for(let b=0;b<i;b++){let d=(b+1)%i;e.triN("top-high",f,s(m,b),s(m,d),h,a(m,b),a(m,d));}let p=(b,d,M)=>{let g=n.center[0],x=n.center[1],L=[g,d,x],R=_=>[g+(o[_][0]-g)*M,d,x+(o[_][1]-x)*M];for(let _=0;_<i;_++)e.tri(b,L,R(_),R((_+1)%i),h);};return p("shadow-soft",.012,1.24),p("shadow",.02,1.08),e}function hr(t,n=false){return (t==="arrow3d"?mr(n):cr(t)).parts.filter(o=>o.positions.length>0)}function Zt(t,n){let e=t<0,o=Math.abs(t),r=1;for(let a=0;a<n;a++)r*=10;let i=Math.floor(o/r),s=String(o-i*r);for(;s.length<n;)s="0"+s;return (e?"-":"")+String(i)+(n>0?"."+s:"")}function Cn(t){let n=Math.floor(Math.abs(t)*1e4+.5);return Zt(t<0&&n>0?-n:n,4)}function H(t){let n=Math.floor(Math.abs(t)*10+.5);return Zt(t<0&&n>0?-n:n,1)}var ge=t=>"["+t.map(Cn).join(",")+"]";function ye(t,n,e){for(let o=0;o<e.length;o++)t.setFloat32(n+o*4,e[o],true);}function Jt(t,n=false){return t==="arrow3d"&&n?"arrow3d-night":t}function Re(t,n=false){let e=hr(t,n),o=Jt(t,n),r=0;for(let x of e)r+=x.positions.length*4*2+x.positions.length/3*4;let i=new DataView(new ArrayBuffer(r)),s=[],a=[],u=[],l=[],c=0;e.forEach((x,L)=>{let R=x.positions.length/3,_=x.material,v=[1/0,1/0,1/0],S=[-1/0,-1/0,-1/0];for(let F=0;F<R;F++)for(let V=0;V<3;V++){let y=x.positions[F*3+V];y<v[V]&&(v[V]=y),y>S[V]&&(S[V]=y);}let k=F=>Zt(Math.floor(F*1e4),4),N=F=>Zt(Math.ceil(F*1e4),4);ye(i,c,x.positions),l.push(`{"buffer":0,"byteOffset":${c},"byteLength":${R*12},"target":34962}`),c+=R*12,ye(i,c,x.normals),l.push(`{"buffer":0,"byteOffset":${c},"byteLength":${R*12},"target":34962}`),c+=R*12;for(let F=0;F<R;F++)i.setUint32(c+F*4,F,true);l.push(`{"buffer":0,"byteOffset":${c},"byteLength":${R*4},"target":34963}`),c+=R*4;let X=L*3;u.push(`{"bufferView":${X},"componentType":5126,"count":${R},"type":"VEC3","min":[${v.map(k).join(",")}],"max":[${S.map(N).join(",")}]}`),u.push(`{"bufferView":${X+1},"componentType":5126,"count":${R},"type":"VEC3"}`),u.push(`{"bufferView":${X+2},"componentType":5125,"count":${R},"type":"SCALAR"}`),s.push(`{"attributes":{"POSITION":${X},"NORMAL":${X+1}},"indices":${X+2},"material":${L},"mode":4}`);let D=`{"name":"${_.name}","pbrMetallicRoughness":{"baseColorFactor":${ge(_.color)},"metallicFactor":${Cn(_.metallic)},"roughnessFactor":${Cn(_.roughness)}}`;_.emissive&&(D+=`,"emissiveFactor":${ge(_.emissive)}`),_.blend&&(D+=',"alphaMode":"BLEND","doubleSided":true'),a.push(D+"}");});let m=`{"asset":{"version":"2.0","generator":"osmgl nav-car"},"scene":0,"scenes":[{"nodes":[0]}],"nodes":[{"mesh":0,"name":"${o}"}],"meshes":[{"name":"${o}","primitives":[${s.join(",")}]}],"materials":[${a.join(",")}],"accessors":[${u.join(",")}],"bufferViews":[${l.join(",")}],"buffers":[{"byteLength":${r}}]}`,h=new TextEncoder().encode(m),f=(4-h.length%4)%4,p=h.length+f,b=20+p+8+r,d=new Uint8Array(b),M=new DataView(d.buffer);M.setUint32(0,1179937895,true),M.setUint32(4,2,true),M.setUint32(8,b,true),M.setUint32(12,p,true),M.setUint32(16,1313821514,true),d.set(h,20);for(let x=0;x<f;x++)d[20+h.length+x]=32;let g=20+p;return M.setUint32(g,r,true),M.setUint32(g+4,5130562,true),d.set(new Uint8Array(i.buffer),g+8),d}function Gs(t){let n=2166136261;for(let e=0;e<t.length;e++)n^=t[e],n=Math.imul(n,16777619)>>>0;return (n>>>0).toString(16).padStart(8,"0")}function _e(t,n,e,o,r=0){if(t==="arrow")return null;let i=t==="arrow3d"?Tt.length:Yn[t].length,s=Math.max(1,kn.minPx*o/i),a=(e%360+360)%360;return {lng:n[0],lat:n[1],altitude:bf+kn.lift+Math.max(0,r),rotation:a,scale:s}}function Vs(t,n){let e=0;for(let o of t){let r=o.stations,i=o.heights,s=Math.min(r.length,i.length);if(s===0||n<r[0]||n>r[s-1])continue;let a=i[s-1];for(let u=0;u+1<s;u++)if(n<=r[u+1]){let l=r[u+1]-r[u],c=l>0?(n-r[u])/l:0;a=i[u]+(i[u+1]-i[u])*c;break}a>e&&(e=a);}return e}var On=48,Xn=24;function js(t){let n=fr(t);return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n.width} ${n.height}">`+n.paths.map(e=>`<path d="${e.d}" fill="${e.fill}"/>`).join("")+"</svg>"}function In(t,n,e){return `M${H(t-e)} ${H(n)}a${H(e)} ${H(e)} 0 1 0 ${H(2*e)} 0a${H(e)} ${H(e)} 0 1 0 ${H(-2*e)} 0Z`}function fr(t){if(t==="arrow"){let c=[[0,-19],[13,15],[0,7],[-13,15]].map(([m,h])=>[24+m*.475*.95,12+h*.475*.95]);return {width:On,height:Xn,paths:[{d:In(24,12,11),fill:"#2f6bff"},{d:"M"+c.map(([m,h])=>`${H(m)} ${H(h)}`).join("L")+"Z",fill:"#ffffff"}]}}if(t==="arrow3d")return br();let n=Yn[t],e=44/n.length,o=l=>2+l*e,r=l=>21-l*e,i=n.sections,s=i.map(l=>`${H(o(l[0]))} ${H(r(Math.max(l[2],l[4])))}`),a=i.slice().reverse().map(l=>`${H(o(l[0]))} ${H(r(n.clearance))}`),u=[{d:"M"+s.concat(a).join("L")+"Z",fill:n.color}];for(let l=0;l+1<i.length;l++){let c=n.segs[l];if(c!=="W"&&c!=="R")continue;let m=i[l],h=i[l+1],f=b=>b[2]+(b[4]-b[2])*.82,p=[[o(m[0]),r(m[2])],[o(h[0]),r(h[2])],[o(h[0]),r(f(h))],[o(m[0]),r(f(m))]];u.push({d:"M"+p.map(([b,d])=>`${H(b)} ${H(d)}`).join("L")+"Z",fill:"#1c2733"});}for(let l of n.wheel.axles)u.push({d:In(o(l),r(n.wheel.r),n.wheel.r*e),fill:"#17181a"}),u.push({d:In(o(l),r(n.wheel.r),n.wheel.r*e*.5),fill:"#bdc1c7"});return {width:On,height:Xn,paths:u}}function br(){let t=Tt,n=Sn.day,e=22/t.length,o=(t.outer[0][1]+t.outer[1][1])/2,{points:r,normals:i}=Le(),s=a=>"M"+r.map((u,l)=>`${H(24+(u[0]-i[l][0]*a)*e)} ${H(12+(u[1]-i[l][1]*a-o)*e)}`).join("L")+"Z";return {width:On,height:Xn,paths:[{d:s(0),fill:n.side},{d:s(.12),fill:n.bevel},{d:s(.3),fill:n.top}]}}var we=class{constructor(n){this.map=n;this.models=new Map;this.shown=null;this._kind="arrow";this._night=false;}get kind(){return this._kind}set kind(n){this._kind!==n&&(this._kind=n,this.hide());}get night(){return this._night}set night(n){this._night!==n&&(this._night=n,this._kind==="arrow3d"&&this.hideModel());}get visible(){return this.shown!==null}update(n,e,o,r=0){this.map.setFacadeFocus?.(n);let i=_e(this._kind,n,e,H$1(n[1],o),r);if(!i)return this.hideModel(),false;let s=this._kind,a=Jt(s,this._night),u=this.models.get(a),l=!u;return u||(u=pr(s,this._night),this.models.set(a,u)),this.shown!==u&&this.hideModel(),this.shown=u,u.coordinates=[i.lng,i.lat],u.rotation=i.rotation,u.scale=i.scale,u.altitude=i.altitude,u.visible=true,l?this.map.addModel(u):this.map.triggerRepaint(),true}clear(){this.hide();}destroy(){this.map.setFacadeFocus?.(null),this.shown=null;for(let n of this.models.values())this.map.removeModel(n);this.models.clear();}hide(){this.map.setFacadeFocus?.(null),this.hideModel();}hideModel(){let n=this.shown;n&&(this.shown=null,n.visible=false,this.map.triggerRepaint());}};function pr(t,n){let e=Jt(t,n),o=new ef({url:`osmgl://nav-car/${e}.glb`,coordinates:[0,0],fetchBytes:async()=>{let r=Re(t,n);return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)},id:`nav-car-${e}`,visible:false});return o.onTop=true,o.castShadows=false,o}function $(t){let n=111320*Math.cos(t[1]*Math.PI/180);return {toXY:e=>({x:(e[0]-t[0])*n,y:(e[1]-t[1])*111320}),toLonLat:e=>[t[0]+e.x/n,t[1]+e.y/111320]}}var pt=(t,n,e)=>t+(n-t)*e,rt=(t,n,e)=>({x:pt(t.x,n.x,e),y:pt(t.y,n.y,e)}),W=(t,n)=>Math.hypot(n.x-t.x,n.y-t.y),Se=t=>t<0?0:t>1?1:t,U=t=>{let n=Se(t);return n*n*(3-2*n)};function nn(t,n){let e=[0];for(let o=1;o<t.length;o++)e.push(e[o-1]+(n?n[o-1]:W(t[o-1],t[o])));return {pts:t,cum:e,length:e[e.length-1]??0}}function dt(t,n){let e=(n[0]-t[0])*Math.cos((t[1]+n[1])/2*Math.PI/180)*111320,o=(n[1]-t[1])*111320;return Math.hypot(e,o)}function Et(t,n){let e=t.slice(1).map((o,r)=>dt(t[r],o));return nn(t.map(n.toXY),e)}function Bt(t,n){let e=0,o=t.pts.length-2;if(o<0)return 0;for(;e<o;){let r=e+o+1>>1;t.cum[r]<=n?e=r:o=r-1;}return e}function G(t,n){if(t.pts.length===1)return t.pts[0];let e=Bt(t,n),o=t.cum[e+1]-t.cum[e],r=o>1e-9?(n-t.cum[e])/o:0;return rt(t.pts[e],t.pts[e+1],r)}function Qt(t,n){if(t.pts.length<2)return {x:1,y:0};let e=Bt(t,n);for(;e<t.pts.length-2&&W(t.pts[e],t.pts[e+1])<1e-6;)e++;let o=t.pts[e],r=t.pts[e+1],i=W(o,r)||1;return {x:(r.x-o.x)/i,y:(r.y-o.y)/i}}function $n(t,n,e=0){let o=e>0?(()=>{let r=G(t,n),i=G(t,Math.min(t.length,n+e)),s=W(r,i);return s>.5?{x:(i.x-r.x)/s,y:(i.y-r.y)/s}:Qt(t,n)})():Qt(t,n);return (Math.atan2(o.x,o.y)*180/Math.PI+360)%360}function Mt(t,n,e=-1/0,o=1/0){let r={s:0,d:1/0};for(let i=0;i+1<t.pts.length;i++){if(t.cum[i+1]<e||t.cum[i]>o)continue;let s=t.pts[i],a=t.pts[i+1],u=a.x-s.x,l=a.y-s.y,c=u*u+l*l,m=c>1e-12?Se(((n.x-s.x)*u+(n.y-s.y)*l)/c):0,h={x:s.x+u*m,y:s.y+l*m},f=W(n,h);f<r.d&&(r={s:t.cum[i]+m*(t.cum[i+1]-t.cum[i]),d:f});}return r}function dr(t,n){if(t.length<2)return t.slice();let e=[t[0]];for(let o=1;o<t.length;o++){let r=t[o-1],i=t[o],s=Math.max(1,Math.ceil(W(r,i)/n));for(let a=1;a<=s;a++)e.push(rt(r,i,a/s));}return e}function Zs(t,n,e){let o=nn(t),r=Math.max(0,Math.min(n,e)),i=Math.min(o.length,Math.max(n,e));if(t.length<2||i-r<1e-6)return [];let s=[G(o,r)];for(let a=0;a<t.length;a++)o.cum[a]>r&&o.cum[a]<i&&s.push(t[a]);return s.push(G(o,i)),s}function Js(t,n){let e=t.length;if(e<2)return t.slice();let o=s=>typeof n=="number"?n:n[s]??0,r=(s,a)=>{let u=W(s,a)||1;return {x:(a.y-s.y)/u,y:-(a.x-s.x)/u}},i=[];for(let s=0;s<e;s++){let a=s>0?r(t[s-1],t[s]):null,u=s<e-1?r(t[s],t[s+1]):null,l,c;if(a&&u){l=a.x+u.x,c=a.y+u.y;let m=Math.hypot(l,c);if(m<1e-6)l=u.x,c=u.y;else {l/=m,c/=m;let h=Math.max(.5,l*u.x+c*u.y);l/=h,c/=h;}}else {let m=a??u;l=m.x,c=m.y;}i.push({x:t[s].x+l*o(s),y:t[s].y+c*o(s)});}return i}function Mr(t,n,e){let o=G(t,n),r=Qt(t,n);return (e.x-o.x)*r.y-(e.y-o.y)*r.x}var xr=2;function gr(t,n,e){let o=dr(n,xr),r={s:[],pts:[]};for(let i of o){let{s}=Mt(t,i,e[0],e[1]);r.s.length&&s<=r.s[r.s.length-1]+.05||(r.s.push(s),r.pts.push(i));}return r.s.length>=2?r:null}function ve(t,n,e){let o=n.s.length,r=u=>{let l=Mr(t,n.s[u],n.pts[u]);return yr(t,e,l)};if(e<=n.s[0])return r(0);if(e>=n.s[o-1])return r(o-1);let i=0,s=o-1;for(;s-i>1;){let u=i+s>>1;n.s[u]<=e?i=u:s=u;}let a=(e-n.s[i])/(n.s[s]-n.s[i]);return rt(n.pts[i],n.pts[s],a)}function yr(t,n,e){let o=G(t,n),r=Qt(t,n);return {x:o.x+r.y*e,y:o.y-r.x*e}}var Ne=.7,Tn=2,tn=25,Fe=4.5,Lr=8,Rr=["round","flat","arrow"],_r="round",Qs=t=>typeof t=="string"&&Rr.includes(t),Ae=32,Ee=1.5;function Ht(t,n=0,e){let o=t.map(([i,s])=>[Math.min(i,s),Math.max(i,s)]).map(([i,s])=>e?[Math.max(i,e[0]),Math.min(s,e[1])]:[i,s]).filter(([i,s])=>s-i>1e-6).sort((i,s)=>i[0]-s[0]),r=[];for(let i of o){let s=r[r.length-1];s&&i[0]-s[1]<=n?s[1]=Math.max(s[1],i[1]):r.push([i[0],i[1]]);}return r}function wr(t){let n=[...t].sort((o,r)=>o.index-r.index),e=[];for(let o of n){let r=e[e.length-1];r&&o.index===r[r.length-1].index+1?r.push(o):e.push([o]);}return e}var Dt=4,Pe=3.3,vr=.045;function ti(t,n,e={}){if(n.length<2||!t.segments.length)return {features:[],hidden:[]};let o=$(n[0]),r=Et(n,o),i=Ht(t.coverage,e.gapM??0,[0,r.length]);if(!i.length)return {features:[],hidden:[]};let s=[...t.segments].sort((y,w)=>y.fromM-w.fromM),a=new Map;for(let y of s){let w=[y.fromM-40,y.toM+40],I=new Map;for(let E of y.lanes){if(E.centre.length<2)continue;let O=gr(r,E.centre.map(o.toXY),w);O&&I.set(E.laneId,{lane:E,track:O});}a.set(y,I);}let u=y=>s.some(w=>a.get(w).has(y)),l=(y,w)=>w<y.fromM?y.fromM-w:w>y.toM?w-y.toM:0,c=(y,w)=>{let I=null;for(let E of s)a.get(E).has(y)&&(!I||l(E,w)<=l(I,w))&&(I=I&&l(I,w)===0&&l(E,w)===0?I:E);return I},m=(y,w,I)=>{let E=a.get(w),O=E.get(y[0].laneId),C=E.get(y[y.length-1].laneId);if(!O||!C)return null;let Y=ve(r,O.track,I),P=ve(r,C.track,I),A=y.length===1?y[0].widthM:W(Y,P)+(y[0].widthM+y[y.length-1].widthM)/2;return {p:rt(Y,P,.5),w:A,level:w.level}},h=(y,w)=>wr(y.lanes.filter(I=>I.state===w&&a.get(y).has(I.laneId))),f=(y,w)=>{let I=h(y,"recommended").find(O=>O.some(C=>C.laneId===w));if(I)return I;let E=a.get(y).get(w);return E?[E.lane]:null},p=(y,w)=>{let I=c(y,w),E=I?f(I,y):null;return I&&E?m(E,I,w):null},b=t.changes.filter(y=>u(y.fromLane)&&u(y.toLane)&&y.endM>y.startM).sort((y,w)=>y.startM-w.startM),d=(y,w)=>{let I=a.get(y);if(y.ribbonLaneId&&I.has(y.ribbonLaneId)){let P=y.ribbonLaneId;for(let A of b)A.endM<=w+1e-6&&A.endM>=y.fromM-1&&A.fromLane===P&&(P=A.toLane);return P}let E=b.find(P=>P.startM>w&&P.startM<=y.toM&&I.has(P.fromLane));if(E)return E.fromLane;let O=[...b].reverse().find(P=>P.endM<=w+1e-6&&P.endM>=y.fromM-1&&I.has(P.toLane));if(O)return O.toLane;let C=b.find(P=>P.startM>=y.toM&&I.has(P.fromLane));if(C)return C.fromLane;let Y=h(y,"recommended");return Y.length?Y.reduce((P,A)=>A.length>P.length?A:P)[0].laneId:null},M=(y,w)=>{let I=d(y,w),E=I?f(y,I):null;return E?m(E,y,w):null},g=new Map(s.map(y=>{let w=new Set;for(let I of [y.fromM,...b.map(E=>E.endM).filter(E=>E>y.fromM&&E<=y.toM),y.toM]){let E=d(y,I);E&&w.add(E);}return [y,w]})),x=y=>g.get(y).size>0,L=y=>{let w=b.find(P=>P.startM<=y&&y<=P.endM);if(w){let P=p(w.fromLane,y),A=p(w.toLane,y);if(P&&A){let T=U((y-w.startM)/(w.endM-w.startM));return {p:rt(P.p,A.p,T),w:pt(P.w,A.w,T),level:T<.5?P.level:A.level}}}let I=[...s].reverse().find(P=>P.fromM<=y&&y<=P.toM&&x(P));if(I)return M(I,y);let E=[...s].reverse().find(P=>P.toM<y&&x(P)),O=s.find(P=>P.fromM>y&&x(P)),C=E?M(E,E.toM):null,Y=O?M(O,O.fromM):null;if(C&&Y&&E&&O){let P=U((y-E.toM)/(O.fromM-E.toM));return {p:rt(C.p,Y.p,P),w:pt(C.w,Y.w,P),level:Math.max(C.level,Y.level)}}return E?M(E,y):O?M(O,y):null},R=[],_=[],v={stations:[],line:[],weights:[]},S=e.cap??_r,k=y=>[y[0]>0||S==="flat"?"flat":"round",y[1]>0?"flat":S],N=S==="flat"?"flat":"round",X=(y,w,I,E,O)=>{for(let C=0;C+1<s.length;C++){let Y=s[C],P=s[C+1];if(!x(Y)||!x(P)||P.fromM-Y.toM>2*Dn)continue;let A=Math.max(Y.toM-Math.min(Dn,(Y.toM-Y.fromM)/2),E),T=Math.min(P.fromM+Math.min(Dn,(P.toM-P.fromM)/2),O);b.some(B=>B.endM>A-5&&B.startM<T+5)||Er(r,y,w,I,A,T);}},D=e.outside===false?null:{laneM:e.outside?.laneM??Pe,offsetM:e.outside?.offsetM??(e.outside?.laneM??Pe)/2};if(D){let y=r.length,w=Bn(0,y,Tn),I=Oe(w.map(A=>G(r,A))),E=ct(I),O=A=>({x:I[A].x+E[A].x*D.offsetM,y:I[A].y+E[A].y*D.offsetM}),C=A=>i.some(([T,B])=>B-T>=Dt&&A>=T-1e-9&&A<=B+1e-9),Y=w.map(A=>C(A)?L(A):null),P=[];for(let A=0;A<w.length;){if(!Y[A]){A++;continue}let T=A;for(;T+1<w.length&&Y[T+1];)T++;w[T]-w[A]>=Dt&&P.push([A,T]),A=T+1;}if(P.length){let A=w.map((j,et)=>({p:O(et),w:D.laneM,level:0})),T=w.slice(),B=w.map(j=>kr(j,P.map(([et,lt])=>[w[et],w[lt]])));for(let[j,et]of P){let lt=w[j],Lt=w[et],Rt=ot=>{let Xt=Y[ot],_t=Math.max(W(Xt.p,O(ot)),2*Math.abs(Xt.w-D.laneM));return Math.min(Math.max(tn,1.5*_t/vr),(Lt-lt)/2)},_n=lt>.5?Rt(j):0,wn=Lt<y-.5?Rt(et):0;for(let ot=j;ot<=et;ot++){let Xt=w[ot],_t=Y[ot],ae=Math.min(_n?(Xt-lt)/_n:1/0,wn?(Lt-Xt)/wn:1/0);if(ae>=1){A[ot]=_t;continue}let vn=U(ae);A[ot]={p:rt(O(ot),_t.p,vn),w:pt(D.laneM,_t.w,vn),level:vn<.5?0:_t.level};}X(w,T,A,lt+_n,Lt-wn);}_.push([0,y]),Ie(T,A,[0,0],o,R,k([0,0]),v,B);}}else for(let[y,w]of i){if(w-y<Dt)continue;let I=Bn(y,w,Tn),E=[];for(let B of I){let j=L(B);if(!j){E.push({p:G(r,B),w:0,level:0});continue}E.push(j);}let O=Math.min(tn,(w-y)/3),C=y>.5?O:0,Y=w<r.length-.5?O:0;I.forEach((B,j)=>{let et=Math.min(C?(B-y)/C:1/0,Y?(w-B)/Y:1/0);if(et>=1)return;let lt=U(et),Lt=G(r,B),Rt=E[j];E[j]={p:rt(Lt,Rt.p,lt),w:Rt.w,level:Rt.level};});let P=I.slice();X(I,P,E,y+C,w-Y);let A={s:[],pts:[]},T=()=>{if(A.s.length>=2&&A.s[A.s.length-1]-A.s[0]>=Dt){_.push([A.s[0],A.s[A.s.length-1]]);let B=[A.s[0]-y<1e-6?C:0,w-A.s[A.s.length-1]<1e-6?Y:0];Ie(A.s,A.pts,B,o,R,k(B),v,A.s.map(()=>1));}A={s:[],pts:[]};};I.forEach((B,j)=>{if(E[j].w<=0){T();return}A.s.push(P[j]),A.pts.push(E[j]);}),T();}for(let y of s){let w=g.get(y);for(let I of h(y,"recommended"))I.some(E=>w.has(E.laneId))||F(I,y,"band");for(let I of h(y,"allowed"))F(I,y,"allowed");}function F(y,w,I){let E=Math.max(w.fromM,i[0][0]),O=Math.min(w.toM,i[i.length-1][1]);if(O-E<Dt)return;let C=[],Y=[];for(let A of Bn(E,O,Tn)){let T=m(y,w,A);T&&(C.push(T),Y.push(A));}if(C.length<2)return;let P=Math.max(.5,C[0].w-Ne);R.push(Ce(I,C.map(A=>A.p),C.map(()=>P),C.map(A=>A.level),o,Y,[N,N]).feature);}let V={features:R,hidden:Ht(_,.5)};return v.stations.length>=2&&(V.car=v),V}var Dn=14,Ar=20;function Er(t,n,e,o,r,i){if(i-r<8)return;let s=n.findIndex(F=>F>=r-1e-9),a=-1;for(let F=n.length-1;F>=0;F--)if(n[F]<=i+1e-9){a=F;break}if(s<2||a<0||a+2>=n.length||a-s<3)return;for(let F=s-2;F<=a+2;F++)if(o[F].w<=0)return;let u=o[s].p,l=o[a].p,c={x:u.x-o[s-2].p.x,y:u.y-o[s-2].p.y},m={x:o[a+2].p.x-l.x,y:o[a+2].p.y-l.y},h=Math.hypot(c.x,c.y),f=Math.hypot(m.x,m.y);if(h<1e-6||f<1e-6)return;let p={x:c.x/h,y:c.y/h},b={x:m.x/f,y:m.y/f},d=p.x*b.y-p.y*b.x,M=Math.abs(Math.atan2(d,p.x*b.x+p.y*b.y));if(M<Ar*Math.PI/180||Math.abs(d)<1e-9)return;let g=l.x-u.x,x=l.y-u.y,L=(g*b.y-x*b.x)/d,R=(p.x*x-p.y*g)/d;if(L<.5||R<.5)return;let _={x:u.x+p.x*L,y:u.y+p.y*L},v=nn([u,_,l]),S=n[a]-n[s],k=n[s],N=Fe*Math.min(1,Math.max(.2,M/(Math.PI/2))),X=o[s].w,D=o[a].w;for(let F=s+1;F<a;F++){let V=v.length*(n[F]-n[s])/S,y=Pr((V-L)/N),w=G(v,V);o[F]={...o[F],p:w,w:pt(X,D,y)},k=Math.min(n[a],Math.max(k,Mt(t,w,n[s],n[a]).s)),e[F]=k;}}function Pr(t){let n=Math.abs(t)/Math.SQRT2,e=1/(1+.3275911*n),o=1-((((1.061405429*e-1.453152027)*e+1.421413741)*e-.284496736)*e+.254829592)*e*Math.exp(-n*n);return t>=0?(1+o)/2:(1-o)/2}var Ir=1;function kr(t,n){let e=Ir;for(let[o,r]of n){if(t>=o&&t<=r)return 1;let i=t<o?o-t:t-r;i<tn&&(e=Math.max(e,U(1-i/tn)));}return e}function Z(t,n,e){let o=Math.min(t.length,n.length);if(o===0)return 0;if(!(e>t[0]))return n[0];if(e>=t[o-1])return n[o-1];let r=0,i=o-1;for(;i-r>1;){let a=r+i>>1;t[a]<=e?r=a:i=a;}let s=t[i]-t[r];return s>0?n[r]+(n[i]-n[r])*((e-t[r])/s):n[r]}function Bn(t,n,e){if(n<=t)return [t];let o=Math.max(1,Math.ceil((n-t)/e));return Array.from({length:o+1},(r,i)=>t+(n-t)*i/o)}function Ie(t,n,e,o,r,i,s,a){let u=Sr(n.map(f=>Math.max(.5,f.w-Ne))),l=Ce("band",n.map(f=>f.p),u,n.map(f=>f.level),o,t,i);r.push(l.feature);for(let f=0;f<l.stations.length;f++){let p=l.stations[f];s.stations.length&&p<s.stations[s.stations.length-1]||(s.stations.push(p),s.line.push(l.feature.line[f]),s.weights.push(Z(t,a,p)));}let c=t[0]+e[0],m=t[t.length-1]-e[1],h=l.stations.map((f,p)=>f>=c-1e-6&&f<=m+1e-6?p:-1).filter(f=>f>=0);if(h.length>=2&&m-c>=10){let f=h.map(d=>l.centre[d]),p=Cr(f,Nr),b=Math.max(1,Math.min(...h.map(d=>l.widths[d]))-.6);for(let d=0;d+1<p.length;d++){let M=h[p[d]],g=h[p[d+1]];W(l.centre[M],l.centre[g])<Fr||r.push({kind:"chevron",line:[l.feature.line[M],l.feature.line[g]],width:b,levels:[l.feature.levels[M],l.feature.levels[g]],stations:[l.stations[M],l.stations[g]]});}}}var Hn=.5;function Sr(t){if(!t.length)return t;let n=[...t].sort((o,r)=>o-r),e=n[n.length>>1];return t.map(o=>{let r=Math.abs(o-e);return r<Hn?e:r<2*Hn?e+Math.sign(o-e)*2*(r-Hn):o})}var Nr=.1,Fr=6;function Cr(t,n){let e=t.length;if(e<=2)return t.map((i,s)=>s);let o=new Array(e).fill(false);o[0]=true,o[e-1]=true;let r=[[0,e-1]];for(;r.length;){let[i,s]=r.pop(),a=-1,u=-1,l=t[i].x,c=t[i].y,m=t[s].x-l,h=t[s].y-c,f=Math.hypot(m,h);for(let p=i+1;p<s;p++){let b=f>1e-9?Math.abs((t[p].x-l)*h-(t[p].y-c)*m)/f:Math.hypot(t[p].x-l,t[p].y-c);b>a&&(a=b,u=p);}u>=0&&a>n&&(o[u]=true,r.push([i,u],[u,s]));}return o.map((i,s)=>i?s:-1).filter(i=>i>=0)}var Or=1;function Xr(t,n,e=Or){let o=nn(t);if(t.length<2||o.length<1e-6)return {pts:t.slice(),attrs:n.map(a=>a.slice())};let r=Math.max(1,Math.round(o.length/e)),i=[],s=n.map(()=>[]);for(let a=0;a<=r;a++){let u=o.length*a/r,l=Bt(o,u),c=o.cum[l+1]-o.cum[l],m=c>1e-9?(u-o.cum[l])/c:0;i.push(rt(t[l],t[l+1],m)),n.forEach((h,f)=>s[f].push(pt(h[l],h[l+1],m)));}return {pts:i,attrs:s}}function Ce(t,n,e,o,r,i,s){let a=Xr(n,[e,o,i??e.map(()=>0)]),u=Oe(a.pts),l=Tr(a.attrs[0]),c=a.attrs[1].map(m=>Math.round(m));return {feature:{kind:t,line:u.map(r.toLonLat),width:Math.max(...l),levels:c,outline:$t(u,l.map(m=>m/2),ct(u),s).map(r.toLonLat),stations:a.attrs[2],widths:l,caps:s},centre:u,widths:l,stations:a.attrs[2]}}var Yr=2;function Tr(t,n=Yr){let e=t.length;if(e<3||n<=0)return t.slice();let o=Math.ceil(n*3),r=[];for(let i=0;i<e;i++){let s=true;for(let l=Math.max(0,i-o);l<=Math.min(e-1,i+o)&&s;l++)s=Math.abs(t[l]-t[i])<1e-9;if(s||i===0||i===e-1){r.push(t[i]);continue}let a=0,u=0;for(let l=-o;l<=o;l++){let c=Math.min(e-1,Math.max(0,i+l)),m=Math.exp(-(l*l)/(2*n*n));a+=m,u+=t[c]*m;}r.push(u/a);}return r}function Dr(t,n){let e=t[n-1],o=t[n],r=t[n+1],i=o.x-e.x,s=o.y-e.y,a=r.x-o.x,u=r.y-o.y;return Math.hypot(i,s)<1e-6||Math.hypot(a,u)<1e-6?0:Math.abs(Math.atan2(i*u-s*a,i*a+s*u))}function Oe(t,n=Fe){let e=t.length;if(e<3||n<=0)return t.slice();let o=0;for(let c=1;c<e;c++)o+=W(t[c-1],t[c]);let r=Math.max(.05,o/(e-1)),i=Lr*Math.PI/180,s=[];for(let c=1;c<e-1;c++){let m=Dr(t,c);if(Math.abs(m)<=i)continue;let h=s[s.length-1];h&&(c-h.to)*r<=3?(h.to=c,h.turn+=m):s.push({at:c,turn:m,from:c,to:c});}if(!s.length)return t.slice();let a=s.map(c=>{let m=Math.max(0,c.from-2),h=Math.min(e-1,c.to+2),f={x:t[c.from].x-t[m].x,y:t[c.from].y-t[m].y},p={x:t[h].x-t[c.to].x,y:t[h].y-t[c.to].y},b=Math.abs(Math.atan2(f.x*p.y-f.y*p.x,f.x*p.x+f.y*p.y))||Math.abs(c.turn),d=n*Math.min(1,Math.max(.2,b/(Math.PI/2)))/r;return {at:(c.from+c.to)/2,sig:d}}),u=c=>{if(c<0){let m=t[Math.min(e-1,-c)];return {x:2*t[0].x-m.x,y:2*t[0].y-m.y}}if(c>e-1){let m=t[Math.max(0,2*(e-1)-c)];return {x:2*t[e-1].x-m.x,y:2*t[e-1].y-m.y}}return t[c]},l=[];for(let c=0;c<e;c++){let m=0,h=0;for(let M of a){let g=Math.abs(M.at-c),x=2*M.sig,L=1.5*M.sig,R=g<=x?1:g>=x+L?0:U(1-(g-x)/L);(R>m||R===m&&R>0&&M.sig>h)&&(m=R,h=M.sig);}if(m<=0||c===0||c===e-1){l.push(t[c]);continue}let f=Math.ceil(h*2.5),p=0,b=0,d=0;for(let M=-f;M<=f;M++){let g=u(c+M),x=Math.exp(-(M*M)/(2*h*h));p+=g.x*x,b+=g.y*x,d+=x;}l.push(rt(t[c],{x:p/d,y:b/d},m));}return l}function $t(t,n,e=ct(t),o=["flat","flat"]){let r=t.length;if(r<2)return [];let{right:i,left:s}=Br(t,n,e),a=[...i,...ke(t[r-1],e[r-1],n[r-1],o[1],true),...s.reverse(),...ke(t[0],e[0],n[0],o[0],false)];return a.push(a[0]),a}function ke(t,n,e,o,r){if(o==="flat"||!(e>0))return [];let i=r?1:-1,s=-n.y*i,a=n.x*i,u=n.x*i,l=n.y*i;if(o==="arrow")return [{x:t.x+s*e*Ee,y:t.y+a*e*Ee}];let c=[];for(let m=1;m<Ae;m++){let h=Math.PI*m/Ae,f=Math.cos(h),p=Math.sin(h);c.push({x:t.x+e*(u*f+s*p),y:t.y+e*(l*f+a*p)});}return c}function Br(t,n,e=ct(t)){let o=t.length;if(o<2)return {right:[],left:[]};let r=i=>{let s=[],a=[],u=(l,c)=>{let m=s[s.length-1],h=a[a.length-1];return (l.x-m.x)*(t[c].x-t[h].x)+(l.y-m.y)*(t[c].y-t[h].y)<=1e-9};for(let l=0;l<o;l++){let c={x:t[l].x+e[l].x*n[l]*i,y:t[l].y+e[l].y*n[l]*i};if(s.length&&u(c,l)){if(l<o-1)continue;for(;s.length>1&&u(c,l);)s.pop(),a.pop();}s.push(c),a.push(l);}return s};return {right:r(1),left:r(-1)}}function ct(t){let n=t.length,e=[],o={x:0,y:-1};for(let r=0;r<n;r++){let i=t[Math.max(0,r-1)],s=t[Math.min(n-1,r+1)],a=W(i,s);a>1e-9&&(o={x:(s.y-i.y)/a,y:-(s.x-i.x)/a}),e.push(o);}return e}function ni(t,n){if(t.length<2)return [];if(!n.length)return [{coords:t.slice(),source:t.map((a,u)=>Math.min(u,t.length-2))}];let e=$(t[0]),o=Et(t,e),r=[],i=0;for(let[a,u]of Ht(n,0,[0,o.length]))a>i&&r.push([i,a]),i=Math.max(i,u);i<o.length&&r.push([i,o.length]);let s=[];for(let[a,u]of r){if(u-a<.5)continue;let l=Bt(o,a),c=Bt(o,u),m=[e.toLonLat(G(o,a))],h=[l];for(let f=l+1;f<=c;f++)o.cum[f]<=a||o.cum[f]>=u||(m.push(t[f]),h.push(Math.min(f,t.length-2)));m.push(e.toLonLat(G(o,u))),h.push(c),s.push({coords:m,source:h});}return s}function en(t,n){if(t.length<2)return n.map(()=>0);let e=$(t[0]),o=Et(t,e),r=0;return n.map(i=>{let{s}=Mt(o,e.toXY(i),r);return r=Math.max(r,s-1),s})}function Xe(t){let n=$(t[0]??[0,0]);return {frame:n,route:Et(t,n)}}var Gn=8,it=(t,n)=>Math.max(0,n)*Gn;function ei(t,n){return on(t.line,t.line.map((e,o)=>n(e,t.levels[o]??0)))}function on(t,n){let e=Math.min(...n),o=Math.max(...n);return o-e<.05?o>.01?{lift:+o.toFixed(2)}:{}:{liftPath:t.map((r,i)=>`${r[0].toFixed(7)},${r[1].toFixed(7)},${n[i].toFixed(2)}`).join(";")}}var Hr="/tiles/ldroads/guidance";function si(t){let n=t.geometry,e=t.maneuvers??[],o=en(n,e.map(r=>r.at));return {geometry:n.map(([r,i])=>[+r.toFixed(7),+i.toFixed(7)]),...t.edges?{edges:t.edges}:{},graphVersion:t.graphVersion??null,maneuvers:e.map((r,i)=>({atM:+o[i].toFixed(1),type:r.type,modifier:r.modifier??""}))}}var $r=10*6e4,Vn=new Map;async function ii(t,n={}){let e=n.url??Hr;if(Date.now()<(Vn.get(e)??0))return null;let o=n.fetch??globalThis.fetch;if(!o)return null;try{let r=await o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});return r.status===404||r.status===405||r.status===501?(Vn.set(e,Date.now()+$r),null):r.ok?jr(await r.json()):null}catch{return null}}function ai(){Vn.clear();}var q=t=>typeof t=="number"&&Number.isFinite(t)?t:null,z=t=>typeof t=="string"?t:typeof t=="number"&&Number.isFinite(t)?String(t):null,J=t=>Array.isArray(t)?t:[],Pt=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:null,Ye=t=>typeof t=="string"?t.split(/[|;,\s]+/).filter(Boolean):J(t).map(z).filter(n=>n!==null&&n!==""),Gr=t=>{let n=J(t),e=q(n[0]),o=q(n[1]);return e!==null&&o!==null&&Math.abs(o)<=90&&Math.abs(e)<=180?[e,o]:null},Vr=new Set(["recommended","allowed","other"]);function jr(t){let n=Pt(t);if(!n)return null;let e=J(n.coverage).map(s=>{let a=J(s),u=q(a[0]),l=q(a[1]);return u!==null&&l!==null&&l>u?[u,l]:null}).filter(s=>s!==null);if(!e.length)return null;let o=[];for(let s of J(n.segments)){let a=Pt(s);if(!a)continue;let u=q(a.fromM),l=q(a.toM);if(u===null||l===null||l<=u)continue;let c=[];for(let m of J(a.lanes)){let h=Pt(m);if(!h)continue;let f=z(h.laneId),p=q(h.index),b=q(h.widthM),d=J(h.centre).map(Gr).filter(g=>g!==null);if(f===null||p===null||b===null||b<=0||d.length<2)continue;let M=Vr.has(h.state)?h.state:"other";c.push({laneId:f,index:p,widthM:b,centre:d,state:M,turns:Ye(h.turns)});}c.length&&o.push({fromM:u,toM:l,wayId:typeof a.wayId=="number"||typeof a.wayId=="string"?a.wayId:0,dir:z(a.dir)??"forward",level:q(a.level)??0,...z(a.ribbonLaneId)!==null?{ribbonLaneId:z(a.ribbonLaneId)}:{},lanes:c});}if(!o.length)return null;let r=[];for(let s of J(n.changes)){let a=Pt(s);if(!a)continue;let u=z(a.fromLane),l=z(a.toLane),c=q(a.startM),m=q(a.endM);u===null||l===null||c===null||m===null||m<=c||r.push({fromLane:u,toLane:l,startM:c,endM:m});}let i=[];for(let s of J(n.maneuvers)){let a=Pt(s);if(!a)continue;let u=q(a.atM);u!==null&&i.push({atM:u,kind:z(a.kind)??"",laneIds:J(a.laneIds).map(z).filter(l=>l!==null),arrows:J(a.arrows).flatMap(l=>{let c=Pt(l),m=c?z(c.laneId):null;return c&&m!==null?[{laneId:m,turns:Ye(c.turns)}]:[]})});}return {version:z(n.version)??"",matchedBy:z(n.matchedBy),coverage:e,segments:o.sort((s,a)=>s.fromM-a.fromM),changes:r,maneuvers:i.sort((s,a)=>s.atM-a.atM)}}var It=(t,n,e)=>t+(n-t)*e;function at(t){let n=[0];for(let e=1;e<t.length;e++)n.push(n[e-1]+dt(t[e-1],t[e]));return {geometry:t,cum:n,length:n[n.length-1]??0}}function De(t,n){let e=0,o=t.length-2;if(o<0)return 0;for(;e<o;){let r=e+o+1>>1;t[r]<=n?e=r:o=r-1;}return e}function xt(t,n){let e=t.geometry;if(e.length===1)return e[0];let o=De(t.cum,n),r=t.cum[o+1]-t.cum[o],i=r>1e-9?Math.max(0,Math.min(1,(n-t.cum[o])/r)):0;return [It(e[o][0],e[o+1][0],i),It(e[o][1],e[o+1][1],i)]}function jn(t,n,e,o=1e-6){let r=Math.max(0,n),i=Math.min(t.length,e);if(t.geometry.length<2||i-r<o)return [];let s=[xt(t,r)];for(let a=De(t.cum,r)+1;a<t.geometry.length&&t.cum[a]<i;a++)t.cum[a]>r&&s.push(t.geometry[a]);return s.push(xt(t,i)),s}var Kr=.5;function ci(t,n,e){if(t.geometry.length<2||!(e>0))return [];let o=Math.min(e,t.length),r=[],i=0,s=[];for(let[a,u]of Ht(n,0,[0,t.length]))a>i&&s.push([i,a]),i=Math.max(i,u);i<t.length&&s.push([i,t.length]);for(let[a,u]of s){if(u-a<.5||a>=o)continue;let l=jn(t,a,Math.min(u,o),Kr);l.length>=2&&r.push(l);}return r}function Q(t,n){let e=t.length;if(e<2||n<=t[0])return 0;if(n>=t[e-1])return e-1;let o=0,r=e-2;for(;o<r;){let s=o+r+1>>1;t[s]<=n?o=s:r=s-1;}let i=t[o+1]-t[o];return o+(i>1e-12?(n-t[o])/i:0)}function K(t,n,e,o){let r=t.length,i=a=>{let u=Math.floor(a),l=a-u;return u>=r-1?t[r-1]:l<1e-12?t[u]:o(t[u],t[u+1],l)},s=[i(n)];for(let a=Math.floor(n)+1;a<e;a++)s.push(t[a]);return s.push(i(e)),s}var mt=(t,n,e)=>It(t,n,e),Ur=(t,n,e)=>Math.round(It(t,n,e)),gt=(t,n,e)=>[It(t[0],n[0],e),It(t[1],n[1],e)],rn=t=>t==="band"?"band-passed":t==="allowed"?"allowed-passed":t,Te=1e-6;function mi(t,n){let e=[];return t.forEach((o,r)=>{let i=o.line.length,s=m=>e.push({feature:m,source:r,from:0,to:i-1}),a=o.stations;if(n===null||!a||a.length!==i||i<2)return s(o);if(o.kind==="chevron"){a[i-1]>n&&s(o);return}if(o.kind!=="band"&&o.kind!=="allowed")return s(o);let u=Q(a,n);if(u<=Te)return s(o);if(u>=i-1-Te)return s({...o,kind:rn(o.kind)});let[l,c]=Wr(o,u);e.push({feature:l,source:r,from:0,to:u},{feature:c,source:r,from:u,to:i-1});}),e}function Wr(t,n){let e=t.line.length,o=t.widths&&t.widths.length===e?t.widths:t.line.map(()=>t.width),r=$(t.line[0]),i=K(t.line,0,n,gt),s=K(t.line,n,e-1,gt),a=[...i,...s.slice(1)].map(r.toXY),u=ct(a),l=i.length-1,c=t.caps,m=(h,f,p,b,d,M,g)=>{let x=K(o,p,b,mt);return {kind:h,line:f,width:Math.max(...x),levels:K(t.levels,p,b,Ur),outline:$t(a.slice(d,M),x.map(L=>L/2),u.slice(d,M),g).map(r.toLonLat),stations:K(t.stations,p,b,mt),widths:x,...g?{caps:g}:{}}};return [m(rn(t.kind),i,0,n,0,l+1,c&&[c[0],"flat"]),m(t.kind,s,n,e-1,l,a.length,c&&["flat",c[1]])]}function hi(t,n){if(n===null)return {passed:-1,cut:false};let e=0,o=false;for(let r of t){let i=r.stations;!i||i.length<2||(i[i.length-1]<=n?e++:i[0]<n&&(r.kind==="band"||r.kind==="allowed")&&(o=true));}return {passed:e,cut:o}}var sn=zr,He={intersection:sn.intersection??sn.default?.intersection,difference:sn.difference??sn.default?.difference},qr=18,st=4096,di=1,an=2**qr*st;function Gt(t){let n=Math.sin(t[1]*Math.PI/180);return [(t[0]+180)/360*an,(.5-Math.log((1+n)/(1-n))/(4*Math.PI))*an]}function ln(t){let n=t[0]/an*360-180,e=Math.PI-2*Math.PI*t[1]/an;return [n,Math.atan(Math.sinh(e))*180/Math.PI]}var Be=t=>t%2===0?1.2:.6,un=t=>t;function $e(t){if(!t.length||t[0].length<4)return [];let n=t.map(f=>f.map(Gt)),e=1/0,o=1/0,r=-1/0,i=-1/0;for(let[f,p]of n[0])f<e&&(e=f),f>r&&(r=f),p<o&&(o=p),p>i&&(i=p);let s=Math.floor(e/st),a=Math.floor(r/st),u=Math.floor(o/st),l=Math.floor(i/st),c=(f,p)=>f-p*st>=2;if(s===a&&u===l&&c(e,s)&&c(o,u))return [t];let m=n.map(un),h=[];for(let f=s;f<=a;f++)for(let p=u;p<=l;p++){let b=f*st+Be(f),d=p*st+Be(p),M=(f+1)*st,g=(p+1)*st;if(M<=e||b>=r||g<=o||d>=i)continue;let x=[un([[b,d],[M,d],[M,g],[b,g],[b,d]])];for(let L of He.intersection(m,x))h.push(L.map(R=>R.map(_=>ln([_[0],_[1]]))));}return h}function Ge(t){return {polys:t.filter(n=>n.length>=4).map(n=>{let e=n.map(Gt),o=e.map(i=>i[0]),r=e.map(i=>i[1]);return {box:[Math.min(...o),Math.min(...r),Math.max(...o),Math.max(...r)],geom:[un(e)]}})}}function Ve(t,n){if(t.length<4||!n.polys.length)return [[t]];let e=t.map(Gt),o=e.map(u=>u[0]),r=e.map(u=>u[1]),i=[Math.min(...o),Math.min(...r),Math.max(...o),Math.max(...r)],s=n.polys.filter(u=>u.box[0]<i[2]&&u.box[2]>i[0]&&u.box[1]<i[3]&&u.box[3]>i[1]);return s.length?He.difference([un(e)],...s.map(u=>u.geom)).map(u=>u.map(l=>l.map(c=>ln([c[0],c[1]])))):[[t]]}var Kn=40,kt=1e-6;function Vt(t,n,e=Kn){let o=t.line.length,r=t.stations;if(!r||r.length!==o||o<2)return [{kind:t.kind,from:0,to:o-1}];let i=[0];for(let l=Math.ceil(r[0]/e)*e;l<r[o-1];l+=e){let c=Q(r,l);c>i[i.length-1]+kt&&c<o-1-kt&&i.push(c);}i.push(o-1);let s=n===null?-1:Q(r,n),a=rn(t.kind),u=[];for(let l=0;l+1<i.length;l++){let c=i[l],m=i[l+1];n===null||s<=c+kt?u.push({kind:t.kind,from:c,to:m}):s>=m-kt?u.push({kind:a,from:c,to:m}):u.push({kind:a,from:c,to:s,cut:true},{kind:t.kind,from:s,to:m,cut:true});}return u}function cn(t){let n=$(t.line[0]),e=t.line.map(n.toXY),o=t.widths&&t.widths.length===t.line.length?t.widths:t.line.map(()=>t.width);return {frame:n,xy:e,normals:ct(e),widths:o,caps:t.caps??["flat","flat"]}}var je=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}),Zr=(t,n,e)=>{let o=je(t,n,e),r=Math.hypot(o.x,o.y);return r>1e-12?{x:o.x/r,y:o.y/r}:t};function jt(t,n,e){let o=K(t.xy,n,e,je),r=K(t.normals,n,e,Zr),i=K(t.widths,n,e,mt).map(u=>u/2),s=t.xy.length-1,a=[n<=kt?t.caps[0]:"flat",e>=s-kt?t.caps[1]:"flat"];return $t(o,i,r,a).map(t.frame.toLonLat)}var Ke=(t,n,e)=>K(t.line,n,e,gt);var Un=300,Ue=80,mn=40,We=50,ht={pitch:45,zoom:17.2},ze={pitch:58,zoom:18.6},Jr=600,Je=(t,n)=>t.coverage.some(([e,o])=>n>=e-5&&n<=o+30);function Qr(t,n){return t?t.maneuvers.find(e=>e.atM>=n-mn&&Je(t,e.atM))??null:null}function ts(t,n){if(!t)return 0;let e=0;for(let r of t.maneuvers){if(!Je(t,r.atM))continue;let i=r.atM-n,s=0;i>=0?s=i<=Un?1:i<=Un+Ue?1-(i-Un)/Ue:0:s=-i<=mn?1:-i<=mn+We?1-(-i-mn)/We:0,s>e&&(e=s);}let o=e;return o*o*(3-2*o)}function ns(t,n){let e=ts(t,n);return {pitch:ht.pitch+(ze.pitch-ht.pitch)*e,zoom:ht.zoom+(ze.zoom-ht.zoom)*e,close:e}}function Qe(t,n){if(!t||!n)return null;let e=[...t.segments].reverse().find(i=>i.fromM<=n.atM+1&&i.toM>=n.atM-40)??[...t.segments].reverse().find(i=>i.toM<=n.atM+1);if(!e)return null;let o=new Map(n.arrows.map(i=>[i.laneId,i.turns])),r=[...e.lanes].sort((i,s)=>i.index-s.index).map(i=>({laneId:i.laneId,turns:o.get(i.laneId)??i.turns,recommended:n.laneIds.includes(i.laneId),allowed:!n.laneIds.includes(i.laneId)&&i.state==="allowed"}));return r.length?{atM:n.atM,kind:n.kind,lanes:r}:null}function qe(t,n){let e=Qr(t,n);if(!e||e.atM-n>Jr)return null;let o=Qe(t,e);return o?{...o,distanceM:Math.max(0,e.atM-n)}:null}function gi(t,n,e){if(!t||n.length<2)return null;let o=en(n,[e])[0],r=t.maneuvers.find(i=>Math.abs(i.atM-o)<=25);return r?Qe(t,r):null}var Ze=class{constructor(n,e){this.plan=n;this.progressM=0;this.cam={s:0,pitch:ht.pitch,zoom:ht.zoom,bearing:0};this.started=false;this.measure=e.length>=2?Xe(e):null;}get lengthM(){return this.measure?.route.length??0}start(n,e,o=0){this.progressM=o,this.cam={s:o,pitch:n,zoom:e,bearing:this.measure?$n(this.measure.route,o,30):0},this.started=true;}advance(n,e=11){let o=qe(this.plan,this.progressM),r=o&&o.distanceM<120?e*.6:e;return this.progressM=Math.min(this.lengthM,this.progressM+r*n),this.progressM<this.lengthM}locate(n){let e=this.measure;if(!e||!Number.isFinite(n[0])||!Number.isFinite(n[1]))return false;let{s:o,d:r}=Mt(e.route,e.frame.toXY(n),this.progressM-30,this.progressM+600);return !(r<60)||!Number.isFinite(o)?false:(this.progressM=o,true)}hint(){return qe(this.plan,this.progressM)}step(n,e=false){let o=this.measure;if(!o)return null;this.started||this.start(ht.pitch,ht.zoom,this.progressM);let r=this.cam,i=Number.isFinite(n)?Math.min(.1,Math.max(0,n)):0,s=Math.min(1,i*3);r.s+=(this.progressM-r.s)*(e?1:s);let a=ns(this.plan,r.s);r.pitch+=(a.pitch-r.pitch)*s,r.zoom+=(a.zoom-r.zoom)*s;let u=$n(o.route,r.s,30),l=(u-r.bearing+540)%360-180;return r.bearing=(r.bearing+l*Math.min(1,i*2.5)+360)%360,{center:o.frame.toLonLat(G(o.route,r.s)),zoom:r.zoom,pitch:r.pitch,bearing:r.bearing,close:a.close,courseDeg:u,s:r.s}}};var dn="ld-roads",fn="ld-",eo="roadbed",Ai="/tiles/ldroads/index",Ei=t=>`/tiles/ldroads/style.json?v=${encodeURIComponent(t)}`,Pi=t=>`/tiles/ldroads/roadbed/{z}/{x}/{y}.pbf?v=${encodeURIComponent(t)}`;function es(t,n){return n.startsWith("/")&&!n.startsWith("//")?t.url(n):!t.key||!t.owns(n)||/[?&]key=/.test(n)?n:n+(n.includes("?")?"&":"?")+"key="+t.key}var St=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:null,oo=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return null}},ro=t=>typeof t=="number"&&Number.isFinite(t)?String(t):typeof t=="string"?t:null;function Ii(t){let n=St(oo(t)),e=n?ro(n.version):null;return !n||e===null?null:{version:e,areas:Array.isArray(n.areas)?n.areas.length:0}}var os="ld-mark-",Wn=.35;function rs(t){let n=String(t.id),e={...t,id:n.startsWith(fn)?n:fn+n};e.source==null&&(e.source=dn);let o=t.minzoom,r=St(t.paint),i=r?.opacity;return String(e.id).startsWith(os)&&typeof o=="number"&&o>Wn&&(i===void 0||typeof i=="number")&&(e.paint={...r??{},opacity:{stops:[[o-Wn,0],[o,i??1]]}},e.minzoom=o-Wn),e}function ki(t,n){let e=St(oo(t));if(!e)return null;let o=St(e.source),r=(Array.isArray(o?.tiles)?o.tiles.find(s=>typeof s=="string"):void 0)??(typeof o?.url=="string"?o.url:void 0),i=(Array.isArray(e.layers)?e.layers:[]).map(St).filter(s=>s!==null&&typeof s.id=="string"&&s.id!==""&&typeof s.type=="string"&&s.type!=="").map(rs);return r===void 0||!i.length?null:{version:ro(e.version)??"",tiles:es(n,r),minzoom:typeof o?.minzoom=="number"?o.minzoom:14,maxzoom:typeof o?.maxzoom=="number"?o.maxzoom:16,layers:i}}function ss(t){return {url:t.tiles,minzoom:t.minzoom,maxzoom:t.maxzoom}}var is=new Set(["symbol","fill-extrusion","building","buildings","model"]),Kt=t=>String(t.id).startsWith(fn);function as(t){let n=t.filter(s=>!Kt(s)),e=n.findIndex(s=>s.id===eo);if(e>=0)return e+1;let o=t.findIndex(Kt);if(o>=0)return t.slice(0,o).filter(s=>!Kt(s)).length;let r=-1;if(n.forEach((s,a)=>{s.source===Yd&&(r=a);}),r>=0)return r+1;let i=n.findIndex(s=>is.has(String(s.type)));return i>=0?i:n.length}function us(t){let n=t,e=n.sources??{};return Yd in e||dn in e||n.layers.some(Kt)}function Si(t,n,e=null){if(!us(t))return t;let o=t,r=o.sources??{},i=as(o.layers),s=o.layers.filter(u=>!Kt(u));s.splice(i,0,...n.layers);let a={[dn]:ss(n)};return e!==null&&Yd in r&&(a[Yd]={...St(r[Yd])??{},url:e}),{...t,sources:{...r,...a},layers:s}}function Ni(t){return t.layers.filter(n=>n.source===dn).map(n=>String(n.id))}var so="lane-ribbon",Zn="lane-ribbon-",Mn=17.5,bn="#2f6bff",pn="#8f98a8",io=.58,ao=.2,uo=.62,lo=.16,Fi={allowed:{color:bn,opacity:ao,zIndex:16},"allowed-passed":{color:pn,opacity:lo,zIndex:16},band:{color:bn,opacity:io,zIndex:17},"band-passed":{color:pn,opacity:uo,zIndex:17}},Ci=100,to=bf,ls=bf,co="route",cs={type:"FeatureCollection",features:[]},mo=(t,n)=>({id:`${Zn}${t}`,source:so,"source-layer":"geojson",minzoom:Mn,filter:["==","kind",n]}),hn=(t,n,e)=>({...mo(t,n),type:"surface",overlay:co,elevation:to,base:to,bevel:0,bevelDrop:0,weld:0,groundField:false,paint:{material:"flat",...e}}),ms=(t,n,e)=>({...mo(t,n),type:"line",overlay:co,depthTest:true,paint:{elevation:ls,material:"flat",...e}});function ho(){return [hn("allowed","allowed",{color:bn,opacity:ao}),hn("band","band",{color:bn,opacity:io}),hn("allowed-passed","allowed-passed",{color:pn,opacity:lo}),hn("band-passed","band-passed",{color:pn,opacity:uo}),ms("chevron","chevron",{color:"rgba(255,255,255,0)",opacity:1,width:{stops:[[17,3],[18,6],[19,12],[20,24],[21,48],[22,96]]},arrow:true,arrowStyle:"chevron",arrowColor:"rgba(255,255,255,0.95)",arrowPeriod:{stops:[[17,28],[18,40],[19,64],[20,110],[21,200],[22,380]]},arrowSize:{stops:[[17,1.5],[18,3],[19,6],[20,12],[21,24],[22,48]]}})]}var Oi=`${Zn}chevron`,Xi=()=>ho().map(t=>String(t.id));function Yi(t,n=cs){let e=t,o={...e.sources??{},[so]:{type:"geojson",sourceLayer:"geojson",minzoom:15,buffer:0,data:n}},r=e.layers.filter(s=>!String(s.id).startsWith(Zn)),i=-1;return r.forEach((s,a)=>{String(s.id).startsWith(fn)&&(i=a);}),i<0&&(i=r.findIndex(s=>s.id===eo)),r.splice(i>=0?i+1:r.length,0,...ho()),{...t,sources:o,layers:r}}var ut=111320,ft=32,hs=4096;function Ti(t){let n=new Map,e=0,o=0,r=(u,l)=>{l.length===1&&(l=[l[0],l[0]]);let c=n.get(u)??[];for(let m=1;m<l.length;m++){let[h,f,p]=l[m-1],[b,d,M]=l[m];c.push({ax:h,ay:f,ah:p,bx:b,by:d,bh:M}),e+=f,o++;}n.set(u,c);};for(let u of t){let l=u.properties,c=typeof l.layer=="number"?l.layer:0;if(typeof l.liftPath=="string"){for(let f of l.liftPath.split("|")){let p=f.split(";").map(b=>b.split(",").map(Number)).filter(b=>b.length===3&&b.every(Number.isFinite));p.length&&r(c,p);}continue}let m=typeof l.lift=="number"?l.lift:null;if(m===null)continue;let h=u.geometry;h.type==="LineString"?r(c,h.coordinates.map(([f,p])=>[f,p,m])):h.type==="Polygon"&&r(c,(h.coordinates[0]??[]).map(([f,p])=>[f,p,m]));}if(!o)return it;let i=ut*Math.cos(e/o*Math.PI/180),s=22,a=new Map;if(Number.isFinite(i)){let u=s+1;for(let[l,c]of n){let m=new Map,h=false;for(let f of c){let p=Math.min(f.ax,f.bx)*i-u,b=Math.max(f.ax,f.bx)*i+u,d=Math.min(f.ay,f.by)*ut-u,M=Math.max(f.ay,f.by)*ut+u;if(Number.isFinite(p)&&Number.isFinite(b)&&Number.isFinite(d)&&Number.isFinite(M)){if((b-p)*(M-d)>hs*ft*ft){h=true;break}for(let g=Math.floor(p/ft);g<=Math.floor(b/ft);g++)for(let x=Math.floor(d/ft);x<=Math.floor(M/ft);x++){let L=`${g}:${x}`,R=m.get(L);R?R.push(f):m.set(L,[f]);}}}h||a.set(l,m);}}return (u,l)=>{if(l<0)return 0;let c=n.get(l);if(!c?.length)return it(u,l);let m=a.get(l),h=m?m.get(`${Math.floor(u[0]*i/ft)}:${Math.floor(u[1]*ut/ft)}`)??[]:c,f=1/0,p=it(u,l);for(let b of h){let d=(b.ax-u[0])*i,M=(b.ay-u[1])*ut,g=(b.bx-u[0])*i,x=(b.by-u[1])*ut,L=g-d,R=x-M,_=L*L+R*R,v=_>1e-9?Math.max(0,Math.min(1,-(d*L+M*R)/_)):0,S=Math.hypot(d+L*v,M+R*v);S<f&&(f=S,p=b.ah+(b.bh-b.ah)*v);}return f<=s?p:it(u,l)}}var Di=bf;function fs(t,n=it){let e=t.features.filter(r=>r.outline&&r.stations&&r.stations.length===r.line.length&&r.line.length>=2),o=e.filter(r=>r.kind==="band");return (o.length?o:e).map(r=>({stations:r.stations,heights:r.line.map((i,s)=>n(i,r.levels[s]??0))}))}function bs(t,n=it){let e=fs(t,n);return e.length?o=>ps(e,o):()=>0}function ps(t,n){let e=0;for(let o of t){let r=o.stations,i=o.heights,s=Math.min(r.length,i.length);if(s===0||n<r[0]||n>r[s-1])continue;let a=0,u=s-1;for(;u-a>1;){let h=a+u>>1;r[h]<=n?a=h:u=h;}let l=r[u]-r[a],c=l>0?(n-r[a])/l:0,m=i[a]+(i[u]-i[a])*Math.max(0,Math.min(1,c));m>e&&(e=m);}return e}var zn=25,no=zn;function Bi(t,n,e){if(t.length<2)return null;let o=at(t),r=t[0][0],i=t[0][1],s=ut*Math.cos(i*Math.PI/180),a=t.map(p=>(p[0]-r)*s),u=t.map(p=>(p[1]-i)*ut),l=e?Math.max(0,e[0]-no):0,c=e?Math.min(o.length,e[1]+no):o.length,m=false;for(let p=l;p<=c&&!m;p+=5)n(p)>0&&(m=true);if(!m&&e&&n(c)>0&&(m=true),!m)return null;let h=zn,f=new Map;for(let p=1;p<t.length;p++){if(o.cum[p]<l||o.cum[p-1]>c)continue;let b=Math.floor(Math.min(a[p-1],a[p])/h),d=Math.floor(Math.max(a[p-1],a[p])/h),M=Math.floor(Math.min(u[p-1],u[p])/h),g=Math.floor(Math.max(u[p-1],u[p])/h);for(let x=b;x<=d;x++)for(let L=M;L<=g;L++){let R=`${x}:${L}`,_=f.get(R);_?_.push(p):f.set(R,[p]);}}return (p,b)=>{let d=(p-r)*s,M=(b-i)*ut,g=Math.floor(d/h),x=Math.floor(M/h),L=zn,R=-1;for(let _=-1;_<=1;_++)for(let v=-1;v<=1;v++){let S=f.get(`${g+_}:${x+v}`);if(S)for(let k of S){let N=a[k-1],X=u[k-1],D=a[k]-N,F=u[k]-X,V=D*D+F*F,y=V>1e-12?Math.max(0,Math.min(1,((d-N)*D+(M-X)*F)/V)):0,w=Math.hypot(N+D*y-d,X+F*y-M);w<L&&(L=w,R=Math.max(l,Math.min(c,o.cum[k-1]+(o.cum[k]-o.cum[k-1])*y)));}}return R<0?0:n(R)}}var qn=class{constructor(n,e=it,o={}){this.ribbon=n;this.heights=e;this.options=o;this.hs=[];this.props=new Map;this.shapes=new Map;this.frames=[];this.masks=[];this.routeLift=null;}setLift(n){this.options={...this.options,lift:n},this.hs=[],this.props.clear();}setHeights(n){this.heights=n,this.routeLift=null,this.hs=[],this.props.clear();}heightsOf(n){let e=this.hs[n];if(!e){let o=this.ribbon.features[n],r=o.stations,i=this.options.lift;if(i)e=o.line.map(s=>i(s[0],s[1]));else if(r&&r.length===o.line.length){let s=this.routeLift??(this.routeLift=bs(this.ribbon,this.heights));e=r.map(s);}else e=o.line.map((s,a)=>this.heights(s,o.levels[a]??0));this.hs[n]=e;}return e}maskFor(n){let e=this.masks[n];if(!e){let o=s=>s==="band"?0:1,r=this.ribbon.features,i=o(r[n].kind);e=Ge(r.filter((s,a)=>s.outline&&a!==n&&(o(s.kind)<i||o(s.kind)===i&&a<n)).map(s=>s.outline)),this.masks[n]=e;}return e}shapesOf(n,e,o){var i;let r=(i=this.frames)[n]??(i[n]=cn(this.ribbon.features[n]));return Ve(jt(r,e,o),this.maskFor(n)).flatMap($e)}at(n){let e=[],o=(r,i)=>e.push({type:"Feature",id:e.length+1,geometry:r,properties:i});return this.ribbon.features.forEach((r,i)=>{let s=Math.max(...r.levels);if(!r.outline){let a=r.stations;if(n!==null&&a&&a.length>=2&&a[a.length-1]<=n)return;let u=this.props.get(`${i}`);u||this.props.set(`${i}`,u=on(r.line,this.heightsOf(i))),o({type:"LineString",coordinates:r.line},{kind:r.kind,width:+r.width.toFixed(2),layer:s,...u});return}if(this.options.areas!==false)for(let a of Vt(r,n)){let u=`${i}:${a.kind}:${a.from}:${a.to}`,l=a.cut?void 0:this.shapes.get(u);l||(l=this.shapesOf(i,a.from,a.to),a.cut||this.shapes.set(u,l));let c=a.cut?void 0:this.props.get(u);c||(c=on(Ke(r,a.from,a.to),K(this.heightsOf(i),a.from,a.to,mt)),a.cut||this.props.set(u,c));for(let m of l)o({type:"Polygon",coordinates:m},{kind:a.kind,width:+r.width.toFixed(2),layer:s,...c});}}),{type:"FeatureCollection",features:e}}};function Hi(t,n=it){return new qn(t,n).at(null)}var Nt=zr,yt={union:Nt.union??Nt.default?.union,intersection:Nt.intersection??Nt.default?.intersection,difference:Nt.difference??Nt.default?.difference},fo=t=>{let n=1/0,e=1/0,o=-1/0,r=-1/0;for(let i of t)for(let[s,a]of i[0]??[])s<n&&(n=s),s>o&&(o=s),a<e&&(e=a),a>r&&(r=a);return [n,e,o,r]},bo=100,Ms=(t,n,e)=>!!e&&!!t.metres&&(t.tier[1]<n[0]||n[1]<t.tier[0])&&(t.metres[0]>e[1]+bo||e[0]>t.metres[1]+bo),xs=(t,n)=>t[0]<=n[2]&&n[0]<=t[2]&&t[1]<=n[3]&&n[1]<=t[3],po=t=>t.map(Gt),Mo=t=>t.map(n=>n.map(e=>e.map(o=>ln([o[0],o[1]])))),Ut=20,Qn=5,gs=t=>t==="band"||t==="band-passed"?"band":"allowed",Jn=t=>t==="band"?"band-passed":"allowed-passed",xo=class{constructor(n,e=Kn){this.ribbon=n;this.chunkM=e;this.groups=[];this.frames=[];this.built=false;this.featherCache=new Map;this.spans=null;}frame(n){var e;return (e=this.frames)[n]??(e[n]=cn(this.ribbon.features[n]))}build(){this.built=true;let n=new Map;this.ribbon.features.forEach((r,i)=>{if(!r.outline||r.line.length<2)return;let s=gs(r.kind);for(let a of Vt(r,null,this.chunkM)){let u=r.stations,l=u&&u.length===r.line.length?u[Math.floor(a.from)]+(u[Math.min(Math.floor(a.from)+1,u.length-1)]-u[Math.floor(a.from)])*(a.from-Math.floor(a.from)):0,c=Math.floor((l+1e-6)/this.chunkM),m=`${s}:${c}`,h=n.get(m);h||n.set(m,h={cat:s,chunk:c,pieces:[]}),h.pieces.push({i,from:a.from,to:a.to});}});let e=[...n.values()].sort((r,i)=>r.cat===i.cat?r.chunk-i.chunk:r.cat==="band"?-1:1),o=[];for(let r of e){let i=r.pieces.map(h=>[po(jt(this.frame(h.i),h.from,h.to))]),s=i.length>1?yt.union(i[0],...i.slice(1)):yt.union(i[0]);if(!s.length)continue;let a=this.tierOf(r.pieces),u=this.metresOf(r.pieces),l=fo(s),c=o.filter(h=>xs(h.box,l)&&!Ms(h,a,u));if(c.length&&(s=yt.difference(s,...c.map(h=>h.geom))),!s.length)continue;let m={cat:r.cat,chunk:r.chunk,geom:s,box:fo(s),pieces:r.pieces,tier:a,metres:u};this.groups.push(m),o.push(m);}}tierOf(n){let e=1/0,o=-1/0;for(let r of n){let i=this.ribbon.features[r.i].levels,s=Math.min(Math.ceil(r.to),this.ribbon.features[r.i].line.length-1);for(let a=Math.max(0,Math.floor(r.from));a<=s;a++){let u=i[a]??0;u<e&&(e=u),u>o&&(o=u);}}return e<=o?[e,o]:[0,0]}metresOf(n){let e=1/0,o=-1/0;for(let r of n){let i=this.ribbon.features[r.i].stations;if(!i||!i.length)return null;let s=a=>{let u=Math.min(Math.floor(a),i.length-1);return i[u]+((i[Math.min(u+1,i.length-1)]??i[u])-i[u])*(a-u)};e=Math.min(e,s(r.from)),o=Math.max(o,s(r.to));}return e<=o?[e,o]:null}inside(n,e){for(let o of this.groups)if(!(n<o.box[0]||n>o.box[2]||e<o.box[1]||e>o.box[3]))for(let r of o.geom){if(!yo(n,e,r[0]))continue;let i=false;for(let s=1;s<r.length&&!i;s++)i=yo(n,e,r[s]);if(!i)return true}return false}featherOf(n){return n.map(e=>{let o=e,r=o.length-1,i=[];for(let s=0;s<r;s++){let[a,u]=o[s],[l,c]=o[s+1],m=Math.hypot(l-a,c-u);if(m<1e-9){i.push(false);continue}let h=(a+l)/2,f=(u+c)/2,p=-(c-u)/m*go,b=(l-a)/m*go;i.push(this.inside(h+p,f+b)!==this.inside(h-p,f-b));}return i})}spanOf(n){return this.spans||(this.spans=this.groups.map(e=>{if(e.pieces.every(r=>!this.ribbon.features[r.i].stations))return null;let o=(r,i)=>{let s=this.ribbon.features[r.i].stations;if(!s||!s.length)return 0;let a=Math.min(Math.floor(i),s.length-1);return s[a]+((s[Math.min(a+1,s.length-1)]??s[a])-s[a])*(i-a)};return {lo:Math.min(...e.pieces.map(r=>o(r,r.from))),hi:Math.max(...e.pieces.map(r=>o(r,r.to)))}})),this.spans[n]}passMode(n,e,o){let r=this.spanOf(n);return e===null||!r?"b":r.hi<=e-o-Qn?"g":r.lo>=e+Qn?"b":"x"}passKey(n,e=Ut){this.built||this.build();let o="";for(let r=0;r<this.groups.length;r++)o+=this.passMode(r,n,e);return o}passAt(n,e=Ut){this.built||this.build();let o=[],r=(i,s,a,u,l)=>{let c=Mo(a),m=this.spanOf(u),h=m?[m.lo,m.hi]:null;a.forEach((f,p)=>{let b=`${s}:${p}`,d=this.featherCache.get(b);d||this.featherCache.set(b,d=this.featherOf(f)),o.push({key:b,kind:i,polygon:c[p].map(M=>M.slice(0,-1)),feather:d,group:u,dir:l,span:h});});};return this.groups.forEach((i,s)=>{let a=`${i.cat}:${i.chunk}`,u=this.passMode(s,n,e),l=this.spanOf(s)!==null;u!=="g"&&r(i.cat,`${a}:whole`,i.geom,s,l?1:0),u!=="b"&&r(Jn(i.cat),`${a}:passed`,i.geom,s,-1);}),o}stationsFor(n,e){this.built||this.build();let o=this.groups[n];if(!o||!this.spanOf(n))return null;let r=[];for(let i of o.pieces){let s=this.ribbon.features[i.i],a=s.stations;if(!a||a.length!==s.line.length||a.length<2)continue;let u=this.frame(i.i),l=Math.max(0,Math.floor(i.from)),c=Math.min(a.length-1,Math.ceil(i.to));c>l&&r.push({xy:u.xy,st:a,frame:u.frame,k0:l,k1:c});}return r.length?e.map(i=>i.map(s=>{let a=1/0,u=0;for(let l of r){let c=l.frame.toXY(s);for(let m=l.k0;m<l.k1;m++){let h=l.xy[m],f=l.xy[m+1],p=f.x-h.x,b=f.y-h.y,d=p*p+b*b,M=d>1e-12?((c.x-h.x)*p+(c.y-h.y)*b)/d:0;M=M<0?0:M>1?1:M;let g=c.x-(h.x+p*M),x=c.y-(h.y+b*M),L=g*g+x*x;L<a&&(a=L,u=l.st[m]+(l.st[m+1]-l.st[m])*M);}}return u})):null}at(n){this.built||this.build();let e=[],o=(r,i,s)=>{let a=Mo(s);s.forEach((u,l)=>{let c=`${i}:${l}`,m=this.featherCache.get(c);m||(m=this.featherOf(u),i.includes(":cut-")||this.featherCache.set(c,m)),e.push({key:c,kind:r,polygon:a[l].map(h=>h.slice(0,-1)),feather:m});});};for(let r of this.groups){let i=r.pieces.map(c=>this.ribbon.features[c.i]),s=(c,m)=>{let h=this.ribbon.features[c.i].stations;if(!h||!h.length)return 0;let f=Math.min(Math.floor(m),h.length-1);return h[f]+((h[Math.min(f+1,h.length-1)]??h[f])-h[f])*(m-f)},a=Math.min(...r.pieces.map(c=>s(c,c.from))),u=Math.max(...r.pieces.map(c=>s(c,c.to))),l=`${r.cat}:${r.chunk}`;if(n===null||n<=a||i.every(c=>!c.stations))o(r.cat,`${l}:whole`,r.geom);else if(n>=u)o(Jn(r.cat),`${l}:passed`,r.geom);else {let c=[];for(let p of r.pieces){let b=this.ribbon.features[p.i];for(let d of Vt(b,n,this.chunkM)){if(d.kind===b.kind||d.to<=p.from+1e-9||d.from>=p.to-1e-9)continue;let M=Math.max(d.from,p.from),g=Math.min(d.to,p.to);g-M>1e-6&&c.push([po(jt(this.frame(p.i),M,g))]);}}if(!c.length){o(r.cat,`${l}:whole`,r.geom);continue}let m=c.length>1?yt.union(c[0],...c.slice(1)):yt.union(c[0]),h=yt.intersection(r.geom,m),f=yt.difference(r.geom,m);o(Jn(r.cat),`${l}:cut-passed:${n}`,h),o(r.cat,`${l}:cut-rest:${n}`,f);}}return e}},go=5;function yo(t,n,e){let o=e,r=false;for(let i=0,s=o.length-1;i<o.length;s=i++){let[a,u]=o[i],[l,c]=o[s];u>n!=c>n&&t<(l-a)*(n-u)/(c-u)+a&&(r=!r);}return r}var Ki={COLOR:"rgba(255,255,255,0)",ARROW_COLOR:"rgba(255,255,255,0.95)",WIDTH_M:2.75,PERIOD_M:18.3,SIZE_M:1.37,Z:18};function Ui(t,n,e=Ut){let o=[];return t.features.forEach((r,i)=>{if(r.outline||r.kind!=="chevron"||r.line.length<2)return;let s=r.stations,a=s&&s.length>=2?[s[0],s[s.length-1]]:null;n!==null&&a&&a[1]<=n-e-Qn||o.push({key:`chevron:${i}`,line:r.line,stations:a});}),o}function Wi(t,n){let e=t.stations,o=t.line;if(!e||o.length<2||!n.length)return null;let r=$(o[0]),i=r.toXY(n[0]),s=0,a=1/0,u=0;for(let l=0;l+1<o.length;l++){let c=r.toXY(o[l]),m=r.toXY(o[l+1]),h=dt(o[l],o[l+1]),f=m.x-c.x,p=m.y-c.y,b=f*f+p*p,d=b>1e-12?((i.x-c.x)*f+(i.y-c.y)*p)/b:0;d=d<0?0:d>1?1:d;let M=i.x-(c.x+f*d),g=i.y-(c.y+p*d),x=M*M+g*g;x<a&&(a=x,u=s+h*d),s+=h;}return s>1e-9?e[0]+(e[1]-e[0])*u/s:e[0]}function zi(t,n){let e=[];return t.features.forEach((o,r)=>{if(o.outline||o.kind!=="chevron"||o.line.length<2)return;let i=o.stations;n!==null&&i&&i.length>=2&&i[i.length-1]<=n||e.push({key:`chevron:${r}`,line:o.line});}),e}var Ft=5e-5;function qi(t,n){let e=[],o=new Map;for(let r of t){let i=r.lonlat,s=r.z,a=r.normals,u=r.indices;for(let l=0;l+2<u.length;l+=3){let c=u[l],m=u[l+1],h=u[l+2];if(a[3*c+2]<.5||a[3*m+2]<.5||a[3*h+2]<.5)continue;let f={ax:i[2*c],ay:i[2*c+1],az:s[c],bx:i[2*m],by:i[2*m+1],bz:s[m],cx:i[2*h],cy:i[2*h+1],cz:s[h]},p=e.push(f)-1,b=Math.floor(Math.min(f.ax,f.bx,f.cx)/Ft),d=Math.floor(Math.max(f.ax,f.bx,f.cx)/Ft),M=Math.floor(Math.min(f.ay,f.by,f.cy)/Ft),g=Math.floor(Math.max(f.ay,f.by,f.cy)/Ft);for(let x=b;x<=d;x++)for(let L=M;L<=g;L++){let R=`${x}:${L}`,_=o.get(R);_?_.push(p):o.set(R,[p]);}}}return (r,i,s)=>{let a=o.get(`${Math.floor(r/Ft)}:${Math.floor(i/Ft)}`),u=null;if(a)for(let l of a){let c=e[l],m=(c.by-c.cy)*(c.ax-c.cx)+(c.cx-c.bx)*(c.ay-c.cy);if(Math.abs(m)<1e-20)continue;let h=((c.by-c.cy)*(r-c.cx)+(c.cx-c.bx)*(i-c.cy))/m,f=((c.cy-c.ay)*(r-c.cx)+(c.ax-c.cx)*(i-c.cy))/m,p=1-h-f;if(h<-1e-9||f<-1e-9||p<-1e-9)continue;let b=h*c.az+f*c.bz+p*c.cz;(u===null||(s!==void 0?Math.abs(b-s)<Math.abs(u-s):b>u))&&(u=b);}if(u!==null)return u;for(let l of n)if(r>=l[0]&&r<=l[2]&&i>=l[1]&&i<=l[3])return null}}var Lo=Gn/2;function Zi(t,n){return !t&&!n?null:(e,o)=>{let r=n?n(e,o):0,i=t?t(e,o,r):void 0;return i===void 0?r:i===null?0:Math.abs(i-r)>Lo?r:i>0?i:0}}var xn=2,ys=.5;function Ji(t,n,e){if(!e||t.length<2)return n;let o=at(t),r=Math.max(1,Math.ceil(o.length/xn)),i=new Float64Array(r+1),s=0,a=false,u=1;for(let l=0;l<=r;l++){let c=Math.min(o.length,l*xn);for(;u<t.length-1&&o.cum[u]<c;)u++;let m=t[u-1],h=t[u],f=o.cum[u]-o.cum[u-1],p=f>0?Math.max(0,Math.min(1,(c-o.cum[u-1])/f)):0,b=n(c),d=e(m[0]+(h[0]-m[0])*p,m[1]+(h[1]-m[1])*p,a?s:b);if(typeof d=="number"){let M=d>0?d:0;a&&Math.abs(M-s)<=xn*ys+.5?s=M:Math.abs(M-b)<=Lo?(s=M,a=true):a||(s=b);}else s=b,a=false;i[l]=s;}return l=>{if(!(l>0))return i[0];let c=l/xn,m=Math.floor(c);return m>=r?i[r]:i[m]+(i[m+1]-i[m])*(c-m)}}var _o=20,te=300,ne=34,Ls=Mn+.05,Rs=Mn-.05,gn=2,Wt=30,yn=1;function ea(t,n,e=_o){if(t.length<2||!n.length||!(e>0))return null;let o=$(t[0]),r=Et(t,o),i=[];for(let[s,a]of n)s>yn&&i.push({at:s,dir:1}),a<r.length-yn&&i.push({at:a,dir:-1});return i.length?{frame:o,route:r,ends:i,fadeM:e}:null}function wo(t,n){let e=1;for(let o of t.ends){let r=Mt(t.route,n,o.at-t.fadeM-Wt,o.at+t.fadeM+Wt);r.d>Wt||(e=Math.min(e,U((r.s-o.at)*o.dir/t.fadeM)));}return e}function _s(t,n){return wo(t,t.frame.toXY(n))}function ws(t,n){let e=t.fadeM+Wt;for(let o of t.ends){let r=G(t.route,o.at);if(Math.hypot(n.x-r.x,n.y-r.y)<=e)return true}return false}function vs(t,n,e){let o=e.x-n.x,r=e.y-n.y,i=o*o+r*r,s=i>1e-12?Math.min(Math.max(((t.x-n.x)*o+(t.y-n.y)*r)/i,0),1):0;return Math.hypot(t.x-(n.x+o*s),t.y-(n.y+r*s))}function vo(t,n,e){let o=t.fadeM+Wt;for(let r of t.ends)if(vs(G(t.route,r.at),n,e)<=o)return true;return false}function oa(t,n,e){if(!t)return {polygon:n,feather:e,alphas:null};let o=[],r=[],i=[],s=false;return n.forEach((a,u)=>{let l=a.length,c=a.map(b=>t.frame.toXY(b)),m=[],h=[],f=[],p=(b,d,M)=>{let g=ws(t,d)?wo(t,d):1;g<1&&(s=true),m.push(b),h.push(M),f.push(g);};for(let b=0;b<l;b++){let d=(b+1)%l,M=e[u]?.[b]!==false;p(a[b],c[b],M);let g=Math.hypot(c[d].x-c[b].x,c[d].y-c[b].y);if(g<=gn||!vo(t,c[b],c[d]))continue;let x=Math.ceil(g/gn);for(let L=1;L<x;L++){let R=L/x,_=[a[b][0]+(a[d][0]-a[b][0])*R,a[b][1]+(a[d][1]-a[b][1])*R];p(_,{x:c[b].x+(c[d].x-c[b].x)*R,y:c[b].y+(c[d].y-c[b].y)*R},M);}}o.push(m),r.push(h),i.push(f);}),s?{polygon:o,feather:r,alphas:i}:{polygon:n,feather:e,alphas:null}}function ra(t,n){if(!t||n.length<2)return [n];let e=[],o=[],r=()=>{o.length>=2&&e.push(o),o=[];},i=s=>{_s(t,s)>=.999?o.push(s):r();};i(n[0]);for(let s=1;s<n.length;s++){let a=t.frame.toXY(n[s-1]),u=t.frame.toXY(n[s]),l=Math.hypot(u.x-a.x,u.y-a.y);if(l>gn&&vo(t,a,u)){let c=Math.ceil(l/gn);for(let m=1;m<c;m++){let h=m/c;i([n[s-1][0]+(n[s][0]-n[s-1][0])*h,n[s-1][1]+(n[s][1]-n[s-1][1])*h]);}}i(n[s]);}return r(),e}function sa(t,n,e=_o){let o=0;for(let i=1;i<t.length;i++)o+=dt(t[i-1],t[i]);let r=[];for(let[i,s]of n){let a=i>yn?i+e:i,u=s<o-yn?s-e:s;u-a>.5&&r.push([a,u]);}return r}function ia(t,n){let e=[],o=0;for(let[r,i]of t)r>o&&e.push([o,r]),o=Math.max(o,i);return o<n&&e.push([o,n]),e}var Ro=class{constructor(){this.on=false;this.t=0;this.at=null;}update(n,e,o){if(!o&&this.t===0)return this.on=false,this.at=null,false;let r=this.at===null||e-this.at>1e3||e<this.at?0:Math.min(e-this.at,ne);this.at=e,o?(this.on?n<Rs:n>=Ls)&&(this.on=!this.on):this.on=false;let i=this.on?1:0,s=r/te;return this.t=i>this.t?Math.min(i,this.t+s):Math.max(i,this.t-s),this.t!==i}get ribbonAlpha(){return U(this.t)}get lineAlpha(){return 1-U(this.t)}get animating(){return this.t!==(this.on?1:0)}};var ee={RADIUS_M:15,MIN_TURN_DEG:2,ARC_STEP:Math.PI/16};function ca(t,n=ee.RADIUS_M){let e=t.length,o=[],r=[],i=s=>{let a=o[o.length-1];return (!a||Math.abs(a[0]-s[0])>1e-10||Math.abs(a[1]-s[1])>1e-10)&&o.push(s),o.length-1};for(let s=0;s<e;s++){if(s===0||s===e-1||!(n>0)){r.push(i(t[s]));continue}let a=$(t[s]),u=a.toXY(t[s-1]),l=a.toXY(t[s+1]),c=Math.hypot(u.x,u.y),m=Math.hypot(l.x,l.y);if(c<1e-6||m<1e-6){r.push(i(t[s]));continue}let h={x:-u.x/c,y:-u.y/c},f={x:l.x/m,y:l.y/m},p=Math.max(-1,Math.min(1,h.x*f.x+h.y*f.y)),b=Math.acos(p);if(b<ee.MIN_TURN_DEG*Math.PI/180){r.push(i(t[s]));continue}let d=Math.tan(b/2),M=n*d,g=Math.min(c,m)/2;M>g&&(M=g);let x=M/d,L=h.x*f.y-h.y*f.x>0?1:-1,R={x:-h.x*M,y:-h.y*M},_={x:R.x-h.y*L*x,y:R.y+h.x*L*x},v=Math.atan2(R.y-_.y,R.x-_.x),S=Math.max(2,Math.ceil(b/ee.ARC_STEP));S%2&&S++;let k=0;for(let N=0;N<=S;N++){let X=v+L*b*N/S,D=i(a.toLonLat({x:_.x+Math.cos(X)*x,y:_.y+Math.sin(X)*x}));N===S/2&&(k=D);}r.push(k);}return {coords:o,anchors:r,line:at(o),src:at(t)}}function As(t,n){let e=0,o=t.length-2;if(o<0)return 0;for(;e<o;){let r=e+o+1>>1;t[r]<=n?e=r:o=r-1;}return e}function Ln(t,n){let e=t.src.cum;if(e.length<2)return 0;if(n<=0)return t.line.cum[t.anchors[0]];if(n>=t.src.length)return t.line.cum[t.anchors[t.anchors.length-1]];let o=As(e,n),r=e[o+1]-e[o],i=r>1e-9?(n-e[o])/r:0,s=t.line.cum[t.anchors[o]],a=t.line.cum[t.anchors[o+1]];return s+(a-s)*i}function Eo(t,n){return xt(t.line,Ln(t,n))}var Ao=3;function ma(t,n){let e=Ln(t,n),o=t.line.length,r=xt(t.line,Math.max(0,Math.min(o,e-Ao))),i=xt(t.line,Math.max(0,Math.min(o,e+Ao))),s=Math.cos((r[1]+i[1])/2*Math.PI/180),a=(i[0]-r[0])*s,u=i[1]-r[1],l=a===0&&u===0?0:(Math.atan2(a,u)*180/Math.PI+360)%360;return {point:xt(t.line,e),bearing:l}}function ha(t,n){let e=[];for(let o of n){if(!(o.at>=0&&o.at<t.anchors.length))continue;let r=Math.min(t.anchors[o.at],t.coords.length-2);if(e.length&&r<=e[e.length-1].at){e[e.length-1]={at:e[e.length-1].at,factor:o.factor};continue}e.push({at:r,factor:o.factor});}return e}function fa(t,n){return n.map(([e,o])=>[Ln(t,e),Ln(t,o)])}var Ct=111320,Es=2,Ps=.5;function Is(t,n){let e=Math.min(t.length,n.length),o=t.slice(0,e),r=i=>{let s=Math.cos(n[i][1]*Math.PI/180)*Ct;return Math.hypot((n[i][0]-n[i-1][0])*s,(n[i][1]-n[i-1][1])*Ct)};for(let i=1;i<e;i++){if(o[i]>o[i-1])continue;let s=i;for(;s+1<e&&!(o[s+1]>o[i-1]);)s++;let a=0,u=[];for(let h=i;h<=Math.min(s+1,e-1);h++)u.push(a+=r(h));let l=o[i-1],c=s+1<e?o[s+1]:l+a,m=s+1<e?a:a||1;for(let h=i;h<=s;h++)o[h]=m>0?l+(c-l)*u[h-i]/m:l+(c-l)*(h-i+1)/(s-i+2);i=s;}return o}function Ma(t,n){if(!t||n.coords.length<2)return null;let e=Math.min(t.stations.length,t.line.length,t.weights.length);if(e<2)return null;let o=Is(t.stations.slice(0,e),t.line),r=t.line.slice(0,e).map(M=>M[0]),i=t.line.slice(0,e).map(M=>M[1]),s=o[0],a=o[e-1];if(!(a>s))return null;let u=Math.max(1,Math.ceil((a-s)/Ps)),l=[],c=[],m=[],h=0,f=0;for(;h<=u||f<e;){let M=h<=u?h===u?a:s+(a-s)*h/u:1/0,g=f<e?o[f]:1/0,x;if(M<=g?(x=M,h++):(x=g,f++),l.length&&!(x>l[l.length-1]+1e-9))continue;let L=Z(o,t.weights,x),R=Eo(n,x),_=Math.cos(R[1]*Math.PI/180)*Ct;l.push(x),c.push(L*(Z(o,r,x)-R[0])*_),m.push(L*(Z(o,i,x)-R[1])*Ct);}let p=M=>c[M]===0&&m[M]===0,b={stations:[],east:[],north:[]},d=l.length-1;for(let M=0;M<=d;M++)p(M)&&M>0&&M<d&&p(M-1)&&p(M+1)||(b.stations.push(l[M]),b.east.push(c[M]),b.north.push(m[M]));return b}function ks(t,n){let e=t.stations,o=Es;return {east:Z(e,t.east,n),north:Z(e,t.north,n),dEast:(Z(e,t.east,n+o)-Z(e,t.east,n-o))/(2*o),dNorth:(Z(e,t.north,n+o)-Z(e,t.north,n-o))/(2*o)}}function xa(t,n,e,o){if(!Number.isFinite(e))return {point:t,bearing:n};let r=0,i=0,s=0,a=0,u=false;for(let p of o){if(!p.track||!(p.alpha>0))continue;let b=Math.min(1,p.alpha),d=ks(p.track,e);r+=b*d.east,i+=b*d.north,s+=b*d.dEast,a+=b*d.dNorth,u=true;}if(!u)return {point:t,bearing:n};let l=n*Math.PI/180,c=Math.sin(l)+s,m=Math.cos(l)+a,h=c===0&&m===0?n:(Math.atan2(c,m)*180/Math.PI+360)%360,f=Math.cos(t[1]*Math.PI/180)*Ct;return {point:[t[0]+r/f,t[1]+i/Ct],bearing:h}}var bt={BEFORE_M:22,AFTER_M:18,NEARBY_M:50,END_MARGIN_M:3,MIN_ZOOM:14,BODY_PX:[[14,5],[16,10],[18,12]],BORDER_PX:[[14,8],[16,16],[18,19]],HEAD_SCALE:[[14,.5],[16,1],[18,1.15]],HEAD_BORDER_HALF_PX:15,HEAD_BORDER_LEN_PX:18,HEAD_FILL_HALF_PX:11,HEAD_FILL_LEN_PX:12,HEAD_FILL_INSET_PX:3,ROUND_PX:.75,SHADOW_PX:2.5,ARC_STEP:Math.PI/8,STEP_M:1,FILL:"#ffffff",CASING:"#055fcd",SHADOW:"#0b1a3a",FILL_OPACITY:1,CASING_OPACITY:1,SHADOW_OPACITY:.18,LIFT_M:.28,Z_SHADOW:23,Z_CASING:24,Z_FILL:25,ZOOM_STEP:.125,PASS_FADE_M:Ut};function So(t,n){let e=(t||"").toLowerCase(),o=(n||"").toLowerCase();switch(e){case "turn":case "merge":case "on ramp":case "off ramp":case "fork":case "end of road":case "roundabout":case "rotary":case "roundabout turn":case "exit roundabout":case "exit rotary":return true;case "continue":case "new name":return o!==""&&o!=="straight";default:return false}}function oe(t,n){if(n<=t[0][0])return t[0][1];for(let e=1;e<t.length;e++){let[o,r]=t[e];if(n<=o){let[i,s]=t[e-1];return s+(r-s)*(n-i)/(o-i)}}return t[t.length-1][1]}function va(t){return Math.floor(t/bt.ZOOM_STEP+.5)*bt.ZOOM_STEP}function Ss(t,n){let e=bt,o=n,r=oe(e.HEAD_SCALE,t)*o;return {bodyHalfM:oe(e.BODY_PX,t)/2*o,borderHalfM:oe(e.BORDER_PX,t)/2*o,headBorderHalfM:e.HEAD_BORDER_HALF_PX*r,headBorderLenM:e.HEAD_BORDER_LEN_PX*r,headFillHalfM:e.HEAD_FILL_HALF_PX*r,headFillLenM:e.HEAD_FILL_LEN_PX*r,headFillInsetM:e.HEAD_FILL_INSET_PX*r,roundM:e.ROUND_PX*o,shadowM:e.SHADOW_PX*o}}var tt=(t,n)=>({x:t.x-n.x,y:t.y-n.y}),nt=t=>Math.sqrt(t.x*t.x+t.y*t.y);function No(t,n){let e=[];for(let s of t)(!e.length||nt(tt(s,e[e.length-1]))>1e-6)&&e.push(s);if(e.length<2)return e;let o=[e[0]],r=0;for(let s=1;s<e.length;s++){let a=e[s-1],u=e[s],l=nt(tt(u,a)),c=n-r;for(;c<l-1e-9;)o.push({x:a.x+(u.x-a.x)*c/l,y:a.y+(u.y-a.y)*c/l}),c+=n;r=l-(c-n);}let i=e[e.length-1];return nt(tt(i,o[o.length-1]))>n*.25?o.push(i):o[o.length-1]=i,o}function ie(t){let n=[0];for(let e=1;e<t.length;e++)n.push(n[e-1]+nt(tt(t[e],t[e-1])));return n}function se(t,n,e){for(let o=1;o<t.length;o++)if(n[o]>=e){let r=n[o]-n[o-1],i=r>1e-12?(e-n[o-1])/r:0;return {x:t[o-1].x+(t[o].x-t[o-1].x)*i,y:t[o-1].y+(t[o].y-t[o-1].y)*i}}return t[t.length-1]}function Po(t,n){let e=t[n>0?n-1:0],o=t[n+1<t.length?n+1:t.length-1],r=tt(o,e),i=nt(r)||1;return {x:-r.y/i,y:r.x/i}}function Ns(t){let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=o.x*r.y-r.x*o.y;}return n/2}function Ot(t,n){let e=t.length,o=[];for(let r=0;r<e;r++){let i=t[(r+e-1)%e],s=t[r],a=t[(r+1)%e],u=tt(s,i),l=tt(a,s),c=nt(u)||1,m=nt(l)||1,h={x:u.y/c,y:-u.x/c},f={x:l.y/m,y:-l.x/m};if(u.x*l.y-u.y*l.x>1e-12){let x=Math.atan2(h.y,h.x),L=Math.atan2(f.y,f.x);for(;L<x;)L+=2*Math.PI;let R=Math.max(1,Math.ceil((L-x)/bt.ARC_STEP));for(let _=0;_<=R;_++){let v=x+(L-x)*_/R;o.push({x:s.x+Math.cos(v)*n,y:s.y+Math.sin(v)*n});}continue}let b=h.x+f.x,d=h.y+f.y,M=Math.sqrt(b*b+d*d);if(M<1e-9){o.push({x:s.x+h.x*n,y:s.y+h.y*n});continue}let g=n/(M/2);o.push({x:s.x+b/M*g,y:s.y+d/M*g});}return Cs(Os(o))}function Fs(t,n,e,o){let r=n.x-t.x,i=n.y-t.y,s=o.x-e.x,a=o.y-e.y,u=r*a-i*s;if(Math.abs(u)<1e-12)return null;let l=((e.x-t.x)*a-(e.y-t.y)*s)/u,c=((e.x-t.x)*i-(e.y-t.y)*r)/u;return l>1e-9&&l<1-1e-9&&c>1e-9&&c<1-1e-9?{x:t.x+r*l,y:t.y+i*l}:null}function Cs(t){let n=t;for(let e=0;e<64;e++){let o=n.length,r=null;for(let s=0;s<o&&!r;s++)for(let a=2;a<o/2&&!r;a++){let u=(s+a)%o,l=Fs(n[s],n[(s+1)%o],n[u],n[(u+1)%o]);l&&(r={i:s,j:u,p:l});}if(!r)return n;let i=[];for(let s=0;s<o;s++)(r.i<r.j?s>r.i&&s<=r.j:s>r.i||s<=r.j)||i.push(n[s]),s===r.i&&i.push(r.p);n=i;}return n}function Os(t){let n=t;for(let e=true;e&&n.length>3;){e=false;let o=[],r=n.length;for(let i=0;i<r;i++){let s=o.length?o[o.length-1]:n[(i+r-1)%r],a=n[i],u=n[(i+1)%r],l=a.x-s.x,c=a.y-s.y,m=u.x-a.x,h=u.y-a.y,f=l*m+c*h,p=l*h-c*m,b=Math.sqrt(l*l+c*c),d=Math.sqrt(m*m+h*h);if(b<1e-9||f<0&&Math.abs(p)<=.2*b*d){e=true;continue}o.push(a);}n=o;}return n}function Rn(t,n,e,o,r){let i=ie(t),s=i[i.length-1];if(s<o*1.2)return null;let a=s-o,u=se(t,i,s-r),l=se(t,i,a),c=tt(t[t.length-1],l),m=nt(c)||1,h={x:-c.y/m,y:c.x/m},f=Math.max(n-r,n*.02),p=Math.max(e-r,f),b=[],d=[];for(let v=0;v<t.length&&i[v]<a-1e-9;v++){let S=Po(t,v);b.push({x:t[v].x+S.x*f,y:t[v].y+S.y*f}),d.push({x:t[v].x-S.x*f,y:t[v].y-S.y*f});}let M=v=>(v.x-l.x)*c.x+(v.y-l.y)*c.y>=-1e-9;for(;b.length>1&&M(b[b.length-1]);)b.pop();for(;d.length>1&&M(d[d.length-1]);)d.pop();b.push({x:l.x+h.x*f,y:l.y+h.y*f}),d.push({x:l.x-h.x*f,y:l.y-h.y*f});let g=Po(t,0),x={x:-g.y,y:g.x},L=[],R=Math.max(2,Math.ceil(Math.PI/bt.ARC_STEP));for(let v=1;v<R;v++){let S=Math.PI*v/R,k=Math.cos(S),N=Math.sin(S);L.push({x:t[0].x+(g.x*k+x.x*N)*f,y:t[0].y+(g.y*k+x.y*N)*f});}let _=[...d,{x:l.x-h.x*p,y:l.y-h.y*p},u,{x:l.x+h.x*p,y:l.y+h.y*p},...b.reverse(),...L];return Ns(_)>=0?_:_.reverse()}function Io(t,n){let e=t[t.length-2],o=t[t.length-1],r=tt(o,e),i=nt(r)||1;return [...t,{x:o.x+r.x/i*n,y:o.y+r.y/i*n}]}function re(t,n,e,o,r){let i=t.length,s=n[i-1],a=[];for(let u of r){let l=1/0,c=0;for(let m=1;m<i;m++){let h=t[m-1],f=t[m],p=f.x-h.x,b=f.y-h.y,d=p*p+b*b,M=d>1e-12?((u.x-h.x)*p+(u.y-h.y)*b)/d:0;M=M<0?0:M>1?1:M;let g=u.x-(h.x+p*M),x=u.y-(h.y+b*M),L=g*g+x*x;L<l&&(l=L,c=n[m-1]+(n[m]-n[m-1])*M);}if(c<=0){let m=tt(t[1],t[0]),h=nt(m)||1;c=Math.min(0,((u.x-t[0].x)*m.x+(u.y-t[0].y)*m.y)/h);}else if(c>=s){let m=tt(t[i-1],t[i-2]),h=nt(m)||1;c=s+Math.max(0,((u.x-t[i-1].x)*m.x+(u.y-t[i-1].y)*m.y)/h);}a.push(e+c*o);}return a.push(a[0]),a}function Fo(t,n,e,o,r,i,s){let a=f=>{let p=f.map(t.toLonLat);return p.push(p[0]),p},u=ie(n),l=u[u.length-1],c=l>1e-9?(o-e)/l:1,m=re(n,u,e,c,s),h=-1/0;for(let f of m)f>h&&(h=f);return {line:n.map(t.toLonLat),fill:a(r),casing:a(i),shadow:a(s),fillStations:re(n,u,e,c,r),casingStations:re(n,u,e,c,i),shadowStations:m,endM:h}}function Aa(t,n,e={}){if(t.length<2)return [];let o=at(t),r=bt,i=e.zoom??16,s=Ss(i,e.metersPerPixel??H$1(t[0][1],i)),a=Math.min(s.roundM,s.bodyHalfM*.5),u=n.map((m,h)=>({m,i:h})).filter(({m})=>So(m.type,m.modifier)&&m.atM>=r.END_MARGIN_M&&o.length-m.atM>=r.END_MARGIN_M).sort((m,h)=>m.m.atM-h.m.atM||m.i-h.i),l=[];for(let m of u){let h=l[l.length-1];h&&m.m.atM-h[h.length-1].m.atM<=r.NEARBY_M?h.push(m):l.push([m]);}let c=[];for(let m of l){let h=m[0].m.atM,f=Math.max(0,h-r.BEFORE_M),p=Math.min(o.length,m[m.length-1].m.atM+r.AFTER_M),b=jn(o,f,p);if(b.length<2)continue;let d=$(b[0]),M=No(b.map(d.toXY),r.STEP_M);if(M.length<3)continue;let g=Rn(Io(M,s.headBorderLenM),s.borderHalfM,s.headBorderHalfM,s.headBorderLenM,a),x=Rn(Io(M,s.headFillInsetM+s.headFillLenM),s.bodyHalfM,s.headFillHalfM,s.headFillLenM,a);!g||!x||c.push({index:m[0].i,indices:m.map(L=>L.i),atM:h,fromM:f,toM:p,...Fo(d,M,f,p,Ot(x,a),Ot(g,a),Ot(g,a+s.shadowM))});}return c}var Co={BODY:.3,BORDER:.36,HEAD_FILL_HALF:.4,HEAD_BORDER_HALF:.47,HEAD_FILL_LEN:.9,HEAD_BORDER_LEN:1.1,HEAD_FILL_INSET:.15,ROUND:.05,SHADOW:.04,MIN_AFTER_M:8,SETTLE_PROBE_M:4,SETTLE_AHEAD_M:12,SETTLE_TAIL_M:6,SETTLE_DEG:15,SETTLE_STEP_M:1,SETTLE_MAX_M:40};function Ea(t,n){let e=bt,o=Co,r=t.features.filter(u=>u.kind==="band"&&u.outline&&u.stations&&u.stations.length===u.line.length&&u.line.length>=2);if(!r.length)return [];let i=n.map((u,l)=>({m:u,i:l})).filter(({m:u})=>So(u.type,u.modifier)).sort((u,l)=>u.m.atM-l.m.atM||u.i-l.i),s=[];for(let u of i){let l=s[s.length-1];l&&u.m.atM-l[l.length-1].m.atM<=e.NEARBY_M?l.push(u):s.push([u]);}let a=[];for(let u of s){let l=u[0].m.atM,c=u[u.length-1].m.atM,m=r.filter(N=>N.stations[0]<=l&&N.stations[N.stations.length-1]>=c+o.MIN_AFTER_M).sort((N,X)=>X.stations[X.stations.length-1]-X.stations[0]-(N.stations[N.stations.length-1]-N.stations[0]))[0];if(!m)continue;let h=m.stations,f=Math.max(h[0],l-e.BEFORE_M),p=Xs(m.line,h,Math.min(h[h.length-1],c+e.AFTER_M),Math.min(h[h.length-1],c+o.SETTLE_MAX_M)),b=Q(h,f),d=Q(h,p),M=K(m.line,b,d,gt);if(M.length<2)continue;let g=m.widths&&m.widths.length===m.line.length?m.widths:m.line.map(()=>m.width),x=K(g,Q(h,l),Q(h,l),mt)[0]??m.width,L=$(M[0]),R=No(M.map(L.toXY),e.STEP_M);if(R.length<3)continue;let _=Math.min(o.ROUND*x,o.BODY*x*.5),v=Rn(R,o.BORDER*x,o.HEAD_BORDER_HALF*x,o.HEAD_BORDER_LEN*x,_),S=Ys(R,o.HEAD_FILL_INSET*x),k=S?Rn(S,o.BODY*x,o.HEAD_FILL_HALF*x,o.HEAD_FILL_LEN*x,_):null;!v||!k||a.push({index:u[0].i,indices:u.map(N=>N.i),atM:l,fromM:f,toM:p,...Fo(L,R,f,p,Ot(k,_),Ot(v,_),Ot(v,_+o.SHADOW*x))});}return a}function Xs(t,n,e,o){let r=Co,i=l=>K(t,Q(n,l),Q(n,l),gt)[0],s=$(i(e)),a=(l,c)=>{let m=s.toXY(i(l)),h=s.toXY(i(c));return Math.atan2(h.y-m.y,h.x-m.x)},u=e;for(;u<o;){let l=Math.abs(a(u-r.SETTLE_PROBE_M,u)-a(u,u+r.SETTLE_AHEAD_M));if(Math.min(l,2*Math.PI-l)*180/Math.PI<=r.SETTLE_DEG)break;u=Math.min(o,u+r.SETTLE_STEP_M);}return u>e?Math.min(o,u+r.SETTLE_TAIL_M):u}function Ys(t,n){let e=ie(t),o=e[e.length-1];if(o-n<1)return null;let r=se(t,e,o-n),i=[];for(let s=0;s<t.length&&e[s]<o-n-1e-9;s++)i.push(t[s]);return i.push(r),i.length>=2?i:null}function Pa(t,n,e,o=0){if(e<bt.MIN_ZOOM)return [];let r=n??-1/0,i=[];return t.forEach((s,a)=>{(o>0?s.endM>r-o:s.toM>r)&&i.push(a);}),i}var ko=class{constructor(){this.items=new Map;this.at=null;this.gone=[];}show(n){let e=new Set(n);for(let[o,r]of this.items)r.on=e.has(o);for(let o of e)this.items.has(o)||this.items.set(o,{t:0,on:true});}tick(n){this.gone=[];let e=this.at===null||n-this.at>1e3||n<this.at?0:Math.min(n-this.at,ne);this.at=n;let o=e/te,r=false;for(let[i,s]of this.items){let a=s.on?1:0;if(s.t=a>s.t?Math.min(a,s.t+o):Math.max(a,s.t-o),!s.on&&s.t===0){this.items.delete(i),this.gone.push(i);continue}s.t!==a&&(r=true);}return r}settle(){this.gone=[];for(let[n,e]of this.items)e.on?e.t=1:(this.items.delete(n),this.gone.push(n));}alpha(n){let e=this.items.get(n);return e?U(e.t):0}has(n){return this.items.has(n)}get animating(){for(let n of this.items.values())if(n.t!==(n.on?1:0))return true;return false}};
2
- export{U as $,Gn as $a,es as $b,Ro as $c,tr as A,Pe as Aa,ln as Ab,Hi as Ac,nr as B,vr as Ba,Be as Bb,bo as Bc,er as C,ti as Ca,$e as Cb,Ut as Cc,or as D,Dn as Da,Ge as Db,Qn as Dc,rr as E,Ar as Ea,Ve as Eb,xo as Ec,de as F,Pr as Fa,Kn as Fb,Ki as Fc,sr as G,Ir as Ga,Vt as Gb,Ui as Gc,Hs as H,kr as Ha,cn as Hb,Wi as Hc,$s as I,Z as Ia,jt as Ib,zi as Ic,kn as J,Bn as Ja,Ke as Jb,qi as Jc,Yn as K,Hn as Ka,Un as Kb,Lo as Kc,Tt as L,Sr as La,ht as Lb,Zi as Lc,Sn as M,Nr as Ma,ze as Mb,xn as Mc,Fn as N,Fr as Na,Jr as Nb,Ji as Nc,Le as O,Cr as Oa,Qr as Ob,_o as Oc,hr as P,Or as Pa,ts as Pb,te as Pc,Cn as Q,Xr as Qa,ns as Qb,ne as Qc,H as R,Yr as Ra,Qe as Rb,Ls as Rc,Jt as S,Tr as Sa,qe as Sb,Rs as Sc,Re as T,Oe as Ta,gi as Tb,gn as Tc,Gs as U,$t as Ua,Ze as Ub,Wt as Uc,_e as V,ke as Va,dn as Vb,ea as Vc,Vs as W,Br as Wa,fn as Wb,_s as Wc,js as X,ct as Xa,eo as Xb,oa as Xc,fr as Y,ni as Ya,Ai as Yb,ra as Yc,we as Z,en as Za,Ei as Zb,sa as Zc,$ as _,Xe as _a,Pi as _b,ia as _c,Oo as a,nn as aa,it as ab,Ii as ac,ee as ad,Xo as b,dt as ba,ei as bb,os as bc,ca as bd,Yo as c,Et as ca,on as cb,Wn as cc,Ln as cd,To as d,G as da,Hr as db,ki as dc,Eo as dd,Do as e,Qt as ea,si as eb,ss as ec,Ao as ed,ce as f,$n as fa,$r as fb,as as fc,ma as fd,Bo as g,Mt as ga,ii as gb,us as gc,ha as gd,Ho as h,dr as ha,ai as hb,Si as hc,fa as hd,$o as i,Zs as ia,jr as ib,Ni as ic,Es as id,An as j,Js as ja,at as jb,so as jc,Ps as jd,Me as k,Mr as ka,xt as kb,Mn as kc,Is as kd,Pn as l,gr as la,jn as lb,Fi as lc,Ma as ld,Go as m,ve as ma,Kr as mb,Ci as mc,ks as md,Vo as n,yr as na,ci as nb,cs as nc,xa as nd,jo as o,Ne as oa,Q as ob,ho as oc,bt as od,Ko as p,Tn as pa,K as pb,Oi as pc,So as pd,Uo as q,tn as qa,mt as qb,Xi as qc,oe as qd,Wo as r,Fe as ra,Ur as rb,Yi as rc,va as rd,zo as s,Lr as sa,gt as sb,Ti as sc,Ss as sd,qo as t,Rr as ta,rn as tb,Di as tc,Ot as td,Zo as u,_r as ua,mi as ub,fs as uc,Aa as ud,Jo as v,Qs as va,hi as vb,bs as vc,Co as vd,Qo as w,Ae as wa,qr as wb,zn as wc,Ea as wd,fe as x,Ee as xa,st as xb,no as xc,Pa as xd,be as y,Ht as ya,di as yb,Bi as yc,ko as yd,pe as z,wr as za,Gt as zb,qn as zc};//# sourceMappingURL=chunk-NRKJQUT2.js.map
3
- //# sourceMappingURL=chunk-NRKJQUT2.js.map