@textadventures/quest-viva-wasmplayer 6.1.2 → 6.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/v2/v2.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var s={autoScroll:!0,warnedAboutScript:!1,animateScroll:!0,fadePreviousOutput:!1,continueOnClick:!1,commandPlaceholder:null,compassDirections:[],interfaceStrings:new Map,gameFinished:!1,soundWait:!1,waiting:!1,pausing:!1,inDialog:!1,turnPending:!0,hasUnsavedProgress:!1,canSave:!1},V=new Map;function Xt(e,t){if(typeof t!="function")return;let n=V.get(e);n||V.set(e,n=new Set),n.add(t)}function te(e,t){V.get(e)?.delete(t)}function y(e,t){for(let n of V.get(e)??[])try{n(t)}catch(o){console.error(o)}}function ee(){s.autoScroll=!0,s.warnedAboutScript=!1,s.fadePreviousOutput=!1,s.continueOnClick=!1,s.commandPlaceholder=null,s.interfaceStrings.clear(),s.compassDirections=[],s.gameFinished=!1,s.soundWait=!1,s.waiting=!1,s.pausing=!1,s.inDialog=!1,s.turnPending=!0,s.hasUnsavedProgress=!1,V.clear()}var wn={inventory:"inventoryChanged",objects:"objectsChanged",exits:"exitsChanged",status:"statusChanged"},nt={inventory:[],objects:[],exits:[],status:[]},wt=new Set;function ne(){return structuredClone(nt)}function oe(){nt={inventory:[],objects:[],exits:[],status:[]},wt.clear()}function P(e,t){if(wt.has(e)&&JSON.stringify(t)===JSON.stringify(nt[e]))return;wt.add(e),nt[e]=t;let n=structuredClone(t);y(wn[e],e==="exits"?{exits:n}:{items:n})}function re(e){return{text:String(e.Text??""),name:String(e.ElementName??""),elementId:String(e.ElementId??""),verbs:(e.Verbs??[]).map(String)}}var C=typeof HTMLElement.prototype.showPopover=="function";function H(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.hasAttribute("tabindex")||(t.tabIndex=0),t.setAttribute("role","button"),t.classList.contains("elementmenu")&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false")),t.toggleAttribute("aria-disabled",t.classList.contains("disabled"));for(let t of e.querySelectorAll("[data-qv-popup]"))t.setAttribute("aria-controls",t.dataset.qvPopup??""),t.setAttribute("aria-expanded","false")}function ie(e){for(let t of e.querySelectorAll("[data-qv-popup-content].qv-popup-open"))t.classList.remove("qv-popup-open");for(let t of e.querySelectorAll('[aria-expanded="true"]'))t.setAttribute("aria-expanded","false")}function M(e,t){e.classList.toggle("disabled",!t),t?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")}var k=e=>e.classList.contains("disabled");function xt(e){e.setAttribute("data-qv-deactivated",""),M(e,!1)}function se(e){return Array.isArray(e)?e.map(String):[]}function ae(e,t,n){if(t==="object"){let o=n&&typeof n=="object"?n:{};for(let r of e.querySelectorAll("a.elementmenu")){let i=o[r.dataset.elementid??""];i&&(r.dataset.verbs=String(i)),M(r,!!i)}}else if(t==="exit"){let o=se(n);for(let r of e.querySelectorAll("a.exitlink"))M(r,o.includes(r.dataset.elementid??""))}else if(t==="command"){let o=se(n);for(let r of e.querySelectorAll("a.commandlink:not([data-qv-deactivated])")){let i=r.dataset.elementid??"";M(r,i===""||o.includes(i))}}}function le(e,t,n){let o=document.getElementById(e);o&&(o.classList.add("cmdlink","elementmenu"),o.dataset.verbs=t,o.dataset.elementid||(o.dataset.elementid=n),H(o.parentElement??o))}function ce(e,t){let n=e.target instanceof Element?e.target:null;if(!n)return;let o=n.closest("[data-qv-popup]");if(o){e.preventDefault(),Mn(o);return}let r=n.closest("[data-qv-direction]");if(r){r.disabled||v(r.dataset.qvDirection??"");return}let i=n.closest(".qv-pane-verb");if(i){pe(i);return}let l=n.closest(".qv-pane-item");if(l){me(l);return}let c=n.closest("[data-qv-popup-content]");c&&de(c);let u=n.closest("a");u&&(u.matches(".cmdlink, [data-qv-event]")?qn(e,u,t):u.hasAttribute("href")&&xn(e,u))}function qn(e,t,n){if(t.dataset.qvEvent!==void 0){if(e.preventDefault(),k(t))return;if(t.dataset.qvEvent==="ShowMenuResponse")for(let o of t.ownerDocument.querySelectorAll('a[data-qv-event="ShowMenuResponse"]'))M(o,!1);L(t.dataset.qvEvent,t.dataset.qvParam??"")}else if(t.classList.contains("elementmenu"))e.preventDefault(),k(t)||n?.toggle(t);else if(t.classList.contains("exitlink"))e.preventDefault(),k(t)||v(t.dataset.command??"");else if(t.classList.contains("commandlink")){if(e.preventDefault(),k(t)||!Q())return;t.dataset.deactivateonclick==="true"&&xt(t),v(t.dataset.command??"")}}function xn(e,t){let n=t.getAttribute("href")??"";n.startsWith("#")||/^\s*javascript:/i.test(n)||(e.preventDefault(),window.open(t.href,"_blank","noopener"))}function ue(e){if(e.key!=="Enter"&&e.key!==" ")return;let t=e.target instanceof HTMLAnchorElement?e.target:null;t?.matches(".cmdlink, [data-qv-event]")&&(e.preventDefault(),t.click())}function Tn(e){let t=document.getElementById(e.dataset.qvPopup??"");return t?.hasAttribute("data-qv-popup-content")?t:null}function Mn(e){let t=Tn(e);if(t){if(t.classList.contains("qv-popup-open")){de(t);return}C&&!t.popover&&(t.popover="auto",t.addEventListener("beforetoggle",n=>{n.newState==="closed"&&qt(t,!1)})),qt(t,!0),C&&t.showPopover()}}function de(e){C&&e.matches(":popover-open")&&e.hidePopover(),qt(e,!1)}function qt(e,t){e.classList.toggle("qv-popup-open",t);for(let n of document.querySelectorAll(`[data-qv-popup="${CSS.escape(e.id)}"]`))n.setAttribute("aria-expanded",String(t))}var Mt=["inventory","objects","status","compass","commands","customstatus"],Cn={InventoryLabel:"inventory",PlacesObjectsLabel:"objects",StatusLabel:"status",CompassLabel:"compass"},ot=class extends HTMLElement{#e;#t;#n;connectedCallback(){this.#e||(this.dataset.qvPart="pane",this.#e=document.createElement("details"),this.#e.open=!0,this.#t=document.createElement("summary"),this.#t.className="qv-pane-heading",this.#t.textContent=this.getAttribute("label")??"",this.#n=document.createElement("div"),this.#n.className="qv-pane-body",this.#n.append(...this.childNodes),this.#e.append(this.#t,this.#n),this.append(this.#e))}get name(){return this.dataset.qvPane??""}get body(){return this.#n}setLabel(t){this.#t.innerHTML=t}setContent(t){this.#n.innerHTML=t,H(this.#n)}};function f(e){return a()?.querySelector(`qv-pane[data-qv-pane="${CSS.escape(e)}"]`)??null}var An={inventory:"inventory",placesobjects:"objects"};function he(e,t){let n=An[e];if(!n)return;let o=new Set(s.compassDirections),r=Object.values(t).map(u=>JSON.parse(u)).filter(u=>e!=="placesobjects"||!o.has(u.Text));P(n,r.map(re));let i=f(n);if(!i)return;let l=I.get(n);l!==void 0&&!r.some(u=>Tt(u)===l)&&I.delete(n);let c=document.createElement("ul");if(c.className="qv-pane-list",r.forEach((u,d)=>c.append(Pn(n,u,`qv-${n}-verbs-${d}`))),c.childElementCount)i.body.replaceChildren(c);else{let u=document.createElement("p");u.className="qv-pane-empty",u.innerHTML=s.interfaceStrings.get(n==="inventory"?"InventoryEmptyLabel":"PlacesObjectsEmptyLabel")??s.interfaceStrings.get("EmptyListLabel")??"",i.body.replaceChildren(u)}a()?.verbMenu?.closeIfStale()}var I=new Map,Tt=e=>e.ElementId||e.ElementName;function ve(){I.clear()}function Pn(e,t,n){let o=document.createElement("li"),r=document.createElement("button");r.type="button",r.className="qv-pane-item",r.innerHTML=t.Text,r.dataset.qvKey=Tt(t),o.append(r);let i=(t.Verbs??[]).map(String).map(u=>u.trim()).filter(Boolean);if(!i.length)return o;let l=document.createElement("div");l.id=n,l.className="qv-pane-verbs",l.setAttribute("role","group"),l.setAttribute("aria-label",r.textContent?.trim()??"");for(let u of i){let d=document.createElement("button");d.type="button",d.className="qv-pane-verb",d.textContent=u,d.dataset.command=`${u.toLowerCase()} ${t.ElementName}`,d.dataset.qvName=t.ElementName,t.ElementId&&(d.dataset.elementid=t.ElementId),l.append(d)}let c=I.get(e)===Tt(t);return l.hidden=!c,r.setAttribute("aria-expanded",String(c)),r.setAttribute("aria-controls",n),o.append(l),o}function me(e){let t=e.closest("qv-pane"),n=e.nextElementSibling;if(!t||!n?.classList.contains("qv-pane-verbs"))return;let o=n.hidden;for(let r of t.body.querySelectorAll('.qv-pane-item[aria-expanded="true"]'))r.setAttribute("aria-expanded","false"),r.nextElementSibling.hidden=!0;o?(n.hidden=!1,e.setAttribute("aria-expanded","true"),I.set(t.name,e.dataset.qvKey??""),n.scrollIntoView({block:"nearest"})):I.delete(t.name)}function pe(e){let t=e.dataset.qvName??"",n={};e.dataset.elementid&&(n[t]=e.dataset.elementid),v(e.dataset.command??"",n)}function ge(e){let t=f("commands");if(!t)return;let o=(Array.isArray(e)?e.map(String):String(e??"").split(";")).filter(r=>r.trim()).map(r=>{let[i,l]=r.split(":"),c=u=>u.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");return`<a class="cmdlink commandlink" data-elementid="" data-command="${c((l??i).trim().toLowerCase())}">${c(i.trim())}</a>`}).join(" ");t.setContent(o)}function be(e,t){e==="map"||e!=="customstatus"&&Mt.includes(e)||f(e)?.setContent(t)}function ye(e,t,n){let o=a()?.panes;if(!e||e==="map"||!o||f(e))return;let r=document.createElement("qv-pane");r.dataset.qvPane=e,r.setAttribute("label",t??e),o.append(r),r.setContent(n??"")}function Se(e){let t=a()?.panes;if(!t)return;let n=Array.isArray(e)?e.map(String):String(e??"").split(";");for(let o of[...n].reverse()){let r=f(o);r&&t.prepend(r)}}function Ee(e,t){let n=Cn[e];return n?(f(n)?.setLabel(t),!0):!1}function rt(){return!!a()?.panes?.classList.contains("qv-drawer-open")}function w(e,{restoreFocus:t=!0}={}){let n=a(),o=n?.panes,r=n?.panesButton;!o||!r||e===rt()||(o.classList.toggle("qv-drawer-open",e),r.setAttribute("aria-expanded",String(e)),e?(document.addEventListener("pointerdown",fe,!0),o.querySelector('summary, button, a[href], [tabindex="0"]')?.focus()):(document.removeEventListener("pointerdown",fe,!0),t&&o.contains(document.activeElement)&&r.focus()))}function fe(e){let t=a(),n=e.target instanceof Node?e.target:null;!n||t?.panes?.contains(n)||t?.panesButton?.contains(n)||t?.verbMenu?.contains(n)||w(!1,{restoreFocus:!1})}var kn=["northwest","north","northeast","west","east","southwest","south","southeast","up","down","in","out"],we=[315,0,45,270,90,225,180,135,null,null,null,null],Le="http://www.w3.org/2000/svg",Ct=[[1,1],[1,2],[1,3],[2,1],[2,3],[3,1],[3,2],[3,3]],W=[];function st(){return s.compassDirections.length===12?s.compassDirections:kn}function qe(e){let t=st()[e];return e===10?At(s.interfaceStrings.get("InButtonLabel"))||t:e===11&&At(s.interfaceStrings.get("OutButtonLabel"))||t}function At(e){if(!e)return"";let t=document.createElement("template");return t.innerHTML=e,t.content.textContent?.trim()??""}function xe(e,t){let n=st()[e],o=document.createElement("button");o.type="button",o.className=t,o.dataset.qvDirection=n;let r=we[e];return r!=null&&o.append(Hn(r)),o}function Hn(e){let t=document.createElementNS(Le,"svg");t.setAttribute("class","qv-direction-arrow"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round");let n=document.createElementNS(Le,"path");return n.setAttribute("d","M12 19V5M5 12l7-7 7 7"),n.setAttribute("transform",`rotate(${e} 12 12)`),t.append(n),t}function B(){let e=f("compass");if(e){let t=document.createElement("div");t.className="qv-compass-points";let n=document.createElement("div");n.className="qv-compass-others",st().forEach((r,i)=>{let l=xe(i,"qv-compass-button"),c=qe(i);l.setAttribute("aria-label",c),l.title=c,we[i]==null&&l.append(c),l.disabled=!W.includes(r),Ct[i]?(l.style.gridRow=String(Ct[i][0]),l.style.gridColumn=String(Ct[i][1]),t.append(l)):n.append(l)});let o=document.createElement("div");o.className="qv-compass",o.append(t,n),e.body.replaceChildren(o)}h()}function Te(e){W=String(e??"").split("/").filter(Boolean),P("exits",[...W]),B()}function Me(){W=[]}function h(){let e=a(),t=e?.exits;if(!e||!t)return;let n=f("compass"),o=!!n&&!n.hidden&&!e.panes?.hidden,r=!s.turnPending&&!s.waiting&&!s.pausing&&!s.inDialog&&!s.gameFinished,i=[];o&&r&&st().forEach((l,c)=>{if(!W.includes(l))return;let u=xe(c,"qv-exit");u.append(qe(c)),i.push(u)}),t.replaceChildren(...i),t.setAttribute("aria-label",At(s.interfaceStrings.get("CompassLabel"))||(WebPlayer.chromeStrings?.CompassLabel??"Compass")),t.classList.toggle("qv-exits-active",i.length>0)}var N=[];function Pt(e){N=Array.isArray(e)?e.filter(t=>t&&typeof t=="object"):[],P("status",N),kt()}function Ce(e){Pt(String(e??"").split(/\r?\n|<br\s*\/?>/i).filter(t=>t.trim()).map(t=>({text:t})))}function Ae(){N=[]}function In(e){let t=Number(e.value),n=Number(e.max);return e.value==null||e.max==null||!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:{value:Math.min(Math.max(t,0),n),max:n}}var Bn=0;function Pe(e,t){let n=document.createElement(t);n.className="qv-status-item",e.name&&(n.dataset.qvStatus=String(e.name));let o=document.createElement("span");o.className="qv-status-text",o.id=`qv-status-${++Bn}`,o.innerHTML=String(e.text??""),n.append(o);let r=In(e);if(r){let i=document.createElement("span");i.className="qv-status-meter",i.setAttribute("role","meter"),i.setAttribute("aria-valuemin","0"),i.setAttribute("aria-valuemax",String(r.max)),i.setAttribute("aria-valuenow",String(r.value)),i.setAttribute("aria-labelledby",o.id);let l=document.createElement("span");l.className="qv-status-meter-fill",l.style.width=`${r.value/r.max*100}%`,i.append(l),n.append(i)}return n}function kt(){let e=f("status");if(e){let t=document.createElement("ul");t.className="qv-status-list",t.append(...N.map(n=>Pe(n,"li"))),e.body.replaceChildren(t),e.toggleAttribute("data-qv-empty",N.length===0)}it()}function it(){let e=a(),t=e?.statusBar;if(!e||!t)return;let n=f("status"),r=!!n&&!n.hidden&&!e.panes?.hidden?N.filter(i=>i.pinned):[];t.replaceChildren(...r.map(i=>Pe(i,"span"))),t.classList.toggle("qv-status-bar-active",r.length>0),e.updateTopbar()}var at=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",Ht=null,D=null,lt=null,j=[],ct=0,It=!0,z=!1,Bt="header",$=(e,t)=>WebPlayer.chromeStrings?.[e]??t,Nn={gridSquareClicked:(e,t)=>{L("JS_GridSquareClick",`${e};${t}`)},animate:()=>s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches,strings:()=>({map:$("MapLabel","Map"),zoomIn:$("MapZoomIn","Zoom in"),zoomOut:$("MapZoomOut","Zoom out")})};function Dn(){return window.QuestUIV2Map?Promise.resolve():(Ht??=new Promise((e,t)=>{let n=new URL(at?"map.js":"v2/map.js",at||document.baseURI);at&&(n.search=new URL(at).search);let o=document.createElement("script");o.src=n.href,o.onload=()=>e(),o.onerror=()=>{Ht=null,t(new Error(`Failed to load ${n.href}`))},document.head.append(o)}),Ht)}function ke(){return a()?.map?.querySelector(".qv-map-view")??null}function Rn(){let e=ke();if(!e||!window.QuestUIV2Map)return;(!D||lt!==e)&&(D=window.QuestUIV2Map.create(e,Nn),lt=e);let t=j;j=[];for(let[n,o]of t)try{D.call(n,o)}catch(r){console.error(r)}}function Nt(e,t){if(a()?.map){if(e==="show"){let n=typeof t[0]=="number"?t[0]:parseFloat(String(t[0]));ct=Number.isFinite(n)?n:0,q()}if(D&&lt===ke()&&j.length===0){D.call(e,t);return}j.push([e,t]),Dn().then(Rn,n=>console.error(n))}}function He(e){It=e,q()}function Ie(e){e!=="header"&&e!=="panes"||(Bt=e,q())}function q(){let e=a(),t=e?.map;if(!e||!t)return;t.hidden=!(ct>0&&It),t.style.setProperty("--qv-map-height",`${ct}px`),t.classList.toggle("qv-map-collapsed",z);let n=On(t),o=e.mapButton;if(o){o.hidden=t.hidden||n||!e.hasAttribute("data-qv-narrow");let r=o.querySelector(".qv-button-label");r&&(r.textContent=$("MapLabel","Map")),o.setAttribute("aria-expanded",String(!z))}e.updateTopbar()}function On(e){let t=a();if(!t)return!1;let n=Bt==="panes"&&t.layout!=="none"&&!!t.panes&&!t.panes.hidden,o=f("map");if(n&&!o&&t.panes&&(o=document.createElement("qv-pane"),o.dataset.qvPane="map",o.setAttribute("label",$("MapLabel","Map")),t.panes.prepend(o)),n&&o)e.parentElement!==o.body&&o.body.append(e),o.hidden=e.hidden;else{let r=t.querySelector(".qv-header");r&&e.parentElement!==r&&r.append(e),o&&(o.hidden=!0)}return n}function Be(){z=!z,q()}function Ne(){D=null,lt=null,j=[],ct=0,It=!0,z=!1,Bt="header"}var Dt="questviva-colour-scheme",Un=["system","light","dark"],K=Fn(),Re=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;function Fn(){try{let e=window.electronPlayerSettings?window.electronPlayerSettings.getColourScheme():localStorage.getItem(Dt);if(e&&Un.includes(e))return e}catch{}return"system"}function Vn(e){try{window.electronPlayerSettings?window.electronPlayerSettings.setColourScheme(e).catch(()=>{}):e==="system"?localStorage.removeItem(Dt):localStorage.setItem(Dt,e)}catch{}}function Qn(e){return!e.style.getPropertyValue("--qv-bg")}function Wn(e){let t=document.createElement("span");t.style.color=e.style.getPropertyValue("--qv-bg"),t.hidden=!0,e.append(t);let n=/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)/.exec(getComputedStyle(t).color);if(t.remove(),!n)return!1;let[o,r,i]=n.slice(1,4).map(l=>{let c=Number(l)/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*i<.18}function G(e){let t=Qn(e),n=t?K==="dark"||K==="system"&&!!Re?.matches:Wn(e);e.setAttribute("data-qv-scheme",n?"dark":"light"),e.toggleAttribute("data-qv-fixed-scheme",!t),document.documentElement.setAttribute("data-qv-scheme",n?"dark":"light");let o=e.querySelector(".qv-scheme");if(o){o.hidden===t&&(o.hidden=!t,t||A(e,!1));for(let r of o.querySelectorAll("[data-qv-scheme-icon]"))r.hidden=r.dataset.qvSchemeIcon!==K;for(let r of o.querySelectorAll("[data-qv-scheme-choice]"))r.setAttribute("aria-checked",String(r.dataset.qvSchemeChoice===K))}}function $n(e,t){K=t,Vn(t),G(e)}function Ut(e){return e.querySelector(".qv-scheme-menu")}function Rt(e){return[...e.querySelectorAll("[data-qv-scheme-choice]")]}function De(e){let t=Ut(e),n=e.querySelector(".qv-scheme-button");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true"),(Rt(t).find(r=>r.getAttribute("aria-checked")==="true")??Rt(t)[0])?.focus()}function A(e,t){let n=Ut(e),o=e.querySelector(".qv-scheme-button");!n||n.hidden||(n.hidden=!0,o?.setAttribute("aria-expanded","false"),t&&o?.focus())}var Ot=null;Re?.addEventListener("change",()=>{Ot?.isConnected&&G(Ot)});function Oe(e){Ot=e,G(e);let t=e.querySelector(".qv-scheme-button"),n=Ut(e);!t||!n||(t.addEventListener("click",()=>{n.hidden?De(e):A(e,!0)}),t.addEventListener("keydown",o=>{(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),De(e))}),n.addEventListener("click",o=>{let r=o.target instanceof Element?o.target.closest("[data-qv-scheme-choice]"):null;r&&($n(e,r.dataset.qvSchemeChoice),A(e,!0))}),n.addEventListener("keydown",o=>{let r=Rt(n),i=r.indexOf(document.activeElement),l=-1;if(o.key==="ArrowDown")l=(i+1)%r.length;else if(o.key==="ArrowUp")l=(i-1+r.length)%r.length;else if(o.key==="Home")l=0;else if(o.key==="End")l=r.length-1;else if(o.key==="Escape"){o.preventDefault(),o.stopPropagation(),A(e,!0);return}else if(o.key==="Tab"){A(e,!1);return}l>=0&&(o.preventDefault(),r[l]?.focus())}),document.addEventListener("pointerdown",o=>{!n.hidden&&o.target instanceof Node&&!n.contains(o.target)&&!t.contains(o.target)&&A(e,!1)}),n.addEventListener("focusout",o=>{o.relatedTarget instanceof Node&&!n.contains(o.relatedTarget)&&o.relatedTarget!==t&&A(e,!1)}))}var Ue=["sidepanes","nopanes","bottombar"],jn=900,zn=new Set(["--qv-font-size","--qv-output-width","--qv-padding-top","--qv-padding-bottom","--qv-padding-left","--qv-padding-right","--qv-menu-font-size","--qv-radius","--qv-space"]),ut=class extends HTMLElement{#e=!1;#t="sidepanes";#n="sidepanes";connectedCallback(){if(this.#e)return;this.#e=!0,this.addEventListener("click",n=>ce(n,this.verbMenu)),this.addEventListener("keydown",ue);for(let n of this.querySelectorAll(".qv-panes-button"))n.addEventListener("click",()=>w(!rt()));this.mapButton?.addEventListener("click",Be),Oe(this),new ResizeObserver(()=>this.#r()).observe(this),this.panes?.addEventListener("keydown",n=>{n.key==="Escape"&&rt()&&!this.verbMenu?.isOpen&&(n.preventDefault(),w(!1))});let t=this.querySelector(".qv-toolbar");t&&(new MutationObserver(()=>{Ve(t),this.updateTopbar()}).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","hidden"]}),Ve(t)),this.addEventListener("pointerover",n=>{let o=n.target instanceof Element?n.target.closest("button"):null;if(!o?.querySelector(":scope > .qv-icon"))return;let r=o.querySelector(".qv-button-label")?.textContent?.trim()||o.getAttribute("aria-label");r&&(o.title=r)}),this.#r(),this.#s()}get topbar(){return this.querySelector(".qv-topbar")}get saveButton(){return this.querySelector("#cmdSave")}get panes(){return this.querySelector('[data-qv-part="panes"]')}get exits(){return this.querySelector('[data-qv-part="exits"]')}get statusBar(){return this.querySelector('[data-qv-part="status-bar"]')}get panesButton(){return this.querySelector(this.layout==="sheet"?".qv-footer .qv-panes-button":".qv-topbar .qv-panes-button")}get layout(){return this.dataset.qvLayout??"side"}setLayoutPreset(t,n){if(t==="gamebook"){this.toggleAttribute("data-qv-gamebook",!0),this.#t=this.#n="nopanes",this.setVisible("command-bar",!1),this.setVisible("location",!1),this.#r();return}Ue.includes(t)&&(this.removeAttribute("data-qv-gamebook"),this.#t=t,this.#n=n!=null&&Ue.includes(n)?n:t,this.#r())}#r(){let t=this.clientWidth<jn;t!==this.hasAttribute("data-qv-narrow")&&(this.toggleAttribute("data-qv-narrow",t),q());let n=t?this.#n:this.#t,o=n==="nopanes"?"none":n==="bottombar"?"sheet":t?"drawer":"side";this.dataset.qvLayout!==o&&(w(!1,{restoreFocus:!1}),this.toggleAttribute("data-qv-layout-changing",!0),this.dataset.qvLayout=o,q(),requestAnimationFrame(()=>requestAnimationFrame(()=>this.removeAttribute("data-qv-layout-changing"))),h(),it(),this.updateTopbar())}updateTopbar(){let t=this.topbar;if(!t)return;let n=this.location,o=[...t.querySelectorAll(".qv-toolbar > button, .qv-toolbar > .qv-scheme:not([hidden]) > button")].some(l=>!l.hidden&&l.style.display!=="none"&&getComputedStyle(l).display!=="none"),r=this.statusBar,i=!!r&&!r.hidden&&r.classList.contains("qv-status-bar-active")&&getComputedStyle(r).display!=="none";t.hidden=(!n||n.hidden)&&!o&&!i}focusFirstChoice(){if(!this.hasAttribute("data-qv-gamebook"))return;let t=document.activeElement;if(t&&t!==document.body&&this.contains(t)&&!t.closest(".qv-hiding")&&!t.classList.contains("disabled"))return;[...this.querySelectorAll('[data-qv-part="output"] [data-qv-sections] a.commandlink:not(.disabled)')].find(o=>!o.closest(".qv-hiding"))?.focus({preventScroll:!0})}get verbMenu(){return this.querySelector("qv-verb-menu")}updateLinks(t,n){ae(this,t,n),this.verbMenu?.closeIfStale()}get output(){return this.querySelector("qv-output")}get commandBar(){return this.querySelector("qv-command-bar")}get location(){return this.querySelector('[data-qv-part="location"]')}get pictureFrame(){return this.querySelector('[data-qv-part="picture-frame"]')}get map(){return this.querySelector('[data-qv-part="map"]')}get mapButton(){return this.querySelector(".qv-map-button")}get frame(){return this.querySelector('[data-qv-part="border"]')}setVisible(t,n){switch(t){case"output":this.#o(this.output,!n);break;case"command-bar":this.#o(this.commandBar,!n);break;case"location":this.#o(this.location,!n),this.updateTopbar();break;case"border":this.frame?.classList.toggle("qv-borderless",!n);break;case"picture-frame":this.#o(this.pictureFrame,!n);break;case"exits":this.#o(this.exits,!n);break;case"map":He(n);break;case"status-bar":this.#o(this.statusBar,!n);break;case"panes":this.#o(this.panes,!n),n||w(!1,{restoreFocus:!1}),q(),this.#s();break;default:(Mt.includes(t)||f(t))&&(this.#o(f(t),!n),this.#s())}h(),it()}#s(){let t=this.panes;if(!t)return;let n=[...t.querySelectorAll("qv-pane")].some(o=>!o.hidden&&!o.hasAttribute("data-qv-empty"));for(let o of this.querySelectorAll(".qv-panes-button"))o.hidden=t.hidden||!n;this.updateTopbar()}#o(t,n){t&&(t.hidden=n)}setTokens(t){for(let[n,o]of Object.entries(t)){if(!n.startsWith("--"))continue;let r=o==null?"":String(o).trim();if(r===""){this.style.removeProperty(n);continue}zn.has(n)&&/^-?(\d+\.?\d*|\.\d+)$/.test(r)&&(r+="px"),this.style.setProperty(n,r)}this.toggleAttribute("data-qv-own-accent",!!this.style.getPropertyValue("--qv-accent")),this.toggleAttribute("data-qv-own-background",["--qv-bg","--qv-bg-light","--qv-bg-dark"].some(n=>!!this.style.getPropertyValue(n))),this.toggleAttribute("data-qv-own-border",["--qv-border-colour","--qv-border-colour-light","--qv-border-colour-dark"].some(n=>!!this.style.getPropertyValue(n))),G(this),this.updateTopbar()}setLocation(t){let n=this.location;n&&(n.innerHTML=t,n.classList.toggle("qv-empty",t.trim()===""))}},Fe="http://www.w3.org/2000/svg";function Ve(e){let t=e.querySelector("#cmdRestart");if(!t||t.querySelector(".qv-icon"))return;let n=document.createElement("span");n.className="qv-button-label",n.textContent=t.textContent;let o=document.createElementNS(Fe,"svg");o.setAttribute("class","qv-icon"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");for(let r of["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8","M3 3v5h5"]){let i=document.createElementNS(Fe,"path");i.setAttribute("d",r),o.append(i)}t.replaceChildren(o,n)}function a(){return document.querySelector("qv-player")}var dt=0,Ft=0,Y,Qe=!1;function We(e){Ft=e,Kn()}function Vt(){return R(),dt}function $e(){Qe=!0,R()}function R(){Y!==void 0&&(clearInterval(Y),Y=void 0)}function Kn(){Qe||Y!==void 0||(dt=0,Y=setInterval(async()=>{dt++,Ft>0&&dt>=Ft&&await WebPlayer.uiTick(Vt())},1e3))}function Q(){return window.canSendCommand&&!s.gameFinished&&!s.soundWait&&!s.waiting&&!s.pausing&&!s.inDialog}function v(e,t){if(!Q())return!1;window.canSendCommand=!1,a()?.output?.markScrollPosition(),s.hasUnsavedProgress=!0;let n=Vt();return setTimeout(()=>{WebPlayer.sendCommand(e,n,t??null)},0),!0}function L(e,t){s.hasUnsavedProgress=!0;let n=""+t;return setTimeout(()=>{WebPlayer.uiSendEvent(e,n)},1),!0}var mt=new Set;function O(e,t){t?mt.add(e):mt.delete(e),a()?.toggleAttribute("data-qv-input-held",mt.size>0)}function ze(){mt.clear(),clearTimeout(pt),_=null}function Ke(){s.waiting=!0,h(),a()?.commandBar?.setMode("continue"),a()?.output?.markScrollPosition()}function J(){s.waiting&&(s.waiting=!1,a()?.commandBar?.setMode("none"),s.hasUnsavedProgress=!0,sendEndWait())}function Wt(){h(),!s.waiting&&ft()}var pt;function Ge(e){s.pausing=!0,h(),O("pause",!0),clearTimeout(pt),pt=setTimeout(Yn,e)}function Yn(){s.pausing&&(s.pausing=!1,sendEndPause())}function $t(){h(),!s.pausing&&(O("pause",!1),ft())}function Ye(){s.waiting&&(s.waiting=!1,Wt()),s.pausing&&(clearTimeout(pt),s.pausing=!1,$t()),_?.()}function ft(){let e=a()?.commandBar;!e||s.gameFinished||s.waiting||s.inDialog||(e.setMode("input"),e.focusInput())}var Qt={cancel:"Cancel",yes:"Yes",no:"No"},je=0,_=null;function _e(e,t,n){let o=a();if(!o)return;let r=++je;o.querySelector("dialog.qv-dialog")?.remove();let i=document.createElement("dialog");i.className="qv-dialog",i.dataset.qvPart="menu";let l="qv-dialog-caption";i.setAttribute("aria-labelledby",l);let c=document.createElement("div");c.id=l,c.className="qv-dialog-caption",c.innerHTML=e;let u=document.createElement("div");u.className="qv-dialog-choices";let d=!1,b=p=>{d||(d=!0,_=null,i.close(),i.remove(),s.hasUnsavedProgress=!0,setTimeout(async()=>{try{await p()}finally{je===r&&(s.inDialog=!1,h(),ft())}},100))};for(let p of t){let T=document.createElement("button");T.type="button",T.textContent=p.label,T.addEventListener("click",()=>b(p.choose)),u.append(T)}if(i.append(c,u),n){let p=document.createElement("button");p.type="button",p.className="qv-dialog-cancel",p.textContent=Qt.cancel,p.addEventListener("click",()=>b(n)),i.append(p)}i.addEventListener("cancel",p=>{p.preventDefault(),n&&b(n)}),i.addEventListener("close",()=>{!d&&i.isConnected&&i.showModal()}),_=()=>{d=!0,_=null,i.close(),i.remove(),s.inDialog=!1,h(),ft()},s.inDialog=!0,h(),o.commandBar?.setMode("none"),o.append(i),i.showModal(),u.querySelector("button")?.focus()}function Je(e,t,n){let o=Object.entries(t).map(([r,i])=>({label:i,choose:()=>WebPlayer.uiChoice(r)}));_e(e,o,n?()=>WebPlayer.uiChoiceCancel():null)}function Ze(e){_e(e,[{label:Qt.yes,choose:()=>WebPlayer.uiSetQuestionResponse(!0)},{label:Qt.no,choose:()=>WebPlayer.uiSetQuestionResponse(!1)}],null)}var tn=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;document.addEventListener("pointerdown",e=>{tn=e.pointerType!=="mouse"&&!(e.target instanceof Element&&e.target.closest(".qv-command-input"))},!0);var ht=class extends HTMLElement{#e;#t;#n;#r;#s="input";#o=[];#i=0;#a="";connectedCallback(){if(this.#t)return;let t=this.#e=document.createElement("form");t.className="qv-command-form",this.#n=document.createElement("span"),this.#n.className="qv-command-prompt",this.#n.setAttribute("aria-hidden","true"),this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="qv-command-input",this.#t.autocomplete="off",this.#t.spellcheck=!1,this.#t.setAttribute("autocapitalize","off"),this.#t.setAttribute("enterkeyhint","send"),this.#t.dataset.chromeKeyAriaLabel="CommandInputLabel",this.#t.setAttribute("aria-label","Type your command"),t.append(this.#n,this.#t),this.#r=document.createElement("button"),this.#r.type="button",this.#r.className="qv-continue",this.#r.hidden=!0,this.#r.addEventListener("click",J),this.append(t,this.#r),t.addEventListener("submit",n=>{n.preventDefault(),this.#c()}),this.#t.addEventListener("keydown",n=>this.#l(n)),this.updatePlaceholder(),this.updateContinueLabel()}setMode(t){this.#s=t,this.#e.hidden=t!=="input",this.#r.hidden=t!=="continue",t==="continue"&&this.#r.focus({preventScroll:!0})}get input(){return this.#t}focusInput(){if(this.hidden)return;let t=this.#s==="input"?this.#t:this.#s==="continue"?this.#r:null;t===this.#t&&tn||t&&document.activeElement!==t&&t.focus({preventScroll:!0})}setPrompt(t){this.#n.innerHTML=t}setStyle(t){this.#t.style.cssText=t}setPreset(t){(t==="borderless"||t==="shadow")&&(this.dataset.qvPreset=t)}updateContinueLabel(){this.#r.textContent=Xe(s.interfaceStrings.get("ContinueLabel")??"")||"Continue"}updatePlaceholder(){this.#t.placeholder=s.commandPlaceholder??Xe(s.interfaceStrings.get("TypeHereLabel")??"")}#c(){let t=this.#t.value;t.length===0||!Q()||v(t)&&(this.#o.at(-1)!==t&&this.#o.push(t),this.#i=this.#o.length,this.#a="",this.#t.value="")}#l(t){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown"||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let n=this.#i+(t.key==="ArrowUp"?-1:1);if(n<0||n>this.#o.length)return;t.preventDefault(),this.#i===this.#o.length&&(this.#a=this.#t.value),this.#i=n,this.#t.value=n===this.#o.length?this.#a:this.#o[n];let o=this.#t.value.length;this.#t.setSelectionRange(o,o)}};function Xe(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var jt=new Set;function vt(e,t){let n=typeof e=="number"?e:parseFloat(String(e));return Number.isFinite(n)?n:t}function Jn(e){let t=document.createElement("template");return t.innerHTML=String(e??""),t.content.textContent??""}function en(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return e[Math.floor(Math.random()*e.length)]}function Zn(e){for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function nn(e,t){if(e!=="typewriter"&&e!=="unscramble")return;let n=a()?.output;if(!n)return;let o=Jn(t[0]),r=Math.max(0,vt(t[1],100)),i=e==="unscramble"?Math.max(1,Math.floor(vt(t[2],1))):0,[l,c,u]=(e==="unscramble"?t.slice(3,6):t.slice(2,5)).map(g=>g==null?"":String(g).trim()),d=document.createElement("span");d.className="qv-text-effect",d.dataset.qvEffect=e,l&&d.style.setProperty("font-family",l),c&&d.style.setProperty("color",c),u&&vt(u,0)>0&&d.style.setProperty("font-size",`${vt(u,0)}pt`);let b=document.createElement("span");b.className="qv-text-effect-full",b.textContent=o;let p=document.createElement("span");p.className="qv-text-effect-shown",p.setAttribute("aria-hidden","true"),d.append(b,p);let T=document.createElement("span");if(T.textContent=o,n.addNodes([d,document.createElement("br")],`${T.innerHTML}<br/>`),!(s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches)||o===""){zt(d);return}d.classList.add("qv-text-effect-running");let Lt;if(e==="typewriter"){let g=0;Lt=()=>(g++,p.textContent=o.substring(0,g)+(g%2===1&&g<o.length?"_":""),g>=o.length)}else{let g=[...o],F=g.flatMap((E,et)=>/\s/.test(E)?[]:[et]);Zn(F);let tt=g.map(E=>/\s/.test(E)?E:en());p.textContent=tt.join(""),Lt=()=>{for(let E=0;E<i&&F.length;E++){let et=F.pop();tt[et]=g[et]}for(let E of F)tt[E]=en();return p.textContent=tt.join(""),F.length===0}}let U={timer:0,finish:()=>{clearInterval(U.timer),jt.delete(U),zt(d)}};U.timer=window.setInterval(()=>{(!d.isConnected||Lt())&&U.finish()},r),jt.add(U)}function zt(e){let t=e.querySelector(".qv-text-effect-shown");t&&(t.textContent=e.querySelector(".qv-text-effect-full")?.textContent??""),e.classList.remove("qv-text-effect-running")}function gt(){for(let e of[...jt])e.finish()}function on(e){for(let t of e.querySelectorAll(".qv-text-effect"))zt(t)}document.addEventListener("keydown",()=>gt(),!0);document.addEventListener("pointerdown",()=>gt(),!0);var rn=4,Xn=150,to=8,bt=class extends HTMLElement{#e=null;#t=0;#n=0;#r=null;#s=null;#o=!1;connectedCallback(){this.#e=this.querySelector("button"),this.#e?.addEventListener("click",this.#l),window.addEventListener("scroll",this.#i,{passive:!0}),window.addEventListener("resize",this.#i,{passive:!0}),this.#r=new ResizeObserver(this.#i);let t=a();for(let n of[t?.output,t?.commandBar,t?.querySelector(".qv-footer"),t?.querySelector(".qv-header")])n&&this.#r.observe(n);this.#s=new MutationObserver(n=>{n.some(o=>o.type==="characterData"||o.addedNodes.length>0)&&(this.#o=!1,this.#i())}),t?.output&&this.#s.observe(t.output,{childList:!0,characterData:!0,subtree:!0}),this.#i()}disconnectedCallback(){this.#e?.removeEventListener("click",this.#l),window.removeEventListener("scroll",this.#i),window.removeEventListener("resize",this.#i),this.#r?.disconnect(),this.#r=null,this.#s?.disconnect(),this.#s=null,cancelAnimationFrame(this.#t),clearTimeout(this.#n),this.#t=this.#n=0}#i=()=>{this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#a()}))};#a(){let t=this.#e;if(!t)return;let n=Kt();if(!n||this.#o){n||(this.#o=!0),clearTimeout(this.#n),this.#n=0,this.#c();return}this.style.setProperty("--qv-more-bottom",`${window.innerHeight-n.limit+to}px`),this.style.setProperty("--qv-more-x",`${n.centre}px`),t.hidden&&(clearTimeout(this.#n),this.#n=window.setTimeout(()=>{this.#n=0,!this.#o&&Kt()&&(t.hidden=!1)},Xn))}#c(){let t=this.#e;if(!t||t.hidden)return;let n=t.contains(document.activeElement);t.hidden=!0,n&&(a()?.commandBar?.focusInput(),document.activeElement===t&&t.blur())}#l=()=>{let t=Kt();if(!t)return;let n=document.querySelector("qv-player .qv-header"),o=Math.max(0,n?.getBoundingClientRect().bottom??0),r=a()?.output,i=r&&parseFloat(getComputedStyle(r).lineHeight)||24,l=Math.max(i,t.limit-o-2*i),c=!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollBy({top:l,behavior:c?"smooth":"instant"})}};function Kt(){let e=a(),t=e?.output;if(!e||!t||t.hidden||!t.isConnected)return null;let n=window.innerHeight,o=e.querySelector(".qv-footer"),r=o&&getComputedStyle(o).display!=="contents"?o:e.commandBar,i=r&&!r.hidden&&r.offsetHeight>0?r.getBoundingClientRect():null,l=i?Math.min(n,i.top):n,c=t.lastElementChild;if(!((c?c.getBoundingClientRect().bottom:t.getBoundingClientRect().top)>l+rn||i!=null&&i.bottom>n+rn))return null;let b=t.getBoundingClientRect();return{limit:l,centre:b.left+b.width/2}}var an=(e,t)=>WebPlayer.chromeStrings?.[e]??t;function sn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function ln(e,t,n,o=""){let r=a()?.output;r&&r.addText(`<iframe class="qv-video" data-qv-video="${e}" src="${sn(t.href)}" title="${sn(n)}" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" allowfullscreen${o}></iframe>`)}function cn(e){let t=new URL(`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e.trim())}`);t.searchParams.set("autoplay","1"),t.searchParams.set("rel","0"),ln("youtube",t,an("YouTubeVideoTitle","YouTube video"))}function un(e){let[t,n]=e.trim().split("/"),o=new URL(`https://player.vimeo.com/video/${encodeURIComponent(t)}`);n&&o.searchParams.set("h",n),o.searchParams.set("autoplay","1"),o.searchParams.set("dnt","1"),ln("vimeo",o,an("VimeoVideoTitle","Vimeo video"),' sandbox="allow-same-origin allow-scripts allow-popups allow-presentation"')}function dn(e){for(let t of e.querySelectorAll("iframe[data-qv-video]")){let n;try{n=new URL(t.getAttribute("src")??"")}catch{continue}n.searchParams.has("autoplay")&&(n.searchParams.delete("autoplay"),t.setAttribute("src",n.href))}}function yt(e){let t=a()?.pictureFrame;if(t){t.innerHTML=e,t.classList.toggle("qv-empty",e.trim()==="");for(let n of t.querySelectorAll("img"))n.hasAttribute("alt")||(n.alt=""),n.complete||(n.addEventListener("load",Gt,{once:!0}),n.addEventListener("error",Gt,{once:!0}));Gt()}}function mn(){let e=a()?.pictureFrame;return!e||e.hidden||e.classList.contains("qv-empty")?!1:[...e.querySelectorAll("img")].some(t=>!t.complete)}function Gt(){a()?.output?.rescroll(!0)}var hn=new Map;function vn(e,t,n){hn.set(e,{width:t,height:n})}var eo=8;function no(e){s.warnedAboutScript||!/<script[\s>\/]/i.test(e)||(s.warnedAboutScript=!0,console.warn(`[Quest] This game printed a <script> element, which doesn't run in the new player interface. Call your own JavaScript with JS.yourFunction () or JS.eval instead, or tick "Use the classic interface" on the game's Interface tab.`))}var St=class extends HTMLElement{#e=null;#t=[];#n=0;#r=0;#s=!0;#o=0;connectedCallback(){this.setAttribute("role","log"),this.setAttribute("aria-live","polite"),this.addEventListener("load",this.#i,!0),this.addEventListener("error",this.#i,!0)}disconnectedCallback(){this.removeEventListener("load",this.#i,!0),this.removeEventListener("error",this.#i,!0)}#i=t=>{t.target instanceof HTMLImageElement&&this.rescroll()};addText(t){no(t);let n=this.#e??this.setAlignment("left");n.insertAdjacentHTML("beforeend",t),oo(n),ro(n),H(n),this.#s=!0,WebPlayer.transcript?.write(t),y("outputAdded",{html:t})}addNodes(t,n){(this.#e??this.setAlignment("left")).append(...t),this.#s=!0,WebPlayer.transcript?.write(n),y("outputAdded",{html:n})}setAlignment(t){this.#e&&!this.#e.hasChildNodes()&&this.#e.remove();let n=document.createElement("div");return n.className="qv-block",n.style.textAlign=t,this.#t.length&&(n.dataset.qvSections=this.#t.join(" ")),this.append(n),this.#e=n,n}clearScreen(){this.replaceChildren(),this.#e=null,this.setAlignment("left"),this.#n=0,this.#s=!0;let t=this.#u();window.scrollY>t&&window.scrollTo({top:t,behavior:"instant"})}loadHtml(t){let n=document.createElement("template");n.innerHTML=t,dn(n.content),on(n.content),this.replaceChildren(n.content),this.#s=!0,H(this),ie(this),requestAnimationFrame(()=>{let o=document.scrollingElement??document.documentElement;window.scrollTo({top:o.scrollHeight,behavior:"instant"})}),this.#e=null,this.#t=[]}getHtml(){return this.innerHTML}reset(){this.replaceChildren(),this.#e=null,this.#t=[],this.#n=0,this.#r=0,this.#s=!0,this.#o=0}startSection(t){this.#t.includes(t)||(this.#t.push(t),this.setAlignment("left"))}endSection(t){let n=this.#t.indexOf(t);n!==-1&&(this.#t.splice(n,1),this.setAlignment("left"))}hideSection(t){this.endSection(t);let n=this.getBoundingClientRect().top;for(let o of this.#a(t)){let r=o.getBoundingClientRect();r.bottom-n<=this.#n+1&&(this.#n=Math.max(0,this.#n-r.height)),o.classList.add("qv-hiding"),fn(o),setTimeout(()=>o.remove(),250)}}disableSection(t){for(let n of this.#a(t))fn(n)}disableCommandLinks(){for(let t of this.querySelectorAll("a.commandlink"))xt(t);a()?.verbMenu?.closeIfStale()}#a(t){return[...this.querySelectorAll("[data-qv-sections]")].filter(n=>n.dataset.qvSections.split(" ").includes(t))}beginTurn(){if(s.fadePreviousOutput)for(let t of this.children)t.classList.add("qv-previous-output")}clearPreviousOutputFade(){for(let t of this.querySelectorAll(".qv-previous-output"))t.classList.remove("qv-previous-output")}markScrollPosition(){this.#n=this.#c()}#c(){let t=this.lastElementChild;return t?t.getBoundingClientRect().bottom-this.getBoundingClientRect().top:0}scrollToEnd(){let t=this.#c();!this.#s&&t<=this.#o+1||(this.#s=!1,this.#o=t,this.#l(this.#n))}rescroll(t=!1){this.#l(this.#r,t)}#l(t,n=!1){if(!s.autoScroll||(this.#r=t,mn()))return;let r=(document.scrollingElement??document.documentElement).scrollHeight-window.innerHeight,i=s.animateScroll?Math.min(this.#u()+t-pn()-eo,r):r,l=this.#u()+t-window.scrollY,c=n&&l>=0&&l<pn();if(i<=window.scrollY&&!c)return;let u=s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:i,behavior:u?"smooth":"instant"})}#u(){return this.getBoundingClientRect().top+window.scrollY}};function pn(){return document.querySelector("qv-player .qv-header")?.offsetHeight??0}function fn(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))M(t,!1);a()?.verbMenu?.closeIfStale()}function oo(e){for(let t of e.querySelectorAll("img:not([alt])"))t.setAttribute("alt","")}function ro(e){for(let t of e.querySelectorAll("img:not([width]):not([height]):not([style])")){let n=hn.get(t.getAttribute("src")??"");n&&(t.setAttribute("width",String(n.width)),t.setAttribute("height",String(n.height)),t.classList.add("qv-sized"))}}var x=()=>WebPlayer.transcript;function gn(e){let t=a()?.output;t?.addText(e),t?.scrollToEnd()}var bn={write:e=>x()?.write(String(e??"")),enable:e=>x()?.enable(e==null?void 0:String(e)),disable:()=>x()?.disable(),kill:()=>x()?.kill(),revive:()=>x()?.revive(),setName:e=>x()?.setName(String(e??"")),setPrefix:()=>{},stampDateAndTime:()=>gn(`<b>DATE AND TIME:</b> ${new Date().toLocaleString(navigator.language,{timeZoneName:"short"})}`),promptForName:()=>{let e=a()?.commandBar?.input;e&&(e.value=x()?.name||document.title,e.focus({preventScroll:!0}))},show:(e,t)=>{let n=document.createElement("a");n.href=x()?.viewerUrl??"TranscriptViewer/index.html",n.target="_blank",n.textContent=t==null||t===""?"Your Transcripts":String(t);let o=e==null||e===""?"Your transcripts are saved to the localStorage in your browser. You can view, download, or delete them here:":String(e);gn(`${o} ${n.outerHTML}<br/>`)}};var m=e=>(...t)=>Nt(e,t),so={show:m("show"),respondToClicks:m("respondToClicks"),setInteractive:m("setInteractive"),setScale:m("setScale"),setCentre:m("setCentre"),drawBox:m("drawBox"),drawLabel:m("drawLabel"),drawPlayer:m("drawPlayer"),drawLine:m("drawLine"),drawArrow:m("drawArrow"),drawSquare:m("drawSquare"),drawShape:m("drawShape"),addShapePoint:m("addShapePoint"),drawImage:m("drawImage"),drawSvg:m("drawSvg"),loadSvg:m("loadSvg"),drawGridLines:m("drawGridLines"),showCustomLayer:m("showCustomLayer"),clearCustomLayer:m("clearCustomLayer"),clearAllLayers:m("clearAllLayers")};function Z(e){return typeof e=="string"?JSON.parse(e):e}function Yt(e){let t=e??"";a()?.setLocation(t),y("locationChanged",{location:t})}function _t(e,t){s.interfaceStrings.set(e,t),e==="EmptyListLabel"&&(s.interfaceStrings.delete("InventoryEmptyLabel"),s.interfaceStrings.delete("PlacesObjectsEmptyLabel")),Ee(e,t),(e==="InButtonLabel"||e==="OutButtonLabel"||e==="CompassLabel")&&B(),e==="TypeHereLabel"&&a()?.commandBar?.updatePlaceholder(),e==="ContinueLabel"&&a()?.commandBar?.updateContinueLabel()}function Jt(e){s.compassDirections=Array.isArray(e)?e.map(String):String(e??"").split(";"),B()}var yn={sendCommand:v,sendEvent:L,restart:()=>window.RestartGame?.(),addText:e=>a()?.output?.addText(String(e)),clearScreen:()=>a()?.output?.clearScreen(),setAlignment:e=>{a()?.output?.setAlignment(String(e))},startSection:e=>a()?.output?.startSection(String(e)),endSection:e=>a()?.output?.endSection(String(e)),hideSection:e=>a()?.output?.hideSection(String(e)),disableSection:e=>a()?.output?.disableSection(String(e)),disableCommandLinks:()=>a()?.output?.disableCommandLinks(),updateLinks:(e,t)=>a()?.updateLinks(String(e),Z(t)),scrollToEnd:()=>a()?.output?.scrollToEnd(),addYouTube:e=>cn(String(e??"")),addVimeo:e=>un(String(e??"")),textEffect:(e,...t)=>nn(String(e),t),setVisible:(e,t)=>a()?.setVisible(String(e),!!t),setPaneOrder:e=>Se(Z(e)),setLayoutPreset:(e,t)=>a()?.setLayoutPreset(String(e),t==null?void 0:String(t)),setMapPosition:e=>Ie(String(e??"")),setPictureFrame:e=>yt(String(e??"")),setInterfaceString:_t,setCompassDirections:e=>Jt(Z(e)),setLocation:Yt,setStatusAttributes:e=>Pt(Z(e)),setTokens:e=>a()?.setTokens(Z(e)??{}),setCommandBarStyle:e=>a()?.commandBar?.setStyle(String(e??"")),setCommandBarPreset:e=>a()?.commandBar?.setPreset(String(e??"")),setCommandPrompt:e=>a()?.commandBar?.setPrompt(String(e??"")),addStylesheet:e=>addExternalStylesheet(String(e)),map:so,transcript:bn,addPane:(e,t,n)=>ye(String(e),t==null?void 0:String(t),n==null?void 0:String(n)),setPaneContent:(e,t)=>be(String(e),String(t??"")),setCommands:e=>ge(e),setAutoScroll:e=>{s.autoScroll=!!e},setContinueOnClick:e=>{s.continueOnClick=!!e},fadePreviousOutput:e=>{s.fadePreviousOutput=!!e,s.fadePreviousOutput||a()?.output?.clearPreviousOutputFade()},setCommandPlaceholder:e=>{s.commandPlaceholder=e==null?null:String(e),a()?.commandBar?.updatePlaceholder()},setMapInteractive:e=>Nt("setInteractive",[e]),lists:ne,on:Xt,off:te};function Sn(e){return(e.dataset.qvName??e.textContent??"").trim()}var Zt=4,X=8,Et=class extends HTMLElement{#e=null;connectedCallback(){this.setAttribute("role","menu"),C&&(this.popover="manual"),this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r)}get isOpen(){return this.#e!==null}toggle(t){if(this.#e===t){this.close();return}let n=(t.dataset.verbs??"").split("/").map(r=>r.trim()).filter(Boolean);if(!n.length)return;this.close({restoreFocus:!1});let o=Sn(t);this.setAttribute("aria-label",(t.textContent??"").trim()),this.replaceChildren(...n.map(r=>{let i=document.createElement("button");return i.type="button",i.setAttribute("role","menuitem"),i.textContent=r,i.dataset.command=`${r.toLowerCase()} ${o}`,i})),this.#e=t,t.setAttribute("aria-expanded","true"),this.classList.add("qv-open"),C&&this.showPopover(),this.#i(),this.querySelector("button")?.focus({preventScroll:!0}),document.addEventListener("pointerdown",this.#s,!0),window.addEventListener("scroll",this.#o,{passive:!0}),window.addEventListener("resize",this.#o)}close({restoreFocus:t=!0}={}){let n=this.#e;if(!n)return;this.#e=null,n.setAttribute("aria-expanded","false");let o=this.contains(document.activeElement);this.classList.remove("qv-open"),C&&this.matches(":popover-open")&&this.hidePopover(),this.replaceChildren(),document.removeEventListener("pointerdown",this.#s,!0),window.removeEventListener("scroll",this.#o),window.removeEventListener("resize",this.#o),t&&o&&n.isConnected&&n.focus({preventScroll:!0})}closeIfStale(){this.#e&&(!this.#e.isConnected||k(this.#e))&&this.close({restoreFocus:!1})}#t(t){let n=this.#e;if(!n)return;let o=Sn(n),r={};n.dataset.elementid&&(r[o]=n.dataset.elementid),this.close({restoreFocus:!1}),v(t.dataset.command??"",r)}#n=t=>{let n=t.target instanceof Element?t.target.closest('[role="menuitem"]'):null;n&&this.#t(n)};#r=t=>{let n=[...this.querySelectorAll('[role="menuitem"]')],o=n.indexOf(document.activeElement),r=null;switch(t.key){case"Escape":t.preventDefault(),this.close();return;case"Tab":this.close({restoreFocus:!1});return;case"ArrowDown":r=(o+1)%n.length;break;case"ArrowUp":r=(o-1+n.length)%n.length;break;case"Home":r=0;break;case"End":r=n.length-1;break;default:return}t.preventDefault(),n[r]?.focus()};#s=t=>{let n=t.target instanceof Node?t.target:null;n&&(this.contains(n)||this.#e?.contains(n))||this.close({restoreFocus:!1})};#o=()=>{this.closeIfStale(),this.#e&&this.#i()};#i(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),{offsetWidth:n,offsetHeight:o}=this,r=t.bottom+Zt;r+o>window.innerHeight-X&&t.top-Zt-o>=X&&(r=t.top-Zt-o);let i=Math.max(X,Math.min(t.left,window.innerWidth-n-X));this.style.top=`${Math.max(X,r)}px`,this.style.left=`${i}px`}};customElements.define("qv-player",ut);customElements.define("qv-output",St);customElements.define("qv-command-bar",ht);customElements.define("qv-verb-menu",Et);customElements.define("qv-pane",ot);customElements.define("qv-more",bt);window.QuestUI=yn;window.sendCommand=(e,t)=>{v(e,t)};window.ASLEvent=L;window.canSendCommand=!0;window.notifyQuestUITurn=e=>{let t=a()?.output;e?(w(!1,{restoreFocus:!1}),t?.beginTurn(),t?.setAttribute("aria-busy","true"),y("turnStarted")):(t?.removeAttribute("aria-busy"),y("turnEnded"),a()?.commandBar?.focusInput(),a()?.focusFirstChoice())};window.resetQuestUIState=()=>{ee(),R(),ze(),Me(),Ae(),oe(),ve(),Ne(),gt()};document.addEventListener("keydown",e=>{!s.waiting||e.repeat||["Tab","Shift","Control","Alt","Meta"].includes(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, select, [contenteditable], dialog")||(e.preventDefault(),J())});window.addEventListener("beforeunload",e=>{!s.hasUnsavedProgress||!s.canSave||!a()||(e.preventDefault(),e.returnValue="")});document.addEventListener("click",e=>{!s.waiting||!s.continueOnClick||e.target instanceof Element&&e.target.closest("a, button, input, textarea, select, summary, dialog")||J()});var S=()=>a()?.output;function En(){let e=a()?.saveButton;e&&(e.disabled=s.turnPending)}var io=()=>{},Ln={"#gamePanes":"panes","#location":"location","#txtCommandDiv":"command-bar"},ao={addTextAndScroll(e){S()?.addText(e),S()?.scrollToEnd()},createNewDiv:e=>{S()?.setAlignment(e)},bindMenu:(e,t,n,o)=>le(e,t,o),showMenu:Je,showQuestion:Ze,beginWait:Ke,setTurnPending(e){s.turnPending=e,En(),h()},beginPause:Ge,updateLocation:Yt,setGameName(e){document.title=e},clearScreen:()=>S()?.clearScreen(),panesVisible:e=>a()?.setVisible("panes",e),updateStatus:Ce,setBackground:e=>a()?.setTokens({"--qv-bg":e}),setForeground:io,updateList:he,updateCompass:Te,updateObjectLinks:e=>a()?.updateLinks("object",e),gameFinished(){s.gameFinished=!0,R(),s.waiting=!1,O("finished",!0),h()},requestNextTimerTick:We,uiShow:e=>a()?.setVisible(Ln[e]??"",!0),uiHide:e=>a()?.setVisible(Ln[e]??"",!1),setCompassDirections:Jt,setInterfaceString:_t,setPanelContents:yt,loadHtml:e=>S()?.loadHtml(e),markScrollPosition:()=>S()?.markScrollPosition(),scrollToEnd:()=>S()?.scrollToEnd(),requestSave(){GameSaver.saveRequested()},start(){a()?.saveButton?.addEventListener("click",()=>{WebPlayer.onSaveClick?WebPlayer.onSaveClick():GameSaver.save()}),En(),B(),kt(),a()?.commandBar?.focusInput()},resetOutput(){S()?.reset(),R(),s.hasUnsavedProgress=!1},useManualClock:$e,getOutputHtml:()=>S()?.getHtml()??"",getLocation:()=>a()?.location?.textContent?.trim()??"",gameSaved(){S()?.addText(`<span data-qv-save-notice>${WebPlayer.chromeStrings?.GameSaved??"Game saved."}<br></span>`),s.hasUnsavedProgress=!1},clearUnsavedProgress(){s.hasUnsavedProgress=!1},setCanSave(e){s.canSave=e},waitEnded:Wt,pauseEnded:$t,dismissPrompt:Ye,beginSoundWait(){let e=!a()?.commandBar?.hidden;return s.soundWait=!0,O("sound",!0),e},endSoundWait(){s.soundWait=!1,setTimeout(async()=>{O("sound",!1),await WebPlayer.uiEndWait()},100)},rememberImageSize:vn,setAnimateScroll(e){s.animateScroll=e}};window.QuestPlayerUis=window.QuestPlayerUis??{};window.QuestPlayerUis.v2=ao;})();
1
+ "use strict";(()=>{var s={autoScroll:!0,warnedAboutScript:!1,animateScroll:!0,fadePreviousOutput:!1,continueOnClick:!1,commandPlaceholder:null,commands:[],commandsInExitStrip:!1,compassDirections:[],interfaceStrings:new Map,gameFinished:!1,soundWait:!1,waiting:!1,pausing:!1,inDialog:!1,turnPending:!0,hasUnsavedProgress:!1,canSave:!1},V=new Map;function te(e,t){if(typeof t!="function")return;let n=V.get(e);n||V.set(e,n=new Set),n.add(t)}function ee(e,t){V.get(e)?.delete(t)}function y(e,t){for(let n of V.get(e)??[])try{n(t)}catch(o){console.error(o)}}function ne(){s.autoScroll=!0,s.warnedAboutScript=!1,s.fadePreviousOutput=!1,s.continueOnClick=!1,s.commandPlaceholder=null,s.interfaceStrings.clear(),s.compassDirections=[],s.commands=[],s.commandsInExitStrip=!1,s.gameFinished=!1,s.soundWait=!1,s.waiting=!1,s.pausing=!1,s.inDialog=!1,s.turnPending=!0,s.hasUnsavedProgress=!1,V.clear()}var qn={inventory:"inventoryChanged",objects:"objectsChanged",exits:"exitsChanged",status:"statusChanged"},ot={inventory:[],objects:[],exits:[],status:[]},qt=new Set;function oe(){return structuredClone(ot)}function re(){ot={inventory:[],objects:[],exits:[],status:[]},qt.clear()}function P(e,t){if(qt.has(e)&&JSON.stringify(t)===JSON.stringify(ot[e]))return;qt.add(e),ot[e]=t;let n=structuredClone(t);y(qn[e],e==="exits"?{exits:n}:{items:n})}function se(e){return{text:String(e.Text??""),name:String(e.ElementName??""),elementId:String(e.ElementId??""),verbs:(e.Verbs??[]).map(String)}}var C=typeof HTMLElement.prototype.showPopover=="function";function H(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.hasAttribute("tabindex")||(t.tabIndex=0),t.setAttribute("role","button"),t.classList.contains("elementmenu")&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false")),t.toggleAttribute("aria-disabled",t.classList.contains("disabled"));for(let t of e.querySelectorAll("[data-qv-popup]"))t.setAttribute("aria-controls",t.dataset.qvPopup??""),t.setAttribute("aria-expanded","false")}function ae(e){for(let t of e.querySelectorAll("[data-qv-popup-content].qv-popup-open"))t.classList.remove("qv-popup-open");for(let t of e.querySelectorAll('[aria-expanded="true"]'))t.setAttribute("aria-expanded","false")}function M(e,t){e.classList.toggle("disabled",!t),t?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")}var k=e=>e.classList.contains("disabled");function rt(e){e.setAttribute("data-qv-deactivated",""),M(e,!1)}function ie(e){return Array.isArray(e)?e.map(String):[]}function le(e,t,n){if(t==="object"){let o=n&&typeof n=="object"?n:{};for(let r of e.querySelectorAll("a.elementmenu")){let i=o[r.dataset.elementid??""];i&&(r.dataset.verbs=String(i)),M(r,!!i)}}else if(t==="exit"){let o=ie(n);for(let r of e.querySelectorAll("a.exitlink"))M(r,o.includes(r.dataset.elementid??""))}else if(t==="command"){let o=ie(n);for(let r of e.querySelectorAll("a.commandlink:not([data-qv-deactivated])")){let i=r.dataset.elementid??"";M(r,i===""||o.includes(i))}}}function ce(e,t,n){let o=document.getElementById(e);o&&(o.classList.add("cmdlink","elementmenu"),o.dataset.verbs=t,o.dataset.elementid||(o.dataset.elementid=n),H(o.parentElement??o))}function ue(e,t){let n=e.target instanceof Element?e.target:null;if(!n)return;let o=n.closest("[data-qv-popup]");if(o){e.preventDefault(),Cn(o);return}let r=n.closest("[data-qv-direction]");if(r){r.disabled||g(r.dataset.qvDirection??"");return}let i=n.closest("[data-qv-command]");if(i){g(i.dataset.qvCommand??"");return}let l=n.closest(".qv-pane-verb");if(l){fe(l);return}let u=n.closest(".qv-pane-item");if(u){pe(u);return}let d=n.closest("[data-qv-popup-content]");d&&me(d);let c=n.closest("a");c&&(c.matches(".cmdlink, [data-qv-event]")?xn(e,c,t):c.hasAttribute("href")&&Tn(e,c))}function xn(e,t,n){if(t.dataset.qvEvent!==void 0){if(e.preventDefault(),k(t))return;if(t.dataset.qvEvent==="ShowMenuResponse")for(let o of t.ownerDocument.querySelectorAll('a[data-qv-event="ShowMenuResponse"]'))M(o,!1);L(t.dataset.qvEvent,t.dataset.qvParam??"")}else if(t.classList.contains("elementmenu"))e.preventDefault(),k(t)||n?.toggle(t);else if(t.classList.contains("exitlink"))e.preventDefault(),k(t)||g(t.dataset.command??"");else if(t.classList.contains("commandlink")){if(e.preventDefault(),k(t)||!Q())return;t.dataset.deactivateonclick==="true"&&rt(t),g(t.dataset.command??"")}}function Tn(e,t){let n=t.getAttribute("href")??"";n.startsWith("#")||/^\s*javascript:/i.test(n)||(e.preventDefault(),window.open(t.href,"_blank","noopener"))}function de(e){if(e.key!=="Enter"&&e.key!==" ")return;let t=e.target instanceof HTMLAnchorElement?e.target:null;t?.matches(".cmdlink, [data-qv-event]")&&(e.preventDefault(),t.click())}function Mn(e){let t=document.getElementById(e.dataset.qvPopup??"");return t?.hasAttribute("data-qv-popup-content")?t:null}function Cn(e){let t=Mn(e);if(t){if(t.classList.contains("qv-popup-open")){me(t);return}C&&!t.popover&&(t.popover="auto",t.addEventListener("beforetoggle",n=>{n.newState==="closed"&&xt(t,!1)})),xt(t,!0),C&&t.showPopover()}}function me(e){C&&e.matches(":popover-open")&&e.hidePopover(),xt(e,!1)}function xt(e,t){e.classList.toggle("qv-popup-open",t);for(let n of document.querySelectorAll(`[data-qv-popup="${CSS.escape(e.id)}"]`))n.setAttribute("aria-expanded",String(t))}var Mt=["inventory","objects","status","compass","commands","customstatus"],An={InventoryLabel:"inventory",PlacesObjectsLabel:"objects",StatusLabel:"status",CompassLabel:"compass"},st=class extends HTMLElement{#e;#t;#n;connectedCallback(){this.#e||(this.dataset.qvPart="pane",this.#e=document.createElement("details"),this.#e.open=!0,this.#t=document.createElement("summary"),this.#t.className="qv-pane-heading",this.#t.textContent=this.getAttribute("label")??"",this.#n=document.createElement("div"),this.#n.className="qv-pane-body",this.#n.append(...this.childNodes),this.#e.append(this.#t,this.#n),this.append(this.#e))}get name(){return this.dataset.qvPane??""}get body(){return this.#n}setLabel(t){this.#t.innerHTML=t}setContent(t){this.#n.innerHTML=t,H(this.#n)}};function h(e){return a()?.querySelector(`qv-pane[data-qv-pane="${CSS.escape(e)}"]`)??null}var Pn={inventory:"inventory",placesobjects:"objects"};function ve(e,t){let n=Pn[e];if(!n)return;let o=new Set(s.compassDirections),r=Object.values(t).map(d=>JSON.parse(d)).filter(d=>e!=="placesobjects"||!o.has(d.Text));P(n,r.map(se));let i=h(n);if(!i)return;let l=I.get(n);l!==void 0&&!r.some(d=>Tt(d)===l)&&I.delete(n);let u=document.createElement("ul");if(u.className="qv-pane-list",r.forEach((d,c)=>u.append(kn(n,d,`qv-${n}-verbs-${c}`))),u.childElementCount)i.body.replaceChildren(u);else{let d=document.createElement("p");d.className="qv-pane-empty",d.innerHTML=s.interfaceStrings.get(n==="inventory"?"InventoryEmptyLabel":"PlacesObjectsEmptyLabel")??s.interfaceStrings.get("EmptyListLabel")??"",i.body.replaceChildren(d)}a()?.verbMenu?.closeIfStale()}var I=new Map,Tt=e=>e.ElementId||e.ElementName;function ge(){I.clear(),Ct=[]}function kn(e,t,n){let o=document.createElement("li"),r=document.createElement("button");r.type="button",r.className="qv-pane-item",r.innerHTML=t.Text,r.dataset.qvKey=Tt(t),o.append(r);let i=(t.Verbs??[]).map(String).map(d=>d.trim()).filter(Boolean);if(!i.length)return o;let l=document.createElement("div");l.id=n,l.className="qv-pane-verbs",l.setAttribute("role","group"),l.setAttribute("aria-label",r.textContent?.trim()??"");for(let d of i){let c=document.createElement("button");c.type="button",c.className="qv-pane-verb",c.textContent=d,c.dataset.command=`${d.toLowerCase()} ${t.ElementName}`,c.dataset.qvName=t.ElementName,t.ElementId&&(c.dataset.elementid=t.ElementId),l.append(c)}let u=I.get(e)===Tt(t);return l.hidden=!u,r.setAttribute("aria-expanded",String(u)),r.setAttribute("aria-controls",n),o.append(l),o}function pe(e){let t=e.closest("qv-pane"),n=e.nextElementSibling;if(!t||!n?.classList.contains("qv-pane-verbs"))return;let o=n.hidden;for(let r of t.body.querySelectorAll('.qv-pane-item[aria-expanded="true"]'))r.setAttribute("aria-expanded","false"),r.nextElementSibling.hidden=!0;o?(n.hidden=!1,e.setAttribute("aria-expanded","true"),I.set(t.name,e.dataset.qvKey??""),n.scrollIntoView({block:"nearest"})):I.delete(t.name)}function fe(e){let t=e.dataset.qvName??"",n={};e.dataset.elementid&&(n[t]=e.dataset.elementid),g(e.dataset.command??"",n)}function be(e){let t=(Array.isArray(e)?e.map(String):String(e??"").split(";")).filter(o=>o.trim());s.commands=t.map(o=>{let[r,i]=o.split(":");return{label:r.trim(),command:(i??r).trim().toLowerCase()}});let n=o=>o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");h("commands")?.setContent(s.commands.map(({label:o,command:r})=>`<a class="cmdlink commandlink" data-elementid="" data-command="${n(r)}">${n(o)}</a>`).join(" ")),f()}function Se(e,t){e==="map"||e!=="customstatus"&&Mt.includes(e)||h(e)?.setContent(t)}function ye(e,t,n){let o=a()?.panes;if(!e||e==="map"||!o||h(e))return;let r=document.createElement("qv-pane");r.dataset.qvPane=e,r.setAttribute("label",t??e),o.append(r),r.setContent(n??"")}var Ct=[];function Ee(e){Ct=Array.isArray(e)?e.map(String):String(e??"").split(";"),At()}function At(){let e=a()?.panes;if(e)for(let t of[...Ct].reverse()){let n=h(t);n&&e.prepend(n)}}function Le(e,t){let n=An[e];return n?(h(n)?.setLabel(t),!0):!1}function it(){return!!a()?.panes?.classList.contains("qv-drawer-open")}function w(e,{restoreFocus:t=!0}={}){let n=a(),o=n?.panes,r=n?.panesButton;!o||!r||e===it()||(o.classList.toggle("qv-drawer-open",e),r.setAttribute("aria-expanded",String(e)),e?(document.addEventListener("pointerdown",he,!0),o.querySelector('summary, button, a[href], [tabindex="0"]')?.focus()):(document.removeEventListener("pointerdown",he,!0),t&&o.contains(document.activeElement)&&r.focus()))}function he(e){let t=a(),n=e.target instanceof Node?e.target:null;!n||t?.panes?.contains(n)||t?.panesButton?.contains(n)||t?.verbMenu?.contains(n)||w(!1,{restoreFocus:!1})}var Hn=["northwest","north","northeast","west","east","southwest","south","southeast","up","down","in","out"],qe=[315,0,45,270,90,225,180,135,null,null,null,null],we="http://www.w3.org/2000/svg",Pt=[[1,1],[1,2],[1,3],[2,1],[2,3],[3,1],[3,2],[3,3]],W=[];function at(){return s.compassDirections.length===12?s.compassDirections:Hn}function xe(e){let t=at()[e];return e===10?kt(s.interfaceStrings.get("InButtonLabel"))||t:e===11&&kt(s.interfaceStrings.get("OutButtonLabel"))||t}function kt(e){if(!e)return"";let t=document.createElement("template");return t.innerHTML=e,t.content.textContent?.trim()??""}function Te(e,t){let n=at()[e],o=document.createElement("button");o.type="button",o.className=t,o.dataset.qvDirection=n;let r=qe[e];return r!=null&&o.append(In(r)),o}function In(e){let t=document.createElementNS(we,"svg");t.setAttribute("class","qv-direction-arrow"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round");let n=document.createElementNS(we,"path");return n.setAttribute("d","M12 19V5M5 12l7-7 7 7"),n.setAttribute("transform",`rotate(${e} 12 12)`),t.append(n),t}function B(){let e=h("compass");if(e){let t=document.createElement("div");t.className="qv-compass-points";let n=document.createElement("div");n.className="qv-compass-others",at().forEach((r,i)=>{let l=Te(i,"qv-compass-button"),u=xe(i);l.setAttribute("aria-label",u),l.title=u,qe[i]==null&&l.append(u),l.disabled=!W.includes(r),Pt[i]?(l.style.gridRow=String(Pt[i][0]),l.style.gridColumn=String(Pt[i][1]),t.append(l)):n.append(l)});let o=document.createElement("div");o.className="qv-compass",o.append(t,n),e.body.replaceChildren(o)}f()}function Me(e){W=String(e??"").split("/").filter(Boolean),P("exits",[...W]),B()}function Ce(){W=[]}function f(){let e=a(),t=e?.exits;if(!e||!t)return;let n=h("compass"),o=!!n&&!n.hidden&&!e.panes?.hidden,r=!s.turnPending&&!s.waiting&&!s.pausing&&!s.inDialog&&!s.gameFinished,i=[];o&&r&&at().forEach((d,c)=>{if(!W.includes(d))return;let v=Te(c,"qv-exit");v.append(xe(c)),i.push(v)});let l=h("commands");s.commandsInExitStrip&&l&&!l.hidden&&!e.panes?.hidden&&r&&s.commands.forEach(({label:d,command:c},v)=>{let m=document.createElement("button");m.type="button",m.className=v===0&&i.length>0?"qv-exit qv-exit-command qv-exit-command-first":"qv-exit qv-exit-command",m.dataset.qvCommand=c,m.append(d),i.push(m)}),t.replaceChildren(...i),t.setAttribute("aria-label",kt(s.interfaceStrings.get("CompassLabel"))||(WebPlayer.chromeStrings?.CompassLabel??"Compass")),t.classList.toggle("qv-exits-active",i.length>0)}var N=[];function Ht(e){N=Array.isArray(e)?e.filter(t=>t&&typeof t=="object"):[],P("status",N),$()}function Pe(e){Ht(String(e??"").split(/\r?\n|<br\s*\/?>/i).filter(t=>t.trim()).map(t=>({text:t})))}function ke(){N=[]}function Bn(e){let t=Number(e.value),n=Number(e.max);return e.value==null||e.max==null||!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:{value:Math.min(Math.max(t,0),n),max:n}}var Nn=0;function Ae(e,t){let n=document.createElement(t);n.className="qv-status-item",e.name&&(n.dataset.qvStatus=String(e.name));let o=document.createElement("span");o.className="qv-status-text",o.id=`qv-status-${++Nn}`,o.innerHTML=String(e.text??""),n.append(o);let r=Bn(e);if(r){let i=document.createElement("span");i.className="qv-status-meter",i.setAttribute("role","meter"),i.setAttribute("aria-valuemin","0"),i.setAttribute("aria-valuemax",String(r.max)),i.setAttribute("aria-valuenow",String(r.value)),i.setAttribute("aria-labelledby",o.id);let l=document.createElement("span");l.className="qv-status-meter-fill",l.style.width=`${r.value/r.max*100}%`,i.append(l),n.append(i)}return n}function $(){let e=a(),t=e?.statusBar??null,n=!!t&&!t.hidden&&!e?.hasAttribute("data-qv-gamebook"),o=n?N.filter(l=>l.pinned):[],r=n?N.filter(l=>!l.pinned):N,i=h("status");if(i){let l=document.createElement("ul");l.className="qv-status-list",l.append(...r.map(u=>Ae(u,"li"))),i.body.replaceChildren(l),i.hasAttribute("data-qv-empty")!==(r.length===0)&&(i.toggleAttribute("data-qv-empty",r.length===0),e?.updatePanesButton())}t&&(t.replaceChildren(...o.map(l=>Ae(l,"span"))),t.classList.toggle("qv-status-bar-active",o.length>0)),e?.updateTopbar()}var lt=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",It=null,D=null,ct=null,z=[],ut=0,Bt=!0,K=!1,Nt="header",j=(e,t)=>WebPlayer.chromeStrings?.[e]??t,Dn={gridSquareClicked:(e,t)=>{L("JS_GridSquareClick",`${e};${t}`)},animate:()=>s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches,strings:()=>({map:j("MapLabel","Map"),zoomIn:j("MapZoomIn","Zoom in"),zoomOut:j("MapZoomOut","Zoom out")})};function On(){return window.QuestUIV2Map?Promise.resolve():(It??=new Promise((e,t)=>{let n=new URL(lt?"map.js":"v2/map.js",lt||document.baseURI);lt&&(n.search=new URL(lt).search);let o=document.createElement("script");o.src=n.href,o.onload=()=>e(),o.onerror=()=>{It=null,t(new Error(`Failed to load ${n.href}`))},document.head.append(o)}),It)}function He(){return a()?.map?.querySelector(".qv-map-view")??null}function Rn(){let e=He();if(!e||!window.QuestUIV2Map)return;(!D||ct!==e)&&(D=window.QuestUIV2Map.create(e,Dn),ct=e);let t=z;z=[];for(let[n,o]of t)try{D.call(n,o)}catch(r){console.error(r)}}function Dt(e,t){if(a()?.map){if(e==="show"){let n=typeof t[0]=="number"?t[0]:parseFloat(String(t[0]));ut=Number.isFinite(n)?n:0,q()}if(D&&ct===He()&&z.length===0){D.call(e,t);return}z.push([e,t]),On().then(Rn,n=>console.error(n))}}function Ie(e){Bt=e,q()}function Be(e){e!=="header"&&e!=="panes"||(Nt=e,q())}function q(){let e=a(),t=e?.map;if(!e||!t)return;t.hidden=!(ut>0&&Bt),t.style.setProperty("--qv-map-height",`${ut}px`),t.classList.toggle("qv-map-collapsed",K);let n=Un(t),o=e.mapButton;if(o){o.hidden=t.hidden||n||!e.hasAttribute("data-qv-narrow");let r=o.querySelector(".qv-button-label");r&&(r.textContent=j("MapLabel","Map")),o.setAttribute("aria-expanded",String(!K))}e.updateTopbar()}function Un(e){let t=a();if(!t)return!1;let n=Nt==="panes"&&t.layout!=="none"&&!!t.panes&&!t.panes.hidden,o=h("map");if(n&&!o&&t.panes&&(o=document.createElement("qv-pane"),o.dataset.qvPane="map",o.setAttribute("label",j("MapLabel","Map")),t.panes.prepend(o),At()),n&&o)e.parentElement!==o.body&&o.body.append(e),o.hidden=e.hidden;else{let r=t.querySelector(".qv-header");r&&e.parentElement!==r&&r.append(e),o&&(o.hidden=!0)}return n}function Ne(){K=!K,q()}function De(){D=null,ct=null,z=[],ut=0,Bt=!0,K=!1,Nt="header"}var Ot="questviva-colour-scheme",Fn=["system","light","dark"],G=Vn(),Re=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;function Vn(){try{let e=window.electronPlayerSettings?window.electronPlayerSettings.getColourScheme():localStorage.getItem(Ot);if(e&&Fn.includes(e))return e}catch{}return"system"}function Qn(e){try{window.electronPlayerSettings?window.electronPlayerSettings.setColourScheme(e).catch(()=>{}):e==="system"?localStorage.removeItem(Ot):localStorage.setItem(Ot,e)}catch{}}function Wn(e){return!e.style.getPropertyValue("--qv-bg")}function $n(e){let t=document.createElement("span");t.style.color=e.style.getPropertyValue("--qv-bg"),t.hidden=!0,e.append(t);let n=/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)/.exec(getComputedStyle(t).color);if(t.remove(),!n)return!1;let[o,r,i]=n.slice(1,4).map(l=>{let u=Number(l)/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*i<.18}function Y(e){let t=Wn(e),n=t?G==="dark"||G==="system"&&!!Re?.matches:$n(e);e.setAttribute("data-qv-scheme",n?"dark":"light"),e.toggleAttribute("data-qv-fixed-scheme",!t),document.documentElement.setAttribute("data-qv-scheme",n?"dark":"light");let o=e.querySelector(".qv-scheme");if(o){o.hidden===t&&(o.hidden=!t,t||A(e,!1));for(let r of o.querySelectorAll("[data-qv-scheme-icon]"))r.hidden=r.dataset.qvSchemeIcon!==G;for(let r of o.querySelectorAll("[data-qv-scheme-choice]"))r.setAttribute("aria-checked",String(r.dataset.qvSchemeChoice===G))}}function jn(e,t){G=t,Qn(t),Y(e)}function Ft(e){return e.querySelector(".qv-scheme-menu")}function Rt(e){return[...e.querySelectorAll("[data-qv-scheme-choice]")]}function Oe(e){let t=Ft(e),n=e.querySelector(".qv-scheme-button");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true"),(Rt(t).find(r=>r.getAttribute("aria-checked")==="true")??Rt(t)[0])?.focus()}function A(e,t){let n=Ft(e),o=e.querySelector(".qv-scheme-button");!n||n.hidden||(n.hidden=!0,o?.setAttribute("aria-expanded","false"),t&&o?.focus())}var Ut=null;Re?.addEventListener("change",()=>{Ut?.isConnected&&Y(Ut)});function Ue(e){Ut=e,Y(e);let t=e.querySelector(".qv-scheme-button"),n=Ft(e);!t||!n||(t.addEventListener("click",()=>{n.hidden?Oe(e):A(e,!0)}),t.addEventListener("keydown",o=>{(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),Oe(e))}),n.addEventListener("click",o=>{let r=o.target instanceof Element?o.target.closest("[data-qv-scheme-choice]"):null;r&&(jn(e,r.dataset.qvSchemeChoice),A(e,!0))}),n.addEventListener("keydown",o=>{let r=Rt(n),i=r.indexOf(document.activeElement),l=-1;if(o.key==="ArrowDown")l=(i+1)%r.length;else if(o.key==="ArrowUp")l=(i-1+r.length)%r.length;else if(o.key==="Home")l=0;else if(o.key==="End")l=r.length-1;else if(o.key==="Escape"){o.preventDefault(),o.stopPropagation(),A(e,!0);return}else if(o.key==="Tab"){A(e,!1);return}l>=0&&(o.preventDefault(),r[l]?.focus())}),document.addEventListener("pointerdown",o=>{!n.hidden&&o.target instanceof Node&&!n.contains(o.target)&&!t.contains(o.target)&&A(e,!1)}),n.addEventListener("focusout",o=>{o.relatedTarget instanceof Node&&!n.contains(o.relatedTarget)&&o.relatedTarget!==t&&A(e,!1)}))}var Fe=["sidepanes","nopanes","bottombar"],zn=900,Kn=new Set(["--qv-font-size","--qv-output-width","--qv-padding-top","--qv-padding-bottom","--qv-padding-left","--qv-padding-right","--qv-menu-font-size","--qv-radius","--qv-space"]),dt=class extends HTMLElement{#e=!1;#t="sidepanes";#n="sidepanes";connectedCallback(){if(this.#e)return;this.#e=!0,this.addEventListener("click",n=>ue(n,this.verbMenu)),this.addEventListener("keydown",de);for(let n of this.querySelectorAll(".qv-panes-button"))n.addEventListener("click",()=>w(!it()));this.mapButton?.addEventListener("click",Ne),Ue(this),new ResizeObserver(()=>this.#r()).observe(this),this.panes?.addEventListener("keydown",n=>{n.key==="Escape"&&it()&&!this.verbMenu?.isOpen&&(n.preventDefault(),w(!1))});let t=this.querySelector(".qv-toolbar");t&&(new MutationObserver(()=>{Qe(t),this.updateTopbar()}).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","hidden"]}),Qe(t)),this.addEventListener("pointerover",n=>{let o=n.target instanceof Element?n.target.closest("button"):null;if(!o?.querySelector(":scope > .qv-icon"))return;let r=o.querySelector(".qv-button-label")?.textContent?.trim()||o.getAttribute("aria-label");r&&(o.title=r)}),this.#r(),this.updatePanesButton()}get topbar(){return this.querySelector(".qv-topbar")}get saveButton(){return this.querySelector("#cmdSave")}get panes(){return this.querySelector('[data-qv-part="panes"]')}get exits(){return this.querySelector('[data-qv-part="exits"]')}get statusBar(){return this.querySelector('[data-qv-part="status-bar"]')}get panesButton(){return this.querySelector(this.layout==="sheet"?".qv-footer .qv-panes-button":".qv-topbar .qv-panes-button")}get layout(){return this.dataset.qvLayout??"side"}setLayoutPreset(t,n){if(t==="gamebook"){this.toggleAttribute("data-qv-gamebook",!0),this.#t=this.#n="nopanes",this.setVisible("command-bar",!1),this.setVisible("location",!1),this.#r();return}Fe.includes(t)&&(this.removeAttribute("data-qv-gamebook"),this.#t=t,this.#n=n!=null&&Fe.includes(n)?n:t,this.#r())}#r(){let t=this.clientWidth<zn;t!==this.hasAttribute("data-qv-narrow")&&(this.toggleAttribute("data-qv-narrow",t),q());let n=t?this.#n:this.#t,o=n==="nopanes"?"none":n==="bottombar"?"sheet":t?"drawer":"side";this.dataset.qvLayout!==o&&(w(!1,{restoreFocus:!1}),this.toggleAttribute("data-qv-layout-changing",!0),this.dataset.qvLayout=o,q(),requestAnimationFrame(()=>requestAnimationFrame(()=>this.removeAttribute("data-qv-layout-changing"))),f(),this.updateTopbar())}updateTopbar(){let t=this.topbar;if(!t)return;let n=this.location,o=[...t.querySelectorAll(".qv-toolbar > button, .qv-toolbar > .qv-scheme:not([hidden]) > button")].some(l=>!l.hidden&&l.style.display!=="none"&&getComputedStyle(l).display!=="none"),r=this.statusBar,i=!!r&&!r.hidden&&r.classList.contains("qv-status-bar-active")&&getComputedStyle(r).display!=="none";t.hidden=(!n||n.hidden)&&!o&&!i}focusFirstChoice(){if(!this.hasAttribute("data-qv-gamebook"))return;let t=document.activeElement;if(t&&t!==document.body&&this.contains(t)&&!t.closest(".qv-hiding")&&!t.classList.contains("disabled"))return;[...this.querySelectorAll('[data-qv-part="output"] [data-qv-sections] a.commandlink:not(.disabled)')].find(o=>!o.closest(".qv-hiding"))?.focus({preventScroll:!0})}get verbMenu(){return this.querySelector("qv-verb-menu")}updateLinks(t,n){le(this,t,n),this.verbMenu?.closeIfStale()}get output(){return this.querySelector("qv-output")}get commandBar(){return this.querySelector("qv-command-bar")}get location(){return this.querySelector('[data-qv-part="location"]')}get pictureFrame(){return this.querySelector('[data-qv-part="picture-frame"]')}get map(){return this.querySelector('[data-qv-part="map"]')}get mapButton(){return this.querySelector(".qv-map-button")}get frame(){return this.querySelector('[data-qv-part="border"]')}setVisible(t,n){switch(t){case"output":this.#o(this.output,!n);break;case"command-bar":this.#o(this.commandBar,!n);break;case"location":this.#o(this.location,!n),this.updateTopbar();break;case"border":this.frame?.classList.toggle("qv-borderless",!n);break;case"picture-frame":this.#o(this.pictureFrame,!n);break;case"exits":this.#o(this.exits,!n);break;case"map":Ie(n);break;case"status-bar":this.#o(this.statusBar,!n);break;case"panes":this.#o(this.panes,!n),n||w(!1,{restoreFocus:!1}),q(),this.updatePanesButton();break;default:(Mt.includes(t)||h(t))&&(this.#o(h(t),!n),this.updatePanesButton())}f(),$()}updatePanesButton(){let t=this.panes;if(!t)return;let n=[...t.querySelectorAll("qv-pane")].some(o=>!o.hidden&&!o.hasAttribute("data-qv-empty"));for(let o of this.querySelectorAll(".qv-panes-button"))o.hidden=t.hidden||!n;this.updateTopbar()}#o(t,n){t&&(t.hidden=n)}setTokens(t){for(let[n,o]of Object.entries(t)){if(!n.startsWith("--"))continue;let r=o==null?"":String(o).trim();if(r===""){this.style.removeProperty(n);continue}Kn.has(n)&&/^-?(\d+\.?\d*|\.\d+)$/.test(r)&&(r+="px"),this.style.setProperty(n,r)}this.toggleAttribute("data-qv-own-accent",!!this.style.getPropertyValue("--qv-accent")),this.toggleAttribute("data-qv-own-background",["--qv-bg","--qv-bg-light","--qv-bg-dark"].some(n=>!!this.style.getPropertyValue(n))),this.toggleAttribute("data-qv-own-border",["--qv-border-colour","--qv-border-colour-light","--qv-border-colour-dark"].some(n=>!!this.style.getPropertyValue(n))),Y(this),this.updateTopbar()}setLocation(t){let n=this.location;n&&(n.innerHTML=t,n.classList.toggle("qv-empty",t.trim()===""))}},Ve="http://www.w3.org/2000/svg";function Qe(e){let t=e.querySelector("#cmdRestart");if(!t||t.querySelector(".qv-icon"))return;let n=document.createElement("span");n.className="qv-button-label",n.textContent=t.textContent;let o=document.createElementNS(Ve,"svg");o.setAttribute("class","qv-icon"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");for(let r of["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8","M3 3v5h5"]){let i=document.createElementNS(Ve,"path");i.setAttribute("d",r),o.append(i)}t.replaceChildren(o,n)}function a(){return document.querySelector("qv-player")}var mt=0,Vt=0,_,We=!1;function $e(e){Vt=e,Gn()}function Qt(){return O(),mt}function je(){We=!0,O()}function O(){_!==void 0&&(clearInterval(_),_=void 0)}function Gn(){We||_!==void 0||(mt=0,_=setInterval(async()=>{mt++,Vt>0&&mt>=Vt&&await WebPlayer.uiTick(Qt())},1e3))}function Q(){return window.canSendCommand&&!s.gameFinished&&!s.soundWait&&!s.waiting&&!s.pausing&&!s.inDialog}function g(e,t){if(!Q())return!1;window.canSendCommand=!1,a()?.output?.markScrollPosition(),s.hasUnsavedProgress=!0;let n=Qt();return setTimeout(()=>{WebPlayer.sendCommand(e,n,t??null)},0),!0}function L(e,t){s.hasUnsavedProgress=!0;let n=""+t;return setTimeout(()=>{WebPlayer.uiSendEvent(e,n)},1),!0}var pt=new Set;function R(e,t){t?pt.add(e):pt.delete(e),a()?.toggleAttribute("data-qv-input-held",pt.size>0)}function Ke(){pt.clear(),clearTimeout(ft),J=null}function Ge(){s.waiting=!0,f(),a()?.commandBar?.setMode("continue"),a()?.output?.markScrollPosition()}function Z(){s.waiting&&(s.waiting=!1,a()?.commandBar?.setMode("none"),s.hasUnsavedProgress=!0,sendEndWait())}function $t(){f(),!s.waiting&&ht()}var ft;function Ye(e){s.pausing=!0,f(),R("pause",!0),clearTimeout(ft),ft=setTimeout(_n,e)}function _n(){s.pausing&&(s.pausing=!1,sendEndPause())}function jt(){f(),!s.pausing&&(R("pause",!1),ht())}function _e(){s.waiting&&(s.waiting=!1,$t()),s.pausing&&(clearTimeout(ft),s.pausing=!1,jt()),J?.()}function ht(){let e=a()?.commandBar;!e||s.gameFinished||s.waiting||s.inDialog||(e.setMode("input"),e.focusInput())}var Wt={cancel:"Cancel",yes:"Yes",no:"No"},ze=0,J=null;function Je(e,t,n){let o=a();if(!o)return;let r=++ze;o.querySelector("dialog.qv-dialog")?.remove();let i=document.createElement("dialog");i.className="qv-dialog",i.dataset.qvPart="menu";let l="qv-dialog-caption";i.setAttribute("aria-labelledby",l);let u=document.createElement("div");u.id=l,u.className="qv-dialog-caption",u.innerHTML=e;let d=document.createElement("div");d.className="qv-dialog-choices";let c=!1,v=m=>{c||(c=!0,J=null,i.close(),i.remove(),s.hasUnsavedProgress=!0,setTimeout(async()=>{try{await m()}finally{ze===r&&(s.inDialog=!1,f(),ht())}},100))};for(let m of t){let T=document.createElement("button");T.type="button",T.textContent=m.label,T.addEventListener("click",()=>v(m.choose)),d.append(T)}if(i.append(u,d),n){let m=document.createElement("button");m.type="button",m.className="qv-dialog-cancel",m.textContent=Wt.cancel,m.addEventListener("click",()=>v(n)),i.append(m)}i.addEventListener("cancel",m=>{m.preventDefault(),n&&v(n)}),i.addEventListener("close",()=>{!c&&i.isConnected&&i.showModal()}),J=()=>{c=!0,J=null,i.close(),i.remove(),s.inDialog=!1,f(),ht()},s.inDialog=!0,f(),o.commandBar?.setMode("none"),o.append(i),i.showModal(),d.querySelector("button")?.focus()}function Ze(e,t,n){let o=Object.entries(t).map(([r,i])=>({label:i,choose:()=>WebPlayer.uiChoice(r)}));Je(e,o,n?()=>WebPlayer.uiChoiceCancel():null)}function Xe(e){Je(e,[{label:Wt.yes,choose:()=>WebPlayer.uiSetQuestionResponse(!0)},{label:Wt.no,choose:()=>WebPlayer.uiSetQuestionResponse(!1)}],null)}var en=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches;document.addEventListener("pointerdown",e=>{en=e.pointerType!=="mouse"&&!(e.target instanceof Element&&e.target.closest(".qv-command-input"))},!0);var vt=class extends HTMLElement{#e;#t;#n;#r;#o="input";#s=[];#i=0;#a="";connectedCallback(){if(this.#t)return;let t=this.#e=document.createElement("form");t.className="qv-command-form",this.#n=document.createElement("span"),this.#n.className="qv-command-prompt",this.#n.setAttribute("aria-hidden","true"),this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="qv-command-input",this.#t.autocomplete="off",this.#t.spellcheck=!1,this.#t.setAttribute("autocapitalize","off"),this.#t.setAttribute("enterkeyhint","send"),this.#t.dataset.chromeKeyAriaLabel="CommandInputLabel",this.#t.setAttribute("aria-label","Type your command"),t.append(this.#n,this.#t),this.#r=document.createElement("button"),this.#r.type="button",this.#r.className="qv-continue",this.#r.hidden=!0,this.#r.addEventListener("click",Z),this.append(t,this.#r),t.addEventListener("submit",n=>{n.preventDefault(),this.#c()}),this.#t.addEventListener("keydown",n=>this.#l(n)),this.updatePlaceholder(),this.updateContinueLabel()}setMode(t){this.#o=t,this.#e.hidden=t!=="input",this.#r.hidden=t!=="continue",t==="continue"&&this.#r.focus({preventScroll:!0})}get input(){return this.#t}focusInput(){if(this.hidden)return;let t=this.#o==="input"?this.#t:this.#o==="continue"?this.#r:null;t===this.#t&&en||t&&document.activeElement!==t&&t.focus({preventScroll:!0})}setPrompt(t){this.#n.innerHTML=t}setStyle(t){this.#t.style.cssText=t}setPreset(t){(t==="borderless"||t==="shadow")&&(this.dataset.qvPreset=t)}updateContinueLabel(){this.#r.textContent=tn(s.interfaceStrings.get("ContinueLabel")??"")||"Continue"}updatePlaceholder(){this.#t.placeholder=s.commandPlaceholder??tn(s.interfaceStrings.get("TypeHereLabel")??"")}#c(){let t=this.#t.value;t.length===0||!Q()||g(t)&&(this.#s.at(-1)!==t&&this.#s.push(t),this.#i=this.#s.length,this.#a="",this.#t.value="")}#l(t){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown"||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let n=this.#i+(t.key==="ArrowUp"?-1:1);if(n<0||n>this.#s.length)return;t.preventDefault(),this.#i===this.#s.length&&(this.#a=this.#t.value),this.#i=n,this.#t.value=n===this.#s.length?this.#a:this.#s[n];let o=this.#t.value.length;this.#t.setSelectionRange(o,o)}};function tn(e){let t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}var zt=new Set;function gt(e,t){let n=typeof e=="number"?e:parseFloat(String(e));return Number.isFinite(n)?n:t}function Zn(e){let t=document.createElement("template");return t.innerHTML=String(e??""),t.content.textContent??""}function nn(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return e[Math.floor(Math.random()*e.length)]}function Xn(e){for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function on(e,t){if(e!=="typewriter"&&e!=="unscramble")return;let n=a()?.output;if(!n)return;let o=Zn(t[0]),r=Math.max(0,gt(t[1],100)),i=e==="unscramble"?Math.max(1,Math.floor(gt(t[2],1))):0,[l,u,d]=(e==="unscramble"?t.slice(3,6):t.slice(2,5)).map(b=>b==null?"":String(b).trim()),c=document.createElement("span");c.className="qv-text-effect",c.dataset.qvEffect=e,l&&c.style.setProperty("font-family",l),u&&c.style.setProperty("color",u),d&&gt(d,0)>0&&c.style.setProperty("font-size",`${gt(d,0)}pt`);let v=document.createElement("span");v.className="qv-text-effect-full",v.textContent=o;let m=document.createElement("span");m.className="qv-text-effect-shown",m.setAttribute("aria-hidden","true"),c.append(v,m);let T=document.createElement("span");if(T.textContent=o,n.addNodes([c,document.createElement("br")],`${T.innerHTML}<br/>`),!(s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches)||o===""){Kt(c);return}c.classList.add("qv-text-effect-running");let wt;if(e==="typewriter"){let b=0;wt=()=>(b++,m.textContent=o.substring(0,b)+(b%2===1&&b<o.length?"_":""),b>=o.length)}else{let b=[...o],F=b.flatMap((E,nt)=>/\s/.test(E)?[]:[nt]);Xn(F);let et=b.map(E=>/\s/.test(E)?E:nn());m.textContent=et.join(""),wt=()=>{for(let E=0;E<i&&F.length;E++){let nt=F.pop();et[nt]=b[nt]}for(let E of F)et[E]=nn();return m.textContent=et.join(""),F.length===0}}let U={timer:0,finish:()=>{clearInterval(U.timer),zt.delete(U),Kt(c)}};U.timer=window.setInterval(()=>{(!c.isConnected||wt())&&U.finish()},r),zt.add(U)}function Kt(e){let t=e.querySelector(".qv-text-effect-shown");t&&(t.textContent=e.querySelector(".qv-text-effect-full")?.textContent??""),e.classList.remove("qv-text-effect-running")}function bt(){for(let e of[...zt])e.finish()}function rn(e){for(let t of e.querySelectorAll(".qv-text-effect"))Kt(t)}document.addEventListener("keydown",()=>bt(),!0);document.addEventListener("pointerdown",()=>bt(),!0);var sn=4,to=150,eo=8,St=class extends HTMLElement{#e=null;#t=0;#n=0;#r=null;#o=null;#s=!1;connectedCallback(){this.#e=this.querySelector("button"),this.#e?.addEventListener("click",this.#l),window.addEventListener("scroll",this.#i,{passive:!0}),window.addEventListener("resize",this.#i,{passive:!0}),this.#r=new ResizeObserver(this.#i);let t=a();for(let n of[t?.output,t?.commandBar,t?.querySelector(".qv-footer"),t?.querySelector(".qv-header")])n&&this.#r.observe(n);this.#o=new MutationObserver(n=>{n.some(o=>o.type==="characterData"||o.addedNodes.length>0)&&(this.#s=!1,this.#i())}),t?.output&&this.#o.observe(t.output,{childList:!0,characterData:!0,subtree:!0}),this.#i()}disconnectedCallback(){this.#e?.removeEventListener("click",this.#l),window.removeEventListener("scroll",this.#i),window.removeEventListener("resize",this.#i),this.#r?.disconnect(),this.#r=null,this.#o?.disconnect(),this.#o=null,cancelAnimationFrame(this.#t),clearTimeout(this.#n),this.#t=this.#n=0}#i=()=>{this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#a()}))};#a(){let t=this.#e;if(!t)return;let n=Gt();if(!n||this.#s){n||(this.#s=!0),clearTimeout(this.#n),this.#n=0,this.#c();return}this.style.setProperty("--qv-more-bottom",`${window.innerHeight-n.limit+eo}px`),this.style.setProperty("--qv-more-x",`${n.centre}px`),t.hidden&&(clearTimeout(this.#n),this.#n=window.setTimeout(()=>{this.#n=0,!this.#s&&Gt()&&(t.hidden=!1)},to))}#c(){let t=this.#e;if(!t||t.hidden)return;let n=t.contains(document.activeElement);t.hidden=!0,n&&(a()?.commandBar?.focusInput(),document.activeElement===t&&t.blur())}#l=()=>{let t=Gt();if(!t)return;let n=document.querySelector("qv-player .qv-header"),o=Math.max(0,n?.getBoundingClientRect().bottom??0),r=a()?.output,i=r&&parseFloat(getComputedStyle(r).lineHeight)||24,l=Math.max(i,t.limit-o-2*i),u=!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollBy({top:l,behavior:u?"smooth":"instant"})}};function Gt(){let e=a(),t=e?.output;if(!e||!t||t.hidden||!t.isConnected)return null;let n=window.innerHeight,o=e.querySelector(".qv-footer"),r=o&&getComputedStyle(o).display!=="contents"?o:e.commandBar,i=r&&!r.hidden&&r.offsetHeight>0?r.getBoundingClientRect():null,l=i?Math.min(n,i.top):n,u=t.lastElementChild;if(!((u?u.getBoundingClientRect().bottom:t.getBoundingClientRect().top)>l+sn||i!=null&&i.bottom>n+sn))return null;let v=t.getBoundingClientRect();return{limit:l,centre:v.left+v.width/2}}var ln=(e,t)=>WebPlayer.chromeStrings?.[e]??t;function an(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function cn(e,t,n,o=""){let r=a()?.output;r&&r.addText(`<iframe class="qv-video" data-qv-video="${e}" src="${an(t.href)}" title="${an(n)}" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" allowfullscreen${o}></iframe>`)}function un(e){let t=new URL(`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e.trim())}`);t.searchParams.set("autoplay","1"),t.searchParams.set("rel","0"),cn("youtube",t,ln("YouTubeVideoTitle","YouTube video"))}function dn(e){let[t,n]=e.trim().split("/"),o=new URL(`https://player.vimeo.com/video/${encodeURIComponent(t)}`);n&&o.searchParams.set("h",n),o.searchParams.set("autoplay","1"),o.searchParams.set("dnt","1"),cn("vimeo",o,ln("VimeoVideoTitle","Vimeo video"),' sandbox="allow-same-origin allow-scripts allow-popups allow-presentation"')}function mn(e){for(let t of e.querySelectorAll("iframe[data-qv-video]")){let n;try{n=new URL(t.getAttribute("src")??"")}catch{continue}n.searchParams.has("autoplay")&&(n.searchParams.delete("autoplay"),t.setAttribute("src",n.href))}}function yt(e){let t=a()?.pictureFrame;if(t){t.innerHTML=e,t.classList.toggle("qv-empty",e.trim()==="");for(let n of t.querySelectorAll("img"))n.hasAttribute("alt")||(n.alt=""),n.complete||(n.addEventListener("load",Yt,{once:!0}),n.addEventListener("error",Yt,{once:!0}));Yt()}}function pn(){let e=a()?.pictureFrame;return!e||e.hidden||e.classList.contains("qv-empty")?!1:[...e.querySelectorAll("img")].some(t=>!t.complete)}function Yt(){a()?.output?.rescroll(!0)}var vn=new Map;function gn(e,t,n){vn.set(e,{width:t,height:n})}var no=8;function oo(e){s.warnedAboutScript||!/<script[\s>\/]/i.test(e)||(s.warnedAboutScript=!0,console.warn(`[Quest] This game printed a <script> element, which doesn't run in the new player interface. Call your own JavaScript with JS.yourFunction () or JS.eval instead, or tick "Use the classic interface" on the game's Interface tab.`))}var Et=class extends HTMLElement{#e=null;#t=[];#n=0;#r=0;#o=!0;#s=0;connectedCallback(){this.setAttribute("role","log"),this.setAttribute("aria-live","polite"),this.addEventListener("load",this.#i,!0),this.addEventListener("error",this.#i,!0)}disconnectedCallback(){this.removeEventListener("load",this.#i,!0),this.removeEventListener("error",this.#i,!0)}#i=t=>{t.target instanceof HTMLImageElement&&this.rescroll()};addText(t){oo(t);let n=this.#e??this.setAlignment("left");n.insertAdjacentHTML("beforeend",t),ro(n),so(n),H(n),this.#o=!0,WebPlayer.transcript?.write(t),y("outputAdded",{html:t})}addNodes(t,n){(this.#e??this.setAlignment("left")).append(...t),this.#o=!0,WebPlayer.transcript?.write(n),y("outputAdded",{html:n})}setAlignment(t){this.#e&&!this.#e.hasChildNodes()&&this.#e.remove();let n=document.createElement("div");return n.className="qv-block",n.style.textAlign=t,this.#t.length&&(n.dataset.qvSections=this.#t.join(" ")),this.append(n),this.#e=n,n}clearScreen(){this.replaceChildren(),this.#e=null,this.setAlignment("left"),this.#n=0,this.#o=!0;let t=this.#u();window.scrollY>t&&window.scrollTo({top:t,behavior:"instant"})}loadHtml(t){let n=document.createElement("template");n.innerHTML=t,mn(n.content),rn(n.content),this.replaceChildren(n.content),this.#o=!0,H(this),ae(this),requestAnimationFrame(()=>{let o=document.scrollingElement??document.documentElement;window.scrollTo({top:o.scrollHeight,behavior:"instant"})}),this.#e=null,this.#t=[]}getHtml(){return this.innerHTML}reset(){this.replaceChildren(),this.#e=null,this.#t=[],this.#n=0,this.#r=0,this.#o=!0,this.#s=0}startSection(t){this.#t.includes(t)||(this.#t.push(t),this.setAlignment("left"))}endSection(t){let n=this.#t.indexOf(t);n!==-1&&(this.#t.splice(n,1),this.setAlignment("left"))}hideSection(t){this.endSection(t);let n=this.getBoundingClientRect().top;for(let o of this.#a(t)){let r=o.getBoundingClientRect();r.bottom-n<=this.#n+1&&(this.#n=Math.max(0,this.#n-r.height)),o.classList.add("qv-hiding"),hn(o),setTimeout(()=>o.remove(),250)}}disableSection(t){for(let n of this.#a(t))hn(n)}disableCommandLinks(){for(let t of this.querySelectorAll("a.commandlink"))rt(t);a()?.verbMenu?.closeIfStale()}#a(t){return[...this.querySelectorAll("[data-qv-sections]")].filter(n=>n.dataset.qvSections.split(" ").includes(t))}beginTurn(){if(s.fadePreviousOutput)for(let t of this.children)t.classList.add("qv-previous-output")}clearPreviousOutputFade(){for(let t of this.querySelectorAll(".qv-previous-output"))t.classList.remove("qv-previous-output")}markScrollPosition(){this.#n=this.#c()}#c(){let t=this.lastElementChild;return t?t.getBoundingClientRect().bottom-this.getBoundingClientRect().top:0}scrollToEnd(){let t=this.#c();!this.#o&&t<=this.#s+1||(this.#o=!1,this.#s=t,this.#l(this.#n))}rescroll(t=!1){this.#l(this.#r,t)}#l(t,n=!1){if(!s.autoScroll||(this.#r=t,pn()))return;let r=(document.scrollingElement??document.documentElement).scrollHeight-window.innerHeight,i=s.animateScroll?Math.min(this.#u()+t-fn()-no,r):r,l=this.#u()+t-window.scrollY,u=n&&l>=0&&l<fn();if(i<=window.scrollY&&!u)return;let d=s.animateScroll&&!matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:i,behavior:d?"smooth":"instant"})}#u(){return this.getBoundingClientRect().top+window.scrollY}};function fn(){return document.querySelector("qv-player .qv-header")?.offsetHeight??0}function hn(e){for(let t of e.querySelectorAll("a.cmdlink, a[data-qv-event]"))t.classList.contains("commandlink")?rt(t):M(t,!1);a()?.verbMenu?.closeIfStale()}function ro(e){for(let t of e.querySelectorAll("img:not([alt])"))t.setAttribute("alt","")}function so(e){for(let t of e.querySelectorAll("img:not([width]):not([height]):not([style])")){let n=vn.get(t.getAttribute("src")??"");n&&(t.setAttribute("width",String(n.width)),t.setAttribute("height",String(n.height)),t.classList.add("qv-sized"))}}var x=()=>WebPlayer.transcript;function bn(e){let t=a()?.output;t?.addText(e),t?.scrollToEnd()}var Sn={write:e=>x()?.write(String(e??"")),enable:e=>x()?.enable(e==null?void 0:String(e)),disable:()=>x()?.disable(),kill:()=>x()?.kill(),revive:()=>x()?.revive(),setName:e=>x()?.setName(String(e??"")),setPrefix:()=>{},stampDateAndTime:()=>bn(`<b>DATE AND TIME:</b> ${new Date().toLocaleString(navigator.language,{timeZoneName:"short"})}`),promptForName:()=>{let e=a()?.commandBar?.input;e&&(e.value=x()?.name||document.title,e.focus({preventScroll:!0}))},show:(e,t)=>{let n=document.createElement("a");n.href=x()?.viewerUrl??"TranscriptViewer/index.html",n.target="_blank",n.textContent=t==null||t===""?"Your Transcripts":String(t);let o=e==null||e===""?"Your transcripts are saved to the localStorage in your browser. You can view, download, or delete them here:":String(e);bn(`${o} ${n.outerHTML}<br/>`)}};var p=e=>(...t)=>Dt(e,t),io={show:p("show"),respondToClicks:p("respondToClicks"),setInteractive:p("setInteractive"),setScale:p("setScale"),setCentre:p("setCentre"),drawBox:p("drawBox"),drawLabel:p("drawLabel"),drawPlayer:p("drawPlayer"),drawLine:p("drawLine"),drawArrow:p("drawArrow"),drawSquare:p("drawSquare"),drawShape:p("drawShape"),addShapePoint:p("addShapePoint"),drawImage:p("drawImage"),drawSvg:p("drawSvg"),loadSvg:p("loadSvg"),drawGridLines:p("drawGridLines"),showCustomLayer:p("showCustomLayer"),clearCustomLayer:p("clearCustomLayer"),removeDrawing:p("removeDrawing"),clearAllLayers:p("clearAllLayers"),setLevel:p("setLevel")};function X(e){return typeof e=="string"?JSON.parse(e):e}function _t(e){let t=e??"";a()?.setLocation(t),y("locationChanged",{location:t})}function Jt(e,t){s.interfaceStrings.set(e,t),e==="EmptyListLabel"&&(s.interfaceStrings.delete("InventoryEmptyLabel"),s.interfaceStrings.delete("PlacesObjectsEmptyLabel")),Le(e,t),(e==="InButtonLabel"||e==="OutButtonLabel"||e==="CompassLabel")&&B(),e==="TypeHereLabel"&&a()?.commandBar?.updatePlaceholder(),e==="ContinueLabel"&&a()?.commandBar?.updateContinueLabel()}function Zt(e){s.compassDirections=Array.isArray(e)?e.map(String):String(e??"").split(";"),B()}var yn={sendCommand:g,sendEvent:L,restart:()=>window.RestartGame?.(),addText:e=>a()?.output?.addText(String(e)),clearScreen:()=>a()?.output?.clearScreen(),setAlignment:e=>{a()?.output?.setAlignment(String(e))},startSection:e=>a()?.output?.startSection(String(e)),endSection:e=>a()?.output?.endSection(String(e)),hideSection:e=>a()?.output?.hideSection(String(e)),disableSection:e=>a()?.output?.disableSection(String(e)),disableCommandLinks:()=>a()?.output?.disableCommandLinks(),updateLinks:(e,t)=>a()?.updateLinks(String(e),X(t)),scrollToEnd:()=>a()?.output?.scrollToEnd(),addYouTube:e=>un(String(e??"")),addVimeo:e=>dn(String(e??"")),textEffect:(e,...t)=>on(String(e),t),setVisible:(e,t)=>a()?.setVisible(String(e),!!t),setPaneOrder:e=>Ee(X(e)),setLayoutPreset:(e,t)=>a()?.setLayoutPreset(String(e),t==null?void 0:String(t)),setMapPosition:e=>Be(String(e??"")),setPictureFrame:e=>yt(String(e??"")),setInterfaceString:Jt,setCompassDirections:e=>Zt(X(e)),setLocation:_t,setStatusAttributes:e=>Ht(X(e)),setTokens:e=>a()?.setTokens(X(e)??{}),setCommandBarStyle:e=>a()?.commandBar?.setStyle(String(e??"")),setCommandBarPreset:e=>a()?.commandBar?.setPreset(String(e??"")),setCommandPrompt:e=>a()?.commandBar?.setPrompt(String(e??"")),addStylesheet:e=>addExternalStylesheet(String(e)),map:io,transcript:Sn,addPane:(e,t,n)=>ye(String(e),t==null?void 0:String(t),n==null?void 0:String(n)),setPaneContent:(e,t)=>Se(String(e),String(t??"")),setCommands:e=>be(e),setCommandsInExitStrip:e=>{s.commandsInExitStrip=!!e,f()},setAutoScroll:e=>{s.autoScroll=!!e},setContinueOnClick:e=>{s.continueOnClick=!!e},fadePreviousOutput:e=>{s.fadePreviousOutput=!!e,s.fadePreviousOutput||a()?.output?.clearPreviousOutputFade()},setCommandPlaceholder:e=>{s.commandPlaceholder=e==null?null:String(e),a()?.commandBar?.updatePlaceholder()},setMapInteractive:e=>Dt("setInteractive",[e]),lists:oe,on:te,off:ee};function En(e){return(e.dataset.qvName??e.textContent??"").trim()}var Xt=4,tt=8,Lt=class extends HTMLElement{#e=null;connectedCallback(){this.setAttribute("role","menu"),C&&(this.popover="manual"),this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r)}get isOpen(){return this.#e!==null}toggle(t){if(this.#e===t){this.close();return}let n=(t.dataset.verbs??"").split("/").map(r=>r.trim()).filter(Boolean);if(!n.length)return;this.close({restoreFocus:!1});let o=En(t);this.setAttribute("aria-label",(t.textContent??"").trim()),this.replaceChildren(...n.map(r=>{let i=document.createElement("button");return i.type="button",i.setAttribute("role","menuitem"),i.textContent=r,i.dataset.command=`${r.toLowerCase()} ${o}`,i})),this.#e=t,t.setAttribute("aria-expanded","true"),this.classList.add("qv-open"),C&&this.showPopover(),this.#i(),this.querySelector("button")?.focus({preventScroll:!0}),document.addEventListener("pointerdown",this.#o,!0),window.addEventListener("scroll",this.#s,{passive:!0}),window.addEventListener("resize",this.#s)}close({restoreFocus:t=!0}={}){let n=this.#e;if(!n)return;this.#e=null,n.setAttribute("aria-expanded","false");let o=this.contains(document.activeElement);this.classList.remove("qv-open"),C&&this.matches(":popover-open")&&this.hidePopover(),this.replaceChildren(),document.removeEventListener("pointerdown",this.#o,!0),window.removeEventListener("scroll",this.#s),window.removeEventListener("resize",this.#s),t&&o&&n.isConnected&&n.focus({preventScroll:!0})}closeIfStale(){this.#e&&(!this.#e.isConnected||k(this.#e))&&this.close({restoreFocus:!1})}#t(t){let n=this.#e;if(!n)return;let o=En(n),r={};n.dataset.elementid&&(r[o]=n.dataset.elementid),this.close({restoreFocus:!1}),g(t.dataset.command??"",r)}#n=t=>{let n=t.target instanceof Element?t.target.closest('[role="menuitem"]'):null;n&&this.#t(n)};#r=t=>{let n=[...this.querySelectorAll('[role="menuitem"]')],o=n.indexOf(document.activeElement),r=null;switch(t.key){case"Escape":t.preventDefault(),this.close();return;case"Tab":this.close({restoreFocus:!1});return;case"ArrowDown":r=(o+1)%n.length;break;case"ArrowUp":r=(o-1+n.length)%n.length;break;case"Home":r=0;break;case"End":r=n.length-1;break;default:return}t.preventDefault(),n[r]?.focus()};#o=t=>{let n=t.target instanceof Node?t.target:null;n&&(this.contains(n)||this.#e?.contains(n))||this.close({restoreFocus:!1})};#s=()=>{this.closeIfStale(),this.#e&&this.#i()};#i(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),{offsetWidth:n,offsetHeight:o}=this,r=t.bottom+Xt;r+o>window.innerHeight-tt&&t.top-Xt-o>=tt&&(r=t.top-Xt-o);let i=Math.max(tt,Math.min(t.left,window.innerWidth-n-tt));this.style.top=`${Math.max(tt,r)}px`,this.style.left=`${i}px`}};customElements.define("qv-player",dt);customElements.define("qv-output",Et);customElements.define("qv-command-bar",vt);customElements.define("qv-verb-menu",Lt);customElements.define("qv-pane",st);customElements.define("qv-more",St);window.QuestUI=yn;window.sendCommand=(e,t)=>{g(e,t)};window.ASLEvent=L;window.canSendCommand=!0;window.notifyQuestUITurn=e=>{let t=a()?.output;e?(w(!1,{restoreFocus:!1}),t?.beginTurn(),t?.setAttribute("aria-busy","true"),y("turnStarted")):(t?.removeAttribute("aria-busy"),y("turnEnded"),a()?.commandBar?.focusInput(),a()?.focusFirstChoice())};window.resetQuestUIState=()=>{ne(),O(),Ke(),Ce(),ke(),re(),ge(),De(),bt()};document.addEventListener("keydown",e=>{!s.waiting||e.repeat||["Tab","Shift","Control","Alt","Meta"].includes(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, select, [contenteditable], dialog")||(e.preventDefault(),Z())});window.addEventListener("beforeunload",e=>{!s.hasUnsavedProgress||!s.canSave||!a()||(e.preventDefault(),e.returnValue="")});document.addEventListener("click",e=>{!s.waiting||!s.continueOnClick||e.target instanceof Element&&e.target.closest("a, button, input, textarea, select, summary, dialog")||Z()});var S=()=>a()?.output;function Ln(){let e=a()?.saveButton;e&&(e.disabled=s.turnPending)}var ao=()=>{},wn={"#gamePanes":"panes","#location":"location","#txtCommandDiv":"command-bar"},lo={addTextAndScroll(e){S()?.addText(e),S()?.scrollToEnd()},createNewDiv:e=>{S()?.setAlignment(e)},bindMenu:(e,t,n,o)=>ce(e,t,o),showMenu:Ze,showQuestion:Xe,beginWait:Ge,setTurnPending(e){s.turnPending=e,Ln(),f()},beginPause:Ye,updateLocation:_t,setGameName(e){document.title=e},clearScreen:()=>S()?.clearScreen(),panesVisible:e=>a()?.setVisible("panes",e),updateStatus:Pe,setBackground:e=>a()?.setTokens({"--qv-bg":e}),setForeground:ao,updateList:ve,updateCompass:Me,updateObjectLinks:e=>a()?.updateLinks("object",e),gameFinished(){s.gameFinished=!0,O(),s.waiting=!1,R("finished",!0),f()},requestNextTimerTick:$e,uiShow:e=>a()?.setVisible(wn[e]??"",!0),uiHide:e=>a()?.setVisible(wn[e]??"",!1),setCompassDirections:Zt,setInterfaceString:Jt,setPanelContents:yt,loadHtml:e=>S()?.loadHtml(e),markScrollPosition:()=>S()?.markScrollPosition(),scrollToEnd:()=>S()?.scrollToEnd(),requestSave(){GameSaver.saveRequested()},start(){a()?.saveButton?.addEventListener("click",()=>{WebPlayer.onSaveClick?WebPlayer.onSaveClick():GameSaver.save()}),Ln(),B(),$(),a()?.commandBar?.focusInput()},resetOutput(){S()?.reset(),O(),s.hasUnsavedProgress=!1},useManualClock:je,getOutputHtml:()=>S()?.getHtml()??"",getLocation:()=>a()?.location?.textContent?.trim()??"",getOutputElement:()=>S()??null,gameSaved(){S()?.addText(`<span data-qv-save-notice>${WebPlayer.chromeStrings?.GameSaved??"Game saved."}<br></span>`),s.hasUnsavedProgress=!1},clearUnsavedProgress(){s.hasUnsavedProgress=!1},setCanSave(e){s.canSave=e},waitEnded:$t,pauseEnded:jt,dismissPrompt:_e,beginSoundWait(){let e=!a()?.commandBar?.hidden;return s.soundWait=!0,R("sound",!0),e},endSoundWait(){s.soundWait=!1,setTimeout(async()=>{R("sound",!1),await WebPlayer.uiEndWait()},100)},rememberImageSize:gn,setAnimateScroll(e){s.animateScroll=e}};window.QuestPlayerUis=window.QuestPlayerUis??{};window.QuestPlayerUis.v2=lo;})();
package/wasm-player.js CHANGED
@@ -367,6 +367,7 @@ function stageAdjacentFiles(files) {
367
367
  function ui_init() { }
368
368
 
369
369
  function sendEndWait() {
370
+ window.QuestGamepad?.endWait();
370
371
  // The short delay lets the browser paint endWait()'s hidden Continue link
371
372
  // before the engine resumes and (in the WASM build, which runs it on the
372
373
  // one UI thread) blocks painting for the rest of the turn.
@@ -790,6 +791,7 @@ window.WebPlayer = {
790
791
  },
791
792
 
792
793
  setCanSave(value) {
794
+ currentCanSave = value;
793
795
  const cmdSave = document.getElementById("cmdSave");
794
796
  if (cmdSave) cmdSave.style.display = value ? "initial" : "none";
795
797
  playerUi.setCanSave(value);
@@ -842,12 +844,18 @@ window.WebPlayer = {
842
844
  return Bridge.GetSaveGameBytes();
843
845
  },
844
846
 
847
+ // The game's reason for refusing a save right now (game.cansave false), or null.
848
+ saveRefusal() {
849
+ return Bridge?.GetSaveRefusal?.() ?? null;
850
+ },
851
+
845
852
  };
846
853
 
847
854
  // One engine round trip started by the player, bracketed for QuestUI's turnStarted/turnEnded
848
855
  // events (legacy/questui.js).
849
856
  async function playerTurn(run) {
850
857
  window.notifyQuestUITurn?.(true);
858
+ window.QuestGamepad?.markTurnStart();
851
859
  turnsInFlight++;
852
860
  try {
853
861
  // A live interface change being applied finishes first (applyInterfaceChanges).
@@ -866,6 +874,30 @@ async function playerTurn(run) {
866
874
  // change waits for both to be over.
867
875
  let turnsInFlight = 0;
868
876
  let turnPending = false;
877
+ let currentCanSave = false;
878
+
879
+ // A game controller (gamepad.js): what it needs of the host.
880
+ window.QuestGamepad?.attach({
881
+ sendCommand(text) {
882
+ if (typeof window.sendCommand === 'function') window.sendCommand(text);
883
+ },
884
+ commandWord(name) {
885
+ try {
886
+ return Bridge?.GetCommandWord(name) ?? '';
887
+ } catch {
888
+ return '';
889
+ }
890
+ },
891
+ outputElement: () => playerUi?.getOutputElement() ?? null,
892
+ // The controller menu's Saved games button, which works as the Save / Load button does: not
893
+ // mid-turn, and not at all where saving is turned off.
894
+ savedGames() {
895
+ if (!currentCanSave || !WebPlayer.onSaveClick) return 'off';
896
+ return turnPending || turnsInFlight > 0 ? 'busy' : 'ready';
897
+ },
898
+ openSavedGames: () => WebPlayer.onSaveClick?.(),
899
+ chromeString: (key, fallback) => WebPlayer.chromeStrings?.[key] ?? fallback,
900
+ });
869
901
 
870
902
  // Whoever is waiting for the turn to be over (whenTurnOver): a save a game's script asks for waits
871
903
  // until then, so it has the whole turn rather than however much had run when it was asked for.
@@ -988,7 +1020,7 @@ function setGameStylesheet(css) {
988
1020
  // ── Player UIs ──────────────────────────────────────────────────────────────
989
1021
  //
990
1022
  // Each player UI is a bundle of markup (swapped into the page for each game and restart),
991
- // stylesheets and classic scripts, loaded only once a game needs it: the legacy UI (today's, frozen) and v2 (docs/ui-v2-plan.md). The last script
1023
+ // stylesheets and classic scripts, loaded only once a game needs it: the legacy UI (today's, frozen) and v2 (docs/archive/ui-v2-plan.md). The last script
992
1024
  // registers the UI's adapter as window.QuestPlayerUis[name], which is the only way the host
993
1025
  // talks to it. Paths are relative to this page and get the ?v= cache key.
994
1026
  const playerUiBundles = {
@@ -1130,6 +1162,8 @@ function swapInPlayerUi() {
1130
1162
  const debuggerDialogEl = document.getElementById('questVivaDebugger');
1131
1163
  const restartingEl = document.getElementById('qv-restarting');
1132
1164
  const recordingEl = document.getElementById('qv-recording');
1165
+ const controllerEls = ['qv-controller-menu', 'qv-controller-help', 'qv-controller-toast']
1166
+ .map(id => document.getElementById(id)).filter(Boolean);
1133
1167
  startScreenEl?.remove();
1134
1168
  savesDialogEl?.remove();
1135
1169
  debuggerDialogEl?.remove();
@@ -1143,6 +1177,7 @@ function swapInPlayerUi() {
1143
1177
  if (debuggerDialogEl) document.body.appendChild(debuggerDialogEl);
1144
1178
  if (restartingEl) document.body.appendChild(restartingEl);
1145
1179
  if (recordingEl) document.body.appendChild(recordingEl);
1180
+ for (const el of controllerEls) document.body.appendChild(el);
1146
1181
  // This is a genuinely fresh chrome (see above) — addExternalScript's
1147
1182
  // dedupe-by-URL must not carry over, or the game's external
1148
1183
  // scripts silently no-op against it on the very next Initialise() call
@@ -1231,6 +1266,7 @@ function preloadRuntime() {
1231
1266
  async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null, adjacentFiles = null, allowDebug = false) {
1232
1267
  currentIsPreview = isPreview;
1233
1268
  currentAllowDebug = allowDebug;
1269
+ window.QuestGamepad?.reset();
1234
1270
  prefetchPlayerUi(playerUiOverride() ?? (isPreview ? 'v2' : 'legacy'));
1235
1271
  const builder = await loadRuntimeBuilder();
1236
1272
  const runtime = await builder.create();
@@ -1244,14 +1280,20 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
1244
1280
  bindMenu: (linkId, verbs, text, elementId) => playerUi.bindMenu(linkId, verbs, text, elementId),
1245
1281
  showMenu: (caption, optionsJson, allowCancel) => playerUi.showMenu(caption, JSON.parse(optionsJson), allowCancel),
1246
1282
  showQuestion: (caption) => playerUi.showQuestion(caption),
1247
- beginWait: () => playerUi.beginWait(),
1283
+ beginWait: () => {
1284
+ window.QuestGamepad?.beginWait();
1285
+ playerUi.beginWait();
1286
+ },
1248
1287
  setTurnPending: (pending) => {
1249
1288
  turnPending = pending;
1250
1289
  playerUi.setTurnPending(pending);
1251
1290
  if (!pending) scheduleInterfaceChanges();
1252
1291
  },
1253
1292
  beginPause: (ms) => whenClockRuns(() => playerUi.beginPause(ms)),
1254
- dismissPrompt: () => playerUi.dismissPrompt(),
1293
+ dismissPrompt: () => {
1294
+ window.QuestGamepad?.endWait();
1295
+ playerUi.dismissPrompt();
1296
+ },
1255
1297
  updateLocation: (loc) => playerUi.updateLocation(loc),
1256
1298
  setGameName: (name) => {
1257
1299
  currentGameName = name;
@@ -1264,7 +1306,10 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
1264
1306
  setBackground: (colour) => playerUi.setBackground(colour),
1265
1307
  setForeground: (colour) => playerUi.setForeground(colour),
1266
1308
  updateList: (listName, itemsJson) => playerUi.updateList(listName, JSON.parse(itemsJson)),
1267
- updateCompass: (data) => playerUi.updateCompass(data),
1309
+ updateCompass: (data) => {
1310
+ window.QuestGamepad?.updateCompass(data);
1311
+ playerUi.updateCompass(data);
1312
+ },
1268
1313
  updateObjectLinks: (verbsJson) => playerUi.updateObjectLinks(JSON.parse(verbsJson)),
1269
1314
  gameFinished: () => playerUi.gameFinished(),
1270
1315
  requestNextTimerTick: (seconds) => whenClockRuns(() => playerUi.requestNextTimerTick(seconds)),
@@ -1285,7 +1330,11 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
1285
1330
  try { globalEval(call); } catch (e) { console.error(e); }
1286
1331
  },
1287
1332
  jsYield: () => new Promise(resolve => setTimeout(resolve, 0)),
1288
- setCompassDirections: (dirsJson) => playerUi.setCompassDirections(JSON.parse(dirsJson)),
1333
+ setCompassDirections: (dirsJson) => {
1334
+ const directions = JSON.parse(dirsJson);
1335
+ window.QuestGamepad?.setCompassDirections(directions);
1336
+ playerUi.setCompassDirections(directions);
1337
+ },
1289
1338
  setInterfaceString: (name, text) => playerUi.setInterfaceString(name, text),
1290
1339
  setPanelContents: (html) => playerUi.setPanelContents(html),
1291
1340
  consoleError: (msg) => console.error('[Quest]', msg),
@@ -1376,11 +1425,11 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
1376
1425
  // BroadcastChannel (to hand off the picked file's bytes and answer
1377
1426
  // resource requests) but is a real play session and should offer saving.
1378
1427
  WebPlayer.setCanSave(!isPreview);
1379
- // Shown in editor-preview sessions, and also in a source=local play
1380
- // session for a raw .aslx file specifically (allowDebug — see the
1381
- // source=local boot branch below, which is the only caller that ever
1382
- // passes it true) — never for any other normal play session, even
1383
- // though the loaded game itself might have DebugEnabled true.
1428
+ // Shown in editor-preview sessions, and also in a play session for a raw
1429
+ // .aslx file specifically (allowDebug — passed by the source=local,
1430
+ // source=qv and ?url= boot branches below) — never for any other normal
1431
+ // play session, even though the loaded game itself might have
1432
+ // DebugEnabled true.
1384
1433
  WebPlayer.setCanDebug((isPreview || allowDebug) && Bridge.IsDebugEnabled());
1385
1434
 
1386
1435
  // The game's start runs behind the start screen, so a sound it plays can wait for a click
@@ -1933,10 +1982,27 @@ let renamingSave = null;
1933
1982
  let currentSaves = [];
1934
1983
 
1935
1984
  async function refreshSavesList(mode = 'manage') {
1985
+ updateSaveRefusal();
1936
1986
  currentSaves = await listSavesOrReportBlocked(WebPlayer.gameId);
1937
1987
  renderSavesList(currentSaves, mode);
1938
1988
  }
1939
1989
 
1990
+ // A game can refuse saves for a while (game.cansave false), for example while the player is in a
1991
+ // dungeon. The dialog then hides what would make a new save and says why, but loading stays (#3026).
1992
+ // Returns whether saving is refused.
1993
+ function updateSaveRefusal() {
1994
+ const dlg = document.getElementById('qv-saves');
1995
+ const refusal = WebPlayer.saveRefusal();
1996
+ const notice = document.getElementById('qv-saves-refused');
1997
+ if (refusal) {
1998
+ dlg.dataset.saveRefused = '';
1999
+ if (notice) notice.textContent = refusal;
2000
+ } else {
2001
+ delete dlg.dataset.saveRefused;
2002
+ }
2003
+ return !!refusal;
2004
+ }
2005
+
1940
2006
  // Lists the game's saves, or, when the browser won't open IndexedDB at all (a Firefox private
1941
2007
  // window, all site data blocked, a privacy add-on), says in the dialog that saving here isn't
1942
2008
  // available and hides the Save form, instead of the dialog failing to open. Save to file and Load
@@ -1979,6 +2045,7 @@ function downloadSaveBytes(bytes) {
1979
2045
  }
1980
2046
 
1981
2047
  async function downloadSaveToFile() {
2048
+ if (updateSaveRefusal()) return;
1982
2049
  const bytes = await WebPlayer.uiSaveGame(GameSaver.outputHtmlForSave());
1983
2050
  downloadSaveBytes(bytes);
1984
2051
  playerUi.clearUnsavedProgress();
@@ -2089,7 +2156,7 @@ function ensureSavesDialogWired() {
2089
2156
  (cs().OverwriteSaveConfirm ?? 'Overwrite "[name]"?').replace('[name]', saveTitle(slotIndex)),
2090
2157
  cs().OverwriteSave ?? 'Overwrite');
2091
2158
  if (!ok) { opener?.focus(); return; }
2092
- await GameSaver.overwrite(slotIndex);
2159
+ if (!await GameSaver.overwrite(slotIndex)) { await refreshSavesList(); return; }
2093
2160
  await refreshSavesList();
2094
2161
  document.querySelector(`#qv-saves-list [data-slot="${slotIndex}"]`)?.focus();
2095
2162
  } else if (action === 'rename') {
@@ -2136,10 +2203,12 @@ function ensureSavesDialogWired() {
2136
2203
  e.preventDefault();
2137
2204
  const input = document.getElementById('qv-saves-name-input');
2138
2205
  const button = document.getElementById('qv-saves-save-new');
2206
+ let saved = null;
2139
2207
  await withBusyButton(button, cs().SavingBusy ?? 'Saving…', async () => {
2140
- await GameSaver.save(input.value.trim() || undefined);
2208
+ saved = await GameSaver.save(input.value.trim() || undefined);
2141
2209
  });
2142
- input.value = '';
2210
+ // Not saved: the game started refusing saves while the dialog was open.
2211
+ if (saved) input.value = '';
2143
2212
  await refreshSavesList();
2144
2213
  });
2145
2214
 
@@ -2218,6 +2287,7 @@ async function openSavesDialog(mode, gameId = WebPlayer.gameId) {
2218
2287
  saveMenu.hidePopover();
2219
2288
  }
2220
2289
  dlg.dataset.mode = mode;
2290
+ updateSaveRefusal();
2221
2291
  dlg.setAttribute('aria-labelledby', mode === 'boot' ? 'qv-saves-heading-boot' : 'qv-saves-heading-manage');
2222
2292
  currentSaves = await listSavesOrReportBlocked(gameId);
2223
2293
  renderSavesList(currentSaves, mode);
@@ -3028,6 +3098,39 @@ function showFileProtocolError() {
3028
3098
  errorEl.style.display = 'block';
3029
3099
  }
3030
3100
 
3101
+ // The .NET runtime this player is built on can't start in Safari 17 or older, on Mac or iOS:
3102
+ // JavaScriptCore there fails to parse its scripts, and the load mostly hangs with nothing shown
3103
+ // (#3153). Every browser on iOS is WebKit underneath, so there the iOS version is what counts;
3104
+ // on a Mac it's Safari's own version (Chrome, Edge and Firefox bring their own engines). Returns
3105
+ // a short name for the browser, such as "Safari 17" or "iOS 16", or null when it's fine.
3106
+ function unsupportedWebKit(ua = navigator.userAgent) {
3107
+ const ios = /(?:iPhone|iPad|iPod).* OS (\d+)_/.exec(ua);
3108
+ if (ios) return Number(ios[1]) < 18 ? `iOS ${ios[1]}` : null;
3109
+ // A Mac, or an iPad asking for desktop sites, which reports Safari's version the same way.
3110
+ if (!ua.includes('Macintosh') || /Chrome|Chromium|CriOS|FxiOS|Firefox|Edg|Electron/.test(ua)) return null;
3111
+ const safari = /Version\/(\d+)[.\d]* (?:Mobile\/\S+ )?Safari\//.exec(ua);
3112
+ return safari && Number(safari[1]) < 18 ? `Safari ${safari[1]}` : null;
3113
+ }
3114
+
3115
+ function showUnsupportedBrowserError() {
3116
+ document.documentElement.classList.remove('qv-booting');
3117
+ const pickers = document.getElementById('qv-pickers');
3118
+ const msg = document.getElementById('qv-loading-msg');
3119
+ const errorEl = document.getElementById('qv-error');
3120
+ if (msg) msg.style.display = 'none';
3121
+ if (pickers) pickers.style.display = 'none';
3122
+ if (!errorEl) return;
3123
+ const isIos = /iPhone|iPad|iPod/.test(navigator.userAgent)
3124
+ || (navigator.userAgent.includes('Macintosh') && navigator.maxTouchPoints > 1);
3125
+ errorEl.innerHTML = '<strong>This browser is too old to play Quest games.</strong> '
3126
+ + (isIos
3127
+ ? 'Please update your iPhone or iPad to iOS 18 or later (in Settings, General, Software Update), '
3128
+ : 'Please update Safari to version 18 or later (macOS updates it through System Settings, '
3129
+ + 'General, Software Update), or use another browser such as Chrome, Edge or Firefox, ')
3130
+ + 'then open this page again.';
3131
+ errorEl.style.display = 'block';
3132
+ }
3133
+
3031
3134
  // The AppShell tab that was going to hand over game bytes (see the
3032
3135
  // `source=local` boot branch below) turned out not to be there to answer —
3033
3136
  // closed, navigated away, or superseded by a newer Start click in that same
@@ -3294,6 +3397,21 @@ async function fetchGameBytes(url) {
3294
3397
  return;
3295
3398
  }
3296
3399
 
3400
+ // Before anything starts downloading: the runtime won't start here anyway. For a game from
3401
+ // textadventures.co.uk, still report it as failed, so these loads show up in its data.
3402
+ const unsupported = unsupportedWebKit();
3403
+ if (unsupported) {
3404
+ const id = new URLSearchParams(window.location.search).get('id');
3405
+ if (id) {
3406
+ const apiRoot = window.QuestVivaConfig?.textAdventuresApiRoot
3407
+ ?? 'https://textadventures.co.uk/api/';
3408
+ progressUrl = `${apiRoot}gameprogress/${encodeURIComponent(id)}`;
3409
+ reportProgress('failed', `Unsupported browser: ${unsupported}`);
3410
+ }
3411
+ document.addEventListener('DOMContentLoaded', showUnsupportedBrowserError);
3412
+ return;
3413
+ }
3414
+
3297
3415
  // Single-file export (see PlayerExport in src/PlayerCore): the game bytes are
3298
3416
  // inlined as base64 by a <script> tag before this one, so there's nothing
3299
3417
  // to fetch at all — decode and hand straight to the same startGame() every
@@ -3471,7 +3589,10 @@ async function fetchGameBytes(url) {
3471
3589
  showLoading();
3472
3590
  try {
3473
3591
  const { bytes, filename } = await gamePromise;
3474
- await startGame(bytes, filename);
3592
+ // An .aslx is an author's source file, so Debug is on for it as for source=local
3593
+ // and source=qv; a published .quest, .asl or .cas gets none.
3594
+ await startGame(bytes, filename, null, null, false, null, null, null,
3595
+ /\.aslx$/i.test(filename));
3475
3596
  } catch (err) {
3476
3597
  showError(gameUrl, false, err);
3477
3598
  }