From b9a5a49a87047f05ae8ecadd9487dc1dc3aac3b5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 10 Jan 2024 18:26:24 +0000 Subject: [PATCH] Updates --- about/index.html | 2 +- asm/index.html | 2 +- asset-manifest.json | 6 +++--- bitmap/index.html | 2 +- chip/index.html | 2 +- cpu/index.html | 2 +- guide/index.html | 2 +- index.html | 2 +- static/js/495.0f92cb2e.chunk.js | 1 + static/js/495.cd71701a.chunk.js | 1 - static/js/{main.73540501.js => main.7ae39c93.js} | 4 ++-- ...73540501.js.LICENSE.txt => main.7ae39c93.js.LICENSE.txt} | 0 util/index.html | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 static/js/495.0f92cb2e.chunk.js delete mode 100644 static/js/495.cd71701a.chunk.js rename static/js/{main.73540501.js => main.7ae39c93.js} (99%) rename static/js/{main.73540501.js.LICENSE.txt => main.7ae39c93.js.LICENSE.txt} (100%) diff --git a/about/index.html b/about/index.html index ce54045d4..53bfc47fe 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 ce54045d4..53bfc47fe 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 d64e62c16..49552e5dc 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,12 +1,12 @@ { "files": { "main.css": "/web-ide/static/css/main.dc33280d.css", - "main.js": "/web-ide/static/js/main.73540501.js", + "main.js": "/web-ide/static/js/main.7ae39c93.js", "static/js/168.a6f20b5d.chunk.js": "/web-ide/static/js/168.a6f20b5d.chunk.js", "static/js/411.2bb7e61b.chunk.js": "/web-ide/static/js/411.2bb7e61b.chunk.js", "static/js/196.2b1468c2.chunk.js": "/web-ide/static/js/196.2b1468c2.chunk.js", "static/css/495.d2314eed.chunk.css": "/web-ide/static/css/495.d2314eed.chunk.css", - "static/js/495.cd71701a.chunk.js": "/web-ide/static/js/495.cd71701a.chunk.js", + "static/js/495.0f92cb2e.chunk.js": "/web-ide/static/js/495.0f92cb2e.chunk.js", "static/css/548.802865bf.chunk.css": "/web-ide/static/css/548.802865bf.chunk.css", "static/js/548.57d49cef.chunk.js": "/web-ide/static/js/548.57d49cef.chunk.js", "static/css/428.95ebedec.chunk.css": "/web-ide/static/css/428.95ebedec.chunk.css", @@ -25,6 +25,6 @@ }, "entrypoints": [ "static/css/main.dc33280d.css", - "static/js/main.73540501.js" + "static/js/main.7ae39c93.js" ] } \ No newline at end of file diff --git a/bitmap/index.html b/bitmap/index.html index ce54045d4..53bfc47fe 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 ce54045d4..53bfc47fe 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/cpu/index.html b/cpu/index.html index ce54045d4..53bfc47fe 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 ce54045d4..53bfc47fe 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 ce54045d4..53bfc47fe 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/static/js/495.0f92cb2e.chunk.js b/static/js/495.0f92cb2e.chunk.js new file mode 100644 index 000000000..deaf2db4f --- /dev/null +++ b/static/js/495.0f92cb2e.chunk.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[495],{2657:(t,e,s)=>{s.r(e),s.d(e,{Chip:()=>oe,default:()=>le});var i=s(5072),n=s(1058),a=s(6845),r=s(864),o=s(5524),l=s(7239),c=s(2201);class u extends o.tI{width;_memory;_nextData=0;_address=0;get memory(){return this._memory}get address(){return this._address}constructor(t,e){super(["in[16]","load",`address[${t}]`],["out[16]"],e),this.width=t,this._memory=new c.zp(Math.pow(2,this.width))}tick(){const t=this.in("load").voltage();this._address=this.in("address").busVoltage,t&&(this._nextData=this.in().busVoltage,this._memory.set(this._address,this._nextData))}tock(){this.out().busVoltage=this._memory?.get(this._address)??0}eval(){const t=this.in("address").busVoltage;this.out().busVoltage=this._memory?.get(t)??0}at(t){return(0,l.hu)(t`Request out of bounds (${t} >= ${this._memory.size})`)),new d(`${this.name}[${t}]`,t,this._memory)}reset(){this._memory.reset(),super.reset()}}class d extends o.Gc{index;ram;constructor(t,e,s){super(t),this.index=e,this.ram=s}get busVoltage(){return this.ram.get(this.index)}set busVoltage(t){this.ram.set(this.index,t)}}class h extends u{constructor(t){super(3,t)}}class p extends u{constructor(t){super(14,t)}}var g=s(2369),m=s(5150),b=s(9415);class f extends u{constructor(){super(16,"ROM")}async load(t,e){try{(await(0,b.zD)(t,e)).map(((t,e)=>this.at(e).busVoltage=t))}catch(s){throw new Error(`ROM32K Failed to load file ${e}`)}}}class x extends u{static SIZE=c.yJ;static OFFSET=c.GD;constructor(){super(13,"Screen")}}class v extends o.Af{static OFFSET=c.eu;constructor(){super([],["out[16]"],"Keyboard")}getKey(){return this.out().busVoltage}setKey(t){this.out().busVoltage=65535&t}clearKey(){this.out().busVoltage=0}}class y extends o.tI{ram=new p;screen=new x;keyboard=new v;address=0;constructor(){super(["in[16]","load","address[15])"],["out[16]"],"Memory"),this.parts.add(this.keyboard),this.parts.add(this.screen),this.parts.add(this.ram)}tick(){const t=this.in("load").voltage();if(this.address=this.in("address").busVoltage,t){const t=this.in().busVoltage;this.address>=v.OFFSET||(this.address>=x.OFFSET?this.screen.at(this.address-x.OFFSET).busVoltage=t:this.ram.at(this.address).busVoltage=t)}}tock(){this.eval()}eval(){if(!this.ram)return;this.address=this.in("address").busVoltage;let t=0;t=this.address>=v.OFFSET?this.keyboard?.out().busVoltage??0:this.address>=x.OFFSET?this.screen?.at(this.address-x.OFFSET).busVoltage??0:this.ram?.at(this.address).busVoltage??0,this.out().busVoltage=t}in(t){if(t?.startsWith("RAM16K")){const e=(0,m.o5)(t.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.ram.at(e)}if(t?.startsWith("Screen")){const e=(0,m.o5)(t.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.screen.at(e)}return super.in(t)}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.startsWith("RAM16K")?this.at(16383&e):t.startsWith("Screen")?this.at(e&8191+x.OFFSET):t.startsWith("Keyboard")?this.at(v.OFFSET):t.startsWith("Memory")?this.at(e):super.get(t,e)}at(t){return t>=v.OFFSET?this.keyboard.out():t>=x.OFFSET?this.screen.at(t-x.OFFSET):this.ram.at(t)}reset(){this.address=0,this.ram.reset(),this.screen.reset(),super.reset()}}class j extends o.tI{_state=(0,g.Zu)();get state(){return this._state}constructor(){super(["inM[16]","instruction[16]","reset"],["outM[16]","writeM","addressM[15]","pc[15]"])}tick(){const[t,e]=(0,g.aL)(this.cpuInput(),this._state);this._state=t,this.out("writeM").pull(e?o.lj:o.yE),this.out("outM").busVoltage=this._state.ALU??0}tock(){if(!this._state)return;const[t,e]=(0,g.Ff)(this.cpuInput(),this._state);this._state=e,this.out("addressM").busVoltage=t.addressM??0,this.out("outM").busVoltage=t.outM??0,this.out("writeM").pull(t.writeM?o.lj:o.yE),this.out("pc").busVoltage=this._state?.PC??0}cpuInput(){return{inM:this.in("inM").busVoltage,instruction:this.in("instruction").busVoltage,reset:1===this.in("reset").busVoltage}}get(t,e){return t?.startsWith("ARegister")?new o.qP("ARegister",this._state.A):t?.startsWith("DRegister")?new o.qP("DRegister",this._state.D):t?.startsWith("PC")?new o.qP("PC",this._state.PC):super.get(t,e)}reset(){this._state=(0,g.Zu)(),this._state.PC=-1,super.reset()}}class C extends o.Af{#t=new j;#e=new y;#s=new f;constructor(){super(["reset"],[]),this.wire(this.#t,[{from:{name:"reset",start:0},to:{name:"reset",start:0}},{from:{name:"instruction",start:0},to:{name:"instruction",start:0}},{from:{name:"oldOutM",start:0},to:{name:"inM",start:0}},{from:{name:"writeM",start:0},to:{name:"writeM",start:0}},{from:{name:"addressM",start:0},to:{name:"addressM",start:0}},{from:{name:"newInM",start:0},to:{name:"outM",start:0}},{from:{name:"pc",start:0},to:{name:"pc",start:0}}]),this.wire(this.#s,[{from:{name:"pc",start:0},to:{name:"address",start:0}},{from:{name:"instruction",start:0},to:{name:"out",start:0}}]),this.wire(this.#e,[{from:{name:"newInM",start:0},to:{name:"in",start:0}},{from:{name:"writeM",start:0},to:{name:"load",start:0}},{from:{name:"addressM",start:0},to:{name:"address",start:0}},{from:{name:"oldOutM",start:0},to:{name:"out",start:0}}])}eval(){super.eval()}get(t,e){return t.startsWith("PC")||t.startsWith("ARegister")||t.startsWith("DRegister")?this.#t.get(t):t.startsWith("RAM16K")?this.#e.get(t,e):super.get(t,e)}async load(t,e){return await this.#s.load(t,e)}}var w=s(7054);class P extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[1===t&&1===e?o.lj:o.yE]}(t,e);this.out().pull(s)}}class V extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[t&e&65535]}(t,e);this.out().busVoltage=s}}class S extends o.Af{constructor(){super(["in","sel"],["a","b"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").voltage(),[s,i]=function(t,e){return[e===o.yE&&t===o.lj?o.lj:o.yE,e===o.lj&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i)}}class k extends o.Af{constructor(){super(["in","sel[2]"],["a","b","c","d"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").busVoltage,[s,i,n,a]=function(t,e){return[0===e&&t===o.lj?o.lj:o.yE,1===e&&t===o.lj?o.lj:o.yE,2===e&&t===o.lj?o.lj:o.yE,3===e&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i),this.out("c").pull(n),this.out("d").pull(a)}}class A extends o.Af{constructor(){super(["in","sel[3]"],["a","b","c","d","e","f","g","h"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").busVoltage,[s,i,n,a,r,l,c,u]=function(t,e){return[0===e&&t===o.lj?o.lj:o.yE,1===e&&t===o.lj?o.lj:o.yE,2===e&&t===o.lj?o.lj:o.yE,3===e&&t===o.lj?o.lj:o.yE,4===e&&t===o.lj?o.lj:o.yE,5===e&&t===o.lj?o.lj:o.yE,6===e&&t===o.lj?o.lj:o.yE,7===e&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i),this.out("c").pull(n),this.out("d").pull(a),this.out("e").pull(r),this.out("f").pull(l),this.out("g").pull(c),this.out("h").pull(u)}}function E(t,e,s){return[s===o.yE?t:e]}function M(t,e,s,i,n){const a=1&n;return 0===(2&n)?E(t,e,a):E(s,i,a)}class F extends o.Af{constructor(){super(["a","b","sel"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),s=this.in("sel").voltage(),[i]=function(t,e,s){return[s===o.yE?t:e]}(t,e,s);this.out().pull(i)}}class I extends o.Af{constructor(){super(["a[16]","b[16]","sel"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("sel").voltage(),[i]=E(t,e,s);this.out().busVoltage=i}}class O extends o.Af{constructor(){super(["a[16]","b[16]","c[16]","d[16]","sel[2]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("c").busVoltage,i=this.in("d").busVoltage,n=this.in("sel").busVoltage,[a]=M(t,e,s,i,n);this.out().busVoltage=a}}class _ extends o.Af{constructor(){super(["a[16]","b[16]","c[16]","d[16]","e[16]","f[16]","g[16]","h[16]","sel[3]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("c").busVoltage,i=this.in("d").busVoltage,n=this.in("e").busVoltage,a=this.in("f").busVoltage,r=this.in("g").busVoltage,o=this.in("h").busVoltage,l=this.in("sel").busVoltage,[c]=function(t,e,s,i,n,a,r,o,l){const c=3&l;return 0===(4&l)?M(t,e,s,i,c):M(n,a,r,o,c)}(t,e,s,i,n,a,r,o,l);this.out().busVoltage=c}}class T extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[1===t&&1===e?o.yE:o.lj]}(t,e);this.out().pull(s)}}class U extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage;this.out().busVoltage=(0,m.C2)(t,e)}}class R extends o.Af{constructor(){super(["in"],["out"])}eval(){const t=this.in("in").voltage(),[e]=[t===o.yE?o.lj:o.yE];this.out().pull(e)}}class N extends o.Af{constructor(){super(["in[16]"],["out[16]"])}eval(){const[t]=[65535&~this.in().busVoltage];this.out().busVoltage=t}}function L(t,e){return[1===t||1===e?o.lj:o.yE]}class W extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=L(t,e);this.out().pull(s)}}class $ extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[65535&(t|e)]}(t,e);this.out().busVoltage=s}}class D extends o.Af{constructor(){super(["in[8]"],["out"],"Or8way")}eval(){const t=this.in().busVoltage,[e]=[0===(255&t)?o.yE:o.lj];this.out().pull(e)}}class B extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[t===o.lj&&e===o.yE||t===o.yE&&e===o.lj?o.lj:o.yE]}(t,e);this.out().pull(s)}}class z extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[65535&(t^e)]}(t,e);this.out().busVoltage=s}}function G(t,e){return[t+e&65535]}class H extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"],"Add16")}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=G(t,e);this.out().busVoltage=s}}var K=s(137);class Z extends o.Af{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]"],"ALU")}eval(){const t=this.in("x").busVoltage,e=this.in("y").busVoltage,s=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0),[i]=(0,K.Bb)(s,t,e);this.out().busVoltage=i}}class J extends o.Af{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]","zr","ng"],"ALU")}eval(){const t=this.in("x").busVoltage,e=this.in("y").busVoltage,s=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0),[i,n]=(0,K.Bb)(s,t,e),a=n===K.vU.Negative?o.lj:o.yE,r=n===K.vU.Zero?o.lj:o.yE;this.out("out").busVoltage=i,this.out("ng").pull(a),this.out("zr").pull(r)}op(){return(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0)}}function q(t,e){return[1===t&&0===e||0===t&&1===e?o.lj:o.yE,1===t&&1===e?o.lj:o.yE]}class X extends o.Af{constructor(){super(["a","b"],["sum","carry"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s,i]=q(t,e);this.out("sum").pull(s),this.out("carry").pull(i)}}class Y extends o.Af{constructor(){super(["a","b","c"],["sum","carry"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),s=this.in("c").voltage(),[i,n]=function(t,e,s){const[i,n]=q(t,e),[a,r]=q(i,s),[o]=L(n,r);return[a,o]}(t,e,s);this.out("sum").pull(i),this.out("carry").pull(n)}}class Q extends o.Af{constructor(){super(["in[16]"],["out[16]"],"Inc16")}eval(){const t=this.in().busVoltage,[e]=G(t,1);this.out().busVoltage=e}}class tt extends o.tI{bit=o.yE;constructor(t){super(["in","load"],["out"],t)}tick(){this.in("load").voltage()===o.lj&&(this.bit=this.in().voltage())}tock(){this.out().pull(this.bit??0)}reset(){this.bit=o.yE,super.reset()}}class et extends o.tI{bits=0;constructor(t){super(["in[16]","load"],["out[16]"],t)}tick(){this.in("load").voltage()===o.lj&&(this.bits=65535&this.in().busVoltage)}tock(){this.out().busVoltage=65535&this.bits}get(t,e){return t===this.name?this.out():super.get(t,e)}reset(){this.bits=0,super.reset()}}class st extends et{}class it extends o.tI{bits=0;constructor(t){super(["in[16]","load","inc","reset"],["out[16]"],t)}tick(){this.in("reset").voltage()===o.lj?this.bits=0:this.in("load").voltage()===o.lj?this.bits=65535&this.in().busVoltage:this.in("inc").voltage()===o.lj&&(this.bits+=1)}tock(){this.out().busVoltage=65535&this.bits}get(t,e){return t===this.name?this.out():super.get(t,e)}reset(){this.bits=0,super.reset()}}class nt extends o.tI{constructor(t){super(["in"],["out"],t,["t"])}tick(){const t=this.in().voltage();this.pin("t").pull(t)}tock(){const t=this.pin("t").voltage();this.out().pull(t)}}const at=new Map([["Nand",T],["Nand16",U],["Not",R],["Not16",N],["And",P],["And16",V],["Or",W],["Or16",$],["Or8Way",D],["XOr",B],["XOr16",z],["Xor",B],["Xor16",z],["Mux",F],["Mux16",I],["Mux4Way16",O],["Mux8Way16",_],["DMux",S],["DMux4Way",k],["DMux8Way",A],["HalfAdder",X],["FullAdder",Y],["Add16",H],["Inc16",Q],["ALU",J],["ALUNoStat",Z],["DFF",nt],["Bit",tt],["Register",et],["ARegister",et],["DRegister",et],["PC",it],["RAM8",h],["RAM64",class extends u{constructor(t){super(6,t)}}],["RAM512",class extends u{constructor(t){super(9,t)}}],["RAM4K",class extends u{constructor(t){super(12,t)}}],["RAM16K",p],["ROM32K",f],["Screen",x],["Keyboard",v],["CPU",j],["Computer",C],["Memory",y],["ARegister",st],["DRegister",st]].map((t=>{let[e,s]=t;return[e,()=>{const t=new s;return t.name=e,t}]})));function rt(t){const e=at.get(t);return e?(0,w.Ok)(e()):(0,w.UG)(new Error(`Chip ${t} not in builtin registry`))}const ot=t=>{let{A:e,op:s,D:i,out:n,flag:a}=t;return(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{children:"ALU"}),(0,r.jsx)("svg",{width:"250",height:"250",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsxs)("g",{children:[(0,r.jsx)("rect",{x:"1",y:"20",height:"85",width:"70",fill:"black"}),(0,r.jsx)("rect",{x:"1",y:"145",height:"85",width:"70",fill:"black"}),(0,r.jsx)("rect",{x:"180",y:"95",height:"60",width:"70",fill:"black"}),(0,r.jsx)("polygon",{points:"70,10 180,85 180,165 70,240 70,135 90,125 70,115",stroke:"#000",fill:"#6D97AB"}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",strokeWidth:"0",id:"svg_9",y:"63",x:"35",stroke:"white",fill:"#ffffff",children:e}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_10",y:"188",x:"35",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:i}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_11",y:"125",x:"215",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:n}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_13",y:"125",x:"135",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:K.NM.op[s]??"(??)"})]})})]})};var lt=s(3478),ct=s(1062),ut=s(2869),dt=s(8963);function ht(t,e){if(t instanceof J)return(0,r.jsx)(ot,{A:t.in("x").busVoltage,op:t.op(),D:t.in("y").busVoltage,out:t.out().busVoltage,flag:t.out("zr").voltage()===o.lj?K.vU.Zero:t.out("ng").voltage()===o.lj?K.vU.Negative:K.vU.Positive});if(t instanceof et)return(0,r.jsx)(ut.y,{name:t.name??`Chip ${t.id}`,bits:t.bits});if(t instanceof it)return(0,r.jsx)(ut.y,{name:"PC",bits:t.bits});if(t instanceof v)return(0,r.jsx)(lt.N,{keyboard:t,update:e});if(t instanceof x)return(0,r.jsx)(dt.l,{memory:t.memory});if(t instanceof u)return(0,r.jsx)(ct.zp,{name:t.name,memory:t.memory,format:t instanceof f?"asm":"dec",highlight:t.address});if(t instanceof h)return(0,r.jsxs)("span",{children:["RAM ",t.width]});if(t instanceof j){const e=(0,g.Jx)(t.in("instruction").busVoltage);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ut.y,{name:"A",bits:t.state.A}),(0,r.jsx)(ut.y,{name:"D",bits:t.state.D}),(0,r.jsx)(ut.y,{name:"PC",bits:t.state.PC}),(0,r.jsx)(ot,{A:e.am?t.in("inM").busVoltage:t.state.A,D:t.state.D,out:t.state.ALU,op:e.op,flag:t.state.flag})]})}const s=[...t.parts].map((t=>ht(t,e))).filter((t=>void 0!==t));return s.length>0?(0,r.jsx)(r.Fragment,{children:s}):void 0}var pt=s(5554),gt=s(1965),mt=s(8177);class bt{signBehaviors=new Map;constructor(t,e){if(at.has(t)){const s=rt(t);if((0,w.IY)(s)){const t=Array.from((0,w.Ok)(s).ins.entries()).concat(Array.from((0,w.Ok)(s).outs.entries()));for(const s of t)this.signBehaviors.set(s.name,!e||!e.includes(s.name))}}}isSigned(t){return this.signBehaviors.get(t)}}const ft=new Map([["Mux4Way16",["sel"]],["Mux8Way16",["sel"]],["DMux4Way",["sel"]],["DMux8Way",["sel"]],["RAM8",["address"]],["RAM64",["address"]],["RAM512",["address"]],["RAM4K",["address"]],["RAM16K",["address"]],["Screen",["address"]],["Memory",["address"]],["CPU",["addressM","pc"]]]),xt=(0,a.createContext)({});function vt(t){return{pin:t,bits:(0,mt.w)(0,t.width).map((e=>[e,t.voltage(e)])).reverse()}}function yt(t){return[...t.entries()].map(vt)}const jt=t=>{const{inPins:e,outPins:s,internalPins:i}=t.sim,n=(a=t.sim.chip[0].name??"",new bt(a,ft.get(a)));var a;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:"\n table.pinout th {\n font-weight: bold;\n }\n\n table.pinout tbody td:first-child {\n text-align: right;\n --font-size: 1rem;\n width: 0;\n white-space: nowrap;\n border-right: var(--border-width) solid var(--table-border-color);\n }\n\n table.pinout tbody button {\n --font-size: 0.875em;\n font-family: var(--font-family-monospace);\n max-width: 2em;\n }\n "}),(0,r.jsx)("table",{className:"pinout",children:(0,r.jsxs)("tbody",{children:[(0,r.jsx)(Ct,{pins:e,header:"Input pins",toggle:t.toggle,setInputValid:t.setInputValid,displayInfo:n}),(0,r.jsx)(Ct,{pins:s,header:"Output pins",disabled:t.sim.pending,enableEdit:!1,displayInfo:n}),!t.hideInternal&&(0,r.jsx)(Ct,{pins:i,header:"Internal pins",disabled:t.sim.pending,enableEdit:!1,displayInfo:n})]})})]})},Ct=t=>(0,r.jsxs)(r.Fragment,{children:[t.pins.length>0&&(0,r.jsx)("tr",{children:(0,r.jsx)("th",{colSpan:2,children:t.header})}),[...t.pins].map((e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.pin.name}),(0,r.jsx)("td",{children:(0,r.jsx)(wt,{pin:e,toggle:t.toggle,disabled:t.disabled,enableEdit:t.enableEdit,signed:t.displayInfo.isSigned(e.pin.name),setInputValid:t.setInputValid,internal:"Internal pins"===t.header})})]},e.pin.name)))]}),wt=t=>{let{pin:e,toggle:s,disabled:i=!1,enableEdit:n=!0,signed:o=!0,setInputValid:l,internal:c=!1}=t;const[u,d]=(0,a.useState)(!0);let h=!0;const[p,g]=(0,a.useState)(""),m=(0,a.useContext)(xt);m instanceof Pt&&m.registerCallback((()=>{d(!0)}));const b=t=>{h=t,l?.(t)},f=t=>{for(let i=0;i>i&1)&&s?.(e.pin,i)};return(0,a.useEffect)((()=>{if(!u&&h){let t=0;if(o&&e.bits[0][1]){for(const[s,i]of e.bits)s{let[n,a]=t;return(0,r.jsx)("button",{disabled:i,style:c?{backgroundColor:"grey"}:{},onClick:()=>s?.(e.pin,n),"data-testid":`pin-${n}`,children:a},n)})):(0,r.jsx)("input",{className:"colored",value:p,onChange:t=>{(t=>{const s=t.replace(/[^\d]/g,""),i=o&&"-"===t[0]?`-${s}`:s;if(g(i),isNaN(parseInt(i)))b(!1);else{const t=parseInt(i);!o&&t>=Math.pow(2,e.bits.length)||o&&(t>=Math.pow(2,e.bits.length-1)||t<-Math.pow(2,e.bits.length-1))?b(!1):(f(t),b(!0))}})(t.target.value)},disabled:!n})}),e.bits.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{width:"1em"}}),(0,r.jsx)("button",{style:{maxWidth:"3em",margin:0},onClick:()=>{d(!u)},children:u?"dec":"bin"})]})]})};class Pt{callbacks=[];registerCallback(t){this.callbacks.push(t)}reset(){for(const t of this.callbacks)t()}}var Vt=s(6604),St=s(6791),kt=s(5692),At=s(554),Et=s(168),Mt=s(9814),Ft=s(3484);const It='\nHdl <: Base{\n Root := Chip\n Chip = "CHIP" Name OpenBrace ChipBody CloseBrace\n ChipBody = InList? OutList? PartList ClockedList?\n InList = "IN" PinList Semi\n OutList = "OUT" PinList Semi\n PartList = BuiltinPart | Parts\n PinList = List\n PinDecl = Name PinWidth?\n PinWidth = OpenSquare decNumber CloseSquare\n BuiltinPart = "BUILTIN" Semi\n Parts = "PARTS:" Part*\n Part = Name "(" Wires ")" Semi\n Wires = List\n Wire = WireSide Equal (WireSide | True | False) \n WireSide = Name SubBus? \n SubBus = OpenSquare decNumber subBusRest? CloseSquare\n subBusRest = ".." decNumber\n ClockedList = "CLOCKED" SimplePinList Semi\n SimplePinList = List\n}',Ot=Mt.Z.grammar(It,Ft.y1),_t=Ot.extendSemantics(Ft.rJ);_t.addAttribute("SubBus",{SubBus(t,e,s,i){const n=e.value;return{start:n,end:s.child(0)?.child(1)?.value??n}}}),_t.addAttribute("WireSide",{WireSide(t,e){let{name:s}=t;const{start:i,end:n}=e.child(0)?.SubBus??{start:void 0,end:void 0};return{pin:s,start:i,end:n,span:(0,Ft.yP)(this.source)}}}),_t.addAttribute("Wire",{Wire(t,e,s){const i=s.isTerminal()?{pin:s.sourceString}:s.WireSide;return{lhs:t.WireSide,rhs:i}}}),_t.addAttribute("Wires",{Wires:t=>t.asIteration().children.map((t=>t.Wire))}),_t.addAttribute("Part",{Part(t,e,s,i,n){let{name:a}=t,{Wires:r}=s;return{name:a,wires:r,span:(0,Ft.yP)(this.source)}}}),_t.addAttribute("Parts",{Parts:(t,e)=>e.children.map((t=>t.Part)),BuiltinPart:(t,e)=>"BUILTIN"}),_t.addAttribute("PartList",{PartList:t=>t.Parts}),_t.addAttribute("Clocked",{ClockedList:(t,e,s)=>e.asIteration().children.map((t=>{let{sourceString:e}=t;return e}))??[]}),_t.addAttribute("PinDecl",{PinDecl(t,e){let{name:s}=t;return{pin:s,width:e.child(0)?.child(1)?.value??1}}}),_t.addAttribute("PinList",{PinList:t=>t.asIteration().children.map((t=>t.PinDecl))}),_t.addAttribute("Chip",{Chip:(t,e,s,i,n)=>({name:{value:e.sourceString,span:(0,Ft.yP)(e.source)},ins:i.child(0).child(0)?.child(1)?.PinList??[],outs:i.child(1).child(0)?.child(1)?.PinList??[],parts:i.child(2).PartList??[],clocked:i.child(3).child(0)?.Clocked})}),_t.addAttribute("Root",{Root:t=>t.child(0)?.Chip});const Tt={parser:Ot,grammar:It,semantics:_t,parse:(0,Ft.Pz)(Ot,_t,(t=>t.Chip))};function Ut(t,e){if(void 0!==e){if(e>=t)return e-t+1;if(t>0&&0===e)return 1;throw new Error(`Bus specification has start > end (${t} > ${e})`)}}async function Rt(t,e){if(function(t){return at.has(t)}(t)||void 0===e)return rt(t);try{const s=await e.readFile(`${t}.hdl`),i=Tt.parse(s);let n;if((0,w.IY)(i)){const t=await Bt((0,w.Ok)(i),e);n=(0,w.dZ)(t)?(0,w.UG)(new Error((0,w.UG)(t).message)):t}else n=(0,w.UG)(new Error("HDL Was not parsed"));return n}catch(s){return(0,w.UG)(new Error(`Could not load chip ${t}.hdl`))}}function Nt(t){return"false"===t.toLowerCase()||"true"===t.toLowerCase()||"0"===t||"1"===t}function Lt(t){if(void 0!=t.start&&void 0!=t.end){const e=[];for(let s=t.start;s<=t.end;s++)e.push(s);return e}return[-1]}function Wt(t,e){let s=null;const i=e.get(t.pin);if(i)if(i.has(-1))s=t.start??-1;else if(void 0!==t.start&&void 0!==t.end)for(const n of Lt(t))i.has(n)&&(s=n),i.add(n);else i.add(-1);else e.set(t.pin,new Set(Lt(t)));return null!=s?(0,w.UG)({message:`Cannot write to pin ${t.pin}${-1!=s?`[${s}]`:""} multiple times`,span:t.span}):(0,w.Ok)(!0)}function $t(t,e){return e.isOutPin(t.pin)?(0,w.UG)({message:"Cannot use output pin as input",span:t.span}):e.isInPin(t.pin)||void 0==t.start?(0,w.Ok)(!0):(0,w.UG)({message:Nt(t.pin)?"Cannot use sub bus of constant bus":`Cannot use sub bus of internal pin ${t.pin} as input`,span:t.span})}function Dt(t,e){return e.isInPin(t.pin)?(0,w.UG)({message:`Cannot write to input pin ${t.pin}`,span:t.span}):Nt(t.pin)?(0,w.UG)({message:"Cannot write to constant bus",span:t.span}):(0,w.Ok)(!0)}async function Bt(t,e,s){if(s&&t.name.value!=s)return(0,w.UG)({message:"Wrong chip name",span:t.name.span});if("BUILTIN"===t.parts)return rt(t.name.value);const i=new o.Af(t.ins.map((t=>{let{pin:e,width:s}=t;return{pin:e.toString(),width:s}})),t.outs.map((t=>{let{pin:e,width:s}=t;return{pin:e.toString(),width:s}})),t.name.value,[],t.clocked),n=new Map,a=new Map;for(const o of t.parts){const t=await Rt(o.name,e);if((0,w.dZ)(t))return(0,w.UG)({message:`Undefined chip name: ${o.name}`,span:o.span});const s=(0,w.Ok)(t);if(s.name==i.name)return(0,w.UG)({message:`Cannot use chip ${s.name} to implement itself`,span:o.span});const l=[],c=new Map;for(const{lhs:e,rhs:r}of o.wires){const t=!(i.isInPin(r.pin)||i.isOutPin(r.pin)||Nt(r.pin));if(s.isInPin(e.pin)){let s=Wt(e,c);if((0,w.dZ)(s))return s;if(s=$t(r,i),(0,w.dZ)(s))return s;if(t){const t=n.get(r.pin);void 0==t?n.set(r.pin,{isDefined:!1,firstUse:r.span}):t.firstUse=t.firstUse.start1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:t.clocked,inPins:yt(t.ins),outPins:yt(t.outs),internalPins:yt(t.pins),chip:[t],pending:e,invalid:s}}const Qt=zt.S.get();function te(t,e,s,i){const n=function(t){const e=t["/chip/project"]??"01";return{project:e,chips:Jt(e),chipName:t["/chip/chip"]??Et.CHIP_PROJECTS[e][0]}}(s);let{project:a,chipName:r}=n;const{chips:c}=n;let u=new o.P9,d=new Ht.l1,h=!1,p=!1;const g={setFiles(t,e){let{hdl:s=t.files.hdl,tst:i=t.files.tst,cmp:n=t.files.cmp,out:a=""}=e;t.files.hdl=s,t.files.tst=i,t.files.cmp=n,t.files.out=a},updateChip(t,e){t.sim=Yt(u,e?.pending??t.sim.pending,e?.invalid??t.sim.invalid),t.controls.error=t.sim.invalid?e?.error??t.controls.error:void 0},setProject(t,e){const s=Jt(e),i=t.controls.chipName&&s.includes(t.controls.chipName)?t.controls.chipName:s[0];t.controls.project=e,t.controls.chips=s,this.setChip(t,i)},setChip(t,e){t.controls.chipName=e,t.controls.hasBuiltin=at.has(e),t.controls.builtinOnly=qt(e)},testRunning(t){t.controls.runningTest=!0},testFinished(t){t.controls.runningTest=!1;const s=(0,Kt.q)(t.files.cmp.trim(),t.files.out.trim());e(s?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep(t){if(t.files.out=d?.log()??"",d?.currentStep?.span)t.controls.span=d.currentStep.span;else if(d.done){const e=t.files.tst.length;t.controls.span={start:e-1,end:e,line:t.files.tst.split("\n").length}}this.updateChip(t,{pending:t.sim.pending,invalid:t.sim.invalid})}},m={setProject(t){a=s["/chip/project"]=t,i.current({action:"setProject",payload:a}),this.setChip(Et.CHIP_PROJECTS[a][0])},async setChip(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s["/chip/project"]??"01";if(r=s["/chip/chip"]=t,i.current({action:"setChip",payload:r}),p=qt(r),p)return i.current({action:"setFiles",payload:{hdl:"",tst:"",cmp:""}}),void this.useBuiltin();await this.loadChip(e,r),h&&this.useBuiltin()},reset(){zt.S.get().reset(),u.reset(),d.reset(),i.current({action:"setFiles",payload:{}}),i.current({action:"updateChip"})},async updateFiles(t){let{hdl:s,tst:n,cmp:a}=t;i.current({action:"setFiles",payload:{hdl:s,tst:n,cmp:a}});try{s&&await this.compileChip(s),n&&this.compileTest(n)}catch(r){e((0,At.j)(r))}},async compileChip(t){u.remove();const s=await async function(t,e){const s=Tt.parse(t.toString());return(0,w.dZ)(s)?(0,w.UG)(function(t){if(!t.message)return{message:"HDL statement has a syntax error",span:t.span};const e=t.message.match(/Line \d+, col \d+: (?.*)/);return void 0!==e?.groups?.message?{message:e.groups.message,span:t.span}:{message:t.message,span:t.span}}((0,w.UG)(s))):Bt((0,w.Ok)(s),void 0,e)}(t,r);if((0,w.dZ)(s)){const t=(0,w.UG)(s);return e(`${void 0!=t.span?.line?`Line ${t.span.line}: `:""}${(0,w.UG)(s).message}`),void i.current({action:"updateChip",payload:{invalid:!0,error:t}})}e("HDL code: No syntax errors"),this.replaceChip((0,w.Ok)(s))},replaceChip(t){const e=u.ins;for(const[s,{busVoltage:i}]of e){const e=t.ins.get(s);e&&(e.busVoltage=i)}Qt.reset(),t.eval(),u=t,u.reset(),d=d.with(u).reset(),i.current({action:"updateChip",payload:{invalid:!1}}),i.current({action:"updateTestStep"})},async loadChip(e,n){s["/chip/chip"]=n;const a=t=>`/projects/${e}/${n}/${n}.${t}`,[r,o,l]=await Promise.all([t.readFile(a("hdl")).catch((()=>function(t){return`CHIP ${t} {\n IN in;\n OUT out;\n PARTS:\n}`}(n))),t.readFile(a("tst")).catch((t=>"repeat 10 {\n tick,\n tock;\n}")),t.readFile(a("cmp")).catch((()=>"| in|out|"))]);i.current({action:"setFiles",payload:{hdl:r,tst:o,cmp:l}}),await this.compileChip(r),this.compileTest(o)},async saveChip(s){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;i.current({action:"setFiles",payload:{hdl:s}});const l=`/projects/${n}/${o}/${o}.hdl`;await t.writeFile(l,s),e(`Saved ${l}`)},toggle(t,e){void 0!==e?t.busVoltage=t.busVoltage^1<1?arguments[1]:void 0;if(!(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]))return p||(h=!1),void await this.loadChip(a,r);p||(h=!0);const s=r,n=rt(s);if((0,w.dZ)(n))return void e(`Failed to load builtin ${s}: ${(0,At.j)((0,w.UG)(n))}`);t&&await this.saveChip(t,a,r);const o=Xt(a,s);i.current({action:"setFiles",payload:{hdl:o}}),this.replaceChip((0,w.Ok)(n))},async initialize(){await this.setChip(r,a)},compileTest(s){i.current({action:"setFiles",payload:{tst:s}});const n=Gt.qH.parse(s);return(0,w.dZ)(n)?(e("Failed to parse test"),!1):(d=Ht.l1.from((0,w.Ok)(n)).with(u).reset(),d.setFileSystem(t),i.current({action:"updateTestStep"}),!0)},async runTest(e){this.compileTest(e)&&(i.current({action:"testRunning"}),t.pushd("/samples"),await d.run(),t.popd(),i.current({action:"updateTestStep"}),i.current({action:"testFinished"}))},tick(){return this.stepTest()},stepTest(){(0,l.hu)(d.chipId===u.id,"Test and chip out of sync");const t=d.step();return i.current({action:"updateTestStep"}),t&&i.current({action:"testFinished"}),t},resetFile(){const t=Et.ChipProjects[a].CHIPS[r][`${r}.hdl`];i.current({action:"setFiles",payload:{hdl:t}})}};return{initialState:(()=>{const t={project:a,chips:c,chipName:r,hasBuiltin:at.has(r),builtinOnly:qt(r),runningTest:!1,error:void 0},s=rt(t.chipName);(0,w.dZ)(s)?(e((0,At.j)((0,w.UG)(s))),u=new o.P9):u=(0,w.Ok)(s);return{controls:t,files:{hdl:"",cmp:"",tst:"",out:""},sim:Yt(u)}})(),reducers:g,actions:m}}var ee=s(7880),se=s(4619),ie=s(8722),ne=s(3847),ae=s(9200),re=s(8398);const oe=()=>{const{fs:t,setStatus:e}=(0,a.useContext)(kt.r),{filePicker:s,tracking:o}=(0,a.useContext)(ie.Il),{state:l,actions:c,dispatch:u}=function(){const{fs:t,setStatus:e,storage:s}=(0,a.useContext)(kt.r),i=(0,a.useRef)((()=>{})),{initialState:n,reducers:r,actions:o}=(0,a.useMemo)((()=>te(t,e,s,i)),[t,e,s,i]),[l,c]=(0,Vt.C)(r,n);return i.current=c,{state:l,dispatch:i,actions:o}}(),[d,h]=(0,Vt.i)(l.files.hdl),[p,g]=(0,Vt.i)(l.files.tst),[m,b]=(0,Vt.i)(l.files.cmp),[f]=(0,Vt.i)(l.files.out);(0,a.useEffect)((()=>{c.initialize()}),[c]),(0,a.useEffect)((()=>{o.trackPage("/chip")}),[o]),(0,a.useEffect)((()=>{o.trackEvent("action","setProject",l.controls.project),o.trackEvent("action","setChip",l.controls.chipName)}),[]);const x=(0,a.useCallback)((t=>{c.setProject(t),o.trackEvent("action","setProject",t)}),[c,o]),v=(0,a.useCallback)((t=>{c.setChip(t),o.trackEvent("action","setChip",t),U.reset()}),[c,o]),y=(0,a.useCallback)((()=>{c.eval(),o.trackEvent("action","eval")}),[c,o]),j=(0,a.useRef)((()=>{}));j.current=async function(){var t,e;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await c.updateFiles({hdl:s.hdl,tst:null!==(t=s.tst)&&void 0!==t?t:p,cmp:null!==(e=s.cmp)&&void 0!==e?e:m})};const C=(0,a.useCallback)((async()=>{try{const e=await s.select(),i=await t.readFile(e);await j.current({tst:i})}catch(i){console.error(i),e("Failed to load into memory")}}),[s,e,t,j]),w=(0,a.useRef)();(0,a.useEffect)((()=>(w.current=new class extends se.B{async reset(){await j.current(),await c.reset()}finishFrame(){super.finishFrame(),u.current({action:"updateTestStep"})}async tick(){return await c.stepTest()}toggle(){u.current({action:"updateTestStep"})}},()=>{var t;null===(t=w.current)||void 0===t||t.stop()})),[j,c,u]);const P=(0,a.useMemo)((()=>({toggle(){c.clock(),o.trackEvent("action","toggleClock")},reset(){o.trackEvent("action","resetClock"),c.reset()}})),[c]),[V,S]=(0,a.useState)(!1),k=(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("fieldset",{role:"group",children:[(0,r.jsx)("select",{value:l.controls.project,onChange:t=>{let{target:{value:e}}=t;x(e)},"data-testid":"project-picker",children:Zt.map((t=>{let[e,s]=t;return(0,r.jsx)("option",{value:e,children:s},e)}))}),(0,r.jsx)("select",{value:l.controls.chipName,onChange:t=>{let{target:{value:e}}=t;v(e)},"data-testid":"chip-picker",children:l.controls.chips.map((t=>(0,r.jsx)("option",{value:t,style:qt(t)?{color:"rgb(170, 170, 170)"}:{},children:`${t} ${qt(t)?"(given)":""}`},t)))}),!V&&!l.controls.builtinOnly&&(0,r.jsx)("button",{className:"flex-0",onClick:c.resetFile,children:(0,r.jsx)(i.cC,{id:"Reset"})})]})}),A=(0,r.jsx)(re.s,{className:"_hdl_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{tabIndex:0,children:"HDL"}),(0,r.jsx)("fieldset",{children:l.controls.hasBuiltin&&!l.controls.builtinOnly&&(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",role:"switch",checked:V,onChange:()=>{V?(S(!1),c.useBuiltin(!1)):(S(!0),c.useBuiltin(!0,d)),U.reset()}}),(0,r.jsx)(i.cC,{id:"Builtin"})]})}),k]}),children:(0,r.jsx)(ae.M,{className:"flex-1",value:d,error:l.controls.error,onChange:async t=>{h(t),V||await c.saveChip(t),j.current(V||l.controls.builtinOnly?{}:{hdl:t})},grammar:Tt.parser,language:"hdl",disabled:V||l.controls.builtinOnly})}),[E,M]=(0,a.useState)(!0),F=()=>{e(n.ag._("Cannot test a chip that has syntax errors"))},I=()=>{j.current(V||l.controls.builtinOnly?{}:{hdl:d})},O=()=>{l.sim.invalid?F():y()},_=(0,r.jsxs)("fieldset",{role:"group",children:[(0,r.jsx)("button",{onClick:O,onKeyDown:O,onBlur:I,disabled:!l.sim.pending||!E,children:(0,r.jsx)(i.cC,{id:"Eval"})}),(0,r.jsxs)("button",{onClick:()=>{l.sim.invalid?F():P.toggle()},onBlur:I,style:{maxWidth:"initial"},disabled:!l.sim.clocked,children:[(0,r.jsx)(i.cC,{id:"Clock"}),":","\xa0",(0,r.jsx)(pt.uY,{})]}),(0,r.jsx)("button",{onClick:()=>{l.sim.invalid?F():P.reset()},onBlur:I,style:{maxWidth:"initial"},disabled:!l.sim.clocked,children:(0,r.jsx)(i.cC,{id:"Reset"})})]}),T=function(t,e){return[...t.parts].map(((t,s)=>[`${t.id}_${s}`,ht(t,e)])).filter((t=>{let[e,s]=t;return void 0!==s}))}({parts:l.sim.chip},(()=>{u.current({action:"updateChip"})})),U=new Pt,R=(0,r.jsx)(re.s,{className:"_parts_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(i.cC,{id:"Chip"})," ",l.controls.chipName]}),_]}),children:l.sim.invalid?(0,r.jsx)(i.cC,{id:"Syntax errors in the HDL code"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xt.Provider,{value:U,children:(0,r.jsx)(jt,{sim:l.sim,toggle:c.toggle,setInputValid:M,hideInternal:l.controls.builtinOnly||V})}),T.length>0&&(0,r.jsx)(re.G,{summary:(0,r.jsx)(i.cC,{id:"Visualization"}),open:!0,children:(0,r.jsx)("main",{children:T.map((t=>{let[e,s]=t;return s}))})})]})}),[N,L]=(0,a.useState)("tst"),W=(0,a.useCallback)((t=>{L(t),o.trackEvent("tab","change",t)}),[o]),$=(0,r.jsx)(re.s,{className:"_test_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(i.cC,{id:"Test"})}),(0,r.jsx)("div",{className:"flex-2",children:w.current&&(0,r.jsx)(St.D,{runner:w.current,disabled:l.sim.invalid})}),(0,r.jsx)("div",{children:(0,r.jsxs)("button",{onClick:C,children:[(0,r.jsx)(ne.J,{name:"upload_file"})," "]})})]}),children:(0,r.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,r.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===N,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===N,onChange:()=>W("tst")}),"Test Script"]})}),(0,r.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,r.jsx)(ae.M,{value:p,onChange:g,grammar:Gt.qH.parser,language:"tst",highlight:l.controls.span,disabled:l.controls.builtinOnly})}),(0,r.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===N,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===N,onChange:()=>W("cmp")}),"Compare File"]})}),(0,r.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,r.jsx)(ae.M,{value:m,onChange:b,grammar:ee.lA.parser,language:"cmp",disabled:l.controls.builtinOnly})}),(0,r.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===N,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===N,onChange:()=>W("out")}),"Output File"]})}),(0,r.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,r.jsx)(gt.M,{cmp:m,out:f})})]})});return(0,r.jsxs)("div",{className:"Page ChipPage grid",children:[A,R,$]})},le=oe}}]); \ No newline at end of file diff --git a/static/js/495.cd71701a.chunk.js b/static/js/495.cd71701a.chunk.js deleted file mode 100644 index f99046a6e..000000000 --- a/static/js/495.cd71701a.chunk.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[495],{2657:(t,e,s)=>{s.r(e),s.d(e,{Chip:()=>se,default:()=>ie});var i=s(5072),n=s(1058),a=s(6845),r=s(864),o=s(5524),l=s(7239),c=s(2201);class u extends o.tI{width;_memory;_nextData=0;_address=0;get memory(){return this._memory}get address(){return this._address}constructor(t,e){super(["in[16]","load",`address[${t}]`],["out[16]"],e),this.width=t,this._memory=new c.zp(Math.pow(2,this.width))}tick(){const t=this.in("load").voltage();this._address=this.in("address").busVoltage,t&&(this._nextData=this.in().busVoltage,this._memory.set(this._address,this._nextData))}tock(){this.out().busVoltage=this._memory?.get(this._address)??0}eval(){const t=this.in("address").busVoltage;this.out().busVoltage=this._memory?.get(t)??0}at(t){return(0,l.hu)(t`Request out of bounds (${t} >= ${this._memory.size})`)),new d(`${this.name}[${t}]`,t,this._memory)}reset(){this._memory.reset(),super.reset()}}class d extends o.Gc{index;ram;constructor(t,e,s){super(t),this.index=e,this.ram=s}get busVoltage(){return this.ram.get(this.index)}set busVoltage(t){this.ram.set(this.index,t)}}class h extends u{constructor(t){super(3,t)}}class p extends u{constructor(t){super(14,t)}}var g=s(2369),m=s(5150),b=s(9415);class f extends u{constructor(){super(16,"ROM")}async load(t,e){try{(await(0,b.zD)(t,e)).map(((t,e)=>this.at(e).busVoltage=t))}catch(s){throw new Error(`ROM32K Failed to load file ${e}`)}}}class x extends u{static SIZE=c.yJ;static OFFSET=c.GD;constructor(){super(13,"Screen")}}class y extends o.Af{static OFFSET=c.eu;constructor(){super([],["out[16]"],"Keyboard")}getKey(){return this.out().busVoltage}setKey(t){this.out().busVoltage=65535&t}clearKey(){this.out().busVoltage=0}}class v extends o.tI{ram=new p;screen=new x;keyboard=new y;address=0;constructor(){super(["in[16]","load","address[15])"],["out[16]"],"Memory"),this.parts.add(this.keyboard),this.parts.add(this.screen),this.parts.add(this.ram)}tick(){const t=this.in("load").voltage();if(this.address=this.in("address").busVoltage,t){const t=this.in().busVoltage;this.address>=y.OFFSET||(this.address>=x.OFFSET?this.screen.at(this.address-x.OFFSET).busVoltage=t:this.ram.at(this.address).busVoltage=t)}}tock(){this.eval()}eval(){if(!this.ram)return;this.address=this.in("address").busVoltage;let t=0;t=this.address>=y.OFFSET?this.keyboard?.out().busVoltage??0:this.address>=x.OFFSET?this.screen?.at(this.address-x.OFFSET).busVoltage??0:this.ram?.at(this.address).busVoltage??0,this.out().busVoltage=t}in(t){if(t?.startsWith("RAM16K")){const e=(0,m.o5)(t.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.ram.at(e)}if(t?.startsWith("Screen")){const e=(0,m.o5)(t.match(/\[(?\d+)]/)?.groups?.idx??"0");return this.screen.at(e)}return super.in(t)}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.startsWith("RAM16K")?this.at(16383&e):t.startsWith("Screen")?this.at(e&8191+x.OFFSET):t.startsWith("Keyboard")?this.at(y.OFFSET):t.startsWith("Memory")?this.at(e):super.get(t,e)}at(t){return t>=y.OFFSET?this.keyboard.out():t>=x.OFFSET?this.screen.at(t-x.OFFSET):this.ram.at(t)}reset(){this.address=0,this.ram.reset(),this.screen.reset(),super.reset()}}class j extends o.tI{_state=(0,g.Zu)();get state(){return this._state}constructor(){super(["inM[16]","instruction[16]","reset"],["outM[16]","writeM","addressM[15]","pc[15]"])}tick(){const[t,e]=(0,g.aL)(this.cpuInput(),this._state);this._state=t,this.out("writeM").pull(e?o.lj:o.yE),this.out("outM").busVoltage=this._state.ALU??0}tock(){if(!this._state)return;const[t,e]=(0,g.Ff)(this.cpuInput(),this._state);this._state=e,this.out("addressM").busVoltage=t.addressM??0,this.out("outM").busVoltage=t.outM??0,this.out("writeM").pull(t.writeM?o.lj:o.yE),this.out("pc").busVoltage=this._state?.PC??0}cpuInput(){return{inM:this.in("inM").busVoltage,instruction:this.in("instruction").busVoltage,reset:1===this.in("reset").busVoltage}}get(t,e){return t?.startsWith("ARegister")?new o.qP("ARegister",this._state.A):t?.startsWith("DRegister")?new o.qP("DRegister",this._state.D):t?.startsWith("PC")?new o.qP("PC",this._state.PC):super.get(t,e)}reset(){this._state=(0,g.Zu)(),this._state.PC=-1,super.reset()}}class C extends o.Af{#t=new j;#e=new v;#s=new f;constructor(){super(["reset"],[]),this.wire(this.#t,[{from:{name:"reset",start:0},to:{name:"reset",start:0}},{from:{name:"instruction",start:0},to:{name:"instruction",start:0}},{from:{name:"oldOutM",start:0},to:{name:"inM",start:0}},{from:{name:"writeM",start:0},to:{name:"writeM",start:0}},{from:{name:"addressM",start:0},to:{name:"addressM",start:0}},{from:{name:"newInM",start:0},to:{name:"outM",start:0}},{from:{name:"pc",start:0},to:{name:"pc",start:0}}]),this.wire(this.#s,[{from:{name:"pc",start:0},to:{name:"address",start:0}},{from:{name:"instruction",start:0},to:{name:"out",start:0}}]),this.wire(this.#e,[{from:{name:"newInM",start:0},to:{name:"in",start:0}},{from:{name:"writeM",start:0},to:{name:"load",start:0}},{from:{name:"addressM",start:0},to:{name:"address",start:0}},{from:{name:"oldOutM",start:0},to:{name:"out",start:0}}])}eval(){super.eval()}get(t,e){return t.startsWith("PC")||t.startsWith("ARegister")||t.startsWith("DRegister")?this.#t.get(t):t.startsWith("RAM16K")?this.#e.get(t,e):super.get(t,e)}async load(t,e){return await this.#s.load(t,e)}}var w=s(7054);class V extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[1===t&&1===e?o.lj:o.yE]}(t,e);this.out().pull(s)}}class P extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[t&e&65535]}(t,e);this.out().busVoltage=s}}class S extends o.Af{constructor(){super(["in","sel"],["a","b"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").voltage(),[s,i]=function(t,e){return[e===o.yE&&t===o.lj?o.lj:o.yE,e===o.lj&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i)}}class k extends o.Af{constructor(){super(["in","sel[2]"],["a","b","c","d"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").busVoltage,[s,i,n,a]=function(t,e){return[0===e&&t===o.lj?o.lj:o.yE,1===e&&t===o.lj?o.lj:o.yE,2===e&&t===o.lj?o.lj:o.yE,3===e&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i),this.out("c").pull(n),this.out("d").pull(a)}}class A extends o.Af{constructor(){super(["in","sel[3]"],["a","b","c","d","e","f","g","h"])}eval(){const t=this.in("in").voltage(),e=this.in("sel").busVoltage,[s,i,n,a,r,l,c,u]=function(t,e){return[0===e&&t===o.lj?o.lj:o.yE,1===e&&t===o.lj?o.lj:o.yE,2===e&&t===o.lj?o.lj:o.yE,3===e&&t===o.lj?o.lj:o.yE,4===e&&t===o.lj?o.lj:o.yE,5===e&&t===o.lj?o.lj:o.yE,6===e&&t===o.lj?o.lj:o.yE,7===e&&t===o.lj?o.lj:o.yE]}(t,e);this.out("a").pull(s),this.out("b").pull(i),this.out("c").pull(n),this.out("d").pull(a),this.out("e").pull(r),this.out("f").pull(l),this.out("g").pull(c),this.out("h").pull(u)}}function E(t,e,s){return[s===o.yE?t:e]}function F(t,e,s,i,n){const a=1&n;return 0===(2&n)?E(t,e,a):E(s,i,a)}class M extends o.Af{constructor(){super(["a","b","sel"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),s=this.in("sel").voltage(),[i]=function(t,e,s){return[s===o.yE?t:e]}(t,e,s);this.out().pull(i)}}class I extends o.Af{constructor(){super(["a[16]","b[16]","sel"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("sel").voltage(),[i]=E(t,e,s);this.out().busVoltage=i}}class O extends o.Af{constructor(){super(["a[16]","b[16]","c[16]","d[16]","sel[2]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("c").busVoltage,i=this.in("d").busVoltage,n=this.in("sel").busVoltage,[a]=F(t,e,s,i,n);this.out().busVoltage=a}}class _ extends o.Af{constructor(){super(["a[16]","b[16]","c[16]","d[16]","e[16]","f[16]","g[16]","h[16]","sel[3]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,s=this.in("c").busVoltage,i=this.in("d").busVoltage,n=this.in("e").busVoltage,a=this.in("f").busVoltage,r=this.in("g").busVoltage,o=this.in("h").busVoltage,l=this.in("sel").busVoltage,[c]=function(t,e,s,i,n,a,r,o,l){const c=3&l;return 0===(4&l)?F(t,e,s,i,c):F(n,a,r,o,c)}(t,e,s,i,n,a,r,o,l);this.out().busVoltage=c}}class T extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[1===t&&1===e?o.yE:o.lj]}(t,e);this.out().pull(s)}}class R extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage;this.out().busVoltage=(0,m.C2)(t,e)}}class N extends o.Af{constructor(){super(["in"],["out"])}eval(){const t=this.in("in").voltage(),[e]=[t===o.yE?o.lj:o.yE];this.out().pull(e)}}class L extends o.Af{constructor(){super(["in[16]"],["out[16]"])}eval(){const[t]=[65535&~this.in().busVoltage];this.out().busVoltage=t}}function W(t,e){return[1===t||1===e?o.lj:o.yE]}class U extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=W(t,e);this.out().pull(s)}}class D extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[65535&(t|e)]}(t,e);this.out().busVoltage=s}}class B extends o.Af{constructor(){super(["in[8]"],["out"],"Or8way")}eval(){const t=this.in().busVoltage,[e]=[0===(255&t)?o.yE:o.lj];this.out().pull(e)}}class $ extends o.Af{constructor(){super(["a","b"],["out"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s]=function(t,e){return[t===o.lj&&e===o.yE||t===o.yE&&e===o.lj?o.lj:o.yE]}(t,e);this.out().pull(s)}}class z extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"])}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=function(t,e){return[65535&(t^e)]}(t,e);this.out().busVoltage=s}}function H(t,e){return[t+e&65535]}class G extends o.Af{constructor(){super(["a[16]","b[16]"],["out[16]"],"Add16")}eval(){const t=this.in("a").busVoltage,e=this.in("b").busVoltage,[s]=H(t,e);this.out().busVoltage=s}}var K=s(137);class J extends o.Af{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]"],"ALU")}eval(){const t=this.in("x").busVoltage,e=this.in("y").busVoltage,s=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0),[i]=(0,K.Bb)(s,t,e);this.out().busVoltage=i}}class Z extends o.Af{constructor(){super(["x[16]","y[16]","zx","nx","zy","ny","f","no"],["out[16]","zr","ng"],"ALU")}eval(){const t=this.in("x").busVoltage,e=this.in("y").busVoltage,s=(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0),[i,n]=(0,K.Bb)(s,t,e),a=n===K.vU.Negative?o.lj:o.yE,r=n===K.vU.Zero?o.lj:o.yE;this.out("out").busVoltage=i,this.out("ng").pull(a),this.out("zr").pull(r)}op(){return(this.in("zx").busVoltage<<5)+(this.in("nx").busVoltage<<4)+(this.in("zy").busVoltage<<3)+(this.in("ny").busVoltage<<2)+(this.in("f").busVoltage<<1)+(this.in("no").busVoltage<<0)}}function q(t,e){return[1===t&&0===e||0===t&&1===e?o.lj:o.yE,1===t&&1===e?o.lj:o.yE]}class X extends o.Af{constructor(){super(["a","b"],["sum","carry"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),[s,i]=q(t,e);this.out("sum").pull(s),this.out("carry").pull(i)}}class Y extends o.Af{constructor(){super(["a","b","c"],["sum","carry"])}eval(){const t=this.in("a").voltage(),e=this.in("b").voltage(),s=this.in("c").voltage(),[i,n]=function(t,e,s){const[i,n]=q(t,e),[a,r]=q(i,s),[o]=W(n,r);return[a,o]}(t,e,s);this.out("sum").pull(i),this.out("carry").pull(n)}}class Q extends o.Af{constructor(){super(["in[16]"],["out[16]"],"Inc16")}eval(){const t=this.in().busVoltage,[e]=H(t,1);this.out().busVoltage=e}}class tt extends o.tI{bit=o.yE;constructor(t){super(["in","load"],["out"],t)}tick(){this.in("load").voltage()===o.lj&&(this.bit=this.in().voltage())}tock(){this.out().pull(this.bit??0)}reset(){this.bit=o.yE,super.reset()}}class et extends o.tI{bits=0;constructor(t){super(["in[16]","load"],["out[16]"],t)}tick(){this.in("load").voltage()===o.lj&&(this.bits=65535&this.in().busVoltage)}tock(){this.out().busVoltage=65535&this.bits}get(t,e){return t===this.name?this.out():super.get(t,e)}reset(){this.bits=0,super.reset()}}class st extends et{}class it extends o.tI{bits=0;constructor(t){super(["in[16]","load","inc","reset"],["out[16]"],t)}tick(){this.in("reset").voltage()===o.lj?this.bits=0:this.in("load").voltage()===o.lj?this.bits=65535&this.in().busVoltage:this.in("inc").voltage()===o.lj&&(this.bits+=1)}tock(){this.out().busVoltage=65535&this.bits}get(t,e){return t===this.name?this.out():super.get(t,e)}reset(){this.bits=0,super.reset()}}class nt extends o.tI{constructor(t){super(["in"],["out"],t,["t"])}tick(){const t=this.in().voltage();this.pin("t").pull(t)}tock(){const t=this.pin("t").voltage();this.out().pull(t)}}const at=new Map([["Nand",T],["Nand16",R],["Not",N],["Not16",L],["And",V],["And16",P],["Or",U],["Or16",D],["Or8Way",B],["XOr",$],["XOr16",z],["Xor",$],["Xor16",z],["Mux",M],["Mux16",I],["Mux4Way16",O],["Mux8Way16",_],["DMux",S],["DMux4Way",k],["DMux8Way",A],["HalfAdder",X],["FullAdder",Y],["Add16",G],["Inc16",Q],["ALU",Z],["ALUNoStat",J],["DFF",nt],["Bit",tt],["Register",et],["ARegister",et],["DRegister",et],["PC",it],["RAM8",h],["RAM64",class extends u{constructor(t){super(6,t)}}],["RAM512",class extends u{constructor(t){super(9,t)}}],["RAM4K",class extends u{constructor(t){super(12,t)}}],["RAM16K",p],["ROM32K",f],["Screen",x],["Keyboard",y],["CPU",j],["Computer",C],["Memory",v],["ARegister",st],["DRegister",st]].map((t=>{let[e,s]=t;return[e,()=>{const t=new s;return t.name=e,t}]})));function rt(t){const e=at.get(t);return e?(0,w.Ok)(e()):(0,w.UG)(new Error(`Chip ${t} not in builtin registry`))}const ot=t=>{let{A:e,op:s,D:i,out:n,flag:a}=t;return(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{children:"ALU"}),(0,r.jsx)("svg",{width:"250",height:"250",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsxs)("g",{children:[(0,r.jsx)("rect",{x:"1",y:"20",height:"85",width:"70",fill:"black"}),(0,r.jsx)("rect",{x:"1",y:"145",height:"85",width:"70",fill:"black"}),(0,r.jsx)("rect",{x:"180",y:"95",height:"60",width:"70",fill:"black"}),(0,r.jsx)("polygon",{points:"70,10 180,85 180,165 70,240 70,135 90,125 70,115",stroke:"#000",fill:"#6D97AB"}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",strokeWidth:"0",id:"svg_9",y:"63",x:"35",stroke:"white",fill:"#ffffff",children:e}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_10",y:"188",x:"35",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:i}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_11",y:"125",x:"215",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:n}),(0,r.jsx)("text",{xmlSpace:"preserve",textAnchor:"middle",fontFamily:"Noto Sans JP",fontSize:"14",id:"svg_13",y:"125",x:"135",strokeWidth:"0",stroke:"white",fill:"#ffffff",children:K.NM.op[s]??"(??)"})]})})]})};var lt=s(3478),ct=s(1062),ut=s(2869),dt=s(8963);function ht(t,e){if(t instanceof Z)return(0,r.jsx)(ot,{A:t.in("x").busVoltage,op:t.op(),D:t.in("y").busVoltage,out:t.out().busVoltage,flag:t.out("zr").voltage()===o.lj?K.vU.Zero:t.out("ng").voltage()===o.lj?K.vU.Negative:K.vU.Positive});if(t instanceof et)return(0,r.jsx)(ut.y,{name:t.name??`Chip ${t.id}`,bits:t.bits});if(t instanceof it)return(0,r.jsx)(ut.y,{name:"PC",bits:t.bits});if(t instanceof y)return(0,r.jsx)(lt.N,{keyboard:t,update:e});if(t instanceof x)return(0,r.jsx)(dt.l,{memory:t.memory});if(t instanceof u)return(0,r.jsx)(ct.zp,{name:t.name,memory:t.memory,format:t instanceof f?"asm":"dec",highlight:t.address});if(t instanceof h)return(0,r.jsxs)("span",{children:["RAM ",t.width]});if(t instanceof j){const e=(0,g.Jx)(t.in("instruction").busVoltage);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ut.y,{name:"A",bits:t.state.A}),(0,r.jsx)(ut.y,{name:"D",bits:t.state.D}),(0,r.jsx)(ut.y,{name:"PC",bits:t.state.PC}),(0,r.jsx)(ot,{A:e.am?t.in("inM").busVoltage:t.state.A,D:t.state.D,out:t.state.ALU,op:e.op,flag:t.state.flag})]})}const s=[...t.parts].map((t=>ht(t,e))).filter((t=>void 0!==t));return s.length>0?(0,r.jsx)(r.Fragment,{children:s}):void 0}var pt=s(5554),gt=s(1965),mt=s(8177);class bt{signBehaviors=new Map;constructor(t,e){if(at.has(t)){const s=rt(t);if((0,w.IY)(s)){const t=Array.from((0,w.Ok)(s).ins.entries()).concat(Array.from((0,w.Ok)(s).outs.entries()));for(const s of t)this.signBehaviors.set(s.name,!e||!e.includes(s.name))}}}isSigned(t){return this.signBehaviors.get(t)}}const ft=new Map([["Mux4Way16",["sel"]],["Mux8Way16",["sel"]],["DMux4Way",["sel"]],["DMux8Way",["sel"]],["RAM8",["address"]],["RAM64",["address"]],["RAM512",["address"]],["RAM4K",["address"]],["RAM16K",["address"]],["Screen",["address"]],["Memory",["address"]],["CPU",["addressM","pc"]]]),xt=(0,a.createContext)({});function yt(t){return{pin:t,bits:(0,mt.w)(0,t.width).map((e=>[e,t.voltage(e)])).reverse()}}function vt(t){return[...t.entries()].map(yt)}const jt=t=>{const{inPins:e,outPins:s,internalPins:i}=t.sim,n=(a=t.sim.chip[0].name??"",new bt(a,ft.get(a)));var a;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:"\n table.pinout th {\n font-weight: bold;\n }\n\n table.pinout tbody td:first-child {\n text-align: right;\n --font-size: 1rem;\n width: 0;\n white-space: nowrap;\n border-right: var(--border-width) solid var(--table-border-color);\n }\n\n table.pinout tbody button {\n --font-size: 0.875em;\n font-family: var(--font-family-monospace);\n max-width: 2em;\n }\n "}),(0,r.jsx)("table",{className:"pinout",children:(0,r.jsxs)("tbody",{children:[(0,r.jsx)(Ct,{pins:e,header:"Input pins",toggle:t.toggle,setInputValid:t.setInputValid,displayInfo:n}),(0,r.jsx)(Ct,{pins:s,header:"Output pins",disabled:t.sim.pending,enableEdit:!1,displayInfo:n}),!t.hideInternal&&(0,r.jsx)(Ct,{pins:i,header:"Internal pins",disabled:t.sim.pending,enableEdit:!1,displayInfo:n})]})})]})},Ct=t=>(0,r.jsxs)(r.Fragment,{children:[t.pins.length>0&&(0,r.jsx)("tr",{children:(0,r.jsx)("th",{colSpan:2,children:t.header})}),[...t.pins].map((e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.pin.name}),(0,r.jsx)("td",{children:(0,r.jsx)(wt,{pin:e,toggle:t.toggle,disabled:t.disabled,enableEdit:t.enableEdit,signed:t.displayInfo.isSigned(e.pin.name),setInputValid:t.setInputValid,internal:"Internal pins"===t.header})})]},e.pin.name)))]}),wt=t=>{let{pin:e,toggle:s,disabled:i=!1,enableEdit:n=!0,signed:o=!0,setInputValid:l,internal:c=!1}=t;const[u,d]=(0,a.useState)(!0);let h=!0;const[p,g]=(0,a.useState)(""),m=(0,a.useContext)(xt);m instanceof Vt&&m.registerCallback((()=>{d(!0)}));const b=t=>{h=t,l?.(t)},f=t=>{for(let i=0;i>i&1)&&s?.(e.pin,i)};return(0,a.useEffect)((()=>{if(!u&&h){let t=0;if(o&&e.bits[0][1]){for(const[s,i]of e.bits)s{let[n,a]=t;return(0,r.jsx)("button",{disabled:i,style:c?{backgroundColor:"grey"}:{},onClick:()=>s?.(e.pin,n),"data-testid":`pin-${n}`,children:a},n)})):(0,r.jsx)("input",{className:"colored",value:p,onChange:t=>{(t=>{const s=t.replace(/[^\d]/g,""),i=o&&"-"===t[0]?`-${s}`:s;if(g(i),isNaN(parseInt(i)))b(!1);else{const t=parseInt(i);!o&&t>=Math.pow(2,e.bits.length)||o&&(t>=Math.pow(2,e.bits.length-1)||t<-Math.pow(2,e.bits.length-1))?b(!1):(f(t),b(!0))}})(t.target.value)},disabled:!n})}),e.bits.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{width:"1em"}}),(0,r.jsx)("button",{style:{maxWidth:"3em",margin:0},onClick:()=>{d(!u)},children:u?"dec":"bin"})]})]})};class Vt{callbacks=[];registerCallback(t){this.callbacks.push(t)}reset(){for(const t of this.callbacks)t()}}var Pt=s(6604),St=s(6791),kt=s(5692),At=s(554),Et=s(168),Ft=s(9814),Mt=s(3484);const It='\nHdl <: Base{\n Root := Chip\n Chip = "CHIP" Name OpenBrace ChipBody CloseBrace\n ChipBody = InList? OutList? PartList ClockedList?\n InList = "IN" PinList Semi\n OutList = "OUT" PinList Semi\n PartList = BuiltinPart | Parts\n PinList = List\n PinDecl = Name PinWidth?\n PinWidth = OpenSquare decNumber CloseSquare\n BuiltinPart = "BUILTIN" Semi\n Parts = "PARTS:" Part*\n Part = Name "(" Wires ")" Semi\n Wires = List\n Wire = WireSide Equal (WireSide | True | False) \n WireSide = Name SubBus? \n SubBus = OpenSquare decNumber subBusRest? CloseSquare\n subBusRest = ".." decNumber\n ClockedList = "CLOCKED" SimplePinList Semi\n SimplePinList = List\n}',Ot=Ft.Z.grammar(It,Mt.y1),_t=Ot.extendSemantics(Mt.rJ);_t.addAttribute("SubBus",{SubBus(t,e,s,i){const n=e.value;return{start:n,end:s.child(0)?.child(1)?.value??n}}}),_t.addAttribute("WireSide",{WireSide(t,e){let{name:s}=t;const{start:i,end:n}=e.child(0)?.SubBus??{start:void 0,end:void 0};return{pin:s,start:i,end:n,span:(0,Mt.yP)(this.source)}}}),_t.addAttribute("Wire",{Wire(t,e,s){const i=s.isTerminal()?{pin:s.sourceString}:s.WireSide;return{lhs:t.WireSide,rhs:i}}}),_t.addAttribute("Wires",{Wires:t=>t.asIteration().children.map((t=>t.Wire))}),_t.addAttribute("Part",{Part(t,e,s,i,n){let{name:a}=t,{Wires:r}=s;return{name:a,wires:r,span:(0,Mt.yP)(this.source)}}}),_t.addAttribute("Parts",{Parts:(t,e)=>e.children.map((t=>t.Part)),BuiltinPart:(t,e)=>"BUILTIN"}),_t.addAttribute("PartList",{PartList:t=>t.Parts}),_t.addAttribute("Clocked",{ClockedList:(t,e,s)=>e.asIteration().children.map((t=>{let{sourceString:e}=t;return e}))??[]}),_t.addAttribute("PinDecl",{PinDecl(t,e){let{name:s}=t;return{pin:s,width:e.child(0)?.child(1)?.value??1}}}),_t.addAttribute("PinList",{PinList:t=>t.asIteration().children.map((t=>t.PinDecl))}),_t.addAttribute("Chip",{Chip(t,e,s,i,n){let{name:a}=e;return{name:a,ins:i.child(0).child(0)?.child(1)?.PinList??[],outs:i.child(1).child(0)?.child(1)?.PinList??[],parts:i.child(2).PartList??[],clocked:i.child(3).child(0)?.Clocked}}}),_t.addAttribute("Root",{Root:t=>t.child(0)?.Chip});const Tt={parser:Ot,grammar:It,semantics:_t,parse:(0,Mt.Pz)(Ot,_t,(t=>t.Chip))};function Rt(t,e){if(void 0!==e){if(e>=t)return e-t+1;if(t>0&&0===e)return 1;throw new Error(`Bus specification has start > end (${t} > ${e})`)}}async function Nt(t,e){if(function(t){return at.has(t)}(t)||void 0===e)return rt(t);try{const s=await e.readFile(`${t}.hdl`),i=Tt.parse(s);let n;if((0,w.IY)(i)){const t=await Lt((0,w.Ok)(i),e);n=(0,w.dZ)(t)?(0,w.UG)(new Error((0,w.UG)(t).message)):t}else n=(0,w.UG)(new Error("HDL Was not parsed"));return n}catch(s){return(0,w.UG)(new Error(`Could not load chip ${t}.hdl`))}}async function Lt(t,e){if("BUILTIN"===t.parts)return rt(t.name.toString());const s=new o.Af(t.ins.map((t=>{let{pin:e,width:s}=t;return{pin:e.toString(),width:s}})),t.outs.map((t=>{let{pin:e,width:s}=t;return{pin:e.toString(),width:s}})),t.name.toString(),[],t.clocked),i=new Map;for(const r of t.parts){const t=await Nt(r.name.toString(),e);if((0,w.dZ)(t))return(0,w.UG)({message:`Undefined chip name: ${r.name}`,span:r.span});const o=(0,w.Ok)(t),l=[];for(const{lhs:e,rhs:a}of r.wires){const t=!(s.isInPin(a.pin)||s.isOutPin(a.pin)||(n=a.pin,"false"===n.toLowerCase()||"true"===n.toLowerCase()||"0"===n||"1"===n));if(o.isInPin(e.pin)){if(t){const t=i.get(a.pin);void 0==t?i.set(a.pin,{isDefined:!1,firstUse:a.span}):t.firstUse=t.firstUse.start1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:t.clocked,inPins:vt(t.ins),outPins:vt(t.outs),internalPins:vt(t.pins),chip:[t],pending:e,invalid:s}}const Jt=Wt.S.get();function Zt(t,e,s,i){const n=function(t){const e=t["/chip/project"]??"01";return{project:e,chips:zt(e),chipName:t["/chip/chip"]??Et.CHIP_PROJECTS[e][0]}}(s);let{project:a,chipName:r}=n;const{chips:c}=n;let u=new o.P9,d=new Dt.l1,h=!1,p=!1;const g={setFiles(t,e){let{hdl:s=t.files.hdl,tst:i=t.files.tst,cmp:n=t.files.cmp,out:a=""}=e;t.files.hdl=s,t.files.tst=i,t.files.cmp=n,t.files.out=a},updateChip(t,e){t.sim=Kt(u,e?.pending??t.sim.pending,e?.invalid??t.sim.invalid),t.controls.error=t.sim.invalid?e?.error??t.controls.error:void 0},setProject(t,e){const s=zt(e),i=t.controls.chipName&&s.includes(t.controls.chipName)?t.controls.chipName:s[0];t.controls.project=e,t.controls.chips=s,this.setChip(t,i)},setChip(t,e){t.controls.chipName=e,t.controls.hasBuiltin=at.has(e),t.controls.builtinOnly=Ht(e)},testRunning(t){t.controls.runningTest=!0},testFinished(t){t.controls.runningTest=!1;const s=(0,Bt.q)(t.files.cmp.trim(),t.files.out.trim());e(s?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep(t){if(t.files.out=d?.log()??"",d?.currentStep?.span)t.controls.span=d.currentStep.span;else if(d.done){const e=t.files.tst.length;t.controls.span={start:e-1,end:e,line:t.files.tst.split("\n").length}}this.updateChip(t,{pending:t.sim.pending,invalid:t.sim.invalid})}},m={setProject(t){a=s["/chip/project"]=t,i.current({action:"setProject",payload:a}),this.setChip(Et.CHIP_PROJECTS[a][0])},async setChip(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s["/chip/project"]??"01";if(r=s["/chip/chip"]=t,i.current({action:"setChip",payload:r}),p=Ht(r),p)return i.current({action:"setFiles",payload:{hdl:"",tst:"",cmp:""}}),void this.useBuiltin();await this.loadChip(e,r),h&&this.useBuiltin()},reset(){Wt.S.get().reset(),u.reset(),d.reset(),i.current({action:"setFiles",payload:{}}),i.current({action:"updateChip"})},async updateFiles(t){let{hdl:s,tst:n,cmp:a}=t;i.current({action:"setFiles",payload:{hdl:s,tst:n,cmp:a}});try{s&&await this.compileChip(s),n&&this.compileTest(n)}catch(r){e((0,At.j)(r))}},async compileChip(t){u.remove();const s=await async function(t){const e=Tt.parse(t.toString());return(0,w.dZ)(e)?(0,w.UG)(function(t){if(!t.message)return{message:"HDL statement has a syntax error",span:t.span};const e=t.message.match(/Line \d+, col \d+: (?.*)/);return void 0!==e?.groups?.message?{message:e.groups.message,span:t.span}:{message:t.message,span:t.span}}((0,w.UG)(e))):Lt((0,w.Ok)(e))}(t);if((0,w.dZ)(s)){const t=(0,w.UG)(s);return e(`${void 0!=t.span?.line?`Line ${t.span.line}: `:""}${(0,w.UG)(s).message}`),void i.current({action:"updateChip",payload:{invalid:!0,error:t}})}(0,w.Ok)(s).name!=r?e("Warning: Chip name doesn't match selected chip"):(e(`Compiled ${r}`),e("HDL code: No syntax errors")),this.replaceChip((0,w.Ok)(s))},replaceChip(t){const e=u.ins;for(const[s,{busVoltage:i}]of e){const e=t.ins.get(s);e&&(e.busVoltage=i)}Jt.reset(),t.eval(),u=t,u.reset(),d=d.with(u).reset(),i.current({action:"updateChip",payload:{invalid:!1}}),i.current({action:"updateTestStep"})},async loadChip(e,n){s["/chip/chip"]=n;const a=t=>`/projects/${e}/${n}/${n}.${t}`,[r,o,l]=await Promise.all([t.readFile(a("hdl")).catch((()=>function(t){return`CHIP ${t} {\n IN in;\n OUT out;\n PARTS:\n}`}(n))),t.readFile(a("tst")).catch((t=>"repeat 10 {\n tick,\n tock;\n}")),t.readFile(a("cmp")).catch((()=>"| in|out|"))]);i.current({action:"setFiles",payload:{hdl:r,tst:o,cmp:l}}),await this.compileChip(r),this.compileTest(o)},async saveChip(s){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;i.current({action:"setFiles",payload:{hdl:s}});const l=`/projects/${n}/${o}/${o}.hdl`;await t.writeFile(l,s),e(`Saved ${l}`)},toggle(t,e){void 0!==e?t.busVoltage=t.busVoltage^1<1?arguments[1]:void 0;if(!(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]))return p||(h=!1),void await this.loadChip(a,r);p||(h=!0);const s=r,n=rt(s);if((0,w.dZ)(n))return void e(`Failed to load builtin ${s}: ${(0,At.j)((0,w.UG)(n))}`);t&&await this.saveChip(t,a,r);const o=Gt(a,s);i.current({action:"setFiles",payload:{hdl:o}}),this.replaceChip((0,w.Ok)(n))},async initialize(){await this.setChip(r,a)},compileTest(s){i.current({action:"setFiles",payload:{tst:s}});const n=Ut.qH.parse(s);return(0,w.dZ)(n)?(e("Failed to parse test"),!1):(d=Dt.l1.from((0,w.Ok)(n)).with(u).reset(),d.setFileSystem(t),i.current({action:"updateTestStep"}),!0)},async runTest(e){this.compileTest(e)&&(i.current({action:"testRunning"}),t.pushd("/samples"),await d.run(),t.popd(),i.current({action:"updateTestStep"}),i.current({action:"testFinished"}))},tick(){return this.stepTest()},stepTest(){(0,l.hu)(d.chipId===u.id,"Test and chip out of sync");const t=d.step();return i.current({action:"updateTestStep"}),t&&i.current({action:"testFinished"}),t},resetFile(){const t=Et.ChipProjects[a].CHIPS[r][`${r}.hdl`];i.current({action:"setFiles",payload:{hdl:t}})}};return{initialState:(()=>{const t={project:a,chips:c,chipName:r,hasBuiltin:at.has(r),builtinOnly:Ht(r),runningTest:!1,error:void 0},s=rt(t.chipName);(0,w.dZ)(s)?(e((0,At.j)((0,w.UG)(s))),u=new o.P9):u=(0,w.Ok)(s);return{controls:t,files:{hdl:"",cmp:"",tst:"",out:""},sim:Kt(u)}})(),reducers:g,actions:m}}var qt=s(7880),Xt=s(4619),Yt=s(8722),Qt=s(3847),te=s(9200),ee=s(8398);const se=()=>{const{fs:t,setStatus:e}=(0,a.useContext)(kt.r),{filePicker:s,tracking:o}=(0,a.useContext)(Yt.Il),{state:l,actions:c,dispatch:u}=function(){const{fs:t,setStatus:e,storage:s}=(0,a.useContext)(kt.r),i=(0,a.useRef)((()=>{})),{initialState:n,reducers:r,actions:o}=(0,a.useMemo)((()=>Zt(t,e,s,i)),[t,e,s,i]),[l,c]=(0,Pt.C)(r,n);return i.current=c,{state:l,dispatch:i,actions:o}}(),[d,h]=(0,Pt.i)(l.files.hdl),[p,g]=(0,Pt.i)(l.files.tst),[m,b]=(0,Pt.i)(l.files.cmp),[f]=(0,Pt.i)(l.files.out);(0,a.useEffect)((()=>{c.initialize()}),[c]),(0,a.useEffect)((()=>{o.trackPage("/chip")}),[o]),(0,a.useEffect)((()=>{o.trackEvent("action","setProject",l.controls.project),o.trackEvent("action","setChip",l.controls.chipName)}),[]);const x=(0,a.useCallback)((t=>{c.setProject(t),o.trackEvent("action","setProject",t)}),[c,o]),y=(0,a.useCallback)((t=>{c.setChip(t),o.trackEvent("action","setChip",t),R.reset()}),[c,o]),v=(0,a.useCallback)((()=>{c.eval(),o.trackEvent("action","eval")}),[c,o]),j=(0,a.useRef)((()=>{}));j.current=async function(){var t,e;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await c.updateFiles({hdl:s.hdl,tst:null!==(t=s.tst)&&void 0!==t?t:p,cmp:null!==(e=s.cmp)&&void 0!==e?e:m})};const C=(0,a.useCallback)((async()=>{try{const e=await s.select(),i=await t.readFile(e);await j.current({tst:i})}catch(i){console.error(i),e("Failed to load into memory")}}),[s,e,t,j]),w=(0,a.useRef)();(0,a.useEffect)((()=>(w.current=new class extends Xt.B{async reset(){await j.current(),await c.reset()}finishFrame(){super.finishFrame(),u.current({action:"updateTestStep"})}async tick(){return await c.stepTest()}toggle(){u.current({action:"updateTestStep"})}},()=>{var t;null===(t=w.current)||void 0===t||t.stop()})),[j,c,u]);const V=(0,a.useMemo)((()=>({toggle(){c.clock(),o.trackEvent("action","toggleClock")},reset(){o.trackEvent("action","resetClock"),c.reset()}})),[c]),[P,S]=(0,a.useState)(!1),k=(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("fieldset",{role:"group",children:[(0,r.jsx)("select",{value:l.controls.project,onChange:t=>{let{target:{value:e}}=t;x(e)},"data-testid":"project-picker",children:$t.map((t=>{let[e,s]=t;return(0,r.jsx)("option",{value:e,children:s},e)}))}),(0,r.jsx)("select",{value:l.controls.chipName,onChange:t=>{let{target:{value:e}}=t;y(e)},"data-testid":"chip-picker",children:l.controls.chips.map((t=>(0,r.jsx)("option",{value:t,style:Ht(t)?{color:"rgb(170, 170, 170)"}:{},children:`${t} ${Ht(t)?"(given)":""}`},t)))}),!P&&!l.controls.builtinOnly&&(0,r.jsx)("button",{className:"flex-0",onClick:c.resetFile,children:(0,r.jsx)(i.cC,{id:"Reset"})})]})}),A=(0,r.jsx)(ee.s,{className:"_hdl_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{tabIndex:0,children:"HDL"}),(0,r.jsx)("fieldset",{children:l.controls.hasBuiltin&&!l.controls.builtinOnly&&(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",role:"switch",checked:P,onChange:()=>{P?(S(!1),c.useBuiltin(!1)):(S(!0),c.useBuiltin(!0,d)),R.reset()}}),(0,r.jsx)(i.cC,{id:"Builtin"})]})}),k]}),children:(0,r.jsx)(te.M,{className:"flex-1",value:d,error:l.controls.error,onChange:async t=>{h(t),P||await c.saveChip(t),j.current(P||l.controls.builtinOnly?{}:{hdl:t})},grammar:Tt.parser,language:"hdl",disabled:P||l.controls.builtinOnly})}),[E,F]=(0,a.useState)(!0),M=()=>{e(n.ag._("Cannot test a chip that has syntax errors"))},I=()=>{j.current(P||l.controls.builtinOnly?{}:{hdl:d})},O=()=>{l.sim.invalid?M():v()},_=(0,r.jsxs)("fieldset",{role:"group",children:[(0,r.jsx)("button",{onClick:O,onKeyDown:O,onBlur:I,disabled:!l.sim.pending||!E,children:(0,r.jsx)(i.cC,{id:"Eval"})}),(0,r.jsxs)("button",{onClick:()=>{l.sim.invalid?M():V.toggle()},onBlur:I,style:{maxWidth:"initial"},disabled:!l.sim.clocked,children:[(0,r.jsx)(i.cC,{id:"Clock"}),":","\xa0",(0,r.jsx)(pt.uY,{})]}),(0,r.jsx)("button",{onClick:()=>{l.sim.invalid?M():V.reset()},onBlur:I,style:{maxWidth:"initial"},disabled:!l.sim.clocked,children:(0,r.jsx)(i.cC,{id:"Reset"})})]}),T=function(t,e){return[...t.parts].map(((t,s)=>[`${t.id}_${s}`,ht(t,e)])).filter((t=>{let[e,s]=t;return void 0!==s}))}({parts:l.sim.chip},(()=>{u.current({action:"updateChip"})})),R=new Vt,N=(0,r.jsx)(ee.s,{className:"_parts_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(i.cC,{id:"Chip"})," ",l.controls.chipName]}),_]}),children:l.sim.invalid?(0,r.jsx)(i.cC,{id:"Syntax errors in the HDL code"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xt.Provider,{value:R,children:(0,r.jsx)(jt,{sim:l.sim,toggle:c.toggle,setInputValid:F,hideInternal:l.controls.builtinOnly||P})}),T.length>0&&(0,r.jsx)(ee.G,{summary:(0,r.jsx)(i.cC,{id:"Visualization"}),open:!0,children:(0,r.jsx)("main",{children:T.map((t=>{let[e,s]=t;return s}))})})]})}),[L,W]=(0,a.useState)("tst"),U=(0,a.useCallback)((t=>{W(t),o.trackEvent("tab","change",t)}),[o]),D=(0,r.jsx)(ee.s,{className:"_test_panel",header:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(i.cC,{id:"Test"})}),(0,r.jsx)("div",{className:"flex-2",children:w.current&&(0,r.jsx)(St.D,{runner:w.current,disabled:l.sim.invalid})}),(0,r.jsx)("div",{children:(0,r.jsxs)("button",{onClick:C,children:[(0,r.jsx)(Qt.J,{name:"upload_file"})," "]})})]}),children:(0,r.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,r.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===L,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===L,onChange:()=>U("tst")}),"Test Script"]})}),(0,r.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,r.jsx)(te.M,{value:p,onChange:g,grammar:Ut.qH.parser,language:"tst",highlight:l.controls.span,disabled:l.controls.builtinOnly})}),(0,r.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===L,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===L,onChange:()=>U("cmp")}),"Compare File"]})}),(0,r.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,r.jsx)(te.M,{value:m,onChange:b,grammar:qt.lA.parser,language:"cmp",disabled:l.controls.builtinOnly})}),(0,r.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===L,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===L,onChange:()=>U("out")}),"Output File"]})}),(0,r.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,r.jsx)(gt.M,{cmp:m,out:f})})]})});return(0,r.jsxs)("div",{className:"Page ChipPage grid",children:[A,N,D]})},ie=se}}]); \ No newline at end of file diff --git a/static/js/main.73540501.js b/static/js/main.7ae39c93.js similarity index 99% rename from static/js/main.73540501.js rename to static/js/main.7ae39c93.js index da9d0aca4..6c14b8f6d 100644 --- a/static/js/main.73540501.js +++ b/static/js/main.7ae39c93.js @@ -1,2 +1,2 @@ -/*! For license information please see main.73540501.js.LICENSE.txt */ -(()=>{var e={8722:(e,t,n)=>{"use strict";n.d(t,{Il:()=>f,bp:()=>c});var r=n(2608),a=n(6845),o=n(7457),l=n(8849),i=n(6839);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)(),[o,l]=(0,a.useState)(),[i,u]=(0,a.useState)();return{tool:e,setTool:t,cpuState:{rom:n,name:o},setCpuState:(e,t)=>{l(e),r(t)},asmState:i,setAsmState:u}}function c(){arguments.length>0&&void 0!==arguments[0]||new r.Wd;const[e,t]=(0,a.useState)("system");return{monaco:u(),settings:(0,o.R)(),filePicker:(0,l.ss)(),tracking:(0,i.rS)(),theme:e,setTheme:t,toolStates:s()}}const f=(0,a.createContext)({monaco:{canUse:!0,wants:!0,toggle(){}},filePicker:{close(){},open(){},select:()=>Promise.reject(""),isOpen:!1},settings:{close(){},open(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept(){},reject(){},trackEvent(){},trackPage(){}},theme:"system",setTheme(){},toolStates:{tool:void 0,setTool(){},cpuState:{rom:void 0,name:void 0},setCpuState(){},asmState:{asm:"",asmName:void 0,translating:!1,current:-1,resultHighlight:void 0,sourceHighlight:void 0,symbols:[],result:"",compare:"",compareName:void 0,lineNumbers:[]},setAsmState(){}}})},8852:e=>{e.exports={messages:{"Allow anonymous interaction tracking":"\xc0\u013a\u013a\u014d\u0175 \xe0\u0144\u014d\u0144\u0177m\u014d\u0169\u015b \u0129\u0144\u0163\u0113\u0155\xe0\u0107\u0163\u0129\u014d\u0144 \u0163\u0155\xe0\u0107\u0137\u0129\u0144\u011d","Binary Code":"\xdf\u0129\u0144\xe0\u0155\u0177 \u0106\u014d\u010f\u0113",Builtin:"\xdf\u0169\u0129\u013a\u0163\u0129\u0144",Chip:"\u0106\u0125\u0129\u01a5","Choose file":"\u0106\u0125\u014d\u014d\u015b\u0113 \u0192\u0129\u013a\u0113",Clock:"\u0106\u013a\u014d\u0107\u0137",Compare:"\u0106\u014dm\u01a5\xe0\u0155\u0113",Dark:"\u010e\xe0\u0155\u0137",Editor:"\u0112\u010f\u0129\u0163\u014d\u0155",English:"\u0112\u0144\u011d\u013a\u0129\u015b\u0125",Eval:"\u0112v\xe0\u013a",Failed:"\u0191\xe0\u0129\u013a\u0113\u010f",Files:"\u0191\u0129\u013a\u0113\u015b",Language:"\u0139\xe0\u0144\u011d\u0169\xe0\u011d\u0113",Light:"\u0139\u0129\u011d\u0125\u0163","Parse Error":"\u01a4\xe0\u0155\u015b\u0113 \u0112\u0155\u0155\u014d\u0155",Passed:"\u01a4\xe0\u015b\u015b\u0113\u010f",Project:"\u01a4\u0155\u014d\u0134\u0113\u0107\u0163",Pseudolocale:"\u01a4\u015b\u0113\u0169\u010f\u014d\u013a\u014d\u0107\xe0\u013a\u0113",References:"\u0154\u0113\u0192\u0113\u0155\u0113\u0144\u0107\u0113\u015b",Reset:"\u0154\u0113\u015b\u0113\u0163",Samples:"\u015a\xe0m\u01a5\u013a\u0113\u015b",Settings:"\u015a\u0113\u0163\u0163\u0129\u0144\u011d\u015b",Source:"\u015a\u014d\u0169\u0155\u0107\u0113","Syntax errors in the HDL code":"\u015a\u0177\u0144\u0163\xe0x \u0113\u0155\u0155\u014d\u0155\u015b \u0129\u0144 \u0163\u0125\u0113 \u0124\u010e\u0139 \u0107\u014d\u010f\u0113",System:"\u015a\u0177\u015b\u0163\u0113m",Test:"\u0162\u0113\u015b\u0163",Theme:"\u0162\u0125\u0113m\u0113",Tracking:"\u0162\u0155\xe0\u0107\u0137\u0129\u0144\u011d","Use Monaco Editor":"\u0168\u015b\u0113 M\u014d\u0144\xe0\u0107\u014d \u0112\u010f\u0129\u0163\u014d\u0155",Visualization:"V\u0129\u015b\u0169\xe0\u013a\u0129\u017a\xe0\u0163\u0129\u014d\u0144","{0}":[["0"]]}}},1711:e=>{e.exports={messages:{"Allow anonymous interaction tracking":"Allow anonymous interaction tracking","Binary Code":"Binary Code",Builtin:"Builtin",Chip:"Chip","Choose file":"Choose file",Clock:"Clock",Compare:"Compare",Dark:"Dark",Editor:"Editor",English:"English",Eval:"Eval",Failed:"Failed",Files:"Files",Language:"Language",Light:"Light","Parse Error":"Parse Error",Passed:"Passed",Project:"Project",Pseudolocale:"Pseudolocale",References:"References",Reset:"Reset",Samples:"Samples",Settings:"Settings",Source:"Source","Syntax errors in the HDL code":"Syntax errors in the HDL code",System:"System",Test:"Test",Theme:"Theme",Tracking:"Tracking","Use Monaco Editor":"Use Monaco Editor",Visualization:"Visualization","{0}":[["0"]]}}},3847:(e,t,n)=>{"use strict";n.d(t,{J:()=>a});var r=n(864);const a=e=>{let{name:t}=e;return(0,r.jsx)("span",{className:"material-symbols-outlined",children:t})}},7457:(e,t,n)=>{"use strict";n.d(t,{R:()=>a});var r=n(6845);function a(){const[e,t]=(0,r.useState)(!1);return{isOpen:e,open(){t(!0)},close(){t(!1)}}}},8849:(e,t,n)=>{"use strict";n.d(t,{GB:()=>p,ss:()=>f});var r=n(5072),a=n(5692),o=n(6845),l=n(8722),i=n(3847),u=n(7457),s=n(864);const c="file selected";function f(){const e=(0,u.R)(),t=(0,o.useRef)(),n=(0,o.useCallback)((async()=>(e.open(),new Promise((e=>{t.current=e})))),[e,t]);return{...e,select:n,[c]:t}}const d=e=>{let{onSelect:t,stats:n,highlighted:r=!1}=e;return(0,s.jsx)("div",{children:(0,s.jsxs)("button",{className:"flex row justify-start outline "+(r?"":"secondary"),style:{textAlign:"left"},onClick:t,children:[(0,s.jsx)(i.J,{name:n.isDirectory()?"folder":"draft"}),n.name]})})},p=()=>{const{fs:e,setStatus:t}=(0,o.useContext)(a.r),{filePicker:n}=(0,o.useContext)(l.Il),[i,u]=(0,o.useState)([]),[f,p]=(0,o.useState)(""),h=e.cwd();(0,o.useEffect)((()=>{e.scandir(e.cwd()).then((e=>{u(e)}))}),[e,h,u]);const m=(0,o.useCallback)((t=>{p(""),e.cd(t),e.scandir(e.cwd()).then((e=>{u(e)}))}),[e,p,u]),g=(0,o.useCallback)((e=>{p(e)}),[p]),v=(0,o.useCallback)((()=>{var e,r;t(`Selected ${f}`),n.close(),null===(e=(r=n[c]).current)||void 0===e||e.call(r,f)}),[f,n,t]);return(0,s.jsx)("dialog",{open:n.isOpen,children:(0,s.jsxs)("article",{style:{width:"350px"},children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("p",{children:(0,s.jsx)(r.cC,{id:"Choose file"})}),(0,s.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:e=>{e.preventDefault(),n.close()},children:"close"})]}),(0,s.jsxs)("main",{children:[(0,s.jsx)("div",{children:(0,s.jsx)("b",{children:e.cwd()})}),"/"!==e.cwd()&&(0,s.jsx)(d,{stats:{isDirectory:()=>!0,isFile:()=>!1,name:".."},onSelect:()=>m("..")}),i.map((e=>(0,s.jsx)(d,{stats:e,highlighted:e.name===f,onSelect:()=>e.isDirectory()?m(e.name):g(e.name)},e.name)))]}),(0,s.jsx)("footer",{children:(0,s.jsx)("button",{disabled:!f,onClick:v,children:"Select"})})]})})}},6839:(e,t,n)=>{"use strict";n.d(t,{Hy:()=>h,LK:()=>m,rS:()=>p});var r=n(303),a=n(7239),o=n(6845),l=n(864);const i="/tracking/canTrack",u="yes",s=[u,"no"];let c=!1;function f(e){r.ZP.send({hitType:"pageview",page:e})}function d(e,t,n,o){var l,i;if(c)return;const u="string"===typeof e?{category:e,action:(0,a.kP)(t),label:n&&o?{label:n,value:o}:void 0}:e;r.ZP.event({category:u.category,action:u.action,nonInteraction:!u.interaction,label:null===(l=u.label)||void 0===l?void 0:l.label,value:null===(i=u.label)||void 0===i?void 0:i.value})}function p(){var e;const t=null!==(e=localStorage[i])&&void 0!==e?e:"",[n,a]=(0,o.useState)(t===u),[l,p]=(0,o.useState)(s.includes(t)||"1"===navigator.doNotTrack);return{canTrack:n,haveAsked:l,accept:(0,o.useCallback)((()=>{localStorage[i]=u,a(!0),p(!0),function(){var e;r.ZP.initialize(null!==(e={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!==e?e:"G-0VTR5BJFQP"),r.ZP.send("pageview")}()}),[a,p]),reject:(0,o.useCallback)((()=>{localStorage[i]="no",a(!1),p(!0),c=!0}),[a,p]),trackEvent:d,trackPage:f}}function h(){const{accept:e,reject:t,haveAsked:n}=p(),[r,a]=(0,o.useState)(!n),i=(0,o.useCallback)((()=>{a(!1)}),[a]),u=(0,o.useCallback)((()=>{e(),i()}),[e,i]),s=(0,o.useCallback)((()=>{t(),i()}),[t,i]);return(0,l.jsx)(l.Fragment,{children:r&&(0,l.jsxs)("div",{id:"trackingBanner",className:"flex row",children:[(0,l.jsx)("div",{className:"flex-1",children:(0,l.jsx)(m,{})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("a",{href:"#reject",role:"button",className:"reject",onClick:s,children:"Reject"}),(0,l.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:u,children:"Accept"}),(0,l.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:i,children:"\ud835\uddb7"})]})]})})}function m(){return(0,l.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,l.jsx)("a",{href:"www.google.com/policies/privacy/partners/",children:"How Google uses data."})]})}},8079:(e,t,n)=>{"use strict";n.d(t,{Tk:()=>p,ZP:()=>h,oC:()=>d});var r=n(6845),a=n(864);const o=(0,r.lazy)((()=>Promise.all([n.e(114),n.e(996),n.e(168),n.e(318),n.e(495)]).then(n.bind(n,2657)))),l=(0,r.lazy)((()=>Promise.all([n.e(114),n.e(996),n.e(318),n.e(548)]).then(n.bind(n,7070)))),i=(0,r.lazy)((()=>Promise.all([n.e(114),n.e(996),n.e(428)]).then(n.bind(n,6393)))),u=(0,r.lazy)((()=>n.e(630).then(n.bind(n,3630)))),s=(0,r.lazy)((()=>n.e(846).then(n.bind(n,1846)))),c=(0,r.lazy)((()=>Promise.all([n.e(950),n.e(912)]).then(n.bind(n,3912)))),f=(0,r.lazy)((()=>Promise.all([n.e(950),n.e(70)]).then(n.bind(n,2070)))),d="lastRoute",p={chip:"Hardware Simulator",cpu:"CPU Emulator",asm:"Assembler",VM:"VM Emulator",bitmap:"Bitmap Editor"},h={chip:{href:"/chip",tool:"chip",target:(0,a.jsx)(o,{})},cpu:{href:"/cpu",tool:"cpu",target:(0,a.jsx)(l,{})},asm:{href:"/asm",tool:"asm",target:(0,a.jsx)(i,{})},bitmap:{href:"/bitmap",tool:"bitmap",target:(0,a.jsx)(u,{})},util:{href:"/util",target:(0,a.jsx)(s,{})},chipGuide:{href:"/chip_guide",target:(0,a.jsx)(c,{})},about:{href:"/about",target:(0,a.jsx)(f,{})},placeholder:{href:"/placeholder",target:(0,a.jsx)("span",{children:"To be added later"})}}},1703:(e,t,n)=>{"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?e.apply(this,a):function(){for(var e=arguments.length,r=new Array(e),o=0;ode,_m:()=>W,Ik:()=>ie});var m=d((function(e,t){throw new Error(e[t]||e.default)}))({initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"}),g={changes:function(e,t){return p(t)||m("changeType"),Object.keys(t).some((function(t){return n=e,r=t,!Object.prototype.hasOwnProperty.call(n,r);var n,r}))&&m("changeField"),t},selector:function(e){h(e)||m("selectorType")},handler:function(e){h(e)||p(e)||m("handlerType"),p(e)&&Object.values(e).some((function(e){return!h(e)}))&&m("handlersType")},initial:function(e){var t;e||m("initialIsRequired"),p(e)||m("initialType"),t=e,Object.keys(t).length||m("initialContent")}};function v(e,t){return h(t)?t(e.current):t}function y(e,t){return e.current=c(c({},e.current),t),t}function b(e,t,n){return h(t)?t(e.current):Object.keys(n).forEach((function(n){var r;return null===(r=t[n])||void 0===r?void 0:r.call(t,e.current[n])})),n}var w={create:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g.initial(e),g.handler(t);var n={current:e},r=d(b)(n,t),a=d(y)(n),o=d(g.changes)(e),l=d(v)(n);function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e};return g.selector(e),e(n.current)}function u(e){f(r,a,o,l)(e)}return[i,u]}};const k=w;const S={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};const x=function(e){return{}.toString.call(e).includes("Object")};var _={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:"Deprecation warning!\n You are using deprecated way of configuration.\n\n Instead of using\n monaco.config({ urls: { monacoBase: '...' } })\n use\n monaco.config({ paths: { vs: '...' } })\n\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\n "},C=function(e){return function t(){for(var n=this,r=arguments.length,a=new Array(r),o=0;o=e.length?e.apply(this,a):function(){for(var e=arguments.length,r=new Array(e),o=0;o2&&void 0!==arguments[2])||arguments[2];const r=(0,H.useRef)(!0);(0,H.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)};function re(){}function ae(e,t,n,r){return function(e,t){return e.editor.getModel(oe(e,t))}(e,r)||function(e,t,n,r){return e.editor.createModel(t,n,r&&oe(e,r))}(e,t,n,r)}function oe(e,t){return e.Uri.parse(t)}function le(e){let{original:t,modified:n,language:r,originalLanguage:a,modifiedLanguage:o,originalModelPath:l,modifiedModelPath:i,keepCurrentOriginalModel:u,keepCurrentModifiedModel:s,theme:c,loading:f,options:d,height:p,width:h,className:m,wrapperProps:g,beforeMount:v,onMount:y}=e;const[b,w]=(0,H.useState)(!1),[k,S]=(0,H.useState)(!0),x=(0,H.useRef)(null),_=(0,H.useRef)(null),C=(0,H.useRef)(null),E=(0,H.useRef)(y),P=(0,H.useRef)(v);te((()=>{const e=W.init();return e.then((e=>(_.current=e)&&S(!1))).catch((e=>"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e))),()=>x.current?function(){const e=x.current.getModel();var t,n;u||null===(t=e.original)||void 0===t||t.dispose();s||null===(n=e.modified)||void 0===n||n.dispose();x.current.dispose()}():e.cancel()})),ne((()=>{const e=x.current.getModifiedEditor();e.getOption(_.current.editor.EditorOption.readOnly)?e.setValue(n):n!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),e.pushUndoStop())}),[n],b),ne((()=>{x.current.getModel().original.setValue(t)}),[t],b),ne((()=>{const{original:e,modified:t}=x.current.getModel();_.current.editor.setModelLanguage(e,a||r),_.current.editor.setModelLanguage(t,o||r)}),[r,a,o],b),ne((()=>{_.current.editor.setTheme(c)}),[c],b),ne((()=>{x.current.updateOptions(d)}),[d],b);const j=(0,H.useCallback)((()=>{P.current(_.current);const e=ae(_.current,t,a||r,l),u=ae(_.current,n,o||r,i);x.current.setModel({original:e,modified:u})}),[r,n,o,t,a,l,i]),O=(0,H.useCallback)((()=>{x.current=_.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...d}),j(),_.current.editor.setTheme(c),w(!0)}),[d,c,j]);return(0,H.useEffect)((()=>{b&&E.current(x.current,_.current)}),[b]),(0,H.useEffect)((()=>{!k&&!b&&O()}),[k,b,O]),H.createElement(ee,{width:h,height:p,isEditorReady:b,loading:f,_ref:C,className:m,wrapperProps:g})}le.propTypes={original:q().string,modified:q().string,language:q().string,originalLanguage:q().string,modifiedLanguage:q().string,originalModelPath:q().string,modifiedModelPath:q().string,keepCurrentOriginalModel:q().bool,keepCurrentModifiedModel:q().bool,theme:q().string,loading:q().oneOfType([q().element,q().string]),options:q().object,width:q().oneOfType([q().number,q().string]),height:q().oneOfType([q().number,q().string]),className:q().string,wrapperProps:q().object,beforeMount:q().func,onMount:q().func},le.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:re,onMount:re};const ie=function(){const[e,t]=(0,H.useState)(W.__getMonacoInstance());return te((()=>{let n;return e||(n=W.init(),n.then((e=>{t(e)}))),()=>{var e;return null===(e=n)||void 0===e?void 0:e.cancel()}})),e};const ue=function(e){const t=(0,H.useRef)();return(0,H.useEffect)((()=>{t.current=e}),[e]),t.current},se=new Map;function ce(e){let{defaultValue:t,defaultLanguage:n,defaultPath:r,value:a,language:o,path:l,theme:i,line:u,loading:s,options:c,overrideServices:f,saveViewState:d,keepCurrentModel:p,width:h,height:m,className:g,wrapperProps:v,beforeMount:y,onMount:b,onChange:w,onValidate:k}=e;const[S,x]=(0,H.useState)(!1),[_,C]=(0,H.useState)(!0),E=(0,H.useRef)(null),P=(0,H.useRef)(null),j=(0,H.useRef)(null),O=(0,H.useRef)(b),A=(0,H.useRef)(y),R=(0,H.useRef)(null),M=(0,H.useRef)(a),T=ue(l),N=(0,H.useRef)(!1);te((()=>{const e=W.init();return e.then((e=>(E.current=e)&&C(!1))).catch((e=>"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e))),()=>P.current?function(){var e,t;null===(e=R.current)||void 0===e||e.dispose(),p?d&&se.set(l,P.current.saveViewState()):null===(t=P.current.getModel())||void 0===t||t.dispose();P.current.dispose()}():e.cancel()})),ne((()=>{const e=ae(E.current,t||a,n||o,l);e!==P.current.getModel()&&(d&&se.set(T,P.current.saveViewState()),P.current.setModel(e),d&&P.current.restoreViewState(se.get(l)))}),[l],S),ne((()=>{P.current.updateOptions(c)}),[c],S),ne((()=>{P.current.getOption(E.current.editor.EditorOption.readOnly)?P.current.setValue(a):a!==P.current.getValue()&&(P.current.executeEdits("",[{range:P.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),P.current.pushUndoStop())}),[a],S),ne((()=>{E.current.editor.setModelLanguage(P.current.getModel(),o)}),[o],S),ne((()=>{void 0!==u&&P.current.revealLine(u)}),[u],S),ne((()=>{E.current.editor.setTheme(i)}),[i],S);const L=(0,H.useCallback)((()=>{if(!N.current){A.current(E.current);const e=l||r,u=ae(E.current,a||t,n||o,e);P.current=E.current.editor.create(j.current,{model:u,automaticLayout:!0,...c},f),d&&P.current.restoreViewState(se.get(e)),E.current.editor.setTheme(i),x(!0),N.current=!0}}),[t,n,r,a,o,l,c,f,d,i]);return(0,H.useEffect)((()=>{S&&O.current(P.current,E.current)}),[S]),(0,H.useEffect)((()=>{!_&&!S&&L()}),[_,S,L]),M.current=a,(0,H.useEffect)((()=>{var e,t;S&&w&&(null===(e=R.current)||void 0===e||e.dispose(),R.current=null===(t=P.current)||void 0===t?void 0:t.onDidChangeModelContent((e=>{w(P.current.getValue(),e)})))}),[S,w]),(0,H.useEffect)((()=>{if(S){const e=E.current.editor.onDidChangeMarkers((e=>{var t;const n=null===(t=P.current.getModel())||void 0===t?void 0:t.uri;if(n){if(e.find((e=>e.path===n.path))){const e=E.current.editor.getModelMarkers({resource:n});null===k||void 0===k||k(e)}}}));return()=>{null===e||void 0===e||e.dispose()}}}),[S,k]),H.createElement(ee,{width:h,height:m,isEditorReady:S,loading:s,_ref:j,className:g,wrapperProps:v})}ce.propTypes={defaultValue:q().string,defaultPath:q().string,defaultLanguage:q().string,value:q().string,language:q().string,path:q().string,theme:q().string,line:q().number,loading:q().oneOfType([q().element,q().string]),options:q().object,overrideServices:q().object,saveViewState:q().bool,keepCurrentModel:q().bool,width:q().oneOfType([q().number,q().string]),height:q().oneOfType([q().number,q().string]),className:q().string,wrapperProps:q().object,beforeMount:q().func,onMount:q().func,onChange:q().func,onValidate:q().func},ce.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:re,onMount:re,onValidate:re};const fe=ce;const de=(0,H.memo)(fe)},733:(e,t,n)=>{"use strict";function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;tc,RQ:()=>O,WK:()=>L,Zn:()=>_,Zq:()=>P,aU:()=>a,cP:()=>f,fp:()=>m,kG:()=>i,lX:()=>l,pC:()=>j}),function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(a||(a={}));const o="popstate";function l(e){return void 0===e&&(e={}),p((function(e,t){let{pathname:n,search:r,hash:a}=e.location;return s("",{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:c(t)}),null,e)}function i(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function u(e){return{usr:e.state,key:e.key}}function s(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 c(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 d(e){let t="undefined"!==typeof window&&"undefined"!==typeof window.location&&"null"!==window.location.origin?window.location.origin:window.location.href,n="string"===typeof e?e:c(e);return i(t,"No window.location.(origin|href) available to create URL for href: "+n),new URL(n,t)}function p(e,t,n,r){void 0===r&&(r={});let{window:l=document.defaultView,v5Compat:i=!1}=r,f=l.history,p=a.Pop,h=null;function m(){p=a.Pop,h&&h({action:p,location:g.location})}let g={get action(){return p},get location(){return e(l,f)},listen(e){if(h)throw new Error("A history only accepts one active listener");return l.addEventListener(o,m),h=e,()=>{l.removeEventListener(o,m),h=null}},createHref:e=>t(l,e),encodeLocation(e){let t=d("string"===typeof e?e:c(e));return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){p=a.Push;let r=s(g.location,e,t);n&&n(r,e);let o=u(r),c=g.createHref(r);try{f.pushState(o,"",c)}catch(d){l.location.assign(c)}i&&h&&h({action:p,location:g.location})},replace:function(e,t){p=a.Replace;let r=s(g.location,e,t);n&&n(r,e);let o=u(r),l=g.createHref(r);f.replaceState(o,"",l),i&&h&&h({action:p,location:g.location})},go:e=>f.go(e)};return g}var h;function m(e,t,n){void 0===n&&(n="/");let r=_(("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 o=null;for(let l=0;null==o&&l{let l={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};l.relativePath.startsWith("/")&&(i(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path "'+r+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),l.relativePath=l.relativePath.slice(r.length));let u=O([r,l.relativePath]),s=n.concat(l);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:w(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("?"),o=n.replace(/\?$/,"");if(0===r.length)return a?[o,""]:[o];let l=v(r.join("/")),i=[];return i.push(...l.map((e=>""===e?o:[o,e].join("/")))),a&&i.push(...l),i.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(h||(h={}));const y=/^:\w+$/,b=e=>"*"===e;function w(e,t){let n=e.split("/"),r=n.length;return n.some(b)&&(r+=-2),t&&(r+=2),n.filter((e=>!b(e))).reduce(((e,t)=>e+(y.test(t)?3:""===t?1:10)),r)}function k(e,t){let{routesMeta:n}=e,r={},a="/",o=[];for(let l=0;l(r.push(t),"/([^\\/]+)")));e.endsWith("*")?(r.push("*"),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))");let o=new RegExp(a,t?void 0:"i");return[o,r]}(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],l=o.replace(/(.)\/+$/,"$1"),i=a.slice(1);return{params:r.reduce(((e,t,n)=>{if("*"===t){let e=i[n]||"";l=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(n){return C(!1,'The value for the URL param "'+t+'" will not be decoded because the string "'+e+'" is a malformed URL segment. This is probably due to a bad percent encoding ('+n+")."),e}}(i[n]||"",t),e}),{}),pathname:o,pathnameBase:l,pattern:e}}function x(e){try{return decodeURI(e)}catch(t){return C(!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 _(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 C(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function E(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 P(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function j(e,t,n,a){let o;void 0===a&&(a=!1),"string"===typeof e?o=f(e):(o=r({},e),i(!o.pathname||!o.pathname.includes("?"),E("?","pathname","search",o)),i(!o.pathname||!o.pathname.includes("#"),E("#","pathname","hash",o)),i(!o.search||!o.search.includes("#"),E("#","search","hash",o)));let l,u=""===e||""===o.pathname,s=u?"/":o.pathname;if(a||null==s)l=n;else{let e=t.length-1;if(s.startsWith("..")){let t=s.split("/");for(;".."===t[0];)t.shift(),e-=1;o.pathname=t.join("/")}l=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,o=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:o,search:R(r),hash:M(a)}}(o,l),d=s&&"/"!==s&&s.endsWith("/"),p=(u||"."===s)&&n.endsWith("/");return c.pathname.endsWith("/")||!d&&!p||(c.pathname+="/"),c}const O=e=>e.join("/").replace(/\/\/+/g,"/"),A=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),R=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",M=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class T extends Error{}class N{constructor(e,t,n,r){void 0===r&&(r=!1),this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}}function L(e){return e instanceof N}const D=["post","put","patch","delete"],F=(new Set(D),["get",...D]);new Set(F),new Set([301,302,303,307,308]),new Set([307,308]),"undefined"!==typeof window&&"undefined"!==typeof window.document&&window.document.createElement},6212:e=>{"use strict";function t(e,n,r,a){this.message=e,this.expected=n,this.found=r,this.location=a,this.name="SyntaxError","function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(t,Error),t.buildMessage=function(e,t){var n={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t,n="";for(t=0;t0){for(t=1,r=1;tpe&&(pe=fe,he=[]),he.push(e))}function Se(e,n,r){return new t(t.buildMessage(e,n),e,n,r)}function xe(){var e,t;for(e=[],t=_e();t!==a;)e.push(t),t=_e();return e}function _e(){var t,r,o;if(t=function(){var t,n,r,o;t=fe,123===e.charCodeAt(fe)?(n=c,fe++):(n=a,0===me&&ke(f));n!==a&&Le()!==a&&(r=Ce())!==a&&Le()!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===me&&ke(p)),o!==a?(t,t=n={type:"argument",arg:r}):(fe=t,t=a)):(fe=t,t=a);return t}(),t===a&&(t=function(){var t,r,o,l,i,u,s,y,b,w;t=fe,123===e.charCodeAt(fe)?(r=c,fe++):(r=a,0===me&&ke(f));if(r!==a)if(Le()!==a)if((o=Ce())!==a)if(Le()!==a)if(44===e.charCodeAt(fe)?(l=h,fe++):(l=a,0===me&&ke(m)),l!==a)if(Le()!==a)if(i=fe,e.substr(fe,6)===g?(u=g,fe+=6):(u=a,0===me&&ke(v)),u!==a&&(i,x=u,n.strict&&De.unshift(!1),u=x),(i=u)!==a)if((u=Le())!==a)if(44===e.charCodeAt(fe)?(s=h,fe++):(s=a,0===me&&ke(m)),s!==a)if(Le()!==a){if(y=[],(b=Ee())!==a)for(;b!==a;)y.push(b),b=Ee();else y=a;y!==a&&(b=Le())!==a?(125===e.charCodeAt(fe)?(w=d,fe++):(w=a,0===me&&ke(p)),w!==a?(t,k=o,S=y,n.strict&&De.shift(),t=r={type:"select",arg:k,cases:S}):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;var k,S;var x;return t}(),t===a&&(t=function(){var t,r,o,l,i,u,s,g,v,S,x;t=fe,123===e.charCodeAt(fe)?(r=c,fe++):(r=a,0===me&&ke(f));if(r!==a)if(Le()!==a)if((o=Ce())!==a)if(Le()!==a)if(44===e.charCodeAt(fe)?(l=h,fe++):(l=a,0===me&&ke(m)),l!==a)if(Le()!==a)if(i=fe,e.substr(fe,6)===y?(u=y,fe+=6):(u=a,0===me&&ke(b)),u===a&&(e.substr(fe,13)===w?(u=w,fe+=13):(u=a,0===me&&ke(k))),u!==a&&(i,_=u,De.unshift(!0),u=_),(i=u)!==a)if((u=Le())!==a)if(44===e.charCodeAt(fe)?(s=h,fe++):(s=a,0===me&&ke(m)),s!==a)if(Le()!==a)if(g=function(){var t,n,r,o,l;me++,t=fe,n=Le(),n!==a?(e.substr(fe,6)===P?(r=P,fe+=6):(r=a,0===me&&ke(j)),r!==a&&Le()!==a?(58===e.charCodeAt(fe)?(o=":",fe++):(o=a,0===me&&ke(O)),o!==a&&Le()!==a&&(l=Ne())!==a&&Le()!==a?(t,t=n=l):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a);me--,t===a&&(n=a,0===me&&ke(E));return t}(),g===a&&(g=null),g!==a){if(v=[],(S=Pe())!==a)for(;S!==a;)v.push(S),S=Pe();else v=a;v!==a&&(S=Le())!==a?(125===e.charCodeAt(fe)?(x=d,fe++):(x=a,0===me&&ke(p)),x!==a?(t,t=r=function(e,t,r,a){var o=("selectordinal"===t?n.ordinal:n.cardinal)||["zero","one","two","few","many","other"];return o&&o.length&&a.forEach((function(n){if(isNaN(n.key)&&o.indexOf(n.key)<0)throw new Error("Invalid key `"+n.key+"` for argument `"+e+"`. Valid "+t+" keys for this locale are `"+o.join("`, `")+"`, and explicit keys like `=0`.")})),De.shift(),{type:t,arg:e,offset:r||0,cases:a}}(o,i,g,v)):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;else fe=t,t=a;var _;return t}(),t===a&&(t=function(){var t,r,o,l,i,u,s;t=fe,123===e.charCodeAt(fe)?(r=c,fe++):(r=a,0===me&&ke(f));r!==a&&Le()!==a&&(o=Ce())!==a&&Le()!==a?(44===e.charCodeAt(fe)?(l=h,fe++):(l=a,0===me&&ke(m)),l!==a&&Le()!==a?(i=function(){var t,r,o,l,i;e.substr(fe,6)===R?(t=R,fe+=6):(t=a,0===me&&ke(M));t===a&&(e.substr(fe,4)===T?(t=T,fe+=4):(t=a,0===me&&ke(N)),t===a&&(e.substr(fe,4)===L?(t=L,fe+=4):(t=a,0===me&&ke(D)),t===a&&(e.substr(fe,8)===F?(t=F,fe+=8):(t=a,0===me&&ke(z)),t===a&&(e.substr(fe,7)===I?(t=I,fe+=7):(t=a,0===me&&ke(U)),t===a&&(e.substr(fe,8)===B?(t=B,fe+=8):(t=a,0===me&&ke(V)),t===a&&(t=fe,r=fe,me++,e.substr(fe,6)===g?(o=g,fe+=6):(o=a,0===me&&ke(v)),me--,o===a?r=void 0:(fe=r,r=a),r!==a?(o=fe,me++,e.substr(fe,6)===y?(l=y,fe+=6):(l=a,0===me&&ke(b)),me--,l===a?o=void 0:(fe=o,o=a),o!==a?(l=fe,me++,e.substr(fe,13)===w?(i=w,fe+=13):(i=a,0===me&&ke(k)),me--,i===a?l=void 0:(fe=l,l=a),l!==a&&(i=Ce())!==a?(fe,(function(e){if(n.strict||/^\d/.test(e))return!1;switch(e.toLowerCase()){case"select":case"plural":case"selectordinal":return!1;default:return!0}}(i)?void 0:a)!==a?(t,t=r=i):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)))))));return t}(),i!==a&&Le()!==a?(u=function(){var t,r,o,l,i;if(t=fe,r=Le(),r!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===me&&ke(m)),o!==a){for(l=[],i=_e();i!==a;)l.push(i),i=_e();l!==a?(fe,(i=(i=!n.strict)?void 0:a)!==a?(t,t=r={tokens:l}):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;if(t===a)if(t=fe,(r=Le())!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===me&&ke(m)),o!==a){for(l=[],i=Oe();i!==a;)l.push(i),i=Oe();l!==a?(t,t=r={tokens:[l.join("")]}):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;return t}(),u===a&&(u=null),u!==a?(125===e.charCodeAt(fe)?(s=d,fe++):(s=a,0===me&&ke(p)),s!==a?(t,t=r={type:"function",arg:o,key:i,param:u}):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a);return t}(),t===a&&(t=fe,35===e.charCodeAt(fe)?(r="#",fe++):(r=a,0===me&&ke(i)),r!==a?(fe,(o=(o=u())?void 0:a)!==a?(t,t=r={type:"octothorpe"}):(fe=t,t=a)):(fe=t,t=a),t===a))))){if(t=fe,r=[],(o=Te())!==a)for(;o!==a;)r.push(o),o=Te();else r=a;r!==a&&(t,r=s(r)),t=r}return t}function Ce(){var t,n,r;if(me++,t=fe,n=[],x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(_)),r!==a)for(;r!==a;)n.push(r),x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(_));else n=a;return t=n!==a?e.substring(t,fe):n,me--,t===a&&(n=a,0===me&&ke(S)),t}function Ee(){var e,t,n;return e=fe,Le()!==a&&(t=Ce())!==a&&Le()!==a&&(n=je())!==a?(e,e=C(t,n)):(fe=e,e=a),e}function Pe(){var t,n,r;return t=fe,Le()!==a?(n=function(){var t,n,r;t=Ce(),t===a&&(t=fe,61===e.charCodeAt(fe)?(n="=",fe++):(n=a,0===me&&ke(A)),n!==a&&(r=Ne())!==a?(t,t=n=r):(fe=t,t=a));return t}(),n!==a&&Le()!==a&&(r=je())!==a?(t,t=C(n,r)):(fe=t,t=a)):(fe=t,t=a),t}function je(){var t,n,r,o,l,i;if(t=fe,123===e.charCodeAt(fe)?(n=c,fe++):(n=a,0===me&&ke(f)),n!==a)if(r=fe,(o=Le())!==a?(l=fe,me++,123===e.charCodeAt(fe)?(i=c,fe++):(i=a,0===me&&ke(f)),me--,i!==a?(fe=l,l=void 0):l=a,l!==a?r=o=[o,l]:(fe=r,r=a)):(fe=r,r=a),r===a&&(r=null),r!==a){for(o=[],l=_e();l!==a;)o.push(l),l=_e();o!==a&&(l=Le())!==a?(125===e.charCodeAt(fe)?(i=d,fe++):(i=a,0===me&&ke(p)),i!==a?(t,t=n=o):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;else fe=t,t=a;return t}function Oe(){var t,n,r,o;if(me++,t=fe,n=[],W.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(H)),r!==a)for(;r!==a;)n.push(r),W.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(H));else n=a;if(n!==a&&(t,n=n.join("")),(t=n)===a&&(t=Ae())===a&&(t=fe,39===e.charCodeAt(fe)?(n=Q,fe++):(n=a,0===me&&ke(q)),n!==a&&(r=Re())!==a?(39===e.charCodeAt(fe)?(o=Q,fe++):(o=a,0===me&&ke(q)),o!==a?(t,t=n=r):(fe=t,t=a)):(fe=t,t=a),t===a))if(t=fe,123===e.charCodeAt(fe)?(n=c,fe++):(n=a,0===me&&ke(f)),n!==a){for(r=[],o=Oe();o!==a;)r.push(o),o=Oe();r!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===me&&ke(p)),o!==a?(t,n=function(e){return"{"+e.join("")+"}"}(r),t=n):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;return me--,t===a&&(n=a,0===me&&ke($)),t}function Ae(){var t,n;return me++,t=fe,"''"===e.substr(fe,2)?(n="''",fe+=2):(n=a,0===me&&ke(Z)),n!==a&&(t,n="'"),me--,(t=n)===a&&(n=a,0===me&&ke(G)),t}function Re(){var t,n,r;if((t=Ae())===a){if(t=fe,n=[],K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(X)),r!==a)for(;r!==a;)n.push(r),K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(X));else n=a;n!==a&&(t,n=s(n)),t=n}return t}function Me(){var t,n,r,o,l,i;if(me++,t=function(){var t,n,r,o;if(t=fe,"'{"===e.substr(fe,2)?(n="'{",fe+=2):(n=a,0===me&&ke(Y)),n!==a){for(r=[],o=Re();o!==a;)r.push(o),o=Re();r!==a?(39===e.charCodeAt(fe)?(o=Q,fe++):(o=a,0===me&&ke(q)),o!==a?(t,t=n="{"+r.join("")):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;if(t===a)if(t=fe,"'}"===e.substr(fe,2)?(n="'}",fe+=2):(n=a,0===me&&ke(J)),n!==a){for(r=[],o=Re();o!==a;)r.push(o),o=Re();r!==a?(39===e.charCodeAt(fe)?(o=Q,fe++):(o=a,0===me&&ke(q)),o!==a?(t,t=n="}"+r.join("")):(fe=t,t=a)):(fe=t,t=a)}else fe=t,t=a;return t}(),t===a){if(t=fe,n=fe,r=fe,"'#"===e.substr(fe,2)?(o="'#",fe+=2):(o=a,0===me&&ke(te)),o!==a){for(l=[],i=Re();i!==a;)l.push(i),i=Re();l!==a?(39===e.charCodeAt(fe)?(i=Q,fe++):(i=a,0===me&&ke(q)),i!==a?(r,r=o="#"+l.join("")):(fe=r,r=a)):(fe=r,r=a)}else fe=r,r=a;r!==a?(fe,(o=(o=u())?void 0:a)!==a?n=r=[r,o]:(fe=n,n=a)):(fe=n,n=a),n!==a&&(t,n=n[0]),(t=n)===a&&(39===e.charCodeAt(fe)?(t=Q,fe++):(t=a,0===me&&ke(q)))}return me--,t===a&&(n=a,0===me&&ke(ee)),t}function Te(){var t,n;return(t=Ae())===a&&(t=Me())===a&&(t=fe,35===e.charCodeAt(fe)?(n="#",fe++):(n=a,0===me&&ke(i)),n!==a?(fe,(!De[0]?void 0:a)!==a?(t,t=n):(fe=t,t=a)):(fe=t,t=a),t===a&&(t=function(){var t;return me++,re.test(e.charAt(fe))?(t=e.charAt(fe),fe++):(t=a,0===me&&ke(ae)),me--,t===a&&0===me&&ke(ne),t}())),t}function Ne(){var t,n,r;if(me++,t=fe,n=[],le.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(ie)),r!==a)for(;r!==a;)n.push(r),le.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(ie));else n=a;return t=n!==a?e.substring(t,fe):n,me--,t===a&&(n=a,0===me&&ke(oe)),t}function Le(){var t,n,r;for(me++,t=fe,n=[],se.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(ce));r!==a;)n.push(r),se.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===me&&ke(ce));return t=n!==a?e.substring(t,fe):n,me--,t===a&&(n=a,0===me&&ke(ue)),t}var De=[!1];if((r=l())!==a&&fe===e.length)return r;throw r!==a&&fe{"use strict";var r=n(3584);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,l){if(l!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},8984:(e,t,n)=>{e.exports=n(8699)()},3584:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},3207:(e,t,n)=>{"use strict";var r=n(6845),a=n(120);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n