<script lang="ts">
import Track from "./components/track.svelte";
import Switch from "./components/switch.svelte";
import Label from "./components/label.svelte";
import Wye from "./components/wye.svelte";
import Map from "./Map.svelte";
import type { tile } from "./components/common";
const a={
Track,
Switch,
Label,
Wye,
} as const
const range=(l:number)=>[...Array(l).keys()]
const data:tile[]=[
{this:"Switch",props:{pos:[-1,4],line:[2,8],siding:7}},
{this:"Track",props:{pos:[-1,3],line:[2,9]}},
{this:"Label",props:{pos:[-1,3],text:"MF"}},
{this:"Track",props:{pos:[2,0],line:[1,6]}},
{this:"Switch",props:{pos:[1,1],line:[9,1],siding:4}},
{this:"Track",props:{pos:[0,1],line:[6,4]}},
{this:"Switch",props:{pos:[0,2],line:[9,1],siding:4}},
{this:"Track",props:{pos:[3,0],line:[4,6]}},
{this:"Switch",props:{pos:[-1,5],line:[2,8],siding:9}},
{this:'Track' ,props:{pos:[-1,6],line:[8,6]}},
{this:'Label' ,props:{pos:[-1,6],text:"CSW"}},
{this:"Track",props:{pos:[-1,1],line:[4,6]}},
{this:"Track",props:{pos:[-2,1],line:[2,6]}},
{this:"Wye" ,props:{pos:[-2,2],line:[2,8],siding:4}},
{this:"Track",props:{pos:[-2,3],line:[3,8]}},
{this:"Wye" ,props:{pos:[0,6],line:[4,6],siding:2}},
{this:'Track' ,props:{pos:[1,6],line:[4,6]}},
{this:"Wye" ,props:{pos:[2,6],line:[4,6],siding:2}},
{this:'Track' ,props:{pos:[3,6],line:[4,6]}},
{this:'Label' ,props:{pos:[3,6],text:"OWC"}},
{this:'Track' ,props:{pos:[4,6],line:[4,6]}},
{this:'Label' ,props:{pos:[4,6],text:"FM"}},
{this:"Switch",props:{pos:[5,6],line:[6,4],siding:7}},
{this:"Wye",props:{pos:[6,6],line:[8,2],siding:4}},
{this:"Track",props:{pos:[6,5],line:[8,2]}},
{this:"Label",props:{pos:[6,5],text:"SM"}},
{this:"Switch",props:{pos:[6,4],line:[2,8],siding:9}},
{this: "Track",props:{pos:[6,3],line:[8,2]}},
{this:"Wye" ,props:{pos:[6,2],line:[2,8],siding:6}},
{this:"Track" ,props:{pos:[7,2],line:[4,6]}},
{this:"Label" ,props:{pos:[7,2],text:"GF"}},
{this:"Wye" ,props:{pos:[6,1],line:[2,8],siding:6}},
{this:"Track" ,props:{pos:[7,1],line:[4,6]}},
{this:"Label" ,props:{pos:[7,1],text:"OWN"}},
{this:"Wye" ,props:{pos:[6,0],line:[4,6],siding:2}},
{this:"Track",props:{pos:[5,0],line:[4,6]}},
{this:"Label",props:{pos:[5,0],text:"FF"}},
{this:"Switch",props:{pos:[4,0],line:[6,4],siding:1}},
...(range(4).map<tile>(x=>({this:"Track",props:{pos:[0+x,4-x],line:[1,9]}}))),
{this:"Switch",props:{pos:[6,7],line:[8,2],siding:3}},
{this:"Switch",props:{pos:[7,8],line:[7,3],siding:6}},
{this:"Track",props:{pos:[6,8],line:[8,2]}},
{this:"Label",props:{pos:[6,8],text:"FRS"}},
{this:"Track",props:{pos:[6,9],line:[8,2]}},
{this:"Wye",props:{pos:[6,10],line:[4,6],siding:8}},
{this:"Track",props:{pos:[7,10],line:[4,6]}},
{this:"Track",props:{pos:[8,9],line:[7,2]}},
{this:"Wye",props:{pos:[8,10],line:[4,6],siding:8}},
...range(3).map<tile>(x=>({this:"Track",props:{pos:[0,7+x],line:[8,2]}})),
{this:"Label",props:{pos:[0,9],text:"SW"}},
{this:"Track",props:{pos:[0,10],line:[8,2]}},
{this:"Track",props:{pos:[0,11],line:[8,6]}},
{this:"Track",props:{pos:[1,11],line:[4,6]}},
{this:"Track",props:{pos:[2,11],line:[4,8]}},
{this:"Wye",props:{pos:[2,10],line:[8,2],siding:6}},
...range(3).map<tile>(x=>({this:"Track",props:{pos:[2,7+x],line:[8,2]}})),
{this:"Track",props:{pos:[3,10],line:[4,6]}},
{this:"Switch",props:{pos:[4,10],line:[4,6],siding:9}},
{this:"Track",props:{pos:[5,10],line:[4,6]}},
{this:"Track",props:{pos:[9,10],line:[4,8]}},
{this:"Wye",props:{pos:[8,8],line:[4,6],siding:8}},
{this:"Track",props:{pos:[9,9],line:[8,2]}},
{this:"Wye",props:{pos:[9,8],line:[4,6],siding:2}},
{this:"Track",props:{pos:[10,8],line:[4,6]}},
{this:"Label",props:{pos:[10,8],text:"HT"}},
{this:"Track",props:{pos:[11,8],line:[4,8]}},
{this:"Switch",props:{pos:[11,7],line:[8,2],siding:3}},
{this:"Track",props:{pos:[11,6],line:[4,2]}},
{this:"Switch",props:{pos:[10,6],line:[6,4],siding:7}},
{this:"Track",props:{pos:[9,6],line:[6,1]}},
{this:"Track",props:{pos:[8,7],line:[9,2]}},
{this:"Track",props:{pos:[9,5],line:[8,3]}},
{this:"Track",props:{pos:[8,-2],line:[2,6]}},
{this:"Track",props:{pos:[9,-2],line:[4,3]}},
{this:"Switch",props:{pos:[10,-1],line:[2,8],siding:7}},
{this:"Track",props:{pos:[8,1],line:[8,6]}},
...range(3).map<tile>(x=>({this:"Track",props:{pos:[7+x,0],line:[6,4]}})),
{this:"Track",props:{pos:[10,0],line:[4,8]}},
{this:"Track",props:{pos:[10,-2],line:[2,6]}},
{this:"Track",props:{pos:[11,-2],line:[4,6]}},
{this:"Switch",props:{pos:[12,-2],line:[4,6],siding:1}},
{this:"Track",props:{pos:[13,-2],line:[4,2]}},
{this:"Switch",props:{pos:[13,-1],line:[2,8],siding:9}},
{this:"Track",props:{pos:[14,-2],line:[1,6]}},
{this:"Label",props:{pos:[14,-2],text:"IME"}},
{this:"Track",props:{pos:[14,-1],line:[1,6]}},
{this:"Label",props:{pos:[14,-1],text:"CM"}},
{this:"Switch",props:{pos:[13,0],line:[2,8],siding:9}},
{this:"Track",props:{pos:[11,-1],line:[4,9]}},
{this:"Label",props:{pos:[11,-1],text:"MB"}},
...range(3).map<tile>(x=>({this:"Track",props:{pos:[9,2+x],line:[8,2]}})),
{this:"Wye",props:{pos:[9,1],line:[4,6],siding:2}},
...range(3).map<tile>(x=>({this:"Track",props:{pos:[10+x,1],line:[4,6]}})),
{this:"Track",props:{pos:[13,1],line:[4,8]}},
{this:"Track",props:{pos:[8,-1],line:[8,2]}},
]
const o=data.sort((a,b)=>{
const t=a.props.pos[0]-b.props.pos[0]
if (t==0){
return a.props.pos[1]-b.props.pos[1]
}
return t
}).map(x=>({...x,props:{...x.props,pos:[x.props.pos[0]+2,x.props.pos[1]+2]}}))
// alert(JSON.stringify(o))
</script>
<Map tiles={data}/>