intart_the_metro_v2 let theMetro=e=>{let t=new Random(e.seed),o={inverseScaleBase:5,inverseScaleConstant:5,minInverScale:1.5,ignoreAutoScaleCanvas:!1,stopRadius:2.5,lineWidth:2,wagonWidth:1,stopWidth:1.5,lineSeperationScale:1.5,wagonStrokeScale:2.8,metroLineId:0,metroLines:[],metroLinePaths:[],metroLineGroups:[],flatStops:[],wagons:[],metroLineSize:{},metroLineCenter:{},metroLineScale:1,minViewScale:1,viewScale:1,windowScale:1,targetViewScale:1,maxViewScale:0,viewScaleRelativeToWindow:1,pointerOffsetX:0,pointerOffsetY:0,pointerDown:!1,pointerDownX:0,pointerDownY:0,pointerX:0,pointerY:0,baseCameraX:0,baseCameraY:0,targetCameraX:0,targetCameraY:0,cameraX:0,cameraY:0,cameraDownX:0,cameraDownY:0,pickedWagon:void 0,wagonsEnabled:!0,zoomEnabled:!1,zoomScale:5,maxZoomScale:5,isZoomedIn:!1,isInIdleMode:!1,smoothness:0,targetSmoothness:0,idleModeTimer:0,idleModeChangeCount:0,isFinished:!1,previousWidth:0,previousHeight:0,touches:[]};(()=>{if(Object.keys(e).forEach((t=>{o[t]=e[t]})),e.canvas?o.canvas=e.canvas:(_sb.createMainCanvas(),o.canvas=_sb.mainCanvas),e.ignoreBodyStyle||(document.body.style.overflow="hidden",document.body.style.margin="0"),o.ctx=o.canvas.getContext("2d"),o.canvas.style.touchAction="none",e.ignoreAutoScaleCanvas||(o.canvas.style.width="100%",o.canvas.style.height="100%"),e.pixelRatio?o.pScale=e.pixelRatio:o.pScale=window.devicePixelRatio,!e.ignoreMetaTag){let e=document.createElement("meta");e.name="viewport",e.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0",document.getElementsByTagName("head")[0].appendChild(e)}o.theme=e.theme,(!o.theme.ls||o.theme.ls&&0==o.theme.ls.length)&&(o.theme.ls=o.theme.b)})();let n=(e,t)=>{let n=o.theme.lineColors.filter((t=>t[0]==e));return 1==n.length?n[0]:0==n.length?o.theme.lineColors[t%o.theme.lineColors.length]:n[t%n.length]},a=e=>e&&1==e?o.viewScale>1:o.viewScale>.5,i=({x:e,y:t,x1:n,y1:a,width:i,color:r})=>{o.ctx.beginPath(),o.ctx.moveTo(e,t),o.ctx.lineTo(n,a),o.ctx.globalAlpha=1,o.ctx.strokeStyle=r,o.ctx.lineCap="round",o.ctx.lineWidth=i,o.ctx.stroke()},r=({x:e,y:t,x1:o,y1:n,width:a,stroke:r,color:s,strokeColor:l})=>{i({x:e,y:t,x1:o,y1:n,width:r,color:l}),i({x:e,y:t,x1:o,y1:n,width:a,color:s})},s=e=>e.x+"_"+e.y,l=(e,t)=>{let o=(e=>{let t=2*Math.PI;for(e%=t;e<0;)e+=t;return e})(e-t);return 90==Math.floor(180*o/Math.PI)},c=(e,t)=>e.x==t.x||e.y==t.y,h=(e,t)=>e*(o.viewScale+o.inverseScaleBase/Math.max(o.minInverScale,o.viewScale/.5)*o.inverseScaleConstant*t),d=(e,t)=>{let o=m(t.stop0,t.stop1)+.5*Math.PI,n=t.indexes[e.id]-(t.lineCount-1)/2;return{x:Math.cos(o)*n,y:Math.sin(o)*n}},m=(e,t)=>{let o=e.x-t.x,n=e.y-t.y;return Math.atan2(n,o)},g=(e,t)=>{let o=[e.ox+""+e.oy,t.ox+""+t.oy];return o.sort(),o.join("")},p=(e,t,n,a)=>({x:e.x+a*Math.cos(t-Math.PI/2)*n*h(o.lineWidth+.5*o.lineSeperationScale,.1)*.5,y:e.y+a*Math.sin(t-Math.PI/2)*n*h(o.lineWidth+.5*o.lineSeperationScale,.1)*.5}),u=e=>{e.forEach((e=>{let t=1;if(e.stopScale>1&&(t=.6*e.stopScale),e.stopScale<3)(({x:e,y:t,r:n,width:i})=>{a(1)&&(o.ctx.beginPath(),o.ctx.arc(e,t,n,0,2*Math.PI),o.ctx.lineWidth=i,o.ctx.fillStyle=o.theme.sf,o.ctx.strokeStyle=o.theme.ss,o.ctx.fill(),o.ctx.stroke())})({x:e.x,y:e.y,r:h(o.stopRadius*t,.05),width:h(o.stopWidth,.05)});else if(t=1,e.massiveConnections.length>1){if(!a(1))return;e.massiveConnections.forEach((n=>{let a=p(e,n.angle,n.count,1),r=p(e,n.angle,n.count,-1);i({x:a.x,y:a.y,x1:r.x,y1:r.y,width:h(2*o.stopWidth*t*2,.05),color:o.theme.ss})})),e.massiveConnections.forEach((n=>{let a=p(e,n.angle,n.count,1),r=p(e,n.angle,n.count,-1);i({x:a.x,y:a.y,x1:r.x,y1:r.y,width:h(2*o.stopWidth*t,.05),color:o.theme.sf})}))}else if(e.crossPairs){if(!a(1))return;e.crossPairs.forEach((n=>{let a=p(e,n.angle,n.count,1),r=p(e,n.angle,n.count,-1);i({x:a.x,y:a.y,x1:r.x,y1:r.y,width:h(2*o.stopWidth*t*2,.05),color:o.theme.ss})})),e.crossPairs.forEach((n=>{let a=p(e,n.angle,n.count,1),r=p(e,n.angle,n.count,-1);i({x:a.x,y:a.y,x1:r.x,y1:r.y,width:h(2*o.stopWidth*t,.05),color:o.theme.sf})}))}else{if(!a(1))return;let n=p(e,e.biggestAngle.angle,e.biggestAngle.count,1),i=p(e,e.biggestAngle.angle,e.biggestAngle.count,-1);r({x:n.x,y:n.y,x1:i.x,y1:i.y,width:h(2*o.stopWidth*t,.05),stroke:h(2*o.stopWidth*t*2,.05),color:o.theme.sf,strokeColor:o.theme.ss})}}))},x=e=>{if(!o.wagonsEnabled)return;let t=h(.8*o.lineWidth,.1),n=h(.8*o.lineWidth*o.wagonStrokeScale,.1),a=n,i=h(o.wagonWidth,.1),s=i,l=y(e);e.order=l.order,l.progress>.7?(s=i*Math.abs(1-l.progress)/.3,a=n*Math.abs(1-l.progress)/.1):l.progress<.3?(s=i*(1-Math.abs(l.progress-.3)/.3),a=n*(1-Math.abs(l.progress-.1)/.1)):(s=i,a=n),l.progress>.9?a=n*Math.abs(1-l.progress)/.1:l.progress<.1?a=n*(1-Math.abs(l.progress-.1)/.1):(s=i,a=n);let c=Math.cos(l.angle)*s+l.x,d=Math.sin(l.angle)*s+l.y,m=Math.cos(l.angle)*-s+l.x,g=Math.sin(l.angle)*-s+l.y;r({x:c,y:d,x1:m,y1:g,width:t,stroke:a,color:e.metroLine.color[1],strokeColor:e.metroLine.color[0]}),e.progress>100?(e.waitProgress+=e.speed,e.waitProgress>105&&(e.progress=0,e.waitProgress=0,e.currentPath.wagons=e.currentPath.wagons.filter((t=>t!=e)),e.direction?(e.index++,e.index==e.metroLine.paths.length&&(e.index=e.metroLine.paths.length-1,e.direction=0)):(e.index--,e.index<0&&(e.index=0,e.direction=1)),e.currentPath=e.metroLine.paths[e.index],e.metroLine.paths[e.index].wagons.push(e))):e.progress+=e.speed},w=e=>{let t={x:1e13,y:1e13,r:0,b:0,center:{x:0,y:0}};return e.forEach((e=>{e.stops.forEach((e=>{t.x=Math.min(t.x,e.x),t.y=Math.min(t.y,e.y),t.r=Math.max(t.r,e.x),t.b=Math.max(t.b,e.y),t.center.x+=e.x,t.center.y+=e.y}))})),t.center.x=(t.r+t.x)/2,t.center.y=(t.b+t.y)/2,t},f=e=>{(e=>{let t=w(e),o=Math.abs(t.r-t.x),n=Math.abs(t.b-t.y);Math.max(o,n),e.forEach((e=>{e.stops.forEach((e=>{e.x=e.x-t.center.x,e.y=e.y-t.center.y,e.ox=e.x,e.oy=e.y}))}))})(e);let t=w(e);o.metroLineCenter.x=.5*Math.floor(t.r-t.x)+t.x,o.metroLineCenter.y=.5*Math.floor(t.b-t.y)+t.y,o.metroLineSize.width=Math.abs(t.r-t.x),o.metroLineSize.height=Math.abs(t.b-t.y),o.metroLineSize.maxSize=Math.max(o.metroLineSize.width,o.metroLineSize.height),o.metroLineSize.volume=o.metroLineSize.width*o.metroLineSize.height},y=e=>{let t,n,a=e=>-(Math.cos(Math.PI*e)-1)/2,i=h(o.lineWidth,.1),r=e.metroLine.paths[e.index],s=r.lines[e.metroLine.id].stop0,l=r.lines[e.metroLine.id].stop1,c=d(e.metroLine,r);return c.x*=i*o.lineSeperationScale,c.y*=i*o.lineSeperationScale,e.direction?(t={x:s.x+c.x,y:s.y+c.y},n={x:l.x+c.x,y:l.y+c.y}):(n={x:s.x+c.x,y:s.y+c.y},t={x:l.x+c.x,y:l.y+c.y}),{x:t.x+a(e.progress/100)*(n.x-t.x),y:t.y+a(e.progress/100)*(n.y-t.y),angle:m(t,n),progress:e.progress/100,order:r.lineCount}},v=(e,o,n,a)=>({metroLine:e,progress:100*t.random_dec(),waitProgress:0,speed:o,index:n,direction:a,order:0,currentPath:e.paths[n]}),S=()=>{if(o.isFinished||window.requestAnimationFrame(S),M(),o.targetSmoothness=o.isInIdleMode?.005:.1,o.smoothness+=.01*(o.targetSmoothness-o.smoothness),o.isInIdleMode&&o.pickedWagon){let e=y(o.pickedWagon);o.targetCameraX=-(e.x-o.pointerOffsetX)+.5*o.canvas.width,o.targetCameraY=-(e.y-o.pointerOffsetY)+.5*o.canvas.height}var e;o.viewScale+=(o.targetViewScale-o.viewScale)*o.smoothness,o.cameraX+=(o.targetCameraX-o.cameraX)*o.smoothness,o.cameraY+=(o.targetCameraY-o.cameraY)*o.smoothness,o.pointerOffsetX=o.cameraX,o.pointerOffsetY=o.cameraY,e=o.metroLines,o.flatStops,e.forEach((e=>{e.stops.forEach(((e,t)=>{e.x=e.ox*o.viewScale+o.pointerOffsetX*o.pScale,e.y=e.oy*o.viewScale+o.pointerOffsetY*o.pScale}))})),o.ctx.beginPath(),o.ctx.rect(0,0,o.canvas.width,o.canvas.height),o.ctx.fillStyle=o.theme.b,o.ctx.fill(),((e,t)=>{a(1)||t.forEach((t=>{t.lineList.forEach((n=>{let a=e[n.metroLineId],i=h(o.lineWidth,.2),s=h(o.lineWidth,.15),l=n.stop0,c=n.stop1,m=d(a,t);m.x*=s*o.lineSeperationScale,m.y*=s*o.lineSeperationScale;let g=o.theme.ls;if(g&&g.length>0){let e=.18;o.theme.ls==o.theme.b&&(e=0),r({x:l.x+m.x,y:l.y+m.y,x1:c.x+m.x,y1:c.y+m.y,width:i,stroke:h(2*o.lineWidth,e),color:a.color[0],strokeColor:g})}}))}))})(o.metroLines,o.metroLinePaths,o.wagons),((e,t,n)=>{t.forEach((t=>{t.lineList.forEach((n=>{let s=e[n.metroLineId],l=h(o.lineWidth,.2),c=h(o.lineWidth,.15),m=n.stop0,g=n.stop1,p=d(s,t);p.x*=c*o.lineSeperationScale,p.y*=c*o.lineSeperationScale;let u=o.theme.ls;if(u&&u.length>0&&a(1)){let e=.15;o.theme.ls==o.theme.b&&(e=0),r({x:m.x+p.x,y:m.y+p.y,x1:g.x+p.x,y1:g.y+p.y,width:l,stroke:h(2*o.lineWidth,e),color:s.color[0],strokeColor:u})}else i({x:m.x+p.x,y:m.y+p.y,x1:g.x+p.x,y1:g.y+p.y,width:l,color:s.color[0]})})),t.wagons.forEach((e=>{x(e)}))}))})(o.metroLines,o.metroLinePaths,o.wagons),u(o.flatStops),o.onRender&&o.onRender()},L=()=>{e.svgData?o.metroLines=(e=>{let t=e.split("<symbol id='group'")[1].split("</symbol")[0].split("<path d='M"),a=[];for(let e=1;e<t.length;e++){let i=t[e].split("' stroke='"),r=i[0],s=i[1].split("'/>")[0],l=r.split(" "),c=[];for(let e=0;e<l.length;e+=2){let t=parseInt(l[e]),o=parseInt(l[e+1]);c.push({x:t,y:o,tx:t,ty:o})}let h=e=>c[e];c.forEach(((e,t)=>{e.n||(e.n=[]),0==t?c[0].n.push(1):t<c.length-1?(c[t].n.push(t-1),c[t].n.push(t+1)):t==c.length-1&&c[t].n.push(t-1)})),a.push({stops:c,id:o.metroLineId,color:n(s,o.metroLineId),getStop:h}),o.metroLineId++}return a})(e.svgData):o.metroLines=(e=>{let t=[];return e.forEach((e=>{let a=[];e.stops.forEach((e=>{a.push({x:e.x,y:e.y})})),a.forEach(((e,t)=>{e.n||(e.n=[]),0==t?a[0].n.push(1):t<a.length-1?(a[t].n.push(t-1),a[t].n.push(t+1)):t==a.length-1&&a[t].n.push(t-1)})),t.push({stops:a,id:o.metroLineId,color:n(e.color,o.metroLineId),getStop:e=>a[e]}),o.metroLineId++})),t})(e.data),f(o.metroLines),o.flatStops=(e=>{let t={},o=0;e.forEach((e=>{e.stops.forEach(((n,a)=>{let i=s(n);if(t[i]){t[i].lineIds.includes(e.id)||t[i].lineIds.push(e.id);let o=n.n.map((o=>{let a=e.getStop(o),r=e.id+""+s(a),l=m(n,a),h=c(a,n);return t[i].outGoingDirections[l]?(t[i].outGoingDirections[l].count++,t[i].outGoingDirections[l].count>t[i].maxDirectionAngle.count&&(t[i].maxDirectionAngle={angle:l,count:t[i].outGoingDirections[l].count})):(t[i].totalDifferentOutgoinDirection++,t[i].outGoingDirections[l]={count:1,isAngular:h}),t[i].maxDirection=Math.max(t[i].outGoingDirections[l].count,t[i].maxDirection),t[i].maxDirection>1?t[i].stopScale=1.2*t[i].maxDirection:t[i].stopScale=t[i].maxDirection,{id:r,metroLine:e.id,direction:l,indexInLine:o,stop:a}}));t[i].neighbours=t[i].neighbours.concat(o),e.stops[a]=t[i]}else{let r={},l=0,h=0,d={};t[i]={id:o,x:n.x,y:n.y,ox:n.x,oy:n.y,lineIds:[e.id],outGoingDirections:{},stopScale:1,neighbours:n.n.map((t=>{let o=e.getStop(t),a=e.id+"_"+s(o),i=m(n,o),g=c(o,n);return r[i]?(r[i].count++,r[i].count>d.count&&(d={angle:i,count:r[i].count,stop0:n,stop1:o})):(l++,d={angle:i,count:1},r[i]={count:1,isAngular:g}),h=Math.max(r[i].count,h),{id:a,metroLine:e.id,direction:i,indexInLine:t,stop:o,maxDirectionAngle:d}}))},t[i].outGoingDirections=r,t[i].totalDifferentOutgoinDirection=l,t[i].maxDirection=h,t[i].maxDirectionAngle=d,e.stops[a]=t[i],o++}}))}));let n=Object.values(t);return n.forEach((e=>{let t=Object.keys(e.outGoingDirections),o=[],n=[];t.forEach((t=>{let a=e.outGoingDirections[t].isAngular,i=e.outGoingDirections[t].count;i>2&&o.push({angle:t,count:i,isAngular:a}),i>3&&n.push({angle:t,count:i})})),o.sort(((e,t)=>{let o=Math.pow(e.count,3)+(e.isAngular?5:0);return Math.pow(t.count,3)+(t.isAngular?5:0)-o}));let a=!1,i=[];o.forEach((e=>{o.forEach((t=>{l(e.angle,t.angle)&&e!=t&&(a=!0,i.push({connection1:e,connection2:t}))}))})),i.sort(((e,t)=>e.connection1.count+e.connection2.count-(t.connection1.count+t.connection2.count))),e.hasAngularDirection=!1,e.angularDirectionAngle=0,e.bigConnections=o,e.hasAnyCross=a,e.massiveConnections=n,i.length>0&&(e.crossPairs=[i[0].connection1,i[0].connection2]),o.length>0?e.biggestAngle={angle:o[0].angle,count:o[0].count}:e.biggestAngle={angle:e.maxDirectionAngle.angle,count:e.maxDirectionAngle.count}})),n})(o.metroLines),o.metroLinePaths=(e=>{let t={};e.forEach((e=>{e.paths=[];for(let o=0;o<e.stops.length-1;o++){let n=e.stops[o],a=e.stops[o+1],i=g(n,a);if(t[i]){let o={metroLineId:e.id,stop0:n,stop1:a,angle:m(n,a)};o.stop0=n,o.stop1=a,o.isAngular=c(n,a),t[i].lines[e.id]=o}else{let o={lines:[],wagons:[]};o.lines[e.id]={metroLineId:e.id,stop0:n,stop1:a,angle:m(n,a)},o.stop0=n,o.stop1=a,o.isAngular=c(n,a),t[i]=o}e.paths.push(t[i])}})),e.forEach((e=>{e.paths.forEach((t=>{let o=Object.keys(t.lines);o.sort(((e,t)=>e.metroLineId>t.metroLineId));let n=o.indexOf(e.id.toString());t.indexes||(t.indexes={}),t.lineCount=o.length,t.indexes[e.id]=n}))}));let o=Object.values(t);return o.forEach((e=>{e.lineList=Object.values(e.lines)})),o.sort(((e,t)=>Math.pow(e.lineCount,3)+(e.isAngular?1:0)-(Math.pow(t.lineCount,3)+(t.isAngular?1:0)))),o})(o.metroLines),o.wagons=(e=>{let o=[];return e.forEach((e=>{let n=.6*t.random_dec()+.2,a=v(e,n,0,1),i=v(e,n,e.stops.length-2,0);if(a.currentPath.wagons.push(a),i.currentPath.wagons.push(i),o.push(a),o.push(i),e.stops.length>6){let t=v(e,n,Math.floor((e.stops.length-1)/2),1),a=v(e,n,Math.floor((e.stops.length-1)/2),0);t.currentPath.wagons.push(t),a.currentPath.wagons.push(a),o.push(t),o.push(a)}})),o})(o.metroLines)},M=()=>{o.canvasBoundry=o.canvas.getBoundingClientRect(),o.ignoreAutoScaleCanvas?(o.canvas.width=o.canvasBoundry.width*o.pScale,o.canvas.height=o.canvasBoundry.height*o.pScale):(o.canvas.width=window.innerWidth*o.pScale,o.canvas.height=window.innerHeight*o.pScale);let e=0;if(e=o.canvas.width/o.canvas.height>o.metroLineSize.width/o.metroLineSize.height?o.canvas.height/o.metroLineSize.height*.8:o.canvas.width/o.metroLineSize.width*.8,o.maxViewScale>0&&e>o.maxViewScale&&(e=o.maxViewScale),o.previousWidth!=o.canvas.width||o.previousHeight!=o.canvas.height){let t=o.canvas.width/o.previousWidth,n=o.canvas.height/o.previousHeight,a=e/o.windowScale;o.viewScale*=a,o.cameraX*=t,o.cameraY*=n,o.targetCameraX=o.cameraX,o.targetCameraY=o.cameraY,o.targetViewScale=o.viewScale,o.minViewScale=e,o.windowScale=e,o.previousWidth=o.canvas.width,o.previousHeight=o.canvas.height,e<2&&(o.zoomEnabled=!0)}},C=()=>o.targetViewScale!=o.minViewScale,b=e=>{if(o.zoomEnabled)if(C()||o.isInIdleMode)o.targetViewScale=o.minViewScale,o.targetCameraX=.5*o.canvasBoundry.width,o.targetCameraY=.5*o.canvasBoundry.height,o.pickedWagon=void 0,o.isZoomedIn=!1,E();else{Y();let e=o.maxZoomScale,t=(o.pointerX-o.cameraX)/o.viewScale,n=(o.pointerY-o.cameraY)/o.viewScale;o.targetCameraX=o.pointerX-t*e,o.targetCameraY=o.pointerY-n*e,o.targetViewScale=e,o.isZoomedIn=!0}},I=()=>{o.zoomEnabled&&(C()&&!o.isInIdleMode||(o.smoothness=.005,o.targetViewScale=o.maxZoomScale,o.pickedWagon=t.random_choice(o.wagons),o.isInIdleMode=!0,X()))},E=()=>{Y(),o.pickedWagon=null,isIdleModeChanging=!1,o.idleModeChangeCount=0,o.isInIdleMode=!1,o.idleModeTimer=setTimeout((()=>{I()}),1e4)},Y=()=>{o.isInIdleMode=!1,o.idleModeTimer&&clearInterval(o.idleModeTimer)},X=()=>{o.idleModeTimer&&clearInterval(o.idleModeTimer),o.idleModeChangeCount++,o.idleModeTimer=setTimeout((()=>{o.idleModeChangeCount>2?D():I()}),35e3)},D=()=>{o.idleModeChangeCount=0,o.pickedWagon=void 0,o.targetCameraX=.5*o.canvasBoundry.width,o.targetCameraY=.5*o.canvasBoundry.height,o.targetViewScale=o.minViewScale,Y(),o.idleModeTimer=setTimeout((()=>{I()}),3e4)},W=()=>{o.metroLineScale=1,o.viewScale=o.minViewScale,o.targetViewScale=o.minViewScale,o.pointerX=.5*o.canvasBoundry.width,o.pointerY=.5*o.canvasBoundry.height,o.cameraX=.5*o.canvasBoundry.width,o.cameraY=.5*o.canvasBoundry.height,o.targetCameraX=o.cameraX,o.targetCameraY=o.cameraY,Y(),o.idleModeTimer=setTimeout((()=>{I()}),3e4)},k=!1,A=e=>{var t;if(e.preventDefault(),(t=e).toffsetX=t.offsetX,t.toffsetY=t.offsetY,o.touches.push(t),o.pointerDown=!0,1==o.touches.length){if(o.pointerX=e.offsetX,o.pointerY=e.offsetY,o.pointerDownX=o.pointerX,o.pointerDownY=o.pointerY,o.cameraDownX=o.cameraX,o.cameraDownY=o.cameraY,!k)return k=!0,setTimeout((function(){k=!1}),300),!1;b()}},P=e=>{(e=>{const t=o.touches.findIndex((t=>t.pointerId===e.pointerId));o.touches.splice(t,1)})(e),o.pointerDown=!1,o.touchDistance=void 0},V=e=>{var t;if(t=e,o.touches.forEach((e=>{e.pointerId===t.pointerId&&(e.toffsetX=t.offsetX,e.toffsetY=t.offsetY)})),o.pointerDown){let t=0,n=0;if(o.touches.forEach((e=>{t+=e.offsetX})),o.touches.forEach((e=>{n+=e.offsetY})),t/=o.touches.length,n/=o.touches.length,o.pointerX=t,o.pointerY=n,1==o.touches.length){if(o.isInIdleMode&&(Y(),b()),!o.isZoomedIn)return;o.cameraX=o.cameraDownX-(o.pointerDownX-e.offsetX),o.cameraY=o.cameraDownY-(o.pointerDownY-e.offsetY),o.targetCameraX=o.cameraX,o.targetCameraY=o.cameraY}else if(2==o.touches.length){let e=o.touches[1].toffsetX-o.touches[0].toffsetX,t=o.touches[1].toffsetY-o.touches[0].toffsetY,n=Math.sqrt(e*e+t*t);if(null!=o.touchDistance){let e=n-o.touchDistance;O(.01*e),o.touchDistance=n}else o.touchDistance=n}}else o.pointerX=e.offsetX,o.pointerY=e.offsetY;doubleTap=!1},T=e=>{87===e.keyCode&&(o.wagonsEnabled=!o.wagonsEnabled),83===e.keyCode&&(e=>{let t=document.createElement("a");t.href=e,t.download="themetro",document.body.appendChild(t),t.click()})(o.canvas.toDataURL("image/png"))},z=e=>{O(.005*e.wheelDeltaY)},O=e=>{if(!o.zoomEnabled)return;Y();let t=o.viewScale;t+=e,t>o.maxZoomScale&&(t=o.maxZoomScale),t<o.minViewScale&&(t=o.minViewScale,E());let n=(o.pointerX-o.cameraX)/o.viewScale,a=(o.pointerY-o.cameraY)/o.viewScale;o.viewScale=t,o.cameraX=o.pointerX-n*t,o.cameraY=o.pointerY-a*t,o.targetCameraX=o.cameraX,o.targetCameraY=o.cameraY,o.targetViewScale=o.viewScale,o.isZoomedIn=!0},B=!1,G=()=>{B||(B=!0,L(),S(),W(),o.canvas.addEventListener("pointerdown",A),o.canvas.addEventListener("pointerup",P),o.canvas.addEventListener("pointermove",V),o.canvas.addEventListener("keydown",T),o.canvas.addEventListener("wheel",z))},R=()=>{0==o.canvas.width||0==o.canvas.height||0==window.innerWidth||0==window.innerHeight?setTimeout((()=>{R()}),1):G()};return o.start=()=>{window&&(R(),window.addEventListener("load",(()=>{R()})))},o.finish=()=>{o.isFinished=!0,o.canvas.removeEventListener("pointerdown",A),o.canvas.removeEventListener("pointerup",P),o.canvas.removeEventListener("pointermove",V),o.canvas.removeEventListener("keydown",T),o.canvas.removeEventListener("wheel",z),Y()},o};
↓ show full (18,094 bytes)