(()=>{"use strict";const t=new class{constructor(){this.states=new Map}get(t){return this.states.get(t)}set(t,i){return this.states.set(t,i)}};class i{constructor(){this.inventory=[],this.currentRoom="start"}}class e{speak(t){}stop(){}setOptions(t){}}class s extends e{constructor(t={}){super(),this.timeout=100,this.timeout=t.timeout||100,this.init()}init(){this.container=document.createElement("div"),this.container.setAttribute("aria-live","polite"),this.speechDisplay=document.createElement("div"),this.speechDisplay.setAttribute("aria-live","polite"),this.container.append(this.speechDisplay),document.body.appendChild(this.container),document.body.insertBefore(this.container,document.body.firstChild)}speak(t){this.clearDisplay();const i=document.createTextNode(t),e=document.createElement("p");e.appendChild(i),this.speechDisplay.appendChild(e),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class o extends e{}class n{constructor(t=function(t="aria"){return"webtts"===t?o:s}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}class a{constructor(){this.tts=new n(new s),this.history=document.getElementById("output-area")}say(t){const i=document.createElement("p");i.appendChild(document.createTextNode(t)),this.history.appendChild(i)}}class r{constructor(t){this.handler=t,this.inputField=document.getElementById("input-area"),this.init()}init(){this.inputField.addEventListener("keydown",(t=>{if(13==t.which){const t=this.inputField.value;this.inputField.value="",this.handler.doCommand(t)}}))}}const h=[[["look","l"],function(t,i){i.examineRoom()}]];class c{constructor(t,i){this.context=t,this.commands=i||new Map,this.addDefaultCommands()}doCommand(t){const i=this.context.getRoom(this.context.player.currentRoom),e=t.split(" ");this.commands.get(e[0])&&this.commands.get(e[0])(e,this.context),i.getExit(e[0])&&this.context.move(i.getExit(e[0]))}addCommand(t,i){Array.isArray(t)?t.forEach((t=>this.commands.set(t,i))):this.commands.set(t,i)}addCommands(t){t.forEach((t=>{this.addCommand(t[0],t[1])}))}addDefaultCommands(){this.addCommands(h)}}class l{constructor(){this.id="room",this.title="A room",this.description="You see nothing special",this.firstDescription="As you walk into the room, you notice nothing special",this.objects=[],this.exits=new Map,this.enterCallback=null,this.exitCallback=null,this.canEnterLogic=null,this.canExitLogic=null,this.tickCallback=null,this.context=null}async onEnter(){if(this.enterCallback)return this.enterCallback(this.context)}async onExit(){if(this.exitCallback)return this.exitCallback(this.context)}canEnter(){return!this.canEnterLogic||this.canEnterLogic(this.context)}canExit(){return!this.canExitLogic||this.canExitLogic(this.context)}addExit(t,i){return this.exits.set(t,i),this}getExit(t){return this.exits.get(t)}addItem(t){this.objects.push(t)}addEnterCallback(t){this.enterCallback=t}addExitCallback(t){this.exitCallback=t}addEnterLogic(t){this.canEnterLogic=t}addExitLogic(t){this.canExitLogic=t}addTickCallback(t){this.tickCallback=t}}class d{constructor(){this.room=new l}withID(t){return this.room.id=t,this}withTitle(t){return this.room.title=t,this}withFirstDescription(t){return this.room.firstDescription=t,this}withDescription(t){return this.room.description=t,this}withExit(t,i){return this.room.addExit(t,i),this}withItem(t){return this.room.addItem(t),this}withEnterCallback(t){return this.room.addEnterCallback(t),this}withExitCallback(t){return this.room.addExitCallback(t),this}withEnterLogic(t){return this.room.addEnterLogic(t),this}withExitLogic(t){return this.room.addExitLogic(t),this}withTick(t){return this.room.addTickCallback(t),this}create(){return this.room}}const m=[(new d).withID("start").withTitle("The starting room").withFirstDescription("You set foot in your very first room").withDescription("The first room. Nothing special about it.").withExit("north","tunnel_1").withEnterCallback((async function(t){const{output:i,wait:e}=t;i.say("You slowly wake up"),await e(5e3),i.say("It's strange. You never used to be able to be conscious about the fact that you were waking up."),await e(5e3),i.say("Yet here we are.")})).create(),(new d).withID("tunnel_1").withTitle("A long dark tunnel").withFirstDescription("You first step foot in this dark loomy tunnel.").withDescription("The walls are wet. Everything is wet. Ugh. Why do you even.").withExit("south","start").create()];(new class{constructor(){this.player=new i,this.state=t,this.rooms=[],this.items=[],this.output=new a,this.commandHandler=new c(this),this.input=new r(this.commandHandler),this.visitedRooms=new Map}print(t){this.output.say(t)}init(t){this.rooms=t.rooms.map((t=>(t.context=this,t))),this.items=t.items.map((t=>(t.context=this,t))),this.state=t.state,this.commandHandler.addCommands(t.commands),this.player=new i,this.move(this.player.currentRoom)}examineRoom(){const t=this.getRoom(this.player.currentRoom);this.output.say(t.title),this.visitedRooms.get(this.player.currentRoom)||""==t.firstDescription?this.output.say(t.description):this.output.say(t.firstDescription)}getRoom(t){return this.rooms.find((i=>i.id==t))}getItem(t){return this.items.find((i=>i.id==t))}wait(t){return new Promise(((i,e)=>{setTimeout(i,t)}))}async move(t){const i=this.getRoom(this.player.currentRoom),e=this.getRoom(t);i.canExit()&&e.canEnter()&&(await i.onExit(),await e.onEnter(),this.player.currentRoom=t,this.examineRoom(),this.visitedRooms.set(t,!0))}}).init({rooms:m,commands:[[["meow","mew"],async function(t,i){i.print("You meow.")}]],items:[]})})(); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFNDSHBCLE1BQU1DLEVBQ1RDLE1BQU1DLElBR05DLFFBR0FDLFdBQVdDLEtDTlIsTUFBTUMsVUFBbUJOLEVBQzVCWCxZQUFZZ0IsRUFBVSxJQUNsQkUsUUFDQWpCLEtBQUtrQixRQUFVLElBQ2ZsQixLQUFLa0IsUUFBVUgsRUFBUUcsU0FBVyxJQUNsQ2xCLEtBQUttQixPQUVUQSxPQUNJbkIsS0FBS29CLFVBQVlDLFNBQVNDLGNBQWMsT0FDeEN0QixLQUFLb0IsVUFBVUcsYUFBYSxZQUFhLFVBQ3pDdkIsS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0cmluZykge1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShzdHJpbmcpO1xyXG4gICAgfVxyXG5cclxuICAgIGluaXQoZGF0YSkge1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBkYXRhLnJvb21zLm1hcCgocm9vbSkgPT4ge1xyXG4gICAgICAgICAgICByb29tLmNvbnRleHQgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gcm9vbTtcclxuICAgICAgICB9KTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gZGF0YS5pdGVtcy5tYXAoKGl0ZW0pID0+IHtcclxuICAgICAgICAgICAgaXRlbS5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5zdGF0ZSA9IGRhdGEuc3RhdGU7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlci5hZGRDb21tYW5kcyhkYXRhLmNvbW1hbmRzKTtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLm1vdmUodGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgfVxyXG5cclxuICAgIGV4YW1pbmVSb29tKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShyb29tLnRpdGxlKTtcclxuICAgICAgICBpZiAoIXRoaXMudmlzaXRlZFJvb21zLmdldCh0aGlzLnBsYXllci5jdXJyZW50Um9vbSkgJiYgcm9vbS5maXJzdERlc2NyaXB0aW9uICE9IFwiXCIpIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZmlyc3REZXNjcmlwdGlvbik7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBnZXRSb29tKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMucm9vbXMuZmluZCgocm9vbSkgPT4gcm9vbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0SXRlbShpZCkge1xyXG4gICAgICAgIHJldHVybiB0aGlzLml0ZW1zLmZpbmQoKGl0ZW0pID0+IGl0ZW0uaWQgPT0gaWQpO1xyXG4gICAgfVxyXG5cclxuICAgIHdhaXQobXMpIHtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICBzZXRUaW1lb3V0KHJlc29sdmUsIG1zKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBhc3luYyBtb3ZlKHJvb21JRCkge1xyXG4gICAgICAgIGNvbnN0IGN1cnJlbnRSb29tID0gdGhpcy5nZXRSb29tKHRoaXMucGxheWVyLmN1cnJlbnRSb29tKTtcclxuICAgICAgICBjb25zdCBuZXdSb29tID0gdGhpcy5nZXRSb29tKHJvb21JRCk7XHJcbiAgICAgICAgaWYgKGN1cnJlbnRSb29tLmNhbkV4aXQoKSAmJiBuZXdSb29tLmNhbkVudGVyKCkpIHtcclxuICAgICAgICAgICAgYXdhaXQgY3VycmVudFJvb20ub25FeGl0KCk7XHJcbiAgICAgICAgICAgIGF3YWl0IG5ld1Jvb20ub25FbnRlcigpO1xyXG4gICAgICAgICAgICB0aGlzLnBsYXllci5jdXJyZW50Um9vbSA9IHJvb21JRDtcclxuICAgICAgICAgICAgdGhpcy5leGFtaW5lUm9vbSgpO1xyXG4gICAgICAgICAgICB0aGlzLnZpc2l0ZWRSb29tcy5zZXQocm9vbUlELCB0cnVlKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbn0iLCJleHBvcnQgZGVmYXVsdCBh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