2022-11-26 01:22:02 +00:00
|
|
|
(()=>{"use strict";class t{constructor(){this.states=new Map}get(t,e=null){return this.states.has(t)?this.states.get(t):(this.states.set(t,e),e)}set(t,e){return this.states.set(t,e)}change(t,e=1){let s=this.get(t,0);s+=e,this.set(t,s)}serialize(){const t=this.states.entries(),e=[];for(let s of t)e.push(s);return e}deserialize(t){this.states=new Map(t)}}class e{constructor(){this.inventory=[],this.currentRoom="start",this.context=null}addItem(t){this.inventory.push(t)}removeItem(t){this.inventory=this.inventory.filter((e=>e!=t))}getInventory(){return this.inventory.map((t=>this.context.getItem(t)))}}class s{speak(t){}stop(){}setOptions(t){}}class i extends s{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 e=document.createTextNode(t),s=document.createElement("p");s.appendChild(e),this.speechDisplay.appendChild(s),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class a extends s{constructor(t={}){super(),this.rate=t.rate||1,this.synth=window.speechSynthesis}speak(t){let e=new SpeechSynthesisUtterance(t);e.rate=this.rate,this.synth.speak(e)}stop(){this.synth.cancel()}setOptions(t){this.rate=t.rate||1}}class n{constructor(t=function(t="aria"){return"webtts"===t?new a:new i}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}var h=function(t,e,s,i){return new(s||(s=Promise))((function(a,n){function h(t){try{u(i.next(t))}catch(t){n(t)}}function r(t){try{u(i.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(h,r)}u((i=i.apply(t,e||[])).next())}))};class r{constructor(){this.context=new AudioContext}getContext(){return this.context}createGain(){return this.context.createGain()}getOutputDestination(){return this.context.destination}createBufferSource(){return this.context.createBufferSource()}decodeAudioData(t){return h(this,void 0,void 0,(function*(){return yield this.context.decodeAudioData(t)}))}createPanner(){return this.context.createPanner()}createMediaElementSource(t){return this.context.createMediaElementSource(t)}}class u{constructor(){this.events=new Map}emit(t,e={}){let s=this.events.get(t);if(s)s.subscribers.forEach((t=>{t(e)}));else{let e=new o(t);this.events.set(t,e)}}subscribe(t,e){let s=this.events.get(t);s||(s=new o(t),this.events.set(t,s)),s.subscribers.push(e)}unsubscribe(t,e){if(this.events.has(t)){let s=this.events.get(t);s.subscribers=s.subscribers.filter((t=>t!==e)),s.subscribers.length<1&&this.events.delete(t)}}unsubscribeAll(t){this.events.has(t)&&this.events.delete(t)}}class o{constructor(t){this.id=t,this.subscribers=[]}}class l{constructor(t){this.values=new Float32Array(4),void 0!==t&&(this.xyzw=t)}get x(){return this.values[0]}get y(){return this.values[1]}get z(){return this.values[2]}get w(){return this.values[3]}get xy(){return[this.values[0],this.values[1]]}get xyz(){return[this.values[0],this.values[1],this.values[2]]}get xyzw(){return[this.values[0],this.values[1],this.values[2],this.values[3]]}set x(t){this.values[0]=t}set y(t){this.values[1]=t}set z(t){this.values[2]=t}set w(t){this.values[3]=t}set xy(t){this.values[0]=t[0],this.values[1]=t[1]}set xyz(t){this.values[0]=t[0],this.values[1]=t[1],this.values[2]=t[2]}set xyzw(t){this.values[0]=t[0],this.values[1]=t[1],this.values[2]=t[2],this.values[3]=t[3]}get r(){return this.values[0]}get g(){return this.values[1]}get b(){return this.values[2]}get a(){return this.values[3]}get rg(){return[this.values[0],this.values[1]]}get rgb(){return[this.values[0],this.values[1],this.values[2]]}get rgba(){return[this.values[0],this.values[1],this.values[2],this.val
|