!function(t){function o(o){for(var i,r,a=o[0],l=o[1],c=o[2],h=0,p=[];hMath.floor(Math.random()*(o-(t+1)))+t,c=(t,o)=>{const n=o.reduce((t,o)=>t+o,0),i=l(0,n);let e=0;for(let n=0;nnew e.Point(l(0,window.innerWidth),l(0,window.innerHeight)),h=(t,o)=>Math.abs(t.x-o.x)<1&&Math.abs(t.y-o.y)<1,p=(t,o)=>{const n=t.x-o.x,i=t.y-o.y;return Math.sqrt(n*n+i*i)},u=(t,o,n,i,e)=>(t-o)*(e-i)/(n-o)+i;var f,w;(w=f||(f={}))[w.North=0]="North",w[w.Northeast=1]="Northeast",w[w.East=2]="East",w[w.Southeast=3]="Southeast",w[w.South=4]="South",w[w.Southwest=5]="Southwest",w[w.West=6]="West",w[w.Northwest=7]="Northwest";const g=(t,o)=>{const n=((t,o)=>180+((t,o)=>Math.atan2(-(o.x-t.x),o.y-t.y))(t,o)*(180/Math.PI))(t,o);let i=null;if(n>=337.5||n<22.5)i=f.North;else if(n>=22.5&&n<67.5)i=f.Northeast;else if(n>=67.5&&n<112.5)i=f.East;else if(n>=112.5&&n<157.5)i=f.Southeast;else if(n>=157.5&&n<202.5)i=f.South;else if(n>=202.5&&n<247.5)i=f.Southwest;else if(n>=247.5&&n<292.5)i=f.West;else{if(!(n>=292.5&&n<337.5))throw Error("Angle between points is not a valid degree");i=f.Northwest}return i};let x=0;class y{static largestStation(t){let o=null;for(const n of t)(null===o||n.population>o.population)&&(o=n);return o}static stationsWithinRadius(t,o,n){return t.filter(t=>p(o,t.location)<=n)}static stationsInDirection(t,o,n){return t.filter(t=>g(o,t.location)===n)}static closestStation(t,o){return t.reduce((t,n)=>p(o,t.location)t.population);return c(i,e)}static isPointDistant(t,o,n){for(const i of o)if(p(t,i.location)0;){const i=d();if(y.isPointDistant(i,t,o))return i;n-=1}return null}constructor(t,o,n,i){this.location=t,this.population=o,this.color=n,this.connections=i||[],x+=1,this.id=x,this.label=new PIXI.Text(`${this.id}`,{fill:"#FFA500",fontFamily:"monospace",fontSize:"12px"})}}const m=Math.floor(Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2))/8);class b{constructor(t,o){this.name=t,this.color=o}connectStations(t,o,n,i){n.push(t);const e=o.filter(o=>o!==t),s=y.stationsWithinRadius(e,t.location,m);for(let o=0;o{const t=new e.Application({antialias:!0,height:window.innerHeight,width:window.innerWidth}),o=new i({screenHeight:window.innerHeight,screenWidth:window.innerWidth,worldHeight:1e3,worldWidth:1e3}),n=new s;n.showPanel(0),document.body.appendChild(n.dom);const a=new e.ticker.Ticker,d=new e.Graphics,f=(t=>{const o=[];for(let t=0;t<30;t+=1)o.push(new y(y.randomDistantPoint(o,30),l(300,2e3),r.random()));return o})(),w=(((t,o)=>{const n=[];for(let t=0;t<4;t+=1){let i=r.random();for(;i.isDark();)i=r.random();const e=o.filter(t=>0===t.connections.length),s=y.largestStation(e),a=new b(`line-${t}`,r.random()),l=o.slice(0);a.connectStations(s,l,[],5),n.push(a)}})(0,f),((t,o)=>{const n=[],i=f.filter(t=>t.connections.length>0);for(let t=0;t<50;t+=1){const t=i[Math.floor(Math.random()*i.length)];n.push(new v(new e.Point(t.location.x,t.location.y),0,0,t,void 0,r("grey")))}return n})());a.stop(),a.add(t=>{n.begin(),((t,o)=>{for(const o of t){if(0===o.origin.connections.length)continue;if(void 0===o.destination){const t=o.origin.connections.map(t=>t.station),n=t.map(t=>t.population);o.destination=c(t,n);const i=l(0,Math.min(50-o.passengers,o.origin.population));0===o.passengers?o.color=o.origin.color:o.color=r.mix(o.color,o.origin.color,Math.round(i/o.passengers*100)),o.passengers+=i,o.origin.population-=i}if(h(o.location,o.destination.location)){o.speed=0,o.destination.color=r.mix(o.destination.color,o.origin.color,Math.round(o.passengers/o.destination.population*100));const t=l(0,o.passengers);o.destination.population+=t,o.passengers-=t,o.origin=o.destination,o.destination=void 0;continue}const t=p(o.location,o.destination.location);o.speed/.025>=t/o.speed-3&&.025!==o.speed?o.speed-=.025:o.speed<10&&(o.speed+=.025);const n=o.speed/t;o.location.x+=(o.destination.location.x-o.location.x)*n,o.location.y+=(o.destination.location.y-o.location.y)*n}})(w),d.clear(),d.lineStyle(1,16753920,1),((t,o)=>{for(const n of t){const t=n.population/150;o.beginFill(parseInt(n.color.toHex(),16),.5),o.drawCircle(n.location.x,n.location.y,t),o.endFill(),n.label.x=n.location.x+t+1,n.label.y=n.location.y+t+1}})(f,d),d.lineStyle(1,11447982,1),((t,o)=>{for(const o of t){const t=u(o.passengers,0,50,1,5)/100;o.sprite.x=o.location.x,o.sprite.y=o.location.y,o.sprite.scale.x=t,o.sprite.scale.y=t,o.sprite.tint=parseInt(o.color.toHex(),16),o.label.x=o.location.x+t+1,o.label.y=o.location.y+t+1}})(w),((t,o)=>{for(const n of t)for(const t of n.connections){let i=!1;for(const o of t.station.connections)o.station===n&&(i=!0);o.lineStyle(i?2:1,parseInt(t.line.color.toHex(),16),1),o.moveTo(n.location.x,n.location.y),o.lineTo(t.station.location.x,t.station.location.y)}})(f,d),n.end()}),a.start(),o.addChild(d);for(const t of w)o.addChild(t.sprite);for(const t of w)o.addChild(t.label);for(const t of f)o.addChild(t.label);document.body.appendChild(t.view),t.stage.addChild(o),o.drag().pinch().wheel().clampZoom({maxHeight:4e3,maxWidth:4e3,minHeight:100,minWidth:100}).decelerate(),window.addEventListener("resize",()=>{t.renderer.resize(window.innerWidth,window.innerHeight)})})},116:function(t,o){},239:function(t,o){}}); //# sourceMappingURL=main.min.js.map