diff --git a/about/index.html b/about/index.html index ec54756f..bb406fa8 100644 --- a/about/index.html +++ b/about/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/asm/index.html b/asm/index.html index ec54756f..bb406fa8 100644 --- a/asm/index.html +++ b/asm/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/asset-manifest.json b/asset-manifest.json index f2897dfa..5bbe51fc 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,7 +1,7 @@ { "files": { "main.css": "/web-ide/static/css/main.9acd77f6.css", - "main.js": "/web-ide/static/js/main.9fb233e1.js", + "main.js": "/web-ide/static/js/main.64a1b230.js", "static/js/288.9fdaec0d.chunk.js": "/web-ide/static/js/288.9fdaec0d.chunk.js", "static/js/297.2c45dab0.chunk.js": "/web-ide/static/js/297.2c45dab0.chunk.js", "static/js/269.1e46835e.chunk.js": "/web-ide/static/js/269.1e46835e.chunk.js", @@ -29,13 +29,13 @@ "static/js/535.74ad7816.chunk.js": "/web-ide/static/js/535.74ad7816.chunk.js", "static/js/656.c1a30912.chunk.js": "/web-ide/static/js/656.c1a30912.chunk.js", "static/js/700.b4462144.chunk.js": "/web-ide/static/js/700.b4462144.chunk.js", - "static/js/200.79ef4b82.chunk.js": "/web-ide/static/js/200.79ef4b82.chunk.js", + "static/js/200.33bb522e.chunk.js": "/web-ide/static/js/200.33bb522e.chunk.js", "static/js/828.e00c10f6.chunk.js": "/web-ide/static/js/828.e00c10f6.chunk.js", "service-worker.js": "/web-ide/service-worker.js", "index.html": "/web-ide/index.html" }, "entrypoints": [ "static/css/main.9acd77f6.css", - "static/js/main.9fb233e1.js" + "static/js/main.64a1b230.js" ] } \ No newline at end of file diff --git a/bitmap/index.html b/bitmap/index.html index ec54756f..bb406fa8 100644 --- a/bitmap/index.html +++ b/bitmap/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/chip/index.html b/chip/index.html index ec54756f..bb406fa8 100644 --- a/chip/index.html +++ b/chip/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/compiler/index.html b/compiler/index.html index ec54756f..bb406fa8 100644 --- a/compiler/index.html +++ b/compiler/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/cpu/index.html b/cpu/index.html index ec54756f..bb406fa8 100644 --- a/cpu/index.html +++ b/cpu/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/guide/index.html b/guide/index.html index ec54756f..bb406fa8 100644 --- a/guide/index.html +++ b/guide/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/index.html b/index.html index ec54756f..bb406fa8 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -NAND2Tetris
\ No newline at end of file +NAND2Tetris
\ No newline at end of file diff --git a/service-worker.js b/service-worker.js index 425a2e47..84880ab5 100644 --- a/service-worker.js +++ b/service-worker.js @@ -1 +1 @@ -(()=>{"use strict";var e={42:()=>{try{self["workbox:core:6.5.4"]&&_()}catch(e){}},940:()=>{try{self["workbox:expiration:6.5.4"]&&_()}catch(e){}},881:()=>{try{self["workbox:precaching:6.5.4"]&&_()}catch(e){}},661:()=>{try{self["workbox:routing:6.5.4"]&&_()}catch(e){}},772:()=>{try{self["workbox:strategies:6.5.4"]&&_()}catch(e){}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{s(42);const e=(e,...t)=>{let s=e;return t.length>0&&(s+=` :: ${JSON.stringify(t)}`),s};class t extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}const n=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!==typeof registration?registration.scope:""},a=e=>[r.prefix,e,r.suffix].filter((e=>e&&e.length>0)).join("-"),i=e=>e||a(r.precache),o=e=>e||a(r.runtime);function c(e,t){const s=new URL(e);for(const n of t)s.searchParams.delete(n);return s.href}let h;function l(e){e.then((()=>{}))}class u{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}const d=e=>new URL(String(e),location.href).href.replace(new RegExp(`^${location.origin}`),"");function p(e){return new Promise((t=>setTimeout(t,e)))}function f(e,t){const s=t();return e.waitUntil(s),s}async function g(e,s){let n=null;if(e.url){n=new URL(e.url).origin}if(n!==self.location.origin)throw new t("cross-origin-copy-response",{origin:n});const r=e.clone(),a={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},i=s?s(a):a,o=function(){if(void 0===h){const t=new Response("");if("body"in t)try{new Response(t.body),h=!0}catch(e){h=!1}h=!1}return h}()?r.body:await r.blob();return new Response(o,i)}const m=(e,t)=>t.some((t=>e instanceof t));let w,y;const _=new WeakMap,v=new WeakMap,b=new WeakMap,R=new WeakMap,x=new WeakMap;let C={get(e,t,s){if(e instanceof IDBTransaction){if("done"===t)return v.get(e);if("objectStoreNames"===t)return e.objectStoreNames||b.get(e);if("store"===t)return s.objectStoreNames[1]?void 0:s.objectStore(s.objectStoreNames[0])}return q(e[t])},set:(e,t,s)=>(e[t]=s,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function L(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(y||(y=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(U(this),t),q(_.get(this))}:function(...t){return q(e.apply(U(this),t))}:function(t,...s){const n=e.call(U(this),t,...s);return b.set(n,t.sort?t.sort():[t]),q(n)}}function E(e){return"function"===typeof e?L(e):(e instanceof IDBTransaction&&function(e){if(v.has(e))return;const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",a),e.removeEventListener("abort",a)},r=()=>{t(),n()},a=()=>{s(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",r),e.addEventListener("error",a),e.addEventListener("abort",a)}));v.set(e,t)}(e),m(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,C):e)}function q(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("success",r),e.removeEventListener("error",a)},r=()=>{t(q(e.result)),n()},a=()=>{s(e.error),n()};e.addEventListener("success",r),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&_.set(t,e)})).catch((()=>{})),x.set(t,e),t}(e);if(R.has(e))return R.get(e);const t=E(e);return t!==e&&(R.set(e,t),x.set(t,e)),t}const U=e=>x.get(e);const D=["get","getKey","getAll","getAllKeys","count"],k=["put","add","delete","clear"],T=new Map;function N(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!==typeof t)return;if(T.get(t))return T.get(t);const s=t.replace(/FromIndex$/,""),n=t!==s,r=k.includes(s);if(!(s in(n?IDBIndex:IDBObjectStore).prototype)||!r&&!D.includes(s))return;const a=async function(e,...t){const a=this.transaction(e,r?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[s](...t),r&&a.done]))[0]};return T.set(t,a),a}C=(e=>({...e,get:(t,s,n)=>N(t,s)||e.get(t,s,n),has:(t,s)=>!!N(t,s)||e.has(t,s)}))(C);s(940);const I="cache-entries",K=e=>{const t=new URL(e,location.href);return t.hash="",t.href};class M{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(I,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&function(e,{blocked:t}={}){const s=indexedDB.deleteDatabase(e);t&&s.addEventListener("blocked",(e=>t(e.oldVersion,e))),q(s).then((()=>{}))}(this._cacheName)}async setTimestamp(e,t){const s={url:e=K(e),timestamp:t,cacheName:this._cacheName,id:this._getId(e)},n=(await this.getDb()).transaction(I,"readwrite",{durability:"relaxed"});await n.store.put(s),await n.done}async getTimestamp(e){const t=await this.getDb(),s=await t.get(I,this._getId(e));return null===s||void 0===s?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let n=await s.transaction(I).store.index("timestamp").openCursor(null,"prev");const r=[];let a=0;for(;n;){const s=n.value;s.cacheName===this._cacheName&&(e&&s.timestamp=t?r.push(n.value):a++),n=await n.continue()}const i=[];for(const o of r)await s.delete(I,o.id),i.push(o.url);return i}_getId(e){return this._cacheName+"|"+K(e)}async getDb(){return this._db||(this._db=await function(e,t,{blocked:s,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(e,t),o=q(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(q(i.result),e.oldVersion,e.newVersion,q(i.transaction),e)})),s&&i.addEventListener("blocked",(e=>s(e.oldVersion,e.newVersion,e))),o.then((e=>{a&&e.addEventListener("close",(()=>a())),r&&e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("workbox-expiration",1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class P{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new M(e)}async expireEntries(){if(this._isRunning)return void(this._rerunRequested=!0);this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-1e3*this._maxAgeSeconds:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const n of t)await s.delete(n,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,l(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-1e3*this._maxAgeSeconds;return void 0===t||t{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if("install"===e.type&&t&&t.originalRequest&&t.originalRequest instanceof Request){const e=t.originalRequest.url;s?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return s}}}class A{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{const s=(null===t||void 0===t?void 0:t.cacheKey)||this._precacheController.getCacheKeyForURL(e.url);return s?new Request(s,{headers:e.headers}):e},this._precacheController=e}}s(772);function j(e){return"string"===typeof e?new Request(e):e}class B{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new u,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:s}=this;let n=j(e);if("navigate"===n.mode&&s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const e of this.iterateCallbacks("requestWillFetch"))n=await e({request:n.clone(),event:s})}catch(i){if(i instanceof Error)throw new t("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const a=n.clone();try{let e;e=await fetch(n,"navigate"===n.mode?void 0:this._strategy.fetchOptions);for(const t of this.iterateCallbacks("fetchDidSucceed"))e=await t({event:s,request:a,response:e});return e}catch(o){throw r&&await this.runCallbacks("fetchDidFail",{error:o,event:s,originalRequest:r.clone(),request:a.clone()}),o}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=j(e);let s;const{cacheName:n,matchOptions:r}=this._strategy,a=await this.getCacheKey(t,"read"),i=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(a,i);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:n,matchOptions:r,cachedResponse:s,request:a,event:this.event})||void 0;return s}async cachePut(e,s){const r=j(e);await p(0);const a=await this.getCacheKey(r,"write");if(!s)throw new t("cache-put-with-no-response",{url:d(a.url)});const i=await this._ensureResponseSafeToCache(s);if(!i)return!1;const{cacheName:o,matchOptions:h}=this._strategy,l=await self.caches.open(o),u=this.hasCallback("cacheDidUpdate"),f=u?await async function(e,t,s,n){const r=c(t.url,s);if(t.url===r)return e.match(t,n);const a=Object.assign(Object.assign({},n),{ignoreSearch:!0}),i=await e.keys(t,a);for(const o of i)if(r===c(o.url,s))return e.match(o,n)}(l,a.clone(),["__WB_REVISION__"],h):null;try{await l.put(a,u?i.clone():i)}catch(g){if(g instanceof Error)throw"QuotaExceededError"===g.name&&await async function(){for(const e of n)await e()}(),g}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:o,oldResponse:f,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let n=e;for(const e of this.iterateCallbacks("cacheKeyWillBeUsed"))n=j(await e({mode:t,request:n,event:this.event,params:this.params}));this._cacheKeys[s]=n}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if("function"===typeof t[e]){const s=this._pluginStateMap.get(t),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return t[e](r)};yield n}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const n of this.iterateCallbacks("cacheWillUpdate"))if(t=await n({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&200!==t.status&&(t=void 0),t}}class W{constructor(e={}){this.cacheName=o(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s="string"===typeof e.request?new Request(e.request):e.request,n="params"in e?e.params:void 0,r=new B(this,{event:t,request:s,params:n}),a=this._getResponse(r,s,t);return[a,this._awaitComplete(a,r,s,t)]}async _getResponse(e,s,n){let r;await e.runCallbacks("handlerWillStart",{event:n,request:s});try{if(r=await this._handle(s,e),!r||"error"===r.type)throw new t("no-response",{url:s.url})}catch(a){if(a instanceof Error)for(const t of e.iterateCallbacks("handlerDidError"))if(r=await t({error:a,event:n,request:s}),r)break;if(!r)throw a}for(const t of e.iterateCallbacks("handlerWillRespond"))r=await t({event:n,request:s,response:r});return r}async _awaitComplete(e,t,s,n){let r,a;try{r=await e}catch(a){}try{await t.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await t.doneWaiting()}catch(i){i instanceof Error&&(a=i)}if(await t.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:a}),t.destroy(),a)throw a}}class F extends W{constructor(e={}){e.cacheName=i(e.cacheName),super(e),this._fallbackToNetwork=!1!==e.fallbackToNetwork,this.plugins.push(F.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&"install"===t.event.type?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,s){let n;const r=s.params||{};if(!this._fallbackToNetwork)throw new t("missing-precache-entry",{cacheName:this.cacheName,url:e.url});{0;const t=r.integrity,a=e.integrity,i=!a||a===t;if(n=await s.fetch(new Request(e,{integrity:"no-cors"!==e.mode?a||t:void 0})),t&&i&&"no-cors"!==e.mode){this._useDefaultCacheabilityPluginIfNeeded();await s.cachePut(e,n.clone());0}}return n}async _handleInstall(e,s){this._useDefaultCacheabilityPluginIfNeeded();const n=await s.fetch(e);if(!await s.cachePut(e,n.clone()))throw new t("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,n]of this.plugins.entries())n!==F.copyRedirectedCacheableResponsesPlugin&&(n===F.defaultPrecacheCacheabilityPlugin&&(e=s),n.cacheWillUpdate&&t++);0===t?this.plugins.push(F.defaultPrecacheCacheabilityPlugin):t>1&&null!==e&&this.plugins.splice(e,1)}}F.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:e})=>!e||e.status>=400?null:e},F.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:e})=>e.redirected?await g(e):e};class H{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new F({cacheName:i(e),plugins:[...t,new A({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const s=[];for(const n of e){"string"===typeof n?s.push(n):n&&void 0===n.revision&&s.push(n.url);const{cacheKey:e,url:r}=S(n),a="string"!==typeof n&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==e)throw new t("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:e});if("string"!==typeof n&&n.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==n.integrity)throw new t("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(e,n.integrity)}if(this._urlsToCacheKeys.set(r,e),this._urlsToCacheModes.set(r,a),s.length>0){const e=`Workbox is precaching URLs without revision info: ${s.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return f(e,(async()=>{const t=new O;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const t=this._cacheKeysToIntegrities.get(a),s=this._urlsToCacheModes.get(r),n=new Request(r,{integrity:t,cache:s,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:n,event:e}))}const{updatedURLs:s,notUpdatedURLs:n}=t;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(e){return f(e,(async()=>{const e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),s=new Set(this._urlsToCacheKeys.values()),n=[];for(const r of t)s.has(r.url)||(await e.delete(r),n.push(r.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(e){const s=this.getCacheKeyForURL(e);if(!s)throw new t("non-precached-url",{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:s},t.params),this.strategy.handle(t))}}let V;const $=()=>(V||(V=new H),V);s(661);const G=e=>e&&"object"===typeof e?e:{handle:e};class Q{constructor(e,t,s="GET"){this.handler=G(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=G(e)}}class J extends Q{constructor(e,t,s){super((({url:t})=>{const s=e.exec(t.href);if(s&&(t.origin===location.origin||0===s.index))return s.slice(1)}),t,s)}}class Y{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&"CACHE_URLS"===e.data.type){const{payload:t}=e.data;0;const s=Promise.all(t.urlsToCache.map((t=>{"string"===typeof t&&(t=[t]);const s=new Request(...t);return this.handleRequest({request:s,event:e})})));e.waitUntil(s),e.ports&&e.ports[0]&&s.then((()=>e.ports[0].postMessage(!0)))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return void 0;const n=s.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:n,url:s});let i=a&&a.handler;const o=e.method;if(!i&&this._defaultHandlerMap.has(o)&&(i=this._defaultHandlerMap.get(o)),!i)return void 0;let c;try{c=i.handle({url:s,request:e,event:t,params:r})}catch(l){c=Promise.reject(l)}const h=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||h)&&(c=c.catch((async n=>{if(h){0;try{return await h.handle({url:s,request:e,event:t,params:r})}catch(a){a instanceof Error&&(n=a)}}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw n}))),c}findMatchingRoute({url:e,sameOrigin:t,request:s,event:n}){const r=this._routes.get(s.method)||[];for(const a of r){let r;const i=a.match({url:e,sameOrigin:t,request:s,event:n});if(i)return r=i,(Array.isArray(r)&&0===r.length||i.constructor===Object&&0===Object.keys(i).length||"boolean"===typeof i)&&(r=void 0),{route:a,params:r}}return{}}setDefaultHandler(e,t="GET"){this._defaultHandlerMap.set(t,G(e))}setCatchHandler(e){this._catchHandler=G(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t("unregister-route-but-not-found-with-method",{method:e.method});const s=this._routes.get(e.method).indexOf(e);if(!(s>-1))throw new t("unregister-route-route-not-registered");this._routes.get(e.method).splice(s,1)}}let X;const z=()=>(X||(X=new Y,X.addFetchListener(),X.addCacheListener()),X);function Z(e,s,n){let r;if("string"===typeof e){const t=new URL(e,location.href);0;r=new Q((({url:e})=>e.href===t.href),s,n)}else if(e instanceof RegExp)r=new J(e,s,n);else if("function"===typeof e)r=new Q(e,s,n);else{if(!(e instanceof Q))throw new t("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});r=e}return z().registerRoute(r),r}class ee extends Q{constructor(e,t){super((({request:s})=>{const n=e.getURLsToCacheKeys();for(const r of function*(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const a=new URL(e,location.href);a.hash="",yield a.href;const i=function(e,t=[]){for(const s of[...e.searchParams.keys()])t.some((e=>e.test(s)))&&e.searchParams.delete(s);return e}(a,t);if(yield i.href,s&&i.pathname.endsWith("/")){const e=new URL(i.href);e.pathname+=s,yield e.href}if(n){const e=new URL(i.href);e.pathname+=".html",yield e.href}if(r){const e=r({url:a});for(const t of e)yield t.href}}(s.url,t)){const t=n.get(r);if(t){return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}}}),e.strategy)}}const te={cacheWillUpdate:async({response:e})=>200===e.status||0===e.status?e:null};var se;self.addEventListener("activate",(()=>self.clients.claim())),function(e){$().precache(e)}([...[{'revision':'c172799a7865f5b388216f777b57ae70','url':'/web-ide/index.html'},{'revision':null,'url':'/web-ide/static/css/19.cdc27113.chunk.css'},{'revision':null,'url':'/web-ide/static/css/408.4548b55f.chunk.css'},{'revision':null,'url':'/web-ide/static/css/447.5a5c5941.chunk.css'},{'revision':null,'url':'/web-ide/static/css/535.a8c1f171.chunk.css'},{'revision':null,'url':'/web-ide/static/css/71.8f63efb7.chunk.css'},{'revision':null,'url':'/web-ide/static/css/840.f76be948.chunk.css'},{'revision':null,'url':'/web-ide/static/css/911.afb55690.chunk.css'},{'revision':null,'url':'/web-ide/static/css/main.9acd77f6.css'},{'revision':null,'url':'/web-ide/static/js/19.41e234a9.chunk.js'},{'revision':null,'url':'/web-ide/static/js/200.79ef4b82.chunk.js'},{'revision':null,'url':'/web-ide/static/js/233.880b3b5e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/269.1e46835e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/288.9fdaec0d.chunk.js'},{'revision':null,'url':'/web-ide/static/js/297.2c45dab0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/323.14a08baf.chunk.js'},{'revision':null,'url':'/web-ide/static/js/408.a13c70a8.chunk.js'},{'revision':null,'url':'/web-ide/static/js/447.98604c94.chunk.js'},{'revision':null,'url':'/web-ide/static/js/535.74ad7816.chunk.js'},{'revision':null,'url':'/web-ide/static/js/548.ba61af54.chunk.js'},{'revision':null,'url':'/web-ide/static/js/578.b9f22ec3.chunk.js'},{'revision':null,'url':'/web-ide/static/js/608.6d63ee31.chunk.js'},{'revision':null,'url':'/web-ide/static/js/614.12dbb7c0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/656.c1a30912.chunk.js'},{'revision':null,'url':'/web-ide/static/js/700.b4462144.chunk.js'},{'revision':null,'url':'/web-ide/static/js/71.c99ce94e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/828.e00c10f6.chunk.js'},{'revision':null,'url':'/web-ide/static/js/840.ca28c6ce.chunk.js'},{'revision':null,'url':'/web-ide/static/js/911.5accc151.chunk.js'},{'revision':null,'url':'/web-ide/static/js/965.0b77a136.chunk.js'},{'revision':null,'url':'/web-ide/static/js/983.998a7064.chunk.js'},{'revision':null,'url':'/web-ide/static/js/main.9fb233e1.js'}],{url:"/web-ide/root.css",revision:null},{url:"/web-ide/pico.min.css",revision:null},{url:"/web-ide/poppins_400.ttf",revision:null},{url:"/web-ide/poppins_700.ttf",revision:null},{url:"/web-ide/jet_brains_mono.ttf",revision:null},{url:"/web-ide/manifest.json",revision:null},{url:"/web-ide/favicon.svg",revision:null},{url:"/web-ide/logo_192.png",revision:null},{url:"/web-ide/logo_512.png",revision:null},{url:"https://fonts.gstatic.com/s/materialsymbolsoutlined/v179/kJEhBvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oFsLjBuVY.woff2",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/loader.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.css",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.nls.js",revision:null},{url:"user_guide/chip.pdf",revision:null},{url:"user_guide/cpu.pdf",revision:null},{url:"user_guide/asm.pdf",revision:null},{url:"user_guide/vm.pdf",revision:null},{url:"user_guide/compiler.pdf",revision:null}]),function(e){const t=$();Z(new ee(t,e))}(se);const ne=new RegExp("/[^/?]+\\.[^/]+$");var re;Z((({request:e,url:t})=>"navigate"===e.mode&&(!t.pathname.startsWith("/_")&&!t.pathname.match(ne))),(re="/web-ide/index.html",$().createHandlerBoundToURL(re))),Z((({url:e})=>e.origin===self.location.origin&&e.pathname.endsWith(".png")),new class extends W{constructor(e={}){super(e),this.plugins.some((e=>"cacheWillUpdate"in e))||this.plugins.unshift(te)}async _handle(e,s){const n=s.fetchAndCachePut(e).catch((()=>{}));s.waitUntil(n);let r,a=await s.cacheMatch(e);if(a)0;else{0;try{a=await n}catch(i){i instanceof Error&&(r=i)}}if(!a)throw new t("no-response",{url:e.url,error:r});return a}}({cacheName:"images",plugins:[new class{constructor(e={}){this.cachedResponseWillBeUsed=async({event:e,request:t,cacheName:s,cachedResponse:n})=>{if(!n)return null;const r=this._isResponseDateFresh(n),a=this._getCacheExpiration(s);l(a.expireEntries());const i=a.updateTimestamp(t.url);if(e)try{e.waitUntil(i)}catch(o){0}return r?n:null},this.cacheDidUpdate=async({cacheName:e,request:t})=>{const s=this._getCacheExpiration(e);await s.updateTimestamp(t.url),await s.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&function(e){n.add(e)}((()=>this.deleteCacheAndMetadata()))}_getCacheExpiration(e){if(e===o())throw new t("expire-custom-caches-only");let s=this._cacheExpirations.get(e);return s||(s=new P(e,this._config),this._cacheExpirations.set(e,s)),s}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(null===t)return!0;return t>=Date.now()-1e3*this._maxAgeSeconds}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),s=new Date(t).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}({maxEntries:50})]})),self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}))})()})(); \ No newline at end of file +(()=>{"use strict";var e={42:()=>{try{self["workbox:core:6.5.4"]&&_()}catch(e){}},940:()=>{try{self["workbox:expiration:6.5.4"]&&_()}catch(e){}},881:()=>{try{self["workbox:precaching:6.5.4"]&&_()}catch(e){}},661:()=>{try{self["workbox:routing:6.5.4"]&&_()}catch(e){}},772:()=>{try{self["workbox:strategies:6.5.4"]&&_()}catch(e){}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(()=>{s(42);const e=(e,...t)=>{let s=e;return t.length>0&&(s+=` :: ${JSON.stringify(t)}`),s};class t extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}const n=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!==typeof registration?registration.scope:""},a=e=>[r.prefix,e,r.suffix].filter((e=>e&&e.length>0)).join("-"),i=e=>e||a(r.precache),o=e=>e||a(r.runtime);function c(e,t){const s=new URL(e);for(const n of t)s.searchParams.delete(n);return s.href}let h;function l(e){e.then((()=>{}))}class u{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}const d=e=>new URL(String(e),location.href).href.replace(new RegExp(`^${location.origin}`),"");function p(e){return new Promise((t=>setTimeout(t,e)))}function f(e,t){const s=t();return e.waitUntil(s),s}async function g(e,s){let n=null;if(e.url){n=new URL(e.url).origin}if(n!==self.location.origin)throw new t("cross-origin-copy-response",{origin:n});const r=e.clone(),a={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},i=s?s(a):a,o=function(){if(void 0===h){const t=new Response("");if("body"in t)try{new Response(t.body),h=!0}catch(e){h=!1}h=!1}return h}()?r.body:await r.blob();return new Response(o,i)}const m=(e,t)=>t.some((t=>e instanceof t));let w,y;const _=new WeakMap,v=new WeakMap,b=new WeakMap,R=new WeakMap,x=new WeakMap;let C={get(e,t,s){if(e instanceof IDBTransaction){if("done"===t)return v.get(e);if("objectStoreNames"===t)return e.objectStoreNames||b.get(e);if("store"===t)return s.objectStoreNames[1]?void 0:s.objectStore(s.objectStoreNames[0])}return q(e[t])},set:(e,t,s)=>(e[t]=s,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function L(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(y||(y=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(U(this),t),q(_.get(this))}:function(...t){return q(e.apply(U(this),t))}:function(t,...s){const n=e.call(U(this),t,...s);return b.set(n,t.sort?t.sort():[t]),q(n)}}function E(e){return"function"===typeof e?L(e):(e instanceof IDBTransaction&&function(e){if(v.has(e))return;const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",a),e.removeEventListener("abort",a)},r=()=>{t(),n()},a=()=>{s(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",r),e.addEventListener("error",a),e.addEventListener("abort",a)}));v.set(e,t)}(e),m(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,C):e)}function q(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,s)=>{const n=()=>{e.removeEventListener("success",r),e.removeEventListener("error",a)},r=()=>{t(q(e.result)),n()},a=()=>{s(e.error),n()};e.addEventListener("success",r),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&_.set(t,e)})).catch((()=>{})),x.set(t,e),t}(e);if(R.has(e))return R.get(e);const t=E(e);return t!==e&&(R.set(e,t),x.set(t,e)),t}const U=e=>x.get(e);const D=["get","getKey","getAll","getAllKeys","count"],k=["put","add","delete","clear"],T=new Map;function N(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!==typeof t)return;if(T.get(t))return T.get(t);const s=t.replace(/FromIndex$/,""),n=t!==s,r=k.includes(s);if(!(s in(n?IDBIndex:IDBObjectStore).prototype)||!r&&!D.includes(s))return;const a=async function(e,...t){const a=this.transaction(e,r?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[s](...t),r&&a.done]))[0]};return T.set(t,a),a}C=(e=>({...e,get:(t,s,n)=>N(t,s)||e.get(t,s,n),has:(t,s)=>!!N(t,s)||e.has(t,s)}))(C);s(940);const I="cache-entries",K=e=>{const t=new URL(e,location.href);return t.hash="",t.href};class M{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(I,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&function(e,{blocked:t}={}){const s=indexedDB.deleteDatabase(e);t&&s.addEventListener("blocked",(e=>t(e.oldVersion,e))),q(s).then((()=>{}))}(this._cacheName)}async setTimestamp(e,t){const s={url:e=K(e),timestamp:t,cacheName:this._cacheName,id:this._getId(e)},n=(await this.getDb()).transaction(I,"readwrite",{durability:"relaxed"});await n.store.put(s),await n.done}async getTimestamp(e){const t=await this.getDb(),s=await t.get(I,this._getId(e));return null===s||void 0===s?void 0:s.timestamp}async expireEntries(e,t){const s=await this.getDb();let n=await s.transaction(I).store.index("timestamp").openCursor(null,"prev");const r=[];let a=0;for(;n;){const s=n.value;s.cacheName===this._cacheName&&(e&&s.timestamp=t?r.push(n.value):a++),n=await n.continue()}const i=[];for(const o of r)await s.delete(I,o.id),i.push(o.url);return i}_getId(e){return this._cacheName+"|"+K(e)}async getDb(){return this._db||(this._db=await function(e,t,{blocked:s,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(e,t),o=q(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(q(i.result),e.oldVersion,e.newVersion,q(i.transaction),e)})),s&&i.addEventListener("blocked",(e=>s(e.oldVersion,e.newVersion,e))),o.then((e=>{a&&e.addEventListener("close",(()=>a())),r&&e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("workbox-expiration",1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class P{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new M(e)}async expireEntries(){if(this._isRunning)return void(this._rerunRequested=!0);this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-1e3*this._maxAgeSeconds:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),s=await self.caches.open(this._cacheName);for(const n of t)await s.delete(n,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,l(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),s=Date.now()-1e3*this._maxAgeSeconds;return void 0===t||t{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if("install"===e.type&&t&&t.originalRequest&&t.originalRequest instanceof Request){const e=t.originalRequest.url;s?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return s}}}class A{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{const s=(null===t||void 0===t?void 0:t.cacheKey)||this._precacheController.getCacheKeyForURL(e.url);return s?new Request(s,{headers:e.headers}):e},this._precacheController=e}}s(772);function j(e){return"string"===typeof e?new Request(e):e}class B{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new u,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:s}=this;let n=j(e);if("navigate"===n.mode&&s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const e of this.iterateCallbacks("requestWillFetch"))n=await e({request:n.clone(),event:s})}catch(i){if(i instanceof Error)throw new t("plugin-error-request-will-fetch",{thrownErrorMessage:i.message})}const a=n.clone();try{let e;e=await fetch(n,"navigate"===n.mode?void 0:this._strategy.fetchOptions);for(const t of this.iterateCallbacks("fetchDidSucceed"))e=await t({event:s,request:a,response:e});return e}catch(o){throw r&&await this.runCallbacks("fetchDidFail",{error:o,event:s,originalRequest:r.clone(),request:a.clone()}),o}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=j(e);let s;const{cacheName:n,matchOptions:r}=this._strategy,a=await this.getCacheKey(t,"read"),i=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(a,i);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:n,matchOptions:r,cachedResponse:s,request:a,event:this.event})||void 0;return s}async cachePut(e,s){const r=j(e);await p(0);const a=await this.getCacheKey(r,"write");if(!s)throw new t("cache-put-with-no-response",{url:d(a.url)});const i=await this._ensureResponseSafeToCache(s);if(!i)return!1;const{cacheName:o,matchOptions:h}=this._strategy,l=await self.caches.open(o),u=this.hasCallback("cacheDidUpdate"),f=u?await async function(e,t,s,n){const r=c(t.url,s);if(t.url===r)return e.match(t,n);const a=Object.assign(Object.assign({},n),{ignoreSearch:!0}),i=await e.keys(t,a);for(const o of i)if(r===c(o.url,s))return e.match(o,n)}(l,a.clone(),["__WB_REVISION__"],h):null;try{await l.put(a,u?i.clone():i)}catch(g){if(g instanceof Error)throw"QuotaExceededError"===g.name&&await async function(){for(const e of n)await e()}(),g}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:o,oldResponse:f,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let n=e;for(const e of this.iterateCallbacks("cacheKeyWillBeUsed"))n=j(await e({mode:t,request:n,event:this.event,params:this.params}));this._cacheKeys[s]=n}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if("function"===typeof t[e]){const s=this._pluginStateMap.get(t),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return t[e](r)};yield n}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const n of this.iterateCallbacks("cacheWillUpdate"))if(t=await n({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&200!==t.status&&(t=void 0),t}}class W{constructor(e={}){this.cacheName=o(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s="string"===typeof e.request?new Request(e.request):e.request,n="params"in e?e.params:void 0,r=new B(this,{event:t,request:s,params:n}),a=this._getResponse(r,s,t);return[a,this._awaitComplete(a,r,s,t)]}async _getResponse(e,s,n){let r;await e.runCallbacks("handlerWillStart",{event:n,request:s});try{if(r=await this._handle(s,e),!r||"error"===r.type)throw new t("no-response",{url:s.url})}catch(a){if(a instanceof Error)for(const t of e.iterateCallbacks("handlerDidError"))if(r=await t({error:a,event:n,request:s}),r)break;if(!r)throw a}for(const t of e.iterateCallbacks("handlerWillRespond"))r=await t({event:n,request:s,response:r});return r}async _awaitComplete(e,t,s,n){let r,a;try{r=await e}catch(a){}try{await t.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await t.doneWaiting()}catch(i){i instanceof Error&&(a=i)}if(await t.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:a}),t.destroy(),a)throw a}}class F extends W{constructor(e={}){e.cacheName=i(e.cacheName),super(e),this._fallbackToNetwork=!1!==e.fallbackToNetwork,this.plugins.push(F.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&"install"===t.event.type?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,s){let n;const r=s.params||{};if(!this._fallbackToNetwork)throw new t("missing-precache-entry",{cacheName:this.cacheName,url:e.url});{0;const t=r.integrity,a=e.integrity,i=!a||a===t;if(n=await s.fetch(new Request(e,{integrity:"no-cors"!==e.mode?a||t:void 0})),t&&i&&"no-cors"!==e.mode){this._useDefaultCacheabilityPluginIfNeeded();await s.cachePut(e,n.clone());0}}return n}async _handleInstall(e,s){this._useDefaultCacheabilityPluginIfNeeded();const n=await s.fetch(e);if(!await s.cachePut(e,n.clone()))throw new t("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,n]of this.plugins.entries())n!==F.copyRedirectedCacheableResponsesPlugin&&(n===F.defaultPrecacheCacheabilityPlugin&&(e=s),n.cacheWillUpdate&&t++);0===t?this.plugins.push(F.defaultPrecacheCacheabilityPlugin):t>1&&null!==e&&this.plugins.splice(e,1)}}F.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:e})=>!e||e.status>=400?null:e},F.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:e})=>e.redirected?await g(e):e};class H{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new F({cacheName:i(e),plugins:[...t,new A({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const s=[];for(const n of e){"string"===typeof n?s.push(n):n&&void 0===n.revision&&s.push(n.url);const{cacheKey:e,url:r}=S(n),a="string"!==typeof n&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==e)throw new t("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:e});if("string"!==typeof n&&n.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==n.integrity)throw new t("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(e,n.integrity)}if(this._urlsToCacheKeys.set(r,e),this._urlsToCacheModes.set(r,a),s.length>0){const e=`Workbox is precaching URLs without revision info: ${s.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return f(e,(async()=>{const t=new O;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const t=this._cacheKeysToIntegrities.get(a),s=this._urlsToCacheModes.get(r),n=new Request(r,{integrity:t,cache:s,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:n,event:e}))}const{updatedURLs:s,notUpdatedURLs:n}=t;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(e){return f(e,(async()=>{const e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),s=new Set(this._urlsToCacheKeys.values()),n=[];for(const r of t)s.has(r.url)||(await e.delete(r),n.push(r.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(e){const s=this.getCacheKeyForURL(e);if(!s)throw new t("non-precached-url",{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:s},t.params),this.strategy.handle(t))}}let V;const $=()=>(V||(V=new H),V);s(661);const G=e=>e&&"object"===typeof e?e:{handle:e};class Q{constructor(e,t,s="GET"){this.handler=G(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=G(e)}}class J extends Q{constructor(e,t,s){super((({url:t})=>{const s=e.exec(t.href);if(s&&(t.origin===location.origin||0===s.index))return s.slice(1)}),t,s)}}class Y{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&"CACHE_URLS"===e.data.type){const{payload:t}=e.data;0;const s=Promise.all(t.urlsToCache.map((t=>{"string"===typeof t&&(t=[t]);const s=new Request(...t);return this.handleRequest({request:s,event:e})})));e.waitUntil(s),e.ports&&e.ports[0]&&s.then((()=>e.ports[0].postMessage(!0)))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return void 0;const n=s.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:n,url:s});let i=a&&a.handler;const o=e.method;if(!i&&this._defaultHandlerMap.has(o)&&(i=this._defaultHandlerMap.get(o)),!i)return void 0;let c;try{c=i.handle({url:s,request:e,event:t,params:r})}catch(l){c=Promise.reject(l)}const h=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||h)&&(c=c.catch((async n=>{if(h){0;try{return await h.handle({url:s,request:e,event:t,params:r})}catch(a){a instanceof Error&&(n=a)}}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw n}))),c}findMatchingRoute({url:e,sameOrigin:t,request:s,event:n}){const r=this._routes.get(s.method)||[];for(const a of r){let r;const i=a.match({url:e,sameOrigin:t,request:s,event:n});if(i)return r=i,(Array.isArray(r)&&0===r.length||i.constructor===Object&&0===Object.keys(i).length||"boolean"===typeof i)&&(r=void 0),{route:a,params:r}}return{}}setDefaultHandler(e,t="GET"){this._defaultHandlerMap.set(t,G(e))}setCatchHandler(e){this._catchHandler=G(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t("unregister-route-but-not-found-with-method",{method:e.method});const s=this._routes.get(e.method).indexOf(e);if(!(s>-1))throw new t("unregister-route-route-not-registered");this._routes.get(e.method).splice(s,1)}}let X;const z=()=>(X||(X=new Y,X.addFetchListener(),X.addCacheListener()),X);function Z(e,s,n){let r;if("string"===typeof e){const t=new URL(e,location.href);0;r=new Q((({url:e})=>e.href===t.href),s,n)}else if(e instanceof RegExp)r=new J(e,s,n);else if("function"===typeof e)r=new Q(e,s,n);else{if(!(e instanceof Q))throw new t("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});r=e}return z().registerRoute(r),r}class ee extends Q{constructor(e,t){super((({request:s})=>{const n=e.getURLsToCacheKeys();for(const r of function*(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const a=new URL(e,location.href);a.hash="",yield a.href;const i=function(e,t=[]){for(const s of[...e.searchParams.keys()])t.some((e=>e.test(s)))&&e.searchParams.delete(s);return e}(a,t);if(yield i.href,s&&i.pathname.endsWith("/")){const e=new URL(i.href);e.pathname+=s,yield e.href}if(n){const e=new URL(i.href);e.pathname+=".html",yield e.href}if(r){const e=r({url:a});for(const t of e)yield t.href}}(s.url,t)){const t=n.get(r);if(t){return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}}}),e.strategy)}}const te={cacheWillUpdate:async({response:e})=>200===e.status||0===e.status?e:null};var se;self.addEventListener("activate",(()=>self.clients.claim())),function(e){$().precache(e)}([...[{'revision':'246c60f4cd95f90176f3f03fcd8205e9','url':'/web-ide/index.html'},{'revision':null,'url':'/web-ide/static/css/19.cdc27113.chunk.css'},{'revision':null,'url':'/web-ide/static/css/408.4548b55f.chunk.css'},{'revision':null,'url':'/web-ide/static/css/447.5a5c5941.chunk.css'},{'revision':null,'url':'/web-ide/static/css/535.a8c1f171.chunk.css'},{'revision':null,'url':'/web-ide/static/css/71.8f63efb7.chunk.css'},{'revision':null,'url':'/web-ide/static/css/840.f76be948.chunk.css'},{'revision':null,'url':'/web-ide/static/css/911.afb55690.chunk.css'},{'revision':null,'url':'/web-ide/static/css/main.9acd77f6.css'},{'revision':null,'url':'/web-ide/static/js/19.41e234a9.chunk.js'},{'revision':null,'url':'/web-ide/static/js/200.33bb522e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/233.880b3b5e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/269.1e46835e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/288.9fdaec0d.chunk.js'},{'revision':null,'url':'/web-ide/static/js/297.2c45dab0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/323.14a08baf.chunk.js'},{'revision':null,'url':'/web-ide/static/js/408.a13c70a8.chunk.js'},{'revision':null,'url':'/web-ide/static/js/447.98604c94.chunk.js'},{'revision':null,'url':'/web-ide/static/js/535.74ad7816.chunk.js'},{'revision':null,'url':'/web-ide/static/js/548.ba61af54.chunk.js'},{'revision':null,'url':'/web-ide/static/js/578.b9f22ec3.chunk.js'},{'revision':null,'url':'/web-ide/static/js/608.6d63ee31.chunk.js'},{'revision':null,'url':'/web-ide/static/js/614.12dbb7c0.chunk.js'},{'revision':null,'url':'/web-ide/static/js/656.c1a30912.chunk.js'},{'revision':null,'url':'/web-ide/static/js/700.b4462144.chunk.js'},{'revision':null,'url':'/web-ide/static/js/71.c99ce94e.chunk.js'},{'revision':null,'url':'/web-ide/static/js/828.e00c10f6.chunk.js'},{'revision':null,'url':'/web-ide/static/js/840.ca28c6ce.chunk.js'},{'revision':null,'url':'/web-ide/static/js/911.5accc151.chunk.js'},{'revision':null,'url':'/web-ide/static/js/965.0b77a136.chunk.js'},{'revision':null,'url':'/web-ide/static/js/983.998a7064.chunk.js'},{'revision':null,'url':'/web-ide/static/js/main.64a1b230.js'}],{url:"/web-ide/root.css",revision:null},{url:"/web-ide/pico.min.css",revision:null},{url:"/web-ide/poppins_400.ttf",revision:null},{url:"/web-ide/poppins_700.ttf",revision:null},{url:"/web-ide/jet_brains_mono.ttf",revision:null},{url:"/web-ide/manifest.json",revision:null},{url:"/web-ide/favicon.svg",revision:null},{url:"/web-ide/logo_192.png",revision:null},{url:"/web-ide/logo_512.png",revision:null},{url:"https://fonts.gstatic.com/s/materialsymbolsoutlined/v179/kJEhBvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oFsLjBuVY.woff2",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/loader.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.js",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.css",revision:null},{url:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.nls.js",revision:null},{url:"user_guide/chip.pdf",revision:null},{url:"user_guide/cpu.pdf",revision:null},{url:"user_guide/asm.pdf",revision:null},{url:"user_guide/vm.pdf",revision:null},{url:"user_guide/compiler.pdf",revision:null}]),function(e){const t=$();Z(new ee(t,e))}(se);const ne=new RegExp("/[^/?]+\\.[^/]+$");var re;Z((({request:e,url:t})=>"navigate"===e.mode&&(!t.pathname.startsWith("/_")&&!t.pathname.match(ne))),(re="/web-ide/index.html",$().createHandlerBoundToURL(re))),Z((({url:e})=>e.origin===self.location.origin&&e.pathname.endsWith(".png")),new class extends W{constructor(e={}){super(e),this.plugins.some((e=>"cacheWillUpdate"in e))||this.plugins.unshift(te)}async _handle(e,s){const n=s.fetchAndCachePut(e).catch((()=>{}));s.waitUntil(n);let r,a=await s.cacheMatch(e);if(a)0;else{0;try{a=await n}catch(i){i instanceof Error&&(r=i)}}if(!a)throw new t("no-response",{url:e.url,error:r});return a}}({cacheName:"images",plugins:[new class{constructor(e={}){this.cachedResponseWillBeUsed=async({event:e,request:t,cacheName:s,cachedResponse:n})=>{if(!n)return null;const r=this._isResponseDateFresh(n),a=this._getCacheExpiration(s);l(a.expireEntries());const i=a.updateTimestamp(t.url);if(e)try{e.waitUntil(i)}catch(o){0}return r?n:null},this.cacheDidUpdate=async({cacheName:e,request:t})=>{const s=this._getCacheExpiration(e);await s.updateTimestamp(t.url),await s.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&function(e){n.add(e)}((()=>this.deleteCacheAndMetadata()))}_getCacheExpiration(e){if(e===o())throw new t("expire-custom-caches-only");let s=this._cacheExpirations.get(e);return s||(s=new P(e,this._config),this._cacheExpirations.set(e,s)),s}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(null===t)return!0;return t>=Date.now()-1e3*this._maxAgeSeconds}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),s=new Date(t).getTime();return isNaN(s)?null:s}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}({maxEntries:50})]})),self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}))})()})(); \ No newline at end of file diff --git a/static/js/200.33bb522e.chunk.js b/static/js/200.33bb522e.chunk.js new file mode 100644 index 00000000..f2d7c979 --- /dev/null +++ b/static/js/200.33bb522e.chunk.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[200],{1384:(t,e,s)=>{s.d(e,{o:()=>r,w:()=>o});var n=s(8878),i=s(782);const r=t=>{const e=(0,n.useId)(),s=`tab-${e}`,r=`panel-${e}`;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{role:"tab",id:s,"aria-controls":r,style:t.style,children:(0,i.jsxs)("label",{children:[t.title,(0,i.jsx)("input",{type:"radio",name:t.parent,"aria-controls":r,value:s,checked:t.checked,onChange:e=>{var s;return 1==e.target.checked&&(null===(s=t.onSelect)||void 0===s?void 0:s.call(t))}})]})}),(0,i.jsx)("div",{role:"tabpanel",id:r,"aria-labelledby":s,children:t.children})]})},o=t=>{var e,s,r,o;const a=(0,n.useId)(),[c,h]=(0,n.useState)(0),l=null!==(e=null===(s=t.tabIndex)||void 0===s?void 0:s.value)&&void 0!==e?e:c,u=null!==(r=null===(o=t.tabIndex)||void 0===o?void 0:o.set)&&void 0!==r?r:h;return(0,i.jsx)("section",{role:"tablist",style:{"--tab-count":t.children.length},children:n.Children.map(t.children,((t,e)=>(0,n.cloneElement)(t,{checked:e===l,parent:a,idx:e,onSelect:()=>{var s,n;u(e),null===(s=t.props)||void 0===s||null===(n=s.onSelect)||void 0===n||n.call(s)}})))})}},9267:(t,e,s)=>{s.d(e,{B:()=>x});var n=s(6458),i=s(5874),r=s(7365),o=s(1296),a=s(8177),c=s(7022),h=s(910),l=s(7589),u=s(6554),d=s(1091),p=s(8878),m=s(8029),f=s(3508),g=s(2675),y=s(4280),b=s(1384),v=s(782);const S="skipTestEditWarning",x=({runner:t,tst:[e,s,x],cmp:[A,C],out:[k],tstName:I,setPath:_,disabled:L=!1,defaultTst:O,defaultCmp:T,showName:R=!1,showLoad:E=!0,showClear:M=!1,onSpeedChange:N,prefix:F})=>{var P,j;const{fs:$,setStatus:D}=(0,p.useContext)(h.L),{filePicker:V,tracking:G}=(0,p.useContext)(m.BR),[H,z]=(0,p.useState)(!0),B=(0,p.useRef)();(0,p.useEffect)((()=>(B.current=new class extends d.M{async reset(){var e;await(null===(e=t.current)||void 0===e?void 0:e.reset()),z(!0)}finishFrame(){var e;super.finishFrame(),null===(e=t.current)||void 0===e||e.finishFrame()}async tick(){var e,s;return z(!0),null!==(e=await(null===(s=t.current)||void 0===s?void 0:s.tick()))&&void 0!==e&&e}toggle(){var e;null===(e=t.current)||void 0===e||e.toggle()}},()=>{var t;null===(t=B.current)||void 0===t||t.stop()})),[t]);const U=(0,p.useCallback)((t=>{G.trackEvent("tab","change",t)}),[G]),[X,K]=(0,p.useState)(!1),[W,q]=(0,p.useState)(!1),[Y,Z]=(0,p.useState)(""),[J,Q]=(0,p.useState)(""),tt=(0,f.s)(),[et,st]=(0,a.b)(null!==I&&void 0!==I?I:""),nt=(0,p.useCallback)((async()=>{var t;const e=await V.select({suffix:".tst"}),n=await(0,o.g)($,e);if((0,i.ys)(n))return void D("Failed to load test");null===_||void 0===_||_(e),st(null!==(t=e.split("/").pop())&&void 0!==t?t:"");const{tst:r,cmp:a}=(0,i.oA)(n);null===s||void 0===s||s(r),null===C||void 0===C||C(null!==a&&void 0!==a?a:"")}),[V,D,$]),[it,rt]=(0,p.useState)();(0,p.useEffect)((()=>{rt((0,r._)(A,k))}),[k,A]);const ot=(0,v.jsx)("dialog",{open:tt.isOpen,children:(0,v.jsxs)("article",{children:[(0,v.jsx)("header",{children:"Warning"}),(0,v.jsxs)("main",{children:[(0,v.jsxs)("p",{children:["The test script can be edited during this IDE session. In the next session, the original script will be restored.",(0,v.jsx)("br",{})]}),(0,v.jsxs)("div",{style:{display:"flex",flexDirection:"row"},children:[(0,v.jsx)("input",{type:"checkbox",checked:W,onChange:t=>{q(t.target.checked)}}),(0,v.jsx)("p",{children:"Do not show this again"})]}),(0,v.jsx)("p",{children:(0,v.jsx)("br",{})}),(0,v.jsx)("button",{onClick:()=>{W&&localStorage.setItem(S,"true"),tt.close()},children:"Ok"})]})]})});return(0,v.jsx)(y.Z,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{children:[(0,v.jsx)(n.x6,{id:"NnH3pK"}),R&&(""==et?": Default":`: ${et}`)]}),ot,(0,v.jsx)("div",{className:"flex-1",children:B.current&&(0,v.jsx)(c.T,{prefix:(0,v.jsxs)(v.Fragment,{children:[F,M&&(0,v.jsx)("button",{className:"flex-0",onClick:()=>{s(null!==O&&void 0!==O?O:""),C(null!==T&&void 0!==T?T:"")},children:"Clear"}),X?(0,v.jsx)("button",{className:"flex-0",onClick:()=>{K(!1),s(Y),C(J)},children:"Restore"}):(0,v.jsx)("button",{className:"flex-0",onClick:()=>{localStorage.getItem(S)||tt.open(),K(!0),Z(e),Q(A)},children:"Edit"}),E&&(0,v.jsx)("button",{className:"flex-0",onClick:nt,"data-tooltip":"Load a test script","data-placement":"bottom",children:"\ud83d\udcc2"})]}),runner:B.current,disabled:L,onSpeedChange:N})})]}),children:(0,v.jsxs)(b.w,{children:[(0,v.jsx)(b.o,{title:"Test Script",onSelect:()=>U("tst"),children:(0,v.jsx)(g.K,{value:e,onChange:t=>{s(t),z(!1)},grammar:u.uG.parser,language:"tst",disabled:!X,highlight:H?x:void 0})}),(0,v.jsx)(b.o,{title:"Compare File",onSelect:()=>U("cmp"),children:(0,v.jsx)(g.K,{value:A,onChange:C,grammar:l.dl.parser,language:"cmp",lineNumberTransform:t=>"",disabled:!X})}),(0,v.jsxs)(b.o,{title:"Output File",onSelect:()=>U("out"),children:[""==k&&(0,v.jsx)("p",{children:"Execute test script to generate output."}),(0,v.jsx)(g.K,{value:k,onChange:()=>{},language:"cmp",disabled:!0,lineNumberTransform:t=>""})]}),(0,v.jsxs)(b.o,{title:"Diff Table",onSelect:()=>U("diff"),children:[""==k&&(0,v.jsx)("p",{children:"Execute test script to compare output."}),(null!==(P=null===it||void 0===it?void 0:it.failureNum)&&void 0!==P?P:0)>0&&(0,v.jsxs)("p",{children:[null===it||void 0===it?void 0:it.failureNum," comparison failure",1===(null===it||void 0===it?void 0:it.failureNum)?"":"s",". Scroll down for details"]}),(0,v.jsx)(g.K,{value:null!==(j=null===it||void 0===it?void 0:it.text)&&void 0!==j?j:"",onChange:()=>{},language:"",disabled:!0,lineNumberTransform:t=>{var e;return null!==(e=null===it||void 0===it?void 0:it.lineNumbers[t-1])&&void 0!==e?e:""},customDecorations:null===it||void 0===it?void 0:it.decorations.map((t=>({span:t.span,cssClass:w(t.type)})))})]})]})})};function w(t){switch(t){case"error-line":return"diff-highlight-line-1";case"error-cell":return"diff-highlight-cell-1";case"correct-line":return"diff-highlight-line-2";case"correct-cell":return"diff-highlight-cell-2";default:return""}}},7437:(t,e,s)=>{s.d(e,{s:()=>c});var n=s(782),i=s(8878),r=s(6537);const o={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152},a={ArrowLeft:"L-arrow",ArrowUp:"U-arrow",ArrowRight:"R-arrow",ArrowDown:"D-arrow"};const c=({keyboard:t,update:e})=>{const[s,c]=(0,i.useState)(!1),[h,l]=(0,i.useState)(""),[u,d]=(0,i.useState)(t.getKey());let p=0;const m=(0,i.useRef)(null),f=t=>{if(!s)return;l(function(t){return a[t]??t}(t.key)),m.current?.blur();const n=function(t){const e=o[t.key];if(void 0!==e)return e;if(1===t.key.length){const e=t.key.charCodeAt(0);if(e>=32&&e<=126)return e}return 0}(t);n&&t.preventDefault(),n!==p&&(y(n),e?.())},g=n=>{m.current?.blur(),s&&(t.getKey()&&n.preventDefault(),p=0,t.clearKey(),e?.(),d(t.getKey()),l(""))},y=e=>{0!==e&&(t.setKey(e),d(t.getKey()),p=e)};return(0,i.useEffect)((()=>(window.addEventListener("keydown",f),window.addEventListener("keyup",g),()=>{window.removeEventListener("keydown",f),window.removeEventListener("keyup",g)}))),(0,n.jsx)("article",{className:"panel",children:(0,n.jsxs)("div",{className:"flex row align-baseline",children:[(0,n.jsx)("button",{onClick:()=>{c(!s)},ref:m,className:"flex-0",style:{whiteSpace:"pre"},children:(s?"Disable":"Enable")+" Keyboard"}),(0,n.jsx)("div",{className:"flex-1"})," ",(0,n.jsxs)("div",{className:"flex-4",children:["Key: ",h]}),(0,n.jsx)("div",{className:"flex-4",children:(0,n.jsx)(r.d,{name:"Char code",bits:u})})]})})}},64:(t,e,s)=>{s.d(e,{ce:()=>w,Ay:()=>A});var n=s(782),i=s(135),r=s(8878),o=s(7076),a=s(9547),c=s(7496),h=s(7844),l=s(6513),u=s(8281);var d=s(8177);const p=0,m=1,f=t=>{const[e,s]=(0,r.useState)(t.mode??p),[i,o]=(0,d.b)(t.value),a=()=>{return(0,n.jsxs)("div",{style:{cursor:"text",...(t="full",e="inline",void 0===t&&void 0!==u.UL[e]&&(t=e),{..."inline"===e?{display:"inline-block"}:{},width:u.UL[t]??"0"})},onClick:()=>{s(m)},children:[i,"\xa0"]});var t,e},c=(0,r.useCallback)((t=>t?.select()),[]),h=(0,r.useCallback)((e=>{s(p),o(e.value??""),t.onChange(e.value??"")}),[t,s,o]),l=()=>(0,n.jsx)("span",{style:{display:"block",position:"relative"},children:(0,n.jsx)("input",{ref:c,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem",color:"var(--text-color)"},onFocus:t.onFocus,onBlur:({target:t})=>h(t),onKeyPress:({key:t,target:e})=>{"Enter"===t&&h(e)},type:"text",defaultValue:i})});return(()=>{switch(e){case m:return l();case p:return a();default:return(0,n.jsx)("span",{})}})()};var g=s(2144),y=s(910);function b(t,e,s){const{totalHeight:n,toleranceHeight:i,bufferedItems:r,settings:{itemHeight:o,minIndex:a,maxIndex:c}}=e,h=a+Math.floor((t-i)/o),l=function(t,e,s,n,i){const r=Math.max(0,t,s);return[...i(r,Math.min(e,s+n-1)-r)]}(a,c,h,r,s),u=Math.max((h-a)*o,0);return{scrollTop:t,topPaddingHeight:u,bottomPaddingHeight:Math.max(n-(u+l.length*o),0),data:l}}const v=t=>{const e=(0,r.useRef)(null),{settings:s,startState:i,reducer:o}=(0,r.useMemo)((()=>{const e=function(t){const{minIndex:e=0,maxIndex:s=Number.MAX_SAFE_INTEGER,startIndex:n=0,itemHeight:i=20,count:r=Math.max(s-e,1),tolerance:o=r}=t;return{minIndex:e,maxIndex:s,startIndex:n,itemHeight:i,count:r,tolerance:o}}(t.settings??{}),s=function(t,e){const{minIndex:s,maxIndex:n,startIndex:i,itemHeight:r,count:o,tolerance:a}=t,c=o+2*a,h=Math.max(0,i-a-s),l=o*r,u=Math.max(n-s,1)*r,d=a*r,p=h*r,m={scrollTop:0,settings:t,viewportHeight:l,totalHeight:u,toleranceHeight:d,bufferedItems:c,topPaddingHeight:p,bottomPaddingHeight:u-(p+(l+2*d)),data:[]};return{...m,...b(p+d,m,e)}}(e,t.get),n=(i=t.get,(t,e)=>({...t,...b(e,t,i)}));var i;return{settings:e,reducer:n,startState:s}}),[t.settings,t.get]),[a,c]=(0,r.useReducer)(o,i);(0,r.useEffect)((()=>{null!==e.current&&c(e.current.scrollTop)}),[s,t.row]);const h=(0,r.useCallback)((t=>{t&&(t.scrollTop=e.current?e.current.scrollTop:s.startIndex*s.itemHeight),e.current=t}),[e,s.startIndex,s.itemHeight]),l=a.data.map((e=>(0,n.jsx)("div",{style:{height:`${s.itemHeight}px`},children:t.row(e)},t.rowKey(e))));return(0,n.jsxs)("div",{ref:h,style:{height:`${a.viewportHeight}px`,overflowY:"scroll",overflowAnchor:"none"},className:t.className??"",onScroll:t=>c(t.target.scrollTop),children:[(0,n.jsx)("div",{style:{height:`${a.topPaddingHeight}px`}}),l,(0,n.jsx)("div",{style:{height:`${a.bottomPaddingHeight}px`}})]})},S=({memory:t,jmp:e={value:0},highlight:s=-1,editable:i=!1,justifyLeft:o=!1,count:a,maxSize:c,offset:l=0,cellLabels:u,format:d=h.FN,onChange:p=(()=>{}),onFocus:m=(()=>{})})=>{const f=(0,r.useMemo)((()=>({count:Math.min(t.size,a??25),maxIndex:c??t.size,itemHeight:34,startIndex:e.value})),[t.size,e]),g=(0,r.useCallback)(((e,s)=>t.range(e+l,e+l+s).map(((s,n)=>[n+e+l,{value:s,wasChanged:t.wasChanged(n+e+l)}]))),[t]),y=(0,r.useCallback)((([e,r])=>(0,n.jsx)(x,{index:e,value:r.wasChanged?d(r.value):"",label:(u?.[e]??"").padStart(u?Math.max(...u.map((t=>t.length))):0),showLabel:void 0!=u,size:t.size,editable:i,justifyLeft:o,highlight:e===s,onChange:p,onFocus:m})),[d,i,s,p]);return(0,n.jsx)(v,{settings:f,get:g,row:y,rowKey:([t])=>t})},x=({index:t,value:e,label:s,showLabel:r=!1,size:o,highlight:a=!1,editable:c=!1,justifyLeft:l=!1,onChange:u=(()=>{}),onFocus:d=(()=>{})})=>(0,n.jsxs)("div",{style:{display:"flex",height:"100%"},children:[r&&(0,n.jsx)("code",{style:{...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{},whiteSpace:"pre"},children:s??""}),(0,n.jsx)("code",{style:{...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{},whiteSpace:"pre"},children:o?(0,h.FN)(t).padStart(Math.ceil(Math.log10(o))," "):(0,h.FN)(t)}),(0,n.jsx)("code",{style:{flex:"1",textAlign:l?"left":"right",color:"var(--text-color)",...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{}},children:c?(0,n.jsx)(f,{value:e,highlight:a,onChange:s=>u(t,s,Number(e)),onFocus:()=>d(t)}):(0,n.jsx)("span",{style:{color:"var(--text-color)"},children:e})})]}),w=(0,r.forwardRef)((({name:t="Memory",className:e,displayEnabled:s=!0,highlight:i=-1,editable:u=!0,memory:p,format:m="dec",excludedFormats:f=[],count:b,maxSize:v,offset:x,initialAddr:w,cellLabels:A,fileSelect:C,showClear:k=!0,onChange:I},_)=>{const[L,O]=(0,d.b)(m),[T,R]=(0,r.useState)(""),[E,M]=(0,r.useState)({value:w??0}),[N,F]=(0,d.b)(i),[P,j]=(0,r.useState)(0),$=()=>{const t=!isNaN(parseInt(T))&&isFinite(parseInt(T))?Number(T):0;F(t),M({value:t}),V()},{setStatus:D}=(0,r.useContext)(y.L),V=()=>{j(P+1)};(0,r.useImperativeHandle)(_,(()=>({rerender:V})));return(0,l.rT)((()=>{R(""),M({value:0})})),(0,n.jsxs)("article",{className:`panel memory ${e??t}`,children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("div",{style:{whiteSpace:"nowrap"},children:t}),(0,n.jsxs)("fieldset",{role:"group",children:[C&&(0,n.jsx)("button",{onClick:async()=>{if(I?.(),C){const{name:t,content:e}=await C();D(g.F),requestAnimationFrame((async()=>{const s=t.endsWith("hack")?a.aU:t.endsWith("asm")?a.aY:a.yt;requestAnimationFrame((async()=>{try{const n=await s(e);p.loadBytes(n),D(""),O(t.endsWith("hack")?"bin":t.endsWith("asm")?"asm":L),$()}catch(n){return void D(`Error loading memory: ${n.message}`)}}))}))}},className:"flex-0","data-tooltip":"Load file","data-placement":"bottom",children:"\ud83d\udcc2"}),k&&(0,n.jsx)("button",{onClick:()=>{p.reset(),I?.(),V()},className:"flex-0","data-tooltip":"Clear","data-placement":"bottom",children:"\ud83c\udd91"}),(0,n.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Addr",value:T,onKeyDown:({key:t})=>"Enter"===t&&$(),onChange:({target:{value:t}})=>R(t)}),(0,n.jsx)("button",{onClick:$,className:"flex-0","data-tooltip":"Scroll to address","data-placement":"bottom",children:"\u2935\ufe0f"}),(0,n.jsx)("select",{value:L,onChange:t=>O(t.target.value),children:o.hR.filter((t=>!f.includes(t))).map((t=>(0,n.jsx)("option",{children:t},t)))})]})]}),s?(0,n.jsx)(S,{jmp:E,memory:p,highlight:N,editable:u,justifyLeft:"asm"==L,count:b,format:t=>function(t,e){switch(t){case"bin":return(0,h.e5)(e);case"hex":return(0,h.uh)(e);case"asm":return(0,c.k)(e);default:return(0,h.FN)(e)}}(L,t),cellLabels:A,maxSize:v,offset:x,onChange:(t,e)=>{p.update(t,e,L??"dec"),I?.(),V()},onFocus:t=>F(t)},P):"Memory display is disabled"]})}));w.displayName="Memory";const A=w},6537:(t,e,s)=>{s.d(e,{d:()=>r});var n=s(782),i=s(7844);const r=({name:t,bits:e})=>(0,n.jsxs)("div",{children:[t,": ",(0,i.FN)(e)]})},4668:(t,e,s)=>{s.d(e,{f:()=>l});var n=s(782),i=s(2469),r=s(8878),o=s(6513);const a="white",c="black";function h(t,e,s,n){const i=4*(512*s+e),r=n===a?255:0;t[i]=r,t[i+1]=r,t[i+2]=r,t[i+3]=255}const l=({memory:t,showScaleControls:e=!1,scale:s=1,onScale:l})=>{const u=(0,r.useRef)(),[d,p]=(0,r.useState)(s),m=t=>{l?.(t),p(t)},f=(0,r.useCallback)((()=>{const e=u.current?.getContext("2d",{willReadFrequently:!0})??void 0;e&&function(t,e){const s=(0,i.Z1)(t.getImageData(0,0,512,256),"Failed to create Context2d");for(let i=0;i<512;i++)for(let t=0;t<256;t++){const o=(n=i,r=t,0===(e.get(32*r+(n/16|0))&1<{u.current=t??void 0,f()}),[u,f]);return(0,o.Nt)(f),(0,o.rT)((()=>{u.current?.getContext("2d")?.clearRect(0,0,u.current.width,u.current.height)})),(0,n.jsxs)("article",{className:"panel",children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("div",{children:"Screen"}),e&&(0,n.jsxs)("fieldset",{role:"group",children:[(0,n.jsx)("button",{"aria-current":0===d,onClick:()=>m(0),children:"x0"}),(0,n.jsx)("button",{"aria-current":1===d,onClick:()=>m(1),children:"x1"}),(0,n.jsx)("button",{"aria-current":2===d,onClick:()=>m(2),children:"x2"})]})]}),d>0&&(0,n.jsx)("main",{style:{backgroundColor:"var(--code-background-color)"},children:(0,n.jsx)("figure",{style:{width:512*d+"px",height:256*d+"px",boxSizing:"content-box",marginInline:"auto",margin:"auto",borderTop:"2px solid gray",borderLeft:"2px solid gray",borderBottom:"2px solid lightgray",borderRight:"2px solid lightgray"},children:(0,n.jsx)("canvas",{ref:g,width:512,height:256,style:{transform:`translate(-50%, -50%) scale(${d}) translate(50%, 50%)`,imageRendering:"pixelated"}})})})]})}},6513:(t,e,s)=>{s.d(e,{Nt:()=>a,rT:()=>c,wr:()=>l});var n=s(782),i=s(8878),r=s(4641),o=s(1487);function a(t){(0,i.useEffect)((()=>{const e=o.z.get().frame$.subscribe((()=>{t()}));return()=>e.unsubscribe()}),[t])}function c(t){(0,i.useEffect)((()=>{const e=o.z.get().reset$.subscribe((()=>{t()}));return()=>e.unsubscribe()}),[t])}function h(){return(0,r.V)(o.z.get())}const l=()=>{const t=function(){const[t,e]=(0,i.useState)(h());return(0,i.useEffect)((()=>{const t=o.z.get().$.subscribe((()=>{e(h())}));return()=>t.unsubscribe()}),[]),t}();return(0,n.jsx)("span",{style:{whiteSpace:"nowrap"},children:t})}},7365:(t,e,s)=>{s.d(e,{U:()=>o,_:()=>a});var n=s(5874),i=s(7589);function r(t,e){const s=[];for(let n=0;n({span:{start:t.start+m,end:t.end+m,line:t.line},type:"error-cell"})))),m+=t.expectedLine.length+1,p.push(t.expectedLine),f.push({span:{start:m,end:m+t.expectedLine.length,line:n},type:"correct-line"}),f.push(...t.correctCellSpans.map((t=>({span:{start:t.start+m,end:t.end+m,line:p.length},type:"correct-cell"})))),m+=t.givenLine.length+1):(p.push(u[n]),m+=u[n].length+1)}let y=p.join("\n");return y.endsWith("\n")&&(y=y.substring(0,y.length-1)),{text:y,failureNum:h.length,decorations:f,lineNumbers:g}}function c(t,e){const s=t.split("|").filter((t=>""!=t)),n=Array.from(s),i=[];let r=0;for(let c=0;c{s.d(e,{g:()=>i});var n=s(5874);async function i(t,e){try{const i=await t.readFile(e);let r;try{const s=e.replace("VME.tst",".tst").replace(".tst",".cmp");r=await t.readFile(s)}catch(s){}return(0,n.Ok)({tst:i,cmp:r})}catch(s){return(0,n._)(s)}}},4641:(t,e,s)=>{s.d(e,{V:()=>n});const n=t=>{if((t=>"function"===typeof t?.toString||"string"===typeof t)(t)){const e=t.toString();return"[object Object]"===e?JSON.stringify(t):e}return JSON.stringify(t)}},7721:(t,e,s)=>{s.d(e,{D4:()=>a,I8:()=>h,Z8:()=>l,gV:()=>c,p$:()=>r});var n=s(8739),i=s(7076);function r(){return{A:0,D:0,PC:0,ALU:0,flag:n.iI.Zero}}const o={c:32768,x1:36864,x2:36864,am:36864,op:4032,d1:32800,d2:32784,d3:32776,j1:32769,j2:32770,j3:32772};function a(t){function e(e){return(t&e)===e}return{c:e(o.c),x1:e(o.x1),x2:e(o.x2),am:e(o.am),op:(t&o.op)>>6,d1:e(o.d1),d2:e(o.d2),d3:e(o.d3),j1:e(o.j1),j2:e(o.j2),j3:e(o.j3)}}function c({inM:t,instruction:e},{A:s,D:i,PC:r}){const o=a(e),c=o.am?t:s,[h,l]=(0,n.v0)(o.op,i,c);return o.d2&&(i=h),[{A:s,D:i,PC:r+1,ALU:h,flag:l},o.d3,h]}function h({inM:t,instruction:e,reset:s},{A:i,D:r,PC:o,ALU:c,flag:h}){const l=a(e),u=l.j1&&h===n.iI.Positive,d=l.j2&&h===n.iI.Zero,p=l.j3&&h===n.iI.Negative;o=s?0:u||d||p?i:o,l.c?l.d1&&(i=c):i=32767&e;const m=l.am?t:i,f=(0,n.v0)(l.op,r,m);c=f[0],h=f[1];return[{addressM:i,outM:c,writeM:l.d3},{A:i,D:r,ALU:c,flag:h,PC:o}]}class l{RAM;ROM;Screen;Keyboard;#t=0;#e=0;#s=0;#n={A:0,D:0,PC:0,ALU:0,flag:n.iI.Zero};get state(){return this.#n}get PC(){return this.#t}get A(){return this.#e}get D(){return this.#s}setA(t){this.#e=t}setD(t){this.#s=t}setPC(t){this.#t=t}constructor({RAM:t=new i.XK,ROM:e}){this.RAM=t,this.ROM=e,this.Screen=new i.qN(this.RAM,i.RL,i.L7),this.Keyboard=new i.PC(this.RAM)}reset(){this.#t=0,this.#e=0,this.#s=0}tick(){const t=this.#e,e={inM:this.RAM.get(this.#e),instruction:this.ROM.get(this.#t),reset:!1},[s,i,r]=c(e,{A:this.#e,D:this.#s,PC:this.#t,ALU:this.#s,flag:n.iI.Zero});i&&this.RAM.set(t,r);const[o,{A:a,D:l,PC:u}]=h(e,s);this.#e=a,this.#s=l,this.#t=u}}},7589:(t,e,s)=>{s.d(e,{dl:()=>c});var n=s(9563),i=s(3977);const r="\nCmp <: Base {\n Root := line*\n line = bar cell+ newline?\n cell = cellvalue bar\n cellvalue = (~(bar|newline) any)*\n}",o=(0,n.qN)(r,i.lN),a=o.extendSemantics(i.JE);a.addAttribute("cell",{cell:(t,e)=>t.sourceString}),a.addAttribute("line",{line:(t,e,s)=>e.children.map((t=>t.cell))}),a.addAttribute("root",{Root:t=>t.children.map((t=>t.line))});const c={grammar:r,semantics:a,parser:o,parse:(0,i.Q5)(o,a)}},6554:(t,e,s)=>{s.d(e,{uG:()=>c});var n=s(9563),i=s(3977);const r='\nTst <: Base {\n Root := Tst\n Tst = (TstStatement | TstRepeat | TstWhile)+\n\n TstRepeat = Repeat Number? OpenBrace TstCommand+ CloseBrace\n TstWhile = While Condition OpenBrace TstCommand+ CloseBrace\n TstStatement = TstCommand\n\n TstCommand = TstOperation Separator\n Separator = (Semi | Bang | Comma)\n\n TstOperation =\n | TstFileOperation\n | TstOutputListOperation\n | TstEvalOperation\n | TstSetOperation\n | TstOutputOperation\n | TstEchoOperation\n | TstClearEchoOperation\n | TstLoadROMOperation\n\n TstLoadROMOperation = ROM32K Load FileName\n TstFileOperation = FileOperation FileName?\n TstOutputListOperation = "output-list" OutputFormat+\n OutputFormat = Name Index? FormatSpec?\n FormatSpec = percent FormatStyle wholeDec dot wholeDec dot wholeDec\n TstSetOperation = Set Name Index? Number\n Index = OpenSquare wholeDec? CloseSquare\n Condition = Value CompareOp Value\n TstEvalOperation = Eval | TickTock | Tick | Tock | VmStep\n TstOutputOperation = Output\n TstEchoOperation = Echo String\n TstClearEchoOperation = ClearEcho\n\n FileName = Name\n FileOperation = "load" | "output-file" | "compare-to"\n\n Set = "set"\n Eval = "eval"\n Tick = "tick"\n Tock = "tock"\n TickTock = "ticktock"\n VmStep = "vmstep"\n Echo = "echo"\n Repeat = "repeat"\n ClearEcho = "clear-echo"\n Output = "output"\n OutputList = "output-list"\n FormatStyle = "B"|"D"|"S"|"X"\n ROM32K = "ROM32K"\n Load = "load"\n While = "while"\n\n CompareOp = "<>" | "<=" | ">=" | "=" | "<" | ">"\n}',o=(0,n.qN)(r,i.lN),a=o.extendSemantics(i.JE);a.extendAttribute("value",{Index:(t,e,s)=>e?.child(0)?.value??-1}),a.extendAttribute("name",{FileName:({name:t})=>t}),a.addAttribute("index",{Index:(t,e,s)=>e.child(0)?.value??0}),a.addAttribute("formatSpec",{FormatSpec:(t,{sourceString:e},{value:s},n,{value:i},r,{value:o})=>({style:e,width:i,lpad:s,rpad:o})}),a.addAttribute("format",{OutputFormat:({name:t},e,s)=>({id:t,builtin:void 0!==e?.child(0),address:e?.child(0)?.value??-1,format:s?.child(0)?.formatSpec})}),a.addAttribute("operation",{TstEvalOperation:t=>({op:t.sourceString}),TstOutputOperation:t=>({op:"output"}),TstOutputListOperation:(t,e)=>({op:"output-list",spec:e.children.map((t=>t.format))}),TstSetOperation(t,{name:e},s,{value:n}){const i={op:"set",id:e,value:n},r=s.child(0)?.child(1)?.child(0);return r&&(i.index=r.value),i},TstEchoOperation:(t,e)=>({op:"echo",message:e.String}),TstClearEchoOperation:t=>({op:"clear-echo"}),TstLoadROMOperation:(t,e,{name:s})=>({op:"loadRom",file:s}),TstFileOperation:(t,e)=>({op:t.sourceString,file:e?.sourceString})}),a.addAttribute("command",{TstCommand(t,e){return{op:t.operation,separator:e.sourceString,span:(0,i.Ln)(this.source)}}}),a.addAttribute("condition",{Condition:({value:t},{sourceString:e},{value:s})=>({left:t,right:s,op:e})}),a.addAttribute("statement",{TstWhile(t,e,s,n,r){return{statements:n.children.map((t=>t.command)),condition:e.condition,span:(0,i.Ln)(this.source)}},TstRepeat(t,e,s,n,r){return{statements:n.children.map((t=>t.command)),count:e.sourceString?Number(e.sourceString):-1,span:(0,i.Ln)(this.source)}},TstStatement:t=>t.command}),a.addAttribute("tst",{Tst:t=>({lines:t.children.map((t=>t.statement))})}),a.addAttribute("root",{Root:({tst:t})=>t});const c={grammar:r,semantics:a,parser:o,parse:(0,i.Q5)(o,a)}},9976:(t,e,s)=>{s.d(e,{G:()=>u});var n=s(2469),i=s(1106),r=s(6418),o=s(4867),a=s(8783);function c(t){return void 0!==t.op}function h(t){return void 0!==t.condition}function l(t){const{op:e}=t;switch(e){case"tick":return new i.IJ;case"tock":return new i.CX;case"ticktock":return new r.z;case"eval":return new i.Nq;case"vmstep":return new a.a;case"output":return new o.ik;case"set":return new o.jl(t.id,t.value,t.index);case"output-list":return new o.Ad(t.spec);case"echo":return new o.S0(t.message);case"clear-echo":return new o.Tn;case"loadRom":return new o.fK(t.file);case"load":return new o.hh(t.file);case"output-file":case"compare-to":return;default:(0,n.H8)(e,`Unknown tst operation ${e}`)}}function u(t,e){let s,n=[],i=t,r=[];for(const a of e.lines){if(c(a))i=t,r=[a];else{const e=h(a)?new o.eB(new o.kW(a.condition.left,a.condition.right,a.condition.op)):new o.UM(a.count);e.span=a.span,t.addInstruction(e),i=e,r=a.statements}for(const t of r){const e=l(t.op);if(void 0!==e&&(void 0===s?s=a.span:s.end=a.span.end,i.addInstruction(e),n.push(e)),","!=t.separator){";"==t.separator?i.addInstruction(new o.fe(s??t.span)):"!"==t.separator&&i.addInstruction(new o.Ge(s??t.span));for(const e of n)e.span=s??t.span;s=void 0,n=[]}}}return t.reset(),t}},1106:(t,e,s)=>{s.d(e,{BX:()=>a,CX:()=>l,IJ:()=>h,Nq:()=>c});var n=s(9651),i=s(1487),r=s(9976),o=s(9937);class a extends o.V{chip=new n.ti;get chipId(){return this.chip.id}clock=i.z.get();static from(t,e){const s=new a(e);return(0,r.G)(s,t)}with(t){return this.chip=t,this}hasVar(t){return"time"===t||(t=`${t}`,this.chip.hasIn(t)||this.chip.hasOut(t))}getVar(t,e){if("time"===(t=`${t}`))return this.clock.toString();const s=this.chip.get(t,e);return s?s instanceof n.z7?s.busVoltage:s.voltage():0}getWidth(t,e){const s=this.chip.get(t,e);return s?s.width:0}setVar(t,e,s){const i=this.chip.get(t,s);i instanceof n.z7?i.busVoltage=e:i?.pull(0===e?n.$L:n.RY)}eval(){this.chip.eval()}tick(){this.chip.eval(),this.clock.tick()}tock(){this.chip.eval(),this.clock.tock()}async loadROM(t){await this.chip.load(this.fs,t)}async run(){this.clock.reset(),await super.run()}}class c{_chipTestInstruction_=!0;async do(t){t.eval()}*steps(){yield this}}class h{_chipTestInstruction_=!0;async do(t){t.tick()}*steps(){yield this}}class l{_chipTestInstruction_=!0;async do(t){t.tock()}*steps(){yield this}}},6418:(t,e,s)=>{s.d(e,{b:()=>a,z:()=>c});var n=s(7721),i=s(7076),r=s(9976),o=s(9937);class a extends o.V{cpu;ticks=0;static from(t,e,s){const n=new a(e,s);return(0,r.G)(n,t)}constructor(t=new i.n9,e){super(e),this.cpu=new n.Z8({ROM:t}),this.reset()}reset(){return super.reset(),this.cpu.reset(),this.ticks=0,this}hasVar(t){return"number"!==typeof t&&!("A"!==t&&"D"!==t&&"PC"!==t&&"time"!==t&&!t.startsWith("RAM"))}getVar(t,e){switch(t){case"A":return this.cpu.A;case"D":return this.cpu.D;case"PC":return this.cpu.PC;case"time":return this.ticks;case"RAM":return void 0===e?0:this.cpu.RAM.get(e)}if("number"===typeof t)return 0;if(t.startsWith("RAM")){const e=Number(t.substring(4,t.length-1));return this.cpu.RAM.get(e)}return 0}getWidth(t,e){return 16}setVar(t,e,s){switch(t){case"A":this.cpu.setA(e);break;case"D":this.cpu.setD(e);break;case"PC":this.cpu.setPC(e);break;case"RAM":this.cpu.RAM.set(s??0,e)}}ticktock(){this.ticks+=1,this.cpu.tick()}async loadROM(t){await this.cpu.ROM.load(this.fs,t)}}class c{_cpuTestInstruction_=!0;async do(t){t.ticktock()}*steps(){yield this}}},4867:(t,e,s)=>{s.d(e,{Ad:()=>c,Ge:()=>r,S0:()=>p,Tn:()=>m,UM:()=>l,eB:()=>d,fK:()=>f,fe:()=>i,hh:()=>g,ik:()=>a,jl:()=>o,kW:()=>u});class n{span;constructor(t){this.span=t}async do(){}*steps(){yield this}}class i extends n{}class r extends n{}class o{variable;value;index;constructor(t,e,s){this.variable=t,this.value=e,this.index=s}async do(t){t.setVar(this.variable,this.value,this.index)}*steps(){yield this}}class a{async do(t){t.output()}*steps(){yield this}}class c{outputs=[];constructor(t=[]){for(const e of t)this.addOutput(e)}addOutput(t){this.outputs.push({id:t.id,style:t.format?.style??"B",len:t.format?.width??-1,lpad:t.format?.lpad??1,rpad:t.format?.rpad??1,builtin:t.builtin,address:t.address})}async do(t){t.outputList(this.outputs),t.header()}*steps(){yield this}}class h{instructions=[];span;addInstruction(t){this.instructions.push(t)}async do(t){for(const e of this.instructions)e.do(t)}*steps(t){yield this}}class l extends h{repeat;constructor(t){super(),this.repeat=t}async do(){}*innerSteps(t){for(const e of this.instructions)yield*e.steps(t)}*steps(t){if(-1===this.repeat)for(yield this;;)yield*this.innerSteps(t);else for(let e=0;e":return`${e}`!==`${s}`}else switch(this.op){case"<":return e":return e>s;case">=":return e>=s;case"=":return e===s;case"<>":return e!==s}return!1}}class d extends h{condition;constructor(t){super(),this.condition=t}*steps(t){for(;this.condition.check(t);){yield this;for(const e of this.instructions)yield*e.steps(t)}}}class p{content;constructor(t){this.content=t}async do(t){t.echo(this.content)}*steps(){yield this}}class m{async do(t){t.clearEcho()}*steps(){yield this}}class f{file;constructor(t){this.file=t}async do(t){t.fs.pushd("/samples"),await t.loadROM(this.file),t.fs.popd()}*steps(){yield this}}class g{file;constructor(t){this.file=t}async do(t){await t.load(this.file)}*steps(){yield this}}},9937:(t,e,s)=>{s.d(e,{V:()=>c});var n=s(2469),i=s(4544),r=s(7844);class o{variable;fmt;lPad;rPad;len;index;builtin;constructor(t,e="%B1.1.1",s,i,r,o,a){if(this.variable=t,e.startsWith("%")&&void 0===s&&void 0===i&&void 0===r){const{fmt:t,lPad:s,rPad:n,len:i}=e.match(/^%(?[BDXS])(?\d+)\.(?\d+)\.(?\d+)$/)?.groups;this.fmt=t,this.lPad=parseInt(s),this.rPad=parseInt(n),this.len=parseInt(i),this.builtin=!1,this.index=-1}else(0,n.vA)(["B","X","D","S"].includes(e[0])),this.fmt=e[0],this.len=s??3,this.lPad=i??1,this.rPad=r??1,this.builtin=o??!1,this.index=a??-1}header(t){let e=`${this.variable}`;if(this.builtin){e=`${e}[${this.index>=0?this.index:""}]`}return e.length>this.len+this.lPad+this.rPad?e.substring(0,this.len+this.lPad+this.rPad):this.padCenter(e)}print(t){const e=t.getVar(this.variable,this.index);if("S"===this.fmt)return this.padLeft(e);const s=(0,{B:r.e5,D:r.FN,X:r.uh}[this.fmt])(e);return"D"===this.fmt?this.padRight(s):this.padLeft(s.slice(s.length-this.len))}padCenter(t){const e=this.lPad+this.len+this.rPad,s=Math.floor((e-t.length)/2),n=e-s-t.length,i=s+t.length,r=i+n;return t=(t=t.padStart(i)).padEnd(r)}padLeft(t){t=t.substring(0,this.len);const e=this.rPad+this.len,s=this.lPad+e;return t=(t=t.padEnd(e)).padStart(s)}padRight(t){t=t.substring(0,this.len);const e=this.lPad+this.len,s=this.rPad+e;return t=(t=t.padStart(e)).padEnd(s)}}var a=s(4867);class c{instructions=[];_outputList=[];_log="";fs=new i.Q2;doEcho;constructor(t){this.doEcho=t}setFileSystem(t){return this.fs=t,this}echo(t){this.doEcho?.(t)}clearEcho(){this.doEcho?.("")}async loadROM(t){}async load(t){}async compareTo(t){}outputFile(t){}createOutputs(t){return t.map((t=>{if(-1===t.len)if("time"===t.id)t.len=7,t.style="S";else{const e=this.getWidth(t.id,t.address);"B"===t.style?t.len=e:"D"===t.style?t.len=Math.ceil(Math.log(e)):"X"===t.style&&(t.len=Math.ceil(e/4))}return new o(t.id,t.style,t.len,t.lpad,t.rpad,t.builtin,t.address)}))}outputList(t){this._outputList=this.createOutputs(t)}addInstruction(t){this.instructions.push(t)}reset(){return this._steps=function*(t){for(const e of t.instructions)yield*e.steps(t)}(this),this._step=this._steps.next(),this._log="",this}_steps;_step;get steps(){return void 0===this._steps&&(this.reset(),this._steps=(0,n.Z1)(this._steps,"Reset did not initialize steps"),this._step=(0,n.Z1)(this._step,"Reset did not find first step")),this._steps}get currentStep(){return this._step?.value}get done(){return this._step?.done??!1}async step(){for(;!this._step.done;){if(await this._step.value.do(this),this._step=this.steps.next(),this._step.value instanceof a.fe)return this._step=this.steps.next(),!1;if(this._step.value instanceof a.Ge)return!0}return!0}async run(){for(this.reset();!await this.step(););}breakpoints=new Map;addBreakpoint(t,e){this.breakpoints.set(t,e)}clearBreakpoints(){this.breakpoints.clear()}output(){const t=this._outputList.map((t=>t.print(this)));this._log+=`|${t.join("|")}|\n`}header(){const t=this._outputList.map((t=>t.header(this)));this._log+=`|${t.join("|")}|\n`}log(){return this._log}}},8783:(t,e,s)=>{s.d(e,{Y:()=>a,a:()=>c});var n=s(7076),i=s(5087),r=s(9976),o=s(9937);class a extends o.V{vm=new i.Vm;loadAction;dir;static from(t,e,s,n){const i=new a(n);return i.dir=e?.split("/").slice(0,-1).join("/"),i.loadAction=s,(0,r.G)(i,t)}using(t){return this.fs=t,this}with(t){return this.vm=t,this}hasVar(t,e){return"string"!==typeof t&&(e=t,t="RAM"),"RAM"===t&&void 0!==e&&e>0&&e{s.d(e,{P:()=>o});var n=s(270),i=s(8032);function r(t,e){const s=[];for(let n=0;n{const[s,n]=r(t,2);return s*n&65535},nArgs:2,type:"function"},"Math.divide":{func:(t,e)=>{const[s,i]=r(t,2);return 0==i?(e.sys.error(n.X.DIVIDE_BY_ZERO),0):65535&Math.floor(s/i)},nArgs:2,type:"function"},"Math.min":{func:(t,e)=>{const[s,n]=r(t,2);return 65535&Math.min(s,n)},nArgs:2,type:"function"},"Math.max":{func:(t,e)=>{const[s,n]=r(t,2);return 65535&Math.max(s,n)},nArgs:2,type:"function"},"Math.sqrt":{func:(t,e)=>{const[s]=r(t,1);return s<0?(e.sys.error(n.X.SQRT_NEG),0):65535&Math.floor(Math.sqrt(s))},nArgs:1,type:"function"},"Math.abs":{func:(t,e)=>{const[s]=r(t,1);return 65535&Math.abs(s)},nArgs:1,type:"function"},"Screen.clearScreen":{func:(t,e)=>(e.screen.clear(),0),nArgs:0,type:"function"},"Screen.setColor":{func:(t,e)=>{const[s]=r(t,1);return e.screen.color=0!==s,0},nArgs:1,type:"function"},"Screen.drawPixel":{func:(t,e)=>{const[s,n]=r(t,2);return e.screen.drawPixel(s,n),0},nArgs:2,type:"function"},"Screen.drawLine":{func:(t,e)=>{const[s,n,i,o]=r(t,4);return e.screen.drawLine(s,n,i,o),0},nArgs:4,type:"function"},"Screen.drawRectangle":{func:(t,e)=>{const[s,n,i,o]=r(t,4);return e.screen.drawRect(s,n,i,o),0},nArgs:4,type:"function"},"Screen.drawCircle":{func:(t,e)=>{const[s,n,i]=r(t,3);return e.screen.drawCircle(s,n,i),0},nArgs:3,type:"function"},"Memory.peek":{func:(t,e)=>{const[s]=r(t,1);return t.get(s)},nArgs:1,type:"function"},"Memory.poke":{func:(t,e)=>{const[s,n]=r(t,2);return t.set(s,n),0},nArgs:2,type:"function"},"Memory.alloc":{func:(t,e)=>{const[s]=r(t,1);return e.memory.alloc(s)},nArgs:1,type:"function"},"Memory.deAlloc":{func:(t,e)=>{const[s]=r(t,1);return e.memory.deAlloc(s),0},nArgs:1,type:"function"},"Array.new":{func:(t,e)=>{const[s]=r(t,1);return s<=0?(e.sys.error(n.X.ARRAY_SIZE_NOT_POSITIVE),0):e.memory.alloc(s)},nArgs:1,type:"constructor"},"Array.dispose":{func:(t,e)=>{const[s]=r(t,1);return e.memory.deAlloc(s),0},nArgs:1,type:"method"},"String.new":{func:(t,e)=>{const[s]=r(t,1);return e.string.new(s)},nArgs:1,type:"constructor"},"String.dispose":{func:(t,e)=>{const[s]=r(t,1);return e.string.dispose(s),0},nArgs:1,type:"method"},"String.length":{func:(t,e)=>{const[s]=r(t,1);return e.string.length(s)},nArgs:1,type:"method"},"String.charAt":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.charAt(s,n)},nArgs:2,type:"method"},"String.setCharAt":{func:(t,e)=>{const[s,n,i]=r(t,3);return e.string.setCharAt(s,n,i),0},nArgs:3,type:"method"},"String.appendChar":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.appendChar(s,n)},nArgs:2,type:"method"},"String.eraseLastChar":{func:(t,e)=>{const[s]=r(t,1);return e.string.eraseLastChar(s),0},nArgs:1,type:"method"},"String.intValue":{func:(t,e)=>{const[s]=r(t,1);return e.string.intValue(s)},nArgs:1,type:"method"},"String.setInt":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.setInt(s,n),0},nArgs:2,type:"method"},"String.backSpace":{func:(t,e)=>i.G_,nArgs:0,type:"function"},"String.doubleQuote":{func:(t,e)=>i.MD,nArgs:0,type:"function"},"String.newLine":{func:(t,e)=>i.qK,nArgs:0,type:"function"},"Output.moveCursor":{func:(t,e)=>{const[s,n]=r(t,2);return e.output.moveCursor(s,n),0},nArgs:2,type:"function"},"Output.printChar":{func:(t,e)=>{const[s]=r(t,1);return e.output.printChar(s),0},nArgs:1,type:"function"},"Output.printString":{func:(t,e)=>{const[s]=r(t,1);return e.output.printString(s),0},nArgs:1,type:"function"},"Output.printInt":{func:(t,e)=>{const[s]=r(t,1);return e.output.printInt(s),0},nArgs:1,type:"function"},"Output.println":{func:(t,e)=>(e.output.println(),0),nArgs:0,type:"function"},"Output.backSpace":{func:(t,e)=>(e.output.backspace(),0),nArgs:0,type:"function"},"Keyboard.keyPressed":{func:(t,e)=>e.keyboard.keyPressed(),nArgs:0,type:"function"},"Keyboard.readChar":{func:(t,e)=>(e.keyboard.readChar(),0),nArgs:0,type:"function"},"Keyboard.readLine":{func:(t,e)=>{const[s]=r(t,1);return e.keyboard.readLine(s),0},nArgs:1,type:"function"},"Keyboard.readInt":{func:(t,e)=>{const[s]=r(t,1);return e.keyboard.readInt(s),0},nArgs:1,type:"function"},"Sys.halt":{func:(t,e)=>(e.sys.halt(),0),nArgs:0,type:"function"},"Sys.error":{func:(t,e)=>{const[s]=r(t,1);return e.sys.error(s),0},nArgs:1,type:"function"},"Sys.wait":{func:(t,e)=>{const[s]=r(t,1);return e.sys.wait(s),0},nArgs:1,type:"function"}}},270:(t,e,s)=>{var n;function i(t){return Object.values(n).includes(t)}s.d(e,{U:()=>i,X:()=>n}),function(t){t[t.SYS_WAIT_DURATION_NOT_POSITIVE=1]="SYS_WAIT_DURATION_NOT_POSITIVE",t[t.ARRAY_SIZE_NOT_POSITIVE=2]="ARRAY_SIZE_NOT_POSITIVE",t[t.DIVIDE_BY_ZERO=3]="DIVIDE_BY_ZERO",t[t.SQRT_NEG=4]="SQRT_NEG",t[t.ALLOC_SIZE_NOT_POSITIVE=5]="ALLOC_SIZE_NOT_POSITIVE",t[t.HEAP_OVERFLOW=6]="HEAP_OVERFLOW",t[t.ILLEGAL_PIXEL_COORD=7]="ILLEGAL_PIXEL_COORD",t[t.ILLEGAL_LINE_COORD=8]="ILLEGAL_LINE_COORD",t[t.ILLEGAL_RECT_COORD=9]="ILLEGAL_RECT_COORD",t[t.ILLEGAL_CENTER_COORD=12]="ILLEGAL_CENTER_COORD",t[t.ILLEGAL_RADIUS=13]="ILLEGAL_RADIUS",t[t.STRING_LENGTH_NEG=14]="STRING_LENGTH_NEG",t[t.GET_CHAR_INDEX_OUT_OF_BOUNDS=15]="GET_CHAR_INDEX_OUT_OF_BOUNDS",t[t.SET_CHAR_INDEX_OUT_OF_BOUNDS=16]="SET_CHAR_INDEX_OUT_OF_BOUNDS",t[t.STRING_FULL=17]="STRING_FULL",t[t.STRING_EMPTY=18]="STRING_EMPTY",t[t.STRING_INSUFFICIENT_CAPACITY=19]="STRING_INSUFFICIENT_CAPACITY",t[t.ILLEGAL_CURSOR_LOCATION=20]="ILLEGAL_CURSOR_LOCATION"}(n||(n={}))},8032:(t,e,s)=>{s.d(e,{Fz:()=>h,G_:()=>r,MD:()=>o,eY:()=>c,qK:()=>i});var n=s(270);const i=128,r=129,o=34;function a(t){return t-48}function c(t){return t.toString().split("").map((t=>Number(t)+48))}class h{memory;os;constructor(t,e){this.memory=t,this.os=e}new(t){t<=0&&this.os.sys.error(n.X.STRING_LENGTH_NEG);const e=this.os.memory.alloc(t+2);return this.os.sys.halted?0:(this.memory.set(e,t),this.memory.set(e+1,0),e)}dispose(t){this.os.memory.deAlloc(t)}maxLength(t){return this.memory.get(t)}length(t){return this.memory.get(t+1)}setLength(t,e){this.memory.set(t+1,e)}charAt(t,e){return e<0||e>=this.length(t)?(this.os.sys.error(n.X.GET_CHAR_INDEX_OUT_OF_BOUNDS),0):this.memory.get(t+e+2)}setCharAt(t,e,s){e<0||e>=this.length(t)?this.os.sys.error(n.X.SET_CHAR_INDEX_OUT_OF_BOUNDS):this.memory.set(t+e+2,s)}appendChar(t,e){const s=this.length(t);return s==this.maxLength(t)?(this.os.sys.error(n.X.STRING_FULL),0):(this.setLength(t,s+1),this.setCharAt(t,s,e),t)}eraseLastChar(t){const e=this.length(t);0!=e?this.setLength(t,e-1):this.os.sys.error(n.X.STRING_EMPTY)}intValue(t){const e=[];for(let n=0;n=48&&s<=57);n++)e.push(a(this.charAt(t,n)));var s;return e.reduce(((t,e)=>10*t+e),0)}setInt(t,e){const s=c(e);if(s.length>this.maxLength(t))this.os.sys.error(n.X.STRING_INSUFFICIENT_CAPACITY);else{this.setLength(t,0);for(const e of s)this.appendChar(t,e)}}}},5087:(t,e,s)=>{s.d(e,{IG:()=>S,h0:()=>x,Vm:()=>w});var n=s(5874),i=s(3977),r=s(2548),o=s(7076);class a extends o.XK{strict=!0;get SP(){return this.get(0)}set SP(t){this.set(0,t)}get LCL(){return this.get(1)}set LCL(t){this.set(1,t)}get ARG(){return this.get(2)}set ARG(t){this.set(2,t)}get THIS(){return this.get(3)}set THIS(t){this.set(3,t)}get THAT(){return this.get(4)}set THAT(t){this.set(4,t)}get statics(){const t=[];for(let e=16;e<256;e++)t.push(this.get(e));return t}constructor(){super(),this.set(0,256)}baseSegment(t,e){if(this.strict&&(e<0||e>32767))return(0,n._)(new Error(`Illegal offset value ${e} (must be between 0 and 32767)`));switch(t){case"argument":return(0,n.Ok)(this.ARG+e);case"constant":return(0,n.Ok)(e);case"local":return(0,n.Ok)(this.LCL+e);case"pointer":if(this.strict&&e>1)throw new Error(`pointer out of bounds access (pointer can be 0 for this, 1 for that, but got ${e}`);return(0,n.Ok)(0===e?3:4);case"static":return this.strict&&e>239?(0,n._)(new Error(`Cannot access statics beyond 239: ${e}`)):(0,n.Ok)(16+e);case"temp":return this.strict&&e>7?(0,n._)(new Error(`Temp out of bounds access (temp can be 0 to 7, but got ${e}`)):(0,n.Ok)(5+e);case"that":return(0,n.Ok)(this.THAT+e);case"this":return(0,n.Ok)(this.THIS+e)}}getSegment(t,e){if("constant"===t){if(this.strict&&(e<0||e>32767))throw new Error(`Illegal offset value ${e} (must be between 0 and 32767)`);return e}const s=this.baseSegment(t,e);if((0,n.ys)(s))throw(0,n._)(s);return this.get((0,n.Ok)(s))}setSegment(t,e,s){const i=this.baseSegment(t,e);if((0,n.ys)(i))throw(0,n._)(i);this.set((0,n.Ok)(i),s)}argument(t){return this.getSegment("argument",t)}local(t){return this.getSegment("local",t)}static(t){return this.getSegment("static",t)}constant(t){return this.getSegment("constant",t)}this(t){return this.getSegment("this",t)}that(t){return this.getSegment("that",t)}pointer(t){return this.getSegment("pointer",t)}temp(t){return this.getSegment("temp",t)}push(t){const e=this.SP;this.set(e,t),this.set(0,e+1)}pop(){if(this.strict&&256===this.SP)throw new Error("Cannot pop the stack below 256 in strict mode");this.set(0,this.SP-1);return this.get(this.SP)}pushFrame(t,e,s){const n=this.SP,i=n-e;this.set(n,t),this.set(n+1,this.LCL),this.set(n+2,this.ARG),this.set(n+3,this.THIS),this.set(n+4,this.THAT),this.set(2,i),this.set(1,n+5);const r=n+5;for(let o=0;oe),o,o+e)]},locals:{base:a,count:s,values:[...this.map(((t,e)=>e),a,a+s)]},stack:{base:c,count:h,values:[...this.map(((t,e)=>e),c,c+h)]},this:{base:c,count:n,values:[...this.map(((t,e)=>e),this.THIS,this.THIS+n)]},that:{base:c,count:i,values:[...this.map(((t,e)=>e),this.THAT,this.THAT+i)]},frame:{RET:this.get(t),LCL:this.LCL,ARG:this.ARG,THIS:this.THIS,THAT:this.THAT}}}getVmState(t=240){const e=[...this.map(((t,e)=>e),5,13)],s=[...this.map(((t,e)=>e),13,16)],n=[...this.map(((t,e)=>e),16,16+t)];return{"0: SP":this.SP,"1: LCL":this.LCL,"2: ARG":this.ARG,"3: THIS":this.THIS,"4: THAT":this.THAT,temps:e,internal:s,static:n}}binOp(t){const e=65535&t(this.get(this.SP-2),this.get(this.SP-1));this.set(this.SP-2,e),this.set(0,this.SP-1)}unOp(t){const e=65535&t(this.get(this.SP-1));this.set(this.SP-1,e)}comp(t){this.binOp(((e,s)=>t(e,s)?-1:0))}}var c=s(8032);class h{memory;os;animationFrameId=void 0;cancel=!1;constructor(t,e){this.memory=t,this.os=e}keyPressed(){return this.memory.get(o.ky)}readCharLoop(t){let e=!1,s=0;const n=()=>{if(this.cancel)return;let i=!1;this.os.paused||(e||0===this.keyPressed()||(e=!0,s=this.keyPressed()),e&&0===this.keyPressed()&&(i=!0,t(s))),i||(this.animationFrameId=requestAnimationFrame(n))};n()}readChar(){this.os.sys.block(),this.os.output.drawCursor(),new Promise((t=>{this.readCharLoop(t)})).then((t=>{this.os.output.printChar(t),this.os.sys.release(t)}))}readLineLoop(t){const e=this.os.string.new(100);this.os.sys.halted&&t(0);let s=!1,n=0;const i=()=>{if(this.cancel)return;let r=!1;this.os.paused||(s||0==this.keyPressed()||(s=!0,n=this.keyPressed()),s&&0==this.keyPressed()&&(s=!1,n==c.G_?(this.os.string.length(e)>0&&this.os.output.backspace(),this.os.string.eraseLastChar(e)):n==c.qK?(t(e),r=!0):(this.os.string.appendChar(e,n),this.os.sys.halted&&t(0),this.os.output.printChar(n),this.os.output.drawCursor()))),r||(this.animationFrameId=requestAnimationFrame(i))};i()}readLine(t){this.os.sys.block(),this.os.output.printString(t),this.os.output.drawCursor(),new Promise((t=>{this.readLineLoop(t)})).then((t=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(t)}))}readInt(t){this.os.sys.block(),this.os.output.printString(t),this.os.output.drawCursor(),new Promise((t=>{this.readLineLoop(t)})).then((t=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(this.os.string.intValue(t))}))}dispose(){this.cancel=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}var l=s(270);class u{memory;os;freeSegments=[{address:2048,length:14336}];constructor(t,e){this.memory=t,this.os=e}alloc(t){if(t<=0)return this.os.sys.error(l.X.ARRAY_SIZE_NOT_POSITIVE),0;for(let e=0;e=t){const n=s.address;return s.address+=t+1,s.length-=t+1,0===s.length&&this.freeSegments.splice(e,1),this.memory.set(n,t),n+1}}return this.os.sys.error(l.X.HEAP_OVERFLOW),0}deAlloc(t){const e=this.memory.get(t-1);this.freeSegments.push({address:t-1,length:e+1})}}const d=function(){const t=new Array(126);return t[32]=p([" "," "," "," "," "," "," "," "," "," "," "]),t[33]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[34]=p([" \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588 \u2588 "," "," "," "," "," "," "," "," "]),t[35]=p([" "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 "," "," "]),t[36]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[37]=p([" "," ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," "," "]),t[38]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[39]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[40]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[41]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[42]=p([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "," "]),t[43]=p([" "," "," "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),t[44]=p([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[45]=p([" "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "," "]),t[46]=p([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[47]=p([" "," "," \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588 "," "," "]),t[48]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),t[49]=p([" \u2588\u2588 "," \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[50]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[51]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[52]=p([" \u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588 \u2588\u2588 ","\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[53]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[54]=p([" \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[55]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[56]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[57]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[58]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),t[59]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[60]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[61]=p([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "]),t[62]=p([" "," ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," "," "]),t[64]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[63]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[65]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[66]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[67]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[68]=p(["\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),t[69]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[70]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),t[71]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," "," "]),t[72]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[73]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[74]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[75]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[76]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[77]=p(["\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[78]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[79]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[80]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),t[81]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "]),t[82]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[83]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[84]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[85]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[86]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[87]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),t[88]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[89]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[90]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[91]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[92]=p([" "," ","\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588 "," "," "]),t[94]=p([" \u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[95]=p([" "," "," "," "," "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "]),t[96]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[97]=p([" "," "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[98]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[99]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[100]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[101]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[102]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),t[103]=p([" "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),t[104]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[105]=p([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[106]=p([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),t[107]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[108]=p([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[109]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 "," "," "]),t[110]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[111]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[112]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "]),t[113]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[114]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),t[115]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[116]=p([" \u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[117]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[118]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),t[119]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),t[120]=p([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[121]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "]),t[122]=p([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[123]=p([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[124]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[125]=p(["\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),t[126]=p([" \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),t}();function p(t){return t.map((t=>t.split("").map((t=>"\u2588"==t))))}const m=new Array(o.RL).fill(0),f=!0;class g{memory;os;color=f;constructor(t,e){this.memory=t,this.os=e}clear(){this.memory.screen.loadBytes(m)}outOfBounds(t,e){return t<0||t>16*o.pc||e<0||e>o.dh}drawPixel(t,e){if(this.outOfBounds(t,e))return void this.os.sys.error(l.X.ILLEGAL_PIXEL_COORD);const s=32*e+Math.floor(t/16);let n=this.memory.screen.get(s);this.color?n|=1<181)this.os.sys.error(l.X.ILLEGAL_RADIUS);else for(let n=-s;n<=s;n++)this.drawLine(t-Math.floor(Math.sqrt(s*s-n*n)),e+n,t+Math.floor(Math.sqrt(s*s-n*n)),e+n)}}class y{os;col=0;row=0;lastColor=!1;constructor(t){this.os=t}setColor(t){this.lastColor=this.os.screen.color,this.os.screen.color=t}restoreColor(){this.os.screen.color=this.lastColor}clearChar(){this.setColor(false),this.os.screen.drawRect(8*this.col,11*this.row,8*(this.col+1),11*(this.row+1)),this.restoreColor()}moveCursor(t,e){t<0||t>22||e<0||e>64?this.os.sys.error(l.X.ILLEGAL_CURSOR_LOCATION):(this.row=t,this.col=e,this.drawCursor())}println(){this.row+=1,this.col=0}drawCursor(){this.clearChar(),this.setColor(f),this.os.screen.drawRect(8*this.col+2,11*this.row+2,8*(this.col+1)-2,11*(this.row+1)-2),this.restoreColor()}printChar(t){const e=d[t];if(e){this.clearChar(),this.setColor(f);for(let t=0;t{this.cancelWait||(e+=n,e>=t?this.release():this.animationFrameId=requestAnimationFrame(s))};s(0)}halt(){this._halted=!0,this._exitCode=0}error(t){this.os.output.printJsString(`ERR${t}`),this._halted=!0,this._exitCode=t}dispose(){this.cancelWait=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}class v{vmMemory;screen;memory;string;output;keyboard;sys;paused=!1;constructor(t){this.vmMemory=t,this.screen=new g(this.vmMemory,this),this.memory=new u(this.vmMemory,this),this.string=new c.Fz(this.vmMemory,this),this.output=new y(this),this.keyboard=new h(this.vmMemory,this),this.sys=new b(this)}dispose(){this.keyboard.dispose(),this.sys.dispose()}}const S="__implicit",x={name:"Sys.init",labels:{},nVars:0,opBase:0,operations:[{op:"function",name:"Sys.init",nVars:0},{op:"call",name:"Main.main",nArgs:0}]};class w{memory=new a;os=new v(this.memory);functionMap={};executionStack=[];entry="";segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}};functions=[];program=[];addedSysInit=!1;staticCount=0;statics={};getStaticCount(){return this.staticCount}returnLine=void 0;registerStatic(t,e){const s=t.split(".")[0],n=this.statics[s]??[];this.statics[s]=n;const i=n[e]??this.staticCount++;return n[e]=i,i}registerStatics(){for(const t of Object.values(this.functionMap))for(const e of t.operations)"push"!==e.op&&"pop"!==e.op||"static"!==e?.segment||(e.offset=this.registerStatic(t.name,e.offset))}static validateFile(t){for(const e of t.instructions)if("function"==e.op){const s=e.name.split(".");if(2!=s.length)return(0,n._)((0,i.$5)(`Illegal subroutine name ${e.name} (Expected .)`,e.span));if(s[0]!=t.name)return(0,n._)((0,i.$5)(`File name ${t.name} doesn't match class name ${s[0]} (at ${e.name})`,e.span))}return(0,n.Ok)()}static validateFiles(t){const e=new Set;for(const s of t){if(e.has(s.name))return(0,n._)((0,i.$5)(`File ${s.name} already exists`));const t=this.validateFile(s);if((0,n.ys)(t))return t;e.add(s.name)}return(0,n.Ok)()}validateStackInstructions(){for(const t of Object.values(this.functionMap))for(const e of t.operations)if("pop"==e.op||"push"==e.op){const t=this.memory.baseSegment(e.segment,e.offset);if((0,n.ys)(t))return(0,n._)((0,i.$5)((0,n._)(t).message,e.span))}return(0,n.Ok)()}static validateFunctions(t){const e=new Set,s=[];for(const r of t){if("function"==r.op){if(r.nVars<0||r.nVars>32767)return(0,n._)((0,i.$5)(`Illegal number of local variables ${r.nVars} (Expected 0-32767)`,r.span));e.add(r.name)}if("call"==r.op){if(r.nArgs<0||r.nArgs>32767)return(0,n._)((0,i.$5)(`Illegal number of arguments ${r.nArgs} (Expected 0-32767)`,r.span));s.push(r)}}for(const o of s)if(!e.has(o.name)){if(!r.P[o.name])return(0,n._)((0,i.$5)(`Undefined function ${o.name}`,o.span));if(r.P[o.name].nArgs!=o.nArgs)return(0,n._)((0,i.$5)(`OS function ${o.name} expects ${r.P[o.name].nArgs} arguments, not ${o.nArgs}`,o.span))}return(0,n.Ok)()}static buildFromFiles(t){let e=this.validateFiles(t);if((0,n.ys)(e))return e;const s=t.map((t=>t.instructions)).reduce(((t,e)=>t.concat(e)));if(e=this.validateFunctions(s),(0,n.ys)(e))return e;const i=new w,r=i.load(s);return(0,n.ys)(r)?r:i.bootstrap()}static build(t){const e=this.validateFunctions(t);if((0,n.ys)(e))return e;const s=new w,i=s.load(t);return(0,n.ys)(i)?i:s.bootstrap()}static buildFunction(t,e){if("function"!==t[e].op)throw new Error("Only call buildFunction at the initial Function instruction");const{name:s,nVars:r}=t[e],o={name:s,nVars:r,labels:{},operations:[{op:"function",name:s,nVars:r,span:t[e].span}],opBase:0},a=new Set,c={};e+=1;t:for(;ethis.currentFunction.operations.length)throw new Error(`Current operation step beyond end of function operations (${this.invocation.opPtr} > ${this.currentFunction.operations.length})`);return this.currentFunction.operations[this.invocation.opPtr]}}load(t,e=!1){e&&(this.functionMap={},this.statics={},this.staticCount=0),"function"!==t[0]?.op&&t.unshift({op:"function",name:S,nVars:0});let s=0;for(;st.name===this.entry?-1:e.name===this.entry?1:0));let t=0;return this.program=this.functions.reduce(((e,s)=>(s.name!=x.name&&(s.opBase=t),t+=s.operations.length,e.concat(s.operations))),[]),this.reset(),(0,n.Ok)(this)}reset(){this.executionStack=[{function:this.entry,opPtr:1,frameBase:256,nArgs:0,thisInitialized:!1,thatInitialized:!1}],this.memory.reset(),this.memory.SP=256,this.segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}},this.os.dispose(),this.os=new v(this.memory)}validateStackOp(t){if(this.currentFunction?.name==this.entry){for(const e of["local","argument"])if(t.segment==e){if(this.segmentInitializations[e].initialized)return void(this.segmentInitializations[e].n=Math.max(t.offset+1,this.segmentInitializations[e].n));throw new Error(`The ${e} segment cannot be accessed since it was not initialized`)}if("this"==t.segment&&this.invocation.thisInitialized)return void(this.invocation.thisN=Math.max(t.offset+1,this.invocation.thisN??0))}if("argument"==t.segment&&t.offset>=this.invocation.nArgs)throw new Error("Argument offset out of bounds");if("local"==t.segment&&t.offset>=this.functionMap[this.invocation.function]?.nVars)throw new Error("Local offset out of bounds");if("this"==t.segment&&!this.invocation.thisInitialized)throw new Error("The this segment cannot be accessed since it was not initialized");if("that"==t.segment&&!this.invocation.thatInitialized)throw new Error("The that segment cannot be accessed since it was not initialized")}setPaused(t=!0){this.os.paused=t}step(){if(this.os.sys.halted)return this.os.sys.exitCode;if(this.os.sys.blocked)return;if(this.os.sys.released&&"call"==this.operation?.op){const t=this.os.sys.readReturnValue(),e=this.memory.SP-this.operation.nArgs;return this.memory.set(e,t),this.memory.SP=e+1,void(this.invocation.opPtr+=1)}if(void 0==this.operation)return this.os.sys.halt(),this.step();const t=this.operation;if("label"===t.op)return this.invocation.opPtr+=1,this.step();switch(t.op){case"push":{this.validateStackOp(t);const e=this.memory.getSegment(t.segment,t.offset);this.memory.push(e);break}case"pop":{this.validateStackOp(t);const e=this.memory.pop();this.memory.setSegment(t.segment,t.offset,e),"pointer"==t.segment&&(0==t.offset?(this.invocation.thisInitialized=!0,this.invocation.thisN=this.memory.get(this.memory.THIS-1)):1==t.offset&&(this.invocation.thatInitialized=!0));break}case"add":this.memory.binOp(((t,e)=>t+e));break;case"sub":this.memory.binOp(((t,e)=>t-e));break;case"neg":this.memory.unOp((t=>-t));break;case"and":this.memory.binOp(((t,e)=>t&e));break;case"or":this.memory.binOp(((t,e)=>t|e));break;case"not":this.memory.unOp((t=>~t));break;case"eq":this.memory.comp(((t,e)=>t===e));break;case"lt":this.memory.comp(((t,e)=>tt>e));break;case"goto":this.goto(t.label);break;case"if-goto":0!=this.memory.pop()&&this.goto(t.label);break;case"call":{const e=t.name;if(this.functionMap[e]){const s=this.memory.pushFrame(this.invocation.opPtr,t.nArgs,this.functionMap[e].nVars);this.executionStack.push({function:e,opPtr:0,nArgs:t.nArgs,frameBase:s,thisInitialized:!1,thatInitialized:!1})}else if(r.P[e]){const s=r.P[e].func(this.memory,this.os);if(this.os.sys.blocked)return;const n=this.memory.SP-t.nArgs;this.memory.set(n,s),this.memory.SP=n+1}break}case"return":{const t=this.derivedLine();this.executionStack.pop();const e=this.memory.popFrame();if(this.invocation.opPtr=e,0===this.executionStack.length)return this.returnLine=t,0;break}}this.invocation.opPtr+=1}goto(t){if(this.currentFunction){if(void 0===this.currentFunction.labels[t])throw new Error(`Attempting GOTO to unknown label ${t} in ${this.currentFunction.name}`);this.invocation.opPtr=this.currentFunction.labels[t]}}write(t){t.map((([t,e])=>{this.memory.set(t,e)}))}read(t){return t.map((t=>this.memory.get(t)))}vmStack(){return this.executionStack.map(((t,e)=>{const s=this.executionStack[e+1],n=s?s.frameBase-s.nArgs:this.memory.get(0);return this.makeFrame(t,n)}))}getUsedSegments(t){const e=new Set;for(const s of this.functionMap[t.function].operations)"push"!==s.op&&"pop"!=s.op||e.add(s.segment);return e}makeFrame(t=this.invocation,e){const s=this.functionMap[t.function];if(s.name===this.entry){const e=256+s.nVars,n=this.executionStack[1],i=n?n.frameBase-n.nArgs:this.memory.get(0),{ARG:r,LCL:o,THAT:a,THIS:c}=this.memory,h=this.segmentInitializations.argument.n,l=this.segmentInitializations.local.n,u=this.invocation.thisN??0;return{fn:s,args:{base:r,count:h,values:[...this.memory.map(((t,e)=>e),r,r+h)]},locals:{base:o,count:l,values:[...this.memory.map(((t,e)=>e),o,o+l)]},stack:{base:256,count:i-e,values:[...this.memory.map(((t,e)=>e),e,i)]},this:{base:c,count:u,values:[...this.memory.map(((t,e)=>e),c,c+u)]},that:{base:a,count:1,values:[this.memory.THAT]},frame:{ARG:r,LCL:o,RET:65535,THAT:a,THIS:c},usedSegments:this.getUsedSegments(t)}}const n=this.memory.getFrame(t.frameBase,t.nArgs,s.nVars,this.invocation.thisN??0,1,e);return n.fn=s,n.usedSegments=this.getUsedSegments(t),n}derivedLine(){return this.operation?.span?.line??this.returnLine??0}writeDebug(){const t=this.derivedLine(),e=Math.max(t-5,0),s=Math.min(t+3,this.program.length),n=this.program.slice(e,s).map(((s,n)=>`${n===t-e?"->":" "} ${function(t){switch(t.op){case"add":case"and":case"sub":case"eq":case"gt":case"lt":case"neg":case"not":case"or":case"return":return` ${t.op}`;case"goto":return` ${t.op} ${t.label}`;case"if-goto":return` ${t.op} ${t.label}`;case"label":return`${t.op} ${t.label}`;case"call":return` ${t.op} ${t.name} ${t.nArgs}`;case"function":return`${t.op} ${t.name} ${t.nVars}`;case"pop":return` ${t.op} ${t.segment} ${t.offset}`;case"push":return` ${t.op} ${t.segment} ${t.offset}`}}(s)}`)).join("\n"),i=this.vmStack().at(-1);return i?n+"\n\n"+function(t){return[`Frame: ${t.fn?.name??"Unknown Fn"} ARG:${t.frame.ARG} LCL:${t.frame.LCL}`,`Args: ${A(t.args)}`,`Lcls: ${A(t.locals)}`,`Stck: ${A(t.stack)}`].join("\n")}(i):n}}function A(t){return`[${t.base};${t.count}][${t.values.join(", ")}]`}}}]); \ No newline at end of file diff --git a/static/js/200.79ef4b82.chunk.js b/static/js/200.79ef4b82.chunk.js deleted file mode 100644 index 80266660..00000000 --- a/static/js/200.79ef4b82.chunk.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(globalThis.webpackChunk_nand2tetris_web=globalThis.webpackChunk_nand2tetris_web||[]).push([[200],{1384:(t,e,s)=>{s.d(e,{o:()=>r,w:()=>o});var n=s(8878),i=s(782);const r=t=>{const e=(0,n.useId)(),s=`tab-${e}`,r=`panel-${e}`;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{role:"tab",id:s,"aria-controls":r,style:t.style,children:(0,i.jsxs)("label",{children:[t.title,(0,i.jsx)("input",{type:"radio",name:t.parent,"aria-controls":r,value:s,checked:t.checked,onChange:e=>{var s;return 1==e.target.checked&&(null===(s=t.onSelect)||void 0===s?void 0:s.call(t))}})]})}),(0,i.jsx)("div",{role:"tabpanel",id:r,"aria-labelledby":s,children:t.children})]})},o=t=>{var e,s,r,o;const a=(0,n.useId)(),[c,h]=(0,n.useState)(0),l=null!==(e=null===(s=t.tabIndex)||void 0===s?void 0:s.value)&&void 0!==e?e:c,u=null!==(r=null===(o=t.tabIndex)||void 0===o?void 0:o.set)&&void 0!==r?r:h;return(0,i.jsx)("section",{role:"tablist",style:{"--tab-count":t.children.length},children:n.Children.map(t.children,((t,e)=>(0,n.cloneElement)(t,{checked:e===l,parent:a,idx:e,onSelect:()=>{var s,n;u(e),null===(s=t.props)||void 0===s||null===(n=s.onSelect)||void 0===n||n.call(s)}})))})}},9267:(t,e,s)=>{s.d(e,{B:()=>x});var n=s(6458),i=s(5874),r=s(7365),o=s(1296),a=s(8177),c=s(7022),h=s(910),l=s(7589),u=s(6554),d=s(1091),p=s(8878),m=s(8029),f=s(3508),g=s(2675),y=s(4280),b=s(1384),v=s(782);const S="skipTestEditWarning",x=({runner:t,tst:[e,s,x],cmp:[A,C],out:[k],tstName:I,setPath:_,disabled:L=!1,defaultTst:O,defaultCmp:T,showName:R=!1,showLoad:E=!0,showClear:M=!1,onSpeedChange:N,prefix:F})=>{var P,j;const{fs:$,setStatus:D}=(0,p.useContext)(h.L),{filePicker:V,tracking:G}=(0,p.useContext)(m.BR),[H,z]=(0,p.useState)(!0),B=(0,p.useRef)();(0,p.useEffect)((()=>(B.current=new class extends d.M{async reset(){var e;await(null===(e=t.current)||void 0===e?void 0:e.reset()),z(!0)}finishFrame(){var e;super.finishFrame(),null===(e=t.current)||void 0===e||e.finishFrame()}async tick(){var e,s;return z(!0),null!==(e=await(null===(s=t.current)||void 0===s?void 0:s.tick()))&&void 0!==e&&e}toggle(){var e;null===(e=t.current)||void 0===e||e.toggle()}},()=>{var t;null===(t=B.current)||void 0===t||t.stop()})),[t]);const U=(0,p.useCallback)((t=>{G.trackEvent("tab","change",t)}),[G]),[X,K]=(0,p.useState)(!1),[W,q]=(0,p.useState)(!1),[Y,Z]=(0,p.useState)(""),[J,Q]=(0,p.useState)(""),tt=(0,f.s)(),[et,st]=(0,a.b)(null!==I&&void 0!==I?I:""),nt=(0,p.useCallback)((async()=>{var t;const e=await V.select({suffix:".tst"}),n=await(0,o.g)($,e);if((0,i.ys)(n))return void D("Failed to load test");null===_||void 0===_||_(e),st(null!==(t=e.split("/").pop())&&void 0!==t?t:"");const{tst:r,cmp:a}=(0,i.oA)(n);null===s||void 0===s||s(r),null===C||void 0===C||C(null!==a&&void 0!==a?a:"")}),[V,D,$]),[it,rt]=(0,p.useState)();(0,p.useEffect)((()=>{rt((0,r._)(A,k))}),[k,A]);const ot=(0,v.jsx)("dialog",{open:tt.isOpen,children:(0,v.jsxs)("article",{children:[(0,v.jsx)("header",{children:"Warning"}),(0,v.jsxs)("main",{children:[(0,v.jsxs)("p",{children:["The test script can be edited during this IDE session. In the next session, the original script will be restored.",(0,v.jsx)("br",{})]}),(0,v.jsxs)("div",{style:{display:"flex",flexDirection:"row"},children:[(0,v.jsx)("input",{type:"checkbox",checked:W,onChange:t=>{q(t.target.checked)}}),(0,v.jsx)("p",{children:"Do not show this again"})]}),(0,v.jsx)("p",{children:(0,v.jsx)("br",{})}),(0,v.jsx)("button",{onClick:()=>{W&&localStorage.setItem(S,"true"),tt.close()},children:"Ok"})]})]})});return(0,v.jsx)(y.Z,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{children:[(0,v.jsx)(n.x6,{id:"NnH3pK"}),R&&(""==et?": Default":`: ${et}`)]}),ot,(0,v.jsx)("div",{className:"flex-1",children:B.current&&(0,v.jsx)(c.T,{prefix:(0,v.jsxs)(v.Fragment,{children:[F,M&&(0,v.jsx)("button",{className:"flex-0",onClick:()=>{s(null!==O&&void 0!==O?O:""),C(null!==T&&void 0!==T?T:"")},children:"Clear"}),X?(0,v.jsx)("button",{className:"flex-0",onClick:()=>{K(!1),s(Y),C(J)},children:"Restore"}):(0,v.jsx)("button",{className:"flex-0",onClick:()=>{localStorage.getItem(S)||tt.open(),K(!0),Z(e),Q(A)},children:"Edit"}),E&&(0,v.jsx)("button",{className:"flex-0",onClick:nt,"data-tooltip":"Load a test script","data-placement":"bottom",children:"\ud83d\udcc2"})]}),runner:B.current,disabled:L,onSpeedChange:N})})]}),children:(0,v.jsxs)(b.w,{children:[(0,v.jsx)(b.o,{title:"Test Script",onSelect:()=>U("tst"),children:(0,v.jsx)(g.K,{value:e,onChange:t=>{s(t),z(!1)},grammar:u.uG.parser,language:"tst",disabled:!X,highlight:H?x:void 0})}),(0,v.jsx)(b.o,{title:"Compare File",onSelect:()=>U("cmp"),children:(0,v.jsx)(g.K,{value:A,onChange:C,grammar:l.dl.parser,language:"cmp",lineNumberTransform:t=>"",disabled:!X})}),(0,v.jsxs)(b.o,{title:"Output File",onSelect:()=>U("out"),children:[""==k&&(0,v.jsx)("p",{children:"Execute test script to generate output."}),(0,v.jsx)(g.K,{value:k,onChange:()=>{},language:"cmp",disabled:!0,lineNumberTransform:t=>""})]}),(0,v.jsxs)(b.o,{title:"Diff Table",onSelect:()=>U("diff"),children:[""==k&&(0,v.jsx)("p",{children:"Execute test script to compare output."}),(null!==(P=null===it||void 0===it?void 0:it.failureNum)&&void 0!==P?P:0)>0&&(0,v.jsxs)("p",{children:[null===it||void 0===it?void 0:it.failureNum," comparison failure",1===(null===it||void 0===it?void 0:it.failureNum)?"":"s",". Scroll down for details"]}),(0,v.jsx)(g.K,{value:null!==(j=null===it||void 0===it?void 0:it.text)&&void 0!==j?j:"",onChange:()=>{},language:"",disabled:!0,lineNumberTransform:t=>{var e;return null!==(e=null===it||void 0===it?void 0:it.lineNumbers[t-1])&&void 0!==e?e:""},customDecorations:null===it||void 0===it?void 0:it.decorations.map((t=>({span:t.span,cssClass:w(t.type)})))})]})]})})};function w(t){switch(t){case"error-line":return"diff-highlight-line-1";case"error-cell":return"diff-highlight-cell-1";case"correct-line":return"diff-highlight-line-2";case"correct-cell":return"diff-highlight-cell-2";default:return""}}},7437:(t,e,s)=>{s.d(e,{s:()=>c});var n=s(782),i=s(8878),r=s(6537);const o={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152},a={ArrowLeft:"L-arrow",ArrowUp:"U-arrow",ArrowRight:"R-arrow",ArrowDown:"D-arrow"};const c=({keyboard:t,update:e})=>{const[s,c]=(0,i.useState)(!1),[h,l]=(0,i.useState)(""),[u,d]=(0,i.useState)(t.getKey());let p=0;const m=(0,i.useRef)(null),f=t=>{if(!s)return;l(function(t){return a[t]??t}(t.key)),m.current?.blur();const n=function(t){const e=o[t.key];if(void 0!==e)return e;if(1===t.key.length){const e=t.key.charCodeAt(0);if(e>=32&&e<=126)return e}return 0}(t);n!==p&&(y(n),e?.())},g=n=>{m.current?.blur(),s&&(p=0,t.clearKey(),e?.(),d(t.getKey()),l(""))},y=e=>{0!==e&&(t.setKey(e),d(t.getKey()),p=e)};return(0,i.useEffect)((()=>(window.addEventListener("keydown",f),window.addEventListener("keyup",g),()=>{window.removeEventListener("keydown",f),window.removeEventListener("keyup",g)}))),(0,n.jsx)("article",{className:"panel",children:(0,n.jsxs)("div",{className:"flex row align-baseline",children:[(0,n.jsx)("button",{onClick:()=>{c(!s)},ref:m,className:"flex-0",style:{whiteSpace:"pre"},children:(s?"Disable":"Enable")+" Keyboard"}),(0,n.jsx)("div",{className:"flex-1"})," ",(0,n.jsxs)("div",{className:"flex-4",children:["Key: ",h]}),(0,n.jsx)("div",{className:"flex-4",children:(0,n.jsx)(r.d,{name:"Char code",bits:u})})]})})}},64:(t,e,s)=>{s.d(e,{ce:()=>w,Ay:()=>A});var n=s(782),i=s(135),r=s(8878),o=s(7076),a=s(9547),c=s(7496),h=s(7844),l=s(6513),u=s(8281);var d=s(8177);const p=0,m=1,f=t=>{const[e,s]=(0,r.useState)(t.mode??p),[i,o]=(0,d.b)(t.value),a=()=>{return(0,n.jsxs)("div",{style:{cursor:"text",...(t="full",e="inline",void 0===t&&void 0!==u.UL[e]&&(t=e),{..."inline"===e?{display:"inline-block"}:{},width:u.UL[t]??"0"})},onClick:()=>{s(m)},children:[i,"\xa0"]});var t,e},c=(0,r.useCallback)((t=>t?.select()),[]),h=(0,r.useCallback)((e=>{s(p),o(e.value??""),t.onChange(e.value??"")}),[t,s,o]),l=()=>(0,n.jsx)("span",{style:{display:"block",position:"relative"},children:(0,n.jsx)("input",{ref:c,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem",color:"var(--text-color)"},onFocus:t.onFocus,onBlur:({target:t})=>h(t),onKeyPress:({key:t,target:e})=>{"Enter"===t&&h(e)},type:"text",defaultValue:i})});return(()=>{switch(e){case m:return l();case p:return a();default:return(0,n.jsx)("span",{})}})()};var g=s(2144),y=s(910);function b(t,e,s){const{totalHeight:n,toleranceHeight:i,bufferedItems:r,settings:{itemHeight:o,minIndex:a,maxIndex:c}}=e,h=a+Math.floor((t-i)/o),l=function(t,e,s,n,i){const r=Math.max(0,t,s);return[...i(r,Math.min(e,s+n-1)-r)]}(a,c,h,r,s),u=Math.max((h-a)*o,0);return{scrollTop:t,topPaddingHeight:u,bottomPaddingHeight:Math.max(n-(u+l.length*o),0),data:l}}const v=t=>{const e=(0,r.useRef)(null),{settings:s,startState:i,reducer:o}=(0,r.useMemo)((()=>{const e=function(t){const{minIndex:e=0,maxIndex:s=Number.MAX_SAFE_INTEGER,startIndex:n=0,itemHeight:i=20,count:r=Math.max(s-e,1),tolerance:o=r}=t;return{minIndex:e,maxIndex:s,startIndex:n,itemHeight:i,count:r,tolerance:o}}(t.settings??{}),s=function(t,e){const{minIndex:s,maxIndex:n,startIndex:i,itemHeight:r,count:o,tolerance:a}=t,c=o+2*a,h=Math.max(0,i-a-s),l=o*r,u=Math.max(n-s,1)*r,d=a*r,p=h*r,m={scrollTop:0,settings:t,viewportHeight:l,totalHeight:u,toleranceHeight:d,bufferedItems:c,topPaddingHeight:p,bottomPaddingHeight:u-(p+(l+2*d)),data:[]};return{...m,...b(p+d,m,e)}}(e,t.get),n=(i=t.get,(t,e)=>({...t,...b(e,t,i)}));var i;return{settings:e,reducer:n,startState:s}}),[t.settings,t.get]),[a,c]=(0,r.useReducer)(o,i);(0,r.useEffect)((()=>{null!==e.current&&c(e.current.scrollTop)}),[s,t.row]);const h=(0,r.useCallback)((t=>{t&&(t.scrollTop=e.current?e.current.scrollTop:s.startIndex*s.itemHeight),e.current=t}),[e,s.startIndex,s.itemHeight]),l=a.data.map((e=>(0,n.jsx)("div",{style:{height:`${s.itemHeight}px`},children:t.row(e)},t.rowKey(e))));return(0,n.jsxs)("div",{ref:h,style:{height:`${a.viewportHeight}px`,overflowY:"scroll",overflowAnchor:"none"},className:t.className??"",onScroll:t=>c(t.target.scrollTop),children:[(0,n.jsx)("div",{style:{height:`${a.topPaddingHeight}px`}}),l,(0,n.jsx)("div",{style:{height:`${a.bottomPaddingHeight}px`}})]})},S=({memory:t,jmp:e={value:0},highlight:s=-1,editable:i=!1,justifyLeft:o=!1,count:a,maxSize:c,offset:l=0,cellLabels:u,format:d=h.FN,onChange:p=(()=>{}),onFocus:m=(()=>{})})=>{const f=(0,r.useMemo)((()=>({count:Math.min(t.size,a??25),maxIndex:c??t.size,itemHeight:34,startIndex:e.value})),[t.size,e]),g=(0,r.useCallback)(((e,s)=>t.range(e+l,e+l+s).map(((s,n)=>[n+e+l,{value:s,wasChanged:t.wasChanged(n+e+l)}]))),[t]),y=(0,r.useCallback)((([e,r])=>(0,n.jsx)(x,{index:e,value:r.wasChanged?d(r.value):"",label:(u?.[e]??"").padStart(u?Math.max(...u.map((t=>t.length))):0),showLabel:void 0!=u,size:t.size,editable:i,justifyLeft:o,highlight:e===s,onChange:p,onFocus:m})),[d,i,s,p]);return(0,n.jsx)(v,{settings:f,get:g,row:y,rowKey:([t])=>t})},x=({index:t,value:e,label:s,showLabel:r=!1,size:o,highlight:a=!1,editable:c=!1,justifyLeft:l=!1,onChange:u=(()=>{}),onFocus:d=(()=>{})})=>(0,n.jsxs)("div",{style:{display:"flex",height:"100%"},children:[r&&(0,n.jsx)("code",{style:{...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{},whiteSpace:"pre"},children:s??""}),(0,n.jsx)("code",{style:{...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{},whiteSpace:"pre"},children:o?(0,h.FN)(t).padStart(Math.ceil(Math.log10(o))," "):(0,h.FN)(t)}),(0,n.jsx)("code",{style:{flex:"1",textAlign:l?"left":"right",color:"var(--text-color)",...(0,i.Wf)("none"),...a?{background:"var(--mark-background-color)"}:{}},children:c?(0,n.jsx)(f,{value:e,highlight:a,onChange:s=>u(t,s,Number(e)),onFocus:()=>d(t)}):(0,n.jsx)("span",{style:{color:"var(--text-color)"},children:e})})]}),w=(0,r.forwardRef)((({name:t="Memory",className:e,displayEnabled:s=!0,highlight:i=-1,editable:u=!0,memory:p,format:m="dec",excludedFormats:f=[],count:b,maxSize:v,offset:x,initialAddr:w,cellLabels:A,fileSelect:C,showClear:k=!0,onChange:I},_)=>{const[L,O]=(0,d.b)(m),[T,R]=(0,r.useState)(""),[E,M]=(0,r.useState)({value:w??0}),[N,F]=(0,d.b)(i),[P,j]=(0,r.useState)(0),$=()=>{const t=!isNaN(parseInt(T))&&isFinite(parseInt(T))?Number(T):0;F(t),M({value:t}),V()},{setStatus:D}=(0,r.useContext)(y.L),V=()=>{j(P+1)};(0,r.useImperativeHandle)(_,(()=>({rerender:V})));return(0,l.rT)((()=>{R(""),M({value:0})})),(0,n.jsxs)("article",{className:`panel memory ${e??t}`,children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("div",{style:{whiteSpace:"nowrap"},children:t}),(0,n.jsxs)("fieldset",{role:"group",children:[C&&(0,n.jsx)("button",{onClick:async()=>{if(I?.(),C){const{name:t,content:e}=await C();D(g.F),requestAnimationFrame((async()=>{const s=t.endsWith("hack")?a.aU:t.endsWith("asm")?a.aY:a.yt;requestAnimationFrame((async()=>{try{const n=await s(e);p.loadBytes(n),D(""),O(t.endsWith("hack")?"bin":t.endsWith("asm")?"asm":L),$()}catch(n){return void D(`Error loading memory: ${n.message}`)}}))}))}},className:"flex-0","data-tooltip":"Load file","data-placement":"bottom",children:"\ud83d\udcc2"}),k&&(0,n.jsx)("button",{onClick:()=>{p.reset(),I?.(),V()},className:"flex-0","data-tooltip":"Clear","data-placement":"bottom",children:"\ud83c\udd91"}),(0,n.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Addr",value:T,onKeyDown:({key:t})=>"Enter"===t&&$(),onChange:({target:{value:t}})=>R(t)}),(0,n.jsx)("button",{onClick:$,className:"flex-0","data-tooltip":"Scroll to address","data-placement":"bottom",children:"\u2935\ufe0f"}),(0,n.jsx)("select",{value:L,onChange:t=>O(t.target.value),children:o.hR.filter((t=>!f.includes(t))).map((t=>(0,n.jsx)("option",{children:t},t)))})]})]}),s?(0,n.jsx)(S,{jmp:E,memory:p,highlight:N,editable:u,justifyLeft:"asm"==L,count:b,format:t=>function(t,e){switch(t){case"bin":return(0,h.e5)(e);case"hex":return(0,h.uh)(e);case"asm":return(0,c.k)(e);default:return(0,h.FN)(e)}}(L,t),cellLabels:A,maxSize:v,offset:x,onChange:(t,e)=>{p.update(t,e,L??"dec"),I?.(),V()},onFocus:t=>F(t)},P):"Memory display is disabled"]})}));w.displayName="Memory";const A=w},6537:(t,e,s)=>{s.d(e,{d:()=>r});var n=s(782),i=s(7844);const r=({name:t,bits:e})=>(0,n.jsxs)("div",{children:[t,": ",(0,i.FN)(e)]})},4668:(t,e,s)=>{s.d(e,{f:()=>l});var n=s(782),i=s(2469),r=s(8878),o=s(6513);const a="white",c="black";function h(t,e,s,n){const i=4*(512*s+e),r=n===a?255:0;t[i]=r,t[i+1]=r,t[i+2]=r,t[i+3]=255}const l=({memory:t,showScaleControls:e=!1,scale:s=1,onScale:l})=>{const u=(0,r.useRef)(),[d,p]=(0,r.useState)(s),m=t=>{l?.(t),p(t)},f=(0,r.useCallback)((()=>{const e=u.current?.getContext("2d",{willReadFrequently:!0})??void 0;e&&function(t,e){const s=(0,i.Z1)(t.getImageData(0,0,512,256),"Failed to create Context2d");for(let i=0;i<512;i++)for(let t=0;t<256;t++){const o=(n=i,r=t,0===(e.get(32*r+(n/16|0))&1<{u.current=t??void 0,f()}),[u,f]);return(0,o.Nt)(f),(0,o.rT)((()=>{u.current?.getContext("2d")?.clearRect(0,0,u.current.width,u.current.height)})),(0,n.jsxs)("article",{className:"panel",children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("div",{children:"Screen"}),e&&(0,n.jsxs)("fieldset",{role:"group",children:[(0,n.jsx)("button",{"aria-current":0===d,onClick:()=>m(0),children:"x0"}),(0,n.jsx)("button",{"aria-current":1===d,onClick:()=>m(1),children:"x1"}),(0,n.jsx)("button",{"aria-current":2===d,onClick:()=>m(2),children:"x2"})]})]}),d>0&&(0,n.jsx)("main",{style:{backgroundColor:"var(--code-background-color)"},children:(0,n.jsx)("figure",{style:{width:512*d+"px",height:256*d+"px",boxSizing:"content-box",marginInline:"auto",margin:"auto",borderTop:"2px solid gray",borderLeft:"2px solid gray",borderBottom:"2px solid lightgray",borderRight:"2px solid lightgray"},children:(0,n.jsx)("canvas",{ref:g,width:512,height:256,style:{transform:`translate(-50%, -50%) scale(${d}) translate(50%, 50%)`,imageRendering:"pixelated"}})})})]})}},6513:(t,e,s)=>{s.d(e,{Nt:()=>a,rT:()=>c,wr:()=>l});var n=s(782),i=s(8878),r=s(4641),o=s(1487);function a(t){(0,i.useEffect)((()=>{const e=o.z.get().frame$.subscribe((()=>{t()}));return()=>e.unsubscribe()}),[t])}function c(t){(0,i.useEffect)((()=>{const e=o.z.get().reset$.subscribe((()=>{t()}));return()=>e.unsubscribe()}),[t])}function h(){return(0,r.V)(o.z.get())}const l=()=>{const t=function(){const[t,e]=(0,i.useState)(h());return(0,i.useEffect)((()=>{const t=o.z.get().$.subscribe((()=>{e(h())}));return()=>t.unsubscribe()}),[]),t}();return(0,n.jsx)("span",{style:{whiteSpace:"nowrap"},children:t})}},7365:(t,e,s)=>{s.d(e,{U:()=>o,_:()=>a});var n=s(5874),i=s(7589);function r(t,e){const s=[];for(let n=0;n({span:{start:t.start+m,end:t.end+m,line:t.line},type:"error-cell"})))),m+=t.expectedLine.length+1,p.push(t.expectedLine),f.push({span:{start:m,end:m+t.expectedLine.length,line:n},type:"correct-line"}),f.push(...t.correctCellSpans.map((t=>({span:{start:t.start+m,end:t.end+m,line:p.length},type:"correct-cell"})))),m+=t.givenLine.length+1):(p.push(u[n]),m+=u[n].length+1)}let y=p.join("\n");return y.endsWith("\n")&&(y=y.substring(0,y.length-1)),console.log(g),{text:y,failureNum:h.length,decorations:f,lineNumbers:g}}function c(t,e){const s=t.split("|").filter((t=>""!=t)),n=Array.from(s),i=[];let r=0;for(let c=0;c{s.d(e,{g:()=>i});var n=s(5874);async function i(t,e){try{const i=await t.readFile(e);let r;try{const s=e.replace("VME.tst",".tst").replace(".tst",".cmp");r=await t.readFile(s)}catch(s){}return(0,n.Ok)({tst:i,cmp:r})}catch(s){return(0,n._)(s)}}},4641:(t,e,s)=>{s.d(e,{V:()=>n});const n=t=>{if((t=>"function"===typeof t?.toString||"string"===typeof t)(t)){const e=t.toString();return"[object Object]"===e?JSON.stringify(t):e}return JSON.stringify(t)}},7721:(t,e,s)=>{s.d(e,{D4:()=>a,I8:()=>h,Z8:()=>l,gV:()=>c,p$:()=>r});var n=s(8739),i=s(7076);function r(){return{A:0,D:0,PC:0,ALU:0,flag:n.iI.Zero}}const o={c:32768,x1:36864,x2:36864,am:36864,op:4032,d1:32800,d2:32784,d3:32776,j1:32769,j2:32770,j3:32772};function a(t){function e(e){return(t&e)===e}return{c:e(o.c),x1:e(o.x1),x2:e(o.x2),am:e(o.am),op:(t&o.op)>>6,d1:e(o.d1),d2:e(o.d2),d3:e(o.d3),j1:e(o.j1),j2:e(o.j2),j3:e(o.j3)}}function c({inM:t,instruction:e},{A:s,D:i,PC:r}){const o=a(e),c=o.am?t:s,[h,l]=(0,n.v0)(o.op,i,c);return o.d2&&(i=h),[{A:s,D:i,PC:r+1,ALU:h,flag:l},o.d3,h]}function h({inM:t,instruction:e,reset:s},{A:i,D:r,PC:o,ALU:c,flag:h}){const l=a(e),u=l.j1&&h===n.iI.Positive,d=l.j2&&h===n.iI.Zero,p=l.j3&&h===n.iI.Negative;o=s?0:u||d||p?i:o,l.c?l.d1&&(i=c):i=32767&e;const m=l.am?t:i,f=(0,n.v0)(l.op,r,m);c=f[0],h=f[1];return[{addressM:i,outM:c,writeM:l.d3},{A:i,D:r,ALU:c,flag:h,PC:o}]}class l{RAM;ROM;Screen;Keyboard;#t=0;#e=0;#s=0;#n={A:0,D:0,PC:0,ALU:0,flag:n.iI.Zero};get state(){return this.#n}get PC(){return this.#t}get A(){return this.#e}get D(){return this.#s}setA(t){this.#e=t}setD(t){this.#s=t}setPC(t){this.#t=t}constructor({RAM:t=new i.XK,ROM:e}){this.RAM=t,this.ROM=e,this.Screen=new i.qN(this.RAM,i.RL,i.L7),this.Keyboard=new i.PC(this.RAM)}reset(){this.#t=0,this.#e=0,this.#s=0}tick(){const t=this.#e,e={inM:this.RAM.get(this.#e),instruction:this.ROM.get(this.#t),reset:!1},[s,i,r]=c(e,{A:this.#e,D:this.#s,PC:this.#t,ALU:this.#s,flag:n.iI.Zero});i&&this.RAM.set(t,r);const[o,{A:a,D:l,PC:u}]=h(e,s);this.#e=a,this.#s=l,this.#t=u}}},7589:(t,e,s)=>{s.d(e,{dl:()=>c});var n=s(9563),i=s(3977);const r="\nCmp <: Base {\n Root := line*\n line = bar cell+ newline?\n cell = cellvalue bar\n cellvalue = (~(bar|newline) any)*\n}",o=(0,n.qN)(r,i.lN),a=o.extendSemantics(i.JE);a.addAttribute("cell",{cell:(t,e)=>t.sourceString}),a.addAttribute("line",{line:(t,e,s)=>e.children.map((t=>t.cell))}),a.addAttribute("root",{Root:t=>t.children.map((t=>t.line))});const c={grammar:r,semantics:a,parser:o,parse:(0,i.Q5)(o,a)}},6554:(t,e,s)=>{s.d(e,{uG:()=>c});var n=s(9563),i=s(3977);const r='\nTst <: Base {\n Root := Tst\n Tst = (TstStatement | TstRepeat | TstWhile)+\n\n TstRepeat = Repeat Number? OpenBrace TstCommand+ CloseBrace\n TstWhile = While Condition OpenBrace TstCommand+ CloseBrace\n TstStatement = TstCommand\n\n TstCommand = TstOperation Separator\n Separator = (Semi | Bang | Comma)\n\n TstOperation =\n | TstFileOperation\n | TstOutputListOperation\n | TstEvalOperation\n | TstSetOperation\n | TstOutputOperation\n | TstEchoOperation\n | TstClearEchoOperation\n | TstLoadROMOperation\n\n TstLoadROMOperation = ROM32K Load FileName\n TstFileOperation = FileOperation FileName?\n TstOutputListOperation = "output-list" OutputFormat+\n OutputFormat = Name Index? FormatSpec?\n FormatSpec = percent FormatStyle wholeDec dot wholeDec dot wholeDec\n TstSetOperation = Set Name Index? Number\n Index = OpenSquare wholeDec? CloseSquare\n Condition = Value CompareOp Value\n TstEvalOperation = Eval | TickTock | Tick | Tock | VmStep\n TstOutputOperation = Output\n TstEchoOperation = Echo String\n TstClearEchoOperation = ClearEcho\n\n FileName = Name\n FileOperation = "load" | "output-file" | "compare-to"\n\n Set = "set"\n Eval = "eval"\n Tick = "tick"\n Tock = "tock"\n TickTock = "ticktock"\n VmStep = "vmstep"\n Echo = "echo"\n Repeat = "repeat"\n ClearEcho = "clear-echo"\n Output = "output"\n OutputList = "output-list"\n FormatStyle = "B"|"D"|"S"|"X"\n ROM32K = "ROM32K"\n Load = "load"\n While = "while"\n\n CompareOp = "<>" | "<=" | ">=" | "=" | "<" | ">"\n}',o=(0,n.qN)(r,i.lN),a=o.extendSemantics(i.JE);a.extendAttribute("value",{Index:(t,e,s)=>e?.child(0)?.value??-1}),a.extendAttribute("name",{FileName:({name:t})=>t}),a.addAttribute("index",{Index:(t,e,s)=>e.child(0)?.value??0}),a.addAttribute("formatSpec",{FormatSpec:(t,{sourceString:e},{value:s},n,{value:i},r,{value:o})=>({style:e,width:i,lpad:s,rpad:o})}),a.addAttribute("format",{OutputFormat:({name:t},e,s)=>({id:t,builtin:void 0!==e?.child(0),address:e?.child(0)?.value??-1,format:s?.child(0)?.formatSpec})}),a.addAttribute("operation",{TstEvalOperation:t=>({op:t.sourceString}),TstOutputOperation:t=>({op:"output"}),TstOutputListOperation:(t,e)=>({op:"output-list",spec:e.children.map((t=>t.format))}),TstSetOperation(t,{name:e},s,{value:n}){const i={op:"set",id:e,value:n},r=s.child(0)?.child(1)?.child(0);return r&&(i.index=r.value),i},TstEchoOperation:(t,e)=>({op:"echo",message:e.String}),TstClearEchoOperation:t=>({op:"clear-echo"}),TstLoadROMOperation:(t,e,{name:s})=>({op:"loadRom",file:s}),TstFileOperation:(t,e)=>({op:t.sourceString,file:e?.sourceString})}),a.addAttribute("command",{TstCommand(t,e){return{op:t.operation,separator:e.sourceString,span:(0,i.Ln)(this.source)}}}),a.addAttribute("condition",{Condition:({value:t},{sourceString:e},{value:s})=>({left:t,right:s,op:e})}),a.addAttribute("statement",{TstWhile(t,e,s,n,r){return{statements:n.children.map((t=>t.command)),condition:e.condition,span:(0,i.Ln)(this.source)}},TstRepeat(t,e,s,n,r){return{statements:n.children.map((t=>t.command)),count:e.sourceString?Number(e.sourceString):-1,span:(0,i.Ln)(this.source)}},TstStatement:t=>t.command}),a.addAttribute("tst",{Tst:t=>({lines:t.children.map((t=>t.statement))})}),a.addAttribute("root",{Root:({tst:t})=>t});const c={grammar:r,semantics:a,parser:o,parse:(0,i.Q5)(o,a)}},9976:(t,e,s)=>{s.d(e,{G:()=>u});var n=s(2469),i=s(1106),r=s(6418),o=s(4867),a=s(8783);function c(t){return void 0!==t.op}function h(t){return void 0!==t.condition}function l(t){const{op:e}=t;switch(e){case"tick":return new i.IJ;case"tock":return new i.CX;case"ticktock":return new r.z;case"eval":return new i.Nq;case"vmstep":return new a.a;case"output":return new o.ik;case"set":return new o.jl(t.id,t.value,t.index);case"output-list":return new o.Ad(t.spec);case"echo":return new o.S0(t.message);case"clear-echo":return new o.Tn;case"loadRom":return new o.fK(t.file);case"load":return new o.hh(t.file);case"output-file":case"compare-to":return;default:(0,n.H8)(e,`Unknown tst operation ${e}`)}}function u(t,e){let s,n=[],i=t,r=[];for(const a of e.lines){if(c(a))i=t,r=[a];else{const e=h(a)?new o.eB(new o.kW(a.condition.left,a.condition.right,a.condition.op)):new o.UM(a.count);e.span=a.span,t.addInstruction(e),i=e,r=a.statements}for(const t of r){const e=l(t.op);if(void 0!==e&&(void 0===s?s=a.span:s.end=a.span.end,i.addInstruction(e),n.push(e)),","!=t.separator){";"==t.separator?i.addInstruction(new o.fe(s??t.span)):"!"==t.separator&&i.addInstruction(new o.Ge(s??t.span));for(const e of n)e.span=s??t.span;s=void 0,n=[]}}}return t.reset(),t}},1106:(t,e,s)=>{s.d(e,{BX:()=>a,CX:()=>l,IJ:()=>h,Nq:()=>c});var n=s(9651),i=s(1487),r=s(9976),o=s(9937);class a extends o.V{chip=new n.ti;get chipId(){return this.chip.id}clock=i.z.get();static from(t,e){const s=new a(e);return(0,r.G)(s,t)}with(t){return this.chip=t,this}hasVar(t){return"time"===t||(t=`${t}`,this.chip.hasIn(t)||this.chip.hasOut(t))}getVar(t,e){if("time"===(t=`${t}`))return this.clock.toString();const s=this.chip.get(t,e);return s?s instanceof n.z7?s.busVoltage:s.voltage():0}getWidth(t,e){const s=this.chip.get(t,e);return s?s.width:0}setVar(t,e,s){const i=this.chip.get(t,s);i instanceof n.z7?i.busVoltage=e:i?.pull(0===e?n.$L:n.RY)}eval(){this.chip.eval()}tick(){this.chip.eval(),this.clock.tick()}tock(){this.chip.eval(),this.clock.tock()}async loadROM(t){await this.chip.load(this.fs,t)}async run(){this.clock.reset(),await super.run()}}class c{_chipTestInstruction_=!0;async do(t){t.eval()}*steps(){yield this}}class h{_chipTestInstruction_=!0;async do(t){t.tick()}*steps(){yield this}}class l{_chipTestInstruction_=!0;async do(t){t.tock()}*steps(){yield this}}},6418:(t,e,s)=>{s.d(e,{b:()=>a,z:()=>c});var n=s(7721),i=s(7076),r=s(9976),o=s(9937);class a extends o.V{cpu;ticks=0;static from(t,e,s){const n=new a(e,s);return(0,r.G)(n,t)}constructor(t=new i.n9,e){super(e),this.cpu=new n.Z8({ROM:t}),this.reset()}reset(){return super.reset(),this.cpu.reset(),this.ticks=0,this}hasVar(t){return"number"!==typeof t&&!("A"!==t&&"D"!==t&&"PC"!==t&&"time"!==t&&!t.startsWith("RAM"))}getVar(t,e){switch(t){case"A":return this.cpu.A;case"D":return this.cpu.D;case"PC":return this.cpu.PC;case"time":return this.ticks;case"RAM":return void 0===e?0:this.cpu.RAM.get(e)}if("number"===typeof t)return 0;if(t.startsWith("RAM")){const e=Number(t.substring(4,t.length-1));return this.cpu.RAM.get(e)}return 0}getWidth(t,e){return 16}setVar(t,e,s){switch(t){case"A":this.cpu.setA(e);break;case"D":this.cpu.setD(e);break;case"PC":this.cpu.setPC(e);break;case"RAM":this.cpu.RAM.set(s??0,e)}}ticktock(){this.ticks+=1,this.cpu.tick()}async loadROM(t){await this.cpu.ROM.load(this.fs,t)}}class c{_cpuTestInstruction_=!0;async do(t){t.ticktock()}*steps(){yield this}}},4867:(t,e,s)=>{s.d(e,{Ad:()=>c,Ge:()=>r,S0:()=>p,Tn:()=>m,UM:()=>l,eB:()=>d,fK:()=>f,fe:()=>i,hh:()=>g,ik:()=>a,jl:()=>o,kW:()=>u});class n{span;constructor(t){this.span=t}async do(){}*steps(){yield this}}class i extends n{}class r extends n{}class o{variable;value;index;constructor(t,e,s){this.variable=t,this.value=e,this.index=s}async do(t){t.setVar(this.variable,this.value,this.index)}*steps(){yield this}}class a{async do(t){t.output()}*steps(){yield this}}class c{outputs=[];constructor(t=[]){for(const e of t)this.addOutput(e)}addOutput(t){this.outputs.push({id:t.id,style:t.format?.style??"B",len:t.format?.width??-1,lpad:t.format?.lpad??1,rpad:t.format?.rpad??1,builtin:t.builtin,address:t.address})}async do(t){t.outputList(this.outputs),t.header()}*steps(){yield this}}class h{instructions=[];span;addInstruction(t){this.instructions.push(t)}async do(t){for(const e of this.instructions)e.do(t)}*steps(t){yield this}}class l extends h{repeat;constructor(t){super(),this.repeat=t}async do(){}*innerSteps(t){for(const e of this.instructions)yield*e.steps(t)}*steps(t){if(-1===this.repeat)for(yield this;;)yield*this.innerSteps(t);else for(let e=0;e":return`${e}`!==`${s}`}else switch(this.op){case"<":return e":return e>s;case">=":return e>=s;case"=":return e===s;case"<>":return e!==s}return!1}}class d extends h{condition;constructor(t){super(),this.condition=t}*steps(t){for(;this.condition.check(t);){yield this;for(const e of this.instructions)yield*e.steps(t)}}}class p{content;constructor(t){this.content=t}async do(t){t.echo(this.content)}*steps(){yield this}}class m{async do(t){t.clearEcho()}*steps(){yield this}}class f{file;constructor(t){this.file=t}async do(t){t.fs.pushd("/samples"),await t.loadROM(this.file),t.fs.popd()}*steps(){yield this}}class g{file;constructor(t){this.file=t}async do(t){await t.load(this.file)}*steps(){yield this}}},9937:(t,e,s)=>{s.d(e,{V:()=>c});var n=s(2469),i=s(4544),r=s(7844);class o{variable;fmt;lPad;rPad;len;index;builtin;constructor(t,e="%B1.1.1",s,i,r,o,a){if(this.variable=t,e.startsWith("%")&&void 0===s&&void 0===i&&void 0===r){const{fmt:t,lPad:s,rPad:n,len:i}=e.match(/^%(?[BDXS])(?\d+)\.(?\d+)\.(?\d+)$/)?.groups;this.fmt=t,this.lPad=parseInt(s),this.rPad=parseInt(n),this.len=parseInt(i),this.builtin=!1,this.index=-1}else(0,n.vA)(["B","X","D","S"].includes(e[0])),this.fmt=e[0],this.len=s??3,this.lPad=i??1,this.rPad=r??1,this.builtin=o??!1,this.index=a??-1}header(t){let e=`${this.variable}`;if(this.builtin){e=`${e}[${this.index>=0?this.index:""}]`}return e.length>this.len+this.lPad+this.rPad?e.substring(0,this.len+this.lPad+this.rPad):this.padCenter(e)}print(t){const e=t.getVar(this.variable,this.index);if("S"===this.fmt)return this.padLeft(e);const s=(0,{B:r.e5,D:r.FN,X:r.uh}[this.fmt])(e);return"D"===this.fmt?this.padRight(s):this.padLeft(s.slice(s.length-this.len))}padCenter(t){const e=this.lPad+this.len+this.rPad,s=Math.floor((e-t.length)/2),n=e-s-t.length,i=s+t.length,r=i+n;return t=(t=t.padStart(i)).padEnd(r)}padLeft(t){t=t.substring(0,this.len);const e=this.rPad+this.len,s=this.lPad+e;return t=(t=t.padEnd(e)).padStart(s)}padRight(t){t=t.substring(0,this.len);const e=this.lPad+this.len,s=this.rPad+e;return t=(t=t.padStart(e)).padEnd(s)}}var a=s(4867);class c{instructions=[];_outputList=[];_log="";fs=new i.Q2;doEcho;constructor(t){this.doEcho=t}setFileSystem(t){return this.fs=t,this}echo(t){this.doEcho?.(t)}clearEcho(){this.doEcho?.("")}async loadROM(t){}async load(t){}async compareTo(t){}outputFile(t){}createOutputs(t){return t.map((t=>{if(-1===t.len)if("time"===t.id)t.len=7,t.style="S";else{const e=this.getWidth(t.id,t.address);"B"===t.style?t.len=e:"D"===t.style?t.len=Math.ceil(Math.log(e)):"X"===t.style&&(t.len=Math.ceil(e/4))}return new o(t.id,t.style,t.len,t.lpad,t.rpad,t.builtin,t.address)}))}outputList(t){this._outputList=this.createOutputs(t)}addInstruction(t){this.instructions.push(t)}reset(){return this._steps=function*(t){for(const e of t.instructions)yield*e.steps(t)}(this),this._step=this._steps.next(),this._log="",this}_steps;_step;get steps(){return void 0===this._steps&&(this.reset(),this._steps=(0,n.Z1)(this._steps,"Reset did not initialize steps"),this._step=(0,n.Z1)(this._step,"Reset did not find first step")),this._steps}get currentStep(){return this._step?.value}get done(){return this._step?.done??!1}async step(){for(;!this._step.done;){if(await this._step.value.do(this),this._step=this.steps.next(),this._step.value instanceof a.fe)return this._step=this.steps.next(),!1;if(this._step.value instanceof a.Ge)return!0}return!0}async run(){for(this.reset();!await this.step(););}breakpoints=new Map;addBreakpoint(t,e){this.breakpoints.set(t,e)}clearBreakpoints(){this.breakpoints.clear()}output(){const t=this._outputList.map((t=>t.print(this)));this._log+=`|${t.join("|")}|\n`}header(){const t=this._outputList.map((t=>t.header(this)));this._log+=`|${t.join("|")}|\n`}log(){return this._log}}},8783:(t,e,s)=>{s.d(e,{Y:()=>a,a:()=>c});var n=s(7076),i=s(5087),r=s(9976),o=s(9937);class a extends o.V{vm=new i.Vm;loadAction;dir;static from(t,e,s,n){const i=new a(n);return i.dir=e?.split("/").slice(0,-1).join("/"),i.loadAction=s,(0,r.G)(i,t)}using(t){return this.fs=t,this}with(t){return this.vm=t,this}hasVar(t,e){return"string"!==typeof t&&(e=t,t="RAM"),"RAM"===t&&void 0!==e&&e>0&&e{s.d(e,{P:()=>o});var n=s(270),i=s(8032);function r(t,e){const s=[];for(let n=0;n{const[s,n]=r(t,2);return s*n&65535},nArgs:2,type:"function"},"Math.divide":{func:(t,e)=>{const[s,i]=r(t,2);return 0==i?(e.sys.error(n.X.DIVIDE_BY_ZERO),0):65535&Math.floor(s/i)},nArgs:2,type:"function"},"Math.min":{func:(t,e)=>{const[s,n]=r(t,2);return 65535&Math.min(s,n)},nArgs:2,type:"function"},"Math.max":{func:(t,e)=>{const[s,n]=r(t,2);return 65535&Math.max(s,n)},nArgs:2,type:"function"},"Math.sqrt":{func:(t,e)=>{const[s]=r(t,1);return s<0?(e.sys.error(n.X.SQRT_NEG),0):65535&Math.floor(Math.sqrt(s))},nArgs:1,type:"function"},"Math.abs":{func:(t,e)=>{const[s]=r(t,1);return 65535&Math.abs(s)},nArgs:1,type:"function"},"Screen.clearScreen":{func:(t,e)=>(e.screen.clear(),0),nArgs:0,type:"function"},"Screen.setColor":{func:(t,e)=>{const[s]=r(t,1);return e.screen.color=0!==s,0},nArgs:1,type:"function"},"Screen.drawPixel":{func:(t,e)=>{const[s,n]=r(t,2);return e.screen.drawPixel(s,n),0},nArgs:2,type:"function"},"Screen.drawLine":{func:(t,e)=>{const[s,n,i,o]=r(t,4);return e.screen.drawLine(s,n,i,o),0},nArgs:4,type:"function"},"Screen.drawRectangle":{func:(t,e)=>{const[s,n,i,o]=r(t,4);return e.screen.drawRect(s,n,i,o),0},nArgs:4,type:"function"},"Screen.drawCircle":{func:(t,e)=>{const[s,n,i]=r(t,3);return e.screen.drawCircle(s,n,i),0},nArgs:3,type:"function"},"Memory.peek":{func:(t,e)=>{const[s]=r(t,1);return t.get(s)},nArgs:1,type:"function"},"Memory.poke":{func:(t,e)=>{const[s,n]=r(t,2);return t.set(s,n),0},nArgs:2,type:"function"},"Memory.alloc":{func:(t,e)=>{const[s]=r(t,1);return e.memory.alloc(s)},nArgs:1,type:"function"},"Memory.deAlloc":{func:(t,e)=>{const[s]=r(t,1);return e.memory.deAlloc(s),0},nArgs:1,type:"function"},"Array.new":{func:(t,e)=>{const[s]=r(t,1);return s<=0?(e.sys.error(n.X.ARRAY_SIZE_NOT_POSITIVE),0):e.memory.alloc(s)},nArgs:1,type:"constructor"},"Array.dispose":{func:(t,e)=>{const[s]=r(t,1);return e.memory.deAlloc(s),0},nArgs:1,type:"method"},"String.new":{func:(t,e)=>{const[s]=r(t,1);return e.string.new(s)},nArgs:1,type:"constructor"},"String.dispose":{func:(t,e)=>{const[s]=r(t,1);return e.string.dispose(s),0},nArgs:1,type:"method"},"String.length":{func:(t,e)=>{const[s]=r(t,1);return e.string.length(s)},nArgs:1,type:"method"},"String.charAt":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.charAt(s,n)},nArgs:2,type:"method"},"String.setCharAt":{func:(t,e)=>{const[s,n,i]=r(t,3);return e.string.setCharAt(s,n,i),0},nArgs:3,type:"method"},"String.appendChar":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.appendChar(s,n)},nArgs:2,type:"method"},"String.eraseLastChar":{func:(t,e)=>{const[s]=r(t,1);return e.string.eraseLastChar(s),0},nArgs:1,type:"method"},"String.intValue":{func:(t,e)=>{const[s]=r(t,1);return e.string.intValue(s)},nArgs:1,type:"method"},"String.setInt":{func:(t,e)=>{const[s,n]=r(t,2);return e.string.setInt(s,n),0},nArgs:2,type:"method"},"String.backSpace":{func:(t,e)=>i.G_,nArgs:0,type:"function"},"String.doubleQuote":{func:(t,e)=>i.MD,nArgs:0,type:"function"},"String.newLine":{func:(t,e)=>i.qK,nArgs:0,type:"function"},"Output.moveCursor":{func:(t,e)=>{const[s,n]=r(t,2);return e.output.moveCursor(s,n),0},nArgs:2,type:"function"},"Output.printChar":{func:(t,e)=>{const[s]=r(t,1);return e.output.printChar(s),0},nArgs:1,type:"function"},"Output.printString":{func:(t,e)=>{const[s]=r(t,1);return e.output.printString(s),0},nArgs:1,type:"function"},"Output.printInt":{func:(t,e)=>{const[s]=r(t,1);return e.output.printInt(s),0},nArgs:1,type:"function"},"Output.println":{func:(t,e)=>(e.output.println(),0),nArgs:0,type:"function"},"Output.backSpace":{func:(t,e)=>(e.output.backspace(),0),nArgs:0,type:"function"},"Keyboard.keyPressed":{func:(t,e)=>e.keyboard.keyPressed(),nArgs:0,type:"function"},"Keyboard.readChar":{func:(t,e)=>(e.keyboard.readChar(),0),nArgs:0,type:"function"},"Keyboard.readLine":{func:(t,e)=>{const[s]=r(t,1);return e.keyboard.readLine(s),0},nArgs:1,type:"function"},"Keyboard.readInt":{func:(t,e)=>{const[s]=r(t,1);return e.keyboard.readInt(s),0},nArgs:1,type:"function"},"Sys.halt":{func:(t,e)=>(e.sys.halt(),0),nArgs:0,type:"function"},"Sys.error":{func:(t,e)=>{const[s]=r(t,1);return e.sys.error(s),0},nArgs:1,type:"function"},"Sys.wait":{func:(t,e)=>{const[s]=r(t,1);return e.sys.wait(s),0},nArgs:1,type:"function"}}},270:(t,e,s)=>{var n;function i(t){return Object.values(n).includes(t)}s.d(e,{U:()=>i,X:()=>n}),function(t){t[t.SYS_WAIT_DURATION_NOT_POSITIVE=1]="SYS_WAIT_DURATION_NOT_POSITIVE",t[t.ARRAY_SIZE_NOT_POSITIVE=2]="ARRAY_SIZE_NOT_POSITIVE",t[t.DIVIDE_BY_ZERO=3]="DIVIDE_BY_ZERO",t[t.SQRT_NEG=4]="SQRT_NEG",t[t.ALLOC_SIZE_NOT_POSITIVE=5]="ALLOC_SIZE_NOT_POSITIVE",t[t.HEAP_OVERFLOW=6]="HEAP_OVERFLOW",t[t.ILLEGAL_PIXEL_COORD=7]="ILLEGAL_PIXEL_COORD",t[t.ILLEGAL_LINE_COORD=8]="ILLEGAL_LINE_COORD",t[t.ILLEGAL_RECT_COORD=9]="ILLEGAL_RECT_COORD",t[t.ILLEGAL_CENTER_COORD=12]="ILLEGAL_CENTER_COORD",t[t.ILLEGAL_RADIUS=13]="ILLEGAL_RADIUS",t[t.STRING_LENGTH_NEG=14]="STRING_LENGTH_NEG",t[t.GET_CHAR_INDEX_OUT_OF_BOUNDS=15]="GET_CHAR_INDEX_OUT_OF_BOUNDS",t[t.SET_CHAR_INDEX_OUT_OF_BOUNDS=16]="SET_CHAR_INDEX_OUT_OF_BOUNDS",t[t.STRING_FULL=17]="STRING_FULL",t[t.STRING_EMPTY=18]="STRING_EMPTY",t[t.STRING_INSUFFICIENT_CAPACITY=19]="STRING_INSUFFICIENT_CAPACITY",t[t.ILLEGAL_CURSOR_LOCATION=20]="ILLEGAL_CURSOR_LOCATION"}(n||(n={}))},8032:(t,e,s)=>{s.d(e,{Fz:()=>h,G_:()=>r,MD:()=>o,eY:()=>c,qK:()=>i});var n=s(270);const i=128,r=129,o=34;function a(t){return t-48}function c(t){return t.toString().split("").map((t=>Number(t)+48))}class h{memory;os;constructor(t,e){this.memory=t,this.os=e}new(t){t<=0&&this.os.sys.error(n.X.STRING_LENGTH_NEG);const e=this.os.memory.alloc(t+2);return this.os.sys.halted?0:(this.memory.set(e,t),this.memory.set(e+1,0),e)}dispose(t){this.os.memory.deAlloc(t)}maxLength(t){return this.memory.get(t)}length(t){return this.memory.get(t+1)}setLength(t,e){this.memory.set(t+1,e)}charAt(t,e){return e<0||e>=this.length(t)?(this.os.sys.error(n.X.GET_CHAR_INDEX_OUT_OF_BOUNDS),0):this.memory.get(t+e+2)}setCharAt(t,e,s){e<0||e>=this.length(t)?this.os.sys.error(n.X.SET_CHAR_INDEX_OUT_OF_BOUNDS):this.memory.set(t+e+2,s)}appendChar(t,e){const s=this.length(t);return s==this.maxLength(t)?(this.os.sys.error(n.X.STRING_FULL),0):(this.setLength(t,s+1),this.setCharAt(t,s,e),t)}eraseLastChar(t){const e=this.length(t);0!=e?this.setLength(t,e-1):this.os.sys.error(n.X.STRING_EMPTY)}intValue(t){const e=[];for(let n=0;n=48&&s<=57);n++)e.push(a(this.charAt(t,n)));var s;return e.reduce(((t,e)=>10*t+e),0)}setInt(t,e){const s=c(e);if(s.length>this.maxLength(t))this.os.sys.error(n.X.STRING_INSUFFICIENT_CAPACITY);else{this.setLength(t,0);for(const e of s)this.appendChar(t,e)}}}},5087:(t,e,s)=>{s.d(e,{IG:()=>S,h0:()=>x,Vm:()=>w});var n=s(5874),i=s(3977),r=s(2548),o=s(7076);class a extends o.XK{strict=!0;get SP(){return this.get(0)}set SP(t){this.set(0,t)}get LCL(){return this.get(1)}set LCL(t){this.set(1,t)}get ARG(){return this.get(2)}set ARG(t){this.set(2,t)}get THIS(){return this.get(3)}set THIS(t){this.set(3,t)}get THAT(){return this.get(4)}set THAT(t){this.set(4,t)}get statics(){const t=[];for(let e=16;e<256;e++)t.push(this.get(e));return t}constructor(){super(),this.set(0,256)}baseSegment(t,e){if(this.strict&&(e<0||e>32767))return(0,n._)(new Error(`Illegal offset value ${e} (must be between 0 and 32767)`));switch(t){case"argument":return(0,n.Ok)(this.ARG+e);case"constant":return(0,n.Ok)(e);case"local":return(0,n.Ok)(this.LCL+e);case"pointer":if(this.strict&&e>1)throw new Error(`pointer out of bounds access (pointer can be 0 for this, 1 for that, but got ${e}`);return(0,n.Ok)(0===e?3:4);case"static":return this.strict&&e>239?(0,n._)(new Error(`Cannot access statics beyond 239: ${e}`)):(0,n.Ok)(16+e);case"temp":return this.strict&&e>7?(0,n._)(new Error(`Temp out of bounds access (temp can be 0 to 7, but got ${e}`)):(0,n.Ok)(5+e);case"that":return(0,n.Ok)(this.THAT+e);case"this":return(0,n.Ok)(this.THIS+e)}}getSegment(t,e){if("constant"===t){if(this.strict&&(e<0||e>32767))throw new Error(`Illegal offset value ${e} (must be between 0 and 32767)`);return e}const s=this.baseSegment(t,e);if((0,n.ys)(s))throw(0,n._)(s);return this.get((0,n.Ok)(s))}setSegment(t,e,s){const i=this.baseSegment(t,e);if((0,n.ys)(i))throw(0,n._)(i);this.set((0,n.Ok)(i),s)}argument(t){return this.getSegment("argument",t)}local(t){return this.getSegment("local",t)}static(t){return this.getSegment("static",t)}constant(t){return this.getSegment("constant",t)}this(t){return this.getSegment("this",t)}that(t){return this.getSegment("that",t)}pointer(t){return this.getSegment("pointer",t)}temp(t){return this.getSegment("temp",t)}push(t){const e=this.SP;this.set(e,t),this.set(0,e+1)}pop(){if(this.strict&&256===this.SP)throw new Error("Cannot pop the stack below 256 in strict mode");this.set(0,this.SP-1);return this.get(this.SP)}pushFrame(t,e,s){const n=this.SP,i=n-e;this.set(n,t),this.set(n+1,this.LCL),this.set(n+2,this.ARG),this.set(n+3,this.THIS),this.set(n+4,this.THAT),this.set(2,i),this.set(1,n+5);const r=n+5;for(let o=0;oe),o,o+e)]},locals:{base:a,count:s,values:[...this.map(((t,e)=>e),a,a+s)]},stack:{base:c,count:h,values:[...this.map(((t,e)=>e),c,c+h)]},this:{base:c,count:n,values:[...this.map(((t,e)=>e),this.THIS,this.THIS+n)]},that:{base:c,count:i,values:[...this.map(((t,e)=>e),this.THAT,this.THAT+i)]},frame:{RET:this.get(t),LCL:this.LCL,ARG:this.ARG,THIS:this.THIS,THAT:this.THAT}}}getVmState(t=240){const e=[...this.map(((t,e)=>e),5,13)],s=[...this.map(((t,e)=>e),13,16)],n=[...this.map(((t,e)=>e),16,16+t)];return{"0: SP":this.SP,"1: LCL":this.LCL,"2: ARG":this.ARG,"3: THIS":this.THIS,"4: THAT":this.THAT,temps:e,internal:s,static:n}}binOp(t){const e=65535&t(this.get(this.SP-2),this.get(this.SP-1));this.set(this.SP-2,e),this.set(0,this.SP-1)}unOp(t){const e=65535&t(this.get(this.SP-1));this.set(this.SP-1,e)}comp(t){this.binOp(((e,s)=>t(e,s)?-1:0))}}var c=s(8032);class h{memory;os;animationFrameId=void 0;cancel=!1;constructor(t,e){this.memory=t,this.os=e}keyPressed(){return this.memory.get(o.ky)}readCharLoop(t){let e=!1,s=0;const n=()=>{if(this.cancel)return;let i=!1;this.os.paused||(e||0===this.keyPressed()||(e=!0,s=this.keyPressed()),e&&0===this.keyPressed()&&(i=!0,t(s))),i||(this.animationFrameId=requestAnimationFrame(n))};n()}readChar(){this.os.sys.block(),this.os.output.drawCursor(),new Promise((t=>{this.readCharLoop(t)})).then((t=>{this.os.output.printChar(t),this.os.sys.release(t)}))}readLineLoop(t){const e=this.os.string.new(100);this.os.sys.halted&&t(0);let s=!1,n=0;const i=()=>{if(this.cancel)return;let r=!1;this.os.paused||(s||0==this.keyPressed()||(s=!0,n=this.keyPressed()),s&&0==this.keyPressed()&&(s=!1,n==c.G_?(this.os.string.length(e)>0&&this.os.output.backspace(),this.os.string.eraseLastChar(e)):n==c.qK?(t(e),r=!0):(this.os.string.appendChar(e,n),this.os.sys.halted&&t(0),this.os.output.printChar(n),this.os.output.drawCursor()))),r||(this.animationFrameId=requestAnimationFrame(i))};i()}readLine(t){this.os.sys.block(),this.os.output.printString(t),this.os.output.drawCursor(),new Promise((t=>{this.readLineLoop(t)})).then((t=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(t)}))}readInt(t){this.os.sys.block(),this.os.output.printString(t),this.os.output.drawCursor(),new Promise((t=>{this.readLineLoop(t)})).then((t=>{this.os.sys.halted||(this.os.output.clearChar(),this.os.output.println()),this.os.sys.release(this.os.string.intValue(t))}))}dispose(){this.cancel=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}var l=s(270);class u{memory;os;freeSegments=[{address:2048,length:14336}];constructor(t,e){this.memory=t,this.os=e}alloc(t){if(t<=0)return this.os.sys.error(l.X.ARRAY_SIZE_NOT_POSITIVE),0;for(let e=0;e=t){const n=s.address;return s.address+=t+1,s.length-=t+1,0===s.length&&this.freeSegments.splice(e,1),this.memory.set(n,t),n+1}}return this.os.sys.error(l.X.HEAP_OVERFLOW),0}deAlloc(t){const e=this.memory.get(t-1);this.freeSegments.push({address:t-1,length:e+1})}}const d=function(){const t=new Array(126);return t[32]=p([" "," "," "," "," "," "," "," "," "," "," "]),t[33]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[34]=p([" \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588 \u2588 "," "," "," "," "," "," "," "," "]),t[35]=p([" "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," \u2588 \u2588 "," "," "]),t[36]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[37]=p([" "," ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," "," "]),t[38]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[39]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[40]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[41]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[42]=p([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "," "]),t[43]=p([" "," "," "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),t[44]=p([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[45]=p([" "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "," "]),t[46]=p([" "," "," "," "," "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[47]=p([" "," "," \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588 "," "," "]),t[48]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),t[49]=p([" \u2588\u2588 "," \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[50]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[51]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[52]=p([" \u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588 \u2588\u2588 ","\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[53]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[54]=p([" \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[55]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[56]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[57]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[58]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," "]),t[59]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[60]=p([" "," "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[61]=p([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "," "," "]),t[62]=p([" "," ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 "," "," "]),t[64]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[63]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[65]=p([" \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[66]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[67]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[68]=p(["\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),t[69]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[70]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),t[71]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," "," "]),t[72]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[73]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[74]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[75]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[76]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[77]=p(["\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[78]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[79]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[80]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "," "]),t[81]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "]),t[82]=p(["\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[83]=p([" \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[84]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588 \u2588\u2588 \u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[85]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[86]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[87]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),t[88]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[89]=p(["\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[90]=p(["\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[91]=p([" \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[92]=p([" "," ","\u2588 ","\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588 "," "," "]),t[94]=p([" \u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[95]=p([" "," "," "," "," "," "," "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "]),t[96]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "," "," "," "," "," "," "]),t[97]=p([" "," "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[98]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[99]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[100]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[101]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[102]=p([" \u2588\u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "," "]),t[103]=p([" "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),t[104]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[105]=p([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[106]=p([" \u2588\u2588 "," \u2588\u2588 "," "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "]),t[107]=p(["\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[108]=p([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[109]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 ","\u2588\u2588 \u2588 \u2588 "," "," "]),t[110]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[111]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[112]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 "," "]),t[113]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "]),t[114]=p([" "," "," ","\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 ","\u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),t[115]=p([" "," "," "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," "," "]),t[116]=p([" \u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[117]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 \u2588\u2588 "," "," "]),t[118]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," "," "]),t[119]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," \u2588 \u2588 "," "," "]),t[120]=p([" "," "," ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," "," "]),t[121]=p([" "," "," ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588\u2588 "," "]),t[122]=p([" "," "," ","\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2588\u2588 \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588 \u2588\u2588 ","\u2588\u2588\u2588\u2588\u2588\u2588 "," "," "]),t[123]=p([" \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," "," "]),t[124]=p([" \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," "," "]),t[125]=p(["\u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 "," \u2588\u2588 ","\u2588\u2588\u2588 "," "," "]),t[126]=p([" \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 \u2588 ","\u2588 \u2588\u2588 "," "," "," "," "," "," "," "," "]),t}();function p(t){return t.map((t=>t.split("").map((t=>"\u2588"==t))))}const m=new Array(o.RL).fill(0),f=!0;class g{memory;os;color=f;constructor(t,e){this.memory=t,this.os=e}clear(){this.memory.screen.loadBytes(m)}outOfBounds(t,e){return t<0||t>16*o.pc||e<0||e>o.dh}drawPixel(t,e){if(this.outOfBounds(t,e))return void this.os.sys.error(l.X.ILLEGAL_PIXEL_COORD);const s=32*e+Math.floor(t/16);let n=this.memory.screen.get(s);this.color?n|=1<181)this.os.sys.error(l.X.ILLEGAL_RADIUS);else for(let n=-s;n<=s;n++)this.drawLine(t-Math.floor(Math.sqrt(s*s-n*n)),e+n,t+Math.floor(Math.sqrt(s*s-n*n)),e+n)}}class y{os;col=0;row=0;lastColor=!1;constructor(t){this.os=t}setColor(t){this.lastColor=this.os.screen.color,this.os.screen.color=t}restoreColor(){this.os.screen.color=this.lastColor}clearChar(){this.setColor(false),this.os.screen.drawRect(8*this.col,11*this.row,8*(this.col+1),11*(this.row+1)),this.restoreColor()}moveCursor(t,e){t<0||t>22||e<0||e>64?this.os.sys.error(l.X.ILLEGAL_CURSOR_LOCATION):(this.row=t,this.col=e,this.drawCursor())}println(){this.row+=1,this.col=0}drawCursor(){this.clearChar(),this.setColor(f),this.os.screen.drawRect(8*this.col+2,11*this.row+2,8*(this.col+1)-2,11*(this.row+1)-2),this.restoreColor()}printChar(t){const e=d[t];if(e){this.clearChar(),this.setColor(f);for(let t=0;t{this.cancelWait||(e+=n,e>=t?this.release():this.animationFrameId=requestAnimationFrame(s))};s(0)}halt(){this._halted=!0,this._exitCode=0}error(t){this.os.output.printJsString(`ERR${t}`),this._halted=!0,this._exitCode=t}dispose(){this.cancelWait=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}}class v{vmMemory;screen;memory;string;output;keyboard;sys;paused=!1;constructor(t){this.vmMemory=t,this.screen=new g(this.vmMemory,this),this.memory=new u(this.vmMemory,this),this.string=new c.Fz(this.vmMemory,this),this.output=new y(this),this.keyboard=new h(this.vmMemory,this),this.sys=new b(this)}dispose(){this.keyboard.dispose(),this.sys.dispose()}}const S="__implicit",x={name:"Sys.init",labels:{},nVars:0,opBase:0,operations:[{op:"function",name:"Sys.init",nVars:0},{op:"call",name:"Main.main",nArgs:0}]};class w{memory=new a;os=new v(this.memory);functionMap={};executionStack=[];entry="";segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}};functions=[];program=[];addedSysInit=!1;staticCount=0;statics={};getStaticCount(){return this.staticCount}returnLine=void 0;registerStatic(t,e){const s=t.split(".")[0],n=this.statics[s]??[];this.statics[s]=n;const i=n[e]??this.staticCount++;return n[e]=i,i}registerStatics(){for(const t of Object.values(this.functionMap))for(const e of t.operations)"push"!==e.op&&"pop"!==e.op||"static"!==e?.segment||(e.offset=this.registerStatic(t.name,e.offset))}static validateFile(t){for(const e of t.instructions)if("function"==e.op){const s=e.name.split(".");if(2!=s.length)return(0,n._)((0,i.$5)(`Illegal subroutine name ${e.name} (Expected .)`,e.span));if(s[0]!=t.name)return(0,n._)((0,i.$5)(`File name ${t.name} doesn't match class name ${s[0]} (at ${e.name})`,e.span))}return(0,n.Ok)()}static validateFiles(t){const e=new Set;for(const s of t){if(e.has(s.name))return(0,n._)((0,i.$5)(`File ${s.name} already exists`));const t=this.validateFile(s);if((0,n.ys)(t))return t;e.add(s.name)}return(0,n.Ok)()}validateStackInstructions(){for(const t of Object.values(this.functionMap))for(const e of t.operations)if("pop"==e.op||"push"==e.op){const t=this.memory.baseSegment(e.segment,e.offset);if((0,n.ys)(t))return(0,n._)((0,i.$5)((0,n._)(t).message,e.span))}return(0,n.Ok)()}static validateFunctions(t){const e=new Set,s=[];for(const r of t){if("function"==r.op){if(r.nVars<0||r.nVars>32767)return(0,n._)((0,i.$5)(`Illegal number of local variables ${r.nVars} (Expected 0-32767)`,r.span));e.add(r.name)}if("call"==r.op){if(r.nArgs<0||r.nArgs>32767)return(0,n._)((0,i.$5)(`Illegal number of arguments ${r.nArgs} (Expected 0-32767)`,r.span));s.push(r)}}for(const o of s)if(!e.has(o.name)){if(!r.P[o.name])return(0,n._)((0,i.$5)(`Undefined function ${o.name}`,o.span));if(r.P[o.name].nArgs!=o.nArgs)return(0,n._)((0,i.$5)(`OS function ${o.name} expects ${r.P[o.name].nArgs} arguments, not ${o.nArgs}`,o.span))}return(0,n.Ok)()}static buildFromFiles(t){let e=this.validateFiles(t);if((0,n.ys)(e))return e;const s=t.map((t=>t.instructions)).reduce(((t,e)=>t.concat(e)));if(e=this.validateFunctions(s),(0,n.ys)(e))return e;const i=new w,r=i.load(s);return(0,n.ys)(r)?r:i.bootstrap()}static build(t){const e=this.validateFunctions(t);if((0,n.ys)(e))return e;const s=new w,i=s.load(t);return(0,n.ys)(i)?i:s.bootstrap()}static buildFunction(t,e){if("function"!==t[e].op)throw new Error("Only call buildFunction at the initial Function instruction");const{name:s,nVars:r}=t[e],o={name:s,nVars:r,labels:{},operations:[{op:"function",name:s,nVars:r,span:t[e].span}],opBase:0},a=new Set,c={};e+=1;t:for(;ethis.currentFunction.operations.length)throw new Error(`Current operation step beyond end of function operations (${this.invocation.opPtr} > ${this.currentFunction.operations.length})`);return this.currentFunction.operations[this.invocation.opPtr]}}load(t,e=!1){e&&(this.functionMap={},this.statics={},this.staticCount=0),"function"!==t[0]?.op&&t.unshift({op:"function",name:S,nVars:0});let s=0;for(;st.name===this.entry?-1:e.name===this.entry?1:0));let t=0;return this.program=this.functions.reduce(((e,s)=>(s.name!=x.name&&(s.opBase=t),t+=s.operations.length,e.concat(s.operations))),[]),this.reset(),(0,n.Ok)(this)}reset(){this.executionStack=[{function:this.entry,opPtr:1,frameBase:256,nArgs:0,thisInitialized:!1,thatInitialized:!1}],this.memory.reset(),this.memory.SP=256,this.segmentInitializations={local:{initialized:!1,n:0},argument:{initialized:!1,n:0}},this.os.dispose(),this.os=new v(this.memory)}validateStackOp(t){if(this.currentFunction?.name==this.entry){for(const e of["local","argument"])if(t.segment==e){if(this.segmentInitializations[e].initialized)return void(this.segmentInitializations[e].n=Math.max(t.offset+1,this.segmentInitializations[e].n));throw new Error(`The ${e} segment cannot be accessed since it was not initialized`)}if("this"==t.segment&&this.invocation.thisInitialized)return void(this.invocation.thisN=Math.max(t.offset+1,this.invocation.thisN??0))}if("argument"==t.segment&&t.offset>=this.invocation.nArgs)throw new Error("Argument offset out of bounds");if("local"==t.segment&&t.offset>=this.functionMap[this.invocation.function]?.nVars)throw new Error("Local offset out of bounds");if("this"==t.segment&&!this.invocation.thisInitialized)throw new Error("The this segment cannot be accessed since it was not initialized");if("that"==t.segment&&!this.invocation.thatInitialized)throw new Error("The that segment cannot be accessed since it was not initialized")}setPaused(t=!0){this.os.paused=t}step(){if(this.os.sys.halted)return this.os.sys.exitCode;if(this.os.sys.blocked)return;if(this.os.sys.released&&"call"==this.operation?.op){const t=this.os.sys.readReturnValue(),e=this.memory.SP-this.operation.nArgs;return this.memory.set(e,t),this.memory.SP=e+1,void(this.invocation.opPtr+=1)}if(void 0==this.operation)return this.os.sys.halt(),this.step();const t=this.operation;if("label"===t.op)return this.invocation.opPtr+=1,this.step();switch(t.op){case"push":{this.validateStackOp(t);const e=this.memory.getSegment(t.segment,t.offset);this.memory.push(e);break}case"pop":{this.validateStackOp(t);const e=this.memory.pop();this.memory.setSegment(t.segment,t.offset,e),"pointer"==t.segment&&(0==t.offset?(this.invocation.thisInitialized=!0,this.invocation.thisN=this.memory.get(this.memory.THIS-1)):1==t.offset&&(this.invocation.thatInitialized=!0));break}case"add":this.memory.binOp(((t,e)=>t+e));break;case"sub":this.memory.binOp(((t,e)=>t-e));break;case"neg":this.memory.unOp((t=>-t));break;case"and":this.memory.binOp(((t,e)=>t&e));break;case"or":this.memory.binOp(((t,e)=>t|e));break;case"not":this.memory.unOp((t=>~t));break;case"eq":this.memory.comp(((t,e)=>t===e));break;case"lt":this.memory.comp(((t,e)=>tt>e));break;case"goto":this.goto(t.label);break;case"if-goto":0!=this.memory.pop()&&this.goto(t.label);break;case"call":{const e=t.name;if(this.functionMap[e]){const s=this.memory.pushFrame(this.invocation.opPtr,t.nArgs,this.functionMap[e].nVars);this.executionStack.push({function:e,opPtr:0,nArgs:t.nArgs,frameBase:s,thisInitialized:!1,thatInitialized:!1})}else if(r.P[e]){const s=r.P[e].func(this.memory,this.os);if(this.os.sys.blocked)return;const n=this.memory.SP-t.nArgs;this.memory.set(n,s),this.memory.SP=n+1}break}case"return":{const t=this.derivedLine();this.executionStack.pop();const e=this.memory.popFrame();if(this.invocation.opPtr=e,0===this.executionStack.length)return this.returnLine=t,0;break}}this.invocation.opPtr+=1}goto(t){if(this.currentFunction){if(void 0===this.currentFunction.labels[t])throw new Error(`Attempting GOTO to unknown label ${t} in ${this.currentFunction.name}`);this.invocation.opPtr=this.currentFunction.labels[t]}}write(t){t.map((([t,e])=>{this.memory.set(t,e)}))}read(t){return t.map((t=>this.memory.get(t)))}vmStack(){return this.executionStack.map(((t,e)=>{const s=this.executionStack[e+1],n=s?s.frameBase-s.nArgs:this.memory.get(0);return this.makeFrame(t,n)}))}getUsedSegments(t){const e=new Set;for(const s of this.functionMap[t.function].operations)"push"!==s.op&&"pop"!=s.op||e.add(s.segment);return e}makeFrame(t=this.invocation,e){const s=this.functionMap[t.function];if(s.name===this.entry){const e=256+s.nVars,n=this.executionStack[1],i=n?n.frameBase-n.nArgs:this.memory.get(0),{ARG:r,LCL:o,THAT:a,THIS:c}=this.memory,h=this.segmentInitializations.argument.n,l=this.segmentInitializations.local.n,u=this.invocation.thisN??0;return{fn:s,args:{base:r,count:h,values:[...this.memory.map(((t,e)=>e),r,r+h)]},locals:{base:o,count:l,values:[...this.memory.map(((t,e)=>e),o,o+l)]},stack:{base:256,count:i-e,values:[...this.memory.map(((t,e)=>e),e,i)]},this:{base:c,count:u,values:[...this.memory.map(((t,e)=>e),c,c+u)]},that:{base:a,count:1,values:[this.memory.THAT]},frame:{ARG:r,LCL:o,RET:65535,THAT:a,THIS:c},usedSegments:this.getUsedSegments(t)}}const n=this.memory.getFrame(t.frameBase,t.nArgs,s.nVars,this.invocation.thisN??0,1,e);return n.fn=s,n.usedSegments=this.getUsedSegments(t),n}derivedLine(){return this.operation?.span?.line??this.returnLine??0}writeDebug(){const t=this.derivedLine(),e=Math.max(t-5,0),s=Math.min(t+3,this.program.length),n=this.program.slice(e,s).map(((s,n)=>`${n===t-e?"->":" "} ${function(t){switch(t.op){case"add":case"and":case"sub":case"eq":case"gt":case"lt":case"neg":case"not":case"or":case"return":return` ${t.op}`;case"goto":return` ${t.op} ${t.label}`;case"if-goto":return` ${t.op} ${t.label}`;case"label":return`${t.op} ${t.label}`;case"call":return` ${t.op} ${t.name} ${t.nArgs}`;case"function":return`${t.op} ${t.name} ${t.nVars}`;case"pop":return` ${t.op} ${t.segment} ${t.offset}`;case"push":return` ${t.op} ${t.segment} ${t.offset}`}}(s)}`)).join("\n"),i=this.vmStack().at(-1);return i?n+"\n\n"+function(t){return[`Frame: ${t.fn?.name??"Unknown Fn"} ARG:${t.frame.ARG} LCL:${t.frame.LCL}`,`Args: ${A(t.args)}`,`Lcls: ${A(t.locals)}`,`Stck: ${A(t.stack)}`].join("\n")}(i):n}}function A(t){return`[${t.base};${t.count}][${t.values.join(", ")}]`}}}]); \ No newline at end of file diff --git a/static/js/main.9fb233e1.js b/static/js/main.64a1b230.js similarity index 99% rename from static/js/main.9fb233e1.js rename to static/js/main.64a1b230.js index 293c0be1..09fb4346 100644 --- a/static/js/main.9fb233e1.js +++ b/static/js/main.64a1b230.js @@ -1,2 +1,2 @@ -/*! For license information please see main.9fb233e1.js.LICENSE.txt */ -(()=>{"use strict";var e={8029:(e,t,n)=>{n.d(t,{BR:()=>d,Us:()=>c});var r=n(4544),a=n(8878),l=n(3508),o=n(6073),i=n(5270);function u(){const e=!0,[t,n]=(0,a.useState)(e),r=(0,a.useCallback)((e=>{n(!!e)}),[e]);return{canUse:e,wants:t,toggle:r}}function s(){const[e,t]=(0,a.useState)(),[n,r]=(0,a.useState)(),[l,o]=(0,a.useState)("asm"),[i,u]=(0,a.useState)(),[s,c]=(0,a.useState)(),[d,f]=(0,a.useState)(),[p,h]=(0,a.useState)(),[m,g]=(0,a.useState)(),[v,y]=(0,a.useState)(!1);return{cpuState:{rom:e,file:n,format:l},setCpuState:(e,n,a)=>{r(e),t(n),o(a)},asmState:i,setAsmState:u,vm:{files:d,title:s,setFiles:f,setTitle:c},compiler:{title:p,setTitle:h,fs:m,setFs:g,compiled:v,setCompiled:y,reset:()=>{h(void 0),g(void 0),y(!1)}}}}function c(e=new r.Q2){const[t,n]=(0,a.useState)("system"),[c,d]=(0,a.useState)();return{monaco:u(),settings:(0,l.s)(),filePicker:(0,o.g3)(),tracking:(0,i.z1)(),theme:t,setTheme:n,toolStates:s(),title:c,setTitle:d}}const d=(0,a.createContext)({monaco:{canUse:!0,wants:!0,toggle(){}},filePicker:{close(){},open(){},select:e=>Promise.reject(""),isOpen:!1,suffix:void 0},settings:{close(){},open(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept(){},reject(){},trackEvent(){},trackPage(){}},theme:"system",setTheme(){},title:void 0,setTitle(){},toolStates:{cpuState:{rom:void 0,file:void 0,format:"asm"},setCpuState(){},asmState:{asm:"",path:void 0,translating:!1,current:-1,resultHighlight:void 0,sourceHighlight:void 0,symbols:[],result:"",compare:"",compareName:void 0,lineNumbers:[],compareError:!1},setAsmState(){},vm:{files:void 0,title:void 0,setFiles:()=>{},setTitle:()=>{}},compiler:{title:void 0,setTitle:()=>{},fs:void 0,setFs:()=>{},compiled:!1,setCompiled:()=>!1,reset:()=>{}}}})},3015:(e,t,n)=>{n.d(t,{I:()=>a});var r=n(782);const a=({name:e})=>(0,r.jsx)("span",{className:"material-symbols-outlined",children:e})},3508:(e,t,n)=>{n.d(t,{s:()=>a});var r=n(8878);function a(){const[e,t]=(0,r.useState)(!1);return{isOpen:e,open(){t(!0)},close(){t(!1)}}}},6073:(e,t,n)=>{n.d(t,{Nk:()=>g,g3:()=>f});var r=n(6458),a=n(910),l=n(8878),o=n(8029),i=n(3015),u=n(3508),s=n(3569),c=n(782);const d="file selected";function f(){const e=(0,u.s)(),[t,n]=(0,l.useState)(),[r,a]=(0,l.useState)(!1),o=(0,l.useRef)(!1),i=(0,l.useRef)(),s=(0,l.useCallback)((async t=>{var r;return"string"===typeof t.suffix&&(t.suffix=[t.suffix]),n(t.suffix),a(null!==(r=t.allowFolders)&&void 0!==r&&r),e.open(),new Promise((e=>{i.current=e}))}),[e,i]);return{...e,select:async e=>(o.current=!1,await s(e)),selectAllowLocal:async e=>(o.current=!0,s(e)),[d]:i,suffix:t,allowFolders:r,allowLocal:o.current}}const p=({onClick:e,onDoubleClick:t,stats:n,highlighted:r=!1,disabled:a=!1})=>(0,c.jsx)("div",{children:(0,c.jsxs)("button",{className:"flex row justify-start outline "+(r?"":"secondary"),style:{textAlign:"left",color:a?"var(--light-grey)":void 0},onClick:n=>{1==n.detail?null===e||void 0===e||e():2==n.detail&&(null===t||void 0===t||t())},children:[(0,c.jsx)(i.I,{name:n.isDirectory()?"folder":"draft"}),n.name]})});async function h(e,t,n){for(const r of await t.scandir(n))if(r.isDirectory()){const a=e.folder(r.name);a&&await h(a,t,`${n}/${r.name}`)}else e.file(r.name,await t.readFile(`${n}/${r.name}`))}function m(e,t){return t.map((t=>e.endsWith(t))).reduce(((e,t)=>e||t),!1)}const g=()=>{const{fs:e,setStatus:t}=(0,l.useContext)(a.L),{filePicker:n}=(0,l.useContext)(o.BR),[i,u]=(0,l.useState)([]),[f,g]=(0,l.useState)(""),v=e.cwd();(0,l.useEffect)((()=>{"/"==e.cwd()&&y("projects")}),[e]),(0,l.useEffect)((()=>{e.scandir(e.cwd()).then((e=>{u(e)}))}),[e,v,u]);const y=(0,l.useCallback)((t=>{e.cd(t),e.scandir(e.cwd()).then((e=>{u(e)}))}),[e,g,u]),b=(0,l.useCallback)((t=>{g(`${"/"==e.cwd()?"":e.cwd()}/${t}`)}),[g]),w=(0,l.useCallback)((()=>{var e,t;n.close(),null===(e=(t=n[d]).current)||void 0===e||e.call(t,f)}),[f,n,t]),k=(0,l.useRef)(null),S=(0,l.useRef)(null);return(0,c.jsxs)("dialog",{open:n.isOpen,children:[(0,c.jsx)("input",{type:"file",ref:k,onChange:async()=>{if(k.current&&k.current.files){var e,t;const r=k.current.files[0];null===(e=(t=n[d]).current)||void 0===e||e.call(t,{name:r.name,content:await r.text()}),n.close()}},style:{display:"none"}}),(0,c.jsxs)("article",{className:"file-select flex",children:[(0,c.jsxs)("header",{children:[(0,c.jsx)("p",{children:(0,c.jsx)(r.x6,{id:"+yPBXI"})}),(0,c.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:e=>{e.preventDefault(),n.close()},children:"close"})]}),(0,c.jsxs)("main",{children:[(0,c.jsx)("a",{ref:S,style:{display:"none"}}),(0,c.jsx)("div",{children:(0,c.jsx)("b",{children:e.cwd()})}),"/"!==e.cwd()&&(0,c.jsx)(p,{stats:{isDirectory:()=>!0,isFile:()=>!1,name:".."},onDoubleClick:()=>y("..")}),i.map((e=>(0,c.jsx)(p,{stats:e,highlighted:e.name===f.split("/").pop(),onClick:()=>b(e.name),onDoubleClick:()=>{e.isDirectory()&&y(e.name)},disabled:e.name.includes(".")&&void 0!=n.suffix&&!m(e.name,n.suffix)},e.name)))]}),(0,c.jsxs)("footer",{children:[(0,c.jsx)("button",{disabled:!f||".."==f||void 0!=n.suffix&&f.includes(".")&&!m(f,n.suffix)||!n.allowFolders&&!f.includes("."),onClick:w,children:"Select"}),n.allowLocal&&(0,c.jsx)("button",{onClick:()=>{var e;null===(e=k.current)||void 0===e||e.click()},children:"Select local file"}),(0,c.jsx)("button",{onClick:async()=>{var t;if(!S.current)return;const n=await(0,s.e)();await h(n,e,f);const r=await n.generateAsync({type:"blob"}),a=URL.createObjectURL(r);S.current.href=a,S.current.download=null!==(t=f.split("/").pop())&&void 0!==t?t:f,S.current.click(),URL.revokeObjectURL(a)},"data-tooltip":"Download all files in this folder into a zip",disabled:""==f||f.includes("."),children:"Download"})]})]})]})}},3569:(e,t,n)=>{async function r(e){const t=await a();for(const r of e)t.file(r.name,await r.content);const n=await t.generateAsync({type:"blob"});return URL.createObjectURL(n)}async function a(){const{default:e}=await n.e(608).then(n.t.bind(n,5608,23));return new e}n.d(t,{e:()=>a,y:()=>r})},5270:(e,t,n)=>{n.d(t,{w:()=>y,dQ:()=>b,z1:()=>v});var r,a=n(1092),l=n(2469),o=n(8878),i=n(782);const u="/tracking/canTrack",s="yes",c="no",d="",f=[s,c];let p=!1;const h=null!==(r={NODE_ENV:"production",PUBLIC_URL:"/web-ide",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.GA4_ID)&&void 0!==r?r:"G-0VTR5BJFQP";function m(e){a.Ay.send({hitType:"pageview",page:e})}function g(e,t,n,r){var o,i;if(p)return;const u="string"===typeof e?{category:e,action:(0,l.Z1)(t),label:n&&r?{label:n,value:r}:void 0}:e;a.Ay.event({category:u.category,action:u.action,nonInteraction:!u.interaction,label:null===(o=u.label)||void 0===o?void 0:o.label,value:null===(i=u.label)||void 0===i?void 0:i.value})}function v(){var e;const t=null!==(e=localStorage[u])&&void 0!==e?e:d,[n,r]=(0,o.useState)(t===s),[l,i]=(0,o.useState)(f.includes(t)||"1"===navigator.doNotTrack);return{canTrack:n,haveAsked:l,accept:(0,o.useCallback)((()=>{localStorage[u]=s,r(!0),i(!0),a.Ay.initialize(h),a.Ay.send("pageview")}),[r,i]),reject:(0,o.useCallback)((()=>{localStorage[u]=c,r(!1),i(!0),p=!0}),[r,i]),trackEvent:g,trackPage:m}}function y(){const{accept:e,reject:t,haveAsked:n}=v(),[r,a]=(0,o.useState)(!n),l=(0,o.useCallback)((()=>{a(!1)}),[a]),u=(0,o.useCallback)((()=>{e(),l()}),[e,l]),s=(0,o.useCallback)((()=>{t(),l()}),[t,l]);return(0,i.jsx)(i.Fragment,{children:r&&(0,i.jsxs)("div",{id:"trackingBanner",className:"flex row",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(b,{})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("a",{href:"#reject",role:"button",className:"reject",onClick:s,children:"Reject"}),(0,i.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:u,children:"Accept"}),(0,i.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:l,children:"\ud835\uddb7"})]})]})})}function b(){return(0,i.jsxs)("p",{style:{margin:0},children:["This site uses Google Analytics to gather information that will improve the user experience. This only includes anonymous interaction data, and never shares your code."," ",(0,i.jsx)("a",{href:"www.google.com/policies/privacy/partners/",children:"How Google uses data."})]})}},3499:(e,t,n)=>{n.d(t,{Ay:()=>m,It:()=>h,p3:()=>p});var r=n(8878),a=n(782);const l=(0,r.lazy)((()=>Promise.all([n.e(548),n.e(233),n.e(700),n.e(200),n.e(840)]).then(n.bind(n,2632)))),o=(0,r.lazy)((()=>Promise.all([n.e(548),n.e(233),n.e(700),n.e(200),n.e(19)]).then(n.bind(n,445)))),i=(0,r.lazy)((()=>Promise.all([n.e(548),n.e(233),n.e(700),n.e(71)]).then(n.bind(n,2745)))),u=(0,r.lazy)((()=>n.e(323).then(n.bind(n,1323)))),s=(0,r.lazy)((()=>Promise.all([n.e(548),n.e(233),n.e(700),n.e(200),n.e(447)]).then(n.bind(n,6049)))),c=(0,r.lazy)((()=>Promise.all([n.e(548),n.e(911)]).then(n.bind(n,3911)))),d=(0,r.lazy)((()=>n.e(408).then(n.bind(n,2408)))),f=(0,r.lazy)((()=>Promise.all([n.e(656),n.e(614)]).then(n.bind(n,3614)))),p="lastRoute",h={chip:"Hardware Simulator",cpu:"CPU Emulator",asm:"Assembler",vm:"VM Emulator",bitmap:"Bitmap Editor",compiler:"Jack Compiler"},m={chip:{href:"/chip",tool:"chip",target:(0,a.jsx)(l,{})},cpu:{href:"/cpu",tool:"cpu",target:(0,a.jsx)(o,{})},asm:{href:"/asm",tool:"asm",target:(0,a.jsx)(i,{})},vm:{href:"/vm",tool:"vm",target:(0,a.jsx)(s,{})},compiler:{href:"/compiler",tool:"compiler",target:(0,a.jsx)(c,{})},bitmap:{href:"/bitmap",tool:"bitmap",target:(0,a.jsx)(u,{})},util:{href:"/util",target:(0,a.jsx)(d,{})},about:{href:"/about",target:(0,a.jsx)(f,{})}}},1642:(e,t,n)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;td,Gh:()=>R,HS:()=>z,Oi:()=>i,Rr:()=>f,pX:()=>I,pb:()=>O,rc:()=>a,tH:()=>D,ue:()=>m,yD:()=>L,zR:()=>o}),function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(a||(a={}));const l="popstate";function o(e){return void 0===e&&(e={}),p((function(e,t){let{pathname:n,search:r,hash:a}=e.location;return c("",{pathname:n,search:r,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"===typeof t?t:d(t)}),null,e)}function i(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function u(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function s(e,t){return{usr:e.state,key:e.key,idx:t}}function c(e,t,n,a){return void 0===n&&(n=null),r({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?f(t):t,{state:n,key:t&&t.key||a||Math.random().toString(36).substr(2,8)})}function d(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(t+="#"===r.charAt(0)?r:"#"+r),t}function f(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function p(e,t,n,o){void 0===o&&(o={});let{window:u=document.defaultView,v5Compat:f=!1}=o,p=u.history,h=a.Pop,m=null,g=v();function v(){return(p.state||{idx:null}).idx}function y(){h=a.Pop;let e=v(),t=null==e?null:e-g;g=e,m&&m({action:h,location:w.location,delta:t})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,n="string"===typeof e?e:d(e);return n=n.replace(/ $/,"%20"),i(t,"No window.location.(origin|href) available to create URL for href: "+n),new URL(n,t)}null==g&&(g=0,p.replaceState(r({},p.state,{idx:g}),""));let w={get action(){return h},get location(){return e(u,p)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(l,y),m=e,()=>{u.removeEventListener(l,y),m=null}},createHref:e=>t(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){h=a.Push;let r=c(w.location,e,t);n&&n(r,e),g=v()+1;let l=s(r,g),o=w.createHref(r);try{p.pushState(l,"",o)}catch(i){if(i instanceof DOMException&&"DataCloneError"===i.name)throw i;u.location.assign(o)}f&&m&&m({action:h,location:w.location,delta:1})},replace:function(e,t){h=a.Replace;let r=c(w.location,e,t);n&&n(r,e),g=v();let l=s(r,g),o=w.createHref(r);p.replaceState(l,"",o),f&&m&&m({action:h,location:w.location,delta:0})},go:e=>p.go(e)};return w}var h;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(h||(h={}));new Set(["lazy","caseSensitive","path","id","index","children"]);function m(e,t,n){void 0===n&&(n="/");let r=O(("string"===typeof t?f(t):t).pathname||"/",n);if(null==r)return null;let a=g(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]));return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(a);let l=null;for(let o=0;null==l&&o{let o={relativePath:void 0===l?e.path||"":l,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};o.relativePath.startsWith("/")&&(i(o.relativePath.startsWith(r),'Absolute route path "'+o.relativePath+'" nested under path "'+r+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),o.relativePath=o.relativePath.slice(r.length));let u=z([r,o.relativePath]),s=n.concat(o);e.children&&e.children.length>0&&(i(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+u+'".'),g(e.children,t,s,u)),(null!=e.path||e.index)&&t.push({path:u,score:E(u,e.index),routesMeta:s})};return e.forEach(((e,t)=>{var n;if(""!==e.path&&null!=(n=e.path)&&n.includes("?"))for(let r of v(e.path))a(e,t,r);else a(e,t)})),t}function v(e){let t=e.split("/");if(0===t.length)return[];let[n,...r]=t,a=n.endsWith("?"),l=n.replace(/\?$/,"");if(0===r.length)return a?[l,""]:[l];let o=v(r.join("/")),i=[];return i.push(...o.map((e=>""===e?l:[l,e].join("/")))),a&&i.push(...o),i.map((t=>e.startsWith("/")&&""===t?"/":t))}const y=/^:[\w-]+$/,b=3,w=2,k=1,S=10,x=-2,C=e=>"*"===e;function E(e,t){let n=e.split("/"),r=n.length;return n.some(C)&&(r+=x),t&&(r+=w),n.filter((e=>!C(e))).reduce(((e,t)=>e+(y.test(t)?b:""===t?k:S)),r)}function _(e,t){let{routesMeta:n}=e,r={},a="/",l=[];for(let o=0;o(r.push({paramName:t,isOptional:null!=n}),n?"/?([^\\/]+)?":"/([^\\/]+)")));e.endsWith("*")?(r.push({paramName:"*"}),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))");let l=new RegExp(a,t?void 0:"i");return[l,r]}(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let l=a[0],o=l.replace(/(.)\/+$/,"$1"),i=a.slice(1);return{params:r.reduce(((e,t,n)=>{let{paramName:r,isOptional:a}=t;if("*"===r){let e=i[n]||"";o=l.slice(0,l.length-e.length).replace(/(.)\/+$/,"$1")}const u=i[n];return e[r]=a&&!u?void 0:(u||"").replace(/%2F/g,"/"),e}),{}),pathname:l,pathnameBase:o,pattern:e}}function j(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return u(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function O(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&"/"!==r?null:e.slice(n)||"/"}function N(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the `to."+n+'` field. Alternatively you may provide the full path as a string in and the router will parse it for you.'}function T(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function L(e,t){let n=T(e);return t?n.map(((t,n)=>n===e.length-1?t.pathname:t.pathnameBase)):n.map((e=>e.pathnameBase))}function R(e,t,n,a){let l;void 0===a&&(a=!1),"string"===typeof e?l=f(e):(l=r({},e),i(!l.pathname||!l.pathname.includes("?"),N("?","pathname","search",l)),i(!l.pathname||!l.pathname.includes("#"),N("#","pathname","hash",l)),i(!l.search||!l.search.includes("#"),N("#","search","hash",l)));let o,u=""===e||""===l.pathname,s=u?"/":l.pathname;if(null==s)o=n;else{let e=t.length-1;if(!a&&s.startsWith("..")){let t=s.split("/");for(;".."===t[0];)t.shift(),e-=1;l.pathname=t.join("/")}o=e>=0?t[e]:"/"}let c=function(e,t){void 0===t&&(t="/");let{pathname:n,search:r="",hash:a=""}="string"===typeof e?f(e):e,l=n?n.startsWith("/")?n:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(n,t):t;return{pathname:l,search:A(r),hash:M(a)}}(l,o),d=s&&"/"!==s&&s.endsWith("/"),p=(u||"."===s)&&n.endsWith("/");return c.pathname.endsWith("/")||!d&&!p||(c.pathname+="/"),c}const z=e=>e.join("/").replace(/\/\/+/g,"/"),F=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),A=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",M=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class D extends Error{}function I(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}const U=["post","put","patch","delete"],B=(new Set(U),["get",...U]);new Set(B),new Set([301,302,303,307,308]),new Set([307,308]);Symbol("deferred")},2777:(e,t,n)=>{var r=n(8878),a=n(7116);function l(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n