From 4cfae4717edd2552a39cce016972b12adc4988f6 Mon Sep 17 00:00:00 2001 From: Neta London Date: Tue, 31 Oct 2023 12:42:01 +0200 Subject: [PATCH] Updates --- asset-manifest.json | 10 +++++----- chip/index.html | 2 +- guide/index.html | 2 +- index.html | 2 +- static/js/263.58768126.chunk.js.map | 1 - .../{263.58768126.chunk.js => 263.8f4582b5.chunk.js} | 4 ++-- static/js/263.8f4582b5.chunk.js.map | 1 + static/js/{main.85505dfb.js => main.2866a11b.js} | 6 +++--- ...dfb.js.LICENSE.txt => main.2866a11b.js.LICENSE.txt} | 0 .../js/{main.85505dfb.js.map => main.2866a11b.js.map} | 2 +- util/index.html | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 static/js/263.58768126.chunk.js.map rename static/js/{263.58768126.chunk.js => 263.8f4582b5.chunk.js} (91%) create mode 100644 static/js/263.8f4582b5.chunk.js.map rename static/js/{main.85505dfb.js => main.2866a11b.js} (99%) rename static/js/{main.85505dfb.js.LICENSE.txt => main.2866a11b.js.LICENSE.txt} (100%) rename static/js/{main.85505dfb.js.map => main.2866a11b.js.map} (99%) diff --git a/asset-manifest.json b/asset-manifest.json index 2b85a074f..f6284ab5c 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,10 +1,10 @@ { "files": { "main.css": "/web-ide/static/css/main.dfe30f31.css", - "main.js": "/web-ide/static/js/main.85505dfb.js", + "main.js": "/web-ide/static/js/main.2866a11b.js", "static/js/2.021e2975.chunk.js": "/web-ide/static/js/2.021e2975.chunk.js", "static/css/263.d4353148.chunk.css": "/web-ide/static/css/263.d4353148.chunk.css", - "static/js/263.58768126.chunk.js": "/web-ide/static/js/263.58768126.chunk.js", + "static/js/263.8f4582b5.chunk.js": "/web-ide/static/js/263.8f4582b5.chunk.js", "static/js/506.35dc48bd.chunk.js": "/web-ide/static/js/506.35dc48bd.chunk.js", "static/js/568.4e6a571b.chunk.js": "/web-ide/static/js/568.4e6a571b.chunk.js", "static/js/662.41196665.chunk.js": "/web-ide/static/js/662.41196665.chunk.js", @@ -16,10 +16,10 @@ "static/js/356.197fc187.chunk.js": "/web-ide/static/js/356.197fc187.chunk.js", "index.html": "/web-ide/index.html", "main.dfe30f31.css.map": "/web-ide/static/css/main.dfe30f31.css.map", - "main.85505dfb.js.map": "/web-ide/static/js/main.85505dfb.js.map", + "main.2866a11b.js.map": "/web-ide/static/js/main.2866a11b.js.map", "2.021e2975.chunk.js.map": "/web-ide/static/js/2.021e2975.chunk.js.map", "263.d4353148.chunk.css.map": "/web-ide/static/css/263.d4353148.chunk.css.map", - "263.58768126.chunk.js.map": "/web-ide/static/js/263.58768126.chunk.js.map", + "263.8f4582b5.chunk.js.map": "/web-ide/static/js/263.8f4582b5.chunk.js.map", "506.35dc48bd.chunk.js.map": "/web-ide/static/js/506.35dc48bd.chunk.js.map", "568.4e6a571b.chunk.js.map": "/web-ide/static/js/568.4e6a571b.chunk.js.map", "662.41196665.chunk.js.map": "/web-ide/static/js/662.41196665.chunk.js.map", @@ -32,6 +32,6 @@ }, "entrypoints": [ "static/css/main.dfe30f31.css", - "static/js/main.85505dfb.js" + "static/js/main.2866a11b.js" ] } \ No newline at end of file diff --git a/chip/index.html b/chip/index.html index ba98f4418..cb42a3640 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/guide/index.html b/guide/index.html index ba98f4418..cb42a3640 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 ba98f4418..cb42a3640 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/263.58768126.chunk.js.map b/static/js/263.58768126.chunk.js.map deleted file mode 100644 index 63fe099fe..000000000 --- a/static/js/263.58768126.chunk.js.map +++ /dev/null @@ -1 +0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oe,EACP7Q,SAAU4Z,EACVvB,QAASgD,GAAAA,GAAAA,OACThG,SAAU,MACV/J,SAAU/W,EAAMwc,SAASP,iBAG7B,gBACEzK,KAAK,MACL1Z,GAAG,eACH,gBAAc,oBACd,gBAAmC,QAApB2uB,GAA0B,UAEzC,8BACE,kBACExa,KAAK,QACLhU,KAAK,YACL,gBAAc,oBACdiG,MAAM,MACN0T,QAA6B,QAApB6U,GACThb,SAAU,kBAAMkb,GAAmB,MAAM,IACzC,oBAIN,gBACEnV,KAAK,WACL1Z,GAAG,oBACH,kBAAgB,eAAc,UAE9B,SAAC,KAAS,CAACwkB,IAAKA,EAAK1lB,IAAKA,WAMlC,OACE,iBAAK+D,UAAU,gBAAe,UAC3BsrB,EACAM,GACAM,KAGP,EAEA,K","sources":["../../components/src/chips/alu.tsx","../../components/src/chips/register.tsx","../../components/src/chips/keyboard.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/constants.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/core.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/border.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/sizing.js","../../node_modules/immer/src/utils/errors.ts","../../node_modules/immer/src/utils/common.ts","../../node_modules/immer/src/utils/plugins.ts","../../node_modules/immer/src/core/scope.ts","../../node_modules/immer/src/core/finalize.ts","../../node_modules/immer/src/core/proxy.ts","../../node_modules/immer/src/core/immerClass.ts","../../node_modules/immer/src/core/current.ts","../../node_modules/immer/src/immer.ts","../../node_modules/immer/src/utils/env.ts","../../components/src/react.ts","../../components/src/inline_edit.tsx","../../components/src/virtual_scroll.tsx","../../components/src/clockface.tsx","../../components/src/chips/memory.tsx","../../components/src/chips/screen.tsx","../../components/src/chips/visualizations.tsx","../../components/src/pin_display.ts","../../components/src/pinout.tsx","../../components/src/runbar.tsx","../../components/src/timer.tsx","../../components/src/stores/chip.store.ts","../../simulator/src/timer.ts","shell/editor.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/debounce.js","shell/panel.tsx","pages/chip.tsx"],"sourcesContent":["import {\n COMMANDS_ALU,\n COMMANDS_OP,\n Flags,\n} from \"@nand2tetris/simulator/cpu/alu.js\";\n\nexport const ALUComponent = ({\n A,\n op,\n D,\n out,\n flag,\n}: {\n A: number;\n op: COMMANDS_OP;\n D: number;\n out: number;\n flag: keyof typeof Flags;\n}) => (\n
\n ALU\n \n \n \n \n \n \n \n {A}\n \n \n {D}\n \n \n {out}\n \n \n {COMMANDS_ALU.op[op] ?? \"(??)\"}\n \n \n \n
\n);\n","import { dec } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const RegisterComponent = ({\n name,\n bits,\n}: {\n name: string;\n bits: number;\n}) => (\n
\n {name}: {dec(bits)}\n
\n);\n","import { Keyboard as KeyboardChip } from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { KeyboardEvent, useState } from \"react\";\nimport { RegisterComponent } from \"./register.js\";\n\nconst KeyMap: Record = {\n // Delete: 127,\n Enter: 128,\n Backspace: 129,\n ArrowLeft: 130,\n ArrowUp: 131,\n ArrowRight: 132,\n ArrowDown: 133,\n Home: 134,\n End: 135,\n PageUp: 136,\n PageDown: 137,\n Insert: 138,\n Delete: 139,\n Escape: 140,\n F1: 141,\n F2: 142,\n F3: 143,\n F4: 144,\n F5: 145,\n F6: 146,\n F7: 147,\n F8: 148,\n F9: 149,\n F10: 150,\n F11: 151,\n F12: 152,\n};\n\nfunction keyPressToHackCharacter(keypress: KeyboardEvent): number {\n const mapping = KeyMap[keypress.key];\n if (mapping !== undefined) {\n return mapping;\n }\n if (keypress.key.length === 1) {\n const code = keypress.key.charCodeAt(0);\n if (code >= 32 && code <= 126) {\n return code;\n }\n }\n\n return 0;\n}\n\nexport const Keyboard = ({\n keyboard,\n update,\n}: {\n keyboard: KeyboardChip;\n update?: () => void;\n}) => {\n // const [showPicker, setShowPicker] = useState(false);\n const [enabled, setEnabled] = useState(false);\n const [character, setCharacter] = useState(\"\");\n const [bits, setBits] = useState(keyboard.out().busVoltage);\n let currentKey = 0;\n\n const toggleEnabled = () => {\n setEnabled(!enabled);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n event.preventDefault();\n if (!enabled) {\n return;\n }\n\n setCharacter(event.key);\n const key = keyPressToHackCharacter(event);\n if (key === currentKey) {\n return;\n }\n setKey(key);\n update?.();\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) {\n return;\n }\n\n currentKey = 0;\n keyboard.clearKey();\n update?.();\n setBits(keyboard.out().busVoltage);\n setCharacter(\"\");\n };\n\n const setKey = (key: number) => {\n if (key === 0) {\n return;\n }\n keyboard.setKey(key);\n setBits(keyboard.out().busVoltage);\n currentKey = key;\n };\n\n return (\n
\n
\n \n
\n
{`Character: ${character}`}
\n
\n \n
\n
\n );\n};\n","export const Sizes = {\n none: \"0px\",\n sm: \"0.125rem\",\n \"\": \"0.25rem\",\n md: \"0.375rem\",\n lg: \"0.5rem\",\n xl: \"0.75rem\",\n \"2xl\": \"1rem\",\n \"3xl\": \"1.5rem\",\n full: \"9999px\",\n};\nexport const Sides = {\n \"\": \"\",\n t: \"Top\",\n r: \"Right\",\n l: \"Left\",\n b: \"Bottom\",\n tl: \"TopLeft\",\n tr: \"TopRight\",\n bl: \"BottomLeft\",\n br: \"BottomRight\",\n};\nexport const Widths = {\n \"1/4\": \"25%\",\n \"1/2\": \"50%\",\n \"3/4\": \"75%\",\n full: \"100%\",\n};\n","import { Sides, Sizes } from \"./constants.js\";\nexport function isSide(v) {\n return Sides[v] !== undefined;\n}\nexport function isSize(v) {\n return Sizes[v] !== undefined;\n}\nexport function getSize(size) {\n return Sizes[size];\n}\nexport function getSide(side) {\n switch (side) {\n case \"t\":\n return [...getSide(\"tl\"), ...getSide(\"tr\")];\n case \"r\":\n return [...getSide(\"tr\"), ...getSide(\"br\")];\n case \"b\":\n return [...getSide(\"br\"), ...getSide(\"bl\")];\n case \"l\":\n return [...getSide(\"tl\"), ...getSide(\"bl\")];\n default:\n return [Sides[side]];\n }\n}\n","import { isSide, getSize, getSide } from \"./core.js\";\nexport function rounded(size = \"\", side = \"\") {\n if (isSide(size)) {\n side = size;\n size = \"\";\n }\n const sized = getSize(size);\n return getSide(side).reduce((prev, curr) => {\n if (curr === \"\") {\n prev.borderRadius = sized;\n }\n else {\n // @ts-ignore\n prev[`border${curr}Radius`] = sized;\n }\n return prev;\n }, {});\n}\nexport function border({ side = \"\", style = \"solid\", radius = \"\", width = 1, color = \"black\", }) {\n return {};\n}\nexport function inset(width, color1 = \"gray\", color2 = \"lightgray\") {\n return {\n ...border({ side: \"tl\", width, color: color1, radius: \"none\" }),\n ...border({ side: \"br\", width, color: color2, radius: \"none\" }),\n };\n}\n","import { Widths } from \"./constants.js\";\nexport function width(amount, block) {\n if (amount === undefined && Widths[block] !== undefined) {\n amount = block;\n }\n return {\n ...(block === \"inline\" ? { display: \"inline-block\" } : {}),\n width: Widths[amount] ?? \"0\",\n };\n}\n","const errors = {\n\t0: \"Illegal state\",\n\t1: \"Immer drafts cannot have computed properties\",\n\t2: \"This object has been frozen and should not be mutated\",\n\t3(data: any) {\n\t\treturn (\n\t\t\t\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n\t\t\tdata\n\t\t)\n\t},\n\t4: \"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",\n\t5: \"Immer forbids circular references\",\n\t6: \"The first or second argument to `produce` must be a function\",\n\t7: \"The third argument to `produce` must be a function or undefined\",\n\t8: \"First argument to `createDraft` must be a plain object, an array, or an immerable object\",\n\t9: \"First argument to `finishDraft` must be a draft returned by `createDraft`\",\n\t10: \"The given draft is already finalized\",\n\t11: \"Object.defineProperty() cannot be used on an Immer draft\",\n\t12: \"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t13: \"Immer only supports deleting array indices\",\n\t14: \"Immer only supports setting array indices and the 'length' property\",\n\t15(path: string) {\n\t\treturn \"Cannot apply patch, path doesn't resolve: \" + path\n\t},\n\t16: 'Sets cannot have \"replace\" patches.',\n\t17(op: string) {\n\t\treturn \"Unsupported patch operation: \" + op\n\t},\n\t18(plugin: string) {\n\t\treturn `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \\`enable${plugin}()\\` when initializing your application.`\n\t},\n\t20: \"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",\n\t21(thing: string) {\n\t\treturn `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`\n\t},\n\t22(thing: string) {\n\t\treturn `'current' expects a draft, got: ${thing}`\n\t},\n\t23(thing: string) {\n\t\treturn `'original' expects a draft, got: ${thing}`\n\t},\n\t24: \"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"\n} as const\n\nexport function die(error: keyof typeof errors, ...args: any[]): never {\n\tif (__DEV__) {\n\t\tconst e = errors[error]\n\t\tconst msg = !e\n\t\t\t? \"unknown error nr: \" + error\n\t\t\t: typeof e === \"function\"\n\t\t\t? e.apply(null, args as any)\n\t\t\t: e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}${\n\t\t\targs.length ? \" \" + args.map(s => `'${s}'`).join(\",\") : \"\"\n\t\t}. Find the full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","import {\n\tDRAFT_STATE,\n\tDRAFTABLE,\n\thasSet,\n\tObjectish,\n\tDrafted,\n\tAnyObject,\n\tAnyMap,\n\tAnySet,\n\tImmerState,\n\thasMap,\n\tArchtype,\n\tdie\n} from \"../internal\"\n\n/** Returns true if the given value is an Immer draft */\n/*#__PURE__*/\nexport function isDraft(value: any): boolean {\n\treturn !!value && !!value[DRAFT_STATE]\n}\n\n/** Returns true if the given value can be drafted by Immer */\n/*#__PURE__*/\nexport function isDraftable(value: any): boolean {\n\tif (!value) return false\n\treturn (\n\t\tisPlainObject(value) ||\n\t\tArray.isArray(value) ||\n\t\t!!value[DRAFTABLE] ||\n\t\t!!value.constructor?.[DRAFTABLE] ||\n\t\tisMap(value) ||\n\t\tisSet(value)\n\t)\n}\n\nconst objectCtorString = Object.prototype.constructor.toString()\n/*#__PURE__*/\nexport function isPlainObject(value: any): boolean {\n\tif (!value || typeof value !== \"object\") return false\n\tconst proto = Object.getPrototypeOf(value)\n\tif (proto === null) {\n\t\treturn true\n\t}\n\tconst Ctor =\n\t\tObject.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n\n\tif (Ctor === Object) return true\n\n\treturn (\n\t\ttypeof Ctor == \"function\" &&\n\t\tFunction.toString.call(Ctor) === objectCtorString\n\t)\n}\n\n/** Get the underlying object that is represented by the given draft */\n/*#__PURE__*/\nexport function original(value: T): T | undefined\nexport function original(value: Drafted): any {\n\tif (!isDraft(value)) die(23, value)\n\treturn value[DRAFT_STATE].base_\n}\n\n/*#__PURE__*/\nexport const ownKeys: (target: AnyObject) => PropertyKey[] =\n\ttypeof Reflect !== \"undefined\" && Reflect.ownKeys\n\t\t? Reflect.ownKeys\n\t\t: typeof Object.getOwnPropertySymbols !== \"undefined\"\n\t\t? obj =>\n\t\t\t\tObject.getOwnPropertyNames(obj).concat(\n\t\t\t\t\tObject.getOwnPropertySymbols(obj) as any\n\t\t\t\t)\n\t\t: /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport const getOwnPropertyDescriptors =\n\tObject.getOwnPropertyDescriptors ||\n\tfunction getOwnPropertyDescriptors(target: any) {\n\t\t// Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n\t\tconst res: any = {}\n\t\townKeys(target).forEach(key => {\n\t\t\tres[key] = Object.getOwnPropertyDescriptor(target, key)\n\t\t})\n\t\treturn res\n\t}\n\nexport function each(\n\tobj: T,\n\titer: (key: string | number, value: any, source: T) => void,\n\tenumerableOnly?: boolean\n): void\nexport function each(obj: any, iter: any, enumerableOnly = false) {\n\tif (getArchtype(obj) === Archtype.Object) {\n\t\t;(enumerableOnly ? Object.keys : ownKeys)(obj).forEach(key => {\n\t\t\tif (!enumerableOnly || typeof key !== \"symbol\") iter(key, obj[key], obj)\n\t\t})\n\t} else {\n\t\tobj.forEach((entry: any, index: any) => iter(index, entry, obj))\n\t}\n}\n\n/*#__PURE__*/\nexport function getArchtype(thing: any): Archtype {\n\t/* istanbul ignore next */\n\tconst state: undefined | ImmerState = thing[DRAFT_STATE]\n\treturn state\n\t\t? state.type_ > 3\n\t\t\t? state.type_ - 4 // cause Object and Array map back from 4 and 5\n\t\t\t: (state.type_ as any) // others are the same\n\t\t: Array.isArray(thing)\n\t\t? Archtype.Array\n\t\t: isMap(thing)\n\t\t? Archtype.Map\n\t\t: isSet(thing)\n\t\t? Archtype.Set\n\t\t: Archtype.Object\n}\n\n/*#__PURE__*/\nexport function has(thing: any, prop: PropertyKey): boolean {\n\treturn getArchtype(thing) === Archtype.Map\n\t\t? thing.has(prop)\n\t\t: Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\n/*#__PURE__*/\nexport function get(thing: AnyMap | AnyObject, prop: PropertyKey): any {\n\t// @ts-ignore\n\treturn getArchtype(thing) === Archtype.Map ? thing.get(prop) : thing[prop]\n}\n\n/*#__PURE__*/\nexport function set(thing: any, propOrOldValue: PropertyKey, value: any) {\n\tconst t = getArchtype(thing)\n\tif (t === Archtype.Map) thing.set(propOrOldValue, value)\n\telse if (t === Archtype.Set) {\n\t\tthing.delete(propOrOldValue)\n\t\tthing.add(value)\n\t} else thing[propOrOldValue] = value\n}\n\n/*#__PURE__*/\nexport function is(x: any, y: any): boolean {\n\t// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n\tif (x === y) {\n\t\treturn x !== 0 || 1 / x === 1 / y\n\t} else {\n\t\treturn x !== x && y !== y\n\t}\n}\n\n/*#__PURE__*/\nexport function isMap(target: any): target is AnyMap {\n\treturn hasMap && target instanceof Map\n}\n\n/*#__PURE__*/\nexport function isSet(target: any): target is AnySet {\n\treturn hasSet && target instanceof Set\n}\n/*#__PURE__*/\nexport function latest(state: ImmerState): any {\n\treturn state.copy_ || state.base_\n}\n\n/*#__PURE__*/\nexport function shallowCopy(base: any) {\n\tif (Array.isArray(base)) return Array.prototype.slice.call(base)\n\tconst descriptors = getOwnPropertyDescriptors(base)\n\tdelete descriptors[DRAFT_STATE as any]\n\tlet keys = ownKeys(descriptors)\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tconst key: any = keys[i]\n\t\tconst desc = descriptors[key]\n\t\tif (desc.writable === false) {\n\t\t\tdesc.writable = true\n\t\t\tdesc.configurable = true\n\t\t}\n\t\t// like object.assign, we will read any _own_, get/set accessors. This helps in dealing\n\t\t// with libraries that trap values, like mobx or vue\n\t\t// unlike object.assign, non-enumerables will be copied as well\n\t\tif (desc.get || desc.set)\n\t\t\tdescriptors[key] = {\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true, // could live with !!desc.set as well here...\n\t\t\t\tenumerable: desc.enumerable,\n\t\t\t\tvalue: base[key]\n\t\t\t}\n\t}\n\treturn Object.create(Object.getPrototypeOf(base), descriptors)\n}\n\n/**\n * Freezes draftable objects. Returns the original object.\n * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.\n *\n * @param obj\n * @param deep\n */\nexport function freeze(obj: T, deep?: boolean): T\nexport function freeze(obj: any, deep: boolean = false): T {\n\tif (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj\n\tif (getArchtype(obj) > 1 /* Map or Set */) {\n\t\tobj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any\n\t}\n\tObject.freeze(obj)\n\tif (deep) each(obj, (key, value) => freeze(value, true), true)\n\treturn obj\n}\n\nfunction dontMutateFrozenCollections() {\n\tdie(2)\n}\n\nexport function isFrozen(obj: any): boolean {\n\tif (obj == null || typeof obj !== \"object\") return true\n\t// See #600, IE dies on non-objects in Object.isFrozen\n\treturn Object.isFrozen(obj)\n}\n","import {\n\tImmerState,\n\tPatch,\n\tImmerScope,\n\tDrafted,\n\tAnyObject,\n\tImmerBaseState,\n\tAnyMap,\n\tAnySet,\n\tProxyType,\n\tdie\n} from \"../internal\"\n\n/** Plugin utilities */\nconst plugins: {\n\tPatches?: {\n\t\tgeneratePatches_(\n\t\t\tstate: ImmerState,\n\t\t\tbasePath: PatchPath,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tgenerateReplacementPatches_(\n\t\t\tbase: any,\n\t\t\treplacement: any,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tapplyPatches_(draft: T, patches: Patch[]): T\n\t}\n\tES5?: {\n\t\twillFinalizeES5_(scope: ImmerScope, result: any, isReplaced: boolean): void\n\t\tcreateES5Proxy_(\n\t\t\tbase: T,\n\t\t\tparent?: ImmerState\n\t\t): Drafted\n\t\thasChanges_(state: ES5ArrayState | ES5ObjectState): boolean\n\t}\n\tMapSet?: {\n\t\tproxyMap_(target: T, parent?: ImmerState): T\n\t\tproxySet_(target: T, parent?: ImmerState): T\n\t}\n} = {}\n\ntype Plugins = typeof plugins\n\nexport function getPlugin(\n\tpluginKey: K\n): Exclude {\n\tconst plugin = plugins[pluginKey]\n\tif (!plugin) {\n\t\tdie(18, pluginKey)\n\t}\n\t// @ts-ignore\n\treturn plugin\n}\n\nexport function loadPlugin(\n\tpluginKey: K,\n\timplementation: Plugins[K]\n): void {\n\tif (!plugins[pluginKey]) plugins[pluginKey] = implementation\n}\n\n/** ES5 Plugin */\n\ninterface ES5BaseState extends ImmerBaseState {\n\tassigned_: {[key: string]: any}\n\tparent_?: ImmerState\n\trevoked_: boolean\n}\n\nexport interface ES5ObjectState extends ES5BaseState {\n\ttype_: ProxyType.ES5Object\n\tdraft_: Drafted\n\tbase_: AnyObject\n\tcopy_: AnyObject | null\n}\n\nexport interface ES5ArrayState extends ES5BaseState {\n\ttype_: ProxyType.ES5Array\n\tdraft_: Drafted\n\tbase_: any\n\tcopy_: any\n}\n\n/** Map / Set plugin */\n\nexport interface MapState extends ImmerBaseState {\n\ttype_: ProxyType.Map\n\tcopy_: AnyMap | undefined\n\tassigned_: Map | undefined\n\tbase_: AnyMap\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\nexport interface SetState extends ImmerBaseState {\n\ttype_: ProxyType.Set\n\tcopy_: AnySet | undefined\n\tbase_: AnySet\n\tdrafts_: Map // maps the original value to the draft value in the new set\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\n/** Patches plugin */\n\nexport type PatchPath = (string | number)[]\n","import {\n\tPatch,\n\tPatchListener,\n\tDrafted,\n\tImmer,\n\tDRAFT_STATE,\n\tImmerState,\n\tProxyType,\n\tgetPlugin\n} from \"../internal\"\nimport {die} from \"../utils/errors\"\n\n/** Each scope represents a `produce` call. */\n\nexport interface ImmerScope {\n\tpatches_?: Patch[]\n\tinversePatches_?: Patch[]\n\tcanAutoFreeze_: boolean\n\tdrafts_: any[]\n\tparent_?: ImmerScope\n\tpatchListener_?: PatchListener\n\timmer_: Immer\n\tunfinalizedDrafts_: number\n}\n\nlet currentScope: ImmerScope | undefined\n\nexport function getCurrentScope() {\n\tif (__DEV__ && !currentScope) die(0)\n\treturn currentScope!\n}\n\nfunction createScope(\n\tparent_: ImmerScope | undefined,\n\timmer_: Immer\n): ImmerScope {\n\treturn {\n\t\tdrafts_: [],\n\t\tparent_,\n\t\timmer_,\n\t\t// Whenever the modified draft contains a draft from another scope, we\n\t\t// need to prevent auto-freezing so the unowned draft can be finalized.\n\t\tcanAutoFreeze_: true,\n\t\tunfinalizedDrafts_: 0\n\t}\n}\n\nexport function usePatchesInScope(\n\tscope: ImmerScope,\n\tpatchListener?: PatchListener\n) {\n\tif (patchListener) {\n\t\tgetPlugin(\"Patches\") // assert we have the plugin\n\t\tscope.patches_ = []\n\t\tscope.inversePatches_ = []\n\t\tscope.patchListener_ = patchListener\n\t}\n}\n\nexport function revokeScope(scope: ImmerScope) {\n\tleaveScope(scope)\n\tscope.drafts_.forEach(revokeDraft)\n\t// @ts-ignore\n\tscope.drafts_ = null\n}\n\nexport function leaveScope(scope: ImmerScope) {\n\tif (scope === currentScope) {\n\t\tcurrentScope = scope.parent_\n\t}\n}\n\nexport function enterScope(immer: Immer) {\n\treturn (currentScope = createScope(currentScope, immer))\n}\n\nfunction revokeDraft(draft: Drafted) {\n\tconst state: ImmerState = draft[DRAFT_STATE]\n\tif (\n\t\tstate.type_ === ProxyType.ProxyObject ||\n\t\tstate.type_ === ProxyType.ProxyArray\n\t)\n\t\tstate.revoke_()\n\telse state.revoked_ = true\n}\n","import {\n\tImmerScope,\n\tDRAFT_STATE,\n\tisDraftable,\n\tNOTHING,\n\tPatchPath,\n\teach,\n\thas,\n\tfreeze,\n\tImmerState,\n\tisDraft,\n\tSetState,\n\tset,\n\tProxyType,\n\tgetPlugin,\n\tdie,\n\trevokeScope,\n\tisFrozen,\n\tshallowCopy\n} from \"../internal\"\n\nexport function processResult(result: any, scope: ImmerScope) {\n\tscope.unfinalizedDrafts_ = scope.drafts_.length\n\tconst baseDraft = scope.drafts_![0]\n\tconst isReplaced = result !== undefined && result !== baseDraft\n\tif (!scope.immer_.useProxies_)\n\t\tgetPlugin(\"ES5\").willFinalizeES5_(scope, result, isReplaced)\n\tif (isReplaced) {\n\t\tif (baseDraft[DRAFT_STATE].modified_) {\n\t\t\trevokeScope(scope)\n\t\t\tdie(4)\n\t\t}\n\t\tif (isDraftable(result)) {\n\t\t\t// Finalize the result in case it contains (or is) a subset of the draft.\n\t\t\tresult = finalize(scope, result)\n\t\t\tif (!scope.parent_) maybeFreeze(scope, result)\n\t\t}\n\t\tif (scope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(\n\t\t\t\tbaseDraft[DRAFT_STATE].base_,\n\t\t\t\tresult,\n\t\t\t\tscope.patches_,\n\t\t\t\tscope.inversePatches_!\n\t\t\t)\n\t\t}\n\t} else {\n\t\t// Finalize the base draft.\n\t\tresult = finalize(scope, baseDraft, [])\n\t}\n\trevokeScope(scope)\n\tif (scope.patches_) {\n\t\tscope.patchListener_!(scope.patches_, scope.inversePatches_!)\n\t}\n\treturn result !== NOTHING ? result : undefined\n}\n\nfunction finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {\n\t// Don't recurse in tho recursive data structures\n\tif (isFrozen(value)) return value\n\n\tconst state: ImmerState = value[DRAFT_STATE]\n\t// A plain object, might need freezing, might contain drafts\n\tif (!state) {\n\t\teach(\n\t\t\tvalue,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, value, key, childValue, path),\n\t\t\ttrue // See #590, don't recurse into non-enumerable of non drafted objects\n\t\t)\n\t\treturn value\n\t}\n\t// Never finalize drafts owned by another scope.\n\tif (state.scope_ !== rootScope) return value\n\t// Unmodified draft, return the (frozen) original\n\tif (!state.modified_) {\n\t\tmaybeFreeze(rootScope, state.base_, true)\n\t\treturn state.base_\n\t}\n\t// Not finalized yet, let's do that now\n\tif (!state.finalized_) {\n\t\tstate.finalized_ = true\n\t\tstate.scope_.unfinalizedDrafts_--\n\t\tconst result =\n\t\t\t// For ES5, create a good copy from the draft first, with added keys and without deleted keys.\n\t\t\tstate.type_ === ProxyType.ES5Object || state.type_ === ProxyType.ES5Array\n\t\t\t\t? (state.copy_ = shallowCopy(state.draft_))\n\t\t\t\t: state.copy_\n\t\t// Finalize all children of the copy\n\t\t// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628\n\t\t// Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line\n\t\t// back to each(result, ....)\n\t\teach(\n\t\t\tstate.type_ === ProxyType.Set ? new Set(result) : result,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, result, key, childValue, path)\n\t\t)\n\t\t// everything inside is frozen, we can freeze here\n\t\tmaybeFreeze(rootScope, result, false)\n\t\t// first time finalizing, let's create those patches\n\t\tif (path && rootScope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generatePatches_(\n\t\t\t\tstate,\n\t\t\t\tpath,\n\t\t\t\trootScope.patches_,\n\t\t\t\trootScope.inversePatches_!\n\t\t\t)\n\t\t}\n\t}\n\treturn state.copy_\n}\n\nfunction finalizeProperty(\n\trootScope: ImmerScope,\n\tparentState: undefined | ImmerState,\n\ttargetObject: any,\n\tprop: string | number,\n\tchildValue: any,\n\trootPath?: PatchPath\n) {\n\tif (__DEV__ && childValue === targetObject) die(5)\n\tif (isDraft(childValue)) {\n\t\tconst path =\n\t\t\trootPath &&\n\t\t\tparentState &&\n\t\t\tparentState!.type_ !== ProxyType.Set && // Set objects are atomic since they have no keys.\n\t\t\t!has((parentState as Exclude).assigned_!, prop) // Skip deep patches for assigned keys.\n\t\t\t\t? rootPath!.concat(prop)\n\t\t\t\t: undefined\n\t\t// Drafts owned by `scope` are finalized here.\n\t\tconst res = finalize(rootScope, childValue, path)\n\t\tset(targetObject, prop, res)\n\t\t// Drafts from another scope must prevented to be frozen\n\t\t// if we got a draft back from finalize, we're in a nested produce and shouldn't freeze\n\t\tif (isDraft(res)) {\n\t\t\trootScope.canAutoFreeze_ = false\n\t\t} else return\n\t}\n\t// Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n\tif (isDraftable(childValue) && !isFrozen(childValue)) {\n\t\tif (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {\n\t\t\t// optimization: if an object is not a draft, and we don't have to\n\t\t\t// deepfreeze everything, and we are sure that no drafts are left in the remaining object\n\t\t\t// cause we saw and finalized all drafts already; we can stop visiting the rest of the tree.\n\t\t\t// This benefits especially adding large data tree's without further processing.\n\t\t\t// See add-data.js perf test\n\t\t\treturn\n\t\t}\n\t\tfinalize(rootScope, childValue)\n\t\t// immer deep freezes plain objects, so if there is no parent state, we freeze as well\n\t\tif (!parentState || !parentState.scope_.parent_)\n\t\t\tmaybeFreeze(rootScope, childValue)\n\t}\n}\n\nfunction maybeFreeze(scope: ImmerScope, value: any, deep = false) {\n\tif (scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {\n\t\tfreeze(value, deep)\n\t}\n}\n","import {\n\teach,\n\thas,\n\tis,\n\tisDraftable,\n\tshallowCopy,\n\tlatest,\n\tImmerBaseState,\n\tImmerState,\n\tDrafted,\n\tAnyObject,\n\tAnyArray,\n\tObjectish,\n\tgetCurrentScope,\n\tDRAFT_STATE,\n\tdie,\n\tcreateProxy,\n\tProxyType\n} from \"../internal\"\n\ninterface ProxyBaseState extends ImmerBaseState {\n\tassigned_: {\n\t\t[property: string]: boolean\n\t}\n\tparent_?: ImmerState\n\trevoke_(): void\n}\n\nexport interface ProxyObjectState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyObject\n\tbase_: any\n\tcopy_: any\n\tdraft_: Drafted\n}\n\nexport interface ProxyArrayState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyArray\n\tbase_: AnyArray\n\tcopy_: AnyArray | null\n\tdraft_: Drafted\n}\n\ntype ProxyState = ProxyObjectState | ProxyArrayState\n\n/**\n * Returns a new draft of the `base` object.\n *\n * The second argument is the parent draft-state (used internally).\n */\nexport function createProxyProxy(\n\tbase: T,\n\tparent?: ImmerState\n): Drafted {\n\tconst isArray = Array.isArray(base)\n\tconst state: ProxyState = {\n\t\ttype_: isArray ? ProxyType.ProxyArray : (ProxyType.ProxyObject as any),\n\t\t// Track which produce call this is associated with.\n\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t// True for both shallow and deep changes.\n\t\tmodified_: false,\n\t\t// Used during finalization.\n\t\tfinalized_: false,\n\t\t// Track which properties have been assigned (true) or deleted (false).\n\t\tassigned_: {},\n\t\t// The parent draft state.\n\t\tparent_: parent,\n\t\t// The base state.\n\t\tbase_: base,\n\t\t// The base proxy.\n\t\tdraft_: null as any, // set below\n\t\t// The base copy with any updated values.\n\t\tcopy_: null,\n\t\t// Called by the `produce` function.\n\t\trevoke_: null as any,\n\t\tisManual_: false\n\t}\n\n\t// the traps must target something, a bit like the 'real' base.\n\t// but also, we need to be able to determine from the target what the relevant state is\n\t// (to avoid creating traps per instance to capture the state in closure,\n\t// and to avoid creating weird hidden properties as well)\n\t// So the trick is to use 'state' as the actual 'target'! (and make sure we intercept everything)\n\t// Note that in the case of an array, we put the state in an array to have better Reflect defaults ootb\n\tlet target: T = state as any\n\tlet traps: ProxyHandler> = objectTraps\n\tif (isArray) {\n\t\ttarget = [state] as any\n\t\ttraps = arrayTraps\n\t}\n\n\tconst {revoke, proxy} = Proxy.revocable(target, traps)\n\tstate.draft_ = proxy as any\n\tstate.revoke_ = revoke\n\treturn proxy as any\n}\n\n/**\n * Object drafts\n */\nexport const objectTraps: ProxyHandler = {\n\tget(state, prop) {\n\t\tif (prop === DRAFT_STATE) return state\n\n\t\tconst source = latest(state)\n\t\tif (!has(source, prop)) {\n\t\t\t// non-existing or non-own property...\n\t\t\treturn readPropFromProto(state, source, prop)\n\t\t}\n\t\tconst value = source[prop]\n\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\treturn value\n\t\t}\n\t\t// Check for existing draft in modified state.\n\t\t// Assigned values are never drafted. This catches any drafts we created, too.\n\t\tif (value === peek(state.base_, prop)) {\n\t\t\tprepareCopy(state)\n\t\t\treturn (state.copy_![prop as any] = createProxy(\n\t\t\t\tstate.scope_.immer_,\n\t\t\t\tvalue,\n\t\t\t\tstate\n\t\t\t))\n\t\t}\n\t\treturn value\n\t},\n\thas(state, prop) {\n\t\treturn prop in latest(state)\n\t},\n\townKeys(state) {\n\t\treturn Reflect.ownKeys(latest(state))\n\t},\n\tset(\n\t\tstate: ProxyObjectState,\n\t\tprop: string /* strictly not, but helps TS */,\n\t\tvalue\n\t) {\n\t\tconst desc = getDescriptorFromProto(latest(state), prop)\n\t\tif (desc?.set) {\n\t\t\t// special case: if this write is captured by a setter, we have\n\t\t\t// to trigger it with the correct context\n\t\t\tdesc.set.call(state.draft_, value)\n\t\t\treturn true\n\t\t}\n\t\tif (!state.modified_) {\n\t\t\t// the last check is because we need to be able to distinguish setting a non-existing to undefined (which is a change)\n\t\t\t// from setting an existing property with value undefined to undefined (which is not a change)\n\t\t\tconst current = peek(latest(state), prop)\n\t\t\t// special case, if we assigning the original value to a draft, we can ignore the assignment\n\t\t\tconst currentState: ProxyObjectState = current?.[DRAFT_STATE]\n\t\t\tif (currentState && currentState.base_ === value) {\n\t\t\t\tstate.copy_![prop] = value\n\t\t\t\tstate.assigned_[prop] = false\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (is(value, current) && (value !== undefined || has(state.base_, prop)))\n\t\t\t\treturn true\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t}\n\n\t\tif (\n\t\t\tstate.copy_![prop] === value &&\n\t\t\t// special case: NaN\n\t\t\ttypeof value !== \"number\" &&\n\t\t\t// special case: handle new props with value 'undefined'\n\t\t\t(value !== undefined || prop in state.copy_)\n\t\t)\n\t\t\treturn true\n\n\t\t// @ts-ignore\n\t\tstate.copy_![prop] = value\n\t\tstate.assigned_[prop] = true\n\t\treturn true\n\t},\n\tdeleteProperty(state, prop: string) {\n\t\t// The `undefined` check is a fast path for pre-existing keys.\n\t\tif (peek(state.base_, prop) !== undefined || prop in state.base_) {\n\t\t\tstate.assigned_[prop] = false\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t} else {\n\t\t\t// if an originally not assigned property was deleted\n\t\t\tdelete state.assigned_[prop]\n\t\t}\n\t\t// @ts-ignore\n\t\tif (state.copy_) delete state.copy_[prop]\n\t\treturn true\n\t},\n\t// Note: We never coerce `desc.value` into an Immer draft, because we can't make\n\t// the same guarantee in ES5 mode.\n\tgetOwnPropertyDescriptor(state, prop) {\n\t\tconst owner = latest(state)\n\t\tconst desc = Reflect.getOwnPropertyDescriptor(owner, prop)\n\t\tif (!desc) return desc\n\t\treturn {\n\t\t\twritable: true,\n\t\t\tconfigurable: state.type_ !== ProxyType.ProxyArray || prop !== \"length\",\n\t\t\tenumerable: desc.enumerable,\n\t\t\tvalue: owner[prop]\n\t\t}\n\t},\n\tdefineProperty() {\n\t\tdie(11)\n\t},\n\tgetPrototypeOf(state) {\n\t\treturn Object.getPrototypeOf(state.base_)\n\t},\n\tsetPrototypeOf() {\n\t\tdie(12)\n\t}\n}\n\n/**\n * Array drafts\n */\n\nconst arrayTraps: ProxyHandler<[ProxyArrayState]> = {}\neach(objectTraps, (key, fn) => {\n\t// @ts-ignore\n\tarrayTraps[key] = function() {\n\t\targuments[0] = arguments[0][0]\n\t\treturn fn.apply(this, arguments)\n\t}\n})\narrayTraps.deleteProperty = function(state, prop) {\n\tif (__DEV__ && isNaN(parseInt(prop as any))) die(13)\n\t// @ts-ignore\n\treturn arrayTraps.set!.call(this, state, prop, undefined)\n}\narrayTraps.set = function(state, prop, value) {\n\tif (__DEV__ && prop !== \"length\" && isNaN(parseInt(prop as any))) die(14)\n\treturn objectTraps.set!.call(this, state[0], prop, value, state[0])\n}\n\n// Access a property without creating an Immer draft.\nfunction peek(draft: Drafted, prop: PropertyKey) {\n\tconst state = draft[DRAFT_STATE]\n\tconst source = state ? latest(state) : draft\n\treturn source[prop]\n}\n\nfunction readPropFromProto(state: ImmerState, source: any, prop: PropertyKey) {\n\tconst desc = getDescriptorFromProto(source, prop)\n\treturn desc\n\t\t? `value` in desc\n\t\t\t? desc.value\n\t\t\t: // This is a very special case, if the prop is a getter defined by the\n\t\t\t // prototype, we should invoke it with the draft as context!\n\t\t\t desc.get?.call(state.draft_)\n\t\t: undefined\n}\n\nfunction getDescriptorFromProto(\n\tsource: any,\n\tprop: PropertyKey\n): PropertyDescriptor | undefined {\n\t// 'in' checks proto!\n\tif (!(prop in source)) return undefined\n\tlet proto = Object.getPrototypeOf(source)\n\twhile (proto) {\n\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\tif (desc) return desc\n\t\tproto = Object.getPrototypeOf(proto)\n\t}\n\treturn undefined\n}\n\nexport function markChanged(state: ImmerState) {\n\tif (!state.modified_) {\n\t\tstate.modified_ = true\n\t\tif (state.parent_) {\n\t\t\tmarkChanged(state.parent_)\n\t\t}\n\t}\n}\n\nexport function prepareCopy(state: {base_: any; copy_: any}) {\n\tif (!state.copy_) {\n\t\tstate.copy_ = shallowCopy(state.base_)\n\t}\n}\n","import {\n\tIProduceWithPatches,\n\tIProduce,\n\tImmerState,\n\tDrafted,\n\tisDraftable,\n\tprocessResult,\n\tPatch,\n\tObjectish,\n\tDRAFT_STATE,\n\tDraft,\n\tPatchListener,\n\tisDraft,\n\tisMap,\n\tisSet,\n\tcreateProxyProxy,\n\tgetPlugin,\n\tdie,\n\thasProxies,\n\tenterScope,\n\trevokeScope,\n\tleaveScope,\n\tusePatchesInScope,\n\tgetCurrentScope,\n\tNOTHING,\n\tfreeze,\n\tcurrent\n} from \"../internal\"\n\ninterface ProducersFns {\n\tproduce: IProduce\n\tproduceWithPatches: IProduceWithPatches\n}\n\nexport class Immer implements ProducersFns {\n\tuseProxies_: boolean = hasProxies\n\n\tautoFreeze_: boolean = true\n\n\tconstructor(config?: {useProxies?: boolean; autoFreeze?: boolean}) {\n\t\tif (typeof config?.useProxies === \"boolean\")\n\t\t\tthis.setUseProxies(config!.useProxies)\n\t\tif (typeof config?.autoFreeze === \"boolean\")\n\t\t\tthis.setAutoFreeze(config!.autoFreeze)\n\t}\n\n\t/**\n\t * The `produce` function takes a value and a \"recipe function\" (whose\n\t * return value often depends on the base state). The recipe function is\n\t * free to mutate its first argument however it wants. All mutations are\n\t * only ever applied to a __copy__ of the base state.\n\t *\n\t * Pass only a function to create a \"curried producer\" which relieves you\n\t * from passing the recipe function every time.\n\t *\n\t * Only plain objects and arrays are made mutable. All other objects are\n\t * considered uncopyable.\n\t *\n\t * Note: This function is __bound__ to its `Immer` instance.\n\t *\n\t * @param {any} base - the initial state\n\t * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n\t * @param {Function} patchListener - optional function that will be called with all the patches produced here\n\t * @returns {any} a new state, or the initial state if nothing was modified\n\t */\n\tproduce: IProduce = (base: any, recipe?: any, patchListener?: any) => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\" && typeof recipe !== \"function\") {\n\t\t\tconst defaultBase = recipe\n\t\t\trecipe = base\n\n\t\t\tconst self = this\n\t\t\treturn function curriedProduce(\n\t\t\t\tthis: any,\n\t\t\t\tbase = defaultBase,\n\t\t\t\t...args: any[]\n\t\t\t) {\n\t\t\t\treturn self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore\n\t\t\t}\n\t\t}\n\n\t\tif (typeof recipe !== \"function\") die(6)\n\t\tif (patchListener !== undefined && typeof patchListener !== \"function\")\n\t\t\tdie(7)\n\n\t\tlet result\n\n\t\t// Only plain objects, arrays, and \"immerable classes\" are drafted.\n\t\tif (isDraftable(base)) {\n\t\t\tconst scope = enterScope(this)\n\t\t\tconst proxy = createProxy(this, base, undefined)\n\t\t\tlet hasError = true\n\t\t\ttry {\n\t\t\t\tresult = recipe(proxy)\n\t\t\t\thasError = false\n\t\t\t} finally {\n\t\t\t\t// finally instead of catch + rethrow better preserves original stack\n\t\t\t\tif (hasError) revokeScope(scope)\n\t\t\t\telse leaveScope(scope)\n\t\t\t}\n\t\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\tresult => {\n\t\t\t\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\t\t\t\treturn processResult(result, scope)\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\trevokeScope(scope)\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t}\n\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\treturn processResult(result, scope)\n\t\t} else if (!base || typeof base !== \"object\") {\n\t\t\tresult = recipe(base)\n\t\t\tif (result === undefined) result = base\n\t\t\tif (result === NOTHING) result = undefined\n\t\t\tif (this.autoFreeze_) freeze(result, true)\n\t\t\tif (patchListener) {\n\t\t\t\tconst p: Patch[] = []\n\t\t\t\tconst ip: Patch[] = []\n\t\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(base, result, p, ip)\n\t\t\t\tpatchListener(p, ip)\n\t\t\t}\n\t\t\treturn result\n\t\t} else die(21, base)\n\t}\n\n\tproduceWithPatches: IProduceWithPatches = (\n\t\tbase: any,\n\t\trecipe?: any,\n\t): any => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\") {\n\t\t\treturn (state: any, ...args: any[]) =>\n\t\t\t\tthis.produceWithPatches(state, (draft: any) => base(draft, ...args))\n\t\t}\n\n\t\tlet patches: Patch[], inversePatches: Patch[]\n\t\tconst result = this.produce(base, recipe, (p: Patch[], ip: Patch[]) => {\n\t\t\tpatches = p\n\t\t\tinversePatches = ip\n\t\t})\n\n\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\treturn result.then(nextState => [nextState, patches!, inversePatches!])\n\t\t}\n\t\treturn [result, patches!, inversePatches!]\n\t}\n\n\tcreateDraft(base: T): Draft {\n\t\tif (!isDraftable(base)) die(8)\n\t\tif (isDraft(base)) base = current(base)\n\t\tconst scope = enterScope(this)\n\t\tconst proxy = createProxy(this, base, undefined)\n\t\tproxy[DRAFT_STATE].isManual_ = true\n\t\tleaveScope(scope)\n\t\treturn proxy as any\n\t}\n\n\tfinishDraft>(\n\t\tdraft: D,\n\t\tpatchListener?: PatchListener\n\t): D extends Draft ? T : never {\n\t\tconst state: ImmerState = draft && (draft as any)[DRAFT_STATE]\n\t\tif (__DEV__) {\n\t\t\tif (!state || !state.isManual_) die(9)\n\t\t\tif (state.finalized_) die(10)\n\t\t}\n\t\tconst {scope_: scope} = state\n\t\tusePatchesInScope(scope, patchListener)\n\t\treturn processResult(undefined, scope)\n\t}\n\n\t/**\n\t * Pass true to automatically freeze all copies created by Immer.\n\t *\n\t * By default, auto-freezing is enabled.\n\t */\n\tsetAutoFreeze(value: boolean) {\n\t\tthis.autoFreeze_ = value\n\t}\n\n\t/**\n\t * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n\t * always faster than using ES5 proxies.\n\t *\n\t * By default, feature detection is used, so calling this is rarely necessary.\n\t */\n\tsetUseProxies(value: boolean) {\n\t\tif (value && !hasProxies) {\n\t\t\tdie(20)\n\t\t}\n\t\tthis.useProxies_ = value\n\t}\n\n\tapplyPatches(base: T, patches: Patch[]): T {\n\t\t// If a patch replaces the entire state, take that replacement as base\n\t\t// before applying patches\n\t\tlet i: number\n\t\tfor (i = patches.length - 1; i >= 0; i--) {\n\t\t\tconst patch = patches[i]\n\t\t\tif (patch.path.length === 0 && patch.op === \"replace\") {\n\t\t\t\tbase = patch.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// If there was a patch that replaced the entire state, start from the\n\t\t// patch after that.\n\t\tif (i > -1) {\n\t\t\tpatches = patches.slice(i + 1)\n\t\t}\n\n\t\tconst applyPatchesImpl = getPlugin(\"Patches\").applyPatches_\n\t\tif (isDraft(base)) {\n\t\t\t// N.B: never hits if some patch a replacement, patches are never drafts\n\t\t\treturn applyPatchesImpl(base, patches)\n\t\t}\n\t\t// Otherwise, produce a copy of the base state.\n\t\treturn this.produce(base, (draft: Drafted) =>\n\t\t\tapplyPatchesImpl(draft, patches)\n\t\t)\n\t}\n}\n\nexport function createProxy(\n\timmer: Immer,\n\tvalue: T,\n\tparent?: ImmerState\n): Drafted {\n\t// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft\n\tconst draft: Drafted = isMap(value)\n\t\t? getPlugin(\"MapSet\").proxyMap_(value, parent)\n\t\t: isSet(value)\n\t\t? getPlugin(\"MapSet\").proxySet_(value, parent)\n\t\t: immer.useProxies_\n\t\t? createProxyProxy(value, parent)\n\t\t: getPlugin(\"ES5\").createES5Proxy_(value, parent)\n\n\tconst scope = parent ? parent.scope_ : getCurrentScope()\n\tscope.drafts_.push(draft)\n\treturn draft\n}\n","import {\n\tdie,\n\tisDraft,\n\tshallowCopy,\n\teach,\n\tDRAFT_STATE,\n\tget,\n\tset,\n\tImmerState,\n\tisDraftable,\n\tArchtype,\n\tgetArchtype,\n\tgetPlugin\n} from \"../internal\"\n\n/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */\nexport function current(value: T): T\nexport function current(value: any): any {\n\tif (!isDraft(value)) die(22, value)\n\treturn currentImpl(value)\n}\n\nfunction currentImpl(value: any): any {\n\tif (!isDraftable(value)) return value\n\tconst state: ImmerState | undefined = value[DRAFT_STATE]\n\tlet copy: any\n\tconst archType = getArchtype(value)\n\tif (state) {\n\t\tif (\n\t\t\t!state.modified_ &&\n\t\t\t(state.type_ < 4 || !getPlugin(\"ES5\").hasChanges_(state as any))\n\t\t)\n\t\t\treturn state.base_\n\t\t// Optimization: avoid generating new drafts during copying\n\t\tstate.finalized_ = true\n\t\tcopy = copyHelper(value, archType)\n\t\tstate.finalized_ = false\n\t} else {\n\t\tcopy = copyHelper(value, archType)\n\t}\n\n\teach(copy, (key, childValue) => {\n\t\tif (state && get(state.base_, key) === childValue) return // no need to copy or search in something that didn't change\n\t\tset(copy, key, currentImpl(childValue))\n\t})\n\t// In the future, we might consider freezing here, based on the current settings\n\treturn archType === Archtype.Set ? new Set(copy) : copy\n}\n\nfunction copyHelper(value: any, archType: number): any {\n\t// creates a shallow copy, even if it is a map or set\n\tswitch (archType) {\n\t\tcase Archtype.Map:\n\t\t\treturn new Map(value)\n\t\tcase Archtype.Set:\n\t\t\t// Set will be cloned as array temporarily, so that we can replace individual items\n\t\t\treturn Array.from(value)\n\t}\n\treturn shallowCopy(value)\n}\n","import {\n\tIProduce,\n\tIProduceWithPatches,\n\tImmer,\n\tDraft,\n\tImmutable\n} from \"./internal\"\n\nexport {\n\tDraft,\n\tImmutable,\n\tPatch,\n\tPatchListener,\n\toriginal,\n\tcurrent,\n\tisDraft,\n\tisDraftable,\n\tNOTHING as nothing,\n\tDRAFTABLE as immerable,\n\tfreeze\n} from \"./internal\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce: IProduce = immer.produce\nexport default produce\n\n/**\n * Like `produce`, but `produceWithPatches` always returns a tuple\n * [nextState, patches, inversePatches] (instead of just the next state)\n */\nexport const produceWithPatches: IProduceWithPatches = immer.produceWithPatches.bind(\n\timmer\n)\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * Always freeze by default, even in production mode\n */\nexport const setAutoFreeze = immer.setAutoFreeze.bind(immer)\n\n/**\n * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n * always faster than using ES5 proxies.\n *\n * By default, feature detection is used, so calling this is rarely necessary.\n */\nexport const setUseProxies = immer.setUseProxies.bind(immer)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = immer.applyPatches.bind(immer)\n\n/**\n * Create an Immer draft from the given base state, which may be a draft itself.\n * The draft can be modified until you finalize it with the `finishDraft` function.\n */\nexport const createDraft = immer.createDraft.bind(immer)\n\n/**\n * Finalize an Immer draft from a `createDraft` call, returning the base state\n * (if no changes were made) or a modified copy. The draft must *not* be\n * mutated afterwards.\n *\n * Pass a function as the 2nd argument to generate Immer patches based on the\n * changes that were made.\n */\nexport const finishDraft = immer.finishDraft.bind(immer)\n\n/**\n * This function is actually a no-op, but can be used to cast an immutable type\n * to an draft type and make TypeScript happy\n *\n * @param value\n */\nexport function castDraft(value: T): Draft {\n\treturn value as any\n}\n\n/**\n * This function is actually a no-op, but can be used to cast a mutable type\n * to an immutable type and make TypeScript happy\n * @param value\n */\nexport function castImmutable(value: T): Immutable {\n\treturn value as any\n}\n\nexport {Immer}\n\nexport {enableES5} from \"./plugins/es5\"\nexport {enablePatches} from \"./plugins/patches\"\nexport {enableMapSet} from \"./plugins/mapset\"\nexport {enableAllPlugins} from \"./plugins/all\"\n","// Should be no imports here!\n\n// Some things that should be evaluated before all else...\n\n// We only want to know if non-polyfilled symbols are available\nconst hasSymbol =\n\ttypeof Symbol !== \"undefined\" && typeof Symbol(\"x\") === \"symbol\"\nexport const hasMap = typeof Map !== \"undefined\"\nexport const hasSet = typeof Set !== \"undefined\"\nexport const hasProxies =\n\ttypeof Proxy !== \"undefined\" &&\n\ttypeof Proxy.revocable !== \"undefined\" &&\n\ttypeof Reflect !== \"undefined\"\n\n/**\n * The sentinel value returned by producers to replace the draft with undefined.\n */\nexport const NOTHING: Nothing = hasSymbol\n\t? Symbol.for(\"immer-nothing\")\n\t: ({[\"immer-nothing\"]: true} as any)\n\n/**\n * To let Immer treat your class instances as plain immutable objects\n * (albeit with a custom prototype), you must define either an instance property\n * or a static property on each of your custom classes.\n *\n * Otherwise, your class instance will never be drafted, which means it won't be\n * safe to mutate in a produce callback.\n */\nexport const DRAFTABLE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-draftable\")\n\t: (\"__$immer_draftable\" as any)\n\nexport const DRAFT_STATE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-state\")\n\t: (\"__$immer_state\" as any)\n\n// Even a polyfilled Symbol might provide Symbol.iterator\nexport const iteratorSymbol: typeof Symbol.iterator =\n\t(typeof Symbol != \"undefined\" && Symbol.iterator) || (\"@@iterator\" as any)\n\n/** Use a class type for `nothing` so its type is unique */\nexport class Nothing {\n\t// This lets us do `Exclude`\n\t// @ts-ignore\n\tprivate _!: unique symbol\n}\n","import produce from \"immer\";\nimport { Dispatch, useEffect, useReducer, useState } from \"react\";\n\nexport function useImmerReducer<\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Reducers extends Record T | void>\n>(reducers: Reducers, initialState: T) {\n return useReducer(\n (\n state: T,\n command: {\n action: keyof Reducers;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload?: any;\n }\n ): T =>\n produce(state, (draft: T) => {\n reducers[command.action](draft, command.payload);\n }),\n initialState\n );\n}\n\nexport function useStateInitializer(init: T): [T, Dispatch] {\n const [state, setState] = useState(init);\n useEffect(() => {\n setState(init);\n }, [init]);\n return [state, setState];\n}\n","import { width } from \"@davidsouther/jiffies/lib/esm/dom/css/sizing.js\";\nimport { useCallback, useState } from \"react\";\nimport { useStateInitializer } from \"./react.js\";\n\nconst Mode = { VIEW: 0, EDIT: 1 };\n\nexport const InlineEdit = (props: {\n mode?: keyof typeof Mode;\n value: string;\n onChange: (value: string) => void;\n}) => {\n const [mode, setMode] = useState(props.mode ?? Mode.VIEW);\n const [value, setValue] = useStateInitializer(props.value);\n\n const render = () => {\n switch (mode) {\n case Mode.EDIT:\n return edit();\n case Mode.VIEW:\n return view();\n default:\n return ;\n }\n };\n\n const view = () => (\n {\n setMode(Mode.EDIT);\n }}\n >\n {value}\n \n );\n\n const doSelect = useCallback(\n (ref: HTMLInputElement | null) => ref?.select(),\n []\n );\n const doChange = useCallback(\n (target: HTMLInputElement) => {\n setMode(Mode.VIEW);\n setValue(target.value ?? \"\");\n props.onChange(target.value ?? \"\");\n },\n [props, setMode, setValue]\n );\n const edit = () => {\n const edit = (\n \n doChange(target)}\n onKeyPress={({ key, target }) => {\n if (key === \"Enter\") {\n doChange(target as HTMLInputElement);\n }\n }}\n type=\"text\"\n defaultValue={value}\n />\n \n );\n return edit;\n };\n\n return render();\n};\n\nexport default InlineEdit;\n","/* eslint-disable @typescript-eslint/ban-types */\nimport {\n Key,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from \"react\";\n\nexport interface VirtualScrollSettings {\n /**Minimum offset into the adapter. Default is 0. */\n minIndex: number;\n /** Maximum offset into the adapter. Default is Number.MAX_SAFE_INTEGER. */\n maxIndex: number;\n /** Initial index to start rendering from. Default is minIndex. */\n startIndex: number;\n /**\n * Number of items to render in visible area. Default is entire range from\n * minIndex to maxIndex.\n */\n count: number;\n /**\n * Maximum number of items to render on either side of the visible area.\n * Default is `count`.\n */\n tolerance: number;\n /** Height of each item, in pixels. Default is 20px. */\n itemHeight: number;\n}\n\nexport interface VirtualScrollDataAdapter {\n (offset: number, limit: number): Iterable;\n}\n\nexport function arrayAdapter(data: T[]): VirtualScrollDataAdapter {\n return (offset, limit) => data.slice(offset, offset + limit);\n}\n\nexport interface VirtualScrollProps {\n settings?: Partial;\n get: VirtualScrollDataAdapter;\n row: (t: T) => U;\n rowKey: (t: T) => Key;\n}\n\nexport function fillVirtualScrollSettings(\n settings: Partial\n): VirtualScrollSettings {\n const {\n minIndex = 0,\n maxIndex = Number.MAX_SAFE_INTEGER,\n startIndex = 0,\n itemHeight = 20,\n count = Math.max(maxIndex - minIndex, 1),\n tolerance = count,\n } = settings;\n\n return { minIndex, maxIndex, startIndex, itemHeight, count, tolerance };\n}\n\nexport function initialState(\n settings: VirtualScrollSettings,\n adapter: VirtualScrollDataAdapter\n): VirtualScrollState {\n // From Denis Hilt, https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/\n const { minIndex, maxIndex, startIndex, itemHeight, count, tolerance } =\n settings;\n const bufferedItems = count + 2 * tolerance;\n const itemsAbove = Math.max(0, startIndex - tolerance - minIndex);\n\n const viewportHeight = count * itemHeight;\n const totalHeight = (maxIndex - minIndex) * itemHeight;\n const toleranceHeight = tolerance * itemHeight;\n const bufferHeight = viewportHeight + 2 * toleranceHeight;\n const topPaddingHeight = itemsAbove * itemHeight;\n const bottomPaddingHeight = totalHeight - (topPaddingHeight + bufferHeight);\n\n const state: VirtualScrollState = {\n scrollTop: 0,\n settings,\n viewportHeight,\n totalHeight,\n toleranceHeight,\n bufferedItems,\n topPaddingHeight,\n bottomPaddingHeight,\n data: [],\n };\n\n return {\n ...state,\n ...doScroll(topPaddingHeight + toleranceHeight, state, adapter),\n };\n}\n\nexport function getData(\n minIndex: number,\n maxIndex: number,\n offset: number,\n limit: number,\n get: VirtualScrollDataAdapter\n): T[] {\n const start = Math.max(0, minIndex, offset);\n const end = Math.min(maxIndex, offset + limit - 1);\n const data = get(start, end - start);\n return [...data];\n}\n\ninterface ScrollUpdate {\n scrollTop: number;\n topPaddingHeight: number;\n bottomPaddingHeight: number;\n data: T[];\n}\n\nexport function doScroll(\n scrollTop: number,\n state: VirtualScrollState,\n get: VirtualScrollDataAdapter\n): ScrollUpdate {\n const {\n totalHeight,\n toleranceHeight,\n bufferedItems,\n settings: { itemHeight, minIndex, maxIndex },\n } = state;\n const index =\n minIndex + Math.floor((scrollTop - toleranceHeight) / itemHeight);\n const data = getData(minIndex, maxIndex, index, bufferedItems, get);\n const topPaddingHeight = Math.max((index - minIndex) * itemHeight, 0);\n const bottomPaddingHeight = Math.max(\n totalHeight - (topPaddingHeight + data.length * itemHeight),\n 0\n );\n\n return { scrollTop, topPaddingHeight, bottomPaddingHeight, data };\n}\n\ninterface VirtualScrollState {\n settings: VirtualScrollSettings;\n scrollTop: number; // px\n bufferedItems: number; // count\n totalHeight: number; // px\n viewportHeight: number; // px\n topPaddingHeight: number; // px\n bottomPaddingHeight: number; // px\n toleranceHeight: number; // px\n data: T[];\n}\n\nconst scrollReducer =\n (get: VirtualScrollDataAdapter) =>\n (state: VirtualScrollState, scrollTop: number) => ({\n ...state,\n ...doScroll(scrollTop, state, get),\n });\n\nexport const VirtualScroll = (\n props: VirtualScrollProps & { className?: string }\n) => {\n const viewportRef = useRef(null);\n\n const { settings, startState, reducer } = useMemo(() => {\n const settings = fillVirtualScrollSettings(props.settings ?? {});\n const startState = initialState(settings, props.get);\n const reducer = scrollReducer(props.get);\n return { settings, reducer, startState };\n }, [props.settings, props.get]);\n\n const [state, dispatchScroll] = useReducer(reducer, startState);\n\n useEffect(() => {\n if (viewportRef.current !== null) {\n dispatchScroll(viewportRef.current.scrollTop);\n }\n }, [settings, props.row]);\n\n const initialScroll = useCallback(\n (div: HTMLDivElement | null) => {\n if (div) {\n div.scrollTop = viewportRef.current\n ? viewportRef.current.scrollTop\n : settings.startIndex * settings.itemHeight;\n }\n viewportRef.current = div;\n },\n [viewportRef, settings.startIndex, settings.itemHeight]\n );\n\n const rows = state.data.map((d) => (\n
\n {props.row(d)}\n
\n ));\n\n return (\n dispatchScroll((e.target as HTMLDivElement).scrollTop)}\n >\n
\n {rows}\n
\n
\n );\n};\n\nexport default VirtualScroll;\n","import { useEffect, useMemo, useState } from \"react\";\n\nimport { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\n\nexport function useClock(actions: {\n tick?: () => void;\n toggle?: () => void;\n reset?: () => void;\n}) {\n const clock = useMemo(() => Clock.get(), []);\n\n useEffect(() => {\n const subscription = clock.$.subscribe(() => {\n actions.tick?.();\n });\n return () => subscription.unsubscribe();\n }, [actions, clock.$]);\n\n return {\n toggle() {\n clock.tick();\n actions.toggle?.();\n },\n\n reset() {\n clock.reset();\n actions.reset?.();\n },\n };\n}\n\nexport function useClockFrame(frameFinished: () => void) {\n useEffect(() => {\n const subscription = Clock.get().frame$.subscribe(() => {\n frameFinished();\n });\n return () => subscription.unsubscribe();\n }, [frameFinished]);\n}\n\nexport function useClockReset(reset: () => void) {\n useEffect(() => {\n const subscription = Clock.get().reset$.subscribe(() => {\n reset();\n });\n return () => subscription.unsubscribe();\n }, [reset]);\n}\n\nexport function displayClock() {\n return display(Clock.get());\n}\n\nexport function useClockface() {\n const [clockface, setClockface] = useState(displayClock());\n\n useEffect(() => {\n const subscription = Clock.get().$.subscribe(() => {\n setClockface(displayClock());\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return clockface;\n}\n\nexport const Clockface = () => {\n const clockface = useClockface();\n return {clockface};\n};\n","import { rounded } from \"@davidsouther/jiffies/lib/esm/dom/css/border.js\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\n\nimport {\n Format,\n FORMATS,\n Memory as MemoryChip,\n} from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { asm } from \"@nand2tetris/simulator/util/asm.js\";\nimport { bin, dec, hex } from \"@nand2tetris/simulator/util/twos.js\";\nimport InlineEdit from \"../inline_edit.js\";\nimport VirtualScroll, { VirtualScrollSettings } from \"../virtual_scroll.js\";\nimport { useClockReset } from \"../clockface.js\";\n\nconst ITEM_HEIGHT = 34;\n\nexport const MemoryBlock = ({\n memory,\n jmp = { value: 0 },\n highlight = -1,\n editable = false,\n format = dec,\n onChange = () => undefined,\n}: {\n jmp?: { value: number };\n memory: MemoryChip;\n highlight?: number;\n editable?: boolean;\n format?: (v: number) => string;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => {\n const settings = useMemo>(\n () => ({\n count: Math.min(memory.size, 20),\n maxIndex: memory.size,\n itemHeight: ITEM_HEIGHT,\n startIndex: jmp.value,\n }),\n [memory.size, jmp]\n );\n const get = useCallback(\n (offset: number, count: number) =>\n memory\n .range(offset, offset + count)\n .map((v, i) => [i + offset, v] as [number, number]),\n [memory]\n );\n const row = useCallback(\n ([i, v]: [number, number]) => (\n \n ),\n [format, editable, highlight, onChange]\n );\n\n return (\n \n settings={settings}\n get={get}\n row={row}\n rowKey={([i]) => i}\n />\n );\n};\n\nexport const MemoryCell = ({\n index,\n value,\n highlight = false,\n editable = false,\n onChange = () => undefined,\n}: {\n index: number;\n value: string;\n highlight?: boolean;\n editable?: boolean;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => (\n
\n \n {hex(index)}\n \n \n {editable ? (\n \n onChange(index, newValue, Number(value))\n }\n />\n ) : (\n {value}\n )}\n \n
\n);\n\nexport const Memory = ({\n name = \"Memory\",\n highlight = -1,\n editable = true,\n memory,\n format = \"dec\",\n}: {\n name?: string;\n editable?: boolean;\n highlight?: number;\n memory: MemoryChip;\n format: Format;\n}) => {\n const [fmt, setFormat] = useState(format);\n const [jmp, setJmp] = useState(\"\");\n const [goto, setGoto] = useState({ value: 0 });\n\n const jumpTo = () => {\n setGoto({\n value: !isNaN(parseInt(jmp)) && isFinite(parseInt(jmp)) ? Number(jmp) : 0,\n });\n };\n\n // const { filePicker, fs } = useContext(AppContext);\n // const doLoad = useCallback(async () => {\n // try {\n // const file = await filePicker.select();\n // await memory.load(fs, file);\n // } catch (e) {\n // console.error(e);\n // }\n // }, [fs, filePicker, memory]);\n\n const doLoad = () => undefined;\n\n const doUpdate = useCallback(\n (i: number, v: string) => {\n memory.update(i, v, fmt ?? \"dec\");\n },\n [memory, fmt]\n );\n\n useClockReset(() => {\n setJmp(\"\");\n setGoto({ value: 0 });\n });\n\n return (\n
\n
\n
{name}
\n
\n \n key === \"Enter\" && jumpTo()}\n onChange={({ target: { value } }) => setJmp(value)}\n />\n \n {FORMATS.map((option) => (\n \n setFormat(option)}\n />\n {option}\n \n ))}\n
\n
\n doFormat(fmt, v)}\n onChange={doUpdate}\n />\n
\n );\n};\n\nexport default Memory;\n\nfunction doFormat(format: Format, v: number): string {\n switch (format) {\n case \"bin\":\n return bin(v);\n case \"hex\":\n return hex(v);\n case \"asm\":\n return asm(v);\n case \"dec\":\n default:\n return dec(v);\n }\n}\n","import { Memory } from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { assertExists } from \"@davidsouther/jiffies/lib/esm/assert.js\";\nimport { useCallback, useRef } from \"react\";\nimport { useClockFrame, useClockReset } from \"../clockface.js\";\n\nconst WHITE = \"white\";\nconst BLACK = \"black\";\ntype COLOR = typeof WHITE | typeof BLACK;\n\nexport interface ScreenMemory {\n get(idx: number): number;\n}\n\nexport function reduceScreen(memory: Memory, offset = 0): ScreenMemory {\n return {\n get(idx: number): number {\n return memory.get(offset + idx);\n },\n };\n}\n\nfunction get(mem: ScreenMemory, x: number, y: number): COLOR {\n const byte = mem.get(32 * y + ((x / 16) | 0));\n const bit = byte & (1 << x % 16);\n return bit === 0 ? WHITE : BLACK;\n}\n\nfunction set(data: Uint8ClampedArray, x: number, y: number, value: COLOR) {\n const pixel = (y * 512 + x) * 4;\n const color = value === WHITE ? 255 : 0;\n data[pixel] = color;\n data[pixel + 1] = color;\n data[pixel + 2] = color;\n data[pixel + 3] = 255;\n}\n\nfunction drawImage(ctx: CanvasRenderingContext2D, memory: ScreenMemory) {\n const image = assertExists(\n ctx.getImageData(0, 0, 512, 256),\n \"Failed to create Context2d\"\n );\n for (let col = 0; col < 512; col++) {\n for (let row = 0; row < 256; row++) {\n const color = get(memory, col, row);\n set(image.data, col, row, color);\n }\n }\n ctx.putImageData(image, 0, 0);\n}\n\nexport const Screen = ({ memory }: { memory: ScreenMemory }) => {\n const canvas = useRef();\n\n const draw = useCallback(() => {\n const ctx = canvas.current?.getContext(\"2d\") ?? undefined;\n\n if (ctx) {\n drawImage(ctx, memory);\n }\n }, [memory]);\n\n const ctxRef = useCallback(\n (ref: HTMLCanvasElement | null) => {\n canvas.current = ref ?? undefined;\n draw();\n },\n [canvas, draw]\n );\n\n useClockFrame(draw);\n useClockReset(() => {\n canvas.current\n ?.getContext(\"2d\")\n ?.clearRect(0, 0, canvas.current.width, canvas.current.height);\n });\n\n return (\n
\n
Screen
\n
\n \n \n \n
\n
\n );\n};\n","import {\n Keyboard,\n Screen,\n} from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { ALU } from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n PC,\n Register,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/bit.js\";\nimport {\n RAM,\n RAM8,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/ram.js\";\nimport { Chip, HIGH } from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Flags } from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { CPU, decode } from \"@nand2tetris/simulator/cpu/cpu.js\";\nimport { ReactElement } from \"react\";\nimport { ALUComponent } from \"./alu.js\";\nimport { Keyboard as KeyboardComponent } from \"./keyboard.js\";\nimport { Memory as MemoryComponent } from \"./memory.js\";\nimport { RegisterComponent } from \"./register.js\";\nimport { Screen as ScreenComponent } from \"./screen.js\";\n\nexport function getBuiltinVisualization(part: Chip): ReactElement | undefined {\n switch (part.name) {\n case \"Register\":\n case \"ARegister\":\n case \"DRegister\":\n case \"PC\":\n case \"KEYBOARD\":\n case \"RAM8\":\n case \"RAM64\":\n case \"RAM512\":\n case \"RAM4K\":\n case \"RAM16K\":\n case \"ROM32K\":\n case \"Screen\":\n case \"Memory\":\n default:\n return undefined;\n }\n}\n\nexport function makeVisualization(\n chip: Chip,\n updateAction?: () => void\n): ReactElement | undefined {\n if (chip instanceof ALU) {\n return (\n \n );\n }\n if (chip instanceof Register) {\n return (\n \n );\n }\n if (chip instanceof PC) {\n return ;\n }\n if (chip instanceof Keyboard) {\n return ;\n }\n if (chip instanceof Screen) {\n return ;\n }\n if (chip instanceof RAM) {\n return (\n \n );\n }\n if (chip instanceof RAM8) {\n return RAM {chip.width};\n }\n if (chip instanceof CPU) {\n const bits = decode(chip.in(\"instruction\").busVoltage);\n return (\n <>\n \n \n \n \n \n );\n }\n\n const vis = [...chip.parts]\n .map((chip) => makeVisualization(chip, updateAction))\n .filter((v) => v !== undefined);\n return vis.length > 0 ? <>{vis} : undefined;\n}\n\nexport function makeVisualizationsWithId(\n chip: {\n parts: Chip[];\n },\n updateAction?: () => void\n): [string, ReactElement][] {\n return [...chip.parts]\n .map((part, i): [string, ReactElement | undefined] => [\n `${part.id}_${i}`,\n makeVisualization(part, updateAction),\n ])\n .filter(([_, v]) => v !== undefined) as [string, ReactElement][];\n}\n","import { Ok, isOk } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport {\n REGISTRY as BUILTIN_REGISTRY,\n getBuiltinChip,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\n\nexport class ChipDisplayInfo {\n signBehaviors: Map = new Map();\n\n public constructor(chipName: string, unsigned?: string[]) {\n if (BUILTIN_REGISTRY.has(chipName)) {\n const chip = getBuiltinChip(chipName);\n if (isOk(chip)) {\n const pins = Array.from(Ok(chip).ins.entries()).concat(\n Array.from(Ok(chip).outs.entries())\n );\n for (const pin of pins) {\n this.signBehaviors.set(\n pin.name,\n !unsigned || !unsigned.includes(pin.name)\n );\n }\n }\n }\n }\n\n public isSigned(pin: string) {\n return this.signBehaviors.get(pin);\n }\n}\n\nconst UNSIGNED_PINS = new Map([\n [\"Mux4Way16\", [\"sel\"]],\n [\"Mux8Way16\", [\"sel\"]],\n [\"DMux4Way\", [\"sel\"]],\n [\"DMux8Way\", [\"sel\"]],\n [\"RAM8\", [\"address\"]],\n [\"RAM64\", [\"address\"]],\n [\"RAM512\", [\"address\"]],\n [\"RAM4K\", [\"address\"]],\n [\"RAM16K\", [\"address\"]],\n [\"Screen\", [\"address\"]],\n [\"Memory\", [\"address\"]],\n [\"CPU\", [\"addressM\", \"pc\"]],\n]);\n\nexport const getDisplayInfo = (chipName: string) =>\n new ChipDisplayInfo(chipName, UNSIGNED_PINS.get(chipName));\n","// import { plural, Trans } from \"@lingui/macro\";\nimport {\n Pin as ChipPin,\n Pins,\n Voltage,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { range } from \"@davidsouther/jiffies/lib/esm/range.js\";\nimport { ChipSim } from \"./stores/chip.store.js\";\nimport { createContext, useContext, useEffect, useState } from \"react\";\nimport { ChipDisplayInfo, getDisplayInfo } from \"./pin_display.js\";\n\nexport const PinContext = createContext({});\n\nexport interface ImmPin {\n bits: [number, Voltage][];\n pin: ChipPin;\n}\n\nexport function reducePin(pin: ChipPin) {\n return {\n pin,\n bits: range(0, pin.width)\n .map((i) => [i, pin.voltage(i)] as [number, Voltage])\n .reverse(),\n };\n}\n\nexport function reducePins(pins: Pins): ImmPin[] {\n return [...pins.entries()].map(reducePin);\n}\n\nexport interface PinoutPins {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}\n\nexport const FullPinout = (props: {\n sim: ChipSim;\n toggle: (pin: ChipPin, i: number | undefined) => void;\n setInputValid: (pending: boolean) => void;\n hideInternal?: boolean;\n}) => {\n const { inPins, outPins, internalPins } = props.sim;\n const displayInfo = getDisplayInfo(props.sim.chip[0].name ?? \"\");\n return (\n <>\n \n \n \n \n \n {!props.hideInternal && (\n \n )}\n \n
\n \n );\n};\n\nexport const PinoutBlock = (\n props: PinoutPins & {\n header: string;\n disabled?: boolean;\n enableEdit?: boolean;\n setInputValid?: (valid: boolean) => void;\n displayInfo: ChipDisplayInfo;\n }\n) => (\n <>\n {props.pins.length > 0 && (\n \n {props.header}\n \n )}\n {[...props.pins].map((immPin) => (\n \n {immPin.pin.name}\n \n \n \n \n ))}\n \n);\n\nexport const Pinout = ({\n pins,\n toggle,\n}: {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}) => {\n if (pins.length === 0) {\n return <>None;\n }\n return (\n \n \n \n \n \n \n \n \n {[...pins].map((immPin) => (\n \n \n \n \n ))}\n \n
NameValue
{immPin.pin.name}\n \n
\n );\n};\n\nconst Pin = ({\n pin,\n toggle,\n disabled = false,\n enableEdit = true,\n signed = true,\n setInputValid,\n internal = false,\n}: {\n pin: ImmPin;\n toggle: ((pin: ChipPin, bit?: number) => void) | undefined;\n disabled?: boolean;\n enableEdit?: boolean;\n signed?: boolean;\n setInputValid?: (valid: boolean) => void;\n internal: boolean;\n}) => {\n const [isBin, setIsBin] = useState(true);\n let inputValid = true;\n const [decimal, setDecimal] = useState(\"\");\n\n const toggleBin = () => {\n setIsBin(!isBin);\n };\n\n const resetDispatcher = useContext(PinContext);\n if (resetDispatcher instanceof PinResetDispatcher) {\n resetDispatcher.registerCallback(() => {\n setIsBin(true);\n });\n }\n\n const setInputValidity = (valid: boolean) => {\n inputValid = valid;\n setInputValid?.(valid);\n };\n\n const handleDecimalChange = (value: string) => {\n const positive = value.replace(/[^\\d]/g, \"\");\n const numeric = signed && value[0] === \"-\" ? `-${positive}` : positive;\n\n setDecimal(numeric);\n if (isNaN(parseInt(numeric))) {\n setInputValidity(false);\n } else {\n const newValue = parseInt(numeric);\n if (\n (!signed && newValue >= Math.pow(2, pin.bits.length)) ||\n (signed &&\n (newValue >= Math.pow(2, pin.bits.length - 1) ||\n newValue < -Math.pow(2, pin.bits.length - 1)))\n ) {\n setInputValidity(false);\n } else {\n updatePins(newValue);\n setInputValidity(true);\n }\n }\n };\n\n const updatePins = (n: number) => {\n for (let i = 0; i < pin.bits.length; i++) {\n if (pin.bits[pin.bits.length - i - 1][1] !== ((n >> i) & 1)) {\n toggle?.(pin.pin, i);\n }\n }\n };\n\n useEffect(() => {\n if (!isBin && inputValid) {\n let value = 0;\n if (signed && pin.bits[0][1]) {\n // negative\n for (const [i, v] of pin.bits) {\n if (i < pin.bits.length - 1 && !v) {\n value += 2 ** i;\n }\n }\n value = -value - 1;\n } else {\n // positive\n const limit = signed ? pin.bits.length - 1 : pin.bits.length;\n for (const [i, v] of pin.bits) {\n if (i < limit && v) {\n value += 2 ** i;\n }\n }\n }\n setDecimal(value.toString());\n }\n }, [pin, isBin]);\n\n return (\n \n
\n {isBin ? (\n pin.bits.map(([i, v]) => (\n toggle?.(pin.pin, i)}\n data-testid={`pin-${i}`}\n >\n {v}\n \n ))\n ) : (\n {\n handleDecimalChange(e.target.value);\n }}\n disabled={!enableEdit}\n />\n )}\n
\n {pin.bits.length > 1 && (\n <>\n
\n toggleBin()}\n >\n {isBin ? \"dec\" : \"bin\"}\n \n \n )}\n
\n );\n};\n\nexport class PinResetDispatcher {\n private callbacks: (() => void)[] = [];\n\n registerCallback(callback: () => void) {\n this.callbacks.push(callback);\n }\n\n reset() {\n for (const callback of this.callbacks) {\n callback();\n }\n }\n}\n","import { ReactNode } from \"react\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useTimer } from \"./timer.js\";\n\nexport const Runbar = (props: { runner: Timer; children?: ReactNode }) => {\n const runner = useTimer(props.runner);\n return (\n
\n runner.actions.frame()}\n data-tooltip={`Step`}\n data-placement=\"bottom\"\n >\n {/* */}\n ➡️\n \n \n runner.state.running ? runner.actions.stop() : runner.actions.start()\n }\n data-tooltip={runner.state.running ? `Pause` : `Play`}\n data-placement=\"bottom\"\n >\n {/* */}\n {runner.state.running ? \"⏸\" : \"️⏩\"}\n \n runner.actions.reset()}\n data-tooltip={`Reset`}\n data-placement=\"bottom\"\n >\n {/* */}⏮\n \n {\n runner.dispatch({\n action: \"setSpeed\",\n payload: Number(e.target?.value ?? runner.state.speed),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n // [2000, `Debug`], // For debugging, basically the same as clicking through\n [1000, `Slow`],\n [500, `Fast`],\n [16, `Faster`],\n ].map(([speed, label]) => (\n \n ))}\n \n {\n runner.dispatch({\n action: \"setSteps\",\n payload: Number(e.target?.value ?? runner.state.steps),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n [1, `1 Step`],\n [500, \"500\"],\n [1000, \"1000\"],\n [2000, \"2000\"],\n ].map(([steps, label]) => (\n \n ))}\n \n {props.children}\n
\n );\n};\n","import { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useImmerReducer } from \"./react.js\";\n\nexport interface TimerStoreState {\n steps: number;\n speed: number;\n running: boolean;\n}\n\nimport { Dispatch, MutableRefObject, useMemo, useRef } from \"react\";\nexport type TimerStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nconst makeTimerStore = (\n timer: Timer,\n dispatch: MutableRefObject\n) => {\n const initialState: TimerStoreState = {\n running: timer.running,\n speed: timer.speed,\n steps: timer.steps,\n };\n\n const finishFrame = timer.finishFrame.bind(timer);\n timer.finishFrame = function () {\n finishFrame();\n dispatch.current({ action: \"update\" });\n };\n\n const reducers = {\n update(state: TimerStoreState) {\n state.running = timer.running;\n state.speed = timer.speed;\n state.steps = timer.steps;\n },\n setSteps(state: TimerStoreState, steps: number) {\n state.steps = steps;\n timer.steps = steps;\n },\n setSpeed(state: TimerStoreState, speed: number) {\n state.speed = speed;\n timer.speed = speed;\n },\n };\n\n const actions = {\n frame() {\n timer.frame();\n },\n start() {\n timer.start();\n dispatch.current({ action: \"update\" });\n },\n stop() {\n timer.stop();\n dispatch.current({ action: \"update\" });\n },\n reset() {\n timer.reset();\n dispatch.current({ action: \"update\" });\n },\n };\n\n return { initialState, reducers, actions };\n};\n\nexport function useTimer(timer: Timer) {\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeTimerStore(timer, dispatch),\n [timer, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(reducers, initialState);\n\n dispatch.current = dispatcher;\n\n return { state, dispatch: dispatch.current, actions };\n}\n","import { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { FileSystem } from \"@davidsouther/jiffies/lib/esm/fs.js\";\nimport { Err, isErr, Ok } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport { Dispatch, MutableRefObject, useContext, useMemo, useRef } from \"react\";\n\nimport { build as buildChip } from \"@nand2tetris/simulator/chip/builder.js\";\nimport {\n getBuiltinChip,\n REGISTRY,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n Chip,\n Chip as SimChip,\n Low,\n Pin,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\nimport { Span } from \"@nand2tetris/simulator/languages/base.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport {\n BUILTIN_CHIP_PROJECTS,\n CHIP_ORDER,\n CHIP_PROJECTS,\n ChipProjects,\n} from \"@nand2tetris/projects/index.js\";\nimport { ChipTest } from \"@nand2tetris/simulator/tst.js\";\n\nimport { ImmPin, reducePins } from \"../pinout.js\";\nimport { useImmerReducer } from \"../react.js\";\n\nimport { BaseContext } from \"./base.context.js\";\nimport { assert } from \"@davidsouther/jiffies/lib/esm/assert.js\";\n\nexport const PROJECT_NAMES = [\n [\"01\", `Project 1`],\n [\"02\", `Project 2`],\n [\"03\", `Project 3`],\n [\"05\", `Project 5`],\n];\n\nfunction getChips(project: keyof typeof CHIP_PROJECTS) {\n return project in CHIP_ORDER\n ? (CHIP_ORDER as Record)[project]\n : BUILTIN_CHIP_PROJECTS[project].concat(CHIP_PROJECTS[project]);\n}\n\nfunction findDropdowns(storage: Record) {\n const project =\n (storage[\"/chip/project\"] as keyof typeof CHIP_PROJECTS) ?? \"01\";\n const chips = getChips(project);\n const chipName = storage[\"/chip/chip\"] ?? CHIP_PROJECTS[project][0];\n return { project, chips, chipName };\n}\n\nfunction makeHdl(name: string) {\n return `CHIP ${name} {\n IN in;\n OUT out;\n PARTS:\n}`;\n}\n\nfunction makeTst() {\n return `repeat 10 {\n tick,\n tock;\n}`;\n}\n\nfunction makeCmp() {\n return `| in|out|`;\n}\n\nexport function isBuiltinOnly(chipName: string) {\n return Object.values(BUILTIN_CHIP_PROJECTS).flat().includes(chipName);\n}\n\nfunction getTemplate(project: keyof typeof CHIP_PROJECTS, chipName: string) {\n if (isBuiltinOnly(chipName)) {\n return (ChipProjects[project].BUILTIN_CHIPS as Record)[\n chipName\n ];\n }\n\n return (\n ChipProjects[project].CHIPS as Record>\n )[chipName][`${chipName}.hdl`] as string;\n}\n\nfunction getBuiltinCode(project: keyof typeof CHIP_PROJECTS, chipName: string) {\n const template = getTemplate(project, chipName);\n if (isBuiltinOnly(chipName)) {\n return template;\n }\n const bodyComment = \"//// Replace this comment with your code.\";\n const builtinLine = `BUILTIN ${chipName};`;\n const builtinCode = template.includes(bodyComment)\n ? template.replace(bodyComment, builtinLine)\n : template.replace(\"PARTS:\", `PARTS:\\n ${builtinLine}`);\n return builtinCode;\n}\n\nexport interface ChipPageState {\n files: Files;\n sim: ChipSim;\n controls: ControlsState;\n}\n\nexport interface ChipSim {\n clocked: boolean;\n inPins: ImmPin[];\n outPins: ImmPin[];\n internalPins: ImmPin[];\n chip: [Chip];\n pending: boolean;\n invalid: boolean;\n}\n\nexport interface Files {\n hdl: string;\n cmp: string;\n tst: string;\n out: string;\n}\n\nexport interface ControlsState {\n project: keyof typeof CHIP_PROJECTS;\n chips: string[];\n chipName: string;\n hasBuiltin: boolean;\n builtinOnly: boolean;\n runningTest: boolean;\n span?: Span;\n error: string;\n}\n\nfunction reduceChip(chip: SimChip, pending = false, invalid = false): ChipSim {\n return {\n clocked: chip.clocked,\n inPins: reducePins(chip.ins),\n outPins: reducePins(chip.outs),\n internalPins: reducePins(chip.pins),\n chip: [chip],\n pending,\n invalid,\n };\n}\n\nconst clock = Clock.get();\n\nexport type ChipStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nexport function makeChipStore(\n fs: FileSystem,\n setStatus: (status: string) => void,\n storage: Record,\n dispatch: MutableRefObject\n) {\n const dropdowns = findDropdowns(storage);\n let { project, chipName } = dropdowns;\n const { chips } = dropdowns;\n let chip = new Low();\n let test = new ChipTest();\n let usingBuiltin = false;\n let builtinOnly = false;\n\n const reducers = {\n setFiles(\n state: ChipPageState,\n {\n hdl = state.files.hdl,\n tst = state.files.tst,\n cmp = state.files.cmp,\n out = \"\",\n }: {\n hdl?: string;\n tst?: string;\n cmp?: string;\n out?: string;\n }\n ) {\n state.files.hdl = hdl;\n state.files.tst = tst;\n state.files.cmp = cmp;\n state.files.out = out;\n },\n\n updateChip(\n state: ChipPageState,\n payload?: {\n pending?: boolean;\n invalid?: boolean;\n chipName?: string;\n error?: string;\n }\n ) {\n state.sim = reduceChip(\n chip,\n payload?.pending ?? state.sim.pending,\n payload?.invalid ?? state.sim.invalid\n );\n state.controls.error = state.sim.invalid\n ? payload?.error ?? state.controls.error\n : \"\";\n state.controls.chips = getChips(state.controls.project);\n state.controls.chipName = state.sim.invalid\n ? payload?.chipName ?? chipName\n : chip.name ?? payload?.chipName ?? chipName;\n if (!state.controls.chips.includes(state.controls.chipName)) {\n state.controls.chips = [\n ...state.controls.chips,\n state.controls.chipName,\n ];\n }\n },\n\n setProject(state: ChipPageState, project: keyof typeof CHIP_PROJECTS) {\n const chips = getChips(project);\n const chipName =\n state.controls.chipName && chips.includes(state.controls.chipName)\n ? state.controls.chipName\n : chips[0];\n state.controls.project = project;\n state.controls.chips = chips;\n this.setChip(state, chipName);\n },\n\n setChip(state: ChipPageState, chipName: string) {\n state.controls.chipName = chipName;\n state.controls.hasBuiltin = REGISTRY.has(chipName);\n state.controls.builtinOnly = isBuiltinOnly(chipName);\n },\n\n testRunning(state: ChipPageState) {\n state.controls.runningTest = true;\n },\n\n testFinished(state: ChipPageState) {\n state.controls.runningTest = false;\n const passed = state.files.out.trim() === state.files.cmp.trim();\n setStatus(\n passed\n ? `Simulation successful: The output file is identical to the compare file`\n : `Simulation error: The output file differs from the compare file`\n );\n },\n\n updateTestStep(state: ChipPageState) {\n state.files.out = test?.log() ?? \"\";\n if (test?.currentStep?.span) {\n state.controls.span = test.currentStep.span;\n } else {\n if (test.done) {\n const end = state.files.tst.length;\n state.controls.span = {\n start: end - 1,\n end,\n };\n }\n }\n this.updateChip(state, {\n pending: state.sim.pending,\n invalid: state.sim.invalid,\n });\n },\n };\n\n const actions = {\n setProject(p: keyof typeof CHIP_PROJECTS) {\n project = storage[\"/chip/project\"] = p;\n dispatch.current({ action: \"setProject\", payload: project });\n this.setChip(CHIP_PROJECTS[project][0]);\n },\n\n async setChip(chip: string, project = storage[\"/chip/project\"] ?? \"01\") {\n chipName = storage[\"/chip/chip\"] = chip;\n dispatch.current({ action: \"setChip\", payload: chipName });\n builtinOnly = isBuiltinOnly(chipName);\n\n if (builtinOnly) {\n dispatch.current({\n action: \"setFiles\",\n payload: { hdl: \"\", tst: \"\", cmp: \"\" },\n });\n this.useBuiltin();\n return;\n }\n await this.loadChip(project, chipName);\n if (usingBuiltin) {\n this.useBuiltin();\n }\n },\n\n reset() {\n Clock.get().reset();\n chip.reset();\n test.reset();\n dispatch.current({ action: \"setFiles\", payload: {} });\n dispatch.current({ action: \"updateChip\" });\n },\n\n async updateFiles({\n hdl,\n tst,\n cmp,\n }: {\n hdl?: string;\n tst?: string;\n cmp: string;\n }) {\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n try {\n if (hdl) {\n await this.compileChip(hdl);\n }\n if (tst) {\n this.compileTest(tst);\n }\n } catch (e) {\n setStatus(display(e));\n }\n },\n\n async compileChip(hdl: string) {\n chip.remove();\n const maybeParsed = HDL.parse(hdl);\n if (isErr(maybeParsed)) {\n setStatus(\"Failed to parse chip\");\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error: display(Err(maybeParsed)) },\n });\n return;\n }\n const maybeChip = await buildChip(Ok(maybeParsed));\n if (isErr(maybeChip)) {\n const error = display(Err(maybeChip));\n setStatus(error);\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error },\n });\n return;\n }\n setStatus(`Compiled ${chip.name}`);\n this.replaceChip(Ok(maybeChip));\n },\n\n replaceChip(nextChip: SimChip) {\n // Store current inPins\n const inPins = chip.ins;\n for (const [pin, { busVoltage }] of inPins) {\n const nextPin = nextChip.ins.get(pin);\n if (nextPin) {\n nextPin.busVoltage = busVoltage;\n }\n }\n clock.reset();\n nextChip.eval();\n chip = nextChip;\n chip.reset();\n test = test.with(chip).reset();\n dispatch.current({ action: \"updateChip\", payload: { invalid: false } });\n dispatch.current({ action: \"updateTestStep\" });\n },\n\n async loadChip(project: string, name: string) {\n storage[\"/chip/chip\"] = name;\n const fsName = (ext: string) =>\n `/projects/${project}/${name}/${name}.${ext}`;\n\n const [hdl, tst, cmp] = await Promise.all([\n fs.readFile(fsName(\"hdl\")).catch(() => makeHdl(name)),\n fs.readFile(fsName(\"tst\")).catch((e) => {\n return makeTst();\n }),\n fs.readFile(fsName(\"cmp\")).catch(() => makeCmp()),\n ]);\n\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n await this.compileChip(hdl);\n this.compileTest(tst);\n },\n\n async saveChip(hdl: string, prj = project, name = chipName) {\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n const path = `/projects/${prj}/${name}/${name}.hdl`;\n await fs.writeFile(path, hdl);\n setStatus(`Saved ${path}`);\n },\n\n toggle(pin: Pin, i: number | undefined) {\n if (i !== undefined) {\n pin.busVoltage = pin.busVoltage ^ (1 << i);\n } else {\n if (pin.width === 1) {\n pin.toggle();\n } else {\n pin.busVoltage += 1;\n }\n }\n dispatch.current({ action: \"updateChip\", payload: { pending: true } });\n },\n\n eval() {\n chip.eval();\n dispatch.current({ action: \"updateChip\", payload: { pending: false } });\n },\n\n clock() {\n clock.toggle();\n if (clock.isLow) {\n clock.frame();\n }\n dispatch.current({ action: \"updateChip\" });\n },\n\n async useBuiltin(doUseBuiltin = true, oldHdl?: string) {\n if (!doUseBuiltin) {\n if (!builtinOnly) {\n usingBuiltin = false;\n }\n await this.loadChip(project, chipName);\n return;\n }\n if (!builtinOnly) {\n usingBuiltin = true;\n }\n const builtinName = chipName;\n const nextChip = getBuiltinChip(builtinName);\n if (isErr(nextChip)) {\n setStatus(\n `Failed to load builtin ${builtinName}: ${display(Err(nextChip))}`\n );\n return;\n }\n\n // Save hdl code that will be overwritten by the switch\n if (oldHdl) {\n await this.saveChip(oldHdl, project, chipName);\n }\n\n const hdl = getBuiltinCode(project, builtinName);\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n this.replaceChip(Ok(nextChip));\n },\n\n async initialize() {\n await this.setChip(chipName, project);\n },\n\n compileTest(file: string) {\n dispatch.current({ action: \"setFiles\", payload: { tst: file } });\n const tst = TST.parse(file);\n\n if (isErr(tst)) {\n setStatus(`Failed to parse test`);\n return false;\n }\n setStatus(`Parsed tst`);\n\n test = ChipTest.from(Ok(tst)).with(chip).reset();\n test.setFileSystem(fs);\n dispatch.current({ action: \"updateTestStep\" });\n return true;\n },\n\n async runTest(file: string) {\n if (!this.compileTest(file)) {\n return;\n }\n dispatch.current({ action: \"testRunning\" });\n\n fs.pushd(\"/samples\");\n await test.run();\n fs.popd();\n\n dispatch.current({ action: \"updateTestStep\" });\n dispatch.current({ action: \"testFinished\" });\n },\n\n tick(): Promise {\n return this.stepTest();\n },\n\n async stepTest(): Promise {\n assert(test.chipId === chip.id, \"Test and chip out of sync\");\n const done = await test.step();\n dispatch.current({ action: \"updateTestStep\" });\n if (done) {\n dispatch.current({ action: \"testFinished\" });\n }\n return done;\n },\n };\n\n const initialState: ChipPageState = (() => {\n const controls: ControlsState = {\n project,\n chips,\n chipName,\n hasBuiltin: REGISTRY.has(chipName),\n builtinOnly: isBuiltinOnly(chipName),\n runningTest: false,\n error: \"\",\n };\n\n const maybeChip = getBuiltinChip(controls.chipName);\n if (isErr(maybeChip)) {\n setStatus(display(Err(maybeChip)));\n chip = new Low();\n } else {\n chip = Ok(maybeChip);\n }\n\n const sim = reduceChip(chip);\n\n return {\n controls,\n files: {\n hdl: \"\",\n cmp: \"\",\n tst: \"\",\n out: \"\",\n },\n sim,\n };\n })();\n\n return { initialState, reducers, actions };\n}\n\nexport function useChipPageStore() {\n const { fs, setStatus, storage } = useContext(BaseContext);\n\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeChipStore(fs, setStatus, storage, dispatch),\n [fs, setStatus, storage, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(\n reducers as unknown as Record<\n string,\n (state: ChipPageState, action?: unknown) => ChipPageState\n >,\n initialState\n );\n dispatch.current = dispatcher;\n\n return { state, dispatch, actions };\n}\n","import { Clock } from \"./chip/clock.js\";\n\nexport const MAX_STEPS = 1000;\n\nconst clock = Clock.get();\n\nexport abstract class Timer {\n frame() {\n this.tick();\n this.finishFrame();\n }\n\n abstract tick(): Promise | boolean;\n\n finishFrame() {\n clock.frame();\n }\n\n abstract reset(): void;\n\n abstract toggle(): void;\n\n steps = 1; // How many steps to take per update\n speed = 1000; // how often to update, in ms\n get running() {\n return this.#running;\n }\n\n #running = false;\n #sinceLastFrame = 0;\n #lastUpdate = 0;\n #run = async () => {\n if (!this.#running) {\n return;\n }\n const now = Date.now();\n const delta = now - this.#lastUpdate;\n this.#lastUpdate = now;\n this.#sinceLastFrame += delta;\n if (this.#sinceLastFrame > this.speed) {\n let done = false;\n for (let i = 0; i < Math.min(this.steps, MAX_STEPS) && !done; i++) {\n done = await this.tick();\n }\n this.finishFrame();\n if (done) {\n this.stop();\n }\n this.#sinceLastFrame -= this.speed;\n }\n requestAnimationFrame(this.#run);\n };\n\n start() {\n this.#running = true;\n this.#lastUpdate = Date.now() - this.speed;\n this.#run();\n this.toggle();\n }\n\n stop() {\n this.#running = false;\n this.toggle();\n }\n}\n","import { debounce } from \"@davidsouther/jiffies/lib/esm/debounce\";\nimport { Trans } from \"@lingui/macro\";\nimport MonacoEditor, { useMonaco } from \"@monaco-editor/react\";\nimport type * as monacoT from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { OnMount } from \"@monaco-editor/react\";\nimport ohm from \"ohm-js\";\nimport {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AppContext } from \"../App.context\";\n\nimport {\n Span,\n UNKNOWN_PARSE_ERROR,\n} from \"@nand2tetris/simulator/languages/base.js\";\n\nimport \"./editor.scss\";\n\nexport const ErrorPanel = ({ error }: { error?: ohm.MatchResult }) => {\n return error?.failed() ? (\n
\n \n Parse Error\n \n
\n        \n          {error?.message ?? error?.shortMessage ?? UNKNOWN_PARSE_ERROR}\n        \n      
\n
\n ) : (\n <>\n );\n};\n\nconst Textarea = ({\n value,\n onChange,\n language,\n disabled = false,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n disabled?: boolean;\n}) => {\n const [text, setText] = useState(value);\n return (\n {\n const value = e.target?.value;\n setText(value);\n onChange(value);\n }}\n />\n );\n};\n\nconst MONACO_LIGHT_THEME = \"vs\";\nconst MONACO_DARK_THEME = \"vs-dark\";\n\nconst makeHighlight = (\n monaco: typeof monacoT | null,\n editor: monacoT.editor.IStandaloneCodeEditor | undefined,\n highlight: Span | undefined,\n decorations: string[]\n): string[] => {\n if (!(editor && highlight)) return decorations;\n const model = editor.getModel();\n if (!model) return decorations;\n const start = model.getPositionAt(highlight.start);\n const end = model.getPositionAt(highlight.end);\n const range = monaco?.Range.fromPositions(start, end);\n const nextDecoration: monacoT.editor.IModelDeltaDecoration[] = [];\n if (range) {\n nextDecoration.push({\n range,\n options: { inlineClassName: \"highlight\" },\n });\n editor.revealRangeInCenter(range);\n }\n return editor.deltaDecorations(decorations, nextDecoration);\n};\n\nconst Monaco = ({\n value,\n onChange,\n language,\n error,\n disabled = false,\n highlight: currentHighlight,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n error?: ohm.MatchResult | undefined;\n disabled?: boolean;\n highlight?: Span;\n}) => {\n const { theme } = useContext(AppContext);\n const monaco = useMonaco();\n\n const editor = useRef();\n const decorations = useRef([]);\n const highlight = useRef(undefined);\n\n const codeTheme = useCallback(() => {\n const isDark =\n theme === \"system\"\n ? window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n : theme === \"dark\";\n return isDark ? MONACO_DARK_THEME : MONACO_LIGHT_THEME;\n }, [theme]);\n\n const doHighlight = useCallback(() => {\n decorations.current = makeHighlight(\n monaco,\n editor.current,\n // I'm not sure why this makes things work, but it is load bearing.\n // Removing the empty span will cause the initial first-statement\n // highlight in the test view to not show. Setting it to [0, 1] will\n // cause a 1-character highlight in the editor view, so don't do that\n // either.\n highlight.current ?? { start: 0, end: 0 },\n decorations.current\n );\n }, [decorations, monaco, editor, highlight]);\n\n // Mark and center highlighted spans\n useEffect(() => {\n highlight.current = currentHighlight;\n doHighlight();\n }, [currentHighlight]);\n\n // Set options when mounting\n const onMount: OnMount = useCallback(\n (ed) => {\n editor.current = ed;\n editor.current?.updateOptions({\n fontFamily: `\"JetBrains Mono\", source-code-pro, Menlo, Monaco,\n Consolas, \"Roboto Mono\", \"Ubuntu Monospace\", \"Noto Mono\", \"Oxygen Mono\",\n \"Liberation Mono\", monospace, \"Apple Color Emoji\", \"Segoe UI Emoji\",\n \"Segoe UI Symbol\", \"Noto Color Emoji\"`,\n fontSize: 16,\n minimap: {\n enabled: false,\n },\n theme: codeTheme(),\n scrollBeyondLastLine: false,\n readOnly: disabled,\n });\n doHighlight();\n },\n [codeTheme]\n );\n\n // Set themes\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ theme: codeTheme() });\n }, [editor, codeTheme]);\n\n // Prevent editing disabled editors\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ readOnly: disabled });\n }, [editor, disabled]);\n\n // Add error markers on parse failure\n useEffect(() => {\n if (editor.current === undefined) return;\n if (monaco === null) return;\n const model = editor.current.getModel();\n if (model === null) return;\n if (error === undefined || error.succeeded()) {\n monaco.editor.setModelMarkers(model, language, []);\n return;\n }\n // Line 7, col 5:\n const { line, column, message } =\n /Line (?\\d+), col (?\\d+): (?.*)/.exec(\n error.shortMessage ?? \"\"\n )?.groups ?? { line: 1, column: 1, message: \"could not parse error\" };\n const startLineNumber = Number(line);\n const endLineNumber = startLineNumber;\n const startColumn = Number(column);\n const restOfLine = model\n .getLineContent(startLineNumber)\n .substring(startColumn - 1);\n let endColumn =\n startColumn + (restOfLine.match(/([^\\s]+)/)?.[0].length ?? 1);\n if (endColumn <= startColumn) {\n endColumn = startColumn + 1;\n }\n\n monaco.editor.setModelMarkers(model, language, [\n {\n message,\n startColumn,\n startLineNumber,\n endColumn,\n endLineNumber,\n severity: 8, // monacoT.MarkerSeverity.Error,\n },\n ]);\n }, [error, editor, monaco, language]);\n\n return (\n <>\n onChange(v)}\n language={language}\n onMount={onMount}\n />\n \n );\n};\n\nexport const Editor = ({\n className = \"\",\n style = {},\n disabled = false,\n value,\n onChange,\n grammar,\n language,\n highlight,\n}: {\n className?: string;\n style?: CSSProperties;\n disabled?: boolean;\n value: string;\n onChange: (source: string) => void;\n grammar: ohm.Grammar;\n language: string;\n highlight?: Span;\n}) => {\n const [error, setError] = useState();\n const { monaco } = useContext(AppContext);\n\n const parse = useCallback(\n (text = \"\") => {\n const parsed = grammar.match(text);\n setError(parsed.failed() ? parsed : undefined);\n },\n [setError, grammar]\n );\n\n useEffect(() => parse(value), [parse, value]);\n const doParse = useMemo(() => debounce(parse, 500), [parse]);\n\n const onChangeCB = useCallback(\n (text = \"\") => {\n onChange(text);\n doParse(text);\n },\n [doParse, onChange]\n );\n\n return (\n
\n {monaco.canUse && monaco.wants ? (\n \n ) : (\n <>\n \n \n \n )}\n
\n );\n};\n","export function debounce(fn, ms = 32) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => (clearTimeout(timer), fn(...args)), ms);\n return timer;\n };\n}\n","import { CSSProperties, ReactNode } from \"react\";\n\nexport const Panel = (props: {\n children: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}) => {\n return (\n
\n {props.header &&
{props.header}
}\n
{props.children}
\n {props.footer &&
{props.footer}
}\n
\n );\n};\n\nexport const Accordian = (props: {\n children: ReactNode;\n summary: ReactNode;\n className?: string;\n style?: CSSProperties;\n open?: boolean;\n}) => {\n return (\n \n \n
{props.summary}
\n
\n {props.children}\n \n );\n};\n","import { Trans } from \"@lingui/macro\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport \"./chip.scss\";\n\nimport { makeVisualizationsWithId } from \"@nand2tetris/components/chips/visualizations.js\";\nimport { Clockface } from \"@nand2tetris/components/clockface.js\";\nimport { DiffTable } from \"@nand2tetris/components/difftable.js\";\nimport {\n FullPinout,\n PinContext,\n PinResetDispatcher,\n} from \"@nand2tetris/components/pinout.js\";\nimport { useStateInitializer } from \"@nand2tetris/components/react.js\";\nimport { Runbar } from \"@nand2tetris/components/runbar.js\";\nimport { BaseContext } from \"@nand2tetris/components/stores/base.context.js\";\nimport {\n Files,\n PROJECT_NAMES,\n isBuiltinOnly,\n useChipPageStore,\n} from \"@nand2tetris/components/stores/chip.store.js\";\nimport { CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { CMP } from \"@nand2tetris/simulator/languages/cmp.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { AppContext } from \"../App.context\";\nimport { Icon } from \"../pico/icon\";\nimport { Editor } from \"../shell/editor\";\nimport { Accordian, Panel } from \"../shell/panel\";\n\nexport const Chip = () => {\n const { fs, setStatus } = useContext(BaseContext);\n const { filePicker, tracking } = useContext(AppContext);\n const { state, actions, dispatch } = useChipPageStore();\n\n const [hdl, setHdl] = useStateInitializer(state.files.hdl);\n const [tst, setTst] = useStateInitializer(state.files.tst);\n const [cmp, setCmp] = useStateInitializer(state.files.cmp);\n const [out] = useStateInitializer(state.files.out);\n\n useEffect(() => {\n actions.initialize();\n }, [actions]);\n\n useEffect(() => {\n tracking.trackPage(\"/chip\");\n }, [tracking]);\n\n const saveChip = () => {\n actions.saveChip(hdl);\n };\n\n useEffect(() => {\n tracking.trackEvent(\"action\", \"setProject\", state.controls.project);\n tracking.trackEvent(\"action\", \"setChip\", state.controls.chipName);\n }, []);\n\n const setProject = useCallback(\n (project: keyof typeof CHIP_PROJECTS) => {\n actions.setProject(project);\n tracking.trackEvent(\"action\", \"setProject\", project);\n },\n [actions, tracking]\n );\n\n const setChip = useCallback(\n (chip: string) => {\n actions.setChip(chip);\n tracking.trackEvent(\"action\", \"setChip\", chip);\n pinResetDispatcher.reset();\n },\n [actions, tracking]\n );\n\n const doEval = useCallback(() => {\n actions.eval();\n tracking.trackEvent(\"action\", \"eval\");\n }, [actions, tracking]);\n\n const compile = useRef<(files?: Partial) => void>(() => undefined);\n compile.current = async (files: Partial = {}) => {\n await actions.updateFiles({\n hdl: files.hdl,\n tst: files.tst ?? tst,\n cmp: files.cmp ?? cmp,\n });\n };\n\n const loadTest = useCallback(async () => {\n try {\n const path = await filePicker.select();\n const tst = await fs.readFile(path);\n await compile.current({ tst });\n } catch (e) {\n console.error(e);\n setStatus(`Failed to load into memory`);\n }\n }, [filePicker, setStatus, fs, compile]);\n\n const runner = useRef();\n useEffect(() => {\n runner.current = new (class ChipTimer extends Timer {\n async reset(): Promise {\n await compile.current();\n await actions.reset();\n }\n\n override finishFrame(): void {\n super.finishFrame();\n dispatch.current({ action: \"updateTestStep\" });\n }\n\n async tick(): Promise {\n return actions.stepTest();\n }\n\n toggle(): void {\n dispatch.current({ action: \"updateTestStep\" });\n }\n })();\n\n return () => {\n runner.current?.stop();\n };\n }, [compile, actions, dispatch]);\n\n const clockActions = useMemo(\n () => ({\n toggle() {\n actions.clock();\n tracking.trackEvent(\"action\", \"toggleClock\");\n },\n reset() {\n tracking.trackEvent(\"action\", \"resetClock\");\n actions.reset();\n },\n }),\n [actions]\n );\n\n const [useBuiltin, setUseBuiltin] = useState(false);\n const toggleUseBuiltin = () => {\n if (useBuiltin) {\n setUseBuiltin(false);\n actions.useBuiltin(false);\n } else {\n setUseBuiltin(true);\n actions.useBuiltin(true, hdl);\n }\n pinResetDispatcher.reset();\n };\n\n const selectors = (\n <>\n
\n {\n setProject(value as keyof typeof CHIP_PROJECTS);\n }}\n data-testid=\"project-picker\"\n >\n {PROJECT_NAMES.map(([number, label]) => (\n \n ))}\n \n {\n setChip(value);\n }}\n data-testid=\"chip-picker\"\n >\n {state.controls.chips.map((chip) => (\n \n {`${chip} ${isBuiltinOnly(chip) ? \"(given)\" : \"\"}`}\n \n ))}\n \n \n
\n \n );\n const hdlPanel = (\n \n
HDL
\n
\n {state.controls.hasBuiltin && !state.controls.builtinOnly && (\n \n )}\n
\n {selectors}\n \n }\n >\n {\n setHdl(source);\n compile.current(\n useBuiltin || state.controls.builtinOnly ? {} : { hdl: source }\n );\n }}\n grammar={HDL.parser}\n language={\"hdl\"}\n disabled={useBuiltin || state.controls.builtinOnly}\n />\n \n );\n\n const [inputValid, setInputValid] = useState(true);\n\n const chipButtons = (\n
\n \n Eval\n \n \n Clock:{\"\\u00a0\"}\n \n \n \n Reset\n \n
\n );\n\n const visualizations: [string, ReactNode][] = makeVisualizationsWithId(\n {\n parts: state.sim.chip,\n },\n () => {\n dispatch.current({ action: \"updateChip\" });\n }\n );\n\n const pinResetDispatcher = new PinResetDispatcher();\n\n const pinsPanel = (\n \n
\n Chip\n
\n {chipButtons}\n \n }\n >\n {state.sim.invalid ? (\n Syntax errors in the HDL code\n ) : (\n <>\n \n \n \n {visualizations.length > 0 && (\n Visualization} open={true}>\n
{visualizations.map(([_, v]) => v)}
\n
\n )}\n \n )}\n \n );\n\n const [selectedTestTab, doSetSelectedTestTab] = useState<\n \"tst\" | \"cmp\" | \"out\"\n >(\"tst\");\n\n const setSelectedTestTab = useCallback(\n (tab: typeof selectedTestTab) => {\n doSetSelectedTestTab(tab);\n tracking.trackEvent(\"tab\", \"change\", tab);\n },\n [tracking]\n );\n\n const testPanel = (\n \n
\n Test\n
\n
\n {runner.current && }\n
\n
\n \n
\n \n }\n >\n
\n \n \n
\n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n\n return (\n
\n {hdlPanel}\n {pinsPanel}\n {testPanel}\n
\n );\n};\n\nexport default Chip;\n"],"names":["ALUComponent","A","op","D","out","flag","_jsxs","children","_jsx","width","height","xmlns","x","y","fill","points","stroke","xmlSpace","textAnchor","fontFamily","fontSize","strokeWidth","id","COMMANDS_ALU","RegisterComponent","name","bits","dec","KeyMap","Enter","Backspace","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","Escape","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","Keyboard","keyboard","update","useState","enabled","setEnabled","character","setCharacter","busVoltage","setBits","currentKey","setKey","key","className","onClick","onKeyDown","event","preventDefault","keypress","mapping","undefined","length","code","charCodeAt","keyPressToHackCharacter","onKeyUp","clearKey","Sizes","none","sm","md","lg","xl","full","Sides","t","r","l","b","tl","tr","bl","br","Widths","isSide","v","getSize","size","getSide","side","rounded","sized","reduce","prev","curr","borderRadius","amount","block","display","die","error","args","msg","Error","map","s","join","isDraft","value","DRAFT_STATE","isDraftable","proto","Object","getPrototypeOf","Ctor","hasOwnProperty","call","constructor","Function","toString","objectCtorString","Array","isArray","DRAFTABLE","_value$constructor","isMap","isSet","each","obj","iter","enumerableOnly","getArchtype","keys","ownKeys","forEach","entry","index","thing","state","type_","has","prop","prototype","get","set","propOrOldValue","delete","add","is","target","hasMap","Map","hasSet","Set","latest","copy_","base_","shallowCopy","base","slice","descriptors","getOwnPropertyDescriptors","i","desc","writable","configurable","enumerable","create","freeze","deep","isFrozen","clear","dontMutateFrozenCollections","getPlugin","pluginKey","plugin","plugins","getCurrentScope","currentScope","usePatchesInScope","scope","patchListener","patches_","inversePatches_","patchListener_","revokeScope","leaveScope","drafts_","revokeDraft","parent_","enterScope","immer","immer_","canAutoFreeze_","unfinalizedDrafts_","draft","revoke_","revoked_","processResult","result","baseDraft","isReplaced","useProxies_","willFinalizeES5_","modified_","finalize","maybeFreeze","generateReplacementPatches_","NOTHING","rootScope","path","childValue","finalizeProperty","scope_","finalized_","draft_","generatePatches_","parentState","targetObject","rootPath","res","assigned_","concat","autoFreeze_","peek","getDescriptorFromProto","source","getOwnPropertyDescriptor","markChanged","prepareCopy","createProxy","parent","proxyMap_","proxySet_","isManual_","traps","objectTraps","arrayTraps","Proxy","revocable","revoke","proxy","createES5Proxy_","push","current","currentImpl","copy","archType","hasChanges_","copyHelper","from","hasSymbol","Symbol","hasProxies","Reflect","for","iterator","getOwnPropertySymbols","getOwnPropertyNames","_desc$get","currentState","deleteProperty","owner","defineProperty","setPrototypeOf","fn","arguments","apply","this","Immer","e","config","recipe","defaultBase","self","_this","produce","_this2","hasError","Promise","then","p","ip","produceWithPatches","patches","inversePatches","n","nextState","useProxies","setUseProxies","autoFreeze","setAutoFreeze","createDraft","finishDraft","applyPatches","patch","applyPatchesImpl","applyPatches_","bind","useImmerReducer","reducers","initialState","useReducer","command","action","payload","useStateInitializer","init","setState","useEffect","Mode","props","mode","setMode","setValue","view","style","cursor","doSelect","useCallback","ref","select","doChange","onChange","edit","position","zIndex","left","marginTop","onBlur","onKeyPress","type","defaultValue","render","doScroll","scrollTop","totalHeight","toleranceHeight","bufferedItems","settings","itemHeight","minIndex","maxIndex","Math","floor","data","offset","limit","start","max","min","getData","topPaddingHeight","bottomPaddingHeight","viewportRef","useRef","useMemo","Number","MAX_SAFE_INTEGER","startIndex","count","tolerance","fillVirtualScrollSettings","startState","adapter","viewportHeight","reducer","scrollReducer","dispatchScroll","row","initialScroll","div","rows","d","rowKey","overflowY","overflowAnchor","onScroll","useClockReset","reset","subscription","Clock","reset$","subscribe","unsubscribe","displayClock","Clockface","clockface","setClockface","$","useClockface","whiteSpace","MemoryBlock","memory","jmp","highlight","editable","format","range","MemoryCell","VirtualScroll","background","hex","flex","textAlign","InlineEdit","newValue","Memory","fmt","setFormat","setJmp","goto","setGoto","jumpTo","isNaN","parseInt","isFinite","doUpdate","role","placeholder","FORMATS","option","checked","bin","asm","doFormat","WHITE","mem","pixel","color","Screen","frameFinished","canvas","draw","ctx","getContext","image","assertExists","getImageData","col","putImageData","drawImage","ctxRef","frame$","clearRect","maxWidth","boxSizing","marginInline","margin","borderTop","borderLeft","borderBottom","borderRight","makeVisualization","chip","updateAction","ALU","in","voltage","HIGH","Flags","Register","PC","KeyboardComponent","ScreenComponent","RAM","MemoryComponent","address","RAM8","CPU","decode","am","vis","parts","filter","ChipDisplayInfo","chipName","unsigned","BUILTIN_REGISTRY","getBuiltinChip","isOk","pins","Ok","ins","entries","outs","pin","signBehaviors","includes","UNSIGNED_PINS","PinContext","createContext","reducePin","reverse","reducePins","FullPinout","sim","inPins","outPins","internalPins","displayInfo","PinoutBlock","header","toggle","setInputValid","disabled","pending","enableEdit","hideInternal","colSpan","immPin","Pin","signed","isSigned","internal","isBin","setIsBin","inputValid","decimal","setDecimal","resetDispatcher","useContext","PinResetDispatcher","registerCallback","setInputValidity","valid","updatePins","flexDirection","alignItems","backgroundColor","positive","replace","numeric","pow","handleDecimalChange","callback","callbacks","Runbar","runner","timer","dispatch","running","speed","steps","finishFrame","setSteps","setSpeed","actions","frame","stop","makeTimerStore","dispatcher","useTimer","label","PROJECT_NAMES","getChips","project","CHIP_ORDER","BUILTIN_CHIP_PROJECTS","CHIP_PROJECTS","makeHdl","isBuiltinOnly","values","flat","getBuiltinCode","template","ChipProjects","BUILTIN_CHIPS","CHIPS","getTemplate","bodyComment","builtinLine","reduceChip","invalid","clocked","clock","makeChipStore","fs","setStatus","storage","dropdowns","chips","findDropdowns","Low","test","ChipTest","usingBuiltin","builtinOnly","setFiles","hdl","files","tst","cmp","updateChip","controls","setProject","setChip","hasBuiltin","REGISTRY","testRunning","runningTest","testFinished","passed","trim","updateTestStep","log","currentStep","span","done","end","useBuiltin","loadChip","updateFiles","compileChip","compileTest","remove","maybeParsed","HDL","isErr","Err","buildChip","maybeChip","replaceChip","nextChip","nextPin","eval","with","fsName","ext","all","readFile","catch","saveChip","prj","writeFile","isLow","doUseBuiltin","oldHdl","builtinName","initialize","file","TST","setFileSystem","runTest","pushd","run","popd","tick","stepTest","assert","chipId","step","Timer","now","Date","delta","requestAnimationFrame","ErrorPanel","failed","open","message","shortMessage","UNKNOWN_PARSE_ERROR","Textarea","language","text","setText","Monaco","currentHighlight","theme","AppContext","monaco","useMonaco","editor","decorations","codeTheme","window","matchMedia","matches","doHighlight","model","getModel","getPositionAt","Range","fromPositions","nextDecoration","options","inlineClassName","revealRangeInCenter","deltaDecorations","makeHighlight","onMount","ed","updateOptions","minimap","scrollBeyondLastLine","readOnly","succeeded","setModelMarkers","exec","groups","line","column","startLineNumber","endLineNumber","startColumn","endColumn","getLineContent","substring","match","severity","Editor","grammar","setError","parse","parsed","doParse","ms","clearTimeout","setTimeout","debounce","onChangeCB","canUse","wants","Panel","footer","Accordian","summary","Chip","BaseContext","filePicker","tracking","useChipPageStore","setHdl","setTst","setCmp","trackPage","trackEvent","pinResetDispatcher","doEval","compile","loadTest","console","clockActions","setUseBuiltin","selectors","number","hdlPanel","tabIndex","chipButtons","visualizations","part","makeVisualizationsWithId","pinsPanel","Provider","selectedTestTab","doSetSelectedTestTab","setSelectedTestTab","tab","testPanel","CMP"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/263.58768126.chunk.js b/static/js/263.8f4582b5.chunk.js similarity index 91% rename from static/js/263.58768126.chunk.js rename to static/js/263.8f4582b5.chunk.js index 3b4cb2934..d8eedc4e5 100644 --- a/static/js/263.58768126.chunk.js +++ b/static/js/263.8f4582b5.chunk.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[263],{4263:function(e,t,n){n.r(t),n.d(t,{Chip:function(){return tn},default:function(){return nn}});var r=n(2951),i=n(1976),a=n(3243),o=n(7597),s=n(7591),c=n(4337),u=n(1092),l=n(7791),d=n(1026),f=n(8061),p=n(6167),h=n(649),v=n(7878),m=n(3300),g=n(3118),x=n(7039),b=n(3116),y=n(6329),j=n(6693),k=n(134),C=function(e){var t,n=e.A,r=e.op,i=e.D,a=e.out;e.flag;return(0,v.jsxs)("div",{children:[(0,v.jsx)("span",{children:"ALU"}),(0,v.jsx)("svg",{width:"250",height:"250",xmlns:"http://www.w3.org/2000/svg",children:(0,v.jsxs)("g",{children:[(0,v.jsx)("rect",{x:"1",y:"20",height:"85",width:"70",fill:"black"}),(0,v.jsx)("rect",{x:"1",y:"145",height:"85",width:"70",fill:"black"}),(0,v.jsx)("rect",{x:"180",y:"95",height:"60",width:"70",fill:"black"}),(0,v.jsx)("polygon",{points:"70,10 180,85 180,165 70,240 70,135 90,125 70,115",stroke:"#000",fill:"#6D97AB"}),(0,v.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:n}),(0,v.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,v.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:a}),(0,v.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:null!==(t=j.NM.op[r])&&void 0!==t?t:"(??)"})]})})]})},Z=n(326),w=function(e){var t=e.name,n=e.bits;return(0,v.jsxs)("div",{children:[t,": ",(0,Z.E_)(n)]})},P={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152};var S=function(e){var t=e.keyboard,n=e.update,r=(0,p.useState)(!1),i=(0,d.Z)(r,2),a=i[0],o=i[1],s=(0,p.useState)(""),c=(0,d.Z)(s,2),u=c[0],l=c[1],f=(0,p.useState)(t.out().busVoltage),h=(0,d.Z)(f,2),m=h[0],g=h[1],x=0,b=function(e){0!==e&&(t.setKey(e),g(t.out().busVoltage),x=e)};return(0,v.jsxs)("div",{className:"flex row align-baseline",children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(w,{name:"Keyboard",bits:m})}),(0,v.jsx)("div",{className:"flex-1",children:"Character: ".concat(u)}),(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsxs)("button",{onClick:function(){o(!a)},onKeyDown:function(e){if(e.preventDefault(),a){l(e.key);var t=function(e){var t=P[e.key];if(void 0!==t)return t;if(1===e.key.length){var n=e.key.charCodeAt(0);if(n>=32&&n<=126)return n}return 0}(e);t!==x&&(b(t),null===n||void 0===n||n())}},onKeyUp:function(e){a&&(x=0,t.clearKey(),null===n||void 0===n||n(),g(t.out().busVoltage),l(""))},children:[a?"Disable ":"Enable ","\u2328\ufe0f"]})})]})},F=n(189),N={none:"0px",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},I={"":"",t:"Top",r:"Right",l:"Left",b:"Bottom",tl:"TopLeft",tr:"TopRight",bl:"BottomLeft",br:"BottomRight"},O={"1/4":"25%","1/2":"50%","3/4":"75%",full:"100%"};function M(e){return void 0!==I[e]}function A(e){return N[e]}function E(e){switch(e){case"t":return[].concat((0,h.Z)(E("tl")),(0,h.Z)(E("tr")));case"r":return[].concat((0,h.Z)(E("tr")),(0,h.Z)(E("br")));case"b":return[].concat((0,h.Z)(E("br")),(0,h.Z)(E("bl")));case"l":return[].concat((0,h.Z)(E("tl")),(0,h.Z)(E("bl")));default:return[I[e]]}}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";M(e)&&(t=e,e="");var n=A(e);return E(t).reduce((function(e,t){return""===t?e.borderRadius=n:e["border".concat(t,"Radius")]=n,e}),{})}var R=n(5838),D=n(7693);function _(e,t){var n;return void 0===e&&void 0!==O[t]&&(e=t),(0,F.Z)((0,F.Z)({},"inline"===t?{display:"inline-block"}:{}),{},{width:null!==(n=O[e])&&void 0!==n?n:"0"})}function H(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r3?t.i-4:t.i:Array.isArray(e)?1:G(e)?2:$(e)?3:0}function V(e,t){return 2===L(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function W(e,t){return 2===L(e)?e.get(t):e[t]}function K(e,t,n){var r=L(e);2===r?e.set(t,n):3===r?(e.delete(t),e.add(n)):e[t]=n}function J(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function G(e){return ke&&e instanceof Map}function $(e){return Ce&&e instanceof Set}function q(e){return e.o||e.t}function X(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Ie(e);delete t[Se];for(var n=Ne(t),r=0;r1&&(e.set=e.add=e.clear=e.delete=Q),Object.freeze(e),t&&B(e,(function(e,t){return Y(t,!0)}),!0)),e}function Q(){H(2)}function ee(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function te(e){var t=Oe[e];return t||H(18,e),t}function ne(){return ye}function re(e,t){t&&(te("Patches"),e.u=[],e.s=[],e.v=t)}function ie(e){ae(e),e.p.forEach(se),e.p=null}function ae(e){e===ye&&(ye=e.l)}function oe(e){return ye={p:[],l:ye,h:e,m:!0,_:0}}function se(e){var t=e[Se];0===t.i||1===t.i?t.j():t.O=!0}function ce(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||te("ES5").S(t,e,r),r?(n[Se].P&&(ie(t),H(4)),U(e)&&(e=ue(t,e),t.l||de(t,e)),t.u&&te("Patches").M(n[Se].t,e,t.u,t.s)):e=ue(t,n,[]),ie(t),t.u&&t.v(t.u,t.s),e!==we?e:void 0}function ue(e,t,n){if(ee(t))return t;var r=t[Se];if(!r)return B(t,(function(i,a){return le(e,r,t,i,a,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return de(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=X(r.k):r.o;B(3===r.i?new Set(i):i,(function(t,a){return le(e,r,i,t,a,n)})),de(e,i,!1),n&&e.u&&te("Patches").R(r,n,e.u,e.s)}return r.o}function le(e,t,n,r,i,a){if(z(i)){var o=ue(e,i,a&&t&&3!==t.i&&!V(t.D,r)?a.concat(r):void 0);if(K(n,r,o),!z(o))return;e.m=!1}if(U(i)&&!ee(i)){if(!e.h.F&&e._<1)return;ue(e,i),t&&t.A.l||de(e,i)}}function de(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&Y(t,n)}function fe(e,t){var n=e[Se];return(n?q(n):e)[t]}function pe(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function he(e){e.P||(e.P=!0,e.l&&he(e.l))}function ve(e){e.o||(e.o=X(e.t))}function me(e,t,n){var r=G(t)?te("MapSet").N(t,n):$(t)?te("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:ne(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,a=Me;n&&(i=[r],a=Ae);var o=Proxy.revocable(i,a),s=o.revoke,c=o.proxy;return r.k=c,r.j=s,c}(t,n):te("ES5").J(t,n);return(n?n.A:ne()).p.push(r),r}function ge(e){return z(e)||H(22,e),function e(t){if(!U(t))return t;var n,r=t[Se],i=L(t);if(r){if(!r.P&&(r.i<4||!te("ES5").K(r)))return r.t;r.I=!0,n=xe(t,i),r.I=!1}else n=xe(t,i);return B(n,(function(t,i){r&&W(r.t,t)===i||K(n,t,e(i))})),3===i?new Set(n):n}(e)}function xe(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return X(e)}var be,ye,je="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),ke="undefined"!=typeof Map,Ce="undefined"!=typeof Set,Ze="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,we=je?Symbol.for("immer-nothing"):((be={})["immer-nothing"]=!0,be),Pe=je?Symbol.for("immer-draftable"):"__$immer_draftable",Se=je?Symbol.for("immer-state"):"__$immer_state",Fe=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),Ne="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Ie=Object.getOwnPropertyDescriptors||function(e){var t={};return Ne(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Oe={},Me={get:function(e,t){if(t===Se)return e;var n=q(e);if(!V(n,t))return function(e,t,n){var r,i=pe(t,n);return i?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!U(r)?r:r===fe(e.t,t)?(ve(e),e.o[t]=me(e.A.h,r,e)):r},has:function(e,t){return t in q(e)},ownKeys:function(e){return Reflect.ownKeys(q(e))},set:function(e,t,n){var r=pe(q(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=fe(q(e),t),a=null==i?void 0:i[Se];if(a&&a.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(J(n,i)&&(void 0!==n||V(e.t,t)))return!0;ve(e),he(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==fe(e.t,t)||t in e.t?(e.D[t]=!1,ve(e),he(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=q(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){H(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){H(12)}},Ae={};B(Me,(function(e,t){Ae[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ae.deleteProperty=function(e,t){return Ae.set.call(this,e,t,void 0)},Ae.set=function(e,t,n){return Me.set.call(this,e[0],t,n,e[0])};var Ee=function(){function e(e){var t=this;this.g=Ze,this.F=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var a=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,o=Array(r>1?r-1:0),s=1;s1?r-1:0),a=1;a=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=te("Patches").$;return z(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}(),Te=new Ee,Re=Te.produce,De=(Te.produceWithPatches.bind(Te),Te.setAutoFreeze.bind(Te),Te.setUseProxies.bind(Te),Te.applyPatches.bind(Te),Te.createDraft.bind(Te),Te.finishDraft.bind(Te),Re);function _e(e,t){return(0,p.useReducer)((function(t,n){return De(t,(function(t){e[n.action](t,n.payload)}))}),t)}function He(e){var t=(0,p.useState)(e),n=(0,d.Z)(t,2),r=n[0],i=n[1];return(0,p.useEffect)((function(){i(e)}),[e]),[r,i]}var ze=0,Ue=1,Be=function(e){var t,n=(0,p.useState)(null!==(t=e.mode)&&void 0!==t?t:ze),r=(0,d.Z)(n,2),i=r[0],a=r[1],o=He(e.value),s=(0,d.Z)(o,2),c=s[0],u=s[1],l=function(){return(0,v.jsx)("span",{style:(0,F.Z)({cursor:"text"},_("full","inline")),onClick:function(){a(Ue)},children:c})},f=(0,p.useCallback)((function(e){return null===e||void 0===e?void 0:e.select()}),[]),h=(0,p.useCallback)((function(t){var n,r;a(ze),u(null!==(n=t.value)&&void 0!==n?n:""),e.onChange(null!==(r=t.value)&&void 0!==r?r:"")}),[e,a,u]),m=function(){var e=(0,v.jsx)("span",{style:{display:"block",position:"relative"},children:(0,v.jsx)("input",{ref:f,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem"},onBlur:function(e){var t=e.target;return h(t)},onKeyPress:function(e){var t=e.key,n=e.target;"Enter"===t&&h(n)},type:"text",defaultValue:c})});return e};return function(){switch(i){case Ue:return m();case ze:return l();default:return(0,v.jsx)("span",{})}}()};function Le(e,t,n){var r=t.totalHeight,i=t.toleranceHeight,a=t.bufferedItems,o=t.settings,s=o.itemHeight,c=o.minIndex,u=o.maxIndex,l=c+Math.floor((e-i)/s),d=function(e,t,n,r,i){var a=Math.max(0,e,n),o=i(a,Math.min(t,n+r-1)-a);return(0,h.Z)(o)}(c,u,l,a,n),f=Math.max((l-c)*s,0);return{scrollTop:e,topPaddingHeight:f,bottomPaddingHeight:Math.max(r-(f+d.length*s),0),data:d}}var Ve=function(e){var t,n=(0,p.useRef)(null),r=(0,p.useMemo)((function(){var t,n=function(e){var t=e.minIndex,n=void 0===t?0:t,r=e.maxIndex,i=void 0===r?Number.MAX_SAFE_INTEGER:r,a=e.startIndex,o=void 0===a?0:a,s=e.itemHeight,c=void 0===s?20:s,u=e.count,l=void 0===u?Math.max(i-n,1):u,d=e.tolerance;return{minIndex:n,maxIndex:i,startIndex:o,itemHeight:c,count:l,tolerance:void 0===d?l:d}}(null!==(t=e.settings)&&void 0!==t?t:{}),r=function(e,t){var n=e.minIndex,r=e.maxIndex,i=e.startIndex,a=e.itemHeight,o=e.count,s=e.tolerance,c=o+2*s,u=o*a,l=(r-n)*a,d=s*a,f=Math.max(0,i-s-n)*a,p={scrollTop:0,settings:e,viewportHeight:u,totalHeight:l,toleranceHeight:d,bufferedItems:c,topPaddingHeight:f,bottomPaddingHeight:l-(f+(u+2*d)),data:[]};return(0,F.Z)((0,F.Z)({},p),Le(f+d,p,t))}(n,e.get),i=function(e){return function(t,n){return(0,F.Z)((0,F.Z)({},t),Le(n,t,e))}}(e.get);return{settings:n,reducer:i,startState:r}}),[e.settings,e.get]),i=r.settings,a=r.startState,o=r.reducer,s=(0,p.useReducer)(o,a),c=(0,d.Z)(s,2),u=c[0],l=c[1];(0,p.useEffect)((function(){null!==n.current&&l(n.current.scrollTop)}),[i,e.row]);var f=(0,p.useCallback)((function(e){e&&(e.scrollTop=n.current?n.current.scrollTop:i.startIndex*i.itemHeight),n.current=e}),[n,i.startIndex,i.itemHeight]),h=u.data.map((function(t){return(0,v.jsx)("div",{style:{height:"".concat(i.itemHeight,"px")},children:e.row(t)},e.rowKey(t))}));return(0,v.jsxs)("div",{ref:f,style:{height:"".concat(u.viewportHeight,"px"),overflowY:"scroll",overflowAnchor:"none"},className:null!==(t=e.className)&&void 0!==t?t:"",onScroll:function(e){return l(e.target.scrollTop)},children:[(0,v.jsx)("div",{style:{height:"".concat(u.topPaddingHeight,"px")}}),h,(0,v.jsx)("div",{style:{height:"".concat(u.bottomPaddingHeight,"px")}})]})},We=n(4408),Ke=n(6531);function Je(e){(0,p.useEffect)((function(){var t=Ke.S.get().reset$.subscribe((function(){e()}));return function(){return t.unsubscribe()}}),[e])}function Ge(){return(0,We.j)(Ke.S.get())}var $e=function(){var e=function(){var e=(0,p.useState)(Ge()),t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,p.useEffect)((function(){var e=Ke.S.get().$.subscribe((function(){r(Ge())}));return function(){return e.unsubscribe()}}),[]),n}();return(0,v.jsx)("span",{style:{whiteSpace:"nowrap"},children:e})},qe=function(e){var t=e.memory,n=e.jmp,r=void 0===n?{value:0}:n,i=e.highlight,a=void 0===i?-1:i,o=e.editable,s=void 0!==o&&o,c=e.format,u=void 0===c?Z.E_:c,l=e.onChange,f=void 0===l?function(){}:l,h=(0,p.useMemo)((function(){return{count:Math.min(t.size,20),maxIndex:t.size,itemHeight:34,startIndex:r.value}}),[t.size,r]),m=(0,p.useCallback)((function(e,n){return t.range(e,e+n).map((function(t,n){return[n+e,t]}))}),[t]),g=(0,p.useCallback)((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)(Xe,{index:n,value:u(r),editable:s,highlight:n===a,onChange:f})}),[u,s,a,f]);return(0,v.jsx)(Ve,{settings:h,get:m,row:g,rowKey:function(e){return(0,d.Z)(e,1)[0]}})},Xe=function(e){var t=e.index,n=e.value,r=e.highlight,i=void 0!==r&&r,a=e.editable,o=void 0!==a&&a,s=e.onChange,c=void 0===s?function(){}:s;return(0,v.jsxs)("div",{style:{display:"flex",height:"100%"},children:[(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:(0,Z.$v)(t)}),(0,v.jsx)("code",{style:(0,F.Z)((0,F.Z)({flex:"1",textAlign:"right"},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:o?(0,v.jsx)(Be,{value:n,onChange:function(e){return c(t,e,Number(n))}}):(0,v.jsx)("span",{children:n})})]})},Ye=function(e){var t=e.name,n=void 0===t?"Memory":t,r=e.highlight,i=void 0===r?-1:r,a=e.editable,o=void 0===a||a,s=e.memory,c=e.format,u=void 0===c?"dec":c,l=(0,p.useState)(u),f=(0,d.Z)(l,2),h=f[0],m=f[1],g=(0,p.useState)(""),x=(0,d.Z)(g,2),b=x[0],y=x[1],j=(0,p.useState)({value:0}),k=(0,d.Z)(j,2),C=k[0],w=k[1],P=function(){w({value:!isNaN(parseInt(b))&&isFinite(parseInt(b))?Number(b):0})},S=(0,p.useCallback)((function(e,t){s.update(e,t,null!==h&&void 0!==h?h:"dec")}),[s,h]);return Je((function(){y(""),w({value:0})})),(0,v.jsxs)("article",{className:"panel",children:[(0,v.jsxs)("header",{children:[(0,v.jsx)("div",{children:n}),(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:function(){},className:"flex-0",children:"\ud83d\udcc2"}),(0,v.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Goto",value:b,onKeyDown:function(e){return"Enter"===e.key&&P()},onChange:function(e){var t=e.target.value;return y(t)}}),(0,v.jsx)("button",{onClick:P,className:"flex-0",children:"\u2935\ufe0f"}),R.I2.map((function(e){return(0,v.jsxs)("label",{className:"flex-0",role:"button","aria-current":e===h,children:[(0,v.jsx)("input",{type:"radio",name:n,value:e,checked:e===h,onChange:function(){return m(e)}}),e]},e)}))]})]}),(0,v.jsx)(qe,{jmp:C,memory:s,highlight:i,editable:o,format:function(e){return function(e,t){switch(e){case"bin":return(0,Z.Ly)(t);case"hex":return(0,Z.$v)(t);case"asm":return(0,D.a)(t);default:return(0,Z.E_)(t)}}(h,e)},onChange:S})]})};var Qe=n(5541),et="white";function tt(e,t,n){return 0===(e.get(32*n+(t/16|0))&1<0?(0,v.jsx)(v.Fragment,{children:i}):void 0}var at=n(8582),ot=n(4649),st=n(726),ct=n(1585),ut=n(4625),lt=function(){function e(t,n){if((0,r.Z)(this,e),(0,ot.Z)(this,"signBehaviors",new Map),g.zZ.has(t)){var i=(0,g.cT)(t);if((0,ut.IY)(i)){var a,o=Array.from((0,ut.Ok)(i).ins.entries()).concat(Array.from((0,ut.Ok)(i).outs.entries())),s=(0,st.Z)(o);try{for(s.s();!(a=s.n()).done;){var c=a.value;this.signBehaviors.set(c.name,!n||!n.includes(c.name))}}catch(u){s.e(u)}finally{s.f()}}}}return(0,i.Z)(e,[{key:"isSigned",value:function(e){return this.signBehaviors.get(e)}}]),e}(),dt=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"]]]),ft=(0,p.createContext)({});function pt(e){return{pin:e,bits:(0,ct.w)(0,e.width).map((function(t){return[t,e.voltage(t)]})).reverse()}}function ht(e){return(0,h.Z)(e.entries()).map(pt)}var vt=function(e){var t,n,r=e.sim,i=r.inPins,a=r.outPins,o=r.internalPins,s=(n=null!==(t=e.sim.chip[0].name)&&void 0!==t?t:"",new lt(n,dt.get(n)));return(0,v.jsxs)(v.Fragment,{children:[(0,v.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,v.jsx)("table",{className:"pinout",children:(0,v.jsxs)("tbody",{children:[(0,v.jsx)(mt,{pins:i,header:"Input pins",toggle:e.toggle,setInputValid:e.setInputValid,displayInfo:s}),(0,v.jsx)(mt,{pins:a,header:"Output pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s}),!e.hideInternal&&(0,v.jsx)(mt,{pins:o,header:"Internal pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s})]})})]})},mt=function(e){return(0,v.jsxs)(v.Fragment,{children:[e.pins.length>0&&(0,v.jsx)("tr",{children:(0,v.jsx)("th",{colSpan:2,children:e.header})}),(0,h.Z)(e.pins).map((function(t){return(0,v.jsxs)("tr",{children:[(0,v.jsx)("td",{children:t.pin.name}),(0,v.jsx)("td",{children:(0,v.jsx)(gt,{pin:t,toggle:e.toggle,disabled:e.disabled,enableEdit:e.enableEdit,signed:e.displayInfo.isSigned(t.pin.name),setInputValid:e.setInputValid,internal:"Internal pins"===e.header})})]},t.pin.name)}))]})},gt=function(e){var t=e.pin,n=e.toggle,r=e.disabled,i=void 0!==r&&r,a=e.enableEdit,o=void 0===a||a,s=e.signed,c=void 0===s||s,u=e.setInputValid,l=e.internal,f=void 0!==l&&l,h=(0,p.useState)(!0),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=!0,y=(0,p.useState)(""),j=(0,d.Z)(y,2),k=j[0],C=j[1],Z=(0,p.useContext)(ft);Z instanceof xt&&Z.registerCallback((function(){x(!0)}));var w=function(e){b=e,null===u||void 0===u||u(e)},P=function(e){for(var r=0;r>r&1)&&(null===n||void 0===n||n(t.pin,r))};return(0,p.useEffect)((function(){if(!g&&b){var e=0;if(c&&t.bits[0][1]){var n,r=(0,st.Z)(t.bits);try{for(r.s();!(n=r.n()).done;){var i=(0,d.Z)(n.value,2),a=i[0],o=i[1];a=Math.pow(2,t.bits.length)||c&&(i>=Math.pow(2,t.bits.length-1)||i<-Math.pow(2,t.bits.length-1))?w(!1):(P(i),w(!0))}}(e.target.value)},disabled:!o})}),t.bits.length>1&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{style:{width:"1em"}}),(0,v.jsx)("button",{style:{maxWidth:"3em",margin:0},onClick:function(){x(!g)},children:g?"dec":"bin"})]})]})},xt=function(){function e(){(0,r.Z)(this,e),(0,ot.Z)(this,"callbacks",[])}return(0,i.Z)(e,[{key:"registerCallback",value:function(e){this.callbacks.push(e)}},{key:"reset",value:function(){var e,t=(0,st.Z)(this.callbacks);try{for(t.s();!(e=t.n()).done;){(0,e.value)()}}catch(n){t.e(n)}finally{t.f()}}}]),e}();var bt=function(e){var t=function(e){var t=(0,p.useRef)((function(){})),n=(0,p.useMemo)((function(){return function(e,t){var n={running:e.running,speed:e.speed,steps:e.steps},r=e.finishFrame.bind(e);return e.finishFrame=function(){r(),t.current({action:"update"})},{initialState:n,reducers:{update:function(t){t.running=e.running,t.speed=e.speed,t.steps=e.steps},setSteps:function(t,n){t.steps=n,e.steps=n},setSpeed:function(t,n){t.speed=n,e.speed=n}},actions:{frame:function(){e.frame()},start:function(){e.start(),t.current({action:"update"})},stop:function(){e.stop(),t.current({action:"update"})},reset:function(){e.reset(),t.current({action:"update"})}}}}(e,t)}),[e,t]),r=n.initialState,i=n.reducers,a=n.actions,o=_e(i,r),s=(0,d.Z)(o,2),c=s[0],u=s[1];return t.current=u,{state:c,dispatch:t.current,actions:a}}(e.runner);return(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.frame()},"data-tooltip":"Step","data-placement":"bottom",children:"\u27a1\ufe0f"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.state.running?t.actions.stop():t.actions.start()},"data-tooltip":t.state.running?"Pause":"Play","data-placement":"bottom",children:t.state.running?"\u23f8":"\ufe0f\u23e9"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.reset()},"data-tooltip":"Reset","data-placement":"bottom",children:"\u23ee"}),(0,v.jsx)("select",{className:"flex-1",name:"speed",value:t.state.speed,onChange:function(e){var n,r;t.dispatch({action:"setSpeed",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.speed)})},disabled:t.state.running,children:[[1e3,"Slow"],[500,"Fast"],[16,"Faster"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{className:"flex-1",name:"steps",value:t.state.steps,onChange:function(e){var n,r;t.dispatch({action:"setSteps",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.steps)})},disabled:t.state.running,children:[[1,"1 Step"],[500,"500"],[1e3,"1000"],[2e3,"2000"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),e.children]})},yt=n(8698),jt=n(691),kt=n(8090),Ct=n(9647),Zt=n(7662),wt=n(3389),Pt=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function St(e){return e in Zt.CHIP_ORDER?Zt.CHIP_ORDER[e]:Zt.BUILTIN_CHIP_PROJECTS[e].concat(Zt.CHIP_PROJECTS[e])}function Ft(e){return"CHIP ".concat(e," {\n IN in;\n OUT out;\n PARTS:\n}")}function Nt(e){return Object.values(Zt.BUILTIN_CHIP_PROJECTS).flat().includes(e)}function It(e,t){var n=function(e,t){return Nt(t)?Zt.ChipProjects[e].BUILTIN_CHIPS[t]:Zt.ChipProjects[e].CHIPS[t]["".concat(t,".hdl")]}(e,t);if(Nt(t))return n;var r="//// Replace this comment with your code.",i="BUILTIN ".concat(t,";");return n.includes(r)?n.replace(r,i):n.replace("PARTS:","PARTS:\n ".concat(i))}function Ot(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:e.clocked,inPins:ht(e.ins),outPins:ht(e.outs),internalPins:ht(e.pins),chip:[e],pending:t,invalid:n}}var Mt=Ke.S.get();function At(e,t,n,r){var i=function(e){var t,n,r=null!==(t=e["/chip/project"])&&void 0!==t?t:"01";return{project:r,chips:St(r),chipName:null!==(n=e["/chip/chip"])&&void 0!==n?n:Zt.CHIP_PROJECTS[r][0]}}(n),a=i.project,o=i.chipName,s=i.chips,c=new y.P9,f=new wt.l1,p=!1,v=!1,m={setFiles:function(e,t){var n=t.hdl,r=void 0===n?e.files.hdl:n,i=t.tst,a=void 0===i?e.files.tst:i,o=t.cmp,s=void 0===o?e.files.cmp:o,c=t.out,u=void 0===c?"":c;e.files.hdl=r,e.files.tst=a,e.files.cmp=s,e.files.out=u},updateChip:function(e,t){var n,r,i,a,s,u;e.sim=Ot(c,null!==(n=null===t||void 0===t?void 0:t.pending)&&void 0!==n?n:e.sim.pending,null!==(r=null===t||void 0===t?void 0:t.invalid)&&void 0!==r?r:e.sim.invalid),e.controls.error=e.sim.invalid?null!==(i=null===t||void 0===t?void 0:t.error)&&void 0!==i?i:e.controls.error:"",e.controls.chips=St(e.controls.project),e.controls.chipName=e.sim.invalid?null!==(a=null===t||void 0===t?void 0:t.chipName)&&void 0!==a?a:o:null!==(s=null!==(u=c.name)&&void 0!==u?u:null===t||void 0===t?void 0:t.chipName)&&void 0!==s?s:o,e.controls.chips.includes(e.controls.chipName)||(e.controls.chips=[].concat((0,h.Z)(e.controls.chips),[e.controls.chipName]))},setProject:function(e,t){var n=St(t),r=e.controls.chipName&&n.includes(e.controls.chipName)?e.controls.chipName:n[0];e.controls.project=t,e.controls.chips=n,this.setChip(e,r)},setChip:function(e,t){e.controls.chipName=t,e.controls.hasBuiltin=g.zZ.has(t),e.controls.builtinOnly=Nt(t)},testRunning:function(e){e.controls.runningTest=!0},testFinished:function(e){e.controls.runningTest=!1;var n=e.files.out.trim()===e.files.cmp.trim();t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep:function(e){var t,n,r,i;if(e.files.out=null!==(t=null===(n=f)||void 0===n?void 0:n.log())&&void 0!==t?t:"",null!==(r=f)&&void 0!==r&&null!==(i=r.currentStep)&&void 0!==i&&i.span)e.controls.span=f.currentStep.span;else if(f.done){var a=e.files.tst.length;e.controls.span={start:a-1,end:a}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})}},x={setProject:function(e){a=n["/chip/project"]=e,r.current({action:"setProject",payload:a}),this.setChip(Zt.CHIP_PROJECTS[a][0])},setChip:function(e){var t=arguments,i=this;return(0,l.Z)((0,u.Z)().mark((function a(){var s,c;return(0,u.Z)().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(c=t.length>1&&void 0!==t[1]?t[1]:null!==(s=n["/chip/project"])&&void 0!==s?s:"01",o=n["/chip/chip"]=e,r.current({action:"setChip",payload:o}),!(v=Nt(o))){a.next=8;break}return r.current({action:"setFiles",payload:{hdl:"",tst:"",cmp:""}}),i.useBuiltin(),a.abrupt("return");case 8:return a.next=10,i.loadChip(c,o);case 10:p&&i.useBuiltin();case 11:case"end":return a.stop()}}),a)})))()},reset:function(){Ke.S.get().reset(),c.reset(),f.reset(),r.current({action:"setFiles",payload:{}}),r.current({action:"updateChip"})},updateFiles:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var a,o,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=e.hdl,o=e.tst,s=e.cmp,r.current({action:"setFiles",payload:{hdl:a,tst:o,cmp:s}}),i.prev=2,!a){i.next=6;break}return i.next=6,n.compileChip(a);case 6:o&&n.compileTest(o),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),t((0,We.j)(i.t0));case 12:case"end":return i.stop()}}),i,null,[[2,9]])})))()},compileChip:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var a,o,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(c.remove(),a=kt.Gq.parse(e),!(0,ut.dZ)(a)){i.next=6;break}return t("Failed to parse chip"),r.current({action:"updateChip",payload:{invalid:!0,error:(0,We.j)((0,ut.UG)(a))}}),i.abrupt("return");case 6:return i.next=8,(0,jt.J_)((0,ut.Ok)(a));case 8:if(o=i.sent,!(0,ut.dZ)(o)){i.next=14;break}return s=(0,We.j)((0,ut.UG)(o)),t(s),r.current({action:"updateChip",payload:{invalid:!0,error:s}}),i.abrupt("return");case 14:t("Compiled ".concat(c.name)),n.replaceChip((0,ut.Ok)(o));case 16:case"end":return i.stop()}}),i)})))()},replaceChip:function(e){var t,n=c.ins,i=(0,st.Z)(n);try{for(i.s();!(t=i.n()).done;){var a=(0,d.Z)(t.value,2),o=a[0],s=a[1].busVoltage,u=e.ins.get(o);u&&(u.busVoltage=s)}}catch(l){i.e(l)}finally{i.f()}Mt.reset(),e.eval(),(c=e).reset(),f=f.with(c).reset(),r.current({action:"updateChip",payload:{invalid:!1}}),r.current({action:"updateTestStep"})},loadChip:function(t,i){var a=this;return(0,l.Z)((0,u.Z)().mark((function o(){var s,c,l,f,p,h;return(0,u.Z)().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return n["/chip/chip"]=i,s=function(e){return"/projects/".concat(t,"/").concat(i,"/").concat(i,".").concat(e)},o.next=4,Promise.all([e.readFile(s("hdl")).catch((function(){return Ft(i)})),e.readFile(s("tst")).catch((function(e){return"repeat 10 {\n tick,\n tock;\n}"})),e.readFile(s("cmp")).catch((function(){return"| in|out|"}))]);case 4:return c=o.sent,l=(0,d.Z)(c,3),f=l[0],p=l[1],h=l[2],r.current({action:"setFiles",payload:{hdl:f,tst:p,cmp:h}}),o.next=12,a.compileChip(f);case 12:a.compileTest(p);case 13:case"end":return o.stop()}}),o)})))()},saveChip:function(n){var i=arguments;return(0,l.Z)((0,u.Z)().mark((function s(){var c,l,d;return(0,u.Z)().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return c=i.length>1&&void 0!==i[1]?i[1]:a,l=i.length>2&&void 0!==i[2]?i[2]:o,r.current({action:"setFiles",payload:{hdl:n}}),d="/projects/".concat(c,"/").concat(l,"/").concat(l,".hdl"),s.next=6,e.writeFile(d,n);case 6:t("Saved ".concat(d));case 7:case"end":return s.stop()}}),s)})))()},toggle:function(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<0&&void 0!==e[0])||e[0],c=e.length>1?e[1]:void 0,s){i.next=7;break}return v||(p=!1),i.next=6,n.loadChip(a,o);case 6:return i.abrupt("return");case 7:if(v||(p=!0),l=o,d=(0,g.cT)(l),!(0,ut.dZ)(d)){i.next=13;break}return t("Failed to load builtin ".concat(l,": ").concat((0,We.j)((0,ut.UG)(d)))),i.abrupt("return");case 13:if(!c){i.next=16;break}return i.next=16,n.saveChip(c,a,o);case 16:f=It(a,l),r.current({action:"setFiles",payload:{hdl:f}}),n.replaceChip((0,ut.Ok)(d));case 19:case"end":return i.stop()}}),i)})))()},initialize:function(){var e=this;return(0,l.Z)((0,u.Z)().mark((function t(){return(0,u.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.setChip(o,a);case 2:case"end":return t.stop()}}),t)})))()},compileTest:function(n){r.current({action:"setFiles",payload:{tst:n}});var i=Ct.qH.parse(n);return(0,ut.dZ)(i)?(t("Failed to parse test"),!1):(t("Parsed tst"),(f=wt.l1.from((0,ut.Ok)(i)).with(c).reset()).setFileSystem(e),r.current({action:"updateTestStep"}),!0)},runTest:function(t){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n.compileTest(t)){i.next=2;break}return i.abrupt("return");case 2:return r.current({action:"testRunning"}),e.pushd("/samples"),i.next=6,f.run();case 6:e.popd(),r.current({action:"updateTestStep"}),r.current({action:"testFinished"});case 9:case"end":return i.stop()}}),i)})))()},tick:function(){return this.stepTest()},stepTest:function(){return(0,l.Z)((0,u.Z)().mark((function e(){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(0,Qe.hu)(f.chipId===c.id,"Test and chip out of sync"),e.next=3,f.step();case 3:return t=e.sent,r.current({action:"updateTestStep"}),t&&r.current({action:"testFinished"}),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))()}};return{initialState:function(){var e={project:a,chips:s,chipName:o,hasBuiltin:g.zZ.has(o),builtinOnly:Nt(o),runningTest:!1,error:""},n=(0,g.cT)(e.chipName);return(0,ut.dZ)(n)?(t((0,We.j)((0,ut.UG)(n))),c=new y.P9):c=(0,ut.Ok)(n),{controls:e,files:{hdl:"",cmp:"",tst:"",out:""},sim:Ot(c)}}(),reducers:m,actions:x}}var Et=n(8365),Tt=n(7538),Rt=n(2648),Dt=n(3943),_t=Ke.S.get(),Ht=new WeakMap,zt=new WeakMap,Ut=new WeakMap,Bt=new WeakMap,Lt=function(){function e(){var t=this;(0,r.Z)(this,e),(0,ot.Z)(this,"steps",1),(0,ot.Z)(this,"speed",1e3),(0,Tt.Z)(this,Ht,{writable:!0,value:!1}),(0,Tt.Z)(this,zt,{writable:!0,value:0}),(0,Tt.Z)(this,Ut,{writable:!0,value:0}),(0,Tt.Z)(this,Bt,{writable:!0,value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){var n,r,i,a;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((0,Dt.Z)(t,Ht)){e.next=2;break}return e.abrupt("return");case 2:if(n=Date.now(),r=n-(0,Dt.Z)(t,Ut),(0,Rt.Z)(t,Ut,n),(0,Rt.Z)(t,zt,(0,Dt.Z)(t,zt)+r),!((0,Dt.Z)(t,zt)>t.speed)){e.next=19;break}i=!1,a=0;case 9:if(!(a0&&void 0!==arguments[0]?arguments[0]:"";return n(e)},language:r,onMount:g})})},Yt=function(e){var t=e.className,n=void 0===t?"":t,r=e.style,i=void 0===r?{}:r,a=e.disabled,o=void 0!==a&&a,s=e.value,c=e.onChange,u=e.grammar,l=e.language,f=e.highlight,h=(0,p.useState)(),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=(0,p.useContext)(Vt.Il).monaco,y=(0,p.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=u.match(e);x(t.failed()?t:void 0)}),[x,u]);(0,p.useEffect)((function(){return y(s)}),[y,s]);var j=(0,p.useMemo)((function(){return function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;return function(){for(var r=arguments.length,i=new Array(r),a=0;a0&&void 0!==arguments[0]?arguments[0]:"";c(e),j(e)}),[j,c]);return(0,v.jsx)("div",{className:"Editor ".concat(n),style:i,children:b.canUse&&b.wants?(0,v.jsx)(Xt,{value:s,onChange:k,language:l,error:g,disabled:o,highlight:f}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(qt,{value:s,onChange:k,language:l,disabled:o}),(0,v.jsx)($t,{error:g})]})})},Qt=function(e){var t;return(0,v.jsxs)("article",{className:["panel",null!==(t=e.className)&&void 0!==t?t:""].join(" "),children:[e.header&&(0,v.jsx)("header",{children:e.header}),(0,v.jsx)("main",{children:e.children}),e.footer&&(0,v.jsx)("footer",{children:e.footer})]})},en=function(e){var t;return(0,v.jsxs)("details",{className:null!==(t=e.className)&&void 0!==t?t:"",open:e.open,style:e.style,children:[(0,v.jsx)("summary",{children:(0,v.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})},tn=function(){var e=(0,p.useContext)(yt.r),t=e.fs,n=e.setStatus,m=(0,p.useContext)(Vt.Il),g=m.filePicker,x=m.tracking,b=function(){var e=(0,p.useContext)(yt.r),t=e.fs,n=e.setStatus,r=e.storage,i=(0,p.useRef)((function(){})),a=(0,p.useMemo)((function(){return At(t,n,r,i)}),[t,n,r,i]),o=a.initialState,s=a.reducers,c=a.actions,u=_e(s,o),l=(0,d.Z)(u,2),f=l[0],h=l[1];return i.current=h,{state:f,dispatch:i,actions:c}}(),y=b.state,j=b.actions,k=b.dispatch,C=He(y.files.hdl),Z=(0,d.Z)(C,2),w=Z[0],P=Z[1],S=He(y.files.tst),F=(0,d.Z)(S,2),N=F[0],I=F[1],O=He(y.files.cmp),M=(0,d.Z)(O,2),A=M[0],E=M[1],T=He(y.files.out),R=(0,d.Z)(T,1)[0];(0,p.useEffect)((function(){j.initialize()}),[j]),(0,p.useEffect)((function(){x.trackPage("/chip")}),[x]);(0,p.useEffect)((function(){x.trackEvent("action","setProject",y.controls.project),x.trackEvent("action","setChip",y.controls.chipName)}),[]);var D=(0,p.useCallback)((function(e){j.setProject(e),x.trackEvent("action","setProject",e)}),[j,x]),_=(0,p.useCallback)((function(e){j.setChip(e),x.trackEvent("action","setChip",e),ne.reset()}),[j,x]),H=(0,p.useCallback)((function(){j.eval(),x.trackEvent("action","eval")}),[j,x]),z=(0,p.useRef)((function(){}));z.current=(0,l.Z)((0,u.Z)().mark((function e(){var t,n,r,i=arguments;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:{},e.next=3,j.updateFiles({hdl:r.hdl,tst:null!==(t=r.tst)&&void 0!==t?t:N,cmp:null!==(n=r.cmp)&&void 0!==n?n:A});case 3:case"end":return e.stop()}}),e)})));var U=(0,p.useCallback)((0,l.Z)((0,u.Z)().mark((function e(){var r,i;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g.select();case 3:return r=e.sent,e.next=6,t.readFile(r);case 6:return i=e.sent,e.next=9,z.current({tst:i});case 9:e.next=15;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0),n("Failed to load into memory");case 15:case"end":return e.stop()}}),e,null,[[0,11]])}))),[g,n,t,z]),B=(0,p.useRef)();(0,p.useEffect)((function(){return B.current=new(function(e){(0,s.Z)(n,e);var t=(0,c.Z)(n);function n(){return(0,r.Z)(this,n),t.apply(this,arguments)}return(0,i.Z)(n,[{key:"reset",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z.current();case 2:return e.next=4,j.reset();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"finishFrame",value:function(){(0,a.Z)((0,o.Z)(n.prototype),"finishFrame",this).call(this),k.current({action:"updateTestStep"})}},{key:"tick",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",j.stepTest());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"toggle",value:function(){k.current({action:"updateTestStep"})}}]),n}(Lt)),function(){var e;null===(e=B.current)||void 0===e||e.stop()}}),[z,j,k]);var L=(0,p.useMemo)((function(){return{toggle:function(){j.clock(),x.trackEvent("action","toggleClock")},reset:function(){x.trackEvent("action","resetClock"),j.reset()}}}),[j]),V=(0,p.useState)(!1),W=(0,d.Z)(V,2),K=W[0],J=W[1],G=(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("select",{value:y.controls.project,onChange:function(e){var t=e.target.value;D(t)},"data-testid":"project-picker",children:Pt.map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{value:y.controls.chipName,onChange:function(e){var t=e.target.value;_(t)},"data-testid":"chip-picker",children:y.controls.chips.map((function(e){return(0,v.jsx)("option",{value:e,style:Nt(e)?{color:"rgb(170, 170, 170)"}:{},children:"".concat(e," ").concat(Nt(e)?"(given)":"")},e)}))}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){j.saveChip(w)},disabled:K,children:(0,v.jsx)(f.cC,{id:"Save"})})]})}),$=(0,v.jsx)(Qt,{className:"_hdl_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{tabIndex:0,children:"HDL"}),(0,v.jsx)("fieldset",{children:y.controls.hasBuiltin&&!y.controls.builtinOnly&&(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"checkbox",role:"switch",checked:K,onChange:function(){K?(J(!1),j.useBuiltin(!1)):(J(!0),j.useBuiltin(!0,w)),ne.reset()}}),(0,v.jsx)(f.cC,{id:"Builtin"})]})}),G]}),children:(0,v.jsx)(Yt,{className:"flex-1",value:w,onChange:function(e){P(e),z.current(K||y.controls.builtinOnly?{}:{hdl:e})},grammar:kt.Gq.parser,language:"hdl",disabled:K||y.controls.builtinOnly})}),q=(0,p.useState)(!0),X=(0,d.Z)(q,2),Y=X[0],Q=X[1],ee=(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:H,onKeyDown:H,disabled:!y.sim.pending||!Y,children:(0,v.jsx)(f.cC,{id:"Eval"})}),(0,v.jsxs)("button",{onClick:L.toggle,style:{maxWidth:"initial"},disabled:!y.sim.clocked,children:[(0,v.jsx)(f.cC,{id:"Clock"}),":","\xa0",(0,v.jsx)($e,{})]}),(0,v.jsx)("button",{onClick:L.reset,style:{maxWidth:"initial"},disabled:!y.sim.clocked,children:(0,v.jsx)(f.cC,{id:"Reset"})})]}),te=function(e,t){return(0,h.Z)(e.parts).map((function(e,n){return["".concat(e.id,"_").concat(n),it(e,t)]})).filter((function(e){var t=(0,d.Z)(e,2);return t[0],void 0!==t[1]}))}({parts:y.sim.chip},(function(){k.current({action:"updateChip"})})),ne=new xt,re=(0,v.jsx)(Qt,{className:"_parts_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{children:(0,v.jsx)(f.cC,{id:"Chip"})}),ee]}),children:y.sim.invalid?(0,v.jsx)(f.cC,{id:"Syntax errors in the HDL code"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ft.Provider,{value:ne,children:(0,v.jsx)(vt,{sim:y.sim,toggle:j.toggle,setInputValid:Q,hideInternal:y.controls.builtinOnly})}),te.length>0&&(0,v.jsx)(en,{summary:(0,v.jsx)(f.cC,{id:"Visualization"}),open:!0,children:(0,v.jsx)("main",{children:te.map((function(e){var t=(0,d.Z)(e,2);t[0];return t[1]}))})})]})}),ie=(0,p.useState)("tst"),ae=(0,d.Z)(ie,2),oe=ae[0],se=ae[1],ce=(0,p.useCallback)((function(e){se(e),x.trackEvent("tab","change",e)}),[x]),ue=(0,v.jsx)(Qt,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(f.cC,{id:"Test"})}),(0,v.jsx)("div",{className:"flex-2",children:B.current&&(0,v.jsx)(bt,{runner:B.current})}),(0,v.jsx)("div",{children:(0,v.jsxs)("button",{onClick:U,children:[(0,v.jsx)(Wt.J,{name:"upload_file"})," "]})})]}),children:(0,v.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,v.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===oe,onChange:function(){return ce("tst")}}),"Test Script"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,v.jsx)(Yt,{value:N,onChange:I,grammar:Ct.qH.parser,language:"tst",highlight:y.controls.span,disabled:y.controls.builtinOnly})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===oe,onChange:function(){return ce("cmp")}}),"Compare File"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,v.jsx)(Yt,{value:A,onChange:E,grammar:Et.lA.parser,language:"cmp",disabled:y.controls.builtinOnly})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===oe,onChange:function(){return ce("out")}}),"Output File"]})}),(0,v.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,v.jsx)(at.M,{cmp:A,out:R})})]})});return(0,v.jsxs)("div",{className:"ChipPage grid",children:[$,re,ue]})},nn=tn}}]); -//# sourceMappingURL=263.58768126.chunk.js.map \ No newline at end of file +"use strict";(self.webpackChunk_nand2tetris_web=self.webpackChunk_nand2tetris_web||[]).push([[263],{4263:function(e,t,n){n.r(t),n.d(t,{Chip:function(){return tn},default:function(){return nn}});var r=n(2951),i=n(1976),a=n(3243),o=n(7597),s=n(7591),c=n(4337),u=n(1092),l=n(7791),d=n(1026),f=n(8061),p=n(6167),h=n(649),v=n(7878),m=n(3300),g=n(3118),x=n(7039),b=n(3116),y=n(6329),j=n(6693),k=n(134),C=function(e){var t,n=e.A,r=e.op,i=e.D,a=e.out;e.flag;return(0,v.jsxs)("div",{children:[(0,v.jsx)("span",{children:"ALU"}),(0,v.jsx)("svg",{width:"250",height:"250",xmlns:"http://www.w3.org/2000/svg",children:(0,v.jsxs)("g",{children:[(0,v.jsx)("rect",{x:"1",y:"20",height:"85",width:"70",fill:"black"}),(0,v.jsx)("rect",{x:"1",y:"145",height:"85",width:"70",fill:"black"}),(0,v.jsx)("rect",{x:"180",y:"95",height:"60",width:"70",fill:"black"}),(0,v.jsx)("polygon",{points:"70,10 180,85 180,165 70,240 70,135 90,125 70,115",stroke:"#000",fill:"#6D97AB"}),(0,v.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:n}),(0,v.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,v.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:a}),(0,v.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:null!==(t=j.NM.op[r])&&void 0!==t?t:"(??)"})]})})]})},Z=n(326),w=function(e){var t=e.name,n=e.bits;return(0,v.jsxs)("div",{children:[t,": ",(0,Z.E_)(n)]})},P={Enter:128,Backspace:129,ArrowLeft:130,ArrowUp:131,ArrowRight:132,ArrowDown:133,Home:134,End:135,PageUp:136,PageDown:137,Insert:138,Delete:139,Escape:140,F1:141,F2:142,F3:143,F4:144,F5:145,F6:146,F7:147,F8:148,F9:149,F10:150,F11:151,F12:152};var S=function(e){var t=e.keyboard,n=e.update,r=(0,p.useState)(!1),i=(0,d.Z)(r,2),a=i[0],o=i[1],s=(0,p.useState)(""),c=(0,d.Z)(s,2),u=c[0],l=c[1],f=(0,p.useState)(t.out().busVoltage),h=(0,d.Z)(f,2),m=h[0],g=h[1],x=0,b=function(e){0!==e&&(t.setKey(e),g(t.out().busVoltage),x=e)};return(0,v.jsxs)("div",{className:"flex row align-baseline",children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(w,{name:"Keyboard",bits:m})}),(0,v.jsx)("div",{className:"flex-1",children:"Character: ".concat(u)}),(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsxs)("button",{onClick:function(){o(!a)},onKeyDown:function(e){if(e.preventDefault(),a){l(e.key);var t=function(e){var t=P[e.key];if(void 0!==t)return t;if(1===e.key.length){var n=e.key.charCodeAt(0);if(n>=32&&n<=126)return n}return 0}(e);t!==x&&(b(t),null===n||void 0===n||n())}},onKeyUp:function(e){a&&(x=0,t.clearKey(),null===n||void 0===n||n(),g(t.out().busVoltage),l(""))},children:[a?"Disable ":"Enable ","\u2328\ufe0f"]})})]})},N=n(189),F={none:"0px",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},I={"":"",t:"Top",r:"Right",l:"Left",b:"Bottom",tl:"TopLeft",tr:"TopRight",bl:"BottomLeft",br:"BottomRight"},O={"1/4":"25%","1/2":"50%","3/4":"75%",full:"100%"};function M(e){return void 0!==I[e]}function A(e){return F[e]}function E(e){switch(e){case"t":return[].concat((0,h.Z)(E("tl")),(0,h.Z)(E("tr")));case"r":return[].concat((0,h.Z)(E("tr")),(0,h.Z)(E("br")));case"b":return[].concat((0,h.Z)(E("br")),(0,h.Z)(E("bl")));case"l":return[].concat((0,h.Z)(E("tl")),(0,h.Z)(E("bl")));default:return[I[e]]}}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";M(e)&&(t=e,e="");var n=A(e);return E(t).reduce((function(e,t){return""===t?e.borderRadius=n:e["border".concat(t,"Radius")]=n,e}),{})}var R=n(5838),D=n(7693);function _(e,t){var n;return void 0===e&&void 0!==O[t]&&(e=t),(0,N.Z)((0,N.Z)({},"inline"===t?{display:"inline-block"}:{}),{},{width:null!==(n=O[e])&&void 0!==n?n:"0"})}function H(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r3?t.i-4:t.i:Array.isArray(e)?1:G(e)?2:$(e)?3:0}function V(e,t){return 2===L(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function W(e,t){return 2===L(e)?e.get(t):e[t]}function K(e,t,n){var r=L(e);2===r?e.set(t,n):3===r?(e.delete(t),e.add(n)):e[t]=n}function J(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function G(e){return ke&&e instanceof Map}function $(e){return Ce&&e instanceof Set}function q(e){return e.o||e.t}function X(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Ie(e);delete t[Se];for(var n=Fe(t),r=0;r1&&(e.set=e.add=e.clear=e.delete=Q),Object.freeze(e),t&&B(e,(function(e,t){return Y(t,!0)}),!0)),e}function Q(){H(2)}function ee(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function te(e){var t=Oe[e];return t||H(18,e),t}function ne(){return ye}function re(e,t){t&&(te("Patches"),e.u=[],e.s=[],e.v=t)}function ie(e){ae(e),e.p.forEach(se),e.p=null}function ae(e){e===ye&&(ye=e.l)}function oe(e){return ye={p:[],l:ye,h:e,m:!0,_:0}}function se(e){var t=e[Se];0===t.i||1===t.i?t.j():t.O=!0}function ce(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||te("ES5").S(t,e,r),r?(n[Se].P&&(ie(t),H(4)),U(e)&&(e=ue(t,e),t.l||de(t,e)),t.u&&te("Patches").M(n[Se].t,e,t.u,t.s)):e=ue(t,n,[]),ie(t),t.u&&t.v(t.u,t.s),e!==we?e:void 0}function ue(e,t,n){if(ee(t))return t;var r=t[Se];if(!r)return B(t,(function(i,a){return le(e,r,t,i,a,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return de(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=X(r.k):r.o;B(3===r.i?new Set(i):i,(function(t,a){return le(e,r,i,t,a,n)})),de(e,i,!1),n&&e.u&&te("Patches").R(r,n,e.u,e.s)}return r.o}function le(e,t,n,r,i,a){if(z(i)){var o=ue(e,i,a&&t&&3!==t.i&&!V(t.D,r)?a.concat(r):void 0);if(K(n,r,o),!z(o))return;e.m=!1}if(U(i)&&!ee(i)){if(!e.h.F&&e._<1)return;ue(e,i),t&&t.A.l||de(e,i)}}function de(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&Y(t,n)}function fe(e,t){var n=e[Se];return(n?q(n):e)[t]}function pe(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function he(e){e.P||(e.P=!0,e.l&&he(e.l))}function ve(e){e.o||(e.o=X(e.t))}function me(e,t,n){var r=G(t)?te("MapSet").N(t,n):$(t)?te("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:ne(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,a=Me;n&&(i=[r],a=Ae);var o=Proxy.revocable(i,a),s=o.revoke,c=o.proxy;return r.k=c,r.j=s,c}(t,n):te("ES5").J(t,n);return(n?n.A:ne()).p.push(r),r}function ge(e){return z(e)||H(22,e),function e(t){if(!U(t))return t;var n,r=t[Se],i=L(t);if(r){if(!r.P&&(r.i<4||!te("ES5").K(r)))return r.t;r.I=!0,n=xe(t,i),r.I=!1}else n=xe(t,i);return B(n,(function(t,i){r&&W(r.t,t)===i||K(n,t,e(i))})),3===i?new Set(n):n}(e)}function xe(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return X(e)}var be,ye,je="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),ke="undefined"!=typeof Map,Ce="undefined"!=typeof Set,Ze="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,we=je?Symbol.for("immer-nothing"):((be={})["immer-nothing"]=!0,be),Pe=je?Symbol.for("immer-draftable"):"__$immer_draftable",Se=je?Symbol.for("immer-state"):"__$immer_state",Ne=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),Fe="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Ie=Object.getOwnPropertyDescriptors||function(e){var t={};return Fe(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Oe={},Me={get:function(e,t){if(t===Se)return e;var n=q(e);if(!V(n,t))return function(e,t,n){var r,i=pe(t,n);return i?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!U(r)?r:r===fe(e.t,t)?(ve(e),e.o[t]=me(e.A.h,r,e)):r},has:function(e,t){return t in q(e)},ownKeys:function(e){return Reflect.ownKeys(q(e))},set:function(e,t,n){var r=pe(q(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=fe(q(e),t),a=null==i?void 0:i[Se];if(a&&a.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(J(n,i)&&(void 0!==n||V(e.t,t)))return!0;ve(e),he(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==fe(e.t,t)||t in e.t?(e.D[t]=!1,ve(e),he(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=q(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){H(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){H(12)}},Ae={};B(Me,(function(e,t){Ae[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ae.deleteProperty=function(e,t){return Ae.set.call(this,e,t,void 0)},Ae.set=function(e,t,n){return Me.set.call(this,e[0],t,n,e[0])};var Ee=function(){function e(e){var t=this;this.g=Ze,this.F=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var a=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,o=Array(r>1?r-1:0),s=1;s1?r-1:0),a=1;a=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=te("Patches").$;return z(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}(),Te=new Ee,Re=Te.produce,De=(Te.produceWithPatches.bind(Te),Te.setAutoFreeze.bind(Te),Te.setUseProxies.bind(Te),Te.applyPatches.bind(Te),Te.createDraft.bind(Te),Te.finishDraft.bind(Te),Re);function _e(e,t){return(0,p.useReducer)((function(t,n){return De(t,(function(t){e[n.action](t,n.payload)}))}),t)}function He(e){var t=(0,p.useState)(e),n=(0,d.Z)(t,2),r=n[0],i=n[1];return(0,p.useEffect)((function(){i(e)}),[e]),[r,i]}var ze=0,Ue=1,Be=function(e){var t,n=(0,p.useState)(null!==(t=e.mode)&&void 0!==t?t:ze),r=(0,d.Z)(n,2),i=r[0],a=r[1],o=He(e.value),s=(0,d.Z)(o,2),c=s[0],u=s[1],l=function(){return(0,v.jsx)("span",{style:(0,N.Z)({cursor:"text"},_("full","inline")),onClick:function(){a(Ue)},children:c})},f=(0,p.useCallback)((function(e){return null===e||void 0===e?void 0:e.select()}),[]),h=(0,p.useCallback)((function(t){var n,r;a(ze),u(null!==(n=t.value)&&void 0!==n?n:""),e.onChange(null!==(r=t.value)&&void 0!==r?r:"")}),[e,a,u]),m=function(){var e=(0,v.jsx)("span",{style:{display:"block",position:"relative"},children:(0,v.jsx)("input",{ref:f,style:{zIndex:"10",position:"absolute",left:"0",marginTop:"-0.375rem"},onBlur:function(e){var t=e.target;return h(t)},onKeyPress:function(e){var t=e.key,n=e.target;"Enter"===t&&h(n)},type:"text",defaultValue:c})});return e};return function(){switch(i){case Ue:return m();case ze:return l();default:return(0,v.jsx)("span",{})}}()};function Le(e,t,n){var r=t.totalHeight,i=t.toleranceHeight,a=t.bufferedItems,o=t.settings,s=o.itemHeight,c=o.minIndex,u=o.maxIndex,l=c+Math.floor((e-i)/s),d=function(e,t,n,r,i){var a=Math.max(0,e,n),o=i(a,Math.min(t,n+r-1)-a);return(0,h.Z)(o)}(c,u,l,a,n),f=Math.max((l-c)*s,0);return{scrollTop:e,topPaddingHeight:f,bottomPaddingHeight:Math.max(r-(f+d.length*s),0),data:d}}var Ve=function(e){var t,n=(0,p.useRef)(null),r=(0,p.useMemo)((function(){var t,n=function(e){var t=e.minIndex,n=void 0===t?0:t,r=e.maxIndex,i=void 0===r?Number.MAX_SAFE_INTEGER:r,a=e.startIndex,o=void 0===a?0:a,s=e.itemHeight,c=void 0===s?20:s,u=e.count,l=void 0===u?Math.max(i-n,1):u,d=e.tolerance;return{minIndex:n,maxIndex:i,startIndex:o,itemHeight:c,count:l,tolerance:void 0===d?l:d}}(null!==(t=e.settings)&&void 0!==t?t:{}),r=function(e,t){var n=e.minIndex,r=e.maxIndex,i=e.startIndex,a=e.itemHeight,o=e.count,s=e.tolerance,c=o+2*s,u=o*a,l=(r-n)*a,d=s*a,f=Math.max(0,i-s-n)*a,p={scrollTop:0,settings:e,viewportHeight:u,totalHeight:l,toleranceHeight:d,bufferedItems:c,topPaddingHeight:f,bottomPaddingHeight:l-(f+(u+2*d)),data:[]};return(0,N.Z)((0,N.Z)({},p),Le(f+d,p,t))}(n,e.get),i=function(e){return function(t,n){return(0,N.Z)((0,N.Z)({},t),Le(n,t,e))}}(e.get);return{settings:n,reducer:i,startState:r}}),[e.settings,e.get]),i=r.settings,a=r.startState,o=r.reducer,s=(0,p.useReducer)(o,a),c=(0,d.Z)(s,2),u=c[0],l=c[1];(0,p.useEffect)((function(){null!==n.current&&l(n.current.scrollTop)}),[i,e.row]);var f=(0,p.useCallback)((function(e){e&&(e.scrollTop=n.current?n.current.scrollTop:i.startIndex*i.itemHeight),n.current=e}),[n,i.startIndex,i.itemHeight]),h=u.data.map((function(t){return(0,v.jsx)("div",{style:{height:"".concat(i.itemHeight,"px")},children:e.row(t)},e.rowKey(t))}));return(0,v.jsxs)("div",{ref:f,style:{height:"".concat(u.viewportHeight,"px"),overflowY:"scroll",overflowAnchor:"none"},className:null!==(t=e.className)&&void 0!==t?t:"",onScroll:function(e){return l(e.target.scrollTop)},children:[(0,v.jsx)("div",{style:{height:"".concat(u.topPaddingHeight,"px")}}),h,(0,v.jsx)("div",{style:{height:"".concat(u.bottomPaddingHeight,"px")}})]})},We=n(4408),Ke=n(6531);function Je(e){(0,p.useEffect)((function(){var t=Ke.S.get().reset$.subscribe((function(){e()}));return function(){return t.unsubscribe()}}),[e])}function Ge(){return(0,We.j)(Ke.S.get())}var $e=function(){var e=function(){var e=(0,p.useState)(Ge()),t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,p.useEffect)((function(){var e=Ke.S.get().$.subscribe((function(){r(Ge())}));return function(){return e.unsubscribe()}}),[]),n}();return(0,v.jsx)("span",{style:{whiteSpace:"nowrap"},children:e})},qe=function(e){var t=e.memory,n=e.jmp,r=void 0===n?{value:0}:n,i=e.highlight,a=void 0===i?-1:i,o=e.editable,s=void 0!==o&&o,c=e.format,u=void 0===c?Z.E_:c,l=e.onChange,f=void 0===l?function(){}:l,h=(0,p.useMemo)((function(){return{count:Math.min(t.size,20),maxIndex:t.size,itemHeight:34,startIndex:r.value}}),[t.size,r]),m=(0,p.useCallback)((function(e,n){return t.range(e,e+n).map((function(t,n){return[n+e,t]}))}),[t]),g=(0,p.useCallback)((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)(Xe,{index:n,value:u(r),editable:s,highlight:n===a,onChange:f})}),[u,s,a,f]);return(0,v.jsx)(Ve,{settings:h,get:m,row:g,rowKey:function(e){return(0,d.Z)(e,1)[0]}})},Xe=function(e){var t=e.index,n=e.value,r=e.highlight,i=void 0!==r&&r,a=e.editable,o=void 0!==a&&a,s=e.onChange,c=void 0===s?function(){}:s;return(0,v.jsxs)("div",{style:{display:"flex",height:"100%"},children:[(0,v.jsx)("code",{style:(0,N.Z)((0,N.Z)({},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:(0,Z.$v)(t)}),(0,v.jsx)("code",{style:(0,N.Z)((0,N.Z)({flex:"1",textAlign:"right"},T("none")),i?{background:"var(--code-kbd-background-color)"}:{}),children:o?(0,v.jsx)(Be,{value:n,onChange:function(e){return c(t,e,Number(n))}}):(0,v.jsx)("span",{children:n})})]})},Ye=function(e){var t=e.name,n=void 0===t?"Memory":t,r=e.highlight,i=void 0===r?-1:r,a=e.editable,o=void 0===a||a,s=e.memory,c=e.format,u=void 0===c?"dec":c,l=(0,p.useState)(u),f=(0,d.Z)(l,2),h=f[0],m=f[1],g=(0,p.useState)(""),x=(0,d.Z)(g,2),b=x[0],y=x[1],j=(0,p.useState)({value:0}),k=(0,d.Z)(j,2),C=k[0],w=k[1],P=function(){w({value:!isNaN(parseInt(b))&&isFinite(parseInt(b))?Number(b):0})},S=(0,p.useCallback)((function(e,t){s.update(e,t,null!==h&&void 0!==h?h:"dec")}),[s,h]);return Je((function(){y(""),w({value:0})})),(0,v.jsxs)("article",{className:"panel",children:[(0,v.jsxs)("header",{children:[(0,v.jsx)("div",{children:n}),(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:function(){},className:"flex-0",children:"\ud83d\udcc2"}),(0,v.jsx)("input",{style:{width:"4em",height:"100%"},placeholder:"Goto",value:b,onKeyDown:function(e){return"Enter"===e.key&&P()},onChange:function(e){var t=e.target.value;return y(t)}}),(0,v.jsx)("button",{onClick:P,className:"flex-0",children:"\u2935\ufe0f"}),R.I2.map((function(e){return(0,v.jsxs)("label",{className:"flex-0",role:"button","aria-current":e===h,children:[(0,v.jsx)("input",{type:"radio",name:n,value:e,checked:e===h,onChange:function(){return m(e)}}),e]},e)}))]})]}),(0,v.jsx)(qe,{jmp:C,memory:s,highlight:i,editable:o,format:function(e){return function(e,t){switch(e){case"bin":return(0,Z.Ly)(t);case"hex":return(0,Z.$v)(t);case"asm":return(0,D.a)(t);default:return(0,Z.E_)(t)}}(h,e)},onChange:S})]})};var Qe=n(5541),et="white";function tt(e,t,n){return 0===(e.get(32*n+(t/16|0))&1<0?(0,v.jsx)(v.Fragment,{children:i}):void 0}var at=n(8582),ot=n(4649),st=n(726),ct=n(1585),ut=n(4625),lt=function(){function e(t,n){if((0,r.Z)(this,e),(0,ot.Z)(this,"signBehaviors",new Map),g.zZ.has(t)){var i=(0,g.cT)(t);if((0,ut.IY)(i)){var a,o=Array.from((0,ut.Ok)(i).ins.entries()).concat(Array.from((0,ut.Ok)(i).outs.entries())),s=(0,st.Z)(o);try{for(s.s();!(a=s.n()).done;){var c=a.value;this.signBehaviors.set(c.name,!n||!n.includes(c.name))}}catch(u){s.e(u)}finally{s.f()}}}}return(0,i.Z)(e,[{key:"isSigned",value:function(e){return this.signBehaviors.get(e)}}]),e}(),dt=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"]]]),ft=(0,p.createContext)({});function pt(e){return{pin:e,bits:(0,ct.w)(0,e.width).map((function(t){return[t,e.voltage(t)]})).reverse()}}function ht(e){return(0,h.Z)(e.entries()).map(pt)}var vt=function(e){var t,n,r=e.sim,i=r.inPins,a=r.outPins,o=r.internalPins,s=(n=null!==(t=e.sim.chip[0].name)&&void 0!==t?t:"",new lt(n,dt.get(n)));return(0,v.jsxs)(v.Fragment,{children:[(0,v.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,v.jsx)("table",{className:"pinout",children:(0,v.jsxs)("tbody",{children:[(0,v.jsx)(mt,{pins:i,header:"Input pins",toggle:e.toggle,setInputValid:e.setInputValid,displayInfo:s}),(0,v.jsx)(mt,{pins:a,header:"Output pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s}),!e.hideInternal&&(0,v.jsx)(mt,{pins:o,header:"Internal pins",disabled:e.sim.pending,enableEdit:!1,displayInfo:s})]})})]})},mt=function(e){return(0,v.jsxs)(v.Fragment,{children:[e.pins.length>0&&(0,v.jsx)("tr",{children:(0,v.jsx)("th",{colSpan:2,children:e.header})}),(0,h.Z)(e.pins).map((function(t){return(0,v.jsxs)("tr",{children:[(0,v.jsx)("td",{children:t.pin.name}),(0,v.jsx)("td",{children:(0,v.jsx)(gt,{pin:t,toggle:e.toggle,disabled:e.disabled,enableEdit:e.enableEdit,signed:e.displayInfo.isSigned(t.pin.name),setInputValid:e.setInputValid,internal:"Internal pins"===e.header})})]},t.pin.name)}))]})},gt=function(e){var t=e.pin,n=e.toggle,r=e.disabled,i=void 0!==r&&r,a=e.enableEdit,o=void 0===a||a,s=e.signed,c=void 0===s||s,u=e.setInputValid,l=e.internal,f=void 0!==l&&l,h=(0,p.useState)(!0),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=!0,y=(0,p.useState)(""),j=(0,d.Z)(y,2),k=j[0],C=j[1],Z=(0,p.useContext)(ft);Z instanceof xt&&Z.registerCallback((function(){x(!0)}));var w=function(e){b=e,null===u||void 0===u||u(e)},P=function(e){for(var r=0;r>r&1)&&(null===n||void 0===n||n(t.pin,r))};return(0,p.useEffect)((function(){if(!g&&b){var e=0;if(c&&t.bits[0][1]){var n,r=(0,st.Z)(t.bits);try{for(r.s();!(n=r.n()).done;){var i=(0,d.Z)(n.value,2),a=i[0],o=i[1];a=Math.pow(2,t.bits.length)||c&&(i>=Math.pow(2,t.bits.length-1)||i<-Math.pow(2,t.bits.length-1))?w(!1):(P(i),w(!0))}}(e.target.value)},disabled:!o})}),t.bits.length>1&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{style:{width:"1em"}}),(0,v.jsx)("button",{style:{maxWidth:"3em",margin:0},onClick:function(){x(!g)},children:g?"dec":"bin"})]})]})},xt=function(){function e(){(0,r.Z)(this,e),(0,ot.Z)(this,"callbacks",[])}return(0,i.Z)(e,[{key:"registerCallback",value:function(e){this.callbacks.push(e)}},{key:"reset",value:function(){var e,t=(0,st.Z)(this.callbacks);try{for(t.s();!(e=t.n()).done;){(0,e.value)()}}catch(n){t.e(n)}finally{t.f()}}}]),e}();var bt=function(e){var t=function(e){var t=(0,p.useRef)((function(){})),n=(0,p.useMemo)((function(){return function(e,t){var n={running:e.running,speed:e.speed,steps:e.steps},r=e.finishFrame.bind(e);return e.finishFrame=function(){r(),t.current({action:"update"})},{initialState:n,reducers:{update:function(t){t.running=e.running,t.speed=e.speed,t.steps=e.steps},setSteps:function(t,n){t.steps=n,e.steps=n},setSpeed:function(t,n){t.speed=n,e.speed=n}},actions:{frame:function(){e.frame()},start:function(){e.start(),t.current({action:"update"})},stop:function(){e.stop(),t.current({action:"update"})},reset:function(){e.reset(),t.current({action:"update"})}}}}(e,t)}),[e,t]),r=n.initialState,i=n.reducers,a=n.actions,o=_e(i,r),s=(0,d.Z)(o,2),c=s[0],u=s[1];return t.current=u,{state:c,dispatch:t.current,actions:a}}(e.runner);return(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.frame()},"data-tooltip":"Step","data-placement":"bottom",children:"\u27a1\ufe0f"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.state.running?t.actions.stop():t.actions.start()},"data-tooltip":t.state.running?"Pause":"Play","data-placement":"bottom",children:t.state.running?"\u23f8":"\ufe0f\u23e9"}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){return t.actions.reset()},"data-tooltip":"Reset","data-placement":"bottom",children:"\u23ee"}),(0,v.jsx)("select",{className:"flex-1",name:"speed",value:t.state.speed,onChange:function(e){var n,r;t.dispatch({action:"setSpeed",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.speed)})},disabled:t.state.running,children:[[1e3,"Slow"],[500,"Fast"],[16,"Faster"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{className:"flex-1",name:"steps",value:t.state.steps,onChange:function(e){var n,r;t.dispatch({action:"setSteps",payload:Number(null!==(n=null===(r=e.target)||void 0===r?void 0:r.value)&&void 0!==n?n:t.state.steps)})},disabled:t.state.running,children:[[1,"1 Step"],[500,"500"],[1e3,"1000"],[2e3,"2000"]].map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),e.children]})},yt=n(8698),jt=n(691),kt=n(8090),Ct=n(9647),Zt=n(7662),wt=n(3389),Pt=[["01","Project 1"],["02","Project 2"],["03","Project 3"],["05","Project 5"]];function St(e){return e in Zt.CHIP_ORDER?Zt.CHIP_ORDER[e]:Zt.BUILTIN_CHIP_PROJECTS[e].concat(Zt.CHIP_PROJECTS[e])}function Nt(e){return"CHIP ".concat(e," {\n IN in;\n OUT out;\n PARTS:\n}")}function Ft(e){return Object.values(Zt.BUILTIN_CHIP_PROJECTS).flat().includes(e)}function It(e,t){var n=function(e,t){return Ft(t)?Zt.ChipProjects[e].BUILTIN_CHIPS[t]:Zt.ChipProjects[e].CHIPS[t]["".concat(t,".hdl")]}(e,t);if(Ft(t))return n;var r="//// Replace this comment with your code.",i="BUILTIN ".concat(t,";");return n.includes(r)?n.replace(r,i):n.replace("PARTS:","PARTS:\n ".concat(i))}function Ot(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{clocked:e.clocked,inPins:ht(e.ins),outPins:ht(e.outs),internalPins:ht(e.pins),chip:[e],pending:t,invalid:n}}var Mt=Ke.S.get();function At(e,t,n,r){var i=function(e){var t,n,r=null!==(t=e["/chip/project"])&&void 0!==t?t:"01";return{project:r,chips:St(r),chipName:null!==(n=e["/chip/chip"])&&void 0!==n?n:Zt.CHIP_PROJECTS[r][0]}}(n),a=i.project,o=i.chipName,s=i.chips,c=new y.P9,f=new wt.l1,p=!1,v=!1,m={setFiles:function(e,t){var n=t.hdl,r=void 0===n?e.files.hdl:n,i=t.tst,a=void 0===i?e.files.tst:i,o=t.cmp,s=void 0===o?e.files.cmp:o,c=t.out,u=void 0===c?"":c;e.files.hdl=r,e.files.tst=a,e.files.cmp=s,e.files.out=u},updateChip:function(e,t){var n,r,i,a,s,u;e.sim=Ot(c,null!==(n=null===t||void 0===t?void 0:t.pending)&&void 0!==n?n:e.sim.pending,null!==(r=null===t||void 0===t?void 0:t.invalid)&&void 0!==r?r:e.sim.invalid),e.controls.error=e.sim.invalid?null!==(i=null===t||void 0===t?void 0:t.error)&&void 0!==i?i:e.controls.error:"",e.controls.chips=St(e.controls.project),e.controls.chipName=e.sim.invalid?null!==(a=null===t||void 0===t?void 0:t.chipName)&&void 0!==a?a:o:null!==(s=null!==(u=c.name)&&void 0!==u?u:null===t||void 0===t?void 0:t.chipName)&&void 0!==s?s:o,e.controls.chips.includes(e.controls.chipName)||(e.controls.chips=[].concat((0,h.Z)(e.controls.chips),[e.controls.chipName]))},setProject:function(e,t){var n=St(t),r=e.controls.chipName&&n.includes(e.controls.chipName)?e.controls.chipName:n[0];e.controls.project=t,e.controls.chips=n,this.setChip(e,r)},setChip:function(e,t){e.controls.chipName=t,e.controls.hasBuiltin=g.zZ.has(t),e.controls.builtinOnly=Ft(t)},testRunning:function(e){e.controls.runningTest=!0},testFinished:function(e){e.controls.runningTest=!1;var n=e.files.out.trim()===e.files.cmp.trim();t(n?"Simulation successful: The output file is identical to the compare file":"Simulation error: The output file differs from the compare file")},updateTestStep:function(e){var t,n,r,i;if(e.files.out=null!==(t=null===(n=f)||void 0===n?void 0:n.log())&&void 0!==t?t:"",null!==(r=f)&&void 0!==r&&null!==(i=r.currentStep)&&void 0!==i&&i.span)e.controls.span=f.currentStep.span;else if(f.done){var a=e.files.tst.length;e.controls.span={start:a-1,end:a}}this.updateChip(e,{pending:e.sim.pending,invalid:e.sim.invalid})}},x={setProject:function(e){a=n["/chip/project"]=e,r.current({action:"setProject",payload:a}),this.setChip(Zt.CHIP_PROJECTS[a][0])},setChip:function(e){var t=arguments,i=this;return(0,l.Z)((0,u.Z)().mark((function a(){var s,c;return(0,u.Z)().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(c=t.length>1&&void 0!==t[1]?t[1]:null!==(s=n["/chip/project"])&&void 0!==s?s:"01",o=n["/chip/chip"]=e,r.current({action:"setChip",payload:o}),!(v=Ft(o))){a.next=8;break}return r.current({action:"setFiles",payload:{hdl:"",tst:"",cmp:""}}),i.useBuiltin(),a.abrupt("return");case 8:return a.next=10,i.loadChip(c,o);case 10:p&&i.useBuiltin();case 11:case"end":return a.stop()}}),a)})))()},reset:function(){Ke.S.get().reset(),c.reset(),f.reset(),r.current({action:"setFiles",payload:{}}),r.current({action:"updateChip"})},updateFiles:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var a,o,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=e.hdl,o=e.tst,s=e.cmp,r.current({action:"setFiles",payload:{hdl:a,tst:o,cmp:s}}),i.prev=2,!a){i.next=6;break}return i.next=6,n.compileChip(a);case 6:o&&n.compileTest(o),i.next=12;break;case 9:i.prev=9,i.t0=i.catch(2),t((0,We.j)(i.t0));case 12:case"end":return i.stop()}}),i,null,[[2,9]])})))()},compileChip:function(e){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){var a,o,s;return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(c.remove(),a=kt.Gq.parse(e),!(0,ut.dZ)(a)){i.next=6;break}return t("Failed to parse chip"),r.current({action:"updateChip",payload:{invalid:!0,error:(0,We.j)((0,ut.UG)(a))}}),i.abrupt("return");case 6:return i.next=8,(0,jt.J_)((0,ut.Ok)(a));case 8:if(o=i.sent,!(0,ut.dZ)(o)){i.next=14;break}return s=(0,We.j)((0,ut.UG)(o)),t(s),r.current({action:"updateChip",payload:{invalid:!0,error:s}}),i.abrupt("return");case 14:t("Compiled ".concat(c.name)),n.replaceChip((0,ut.Ok)(o));case 16:case"end":return i.stop()}}),i)})))()},replaceChip:function(e){var t,n=c.ins,i=(0,st.Z)(n);try{for(i.s();!(t=i.n()).done;){var a=(0,d.Z)(t.value,2),o=a[0],s=a[1].busVoltage,u=e.ins.get(o);u&&(u.busVoltage=s)}}catch(l){i.e(l)}finally{i.f()}Mt.reset(),e.eval(),(c=e).reset(),f=f.with(c).reset(),r.current({action:"updateChip",payload:{invalid:!1}}),r.current({action:"updateTestStep"})},loadChip:function(t,i){var a=this;return(0,l.Z)((0,u.Z)().mark((function o(){var s,c,l,f,p,h;return(0,u.Z)().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return n["/chip/chip"]=i,s=function(e){return"/projects/".concat(t,"/").concat(i,"/").concat(i,".").concat(e)},o.next=4,Promise.all([e.readFile(s("hdl")).catch((function(){return Nt(i)})),e.readFile(s("tst")).catch((function(e){return"repeat 10 {\n tick,\n tock;\n}"})),e.readFile(s("cmp")).catch((function(){return"| in|out|"}))]);case 4:return c=o.sent,l=(0,d.Z)(c,3),f=l[0],p=l[1],h=l[2],r.current({action:"setFiles",payload:{hdl:f,tst:p,cmp:h}}),o.next=12,a.compileChip(f);case 12:a.compileTest(p);case 13:case"end":return o.stop()}}),o)})))()},saveChip:function(n){var i=arguments;return(0,l.Z)((0,u.Z)().mark((function s(){var c,l,d;return(0,u.Z)().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return c=i.length>1&&void 0!==i[1]?i[1]:a,l=i.length>2&&void 0!==i[2]?i[2]:o,r.current({action:"setFiles",payload:{hdl:n}}),d="/projects/".concat(c,"/").concat(l,"/").concat(l,".hdl"),s.next=6,e.writeFile(d,n);case 6:t("Saved ".concat(d));case 7:case"end":return s.stop()}}),s)})))()},toggle:function(e,t){void 0!==t?e.busVoltage=e.busVoltage^1<0&&void 0!==e[0])||e[0],c=e.length>1?e[1]:void 0,s){i.next=7;break}return v||(p=!1),i.next=6,n.loadChip(a,o);case 6:return i.abrupt("return");case 7:if(v||(p=!0),l=o,d=(0,g.cT)(l),!(0,ut.dZ)(d)){i.next=13;break}return t("Failed to load builtin ".concat(l,": ").concat((0,We.j)((0,ut.UG)(d)))),i.abrupt("return");case 13:if(!c){i.next=16;break}return i.next=16,n.saveChip(c,a,o);case 16:f=It(a,l),r.current({action:"setFiles",payload:{hdl:f}}),n.replaceChip((0,ut.Ok)(d));case 19:case"end":return i.stop()}}),i)})))()},initialize:function(){var e=this;return(0,l.Z)((0,u.Z)().mark((function t(){return(0,u.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.setChip(o,a);case 2:case"end":return t.stop()}}),t)})))()},compileTest:function(n){r.current({action:"setFiles",payload:{tst:n}});var i=Ct.qH.parse(n);return(0,ut.dZ)(i)?(t("Failed to parse test"),!1):(t("Parsed tst"),(f=wt.l1.from((0,ut.Ok)(i)).with(c).reset()).setFileSystem(e),r.current({action:"updateTestStep"}),!0)},runTest:function(t){var n=this;return(0,l.Z)((0,u.Z)().mark((function i(){return(0,u.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n.compileTest(t)){i.next=2;break}return i.abrupt("return");case 2:return r.current({action:"testRunning"}),e.pushd("/samples"),i.next=6,f.run();case 6:e.popd(),r.current({action:"updateTestStep"}),r.current({action:"testFinished"});case 9:case"end":return i.stop()}}),i)})))()},tick:function(){return this.stepTest()},stepTest:function(){return(0,l.Z)((0,u.Z)().mark((function e(){var t;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(0,Qe.hu)(f.chipId===c.id,"Test and chip out of sync"),e.next=3,f.step();case 3:return t=e.sent,r.current({action:"updateTestStep"}),t&&r.current({action:"testFinished"}),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))()}};return{initialState:function(){var e={project:a,chips:s,chipName:o,hasBuiltin:g.zZ.has(o),builtinOnly:Ft(o),runningTest:!1,error:""},n=(0,g.cT)(e.chipName);return(0,ut.dZ)(n)?(t((0,We.j)((0,ut.UG)(n))),c=new y.P9):c=(0,ut.Ok)(n),{controls:e,files:{hdl:"",cmp:"",tst:"",out:""},sim:Ot(c)}}(),reducers:m,actions:x}}var Et=n(8365),Tt=n(7538),Rt=n(2648),Dt=n(3943),_t=Ke.S.get(),Ht=new WeakMap,zt=new WeakMap,Ut=new WeakMap,Bt=new WeakMap,Lt=function(){function e(){var t=this;(0,r.Z)(this,e),(0,ot.Z)(this,"steps",1),(0,ot.Z)(this,"speed",1e3),(0,Tt.Z)(this,Ht,{writable:!0,value:!1}),(0,Tt.Z)(this,zt,{writable:!0,value:0}),(0,Tt.Z)(this,Ut,{writable:!0,value:0}),(0,Tt.Z)(this,Bt,{writable:!0,value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){var n,r,i,a;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((0,Dt.Z)(t,Ht)){e.next=2;break}return e.abrupt("return");case 2:if(n=Date.now(),r=n-(0,Dt.Z)(t,Ut),(0,Rt.Z)(t,Ut,n),(0,Rt.Z)(t,zt,(0,Dt.Z)(t,zt)+r),!((0,Dt.Z)(t,zt)>t.speed)){e.next=19;break}i=!1,a=0;case 9:if(!(a0&&void 0!==arguments[0]?arguments[0]:"";return n(e)},language:r,onMount:g})})},Yt=function(e){var t=e.className,n=void 0===t?"":t,r=e.style,i=void 0===r?{}:r,a=e.disabled,o=void 0!==a&&a,s=e.value,c=e.onChange,u=e.grammar,l=e.language,f=e.highlight,h=(0,p.useState)(),m=(0,d.Z)(h,2),g=m[0],x=m[1],b=(0,p.useContext)(Vt.Il).monaco,y=(0,p.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=u.match(e);x(t.failed()?t:void 0)}),[x,u]);(0,p.useEffect)((function(){return y(s)}),[y,s]);var j=(0,p.useMemo)((function(){return function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;return function(){for(var r=arguments.length,i=new Array(r),a=0;a0&&void 0!==arguments[0]?arguments[0]:"";c(e),j(e)}),[j,c]);return(0,v.jsx)("div",{className:"Editor ".concat(n),style:i,children:b.canUse&&b.wants?(0,v.jsx)(Xt,{value:s,onChange:k,language:l,error:g,disabled:o,highlight:f}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(qt,{value:s,onChange:k,language:l,disabled:o}),(0,v.jsx)($t,{error:g})]})})},Qt=function(e){var t;return(0,v.jsxs)("article",{className:["panel",null!==(t=e.className)&&void 0!==t?t:""].join(" "),children:[e.header&&(0,v.jsx)("header",{children:e.header}),(0,v.jsx)("main",{children:e.children}),e.footer&&(0,v.jsx)("footer",{children:e.footer})]})},en=function(e){var t;return(0,v.jsxs)("details",{className:null!==(t=e.className)&&void 0!==t?t:"",open:e.open,style:e.style,children:[(0,v.jsx)("summary",{children:(0,v.jsx)("div",{className:"flex row align-baseline",children:e.summary})}),e.children]})},tn=function(){var e=(0,p.useContext)(yt.r),t=e.fs,n=e.setStatus,m=(0,p.useContext)(Vt.Il),g=m.filePicker,x=m.tracking,b=function(){var e=(0,p.useContext)(yt.r),t=e.fs,n=e.setStatus,r=e.storage,i=(0,p.useRef)((function(){})),a=(0,p.useMemo)((function(){return At(t,n,r,i)}),[t,n,r,i]),o=a.initialState,s=a.reducers,c=a.actions,u=_e(s,o),l=(0,d.Z)(u,2),f=l[0],h=l[1];return i.current=h,{state:f,dispatch:i,actions:c}}(),y=b.state,j=b.actions,k=b.dispatch,C=He(y.files.hdl),Z=(0,d.Z)(C,2),w=Z[0],P=Z[1],S=He(y.files.tst),N=(0,d.Z)(S,2),F=N[0],I=N[1],O=He(y.files.cmp),M=(0,d.Z)(O,2),A=M[0],E=M[1],T=He(y.files.out),R=(0,d.Z)(T,1)[0];(0,p.useEffect)((function(){j.initialize()}),[j]),(0,p.useEffect)((function(){x.trackPage("/chip")}),[x]);(0,p.useEffect)((function(){x.trackEvent("action","setProject",y.controls.project),x.trackEvent("action","setChip",y.controls.chipName)}),[]);var D=(0,p.useCallback)((function(e){j.setProject(e),x.trackEvent("action","setProject",e)}),[j,x]),_=(0,p.useCallback)((function(e){j.setChip(e),x.trackEvent("action","setChip",e),ne.reset()}),[j,x]),H=(0,p.useCallback)((function(){j.eval(),x.trackEvent("action","eval")}),[j,x]),z=(0,p.useRef)((function(){}));z.current=(0,l.Z)((0,u.Z)().mark((function e(){var t,n,r,i=arguments;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:{},e.next=3,j.updateFiles({hdl:r.hdl,tst:null!==(t=r.tst)&&void 0!==t?t:F,cmp:null!==(n=r.cmp)&&void 0!==n?n:A});case 3:case"end":return e.stop()}}),e)})));var U=(0,p.useCallback)((0,l.Z)((0,u.Z)().mark((function e(){var r,i;return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,g.select();case 3:return r=e.sent,e.next=6,t.readFile(r);case 6:return i=e.sent,e.next=9,z.current({tst:i});case 9:e.next=15;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0),n("Failed to load into memory");case 15:case"end":return e.stop()}}),e,null,[[0,11]])}))),[g,n,t,z]),B=(0,p.useRef)();(0,p.useEffect)((function(){return B.current=new(function(e){(0,s.Z)(n,e);var t=(0,c.Z)(n);function n(){return(0,r.Z)(this,n),t.apply(this,arguments)}return(0,i.Z)(n,[{key:"reset",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z.current();case 2:return e.next=4,j.reset();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"finishFrame",value:function(){(0,a.Z)((0,o.Z)(n.prototype),"finishFrame",this).call(this),k.current({action:"updateTestStep"})}},{key:"tick",value:function(){var e=(0,l.Z)((0,u.Z)().mark((function e(){return(0,u.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",j.stepTest());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{key:"toggle",value:function(){k.current({action:"updateTestStep"})}}]),n}(Lt)),function(){var e;null===(e=B.current)||void 0===e||e.stop()}}),[z,j,k]);var L=(0,p.useMemo)((function(){return{toggle:function(){j.clock(),x.trackEvent("action","toggleClock")},reset:function(){x.trackEvent("action","resetClock"),j.reset()}}}),[j]),V=(0,p.useState)(!1),W=(0,d.Z)(V,2),K=W[0],J=W[1],G=(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("select",{value:y.controls.project,onChange:function(e){var t=e.target.value;D(t)},"data-testid":"project-picker",children:Pt.map((function(e){var t=(0,d.Z)(e,2),n=t[0],r=t[1];return(0,v.jsx)("option",{value:n,children:r},n)}))}),(0,v.jsx)("select",{value:y.controls.chipName,onChange:function(e){var t=e.target.value;_(t)},"data-testid":"chip-picker",children:y.controls.chips.map((function(e){return(0,v.jsx)("option",{value:e,style:Ft(e)?{color:"rgb(170, 170, 170)"}:{},children:"".concat(e," ").concat(Ft(e)?"(given)":"")},e)}))}),(0,v.jsx)("button",{className:"flex-0",onClick:function(){j.saveChip(w)},disabled:K,children:(0,v.jsx)(f.cC,{id:"Save"})})]})}),$=(0,v.jsx)(Qt,{className:"_hdl_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{tabIndex:0,children:"HDL"}),(0,v.jsx)("fieldset",{children:y.controls.hasBuiltin&&!y.controls.builtinOnly&&(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"checkbox",role:"switch",checked:K,onChange:function(){K?(J(!1),j.useBuiltin(!1)):(J(!0),j.useBuiltin(!0,w)),ne.reset()}}),(0,v.jsx)(f.cC,{id:"Builtin"})]})}),G]}),children:(0,v.jsx)(Yt,{className:"flex-1",value:w,onChange:function(e){P(e),z.current(K||y.controls.builtinOnly?{}:{hdl:e})},grammar:kt.Gq.parser,language:"hdl",disabled:K||y.controls.builtinOnly})}),q=(0,p.useState)(!0),X=(0,d.Z)(q,2),Y=X[0],Q=X[1],ee=(0,v.jsxs)("fieldset",{role:"group",children:[(0,v.jsx)("button",{onClick:H,onKeyDown:H,disabled:!y.sim.pending||!Y,children:(0,v.jsx)(f.cC,{id:"Eval"})}),(0,v.jsxs)("button",{onClick:L.toggle,style:{maxWidth:"initial"},disabled:!y.sim.clocked,children:[(0,v.jsx)(f.cC,{id:"Clock"}),":","\xa0",(0,v.jsx)($e,{})]}),(0,v.jsx)("button",{onClick:L.reset,style:{maxWidth:"initial"},disabled:!y.sim.clocked,children:(0,v.jsx)(f.cC,{id:"Reset"})})]}),te=function(e,t){return(0,h.Z)(e.parts).map((function(e,n){return["".concat(e.id,"_").concat(n),it(e,t)]})).filter((function(e){var t=(0,d.Z)(e,2);return t[0],void 0!==t[1]}))}({parts:y.sim.chip},(function(){k.current({action:"updateChip"})})),ne=new xt,re=(0,v.jsx)(Qt,{className:"_parts_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{children:[(0,v.jsx)(f.cC,{id:"Chip"})," ",y.controls.chipName]}),ee]}),children:y.sim.invalid?(0,v.jsx)(f.cC,{id:"Syntax errors in the HDL code"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ft.Provider,{value:ne,children:(0,v.jsx)(vt,{sim:y.sim,toggle:j.toggle,setInputValid:Q,hideInternal:y.controls.builtinOnly})}),te.length>0&&(0,v.jsx)(en,{summary:(0,v.jsx)(f.cC,{id:"Visualization"}),open:!0,children:(0,v.jsx)("main",{children:te.map((function(e){var t=(0,d.Z)(e,2);t[0];return t[1]}))})})]})}),ie=(0,p.useState)("tst"),ae=(0,d.Z)(ie,2),oe=ae[0],se=ae[1],ce=(0,p.useCallback)((function(e){se(e),x.trackEvent("tab","change",e)}),[x]),ue=(0,v.jsx)(Qt,{className:"_test_panel",header:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)(f.cC,{id:"Test"})}),(0,v.jsx)("div",{className:"flex-2",children:B.current&&(0,v.jsx)(bt,{runner:B.current})}),(0,v.jsx)("div",{children:(0,v.jsxs)("button",{onClick:U,children:[(0,v.jsx)(Wt.J,{name:"upload_file"})," "]})})]}),children:(0,v.jsxs)("div",{role:"tablist",style:{"--tab-count":"3"},children:[(0,v.jsx)("div",{role:"tab",id:"test-tab-tst","aria-controls":"test-tabpanel-tst","aria-selected":"tst"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-tst",value:"tst",checked:"tst"===oe,onChange:function(){return ce("tst")}}),"Test Script"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-tst",id:"test-tabpanel-tst",children:(0,v.jsx)(Yt,{value:F,onChange:I,grammar:Ct.qH.parser,language:"tst",highlight:y.controls.span,disabled:y.controls.builtinOnly})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-cmp","aria-controls":"test-tablpanel-cmp","aria-selected":"cmp"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-cmp",value:"cmp",checked:"cmp"===oe,onChange:function(){return ce("cmp")}}),"Compare File"]})}),(0,v.jsx)("div",{role:"tabpanel","aria-labelledby":"test-tab-cmp",id:"test-tabpanel-cmp",style:{position:"relative"},children:(0,v.jsx)(Yt,{value:A,onChange:E,grammar:Et.lA.parser,language:"cmp",disabled:y.controls.builtinOnly})}),(0,v.jsx)("div",{role:"tab",id:"test-tab-out","aria-controls":"test-tabpanel-out","aria-selected":"out"===oe,children:(0,v.jsxs)("label",{children:[(0,v.jsx)("input",{type:"radio",name:"test-tabs","aria-controls":"test-tabpanel-out",value:"out",checked:"out"===oe,onChange:function(){return ce("out")}}),"Output File"]})}),(0,v.jsx)("div",{role:"tabpanel",id:"test-tabpanel-out","aria-labelledby":"test-tab-out",children:(0,v.jsx)(at.M,{cmp:A,out:R})})]})});return(0,v.jsxs)("div",{className:"ChipPage grid",children:[$,re,ue]})},nn=tn}}]); +//# sourceMappingURL=263.8f4582b5.chunk.js.map \ No newline at end of file diff --git a/static/js/263.8f4582b5.chunk.js.map b/static/js/263.8f4582b5.chunk.js.map new file mode 100644 index 000000000..c844d525c --- /dev/null +++ b/static/js/263.8f4582b5.chunk.js.map @@ -0,0 +1 @@ +{"version":3,"file":"static/js/263.8f4582b5.chunk.js","mappings":"4YAMaA,EAAe,SAAH,SACvBC,EAAC,EAADA,EACAC,EAAE,EAAFA,GACAC,EAAC,EAADA,EACAC,EAAG,EAAHA,IACI,EAAJC,KAAI,OAQJC,EAAAA,EAAAA,MAAAA,MAAAA,CAAAC,SAAAA,EACEC,EAAAA,EAAAA,KAAAA,OAAAA,CAAAD,SAAAA,SACAC,EAAAA,EAAAA,KAAAA,MAAAA,CAAKC,MAAM,MAAMC,OAAO,MAAMC,MAAM,6BAA4BJ,UAC9DD,EAAAA,EAAAA,MAAAA,IAAAA,CAAAC,SAAAA,EACEC,EAAAA,EAAAA,KAAAA,OAAAA,CAAMI,EAAE,IAAIC,EAAE,KAAKH,OAAO,KAAKD,MAAM,KAAKK,KAAK,WAC/CN,EAAAA,EAAAA,KAAAA,OAAAA,CAAMI,EAAE,IAAIC,EAAE,MAAMH,OAAO,KAAKD,MAAM,KAAKK,KAAK,WAChDN,EAAAA,EAAAA,KAAAA,OAAAA,CAAMI,EAAE,MAAMC,EAAE,KAAKH,OAAO,KAAKD,MAAM,KAAKK,KAAK,WACjDN,EAAAA,EAAAA,KAAAA,UAAAA,CACEO,OAAO,mDACPC,OAAO,OACPF,KAAK,aAEPN,EAAAA,EAAAA,KAAAA,OAAAA,CACES,SAAS,WACTC,WAAW,SACXC,WAAW,eACXC,SAAS,KACTC,YAAY,IACZC,GAAG,QACHT,EAAE,KACFD,EAAE,KACFI,OAAO,QACPF,KAAK,UAASP,SAEbN,KAEHO,EAAAA,EAAAA,KAAAA,OAAAA,CACES,SAAS,WACTC,WAAW,SACXC,WAAW,eACXC,SAAS,KACTE,GAAG,SACHT,EAAE,MACFD,EAAE,KACFS,YAAY,IACZL,OAAO,QACPF,KAAK,UAASP,SAEbJ,KAEHK,EAAAA,EAAAA,KAAAA,OAAAA,CACES,SAAS,WACTC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,WACL,kBAAgB,eAChB1Z,GAAG,oBACHoT,MAAO,CAAES,SAAU,YAAa,UAEhC,SAACkY,GAAM,CACL3lB,MAAOoe,EACP7Q,SAAU4Z,EACVvB,QAASgD,GAAAA,GAAAA,OACThG,SAAU,MACV/J,SAAU/W,EAAMwc,SAASP,iBAG7B,gBACEzK,KAAK,MACL1Z,GAAG,eACH,gBAAc,oBACd,gBAAmC,QAApB2uB,GAA0B,UAEzC,8BACE,kBACExa,KAAK,QACLhU,KAAK,YACL,gBAAc,oBACdiG,MAAM,MACN0T,QAA6B,QAApB6U,GACThb,SAAU,kBAAMkb,GAAmB,MAAM,IACzC,oBAIN,gBACEnV,KAAK,WACL1Z,GAAG,oBACH,kBAAgB,eAAc,UAE9B,SAAC,KAAS,CAACwkB,IAAKA,EAAK1lB,IAAKA,WAMlC,OACE,iBAAK+D,UAAU,gBAAe,UAC3BsrB,EACAM,GACAM,KAGP,EAEA,K","sources":["../../components/src/chips/alu.tsx","../../components/src/chips/register.tsx","../../components/src/chips/keyboard.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/constants.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/core.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/border.js","../../node_modules/@davidsouther/jiffies/lib/esm/dom/css/sizing.js","../../node_modules/immer/src/utils/errors.ts","../../node_modules/immer/src/utils/common.ts","../../node_modules/immer/src/utils/plugins.ts","../../node_modules/immer/src/core/scope.ts","../../node_modules/immer/src/core/finalize.ts","../../node_modules/immer/src/core/proxy.ts","../../node_modules/immer/src/core/immerClass.ts","../../node_modules/immer/src/core/current.ts","../../node_modules/immer/src/immer.ts","../../node_modules/immer/src/utils/env.ts","../../components/src/react.ts","../../components/src/inline_edit.tsx","../../components/src/virtual_scroll.tsx","../../components/src/clockface.tsx","../../components/src/chips/memory.tsx","../../components/src/chips/screen.tsx","../../components/src/chips/visualizations.tsx","../../components/src/pin_display.ts","../../components/src/pinout.tsx","../../components/src/runbar.tsx","../../components/src/timer.tsx","../../components/src/stores/chip.store.ts","../../simulator/src/timer.ts","shell/editor.tsx","../../node_modules/@davidsouther/jiffies/lib/esm/debounce.js","shell/panel.tsx","pages/chip.tsx"],"sourcesContent":["import {\n COMMANDS_ALU,\n COMMANDS_OP,\n Flags,\n} from \"@nand2tetris/simulator/cpu/alu.js\";\n\nexport const ALUComponent = ({\n A,\n op,\n D,\n out,\n flag,\n}: {\n A: number;\n op: COMMANDS_OP;\n D: number;\n out: number;\n flag: keyof typeof Flags;\n}) => (\n
\n ALU\n \n \n \n \n \n \n \n {A}\n \n \n {D}\n \n \n {out}\n \n \n {COMMANDS_ALU.op[op] ?? \"(??)\"}\n \n \n \n
\n);\n","import { dec } from \"@nand2tetris/simulator/util/twos.js\";\n\nexport const RegisterComponent = ({\n name,\n bits,\n}: {\n name: string;\n bits: number;\n}) => (\n
\n {name}: {dec(bits)}\n
\n);\n","import { Keyboard as KeyboardChip } from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { KeyboardEvent, useState } from \"react\";\nimport { RegisterComponent } from \"./register.js\";\n\nconst KeyMap: Record = {\n // Delete: 127,\n Enter: 128,\n Backspace: 129,\n ArrowLeft: 130,\n ArrowUp: 131,\n ArrowRight: 132,\n ArrowDown: 133,\n Home: 134,\n End: 135,\n PageUp: 136,\n PageDown: 137,\n Insert: 138,\n Delete: 139,\n Escape: 140,\n F1: 141,\n F2: 142,\n F3: 143,\n F4: 144,\n F5: 145,\n F6: 146,\n F7: 147,\n F8: 148,\n F9: 149,\n F10: 150,\n F11: 151,\n F12: 152,\n};\n\nfunction keyPressToHackCharacter(keypress: KeyboardEvent): number {\n const mapping = KeyMap[keypress.key];\n if (mapping !== undefined) {\n return mapping;\n }\n if (keypress.key.length === 1) {\n const code = keypress.key.charCodeAt(0);\n if (code >= 32 && code <= 126) {\n return code;\n }\n }\n\n return 0;\n}\n\nexport const Keyboard = ({\n keyboard,\n update,\n}: {\n keyboard: KeyboardChip;\n update?: () => void;\n}) => {\n // const [showPicker, setShowPicker] = useState(false);\n const [enabled, setEnabled] = useState(false);\n const [character, setCharacter] = useState(\"\");\n const [bits, setBits] = useState(keyboard.out().busVoltage);\n let currentKey = 0;\n\n const toggleEnabled = () => {\n setEnabled(!enabled);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n event.preventDefault();\n if (!enabled) {\n return;\n }\n\n setCharacter(event.key);\n const key = keyPressToHackCharacter(event);\n if (key === currentKey) {\n return;\n }\n setKey(key);\n update?.();\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) {\n return;\n }\n\n currentKey = 0;\n keyboard.clearKey();\n update?.();\n setBits(keyboard.out().busVoltage);\n setCharacter(\"\");\n };\n\n const setKey = (key: number) => {\n if (key === 0) {\n return;\n }\n keyboard.setKey(key);\n setBits(keyboard.out().busVoltage);\n currentKey = key;\n };\n\n return (\n
\n
\n \n
\n
{`Character: ${character}`}
\n
\n \n
\n
\n );\n};\n","export const Sizes = {\n none: \"0px\",\n sm: \"0.125rem\",\n \"\": \"0.25rem\",\n md: \"0.375rem\",\n lg: \"0.5rem\",\n xl: \"0.75rem\",\n \"2xl\": \"1rem\",\n \"3xl\": \"1.5rem\",\n full: \"9999px\",\n};\nexport const Sides = {\n \"\": \"\",\n t: \"Top\",\n r: \"Right\",\n l: \"Left\",\n b: \"Bottom\",\n tl: \"TopLeft\",\n tr: \"TopRight\",\n bl: \"BottomLeft\",\n br: \"BottomRight\",\n};\nexport const Widths = {\n \"1/4\": \"25%\",\n \"1/2\": \"50%\",\n \"3/4\": \"75%\",\n full: \"100%\",\n};\n","import { Sides, Sizes } from \"./constants.js\";\nexport function isSide(v) {\n return Sides[v] !== undefined;\n}\nexport function isSize(v) {\n return Sizes[v] !== undefined;\n}\nexport function getSize(size) {\n return Sizes[size];\n}\nexport function getSide(side) {\n switch (side) {\n case \"t\":\n return [...getSide(\"tl\"), ...getSide(\"tr\")];\n case \"r\":\n return [...getSide(\"tr\"), ...getSide(\"br\")];\n case \"b\":\n return [...getSide(\"br\"), ...getSide(\"bl\")];\n case \"l\":\n return [...getSide(\"tl\"), ...getSide(\"bl\")];\n default:\n return [Sides[side]];\n }\n}\n","import { isSide, getSize, getSide } from \"./core.js\";\nexport function rounded(size = \"\", side = \"\") {\n if (isSide(size)) {\n side = size;\n size = \"\";\n }\n const sized = getSize(size);\n return getSide(side).reduce((prev, curr) => {\n if (curr === \"\") {\n prev.borderRadius = sized;\n }\n else {\n // @ts-ignore\n prev[`border${curr}Radius`] = sized;\n }\n return prev;\n }, {});\n}\nexport function border({ side = \"\", style = \"solid\", radius = \"\", width = 1, color = \"black\", }) {\n return {};\n}\nexport function inset(width, color1 = \"gray\", color2 = \"lightgray\") {\n return {\n ...border({ side: \"tl\", width, color: color1, radius: \"none\" }),\n ...border({ side: \"br\", width, color: color2, radius: \"none\" }),\n };\n}\n","import { Widths } from \"./constants.js\";\nexport function width(amount, block) {\n if (amount === undefined && Widths[block] !== undefined) {\n amount = block;\n }\n return {\n ...(block === \"inline\" ? { display: \"inline-block\" } : {}),\n width: Widths[amount] ?? \"0\",\n };\n}\n","const errors = {\n\t0: \"Illegal state\",\n\t1: \"Immer drafts cannot have computed properties\",\n\t2: \"This object has been frozen and should not be mutated\",\n\t3(data: any) {\n\t\treturn (\n\t\t\t\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n\t\t\tdata\n\t\t)\n\t},\n\t4: \"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",\n\t5: \"Immer forbids circular references\",\n\t6: \"The first or second argument to `produce` must be a function\",\n\t7: \"The third argument to `produce` must be a function or undefined\",\n\t8: \"First argument to `createDraft` must be a plain object, an array, or an immerable object\",\n\t9: \"First argument to `finishDraft` must be a draft returned by `createDraft`\",\n\t10: \"The given draft is already finalized\",\n\t11: \"Object.defineProperty() cannot be used on an Immer draft\",\n\t12: \"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t13: \"Immer only supports deleting array indices\",\n\t14: \"Immer only supports setting array indices and the 'length' property\",\n\t15(path: string) {\n\t\treturn \"Cannot apply patch, path doesn't resolve: \" + path\n\t},\n\t16: 'Sets cannot have \"replace\" patches.',\n\t17(op: string) {\n\t\treturn \"Unsupported patch operation: \" + op\n\t},\n\t18(plugin: string) {\n\t\treturn `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \\`enable${plugin}()\\` when initializing your application.`\n\t},\n\t20: \"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",\n\t21(thing: string) {\n\t\treturn `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`\n\t},\n\t22(thing: string) {\n\t\treturn `'current' expects a draft, got: ${thing}`\n\t},\n\t23(thing: string) {\n\t\treturn `'original' expects a draft, got: ${thing}`\n\t},\n\t24: \"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"\n} as const\n\nexport function die(error: keyof typeof errors, ...args: any[]): never {\n\tif (__DEV__) {\n\t\tconst e = errors[error]\n\t\tconst msg = !e\n\t\t\t? \"unknown error nr: \" + error\n\t\t\t: typeof e === \"function\"\n\t\t\t? e.apply(null, args as any)\n\t\t\t: e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}${\n\t\t\targs.length ? \" \" + args.map(s => `'${s}'`).join(\",\") : \"\"\n\t\t}. Find the full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","import {\n\tDRAFT_STATE,\n\tDRAFTABLE,\n\thasSet,\n\tObjectish,\n\tDrafted,\n\tAnyObject,\n\tAnyMap,\n\tAnySet,\n\tImmerState,\n\thasMap,\n\tArchtype,\n\tdie\n} from \"../internal\"\n\n/** Returns true if the given value is an Immer draft */\n/*#__PURE__*/\nexport function isDraft(value: any): boolean {\n\treturn !!value && !!value[DRAFT_STATE]\n}\n\n/** Returns true if the given value can be drafted by Immer */\n/*#__PURE__*/\nexport function isDraftable(value: any): boolean {\n\tif (!value) return false\n\treturn (\n\t\tisPlainObject(value) ||\n\t\tArray.isArray(value) ||\n\t\t!!value[DRAFTABLE] ||\n\t\t!!value.constructor?.[DRAFTABLE] ||\n\t\tisMap(value) ||\n\t\tisSet(value)\n\t)\n}\n\nconst objectCtorString = Object.prototype.constructor.toString()\n/*#__PURE__*/\nexport function isPlainObject(value: any): boolean {\n\tif (!value || typeof value !== \"object\") return false\n\tconst proto = Object.getPrototypeOf(value)\n\tif (proto === null) {\n\t\treturn true\n\t}\n\tconst Ctor =\n\t\tObject.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n\n\tif (Ctor === Object) return true\n\n\treturn (\n\t\ttypeof Ctor == \"function\" &&\n\t\tFunction.toString.call(Ctor) === objectCtorString\n\t)\n}\n\n/** Get the underlying object that is represented by the given draft */\n/*#__PURE__*/\nexport function original(value: T): T | undefined\nexport function original(value: Drafted): any {\n\tif (!isDraft(value)) die(23, value)\n\treturn value[DRAFT_STATE].base_\n}\n\n/*#__PURE__*/\nexport const ownKeys: (target: AnyObject) => PropertyKey[] =\n\ttypeof Reflect !== \"undefined\" && Reflect.ownKeys\n\t\t? Reflect.ownKeys\n\t\t: typeof Object.getOwnPropertySymbols !== \"undefined\"\n\t\t? obj =>\n\t\t\t\tObject.getOwnPropertyNames(obj).concat(\n\t\t\t\t\tObject.getOwnPropertySymbols(obj) as any\n\t\t\t\t)\n\t\t: /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport const getOwnPropertyDescriptors =\n\tObject.getOwnPropertyDescriptors ||\n\tfunction getOwnPropertyDescriptors(target: any) {\n\t\t// Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n\t\tconst res: any = {}\n\t\townKeys(target).forEach(key => {\n\t\t\tres[key] = Object.getOwnPropertyDescriptor(target, key)\n\t\t})\n\t\treturn res\n\t}\n\nexport function each(\n\tobj: T,\n\titer: (key: string | number, value: any, source: T) => void,\n\tenumerableOnly?: boolean\n): void\nexport function each(obj: any, iter: any, enumerableOnly = false) {\n\tif (getArchtype(obj) === Archtype.Object) {\n\t\t;(enumerableOnly ? Object.keys : ownKeys)(obj).forEach(key => {\n\t\t\tif (!enumerableOnly || typeof key !== \"symbol\") iter(key, obj[key], obj)\n\t\t})\n\t} else {\n\t\tobj.forEach((entry: any, index: any) => iter(index, entry, obj))\n\t}\n}\n\n/*#__PURE__*/\nexport function getArchtype(thing: any): Archtype {\n\t/* istanbul ignore next */\n\tconst state: undefined | ImmerState = thing[DRAFT_STATE]\n\treturn state\n\t\t? state.type_ > 3\n\t\t\t? state.type_ - 4 // cause Object and Array map back from 4 and 5\n\t\t\t: (state.type_ as any) // others are the same\n\t\t: Array.isArray(thing)\n\t\t? Archtype.Array\n\t\t: isMap(thing)\n\t\t? Archtype.Map\n\t\t: isSet(thing)\n\t\t? Archtype.Set\n\t\t: Archtype.Object\n}\n\n/*#__PURE__*/\nexport function has(thing: any, prop: PropertyKey): boolean {\n\treturn getArchtype(thing) === Archtype.Map\n\t\t? thing.has(prop)\n\t\t: Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\n/*#__PURE__*/\nexport function get(thing: AnyMap | AnyObject, prop: PropertyKey): any {\n\t// @ts-ignore\n\treturn getArchtype(thing) === Archtype.Map ? thing.get(prop) : thing[prop]\n}\n\n/*#__PURE__*/\nexport function set(thing: any, propOrOldValue: PropertyKey, value: any) {\n\tconst t = getArchtype(thing)\n\tif (t === Archtype.Map) thing.set(propOrOldValue, value)\n\telse if (t === Archtype.Set) {\n\t\tthing.delete(propOrOldValue)\n\t\tthing.add(value)\n\t} else thing[propOrOldValue] = value\n}\n\n/*#__PURE__*/\nexport function is(x: any, y: any): boolean {\n\t// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n\tif (x === y) {\n\t\treturn x !== 0 || 1 / x === 1 / y\n\t} else {\n\t\treturn x !== x && y !== y\n\t}\n}\n\n/*#__PURE__*/\nexport function isMap(target: any): target is AnyMap {\n\treturn hasMap && target instanceof Map\n}\n\n/*#__PURE__*/\nexport function isSet(target: any): target is AnySet {\n\treturn hasSet && target instanceof Set\n}\n/*#__PURE__*/\nexport function latest(state: ImmerState): any {\n\treturn state.copy_ || state.base_\n}\n\n/*#__PURE__*/\nexport function shallowCopy(base: any) {\n\tif (Array.isArray(base)) return Array.prototype.slice.call(base)\n\tconst descriptors = getOwnPropertyDescriptors(base)\n\tdelete descriptors[DRAFT_STATE as any]\n\tlet keys = ownKeys(descriptors)\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tconst key: any = keys[i]\n\t\tconst desc = descriptors[key]\n\t\tif (desc.writable === false) {\n\t\t\tdesc.writable = true\n\t\t\tdesc.configurable = true\n\t\t}\n\t\t// like object.assign, we will read any _own_, get/set accessors. This helps in dealing\n\t\t// with libraries that trap values, like mobx or vue\n\t\t// unlike object.assign, non-enumerables will be copied as well\n\t\tif (desc.get || desc.set)\n\t\t\tdescriptors[key] = {\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true, // could live with !!desc.set as well here...\n\t\t\t\tenumerable: desc.enumerable,\n\t\t\t\tvalue: base[key]\n\t\t\t}\n\t}\n\treturn Object.create(Object.getPrototypeOf(base), descriptors)\n}\n\n/**\n * Freezes draftable objects. Returns the original object.\n * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.\n *\n * @param obj\n * @param deep\n */\nexport function freeze(obj: T, deep?: boolean): T\nexport function freeze(obj: any, deep: boolean = false): T {\n\tif (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj\n\tif (getArchtype(obj) > 1 /* Map or Set */) {\n\t\tobj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any\n\t}\n\tObject.freeze(obj)\n\tif (deep) each(obj, (key, value) => freeze(value, true), true)\n\treturn obj\n}\n\nfunction dontMutateFrozenCollections() {\n\tdie(2)\n}\n\nexport function isFrozen(obj: any): boolean {\n\tif (obj == null || typeof obj !== \"object\") return true\n\t// See #600, IE dies on non-objects in Object.isFrozen\n\treturn Object.isFrozen(obj)\n}\n","import {\n\tImmerState,\n\tPatch,\n\tImmerScope,\n\tDrafted,\n\tAnyObject,\n\tImmerBaseState,\n\tAnyMap,\n\tAnySet,\n\tProxyType,\n\tdie\n} from \"../internal\"\n\n/** Plugin utilities */\nconst plugins: {\n\tPatches?: {\n\t\tgeneratePatches_(\n\t\t\tstate: ImmerState,\n\t\t\tbasePath: PatchPath,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tgenerateReplacementPatches_(\n\t\t\tbase: any,\n\t\t\treplacement: any,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tapplyPatches_(draft: T, patches: Patch[]): T\n\t}\n\tES5?: {\n\t\twillFinalizeES5_(scope: ImmerScope, result: any, isReplaced: boolean): void\n\t\tcreateES5Proxy_(\n\t\t\tbase: T,\n\t\t\tparent?: ImmerState\n\t\t): Drafted\n\t\thasChanges_(state: ES5ArrayState | ES5ObjectState): boolean\n\t}\n\tMapSet?: {\n\t\tproxyMap_(target: T, parent?: ImmerState): T\n\t\tproxySet_(target: T, parent?: ImmerState): T\n\t}\n} = {}\n\ntype Plugins = typeof plugins\n\nexport function getPlugin(\n\tpluginKey: K\n): Exclude {\n\tconst plugin = plugins[pluginKey]\n\tif (!plugin) {\n\t\tdie(18, pluginKey)\n\t}\n\t// @ts-ignore\n\treturn plugin\n}\n\nexport function loadPlugin(\n\tpluginKey: K,\n\timplementation: Plugins[K]\n): void {\n\tif (!plugins[pluginKey]) plugins[pluginKey] = implementation\n}\n\n/** ES5 Plugin */\n\ninterface ES5BaseState extends ImmerBaseState {\n\tassigned_: {[key: string]: any}\n\tparent_?: ImmerState\n\trevoked_: boolean\n}\n\nexport interface ES5ObjectState extends ES5BaseState {\n\ttype_: ProxyType.ES5Object\n\tdraft_: Drafted\n\tbase_: AnyObject\n\tcopy_: AnyObject | null\n}\n\nexport interface ES5ArrayState extends ES5BaseState {\n\ttype_: ProxyType.ES5Array\n\tdraft_: Drafted\n\tbase_: any\n\tcopy_: any\n}\n\n/** Map / Set plugin */\n\nexport interface MapState extends ImmerBaseState {\n\ttype_: ProxyType.Map\n\tcopy_: AnyMap | undefined\n\tassigned_: Map | undefined\n\tbase_: AnyMap\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\nexport interface SetState extends ImmerBaseState {\n\ttype_: ProxyType.Set\n\tcopy_: AnySet | undefined\n\tbase_: AnySet\n\tdrafts_: Map // maps the original value to the draft value in the new set\n\trevoked_: boolean\n\tdraft_: Drafted\n}\n\n/** Patches plugin */\n\nexport type PatchPath = (string | number)[]\n","import {\n\tPatch,\n\tPatchListener,\n\tDrafted,\n\tImmer,\n\tDRAFT_STATE,\n\tImmerState,\n\tProxyType,\n\tgetPlugin\n} from \"../internal\"\nimport {die} from \"../utils/errors\"\n\n/** Each scope represents a `produce` call. */\n\nexport interface ImmerScope {\n\tpatches_?: Patch[]\n\tinversePatches_?: Patch[]\n\tcanAutoFreeze_: boolean\n\tdrafts_: any[]\n\tparent_?: ImmerScope\n\tpatchListener_?: PatchListener\n\timmer_: Immer\n\tunfinalizedDrafts_: number\n}\n\nlet currentScope: ImmerScope | undefined\n\nexport function getCurrentScope() {\n\tif (__DEV__ && !currentScope) die(0)\n\treturn currentScope!\n}\n\nfunction createScope(\n\tparent_: ImmerScope | undefined,\n\timmer_: Immer\n): ImmerScope {\n\treturn {\n\t\tdrafts_: [],\n\t\tparent_,\n\t\timmer_,\n\t\t// Whenever the modified draft contains a draft from another scope, we\n\t\t// need to prevent auto-freezing so the unowned draft can be finalized.\n\t\tcanAutoFreeze_: true,\n\t\tunfinalizedDrafts_: 0\n\t}\n}\n\nexport function usePatchesInScope(\n\tscope: ImmerScope,\n\tpatchListener?: PatchListener\n) {\n\tif (patchListener) {\n\t\tgetPlugin(\"Patches\") // assert we have the plugin\n\t\tscope.patches_ = []\n\t\tscope.inversePatches_ = []\n\t\tscope.patchListener_ = patchListener\n\t}\n}\n\nexport function revokeScope(scope: ImmerScope) {\n\tleaveScope(scope)\n\tscope.drafts_.forEach(revokeDraft)\n\t// @ts-ignore\n\tscope.drafts_ = null\n}\n\nexport function leaveScope(scope: ImmerScope) {\n\tif (scope === currentScope) {\n\t\tcurrentScope = scope.parent_\n\t}\n}\n\nexport function enterScope(immer: Immer) {\n\treturn (currentScope = createScope(currentScope, immer))\n}\n\nfunction revokeDraft(draft: Drafted) {\n\tconst state: ImmerState = draft[DRAFT_STATE]\n\tif (\n\t\tstate.type_ === ProxyType.ProxyObject ||\n\t\tstate.type_ === ProxyType.ProxyArray\n\t)\n\t\tstate.revoke_()\n\telse state.revoked_ = true\n}\n","import {\n\tImmerScope,\n\tDRAFT_STATE,\n\tisDraftable,\n\tNOTHING,\n\tPatchPath,\n\teach,\n\thas,\n\tfreeze,\n\tImmerState,\n\tisDraft,\n\tSetState,\n\tset,\n\tProxyType,\n\tgetPlugin,\n\tdie,\n\trevokeScope,\n\tisFrozen,\n\tshallowCopy\n} from \"../internal\"\n\nexport function processResult(result: any, scope: ImmerScope) {\n\tscope.unfinalizedDrafts_ = scope.drafts_.length\n\tconst baseDraft = scope.drafts_![0]\n\tconst isReplaced = result !== undefined && result !== baseDraft\n\tif (!scope.immer_.useProxies_)\n\t\tgetPlugin(\"ES5\").willFinalizeES5_(scope, result, isReplaced)\n\tif (isReplaced) {\n\t\tif (baseDraft[DRAFT_STATE].modified_) {\n\t\t\trevokeScope(scope)\n\t\t\tdie(4)\n\t\t}\n\t\tif (isDraftable(result)) {\n\t\t\t// Finalize the result in case it contains (or is) a subset of the draft.\n\t\t\tresult = finalize(scope, result)\n\t\t\tif (!scope.parent_) maybeFreeze(scope, result)\n\t\t}\n\t\tif (scope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(\n\t\t\t\tbaseDraft[DRAFT_STATE].base_,\n\t\t\t\tresult,\n\t\t\t\tscope.patches_,\n\t\t\t\tscope.inversePatches_!\n\t\t\t)\n\t\t}\n\t} else {\n\t\t// Finalize the base draft.\n\t\tresult = finalize(scope, baseDraft, [])\n\t}\n\trevokeScope(scope)\n\tif (scope.patches_) {\n\t\tscope.patchListener_!(scope.patches_, scope.inversePatches_!)\n\t}\n\treturn result !== NOTHING ? result : undefined\n}\n\nfunction finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {\n\t// Don't recurse in tho recursive data structures\n\tif (isFrozen(value)) return value\n\n\tconst state: ImmerState = value[DRAFT_STATE]\n\t// A plain object, might need freezing, might contain drafts\n\tif (!state) {\n\t\teach(\n\t\t\tvalue,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, value, key, childValue, path),\n\t\t\ttrue // See #590, don't recurse into non-enumerable of non drafted objects\n\t\t)\n\t\treturn value\n\t}\n\t// Never finalize drafts owned by another scope.\n\tif (state.scope_ !== rootScope) return value\n\t// Unmodified draft, return the (frozen) original\n\tif (!state.modified_) {\n\t\tmaybeFreeze(rootScope, state.base_, true)\n\t\treturn state.base_\n\t}\n\t// Not finalized yet, let's do that now\n\tif (!state.finalized_) {\n\t\tstate.finalized_ = true\n\t\tstate.scope_.unfinalizedDrafts_--\n\t\tconst result =\n\t\t\t// For ES5, create a good copy from the draft first, with added keys and without deleted keys.\n\t\t\tstate.type_ === ProxyType.ES5Object || state.type_ === ProxyType.ES5Array\n\t\t\t\t? (state.copy_ = shallowCopy(state.draft_))\n\t\t\t\t: state.copy_\n\t\t// Finalize all children of the copy\n\t\t// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628\n\t\t// Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line\n\t\t// back to each(result, ....)\n\t\teach(\n\t\t\tstate.type_ === ProxyType.Set ? new Set(result) : result,\n\t\t\t(key, childValue) =>\n\t\t\t\tfinalizeProperty(rootScope, state, result, key, childValue, path)\n\t\t)\n\t\t// everything inside is frozen, we can freeze here\n\t\tmaybeFreeze(rootScope, result, false)\n\t\t// first time finalizing, let's create those patches\n\t\tif (path && rootScope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generatePatches_(\n\t\t\t\tstate,\n\t\t\t\tpath,\n\t\t\t\trootScope.patches_,\n\t\t\t\trootScope.inversePatches_!\n\t\t\t)\n\t\t}\n\t}\n\treturn state.copy_\n}\n\nfunction finalizeProperty(\n\trootScope: ImmerScope,\n\tparentState: undefined | ImmerState,\n\ttargetObject: any,\n\tprop: string | number,\n\tchildValue: any,\n\trootPath?: PatchPath\n) {\n\tif (__DEV__ && childValue === targetObject) die(5)\n\tif (isDraft(childValue)) {\n\t\tconst path =\n\t\t\trootPath &&\n\t\t\tparentState &&\n\t\t\tparentState!.type_ !== ProxyType.Set && // Set objects are atomic since they have no keys.\n\t\t\t!has((parentState as Exclude).assigned_!, prop) // Skip deep patches for assigned keys.\n\t\t\t\t? rootPath!.concat(prop)\n\t\t\t\t: undefined\n\t\t// Drafts owned by `scope` are finalized here.\n\t\tconst res = finalize(rootScope, childValue, path)\n\t\tset(targetObject, prop, res)\n\t\t// Drafts from another scope must prevented to be frozen\n\t\t// if we got a draft back from finalize, we're in a nested produce and shouldn't freeze\n\t\tif (isDraft(res)) {\n\t\t\trootScope.canAutoFreeze_ = false\n\t\t} else return\n\t}\n\t// Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n\tif (isDraftable(childValue) && !isFrozen(childValue)) {\n\t\tif (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {\n\t\t\t// optimization: if an object is not a draft, and we don't have to\n\t\t\t// deepfreeze everything, and we are sure that no drafts are left in the remaining object\n\t\t\t// cause we saw and finalized all drafts already; we can stop visiting the rest of the tree.\n\t\t\t// This benefits especially adding large data tree's without further processing.\n\t\t\t// See add-data.js perf test\n\t\t\treturn\n\t\t}\n\t\tfinalize(rootScope, childValue)\n\t\t// immer deep freezes plain objects, so if there is no parent state, we freeze as well\n\t\tif (!parentState || !parentState.scope_.parent_)\n\t\t\tmaybeFreeze(rootScope, childValue)\n\t}\n}\n\nfunction maybeFreeze(scope: ImmerScope, value: any, deep = false) {\n\tif (scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {\n\t\tfreeze(value, deep)\n\t}\n}\n","import {\n\teach,\n\thas,\n\tis,\n\tisDraftable,\n\tshallowCopy,\n\tlatest,\n\tImmerBaseState,\n\tImmerState,\n\tDrafted,\n\tAnyObject,\n\tAnyArray,\n\tObjectish,\n\tgetCurrentScope,\n\tDRAFT_STATE,\n\tdie,\n\tcreateProxy,\n\tProxyType\n} from \"../internal\"\n\ninterface ProxyBaseState extends ImmerBaseState {\n\tassigned_: {\n\t\t[property: string]: boolean\n\t}\n\tparent_?: ImmerState\n\trevoke_(): void\n}\n\nexport interface ProxyObjectState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyObject\n\tbase_: any\n\tcopy_: any\n\tdraft_: Drafted\n}\n\nexport interface ProxyArrayState extends ProxyBaseState {\n\ttype_: ProxyType.ProxyArray\n\tbase_: AnyArray\n\tcopy_: AnyArray | null\n\tdraft_: Drafted\n}\n\ntype ProxyState = ProxyObjectState | ProxyArrayState\n\n/**\n * Returns a new draft of the `base` object.\n *\n * The second argument is the parent draft-state (used internally).\n */\nexport function createProxyProxy(\n\tbase: T,\n\tparent?: ImmerState\n): Drafted {\n\tconst isArray = Array.isArray(base)\n\tconst state: ProxyState = {\n\t\ttype_: isArray ? ProxyType.ProxyArray : (ProxyType.ProxyObject as any),\n\t\t// Track which produce call this is associated with.\n\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t// True for both shallow and deep changes.\n\t\tmodified_: false,\n\t\t// Used during finalization.\n\t\tfinalized_: false,\n\t\t// Track which properties have been assigned (true) or deleted (false).\n\t\tassigned_: {},\n\t\t// The parent draft state.\n\t\tparent_: parent,\n\t\t// The base state.\n\t\tbase_: base,\n\t\t// The base proxy.\n\t\tdraft_: null as any, // set below\n\t\t// The base copy with any updated values.\n\t\tcopy_: null,\n\t\t// Called by the `produce` function.\n\t\trevoke_: null as any,\n\t\tisManual_: false\n\t}\n\n\t// the traps must target something, a bit like the 'real' base.\n\t// but also, we need to be able to determine from the target what the relevant state is\n\t// (to avoid creating traps per instance to capture the state in closure,\n\t// and to avoid creating weird hidden properties as well)\n\t// So the trick is to use 'state' as the actual 'target'! (and make sure we intercept everything)\n\t// Note that in the case of an array, we put the state in an array to have better Reflect defaults ootb\n\tlet target: T = state as any\n\tlet traps: ProxyHandler> = objectTraps\n\tif (isArray) {\n\t\ttarget = [state] as any\n\t\ttraps = arrayTraps\n\t}\n\n\tconst {revoke, proxy} = Proxy.revocable(target, traps)\n\tstate.draft_ = proxy as any\n\tstate.revoke_ = revoke\n\treturn proxy as any\n}\n\n/**\n * Object drafts\n */\nexport const objectTraps: ProxyHandler = {\n\tget(state, prop) {\n\t\tif (prop === DRAFT_STATE) return state\n\n\t\tconst source = latest(state)\n\t\tif (!has(source, prop)) {\n\t\t\t// non-existing or non-own property...\n\t\t\treturn readPropFromProto(state, source, prop)\n\t\t}\n\t\tconst value = source[prop]\n\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\treturn value\n\t\t}\n\t\t// Check for existing draft in modified state.\n\t\t// Assigned values are never drafted. This catches any drafts we created, too.\n\t\tif (value === peek(state.base_, prop)) {\n\t\t\tprepareCopy(state)\n\t\t\treturn (state.copy_![prop as any] = createProxy(\n\t\t\t\tstate.scope_.immer_,\n\t\t\t\tvalue,\n\t\t\t\tstate\n\t\t\t))\n\t\t}\n\t\treturn value\n\t},\n\thas(state, prop) {\n\t\treturn prop in latest(state)\n\t},\n\townKeys(state) {\n\t\treturn Reflect.ownKeys(latest(state))\n\t},\n\tset(\n\t\tstate: ProxyObjectState,\n\t\tprop: string /* strictly not, but helps TS */,\n\t\tvalue\n\t) {\n\t\tconst desc = getDescriptorFromProto(latest(state), prop)\n\t\tif (desc?.set) {\n\t\t\t// special case: if this write is captured by a setter, we have\n\t\t\t// to trigger it with the correct context\n\t\t\tdesc.set.call(state.draft_, value)\n\t\t\treturn true\n\t\t}\n\t\tif (!state.modified_) {\n\t\t\t// the last check is because we need to be able to distinguish setting a non-existing to undefined (which is a change)\n\t\t\t// from setting an existing property with value undefined to undefined (which is not a change)\n\t\t\tconst current = peek(latest(state), prop)\n\t\t\t// special case, if we assigning the original value to a draft, we can ignore the assignment\n\t\t\tconst currentState: ProxyObjectState = current?.[DRAFT_STATE]\n\t\t\tif (currentState && currentState.base_ === value) {\n\t\t\t\tstate.copy_![prop] = value\n\t\t\t\tstate.assigned_[prop] = false\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (is(value, current) && (value !== undefined || has(state.base_, prop)))\n\t\t\t\treturn true\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t}\n\n\t\tif (\n\t\t\tstate.copy_![prop] === value &&\n\t\t\t// special case: NaN\n\t\t\ttypeof value !== \"number\" &&\n\t\t\t// special case: handle new props with value 'undefined'\n\t\t\t(value !== undefined || prop in state.copy_)\n\t\t)\n\t\t\treturn true\n\n\t\t// @ts-ignore\n\t\tstate.copy_![prop] = value\n\t\tstate.assigned_[prop] = true\n\t\treturn true\n\t},\n\tdeleteProperty(state, prop: string) {\n\t\t// The `undefined` check is a fast path for pre-existing keys.\n\t\tif (peek(state.base_, prop) !== undefined || prop in state.base_) {\n\t\t\tstate.assigned_[prop] = false\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t} else {\n\t\t\t// if an originally not assigned property was deleted\n\t\t\tdelete state.assigned_[prop]\n\t\t}\n\t\t// @ts-ignore\n\t\tif (state.copy_) delete state.copy_[prop]\n\t\treturn true\n\t},\n\t// Note: We never coerce `desc.value` into an Immer draft, because we can't make\n\t// the same guarantee in ES5 mode.\n\tgetOwnPropertyDescriptor(state, prop) {\n\t\tconst owner = latest(state)\n\t\tconst desc = Reflect.getOwnPropertyDescriptor(owner, prop)\n\t\tif (!desc) return desc\n\t\treturn {\n\t\t\twritable: true,\n\t\t\tconfigurable: state.type_ !== ProxyType.ProxyArray || prop !== \"length\",\n\t\t\tenumerable: desc.enumerable,\n\t\t\tvalue: owner[prop]\n\t\t}\n\t},\n\tdefineProperty() {\n\t\tdie(11)\n\t},\n\tgetPrototypeOf(state) {\n\t\treturn Object.getPrototypeOf(state.base_)\n\t},\n\tsetPrototypeOf() {\n\t\tdie(12)\n\t}\n}\n\n/**\n * Array drafts\n */\n\nconst arrayTraps: ProxyHandler<[ProxyArrayState]> = {}\neach(objectTraps, (key, fn) => {\n\t// @ts-ignore\n\tarrayTraps[key] = function() {\n\t\targuments[0] = arguments[0][0]\n\t\treturn fn.apply(this, arguments)\n\t}\n})\narrayTraps.deleteProperty = function(state, prop) {\n\tif (__DEV__ && isNaN(parseInt(prop as any))) die(13)\n\t// @ts-ignore\n\treturn arrayTraps.set!.call(this, state, prop, undefined)\n}\narrayTraps.set = function(state, prop, value) {\n\tif (__DEV__ && prop !== \"length\" && isNaN(parseInt(prop as any))) die(14)\n\treturn objectTraps.set!.call(this, state[0], prop, value, state[0])\n}\n\n// Access a property without creating an Immer draft.\nfunction peek(draft: Drafted, prop: PropertyKey) {\n\tconst state = draft[DRAFT_STATE]\n\tconst source = state ? latest(state) : draft\n\treturn source[prop]\n}\n\nfunction readPropFromProto(state: ImmerState, source: any, prop: PropertyKey) {\n\tconst desc = getDescriptorFromProto(source, prop)\n\treturn desc\n\t\t? `value` in desc\n\t\t\t? desc.value\n\t\t\t: // This is a very special case, if the prop is a getter defined by the\n\t\t\t // prototype, we should invoke it with the draft as context!\n\t\t\t desc.get?.call(state.draft_)\n\t\t: undefined\n}\n\nfunction getDescriptorFromProto(\n\tsource: any,\n\tprop: PropertyKey\n): PropertyDescriptor | undefined {\n\t// 'in' checks proto!\n\tif (!(prop in source)) return undefined\n\tlet proto = Object.getPrototypeOf(source)\n\twhile (proto) {\n\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\tif (desc) return desc\n\t\tproto = Object.getPrototypeOf(proto)\n\t}\n\treturn undefined\n}\n\nexport function markChanged(state: ImmerState) {\n\tif (!state.modified_) {\n\t\tstate.modified_ = true\n\t\tif (state.parent_) {\n\t\t\tmarkChanged(state.parent_)\n\t\t}\n\t}\n}\n\nexport function prepareCopy(state: {base_: any; copy_: any}) {\n\tif (!state.copy_) {\n\t\tstate.copy_ = shallowCopy(state.base_)\n\t}\n}\n","import {\n\tIProduceWithPatches,\n\tIProduce,\n\tImmerState,\n\tDrafted,\n\tisDraftable,\n\tprocessResult,\n\tPatch,\n\tObjectish,\n\tDRAFT_STATE,\n\tDraft,\n\tPatchListener,\n\tisDraft,\n\tisMap,\n\tisSet,\n\tcreateProxyProxy,\n\tgetPlugin,\n\tdie,\n\thasProxies,\n\tenterScope,\n\trevokeScope,\n\tleaveScope,\n\tusePatchesInScope,\n\tgetCurrentScope,\n\tNOTHING,\n\tfreeze,\n\tcurrent\n} from \"../internal\"\n\ninterface ProducersFns {\n\tproduce: IProduce\n\tproduceWithPatches: IProduceWithPatches\n}\n\nexport class Immer implements ProducersFns {\n\tuseProxies_: boolean = hasProxies\n\n\tautoFreeze_: boolean = true\n\n\tconstructor(config?: {useProxies?: boolean; autoFreeze?: boolean}) {\n\t\tif (typeof config?.useProxies === \"boolean\")\n\t\t\tthis.setUseProxies(config!.useProxies)\n\t\tif (typeof config?.autoFreeze === \"boolean\")\n\t\t\tthis.setAutoFreeze(config!.autoFreeze)\n\t}\n\n\t/**\n\t * The `produce` function takes a value and a \"recipe function\" (whose\n\t * return value often depends on the base state). The recipe function is\n\t * free to mutate its first argument however it wants. All mutations are\n\t * only ever applied to a __copy__ of the base state.\n\t *\n\t * Pass only a function to create a \"curried producer\" which relieves you\n\t * from passing the recipe function every time.\n\t *\n\t * Only plain objects and arrays are made mutable. All other objects are\n\t * considered uncopyable.\n\t *\n\t * Note: This function is __bound__ to its `Immer` instance.\n\t *\n\t * @param {any} base - the initial state\n\t * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n\t * @param {Function} patchListener - optional function that will be called with all the patches produced here\n\t * @returns {any} a new state, or the initial state if nothing was modified\n\t */\n\tproduce: IProduce = (base: any, recipe?: any, patchListener?: any) => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\" && typeof recipe !== \"function\") {\n\t\t\tconst defaultBase = recipe\n\t\t\trecipe = base\n\n\t\t\tconst self = this\n\t\t\treturn function curriedProduce(\n\t\t\t\tthis: any,\n\t\t\t\tbase = defaultBase,\n\t\t\t\t...args: any[]\n\t\t\t) {\n\t\t\t\treturn self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore\n\t\t\t}\n\t\t}\n\n\t\tif (typeof recipe !== \"function\") die(6)\n\t\tif (patchListener !== undefined && typeof patchListener !== \"function\")\n\t\t\tdie(7)\n\n\t\tlet result\n\n\t\t// Only plain objects, arrays, and \"immerable classes\" are drafted.\n\t\tif (isDraftable(base)) {\n\t\t\tconst scope = enterScope(this)\n\t\t\tconst proxy = createProxy(this, base, undefined)\n\t\t\tlet hasError = true\n\t\t\ttry {\n\t\t\t\tresult = recipe(proxy)\n\t\t\t\thasError = false\n\t\t\t} finally {\n\t\t\t\t// finally instead of catch + rethrow better preserves original stack\n\t\t\t\tif (hasError) revokeScope(scope)\n\t\t\t\telse leaveScope(scope)\n\t\t\t}\n\t\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\tresult => {\n\t\t\t\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\t\t\t\treturn processResult(result, scope)\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\trevokeScope(scope)\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t}\n\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\treturn processResult(result, scope)\n\t\t} else if (!base || typeof base !== \"object\") {\n\t\t\tresult = recipe(base)\n\t\t\tif (result === undefined) result = base\n\t\t\tif (result === NOTHING) result = undefined\n\t\t\tif (this.autoFreeze_) freeze(result, true)\n\t\t\tif (patchListener) {\n\t\t\t\tconst p: Patch[] = []\n\t\t\t\tconst ip: Patch[] = []\n\t\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(base, result, p, ip)\n\t\t\t\tpatchListener(p, ip)\n\t\t\t}\n\t\t\treturn result\n\t\t} else die(21, base)\n\t}\n\n\tproduceWithPatches: IProduceWithPatches = (\n\t\tbase: any,\n\t\trecipe?: any,\n\t): any => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\") {\n\t\t\treturn (state: any, ...args: any[]) =>\n\t\t\t\tthis.produceWithPatches(state, (draft: any) => base(draft, ...args))\n\t\t}\n\n\t\tlet patches: Patch[], inversePatches: Patch[]\n\t\tconst result = this.produce(base, recipe, (p: Patch[], ip: Patch[]) => {\n\t\t\tpatches = p\n\t\t\tinversePatches = ip\n\t\t})\n\n\t\tif (typeof Promise !== \"undefined\" && result instanceof Promise) {\n\t\t\treturn result.then(nextState => [nextState, patches!, inversePatches!])\n\t\t}\n\t\treturn [result, patches!, inversePatches!]\n\t}\n\n\tcreateDraft(base: T): Draft {\n\t\tif (!isDraftable(base)) die(8)\n\t\tif (isDraft(base)) base = current(base)\n\t\tconst scope = enterScope(this)\n\t\tconst proxy = createProxy(this, base, undefined)\n\t\tproxy[DRAFT_STATE].isManual_ = true\n\t\tleaveScope(scope)\n\t\treturn proxy as any\n\t}\n\n\tfinishDraft>(\n\t\tdraft: D,\n\t\tpatchListener?: PatchListener\n\t): D extends Draft ? T : never {\n\t\tconst state: ImmerState = draft && (draft as any)[DRAFT_STATE]\n\t\tif (__DEV__) {\n\t\t\tif (!state || !state.isManual_) die(9)\n\t\t\tif (state.finalized_) die(10)\n\t\t}\n\t\tconst {scope_: scope} = state\n\t\tusePatchesInScope(scope, patchListener)\n\t\treturn processResult(undefined, scope)\n\t}\n\n\t/**\n\t * Pass true to automatically freeze all copies created by Immer.\n\t *\n\t * By default, auto-freezing is enabled.\n\t */\n\tsetAutoFreeze(value: boolean) {\n\t\tthis.autoFreeze_ = value\n\t}\n\n\t/**\n\t * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n\t * always faster than using ES5 proxies.\n\t *\n\t * By default, feature detection is used, so calling this is rarely necessary.\n\t */\n\tsetUseProxies(value: boolean) {\n\t\tif (value && !hasProxies) {\n\t\t\tdie(20)\n\t\t}\n\t\tthis.useProxies_ = value\n\t}\n\n\tapplyPatches(base: T, patches: Patch[]): T {\n\t\t// If a patch replaces the entire state, take that replacement as base\n\t\t// before applying patches\n\t\tlet i: number\n\t\tfor (i = patches.length - 1; i >= 0; i--) {\n\t\t\tconst patch = patches[i]\n\t\t\tif (patch.path.length === 0 && patch.op === \"replace\") {\n\t\t\t\tbase = patch.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// If there was a patch that replaced the entire state, start from the\n\t\t// patch after that.\n\t\tif (i > -1) {\n\t\t\tpatches = patches.slice(i + 1)\n\t\t}\n\n\t\tconst applyPatchesImpl = getPlugin(\"Patches\").applyPatches_\n\t\tif (isDraft(base)) {\n\t\t\t// N.B: never hits if some patch a replacement, patches are never drafts\n\t\t\treturn applyPatchesImpl(base, patches)\n\t\t}\n\t\t// Otherwise, produce a copy of the base state.\n\t\treturn this.produce(base, (draft: Drafted) =>\n\t\t\tapplyPatchesImpl(draft, patches)\n\t\t)\n\t}\n}\n\nexport function createProxy(\n\timmer: Immer,\n\tvalue: T,\n\tparent?: ImmerState\n): Drafted {\n\t// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft\n\tconst draft: Drafted = isMap(value)\n\t\t? getPlugin(\"MapSet\").proxyMap_(value, parent)\n\t\t: isSet(value)\n\t\t? getPlugin(\"MapSet\").proxySet_(value, parent)\n\t\t: immer.useProxies_\n\t\t? createProxyProxy(value, parent)\n\t\t: getPlugin(\"ES5\").createES5Proxy_(value, parent)\n\n\tconst scope = parent ? parent.scope_ : getCurrentScope()\n\tscope.drafts_.push(draft)\n\treturn draft\n}\n","import {\n\tdie,\n\tisDraft,\n\tshallowCopy,\n\teach,\n\tDRAFT_STATE,\n\tget,\n\tset,\n\tImmerState,\n\tisDraftable,\n\tArchtype,\n\tgetArchtype,\n\tgetPlugin\n} from \"../internal\"\n\n/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */\nexport function current(value: T): T\nexport function current(value: any): any {\n\tif (!isDraft(value)) die(22, value)\n\treturn currentImpl(value)\n}\n\nfunction currentImpl(value: any): any {\n\tif (!isDraftable(value)) return value\n\tconst state: ImmerState | undefined = value[DRAFT_STATE]\n\tlet copy: any\n\tconst archType = getArchtype(value)\n\tif (state) {\n\t\tif (\n\t\t\t!state.modified_ &&\n\t\t\t(state.type_ < 4 || !getPlugin(\"ES5\").hasChanges_(state as any))\n\t\t)\n\t\t\treturn state.base_\n\t\t// Optimization: avoid generating new drafts during copying\n\t\tstate.finalized_ = true\n\t\tcopy = copyHelper(value, archType)\n\t\tstate.finalized_ = false\n\t} else {\n\t\tcopy = copyHelper(value, archType)\n\t}\n\n\teach(copy, (key, childValue) => {\n\t\tif (state && get(state.base_, key) === childValue) return // no need to copy or search in something that didn't change\n\t\tset(copy, key, currentImpl(childValue))\n\t})\n\t// In the future, we might consider freezing here, based on the current settings\n\treturn archType === Archtype.Set ? new Set(copy) : copy\n}\n\nfunction copyHelper(value: any, archType: number): any {\n\t// creates a shallow copy, even if it is a map or set\n\tswitch (archType) {\n\t\tcase Archtype.Map:\n\t\t\treturn new Map(value)\n\t\tcase Archtype.Set:\n\t\t\t// Set will be cloned as array temporarily, so that we can replace individual items\n\t\t\treturn Array.from(value)\n\t}\n\treturn shallowCopy(value)\n}\n","import {\n\tIProduce,\n\tIProduceWithPatches,\n\tImmer,\n\tDraft,\n\tImmutable\n} from \"./internal\"\n\nexport {\n\tDraft,\n\tImmutable,\n\tPatch,\n\tPatchListener,\n\toriginal,\n\tcurrent,\n\tisDraft,\n\tisDraftable,\n\tNOTHING as nothing,\n\tDRAFTABLE as immerable,\n\tfreeze\n} from \"./internal\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce: IProduce = immer.produce\nexport default produce\n\n/**\n * Like `produce`, but `produceWithPatches` always returns a tuple\n * [nextState, patches, inversePatches] (instead of just the next state)\n */\nexport const produceWithPatches: IProduceWithPatches = immer.produceWithPatches.bind(\n\timmer\n)\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * Always freeze by default, even in production mode\n */\nexport const setAutoFreeze = immer.setAutoFreeze.bind(immer)\n\n/**\n * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n * always faster than using ES5 proxies.\n *\n * By default, feature detection is used, so calling this is rarely necessary.\n */\nexport const setUseProxies = immer.setUseProxies.bind(immer)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = immer.applyPatches.bind(immer)\n\n/**\n * Create an Immer draft from the given base state, which may be a draft itself.\n * The draft can be modified until you finalize it with the `finishDraft` function.\n */\nexport const createDraft = immer.createDraft.bind(immer)\n\n/**\n * Finalize an Immer draft from a `createDraft` call, returning the base state\n * (if no changes were made) or a modified copy. The draft must *not* be\n * mutated afterwards.\n *\n * Pass a function as the 2nd argument to generate Immer patches based on the\n * changes that were made.\n */\nexport const finishDraft = immer.finishDraft.bind(immer)\n\n/**\n * This function is actually a no-op, but can be used to cast an immutable type\n * to an draft type and make TypeScript happy\n *\n * @param value\n */\nexport function castDraft(value: T): Draft {\n\treturn value as any\n}\n\n/**\n * This function is actually a no-op, but can be used to cast a mutable type\n * to an immutable type and make TypeScript happy\n * @param value\n */\nexport function castImmutable(value: T): Immutable {\n\treturn value as any\n}\n\nexport {Immer}\n\nexport {enableES5} from \"./plugins/es5\"\nexport {enablePatches} from \"./plugins/patches\"\nexport {enableMapSet} from \"./plugins/mapset\"\nexport {enableAllPlugins} from \"./plugins/all\"\n","// Should be no imports here!\n\n// Some things that should be evaluated before all else...\n\n// We only want to know if non-polyfilled symbols are available\nconst hasSymbol =\n\ttypeof Symbol !== \"undefined\" && typeof Symbol(\"x\") === \"symbol\"\nexport const hasMap = typeof Map !== \"undefined\"\nexport const hasSet = typeof Set !== \"undefined\"\nexport const hasProxies =\n\ttypeof Proxy !== \"undefined\" &&\n\ttypeof Proxy.revocable !== \"undefined\" &&\n\ttypeof Reflect !== \"undefined\"\n\n/**\n * The sentinel value returned by producers to replace the draft with undefined.\n */\nexport const NOTHING: Nothing = hasSymbol\n\t? Symbol.for(\"immer-nothing\")\n\t: ({[\"immer-nothing\"]: true} as any)\n\n/**\n * To let Immer treat your class instances as plain immutable objects\n * (albeit with a custom prototype), you must define either an instance property\n * or a static property on each of your custom classes.\n *\n * Otherwise, your class instance will never be drafted, which means it won't be\n * safe to mutate in a produce callback.\n */\nexport const DRAFTABLE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-draftable\")\n\t: (\"__$immer_draftable\" as any)\n\nexport const DRAFT_STATE: unique symbol = hasSymbol\n\t? Symbol.for(\"immer-state\")\n\t: (\"__$immer_state\" as any)\n\n// Even a polyfilled Symbol might provide Symbol.iterator\nexport const iteratorSymbol: typeof Symbol.iterator =\n\t(typeof Symbol != \"undefined\" && Symbol.iterator) || (\"@@iterator\" as any)\n\n/** Use a class type for `nothing` so its type is unique */\nexport class Nothing {\n\t// This lets us do `Exclude`\n\t// @ts-ignore\n\tprivate _!: unique symbol\n}\n","import produce from \"immer\";\nimport { Dispatch, useEffect, useReducer, useState } from \"react\";\n\nexport function useImmerReducer<\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Reducers extends Record T | void>\n>(reducers: Reducers, initialState: T) {\n return useReducer(\n (\n state: T,\n command: {\n action: keyof Reducers;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n payload?: any;\n }\n ): T =>\n produce(state, (draft: T) => {\n reducers[command.action](draft, command.payload);\n }),\n initialState\n );\n}\n\nexport function useStateInitializer(init: T): [T, Dispatch] {\n const [state, setState] = useState(init);\n useEffect(() => {\n setState(init);\n }, [init]);\n return [state, setState];\n}\n","import { width } from \"@davidsouther/jiffies/lib/esm/dom/css/sizing.js\";\nimport { useCallback, useState } from \"react\";\nimport { useStateInitializer } from \"./react.js\";\n\nconst Mode = { VIEW: 0, EDIT: 1 };\n\nexport const InlineEdit = (props: {\n mode?: keyof typeof Mode;\n value: string;\n onChange: (value: string) => void;\n}) => {\n const [mode, setMode] = useState(props.mode ?? Mode.VIEW);\n const [value, setValue] = useStateInitializer(props.value);\n\n const render = () => {\n switch (mode) {\n case Mode.EDIT:\n return edit();\n case Mode.VIEW:\n return view();\n default:\n return ;\n }\n };\n\n const view = () => (\n {\n setMode(Mode.EDIT);\n }}\n >\n {value}\n \n );\n\n const doSelect = useCallback(\n (ref: HTMLInputElement | null) => ref?.select(),\n []\n );\n const doChange = useCallback(\n (target: HTMLInputElement) => {\n setMode(Mode.VIEW);\n setValue(target.value ?? \"\");\n props.onChange(target.value ?? \"\");\n },\n [props, setMode, setValue]\n );\n const edit = () => {\n const edit = (\n \n doChange(target)}\n onKeyPress={({ key, target }) => {\n if (key === \"Enter\") {\n doChange(target as HTMLInputElement);\n }\n }}\n type=\"text\"\n defaultValue={value}\n />\n \n );\n return edit;\n };\n\n return render();\n};\n\nexport default InlineEdit;\n","/* eslint-disable @typescript-eslint/ban-types */\nimport {\n Key,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from \"react\";\n\nexport interface VirtualScrollSettings {\n /**Minimum offset into the adapter. Default is 0. */\n minIndex: number;\n /** Maximum offset into the adapter. Default is Number.MAX_SAFE_INTEGER. */\n maxIndex: number;\n /** Initial index to start rendering from. Default is minIndex. */\n startIndex: number;\n /**\n * Number of items to render in visible area. Default is entire range from\n * minIndex to maxIndex.\n */\n count: number;\n /**\n * Maximum number of items to render on either side of the visible area.\n * Default is `count`.\n */\n tolerance: number;\n /** Height of each item, in pixels. Default is 20px. */\n itemHeight: number;\n}\n\nexport interface VirtualScrollDataAdapter {\n (offset: number, limit: number): Iterable;\n}\n\nexport function arrayAdapter(data: T[]): VirtualScrollDataAdapter {\n return (offset, limit) => data.slice(offset, offset + limit);\n}\n\nexport interface VirtualScrollProps {\n settings?: Partial;\n get: VirtualScrollDataAdapter;\n row: (t: T) => U;\n rowKey: (t: T) => Key;\n}\n\nexport function fillVirtualScrollSettings(\n settings: Partial\n): VirtualScrollSettings {\n const {\n minIndex = 0,\n maxIndex = Number.MAX_SAFE_INTEGER,\n startIndex = 0,\n itemHeight = 20,\n count = Math.max(maxIndex - minIndex, 1),\n tolerance = count,\n } = settings;\n\n return { minIndex, maxIndex, startIndex, itemHeight, count, tolerance };\n}\n\nexport function initialState(\n settings: VirtualScrollSettings,\n adapter: VirtualScrollDataAdapter\n): VirtualScrollState {\n // From Denis Hilt, https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/\n const { minIndex, maxIndex, startIndex, itemHeight, count, tolerance } =\n settings;\n const bufferedItems = count + 2 * tolerance;\n const itemsAbove = Math.max(0, startIndex - tolerance - minIndex);\n\n const viewportHeight = count * itemHeight;\n const totalHeight = (maxIndex - minIndex) * itemHeight;\n const toleranceHeight = tolerance * itemHeight;\n const bufferHeight = viewportHeight + 2 * toleranceHeight;\n const topPaddingHeight = itemsAbove * itemHeight;\n const bottomPaddingHeight = totalHeight - (topPaddingHeight + bufferHeight);\n\n const state: VirtualScrollState = {\n scrollTop: 0,\n settings,\n viewportHeight,\n totalHeight,\n toleranceHeight,\n bufferedItems,\n topPaddingHeight,\n bottomPaddingHeight,\n data: [],\n };\n\n return {\n ...state,\n ...doScroll(topPaddingHeight + toleranceHeight, state, adapter),\n };\n}\n\nexport function getData(\n minIndex: number,\n maxIndex: number,\n offset: number,\n limit: number,\n get: VirtualScrollDataAdapter\n): T[] {\n const start = Math.max(0, minIndex, offset);\n const end = Math.min(maxIndex, offset + limit - 1);\n const data = get(start, end - start);\n return [...data];\n}\n\ninterface ScrollUpdate {\n scrollTop: number;\n topPaddingHeight: number;\n bottomPaddingHeight: number;\n data: T[];\n}\n\nexport function doScroll(\n scrollTop: number,\n state: VirtualScrollState,\n get: VirtualScrollDataAdapter\n): ScrollUpdate {\n const {\n totalHeight,\n toleranceHeight,\n bufferedItems,\n settings: { itemHeight, minIndex, maxIndex },\n } = state;\n const index =\n minIndex + Math.floor((scrollTop - toleranceHeight) / itemHeight);\n const data = getData(minIndex, maxIndex, index, bufferedItems, get);\n const topPaddingHeight = Math.max((index - minIndex) * itemHeight, 0);\n const bottomPaddingHeight = Math.max(\n totalHeight - (topPaddingHeight + data.length * itemHeight),\n 0\n );\n\n return { scrollTop, topPaddingHeight, bottomPaddingHeight, data };\n}\n\ninterface VirtualScrollState {\n settings: VirtualScrollSettings;\n scrollTop: number; // px\n bufferedItems: number; // count\n totalHeight: number; // px\n viewportHeight: number; // px\n topPaddingHeight: number; // px\n bottomPaddingHeight: number; // px\n toleranceHeight: number; // px\n data: T[];\n}\n\nconst scrollReducer =\n (get: VirtualScrollDataAdapter) =>\n (state: VirtualScrollState, scrollTop: number) => ({\n ...state,\n ...doScroll(scrollTop, state, get),\n });\n\nexport const VirtualScroll = (\n props: VirtualScrollProps & { className?: string }\n) => {\n const viewportRef = useRef(null);\n\n const { settings, startState, reducer } = useMemo(() => {\n const settings = fillVirtualScrollSettings(props.settings ?? {});\n const startState = initialState(settings, props.get);\n const reducer = scrollReducer(props.get);\n return { settings, reducer, startState };\n }, [props.settings, props.get]);\n\n const [state, dispatchScroll] = useReducer(reducer, startState);\n\n useEffect(() => {\n if (viewportRef.current !== null) {\n dispatchScroll(viewportRef.current.scrollTop);\n }\n }, [settings, props.row]);\n\n const initialScroll = useCallback(\n (div: HTMLDivElement | null) => {\n if (div) {\n div.scrollTop = viewportRef.current\n ? viewportRef.current.scrollTop\n : settings.startIndex * settings.itemHeight;\n }\n viewportRef.current = div;\n },\n [viewportRef, settings.startIndex, settings.itemHeight]\n );\n\n const rows = state.data.map((d) => (\n
\n {props.row(d)}\n
\n ));\n\n return (\n dispatchScroll((e.target as HTMLDivElement).scrollTop)}\n >\n
\n {rows}\n
\n
\n );\n};\n\nexport default VirtualScroll;\n","import { useEffect, useMemo, useState } from \"react\";\n\nimport { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\n\nexport function useClock(actions: {\n tick?: () => void;\n toggle?: () => void;\n reset?: () => void;\n}) {\n const clock = useMemo(() => Clock.get(), []);\n\n useEffect(() => {\n const subscription = clock.$.subscribe(() => {\n actions.tick?.();\n });\n return () => subscription.unsubscribe();\n }, [actions, clock.$]);\n\n return {\n toggle() {\n clock.tick();\n actions.toggle?.();\n },\n\n reset() {\n clock.reset();\n actions.reset?.();\n },\n };\n}\n\nexport function useClockFrame(frameFinished: () => void) {\n useEffect(() => {\n const subscription = Clock.get().frame$.subscribe(() => {\n frameFinished();\n });\n return () => subscription.unsubscribe();\n }, [frameFinished]);\n}\n\nexport function useClockReset(reset: () => void) {\n useEffect(() => {\n const subscription = Clock.get().reset$.subscribe(() => {\n reset();\n });\n return () => subscription.unsubscribe();\n }, [reset]);\n}\n\nexport function displayClock() {\n return display(Clock.get());\n}\n\nexport function useClockface() {\n const [clockface, setClockface] = useState(displayClock());\n\n useEffect(() => {\n const subscription = Clock.get().$.subscribe(() => {\n setClockface(displayClock());\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return clockface;\n}\n\nexport const Clockface = () => {\n const clockface = useClockface();\n return {clockface};\n};\n","import { rounded } from \"@davidsouther/jiffies/lib/esm/dom/css/border.js\";\nimport { ReactNode, useCallback, useMemo, useState } from \"react\";\n\nimport {\n Format,\n FORMATS,\n Memory as MemoryChip,\n} from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { asm } from \"@nand2tetris/simulator/util/asm.js\";\nimport { bin, dec, hex } from \"@nand2tetris/simulator/util/twos.js\";\nimport InlineEdit from \"../inline_edit.js\";\nimport VirtualScroll, { VirtualScrollSettings } from \"../virtual_scroll.js\";\nimport { useClockReset } from \"../clockface.js\";\n\nconst ITEM_HEIGHT = 34;\n\nexport const MemoryBlock = ({\n memory,\n jmp = { value: 0 },\n highlight = -1,\n editable = false,\n format = dec,\n onChange = () => undefined,\n}: {\n jmp?: { value: number };\n memory: MemoryChip;\n highlight?: number;\n editable?: boolean;\n format?: (v: number) => string;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => {\n const settings = useMemo>(\n () => ({\n count: Math.min(memory.size, 20),\n maxIndex: memory.size,\n itemHeight: ITEM_HEIGHT,\n startIndex: jmp.value,\n }),\n [memory.size, jmp]\n );\n const get = useCallback(\n (offset: number, count: number) =>\n memory\n .range(offset, offset + count)\n .map((v, i) => [i + offset, v] as [number, number]),\n [memory]\n );\n const row = useCallback(\n ([i, v]: [number, number]) => (\n \n ),\n [format, editable, highlight, onChange]\n );\n\n return (\n \n settings={settings}\n get={get}\n row={row}\n rowKey={([i]) => i}\n />\n );\n};\n\nexport const MemoryCell = ({\n index,\n value,\n highlight = false,\n editable = false,\n onChange = () => undefined,\n}: {\n index: number;\n value: string;\n highlight?: boolean;\n editable?: boolean;\n onChange?: (i: number, value: string, previous: number) => void;\n}) => (\n
\n \n {hex(index)}\n \n \n {editable ? (\n \n onChange(index, newValue, Number(value))\n }\n />\n ) : (\n {value}\n )}\n \n
\n);\n\nexport const Memory = ({\n name = \"Memory\",\n highlight = -1,\n editable = true,\n memory,\n format = \"dec\",\n}: {\n name?: string;\n editable?: boolean;\n highlight?: number;\n memory: MemoryChip;\n format: Format;\n}) => {\n const [fmt, setFormat] = useState(format);\n const [jmp, setJmp] = useState(\"\");\n const [goto, setGoto] = useState({ value: 0 });\n\n const jumpTo = () => {\n setGoto({\n value: !isNaN(parseInt(jmp)) && isFinite(parseInt(jmp)) ? Number(jmp) : 0,\n });\n };\n\n // const { filePicker, fs } = useContext(AppContext);\n // const doLoad = useCallback(async () => {\n // try {\n // const file = await filePicker.select();\n // await memory.load(fs, file);\n // } catch (e) {\n // console.error(e);\n // }\n // }, [fs, filePicker, memory]);\n\n const doLoad = () => undefined;\n\n const doUpdate = useCallback(\n (i: number, v: string) => {\n memory.update(i, v, fmt ?? \"dec\");\n },\n [memory, fmt]\n );\n\n useClockReset(() => {\n setJmp(\"\");\n setGoto({ value: 0 });\n });\n\n return (\n
\n
\n
{name}
\n
\n \n key === \"Enter\" && jumpTo()}\n onChange={({ target: { value } }) => setJmp(value)}\n />\n \n {FORMATS.map((option) => (\n \n setFormat(option)}\n />\n {option}\n \n ))}\n
\n
\n doFormat(fmt, v)}\n onChange={doUpdate}\n />\n
\n );\n};\n\nexport default Memory;\n\nfunction doFormat(format: Format, v: number): string {\n switch (format) {\n case \"bin\":\n return bin(v);\n case \"hex\":\n return hex(v);\n case \"asm\":\n return asm(v);\n case \"dec\":\n default:\n return dec(v);\n }\n}\n","import { Memory } from \"@nand2tetris/simulator/cpu/memory.js\";\nimport { assertExists } from \"@davidsouther/jiffies/lib/esm/assert.js\";\nimport { useCallback, useRef } from \"react\";\nimport { useClockFrame, useClockReset } from \"../clockface.js\";\n\nconst WHITE = \"white\";\nconst BLACK = \"black\";\ntype COLOR = typeof WHITE | typeof BLACK;\n\nexport interface ScreenMemory {\n get(idx: number): number;\n}\n\nexport function reduceScreen(memory: Memory, offset = 0): ScreenMemory {\n return {\n get(idx: number): number {\n return memory.get(offset + idx);\n },\n };\n}\n\nfunction get(mem: ScreenMemory, x: number, y: number): COLOR {\n const byte = mem.get(32 * y + ((x / 16) | 0));\n const bit = byte & (1 << x % 16);\n return bit === 0 ? WHITE : BLACK;\n}\n\nfunction set(data: Uint8ClampedArray, x: number, y: number, value: COLOR) {\n const pixel = (y * 512 + x) * 4;\n const color = value === WHITE ? 255 : 0;\n data[pixel] = color;\n data[pixel + 1] = color;\n data[pixel + 2] = color;\n data[pixel + 3] = 255;\n}\n\nfunction drawImage(ctx: CanvasRenderingContext2D, memory: ScreenMemory) {\n const image = assertExists(\n ctx.getImageData(0, 0, 512, 256),\n \"Failed to create Context2d\"\n );\n for (let col = 0; col < 512; col++) {\n for (let row = 0; row < 256; row++) {\n const color = get(memory, col, row);\n set(image.data, col, row, color);\n }\n }\n ctx.putImageData(image, 0, 0);\n}\n\nexport const Screen = ({ memory }: { memory: ScreenMemory }) => {\n const canvas = useRef();\n\n const draw = useCallback(() => {\n const ctx = canvas.current?.getContext(\"2d\") ?? undefined;\n\n if (ctx) {\n drawImage(ctx, memory);\n }\n }, [memory]);\n\n const ctxRef = useCallback(\n (ref: HTMLCanvasElement | null) => {\n canvas.current = ref ?? undefined;\n draw();\n },\n [canvas, draw]\n );\n\n useClockFrame(draw);\n useClockReset(() => {\n canvas.current\n ?.getContext(\"2d\")\n ?.clearRect(0, 0, canvas.current.width, canvas.current.height);\n });\n\n return (\n
\n
Screen
\n
\n \n \n \n
\n
\n );\n};\n","import {\n Keyboard,\n Screen,\n} from \"@nand2tetris/simulator/chip/builtins/computer/computer.js\";\nimport { ALU } from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n PC,\n Register,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/bit.js\";\nimport {\n RAM,\n RAM8,\n} from \"@nand2tetris/simulator/chip/builtins/sequential/ram.js\";\nimport { Chip, HIGH } from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Flags } from \"@nand2tetris/simulator/cpu/alu.js\";\nimport { CPU, decode } from \"@nand2tetris/simulator/cpu/cpu.js\";\nimport { ReactElement } from \"react\";\nimport { ALUComponent } from \"./alu.js\";\nimport { Keyboard as KeyboardComponent } from \"./keyboard.js\";\nimport { Memory as MemoryComponent } from \"./memory.js\";\nimport { RegisterComponent } from \"./register.js\";\nimport { Screen as ScreenComponent } from \"./screen.js\";\n\nexport function getBuiltinVisualization(part: Chip): ReactElement | undefined {\n switch (part.name) {\n case \"Register\":\n case \"ARegister\":\n case \"DRegister\":\n case \"PC\":\n case \"KEYBOARD\":\n case \"RAM8\":\n case \"RAM64\":\n case \"RAM512\":\n case \"RAM4K\":\n case \"RAM16K\":\n case \"ROM32K\":\n case \"Screen\":\n case \"Memory\":\n default:\n return undefined;\n }\n}\n\nexport function makeVisualization(\n chip: Chip,\n updateAction?: () => void\n): ReactElement | undefined {\n if (chip instanceof ALU) {\n return (\n \n );\n }\n if (chip instanceof Register) {\n return (\n \n );\n }\n if (chip instanceof PC) {\n return ;\n }\n if (chip instanceof Keyboard) {\n return ;\n }\n if (chip instanceof Screen) {\n return ;\n }\n if (chip instanceof RAM) {\n return (\n \n );\n }\n if (chip instanceof RAM8) {\n return RAM {chip.width};\n }\n if (chip instanceof CPU) {\n const bits = decode(chip.in(\"instruction\").busVoltage);\n return (\n <>\n \n \n \n \n \n );\n }\n\n const vis = [...chip.parts]\n .map((chip) => makeVisualization(chip, updateAction))\n .filter((v) => v !== undefined);\n return vis.length > 0 ? <>{vis} : undefined;\n}\n\nexport function makeVisualizationsWithId(\n chip: {\n parts: Chip[];\n },\n updateAction?: () => void\n): [string, ReactElement][] {\n return [...chip.parts]\n .map((part, i): [string, ReactElement | undefined] => [\n `${part.id}_${i}`,\n makeVisualization(part, updateAction),\n ])\n .filter(([_, v]) => v !== undefined) as [string, ReactElement][];\n}\n","import { Ok, isOk } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport {\n REGISTRY as BUILTIN_REGISTRY,\n getBuiltinChip,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\n\nexport class ChipDisplayInfo {\n signBehaviors: Map = new Map();\n\n public constructor(chipName: string, unsigned?: string[]) {\n if (BUILTIN_REGISTRY.has(chipName)) {\n const chip = getBuiltinChip(chipName);\n if (isOk(chip)) {\n const pins = Array.from(Ok(chip).ins.entries()).concat(\n Array.from(Ok(chip).outs.entries())\n );\n for (const pin of pins) {\n this.signBehaviors.set(\n pin.name,\n !unsigned || !unsigned.includes(pin.name)\n );\n }\n }\n }\n }\n\n public isSigned(pin: string) {\n return this.signBehaviors.get(pin);\n }\n}\n\nconst UNSIGNED_PINS = new Map([\n [\"Mux4Way16\", [\"sel\"]],\n [\"Mux8Way16\", [\"sel\"]],\n [\"DMux4Way\", [\"sel\"]],\n [\"DMux8Way\", [\"sel\"]],\n [\"RAM8\", [\"address\"]],\n [\"RAM64\", [\"address\"]],\n [\"RAM512\", [\"address\"]],\n [\"RAM4K\", [\"address\"]],\n [\"RAM16K\", [\"address\"]],\n [\"Screen\", [\"address\"]],\n [\"Memory\", [\"address\"]],\n [\"CPU\", [\"addressM\", \"pc\"]],\n]);\n\nexport const getDisplayInfo = (chipName: string) =>\n new ChipDisplayInfo(chipName, UNSIGNED_PINS.get(chipName));\n","// import { plural, Trans } from \"@lingui/macro\";\nimport {\n Pin as ChipPin,\n Pins,\n Voltage,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { range } from \"@davidsouther/jiffies/lib/esm/range.js\";\nimport { ChipSim } from \"./stores/chip.store.js\";\nimport { createContext, useContext, useEffect, useState } from \"react\";\nimport { ChipDisplayInfo, getDisplayInfo } from \"./pin_display.js\";\n\nexport const PinContext = createContext({});\n\nexport interface ImmPin {\n bits: [number, Voltage][];\n pin: ChipPin;\n}\n\nexport function reducePin(pin: ChipPin) {\n return {\n pin,\n bits: range(0, pin.width)\n .map((i) => [i, pin.voltage(i)] as [number, Voltage])\n .reverse(),\n };\n}\n\nexport function reducePins(pins: Pins): ImmPin[] {\n return [...pins.entries()].map(reducePin);\n}\n\nexport interface PinoutPins {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}\n\nexport const FullPinout = (props: {\n sim: ChipSim;\n toggle: (pin: ChipPin, i: number | undefined) => void;\n setInputValid: (pending: boolean) => void;\n hideInternal?: boolean;\n}) => {\n const { inPins, outPins, internalPins } = props.sim;\n const displayInfo = getDisplayInfo(props.sim.chip[0].name ?? \"\");\n return (\n <>\n \n \n \n \n \n {!props.hideInternal && (\n \n )}\n \n
\n \n );\n};\n\nexport const PinoutBlock = (\n props: PinoutPins & {\n header: string;\n disabled?: boolean;\n enableEdit?: boolean;\n setInputValid?: (valid: boolean) => void;\n displayInfo: ChipDisplayInfo;\n }\n) => (\n <>\n {props.pins.length > 0 && (\n \n {props.header}\n \n )}\n {[...props.pins].map((immPin) => (\n \n {immPin.pin.name}\n \n \n \n \n ))}\n \n);\n\nexport const Pinout = ({\n pins,\n toggle,\n}: {\n pins: ImmPin[];\n toggle?: (pin: ChipPin, bit?: number) => void;\n}) => {\n if (pins.length === 0) {\n return <>None;\n }\n return (\n \n \n \n \n \n \n \n \n {[...pins].map((immPin) => (\n \n \n \n \n ))}\n \n
NameValue
{immPin.pin.name}\n \n
\n );\n};\n\nconst Pin = ({\n pin,\n toggle,\n disabled = false,\n enableEdit = true,\n signed = true,\n setInputValid,\n internal = false,\n}: {\n pin: ImmPin;\n toggle: ((pin: ChipPin, bit?: number) => void) | undefined;\n disabled?: boolean;\n enableEdit?: boolean;\n signed?: boolean;\n setInputValid?: (valid: boolean) => void;\n internal: boolean;\n}) => {\n const [isBin, setIsBin] = useState(true);\n let inputValid = true;\n const [decimal, setDecimal] = useState(\"\");\n\n const toggleBin = () => {\n setIsBin(!isBin);\n };\n\n const resetDispatcher = useContext(PinContext);\n if (resetDispatcher instanceof PinResetDispatcher) {\n resetDispatcher.registerCallback(() => {\n setIsBin(true);\n });\n }\n\n const setInputValidity = (valid: boolean) => {\n inputValid = valid;\n setInputValid?.(valid);\n };\n\n const handleDecimalChange = (value: string) => {\n const positive = value.replace(/[^\\d]/g, \"\");\n const numeric = signed && value[0] === \"-\" ? `-${positive}` : positive;\n\n setDecimal(numeric);\n if (isNaN(parseInt(numeric))) {\n setInputValidity(false);\n } else {\n const newValue = parseInt(numeric);\n if (\n (!signed && newValue >= Math.pow(2, pin.bits.length)) ||\n (signed &&\n (newValue >= Math.pow(2, pin.bits.length - 1) ||\n newValue < -Math.pow(2, pin.bits.length - 1)))\n ) {\n setInputValidity(false);\n } else {\n updatePins(newValue);\n setInputValidity(true);\n }\n }\n };\n\n const updatePins = (n: number) => {\n for (let i = 0; i < pin.bits.length; i++) {\n if (pin.bits[pin.bits.length - i - 1][1] !== ((n >> i) & 1)) {\n toggle?.(pin.pin, i);\n }\n }\n };\n\n useEffect(() => {\n if (!isBin && inputValid) {\n let value = 0;\n if (signed && pin.bits[0][1]) {\n // negative\n for (const [i, v] of pin.bits) {\n if (i < pin.bits.length - 1 && !v) {\n value += 2 ** i;\n }\n }\n value = -value - 1;\n } else {\n // positive\n const limit = signed ? pin.bits.length - 1 : pin.bits.length;\n for (const [i, v] of pin.bits) {\n if (i < limit && v) {\n value += 2 ** i;\n }\n }\n }\n setDecimal(value.toString());\n }\n }, [pin, isBin]);\n\n return (\n \n
\n {isBin ? (\n pin.bits.map(([i, v]) => (\n toggle?.(pin.pin, i)}\n data-testid={`pin-${i}`}\n >\n {v}\n \n ))\n ) : (\n {\n handleDecimalChange(e.target.value);\n }}\n disabled={!enableEdit}\n />\n )}\n
\n {pin.bits.length > 1 && (\n <>\n
\n toggleBin()}\n >\n {isBin ? \"dec\" : \"bin\"}\n \n \n )}\n
\n );\n};\n\nexport class PinResetDispatcher {\n private callbacks: (() => void)[] = [];\n\n registerCallback(callback: () => void) {\n this.callbacks.push(callback);\n }\n\n reset() {\n for (const callback of this.callbacks) {\n callback();\n }\n }\n}\n","import { ReactNode } from \"react\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useTimer } from \"./timer.js\";\n\nexport const Runbar = (props: { runner: Timer; children?: ReactNode }) => {\n const runner = useTimer(props.runner);\n return (\n
\n runner.actions.frame()}\n data-tooltip={`Step`}\n data-placement=\"bottom\"\n >\n {/* */}\n ➡️\n \n \n runner.state.running ? runner.actions.stop() : runner.actions.start()\n }\n data-tooltip={runner.state.running ? `Pause` : `Play`}\n data-placement=\"bottom\"\n >\n {/* */}\n {runner.state.running ? \"⏸\" : \"️⏩\"}\n \n runner.actions.reset()}\n data-tooltip={`Reset`}\n data-placement=\"bottom\"\n >\n {/* */}⏮\n \n {\n runner.dispatch({\n action: \"setSpeed\",\n payload: Number(e.target?.value ?? runner.state.speed),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n // [2000, `Debug`], // For debugging, basically the same as clicking through\n [1000, `Slow`],\n [500, `Fast`],\n [16, `Faster`],\n ].map(([speed, label]) => (\n \n ))}\n \n {\n runner.dispatch({\n action: \"setSteps\",\n payload: Number(e.target?.value ?? runner.state.steps),\n });\n }}\n disabled={runner.state.running}\n >\n {[\n [1, `1 Step`],\n [500, \"500\"],\n [1000, \"1000\"],\n [2000, \"2000\"],\n ].map(([steps, label]) => (\n \n ))}\n \n {props.children}\n
\n );\n};\n","import { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { useImmerReducer } from \"./react.js\";\n\nexport interface TimerStoreState {\n steps: number;\n speed: number;\n running: boolean;\n}\n\nimport { Dispatch, MutableRefObject, useMemo, useRef } from \"react\";\nexport type TimerStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nconst makeTimerStore = (\n timer: Timer,\n dispatch: MutableRefObject\n) => {\n const initialState: TimerStoreState = {\n running: timer.running,\n speed: timer.speed,\n steps: timer.steps,\n };\n\n const finishFrame = timer.finishFrame.bind(timer);\n timer.finishFrame = function () {\n finishFrame();\n dispatch.current({ action: \"update\" });\n };\n\n const reducers = {\n update(state: TimerStoreState) {\n state.running = timer.running;\n state.speed = timer.speed;\n state.steps = timer.steps;\n },\n setSteps(state: TimerStoreState, steps: number) {\n state.steps = steps;\n timer.steps = steps;\n },\n setSpeed(state: TimerStoreState, speed: number) {\n state.speed = speed;\n timer.speed = speed;\n },\n };\n\n const actions = {\n frame() {\n timer.frame();\n },\n start() {\n timer.start();\n dispatch.current({ action: \"update\" });\n },\n stop() {\n timer.stop();\n dispatch.current({ action: \"update\" });\n },\n reset() {\n timer.reset();\n dispatch.current({ action: \"update\" });\n },\n };\n\n return { initialState, reducers, actions };\n};\n\nexport function useTimer(timer: Timer) {\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeTimerStore(timer, dispatch),\n [timer, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(reducers, initialState);\n\n dispatch.current = dispatcher;\n\n return { state, dispatch: dispatch.current, actions };\n}\n","import { display } from \"@davidsouther/jiffies/lib/esm/display.js\";\nimport { FileSystem } from \"@davidsouther/jiffies/lib/esm/fs.js\";\nimport { Err, isErr, Ok } from \"@davidsouther/jiffies/lib/esm/result.js\";\nimport { Dispatch, MutableRefObject, useContext, useMemo, useRef } from \"react\";\n\nimport { build as buildChip } from \"@nand2tetris/simulator/chip/builder.js\";\nimport {\n getBuiltinChip,\n REGISTRY,\n} from \"@nand2tetris/simulator/chip/builtins/index.js\";\nimport {\n Chip,\n Chip as SimChip,\n Low,\n Pin,\n} from \"@nand2tetris/simulator/chip/chip.js\";\nimport { Clock } from \"@nand2tetris/simulator/chip/clock.js\";\nimport { Span } from \"@nand2tetris/simulator/languages/base.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport {\n BUILTIN_CHIP_PROJECTS,\n CHIP_ORDER,\n CHIP_PROJECTS,\n ChipProjects,\n} from \"@nand2tetris/projects/index.js\";\nimport { ChipTest } from \"@nand2tetris/simulator/tst.js\";\n\nimport { ImmPin, reducePins } from \"../pinout.js\";\nimport { useImmerReducer } from \"../react.js\";\n\nimport { BaseContext } from \"./base.context.js\";\nimport { assert } from \"@davidsouther/jiffies/lib/esm/assert.js\";\n\nexport const PROJECT_NAMES = [\n [\"01\", `Project 1`],\n [\"02\", `Project 2`],\n [\"03\", `Project 3`],\n [\"05\", `Project 5`],\n];\n\nfunction getChips(project: keyof typeof CHIP_PROJECTS) {\n return project in CHIP_ORDER\n ? (CHIP_ORDER as Record)[project]\n : BUILTIN_CHIP_PROJECTS[project].concat(CHIP_PROJECTS[project]);\n}\n\nfunction findDropdowns(storage: Record) {\n const project =\n (storage[\"/chip/project\"] as keyof typeof CHIP_PROJECTS) ?? \"01\";\n const chips = getChips(project);\n const chipName = storage[\"/chip/chip\"] ?? CHIP_PROJECTS[project][0];\n return { project, chips, chipName };\n}\n\nfunction makeHdl(name: string) {\n return `CHIP ${name} {\n IN in;\n OUT out;\n PARTS:\n}`;\n}\n\nfunction makeTst() {\n return `repeat 10 {\n tick,\n tock;\n}`;\n}\n\nfunction makeCmp() {\n return `| in|out|`;\n}\n\nexport function isBuiltinOnly(chipName: string) {\n return Object.values(BUILTIN_CHIP_PROJECTS).flat().includes(chipName);\n}\n\nfunction getTemplate(project: keyof typeof CHIP_PROJECTS, chipName: string) {\n if (isBuiltinOnly(chipName)) {\n return (ChipProjects[project].BUILTIN_CHIPS as Record)[\n chipName\n ];\n }\n\n return (\n ChipProjects[project].CHIPS as Record>\n )[chipName][`${chipName}.hdl`] as string;\n}\n\nfunction getBuiltinCode(project: keyof typeof CHIP_PROJECTS, chipName: string) {\n const template = getTemplate(project, chipName);\n if (isBuiltinOnly(chipName)) {\n return template;\n }\n const bodyComment = \"//// Replace this comment with your code.\";\n const builtinLine = `BUILTIN ${chipName};`;\n const builtinCode = template.includes(bodyComment)\n ? template.replace(bodyComment, builtinLine)\n : template.replace(\"PARTS:\", `PARTS:\\n ${builtinLine}`);\n return builtinCode;\n}\n\nexport interface ChipPageState {\n files: Files;\n sim: ChipSim;\n controls: ControlsState;\n}\n\nexport interface ChipSim {\n clocked: boolean;\n inPins: ImmPin[];\n outPins: ImmPin[];\n internalPins: ImmPin[];\n chip: [Chip];\n pending: boolean;\n invalid: boolean;\n}\n\nexport interface Files {\n hdl: string;\n cmp: string;\n tst: string;\n out: string;\n}\n\nexport interface ControlsState {\n project: keyof typeof CHIP_PROJECTS;\n chips: string[];\n chipName: string;\n hasBuiltin: boolean;\n builtinOnly: boolean;\n runningTest: boolean;\n span?: Span;\n error: string;\n}\n\nfunction reduceChip(chip: SimChip, pending = false, invalid = false): ChipSim {\n return {\n clocked: chip.clocked,\n inPins: reducePins(chip.ins),\n outPins: reducePins(chip.outs),\n internalPins: reducePins(chip.pins),\n chip: [chip],\n pending,\n invalid,\n };\n}\n\nconst clock = Clock.get();\n\nexport type ChipStoreDispatch = Dispatch<{\n action: keyof ReturnType[\"reducers\"];\n payload?: unknown;\n}>;\n\nexport function makeChipStore(\n fs: FileSystem,\n setStatus: (status: string) => void,\n storage: Record,\n dispatch: MutableRefObject\n) {\n const dropdowns = findDropdowns(storage);\n let { project, chipName } = dropdowns;\n const { chips } = dropdowns;\n let chip = new Low();\n let test = new ChipTest();\n let usingBuiltin = false;\n let builtinOnly = false;\n\n const reducers = {\n setFiles(\n state: ChipPageState,\n {\n hdl = state.files.hdl,\n tst = state.files.tst,\n cmp = state.files.cmp,\n out = \"\",\n }: {\n hdl?: string;\n tst?: string;\n cmp?: string;\n out?: string;\n }\n ) {\n state.files.hdl = hdl;\n state.files.tst = tst;\n state.files.cmp = cmp;\n state.files.out = out;\n },\n\n updateChip(\n state: ChipPageState,\n payload?: {\n pending?: boolean;\n invalid?: boolean;\n chipName?: string;\n error?: string;\n }\n ) {\n state.sim = reduceChip(\n chip,\n payload?.pending ?? state.sim.pending,\n payload?.invalid ?? state.sim.invalid\n );\n state.controls.error = state.sim.invalid\n ? payload?.error ?? state.controls.error\n : \"\";\n state.controls.chips = getChips(state.controls.project);\n state.controls.chipName = state.sim.invalid\n ? payload?.chipName ?? chipName\n : chip.name ?? payload?.chipName ?? chipName;\n if (!state.controls.chips.includes(state.controls.chipName)) {\n state.controls.chips = [\n ...state.controls.chips,\n state.controls.chipName,\n ];\n }\n },\n\n setProject(state: ChipPageState, project: keyof typeof CHIP_PROJECTS) {\n const chips = getChips(project);\n const chipName =\n state.controls.chipName && chips.includes(state.controls.chipName)\n ? state.controls.chipName\n : chips[0];\n state.controls.project = project;\n state.controls.chips = chips;\n this.setChip(state, chipName);\n },\n\n setChip(state: ChipPageState, chipName: string) {\n state.controls.chipName = chipName;\n state.controls.hasBuiltin = REGISTRY.has(chipName);\n state.controls.builtinOnly = isBuiltinOnly(chipName);\n },\n\n testRunning(state: ChipPageState) {\n state.controls.runningTest = true;\n },\n\n testFinished(state: ChipPageState) {\n state.controls.runningTest = false;\n const passed = state.files.out.trim() === state.files.cmp.trim();\n setStatus(\n passed\n ? `Simulation successful: The output file is identical to the compare file`\n : `Simulation error: The output file differs from the compare file`\n );\n },\n\n updateTestStep(state: ChipPageState) {\n state.files.out = test?.log() ?? \"\";\n if (test?.currentStep?.span) {\n state.controls.span = test.currentStep.span;\n } else {\n if (test.done) {\n const end = state.files.tst.length;\n state.controls.span = {\n start: end - 1,\n end,\n };\n }\n }\n this.updateChip(state, {\n pending: state.sim.pending,\n invalid: state.sim.invalid,\n });\n },\n };\n\n const actions = {\n setProject(p: keyof typeof CHIP_PROJECTS) {\n project = storage[\"/chip/project\"] = p;\n dispatch.current({ action: \"setProject\", payload: project });\n this.setChip(CHIP_PROJECTS[project][0]);\n },\n\n async setChip(chip: string, project = storage[\"/chip/project\"] ?? \"01\") {\n chipName = storage[\"/chip/chip\"] = chip;\n dispatch.current({ action: \"setChip\", payload: chipName });\n builtinOnly = isBuiltinOnly(chipName);\n\n if (builtinOnly) {\n dispatch.current({\n action: \"setFiles\",\n payload: { hdl: \"\", tst: \"\", cmp: \"\" },\n });\n this.useBuiltin();\n return;\n }\n await this.loadChip(project, chipName);\n if (usingBuiltin) {\n this.useBuiltin();\n }\n },\n\n reset() {\n Clock.get().reset();\n chip.reset();\n test.reset();\n dispatch.current({ action: \"setFiles\", payload: {} });\n dispatch.current({ action: \"updateChip\" });\n },\n\n async updateFiles({\n hdl,\n tst,\n cmp,\n }: {\n hdl?: string;\n tst?: string;\n cmp: string;\n }) {\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n try {\n if (hdl) {\n await this.compileChip(hdl);\n }\n if (tst) {\n this.compileTest(tst);\n }\n } catch (e) {\n setStatus(display(e));\n }\n },\n\n async compileChip(hdl: string) {\n chip.remove();\n const maybeParsed = HDL.parse(hdl);\n if (isErr(maybeParsed)) {\n setStatus(\"Failed to parse chip\");\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error: display(Err(maybeParsed)) },\n });\n return;\n }\n const maybeChip = await buildChip(Ok(maybeParsed));\n if (isErr(maybeChip)) {\n const error = display(Err(maybeChip));\n setStatus(error);\n dispatch.current({\n action: \"updateChip\",\n payload: { invalid: true, error },\n });\n return;\n }\n setStatus(`Compiled ${chip.name}`);\n this.replaceChip(Ok(maybeChip));\n },\n\n replaceChip(nextChip: SimChip) {\n // Store current inPins\n const inPins = chip.ins;\n for (const [pin, { busVoltage }] of inPins) {\n const nextPin = nextChip.ins.get(pin);\n if (nextPin) {\n nextPin.busVoltage = busVoltage;\n }\n }\n clock.reset();\n nextChip.eval();\n chip = nextChip;\n chip.reset();\n test = test.with(chip).reset();\n dispatch.current({ action: \"updateChip\", payload: { invalid: false } });\n dispatch.current({ action: \"updateTestStep\" });\n },\n\n async loadChip(project: string, name: string) {\n storage[\"/chip/chip\"] = name;\n const fsName = (ext: string) =>\n `/projects/${project}/${name}/${name}.${ext}`;\n\n const [hdl, tst, cmp] = await Promise.all([\n fs.readFile(fsName(\"hdl\")).catch(() => makeHdl(name)),\n fs.readFile(fsName(\"tst\")).catch((e) => {\n return makeTst();\n }),\n fs.readFile(fsName(\"cmp\")).catch(() => makeCmp()),\n ]);\n\n dispatch.current({ action: \"setFiles\", payload: { hdl, tst, cmp } });\n await this.compileChip(hdl);\n this.compileTest(tst);\n },\n\n async saveChip(hdl: string, prj = project, name = chipName) {\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n const path = `/projects/${prj}/${name}/${name}.hdl`;\n await fs.writeFile(path, hdl);\n setStatus(`Saved ${path}`);\n },\n\n toggle(pin: Pin, i: number | undefined) {\n if (i !== undefined) {\n pin.busVoltage = pin.busVoltage ^ (1 << i);\n } else {\n if (pin.width === 1) {\n pin.toggle();\n } else {\n pin.busVoltage += 1;\n }\n }\n dispatch.current({ action: \"updateChip\", payload: { pending: true } });\n },\n\n eval() {\n chip.eval();\n dispatch.current({ action: \"updateChip\", payload: { pending: false } });\n },\n\n clock() {\n clock.toggle();\n if (clock.isLow) {\n clock.frame();\n }\n dispatch.current({ action: \"updateChip\" });\n },\n\n async useBuiltin(doUseBuiltin = true, oldHdl?: string) {\n if (!doUseBuiltin) {\n if (!builtinOnly) {\n usingBuiltin = false;\n }\n await this.loadChip(project, chipName);\n return;\n }\n if (!builtinOnly) {\n usingBuiltin = true;\n }\n const builtinName = chipName;\n const nextChip = getBuiltinChip(builtinName);\n if (isErr(nextChip)) {\n setStatus(\n `Failed to load builtin ${builtinName}: ${display(Err(nextChip))}`\n );\n return;\n }\n\n // Save hdl code that will be overwritten by the switch\n if (oldHdl) {\n await this.saveChip(oldHdl, project, chipName);\n }\n\n const hdl = getBuiltinCode(project, builtinName);\n dispatch.current({ action: \"setFiles\", payload: { hdl } });\n this.replaceChip(Ok(nextChip));\n },\n\n async initialize() {\n await this.setChip(chipName, project);\n },\n\n compileTest(file: string) {\n dispatch.current({ action: \"setFiles\", payload: { tst: file } });\n const tst = TST.parse(file);\n\n if (isErr(tst)) {\n setStatus(`Failed to parse test`);\n return false;\n }\n setStatus(`Parsed tst`);\n\n test = ChipTest.from(Ok(tst)).with(chip).reset();\n test.setFileSystem(fs);\n dispatch.current({ action: \"updateTestStep\" });\n return true;\n },\n\n async runTest(file: string) {\n if (!this.compileTest(file)) {\n return;\n }\n dispatch.current({ action: \"testRunning\" });\n\n fs.pushd(\"/samples\");\n await test.run();\n fs.popd();\n\n dispatch.current({ action: \"updateTestStep\" });\n dispatch.current({ action: \"testFinished\" });\n },\n\n tick(): Promise {\n return this.stepTest();\n },\n\n async stepTest(): Promise {\n assert(test.chipId === chip.id, \"Test and chip out of sync\");\n const done = await test.step();\n dispatch.current({ action: \"updateTestStep\" });\n if (done) {\n dispatch.current({ action: \"testFinished\" });\n }\n return done;\n },\n };\n\n const initialState: ChipPageState = (() => {\n const controls: ControlsState = {\n project,\n chips,\n chipName,\n hasBuiltin: REGISTRY.has(chipName),\n builtinOnly: isBuiltinOnly(chipName),\n runningTest: false,\n error: \"\",\n };\n\n const maybeChip = getBuiltinChip(controls.chipName);\n if (isErr(maybeChip)) {\n setStatus(display(Err(maybeChip)));\n chip = new Low();\n } else {\n chip = Ok(maybeChip);\n }\n\n const sim = reduceChip(chip);\n\n return {\n controls,\n files: {\n hdl: \"\",\n cmp: \"\",\n tst: \"\",\n out: \"\",\n },\n sim,\n };\n })();\n\n return { initialState, reducers, actions };\n}\n\nexport function useChipPageStore() {\n const { fs, setStatus, storage } = useContext(BaseContext);\n\n const dispatch = useRef(() => undefined);\n\n const { initialState, reducers, actions } = useMemo(\n () => makeChipStore(fs, setStatus, storage, dispatch),\n [fs, setStatus, storage, dispatch]\n );\n\n const [state, dispatcher] = useImmerReducer(\n reducers as unknown as Record<\n string,\n (state: ChipPageState, action?: unknown) => ChipPageState\n >,\n initialState\n );\n dispatch.current = dispatcher;\n\n return { state, dispatch, actions };\n}\n","import { Clock } from \"./chip/clock.js\";\n\nexport const MAX_STEPS = 1000;\n\nconst clock = Clock.get();\n\nexport abstract class Timer {\n frame() {\n this.tick();\n this.finishFrame();\n }\n\n abstract tick(): Promise | boolean;\n\n finishFrame() {\n clock.frame();\n }\n\n abstract reset(): void;\n\n abstract toggle(): void;\n\n steps = 1; // How many steps to take per update\n speed = 1000; // how often to update, in ms\n get running() {\n return this.#running;\n }\n\n #running = false;\n #sinceLastFrame = 0;\n #lastUpdate = 0;\n #run = async () => {\n if (!this.#running) {\n return;\n }\n const now = Date.now();\n const delta = now - this.#lastUpdate;\n this.#lastUpdate = now;\n this.#sinceLastFrame += delta;\n if (this.#sinceLastFrame > this.speed) {\n let done = false;\n for (let i = 0; i < Math.min(this.steps, MAX_STEPS) && !done; i++) {\n done = await this.tick();\n }\n this.finishFrame();\n if (done) {\n this.stop();\n }\n this.#sinceLastFrame -= this.speed;\n }\n requestAnimationFrame(this.#run);\n };\n\n start() {\n this.#running = true;\n this.#lastUpdate = Date.now() - this.speed;\n this.#run();\n this.toggle();\n }\n\n stop() {\n this.#running = false;\n this.toggle();\n }\n}\n","import { debounce } from \"@davidsouther/jiffies/lib/esm/debounce\";\nimport { Trans } from \"@lingui/macro\";\nimport MonacoEditor, { useMonaco } from \"@monaco-editor/react\";\nimport type * as monacoT from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { OnMount } from \"@monaco-editor/react\";\nimport ohm from \"ohm-js\";\nimport {\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { AppContext } from \"../App.context\";\n\nimport {\n Span,\n UNKNOWN_PARSE_ERROR,\n} from \"@nand2tetris/simulator/languages/base.js\";\n\nimport \"./editor.scss\";\n\nexport const ErrorPanel = ({ error }: { error?: ohm.MatchResult }) => {\n return error?.failed() ? (\n
\n \n Parse Error\n \n
\n        \n          {error?.message ?? error?.shortMessage ?? UNKNOWN_PARSE_ERROR}\n        \n      
\n
\n ) : (\n <>\n );\n};\n\nconst Textarea = ({\n value,\n onChange,\n language,\n disabled = false,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n disabled?: boolean;\n}) => {\n const [text, setText] = useState(value);\n return (\n {\n const value = e.target?.value;\n setText(value);\n onChange(value);\n }}\n />\n );\n};\n\nconst MONACO_LIGHT_THEME = \"vs\";\nconst MONACO_DARK_THEME = \"vs-dark\";\n\nconst makeHighlight = (\n monaco: typeof monacoT | null,\n editor: monacoT.editor.IStandaloneCodeEditor | undefined,\n highlight: Span | undefined,\n decorations: string[]\n): string[] => {\n if (!(editor && highlight)) return decorations;\n const model = editor.getModel();\n if (!model) return decorations;\n const start = model.getPositionAt(highlight.start);\n const end = model.getPositionAt(highlight.end);\n const range = monaco?.Range.fromPositions(start, end);\n const nextDecoration: monacoT.editor.IModelDeltaDecoration[] = [];\n if (range) {\n nextDecoration.push({\n range,\n options: { inlineClassName: \"highlight\" },\n });\n editor.revealRangeInCenter(range);\n }\n return editor.deltaDecorations(decorations, nextDecoration);\n};\n\nconst Monaco = ({\n value,\n onChange,\n language,\n error,\n disabled = false,\n highlight: currentHighlight,\n}: {\n value: string;\n onChange: (value: string) => void;\n language: string;\n error?: ohm.MatchResult | undefined;\n disabled?: boolean;\n highlight?: Span;\n}) => {\n const { theme } = useContext(AppContext);\n const monaco = useMonaco();\n\n const editor = useRef();\n const decorations = useRef([]);\n const highlight = useRef(undefined);\n\n const codeTheme = useCallback(() => {\n const isDark =\n theme === \"system\"\n ? window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n : theme === \"dark\";\n return isDark ? MONACO_DARK_THEME : MONACO_LIGHT_THEME;\n }, [theme]);\n\n const doHighlight = useCallback(() => {\n decorations.current = makeHighlight(\n monaco,\n editor.current,\n // I'm not sure why this makes things work, but it is load bearing.\n // Removing the empty span will cause the initial first-statement\n // highlight in the test view to not show. Setting it to [0, 1] will\n // cause a 1-character highlight in the editor view, so don't do that\n // either.\n highlight.current ?? { start: 0, end: 0 },\n decorations.current\n );\n }, [decorations, monaco, editor, highlight]);\n\n // Mark and center highlighted spans\n useEffect(() => {\n highlight.current = currentHighlight;\n doHighlight();\n }, [currentHighlight]);\n\n // Set options when mounting\n const onMount: OnMount = useCallback(\n (ed) => {\n editor.current = ed;\n editor.current?.updateOptions({\n fontFamily: `\"JetBrains Mono\", source-code-pro, Menlo, Monaco,\n Consolas, \"Roboto Mono\", \"Ubuntu Monospace\", \"Noto Mono\", \"Oxygen Mono\",\n \"Liberation Mono\", monospace, \"Apple Color Emoji\", \"Segoe UI Emoji\",\n \"Segoe UI Symbol\", \"Noto Color Emoji\"`,\n fontSize: 16,\n minimap: {\n enabled: false,\n },\n theme: codeTheme(),\n scrollBeyondLastLine: false,\n readOnly: disabled,\n });\n doHighlight();\n },\n [codeTheme]\n );\n\n // Set themes\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ theme: codeTheme() });\n }, [editor, codeTheme]);\n\n // Prevent editing disabled editors\n useEffect(() => {\n if (editor.current === undefined) return;\n editor.current.updateOptions({ readOnly: disabled });\n }, [editor, disabled]);\n\n // Add error markers on parse failure\n useEffect(() => {\n if (editor.current === undefined) return;\n if (monaco === null) return;\n const model = editor.current.getModel();\n if (model === null) return;\n if (error === undefined || error.succeeded()) {\n monaco.editor.setModelMarkers(model, language, []);\n return;\n }\n // Line 7, col 5:\n const { line, column, message } =\n /Line (?\\d+), col (?\\d+): (?.*)/.exec(\n error.shortMessage ?? \"\"\n )?.groups ?? { line: 1, column: 1, message: \"could not parse error\" };\n const startLineNumber = Number(line);\n const endLineNumber = startLineNumber;\n const startColumn = Number(column);\n const restOfLine = model\n .getLineContent(startLineNumber)\n .substring(startColumn - 1);\n let endColumn =\n startColumn + (restOfLine.match(/([^\\s]+)/)?.[0].length ?? 1);\n if (endColumn <= startColumn) {\n endColumn = startColumn + 1;\n }\n\n monaco.editor.setModelMarkers(model, language, [\n {\n message,\n startColumn,\n startLineNumber,\n endColumn,\n endLineNumber,\n severity: 8, // monacoT.MarkerSeverity.Error,\n },\n ]);\n }, [error, editor, monaco, language]);\n\n return (\n <>\n onChange(v)}\n language={language}\n onMount={onMount}\n />\n \n );\n};\n\nexport const Editor = ({\n className = \"\",\n style = {},\n disabled = false,\n value,\n onChange,\n grammar,\n language,\n highlight,\n}: {\n className?: string;\n style?: CSSProperties;\n disabled?: boolean;\n value: string;\n onChange: (source: string) => void;\n grammar: ohm.Grammar;\n language: string;\n highlight?: Span;\n}) => {\n const [error, setError] = useState();\n const { monaco } = useContext(AppContext);\n\n const parse = useCallback(\n (text = \"\") => {\n const parsed = grammar.match(text);\n setError(parsed.failed() ? parsed : undefined);\n },\n [setError, grammar]\n );\n\n useEffect(() => parse(value), [parse, value]);\n const doParse = useMemo(() => debounce(parse, 500), [parse]);\n\n const onChangeCB = useCallback(\n (text = \"\") => {\n onChange(text);\n doParse(text);\n },\n [doParse, onChange]\n );\n\n return (\n
\n {monaco.canUse && monaco.wants ? (\n \n ) : (\n <>\n \n \n \n )}\n
\n );\n};\n","export function debounce(fn, ms = 32) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => (clearTimeout(timer), fn(...args)), ms);\n return timer;\n };\n}\n","import { CSSProperties, ReactNode } from \"react\";\n\nexport const Panel = (props: {\n children: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}) => {\n return (\n
\n {props.header &&
{props.header}
}\n
{props.children}
\n {props.footer &&
{props.footer}
}\n
\n );\n};\n\nexport const Accordian = (props: {\n children: ReactNode;\n summary: ReactNode;\n className?: string;\n style?: CSSProperties;\n open?: boolean;\n}) => {\n return (\n \n \n
{props.summary}
\n
\n {props.children}\n \n );\n};\n","import { Trans } from \"@lingui/macro\";\nimport {\n CSSProperties,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport \"./chip.scss\";\n\nimport { makeVisualizationsWithId } from \"@nand2tetris/components/chips/visualizations.js\";\nimport { Clockface } from \"@nand2tetris/components/clockface.js\";\nimport { DiffTable } from \"@nand2tetris/components/difftable.js\";\nimport {\n FullPinout,\n PinContext,\n PinResetDispatcher,\n} from \"@nand2tetris/components/pinout.js\";\nimport { useStateInitializer } from \"@nand2tetris/components/react.js\";\nimport { Runbar } from \"@nand2tetris/components/runbar.js\";\nimport { BaseContext } from \"@nand2tetris/components/stores/base.context.js\";\nimport {\n Files,\n PROJECT_NAMES,\n isBuiltinOnly,\n useChipPageStore,\n} from \"@nand2tetris/components/stores/chip.store.js\";\nimport { CHIP_PROJECTS } from \"@nand2tetris/projects/index.js\";\nimport { CMP } from \"@nand2tetris/simulator/languages/cmp.js\";\nimport { HDL } from \"@nand2tetris/simulator/languages/hdl.js\";\nimport { TST } from \"@nand2tetris/simulator/languages/tst.js\";\nimport { Timer } from \"@nand2tetris/simulator/timer.js\";\nimport { AppContext } from \"../App.context\";\nimport { Icon } from \"../pico/icon\";\nimport { Editor } from \"../shell/editor\";\nimport { Accordian, Panel } from \"../shell/panel\";\n\nexport const Chip = () => {\n const { fs, setStatus } = useContext(BaseContext);\n const { filePicker, tracking } = useContext(AppContext);\n const { state, actions, dispatch } = useChipPageStore();\n\n const [hdl, setHdl] = useStateInitializer(state.files.hdl);\n const [tst, setTst] = useStateInitializer(state.files.tst);\n const [cmp, setCmp] = useStateInitializer(state.files.cmp);\n const [out] = useStateInitializer(state.files.out);\n\n useEffect(() => {\n actions.initialize();\n }, [actions]);\n\n useEffect(() => {\n tracking.trackPage(\"/chip\");\n }, [tracking]);\n\n const saveChip = () => {\n actions.saveChip(hdl);\n };\n\n useEffect(() => {\n tracking.trackEvent(\"action\", \"setProject\", state.controls.project);\n tracking.trackEvent(\"action\", \"setChip\", state.controls.chipName);\n }, []);\n\n const setProject = useCallback(\n (project: keyof typeof CHIP_PROJECTS) => {\n actions.setProject(project);\n tracking.trackEvent(\"action\", \"setProject\", project);\n },\n [actions, tracking]\n );\n\n const setChip = useCallback(\n (chip: string) => {\n actions.setChip(chip);\n tracking.trackEvent(\"action\", \"setChip\", chip);\n pinResetDispatcher.reset();\n },\n [actions, tracking]\n );\n\n const doEval = useCallback(() => {\n actions.eval();\n tracking.trackEvent(\"action\", \"eval\");\n }, [actions, tracking]);\n\n const compile = useRef<(files?: Partial) => void>(() => undefined);\n compile.current = async (files: Partial = {}) => {\n await actions.updateFiles({\n hdl: files.hdl,\n tst: files.tst ?? tst,\n cmp: files.cmp ?? cmp,\n });\n };\n\n const loadTest = useCallback(async () => {\n try {\n const path = await filePicker.select();\n const tst = await fs.readFile(path);\n await compile.current({ tst });\n } catch (e) {\n console.error(e);\n setStatus(`Failed to load into memory`);\n }\n }, [filePicker, setStatus, fs, compile]);\n\n const runner = useRef();\n useEffect(() => {\n runner.current = new (class ChipTimer extends Timer {\n async reset(): Promise {\n await compile.current();\n await actions.reset();\n }\n\n override finishFrame(): void {\n super.finishFrame();\n dispatch.current({ action: \"updateTestStep\" });\n }\n\n async tick(): Promise {\n return actions.stepTest();\n }\n\n toggle(): void {\n dispatch.current({ action: \"updateTestStep\" });\n }\n })();\n\n return () => {\n runner.current?.stop();\n };\n }, [compile, actions, dispatch]);\n\n const clockActions = useMemo(\n () => ({\n toggle() {\n actions.clock();\n tracking.trackEvent(\"action\", \"toggleClock\");\n },\n reset() {\n tracking.trackEvent(\"action\", \"resetClock\");\n actions.reset();\n },\n }),\n [actions]\n );\n\n const [useBuiltin, setUseBuiltin] = useState(false);\n const toggleUseBuiltin = () => {\n if (useBuiltin) {\n setUseBuiltin(false);\n actions.useBuiltin(false);\n } else {\n setUseBuiltin(true);\n actions.useBuiltin(true, hdl);\n }\n pinResetDispatcher.reset();\n };\n\n const selectors = (\n <>\n
\n {\n setProject(value as keyof typeof CHIP_PROJECTS);\n }}\n data-testid=\"project-picker\"\n >\n {PROJECT_NAMES.map(([number, label]) => (\n \n ))}\n \n {\n setChip(value);\n }}\n data-testid=\"chip-picker\"\n >\n {state.controls.chips.map((chip) => (\n \n {`${chip} ${isBuiltinOnly(chip) ? \"(given)\" : \"\"}`}\n \n ))}\n \n \n
\n \n );\n const hdlPanel = (\n \n
HDL
\n
\n {state.controls.hasBuiltin && !state.controls.builtinOnly && (\n \n )}\n
\n {selectors}\n \n }\n >\n {\n setHdl(source);\n compile.current(\n useBuiltin || state.controls.builtinOnly ? {} : { hdl: source }\n );\n }}\n grammar={HDL.parser}\n language={\"hdl\"}\n disabled={useBuiltin || state.controls.builtinOnly}\n />\n \n );\n\n const [inputValid, setInputValid] = useState(true);\n\n const chipButtons = (\n
\n \n Eval\n \n \n Clock:{\"\\u00a0\"}\n \n \n \n Reset\n \n
\n );\n\n const visualizations: [string, ReactNode][] = makeVisualizationsWithId(\n {\n parts: state.sim.chip,\n },\n () => {\n dispatch.current({ action: \"updateChip\" });\n }\n );\n\n const pinResetDispatcher = new PinResetDispatcher();\n\n const pinsPanel = (\n \n
\n Chip {state.controls.chipName}\n
\n {chipButtons}\n \n }\n >\n {state.sim.invalid ? (\n Syntax errors in the HDL code\n ) : (\n <>\n \n \n \n {visualizations.length > 0 && (\n Visualization} open={true}>\n
{visualizations.map(([_, v]) => v)}
\n
\n )}\n \n )}\n \n );\n\n const [selectedTestTab, doSetSelectedTestTab] = useState<\n \"tst\" | \"cmp\" | \"out\"\n >(\"tst\");\n\n const setSelectedTestTab = useCallback(\n (tab: typeof selectedTestTab) => {\n doSetSelectedTestTab(tab);\n tracking.trackEvent(\"tab\", \"change\", tab);\n },\n [tracking]\n );\n\n const testPanel = (\n \n
\n Test\n
\n
\n {runner.current && }\n
\n
\n \n
\n \n }\n >\n
\n \n \n
\n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n\n return (\n
\n {hdlPanel}\n {pinsPanel}\n {testPanel}\n
\n );\n};\n\nexport default Chip;\n"],"names":["ALUComponent","A","op","D","out","flag","_jsxs","children","_jsx","width","height","xmlns","x","y","fill","points","stroke","xmlSpace","textAnchor","fontFamily","fontSize","strokeWidth","id","COMMANDS_ALU","RegisterComponent","name","bits","dec","KeyMap","Enter","Backspace","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","Escape","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","Keyboard","keyboard","update","useState","enabled","setEnabled","character","setCharacter","busVoltage","setBits","currentKey","setKey","key","className","onClick","onKeyDown","event","preventDefault","keypress","mapping","undefined","length","code","charCodeAt","keyPressToHackCharacter","onKeyUp","clearKey","Sizes","none","sm","md","lg","xl","full","Sides","t","r","l","b","tl","tr","bl","br","Widths","isSide","v","getSize","size","getSide","side","rounded","sized","reduce","prev","curr","borderRadius","amount","block","display","die","error","args","msg","Error","map","s","join","isDraft","value","DRAFT_STATE","isDraftable","proto","Object","getPrototypeOf","Ctor","hasOwnProperty","call","constructor","Function","toString","objectCtorString","Array","isArray","DRAFTABLE","_value$constructor","isMap","isSet","each","obj","iter","enumerableOnly","getArchtype","keys","ownKeys","forEach","entry","index","thing","state","type_","has","prop","prototype","get","set","propOrOldValue","delete","add","is","target","hasMap","Map","hasSet","Set","latest","copy_","base_","shallowCopy","base","slice","descriptors","getOwnPropertyDescriptors","i","desc","writable","configurable","enumerable","create","freeze","deep","isFrozen","clear","dontMutateFrozenCollections","getPlugin","pluginKey","plugin","plugins","getCurrentScope","currentScope","usePatchesInScope","scope","patchListener","patches_","inversePatches_","patchListener_","revokeScope","leaveScope","drafts_","revokeDraft","parent_","enterScope","immer","immer_","canAutoFreeze_","unfinalizedDrafts_","draft","revoke_","revoked_","processResult","result","baseDraft","isReplaced","useProxies_","willFinalizeES5_","modified_","finalize","maybeFreeze","generateReplacementPatches_","NOTHING","rootScope","path","childValue","finalizeProperty","scope_","finalized_","draft_","generatePatches_","parentState","targetObject","rootPath","res","assigned_","concat","autoFreeze_","peek","getDescriptorFromProto","source","getOwnPropertyDescriptor","markChanged","prepareCopy","createProxy","parent","proxyMap_","proxySet_","isManual_","traps","objectTraps","arrayTraps","Proxy","revocable","revoke","proxy","createES5Proxy_","push","current","currentImpl","copy","archType","hasChanges_","copyHelper","from","hasSymbol","Symbol","hasProxies","Reflect","for","iterator","getOwnPropertySymbols","getOwnPropertyNames","_desc$get","currentState","deleteProperty","owner","defineProperty","setPrototypeOf","fn","arguments","apply","this","Immer","e","config","recipe","defaultBase","self","_this","produce","_this2","hasError","Promise","then","p","ip","produceWithPatches","patches","inversePatches","n","nextState","useProxies","setUseProxies","autoFreeze","setAutoFreeze","createDraft","finishDraft","applyPatches","patch","applyPatchesImpl","applyPatches_","bind","useImmerReducer","reducers","initialState","useReducer","command","action","payload","useStateInitializer","init","setState","useEffect","Mode","props","mode","setMode","setValue","view","style","cursor","doSelect","useCallback","ref","select","doChange","onChange","edit","position","zIndex","left","marginTop","onBlur","onKeyPress","type","defaultValue","render","doScroll","scrollTop","totalHeight","toleranceHeight","bufferedItems","settings","itemHeight","minIndex","maxIndex","Math","floor","data","offset","limit","start","max","min","getData","topPaddingHeight","bottomPaddingHeight","viewportRef","useRef","useMemo","Number","MAX_SAFE_INTEGER","startIndex","count","tolerance","fillVirtualScrollSettings","startState","adapter","viewportHeight","reducer","scrollReducer","dispatchScroll","row","initialScroll","div","rows","d","rowKey","overflowY","overflowAnchor","onScroll","useClockReset","reset","subscription","Clock","reset$","subscribe","unsubscribe","displayClock","Clockface","clockface","setClockface","$","useClockface","whiteSpace","MemoryBlock","memory","jmp","highlight","editable","format","range","MemoryCell","VirtualScroll","background","hex","flex","textAlign","InlineEdit","newValue","Memory","fmt","setFormat","setJmp","goto","setGoto","jumpTo","isNaN","parseInt","isFinite","doUpdate","role","placeholder","FORMATS","option","checked","bin","asm","doFormat","WHITE","mem","pixel","color","Screen","frameFinished","canvas","draw","ctx","getContext","image","assertExists","getImageData","col","putImageData","drawImage","ctxRef","frame$","clearRect","maxWidth","boxSizing","marginInline","margin","borderTop","borderLeft","borderBottom","borderRight","makeVisualization","chip","updateAction","ALU","in","voltage","HIGH","Flags","Register","PC","KeyboardComponent","ScreenComponent","RAM","MemoryComponent","address","RAM8","CPU","decode","am","vis","parts","filter","ChipDisplayInfo","chipName","unsigned","BUILTIN_REGISTRY","getBuiltinChip","isOk","pins","Ok","ins","entries","outs","pin","signBehaviors","includes","UNSIGNED_PINS","PinContext","createContext","reducePin","reverse","reducePins","FullPinout","sim","inPins","outPins","internalPins","displayInfo","PinoutBlock","header","toggle","setInputValid","disabled","pending","enableEdit","hideInternal","colSpan","immPin","Pin","signed","isSigned","internal","isBin","setIsBin","inputValid","decimal","setDecimal","resetDispatcher","useContext","PinResetDispatcher","registerCallback","setInputValidity","valid","updatePins","flexDirection","alignItems","backgroundColor","positive","replace","numeric","pow","handleDecimalChange","callback","callbacks","Runbar","runner","timer","dispatch","running","speed","steps","finishFrame","setSteps","setSpeed","actions","frame","stop","makeTimerStore","dispatcher","useTimer","label","PROJECT_NAMES","getChips","project","CHIP_ORDER","BUILTIN_CHIP_PROJECTS","CHIP_PROJECTS","makeHdl","isBuiltinOnly","values","flat","getBuiltinCode","template","ChipProjects","BUILTIN_CHIPS","CHIPS","getTemplate","bodyComment","builtinLine","reduceChip","invalid","clocked","clock","makeChipStore","fs","setStatus","storage","dropdowns","chips","findDropdowns","Low","test","ChipTest","usingBuiltin","builtinOnly","setFiles","hdl","files","tst","cmp","updateChip","controls","setProject","setChip","hasBuiltin","REGISTRY","testRunning","runningTest","testFinished","passed","trim","updateTestStep","log","currentStep","span","done","end","useBuiltin","loadChip","updateFiles","compileChip","compileTest","remove","maybeParsed","HDL","isErr","Err","buildChip","maybeChip","replaceChip","nextChip","nextPin","eval","with","fsName","ext","all","readFile","catch","saveChip","prj","writeFile","isLow","doUseBuiltin","oldHdl","builtinName","initialize","file","TST","setFileSystem","runTest","pushd","run","popd","tick","stepTest","assert","chipId","step","Timer","now","Date","delta","requestAnimationFrame","ErrorPanel","failed","open","message","shortMessage","UNKNOWN_PARSE_ERROR","Textarea","language","text","setText","Monaco","currentHighlight","theme","AppContext","monaco","useMonaco","editor","decorations","codeTheme","window","matchMedia","matches","doHighlight","model","getModel","getPositionAt","Range","fromPositions","nextDecoration","options","inlineClassName","revealRangeInCenter","deltaDecorations","makeHighlight","onMount","ed","updateOptions","minimap","scrollBeyondLastLine","readOnly","succeeded","setModelMarkers","exec","groups","line","column","startLineNumber","endLineNumber","startColumn","endColumn","getLineContent","substring","match","severity","Editor","grammar","setError","parse","parsed","doParse","ms","clearTimeout","setTimeout","debounce","onChangeCB","canUse","wants","Panel","footer","Accordian","summary","Chip","BaseContext","filePicker","tracking","useChipPageStore","setHdl","setTst","setCmp","trackPage","trackEvent","pinResetDispatcher","doEval","compile","loadTest","console","clockActions","setUseBuiltin","selectors","number","hdlPanel","tabIndex","chipButtons","visualizations","part","makeVisualizationsWithId","pinsPanel","Provider","selectedTestTab","doSetSelectedTestTab","setSelectedTestTab","tab","testPanel","CMP"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.85505dfb.js b/static/js/main.2866a11b.js similarity index 99% rename from static/js/main.85505dfb.js rename to static/js/main.2866a11b.js index 0b684cdfb..c02df380a 100644 --- a/static/js/main.85505dfb.js +++ b/static/js/main.2866a11b.js @@ -1,3 +1,3 @@ -/*! For license information please see main.85505dfb.js.LICENSE.txt */ -!function(){var e={8016:function(e,t,n){"use strict";n.d(t,{Il:function(){return f},bp:function(){return s}});var r=n(1026),a=n(6167),o=n(9956),i=n(2147),l=n(7685),u=n(7203);function c(){var e=!0,t=(0,a.useState)(e),n=(0,r.Z)(t,2),o=n[0],i=n[1],l=(0,a.useCallback)((function(e){i(!!e)}),[e]);return{canUse:e,wants:o,toggle:l}}function s(){arguments.length>0&&void 0!==arguments[0]||new o.Wd;var e=(0,a.useState)("system"),t=(0,r.Z)(e,2),n=t[0],s=t[1];return{monaco:c(),settings:(0,i.R)(),filePicker:(0,l.ss)(),tracking:(0,u.rS)(),theme:n,setTheme:s}}var f=(0,a.createContext)({monaco:{canUse:!0,wants:!0,toggle:function(){}},filePicker:{close:function(){},open:function(){},select:function(){return Promise.reject("")},isOpen:!1},settings:{close:function(){},open:function(){},isOpen:!1},tracking:{canTrack:!1,haveAsked:!1,accept:function(){},reject:function(){},trackEvent:function(){},trackPage:function(){}},theme:"system",setTheme:function(){}})},9622:function(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",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",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","Invalid Chip":"\u0128\u0144v\xe0\u013a\u0129\u010f \u0106\u0125\u0129\u01a5",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",Save:"\u015a\xe0v\u0113",Settings:"\u015a\u0113\u0163\u0163\u0129\u0144\u011d\u015b","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",Visualizations:"V\u0129\u015b\u0169\xe0\u013a\u0129\u017a\xe0\u0163\u0129\u014d\u0144\u015b","{0}":[["0"]]}}},9270:function(e){e.exports={messages:{"Allow anonymous interaction tracking":"Allow anonymous interaction tracking",Builtin:"Builtin",Chip:"Chip","Choose file":"Choose file",Clock:"Clock",Dark:"Dark",Editor:"Editor",English:"English",Eval:"Eval",Failed:"Failed",Files:"Files","Invalid Chip":"Invalid Chip",Language:"Language",Light:"Light","Parse Error":"Parse Error",Passed:"Passed",Project:"Project",Pseudolocale:"Pseudolocale",References:"References",Reset:"Reset",Samples:"Samples",Save:"Save",Settings:"Settings","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",Visualizations:"Visualizations","{0}":[["0"]]}}},659:function(e,t,n){"use strict";n.d(t,{J:function(){return a}});var r=n(7878),a=function(e){var t=e.name;return(0,r.jsx)("span",{className:"material-symbols-outlined",children:t})}},2147:function(e,t,n){"use strict";n.d(t,{R:function(){return o}});var r=n(1026),a=n(6167);function o(){var e=(0,a.useState)(!1),t=(0,r.Z)(e,2),n=t[0],o=t[1];return{isOpen:n,open:function(){o(!0)},close:function(){o(!1)}}}},7685:function(e,t,n){"use strict";n.d(t,{GB:function(){return y},ss:function(){return m}});var r=n(1026),a=n(4649),o=n(189),i=n(1092),l=n(7791),u=n(8061),c=n(8698),s=n(6167),f=n(8016),d=n(659),p=n(2147),h=n(7878),v="file selected";function m(){var e=(0,p.R)(),t=(0,s.useRef)(),n=(0,s.useCallback)((0,l.Z)((0,i.Z)().mark((function n(){return(0,i.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return e.open(),n.abrupt("return",new Promise((function(e){t.current=e})));case 2:case"end":return n.stop()}}),n)}))),[e,t]);return(0,o.Z)((0,o.Z)({},e),{},(0,a.Z)({select:n},v,t))}var g=function(e){var t=e.onSelect,n=e.stats,r=e.highlighted,a=void 0!==r&&r;return(0,h.jsx)("div",{children:(0,h.jsxs)("button",{className:"flex row justify-start outline ".concat(a?"":"secondary"),style:{textAlign:"left"},onClick:t,children:[(0,h.jsx)(d.J,{name:n.isDirectory()?"folder":"draft"}),n.name]})})},y=function(){var e=(0,s.useContext)(c.r),t=e.fs,n=e.setStatus,a=(0,s.useContext)(f.Il).filePicker,o=(0,s.useState)([]),i=(0,r.Z)(o,2),l=i[0],d=i[1],p=(0,s.useState)(""),m=(0,r.Z)(p,2),y=m[0],b=m[1],w=t.cwd();(0,s.useEffect)((function(){t.scandir(t.cwd()).then((function(e){d(e)}))}),[t,w,d]);var k=(0,s.useCallback)((function(e){b(""),t.cd(e),t.scandir(t.cwd()).then((function(e){d(e)}))}),[t,b,d]),S=(0,s.useCallback)((function(e){b(e)}),[b]),x=(0,s.useCallback)((function(){var e,t;n("Selected ".concat(y)),a.close(),null===(e=(t=a[v]).current)||void 0===e||e.call(t,y)}),[y,a,n]);return(0,h.jsx)("dialog",{open:a.isOpen,children:(0,h.jsxs)("article",{style:{width:"350px"},children:[(0,h.jsxs)("header",{children:[(0,h.jsx)("p",{children:(0,h.jsx)(u.cC,{id:"Choose file"})}),(0,h.jsx)("a",{style:{color:"rgba(0, 0, 0, 0)"},className:"close",href:"#root",onClick:function(e){e.preventDefault(),a.close()},children:"close"})]}),(0,h.jsxs)("main",{children:[(0,h.jsx)("div",{children:(0,h.jsx)("b",{children:t.cwd()})}),"/"!==t.cwd()&&(0,h.jsx)(g,{stats:{isDirectory:function(){return!0},isFile:function(){return!1},name:".."},onSelect:function(){return k("..")}}),l.map((function(e){return(0,h.jsx)(g,{stats:e,highlighted:e.name===y,onSelect:function(){return e.isDirectory()?k(e.name):S(e.name)}},e.name)}))]}),(0,h.jsx)("footer",{children:(0,h.jsx)("button",{disabled:!y,onClick:x,children:"Select"})})]})})}},7203:function(e,t,n){"use strict";n.d(t,{Hy:function(){return v},LK:function(){return m},rS:function(){return h}});var r=n(1026),a=n(132),o=n(5541),i=n(6167),l=n(7878),u="/tracking/canTrack",c="yes",s=[c,"no"],f=!1;function d(e){a.ZP.send({hitType:"pageview",page:e})}function p(e,t,n,r){var i,l;if(!f){var u="string"===typeof e?{category:e,action:(0,o.kP)(t),label:n&&r?{label:n,value:r}:void 0}:e;a.ZP.event({category:u.category,action:u.action,nonInteraction:!u.interaction,label:null===(i=u.label)||void 0===i?void 0:i.label,value:null===(l=u.label)||void 0===l?void 0:l.value})}}function h(){var e,t=null!==(e=localStorage[u])&&void 0!==e?e:"",n=(0,i.useState)(t===c),o=(0,r.Z)(n,2),l=o[0],h=o[1],v=(0,i.useState)(s.includes(t)||"1"===navigator.doNotTrack),m=(0,r.Z)(v,2),g=m[0],y=m[1];return{canTrack:l,haveAsked:g,accept:(0,i.useCallback)((function(){localStorage[u]=c,h(!0),y(!0),function(){var e;a.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"),a.ZP.send("pageview")}()}),[h,y]),reject:(0,i.useCallback)((function(){localStorage[u]="no",h(!1),y(!0),f=!0}),[h,y]),trackEvent:p,trackPage:d}}function v(){var e=h(),t=e.accept,n=e.reject,a=e.haveAsked,o=(0,i.useState)(!a),u=(0,r.Z)(o,2),c=u[0],s=u[1],f=(0,i.useCallback)((function(){s(!1)}),[s]),d=(0,i.useCallback)((function(){t(),f()}),[t,f]),p=(0,i.useCallback)((function(){n(),f()}),[n,f]);return(0,l.jsx)(l.Fragment,{children:c&&(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:p,children:"Reject"}),(0,l.jsx)("a",{href:"#accept",role:"button",className:"accept",onClick:d,children:"Accept"}),(0,l.jsx)("a",{href:"#close",role:"button",className:"close secondary",onClick:f,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."})]})}},7536:function(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 l(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;o1&&void 0!==arguments[1]?arguments[1]:{};m.initial(e),m.handler(t);var n={current:e},r=d(b)(n,t),a=d(y)(n),o=d(m.changes)(e),i=d(g)(n);function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e};return m.selector(e),e(n.current)}function u(e){f(r,a,o,i)(e)}return[l,u]}},k=w,S={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};var x=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],r=(0,H.useRef)(!0);(0,H.useEffect)(r.current||!n?function(){r.current=!1}:e,t)};function ie(){}function le(e,t,n,r){return function(e,t){return e.editor.getModel(ue(e,t))}(e,r)||function(e,t,n,r){return e.editor.createModel(t,n,r&&ue(e,r))}(e,t,n,r)}function ue(e,t){return e.Uri.parse(t)}function ce(e){var t=e.original,n=e.modified,r=e.language,a=e.originalLanguage,o=e.modifiedLanguage,i=e.originalModelPath,l=e.modifiedModelPath,u=e.keepCurrentOriginalModel,c=e.keepCurrentModifiedModel,s=e.theme,f=e.loading,d=e.options,p=e.height,h=e.width,v=e.className,m=e.wrapperProps,g=e.beforeMount,y=e.onMount,b=(0,H.useState)(!1),w=(0,q.Z)(b,2),k=w[0],S=w[1],x=(0,H.useState)(!0),_=(0,q.Z)(x,2),E=_[0],C=_[1],O=(0,H.useRef)(null),P=(0,H.useRef)(null),j=(0,H.useRef)(null),T=(0,H.useRef)(y),L=(0,H.useRef)(g);ae((function(){var e=W.init();return e.then((function(e){return(P.current=e)&&C(!1)})).catch((function(e){return"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e)})),function(){return O.current?function(){var e,t,n=O.current.getModel();u||null===(e=n.original)||void 0===e||e.dispose();c||null===(t=n.modified)||void 0===t||t.dispose();O.current.dispose()}():e.cancel()}})),oe((function(){var e=O.current.getModifiedEditor();e.getOption(P.current.editor.EditorOption.readOnly)?e.setValue(n):n!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),e.pushUndoStop())}),[n],k),oe((function(){O.current.getModel().original.setValue(t)}),[t],k),oe((function(){var e=O.current.getModel(),t=e.original,n=e.modified;P.current.editor.setModelLanguage(t,a||r),P.current.editor.setModelLanguage(n,o||r)}),[r,a,o],k),oe((function(){P.current.editor.setTheme(s)}),[s],k),oe((function(){O.current.updateOptions(d)}),[d],k);var N=(0,H.useCallback)((function(){L.current(P.current);var e=le(P.current,t,a||r,i),u=le(P.current,n,o||r,l);O.current.setModel({original:e,modified:u})}),[r,n,o,t,a,i,l]),A=(0,H.useCallback)((function(){O.current=P.current.editor.createDiffEditor(j.current,(0,Q.Z)({automaticLayout:!0},d)),N(),P.current.editor.setTheme(s),S(!0)}),[d,s,N]);return(0,H.useEffect)((function(){k&&T.current(O.current,P.current)}),[k]),(0,H.useEffect)((function(){!E&&!k&&A()}),[E,k,A]),H.createElement(re,{width:h,height:p,isEditorReady:k,loading:f,_ref:j,className:v,wrapperProps:m})}ce.propTypes={original:K().string,modified:K().string,language:K().string,originalLanguage:K().string,modifiedLanguage:K().string,originalModelPath:K().string,modifiedModelPath:K().string,keepCurrentOriginalModel:K().bool,keepCurrentModifiedModel:K().bool,theme:K().string,loading:K().oneOfType([K().element,K().string]),options:K().object,width:K().oneOfType([K().number,K().string]),height:K().oneOfType([K().number,K().string]),className:K().string,wrapperProps:K().object,beforeMount:K().func,onMount:K().func},ce.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:ie,onMount:ie};var se=function(){var e=(0,H.useState)(W.__getMonacoInstance()),t=(0,q.Z)(e,2),n=t[0],r=t[1];return ae((function(){var e;return n||(e=W.init()).then((function(e){r(e)})),function(){var t;return null===(t=e)||void 0===t?void 0:t.cancel()}})),n};var fe=function(e){var t=(0,H.useRef)();return(0,H.useEffect)((function(){t.current=e}),[e]),t.current},de=new Map;function pe(e){var t=e.defaultValue,n=e.defaultLanguage,r=e.defaultPath,a=e.value,o=e.language,i=e.path,l=e.theme,u=e.line,c=e.loading,s=e.options,f=e.overrideServices,d=e.saveViewState,p=e.keepCurrentModel,h=e.width,v=e.height,m=e.className,g=e.wrapperProps,y=e.beforeMount,b=e.onMount,w=e.onChange,k=e.onValidate,S=(0,H.useState)(!1),x=(0,q.Z)(S,2),_=x[0],E=x[1],C=(0,H.useState)(!0),O=(0,q.Z)(C,2),P=O[0],j=O[1],T=(0,H.useRef)(null),L=(0,H.useRef)(null),N=(0,H.useRef)(null),A=(0,H.useRef)(b),R=(0,H.useRef)(y),M=(0,H.useRef)(null),D=(0,H.useRef)(a),z=fe(i),F=(0,H.useRef)(!1);ae((function(){var e=W.init();return e.then((function(e){return(T.current=e)&&j(!1)})).catch((function(e){return"cancelation"!==(null===e||void 0===e?void 0:e.type)&&console.error("Monaco initialization: error:",e)})),function(){return L.current?function(){var e,t;null===(e=M.current)||void 0===e||e.dispose(),p?d&&de.set(i,L.current.saveViewState()):null===(t=L.current.getModel())||void 0===t||t.dispose();L.current.dispose()}():e.cancel()}})),oe((function(){var e=le(T.current,t||a,n||o,i);e!==L.current.getModel()&&(d&&de.set(z,L.current.saveViewState()),L.current.setModel(e),d&&L.current.restoreViewState(de.get(i)))}),[i],_),oe((function(){L.current.updateOptions(s)}),[s],_),oe((function(){L.current.getOption(T.current.editor.EditorOption.readOnly)?L.current.setValue(a):a!==L.current.getValue()&&(L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),L.current.pushUndoStop())}),[a],_),oe((function(){T.current.editor.setModelLanguage(L.current.getModel(),o)}),[o],_),oe((function(){void 0!==u&&L.current.revealLine(u)}),[u],_),oe((function(){T.current.editor.setTheme(l)}),[l],_);var I=(0,H.useCallback)((function(){if(!F.current){R.current(T.current);var e=i||r,u=le(T.current,a||t,n||o,e);L.current=T.current.editor.create(N.current,(0,Q.Z)({model:u,automaticLayout:!0},s),f),d&&L.current.restoreViewState(de.get(e)),T.current.editor.setTheme(l),E(!0),F.current=!0}}),[t,n,r,a,o,i,s,f,d,l]);return(0,H.useEffect)((function(){_&&A.current(L.current,T.current)}),[_]),(0,H.useEffect)((function(){!P&&!_&&I()}),[P,_,I]),D.current=a,(0,H.useEffect)((function(){var e,t;_&&w&&(null===(e=M.current)||void 0===e||e.dispose(),M.current=null===(t=L.current)||void 0===t?void 0:t.onDidChangeModelContent((function(e){w(L.current.getValue(),e)})))}),[_,w]),(0,H.useEffect)((function(){if(_){var e=T.current.editor.onDidChangeMarkers((function(e){var t,n=null===(t=L.current.getModel())||void 0===t?void 0:t.uri;if(n&&e.find((function(e){return e.path===n.path}))){var r=T.current.editor.getModelMarkers({resource:n});null===k||void 0===k||k(r)}}));return function(){null===e||void 0===e||e.dispose()}}}),[_,k]),H.createElement(re,{width:h,height:v,isEditorReady:_,loading:c,_ref:N,className:m,wrapperProps:g})}pe.propTypes={defaultValue:K().string,defaultPath:K().string,defaultLanguage:K().string,value:K().string,language:K().string,path:K().string,theme:K().string,line:K().number,loading:K().oneOfType([K().element,K().string]),options:K().object,overrideServices:K().object,saveViewState:K().bool,keepCurrentModel:K().bool,width:K().oneOfType([K().number,K().string]),height:K().oneOfType([K().number,K().string]),className:K().string,wrapperProps:K().object,beforeMount:K().func,onMount:K().func,onChange:K().func,onValidate:K().func},pe.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:ie,onMount:ie,onValidate:ie};var he=pe,ve=(0,H.memo)(he)},5290:function(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=s,fe++):(n=a,0===ve&&ke(f));n!==a&&Me()!==a&&(r=Ee())!==a&&Me()!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===ve&&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,i,l,u,c,y,b,w;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));if(r!==a)if(Me()!==a)if((o=Ee())!==a)if(Me()!==a)if(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a)if(Me()!==a)if(l=fe,e.substr(fe,6)===m?(u=m,fe+=6):(u=a,0===ve&&ke(g)),u!==a&&(l,x=u,n.strict&&De.unshift(!1),u=x),(l=u)!==a)if((u=Me())!==a)if(44===e.charCodeAt(fe)?(c=h,fe++):(c=a,0===ve&&ke(v)),c!==a)if(Me()!==a){if(y=[],(b=Ce())!==a)for(;b!==a;)y.push(b),b=Ce();else y=a;y!==a&&(b=Me())!==a?(125===e.charCodeAt(fe)?(w=d,fe++):(w=a,0===ve&&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,i,l,u,c,m,g,S,x;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));if(r!==a)if(Me()!==a)if((o=Ee())!==a)if(Me()!==a)if(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a)if(Me()!==a)if(l=fe,e.substr(fe,6)===y?(u=y,fe+=6):(u=a,0===ve&&ke(b)),u===a&&(e.substr(fe,13)===w?(u=w,fe+=13):(u=a,0===ve&&ke(k))),u!==a&&(l,_=u,De.unshift(!0),u=_),(l=u)!==a)if((u=Me())!==a)if(44===e.charCodeAt(fe)?(c=h,fe++):(c=a,0===ve&&ke(v)),c!==a)if(Me()!==a)if(m=function(){var t,n,r,o,i;ve++,t=fe,n=Me(),n!==a?(e.substr(fe,6)===O?(r=O,fe+=6):(r=a,0===ve&&ke(P)),r!==a&&Me()!==a?(58===e.charCodeAt(fe)?(o=":",fe++):(o=a,0===ve&&ke(j)),o!==a&&Me()!==a&&(i=Re())!==a&&Me()!==a?(t,t=n=i):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a);ve--,t===a&&(n=a,0===ve&&ke(C));return t}(),m===a&&(m=null),m!==a){if(g=[],(S=Oe())!==a)for(;S!==a;)g.push(S),S=Oe();else g=a;g!==a&&(S=Me())!==a?(125===e.charCodeAt(fe)?(x=d,fe++):(x=a,0===ve&&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,l,m,g)):(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,i,l,u,c;t=fe,123===e.charCodeAt(fe)?(r=s,fe++):(r=a,0===ve&&ke(f));r!==a&&Me()!==a&&(o=Ee())!==a&&Me()!==a?(44===e.charCodeAt(fe)?(i=h,fe++):(i=a,0===ve&&ke(v)),i!==a&&Me()!==a?(l=function(){var t,r,o,i,l;e.substr(fe,6)===L?(t=L,fe+=6):(t=a,0===ve&&ke(N));t===a&&(e.substr(fe,4)===A?(t=A,fe+=4):(t=a,0===ve&&ke(R)),t===a&&(e.substr(fe,4)===M?(t=M,fe+=4):(t=a,0===ve&&ke(D)),t===a&&(e.substr(fe,8)===z?(t=z,fe+=8):(t=a,0===ve&&ke(F)),t===a&&(e.substr(fe,7)===I?(t=I,fe+=7):(t=a,0===ve&&ke(Z)),t===a&&(e.substr(fe,8)===U?(t=U,fe+=8):(t=a,0===ve&&ke(V)),t===a&&(t=fe,r=fe,ve++,e.substr(fe,6)===m?(o=m,fe+=6):(o=a,0===ve&&ke(g)),ve--,o===a?r=void 0:(fe=r,r=a),r!==a?(o=fe,ve++,e.substr(fe,6)===y?(i=y,fe+=6):(i=a,0===ve&&ke(b)),ve--,i===a?o=void 0:(fe=o,o=a),o!==a?(i=fe,ve++,e.substr(fe,13)===w?(l=w,fe+=13):(l=a,0===ve&&ke(k)),ve--,l===a?i=void 0:(fe=i,i=a),i!==a&&(l=Ee())!==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}}(l)?void 0:a)!==a?(t,t=r=l):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)):(fe=t,t=a)))))));return t}(),l!==a&&Me()!==a?(u=function(){var t,r,o,i,l;if(t=fe,r=Me(),r!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===ve&&ke(v)),o!==a){for(i=[],l=_e();l!==a;)i.push(l),l=_e();i!==a?(fe,(l=(l=!n.strict)?void 0:a)!==a?(t,t=r={tokens:i}):(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=Me())!==a)if(44===e.charCodeAt(fe)?(o=h,fe++):(o=a,0===ve&&ke(v)),o!==a){for(i=[],l=je();l!==a;)i.push(l),l=je();i!==a?(t,t=r={tokens:[i.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)?(c=d,fe++):(c=a,0===ve&&ke(p)),c!==a?(t,t=r={type:"function",arg:o,key:l,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===ve&&ke(l)),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=Ae())!==a)for(;o!==a;)r.push(o),o=Ae();else r=a;r!==a&&(t,r=c(r)),t=r}return t}function Ee(){var t,n,r;if(ve++,t=fe,n=[],x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(_)),r!==a)for(;r!==a;)n.push(r),x.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(_));else n=a;return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(S)),t}function Ce(){var e,t,n;return e=fe,Me()!==a&&(t=Ee())!==a&&Me()!==a&&(n=Pe())!==a?(e,e=E(t,n)):(fe=e,e=a),e}function Oe(){var t,n,r;return t=fe,Me()!==a?(n=function(){var t,n,r;t=Ee(),t===a&&(t=fe,61===e.charCodeAt(fe)?(n="=",fe++):(n=a,0===ve&&ke(T)),n!==a&&(r=Re())!==a?(t,t=n=r):(fe=t,t=a));return t}(),n!==a&&Me()!==a&&(r=Pe())!==a?(t,t=E(n,r)):(fe=t,t=a)):(fe=t,t=a),t}function Pe(){var t,n,r,o,i,l;if(t=fe,123===e.charCodeAt(fe)?(n=s,fe++):(n=a,0===ve&&ke(f)),n!==a)if(r=fe,(o=Me())!==a?(i=fe,ve++,123===e.charCodeAt(fe)?(l=s,fe++):(l=a,0===ve&&ke(f)),ve--,l!==a?(fe=i,i=void 0):i=a,i!==a?r=o=[o,i]:(fe=r,r=a)):(fe=r,r=a),r===a&&(r=null),r!==a){for(o=[],i=_e();i!==a;)o.push(i),i=_e();o!==a&&(i=Me())!==a?(125===e.charCodeAt(fe)?(l=d,fe++):(l=a,0===ve&&ke(p)),l!==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 je(){var t,n,r,o;if(ve++,t=fe,n=[],$.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(W)),r!==a)for(;r!==a;)n.push(r),$.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(W));else n=a;if(n!==a&&(t,n=n.join("")),(t=n)===a&&(t=Te())===a&&(t=fe,39===e.charCodeAt(fe)?(n=H,fe++):(n=a,0===ve&&ke(Q)),n!==a&&(r=Le())!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&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=s,fe++):(n=a,0===ve&&ke(f)),n!==a){for(r=[],o=je();o!==a;)r.push(o),o=je();r!==a?(125===e.charCodeAt(fe)?(o=d,fe++):(o=a,0===ve&&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 ve--,t===a&&(n=a,0===ve&&ke(B)),t}function Te(){var t,n;return ve++,t=fe,"''"===e.substr(fe,2)?(n="''",fe+=2):(n=a,0===ve&&ke(G)),n!==a&&(t,n="'"),ve--,(t=n)===a&&(n=a,0===ve&&ke(q)),t}function Le(){var t,n,r;if((t=Te())===a){if(t=fe,n=[],K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(Y)),r!==a)for(;r!==a;)n.push(r),K.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(Y));else n=a;n!==a&&(t,n=c(n)),t=n}return t}function Ne(){var t,n,r,o,i,l;if(ve++,t=function(){var t,n,r,o;if(t=fe,"'{"===e.substr(fe,2)?(n="'{",fe+=2):(n=a,0===ve&&ke(X)),n!==a){for(r=[],o=Le();o!==a;)r.push(o),o=Le();r!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&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===ve&&ke(J)),n!==a){for(r=[],o=Le();o!==a;)r.push(o),o=Le();r!==a?(39===e.charCodeAt(fe)?(o=H,fe++):(o=a,0===ve&&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===ve&&ke(te)),o!==a){for(i=[],l=Le();l!==a;)i.push(l),l=Le();i!==a?(39===e.charCodeAt(fe)?(l=H,fe++):(l=a,0===ve&&ke(Q)),l!==a?(r,r=o="#"+i.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=H,fe++):(t=a,0===ve&&ke(Q)))}return ve--,t===a&&(n=a,0===ve&&ke(ee)),t}function Ae(){var t,n;return(t=Te())===a&&(t=Ne())===a&&(t=fe,35===e.charCodeAt(fe)?(n="#",fe++):(n=a,0===ve&&ke(l)),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 ve++,re.test(e.charAt(fe))?(t=e.charAt(fe),fe++):(t=a,0===ve&&ke(ae)),ve--,t===a&&0===ve&&ke(ne),t}())),t}function Re(){var t,n,r;if(ve++,t=fe,n=[],ie.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(le)),r!==a)for(;r!==a;)n.push(r),ie.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(le));else n=a;return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(oe)),t}function Me(){var t,n,r;for(ve++,t=fe,n=[],ce.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(se));r!==a;)n.push(r),ce.test(e.charAt(fe))?(r=e.charAt(fe),fe++):(r=a,0===ve&&ke(se));return t=n!==a?e.substring(t,fe):n,ve--,t===a&&(n=a,0===ve&&ke(ue)),t}var De=[!1];if((r=i())!==a&&fe===e.length)return r;throw r!==a&&fe