diff --git a/qubitverse/backend/index.js b/qubitverse/backend/index.js new file mode 100644 index 0000000..030184d --- /dev/null +++ b/qubitverse/backend/index.js @@ -0,0 +1,49 @@ +const express = require("express"); +const cors = require("cors"); +const { spawn } = require("child_process"); + +const app = express(); + +app.use(express.text()); + +app.use( + cors({ + origin: "http://localhost:5173", + }) +); + +app.post("/encode", async (req, res) => { + const data = req.body; + const cppProcess = spawn("../simulator/simulator/temp"); + let output = ""; + + // Collect output from the C++ program + cppProcess.stdout.on("data", (chunk) => { + output += chunk.toString(); + }); + + // Handle errors + cppProcess.stderr.on("data", (chunk) => { + console.error(`Error from C++ parser: ${chunk}`); + }); + + // When the process completes + cppProcess.on("close", (code) => { + if (code === 0) { + res.send(output); + } else { + res.status(500).send("Error processing input"); + } + }); + + // Send the text directly to the C++ program's stdin + cppProcess.stdin.write(data); // Changed from gateData to data + cppProcess.stdin.end(); + + // Remove the second res.send() that was causing the error + // res.send("Data received"); +}); + +app.listen(5000, () => { + console.log("Server is running on port 5000"); +}); \ No newline at end of file diff --git a/qubitverse/backend/package-lock.json b/qubitverse/backend/package-lock.json new file mode 100644 index 0000000..a298d79 --- /dev/null +++ b/qubitverse/backend/package-lock.json @@ -0,0 +1,1202 @@ +{ + "name": "backend", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^1.8.3", + "child_process": "^1.0.2", + "cors": "^2.8.5", + "express": "^4.21.2", + "nodemon": "^3.1.9" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz", + "integrity": "sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/child_process": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", + "integrity": "sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g==" + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", + "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.9.tgz", + "integrity": "sha512-hdr1oIb2p6ZSxu3PB2JWWYS7ZQ0qvaZsc3hK8DR8f02kRzc8rjYmxAIvdz+aYC+8F2IjNaB7HMcSDg8nQpJxyg==", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + } + } +} diff --git a/qubitverse/backend/package.json b/qubitverse/backend/package.json new file mode 100644 index 0000000..9b72174 --- /dev/null +++ b/qubitverse/backend/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "axios": "^1.8.3", + "child_process": "^1.0.2", + "cors": "^2.8.5", + "express": "^4.21.2", + "nodemon": "^3.1.9" + } +} diff --git a/qubitverse/simulator/simulator/temp.cpp b/qubitverse/simulator/simulator/temp.cpp new file mode 100644 index 0000000..e843e4f --- /dev/null +++ b/qubitverse/simulator/simulator/temp.cpp @@ -0,0 +1,16 @@ +#include +#include + +int main() +{ + std::string line; + while (std::getline(std::cin, line)) + { + std::cout << line << std::endl; + } + + // Output results to stdout + std::cout << "Processed result here"; + + return 0; +} \ No newline at end of file diff --git a/qubitverse/visualizer/src/components/QuantumCircuit.jsx b/qubitverse/visualizer/src/components/QuantumCircuit.jsx index b19f2e8..334e501 100644 --- a/qubitverse/visualizer/src/components/QuantumCircuit.jsx +++ b/qubitverse/visualizer/src/components/QuantumCircuit.jsx @@ -8,80 +8,99 @@ import { Button } from "./ui/button"; // CONFIG CONSTANTS // ======================= const qubitSpacing = 50; // vertical spacing between qubit lines -export const numQubits = 50; // Q0 through Qn -const gateSize = 45; // width/height for single-qubit gate squares -const canvasMinX = 50; // left bound for gates on the stage +export const numQubits = 10; // Q0 through Qn +const gateSize = 45; // width/height for single-qubit gate squares +const canvasMinX = 50; // left bound for gates on the stage const canvasMaxX = window.innerWidth - 175 - gateSize; // right bound so gate stays visible // ======================= // GATE LIST // ======================= const gatesList = [ - "I", "X", "Y", "Z", "H", "S", "T", "P", - "Rx", "Ry", "Rz", - "CNOT", "CZ", "SWAP" + "I", + "X", + "Y", + "Z", + "H", + "S", + "T", + "P", + "Rx", + "Ry", + "Rz", + "CNOT", + "CZ", + "SWAP", ]; // ======================= // GATE TOOLTIP DATA (LaTeX + descriptions) // ======================= const gateTooltips = { - I: { - desc: "Identity Gate", - latex: "$$I = \\begin{pmatrix} 1 & 0 \\\\ 0 & 1 \\end{pmatrix}$$", - }, - X: { - desc: "Pauli-X (NOT) Gate", - latex: "$$X = \\begin{pmatrix}0 & 1\\\\ 1 & 0\\end{pmatrix}$$", - }, - Y: { - desc: "Pauli-Y Gate", - latex: "$$Y = \\begin{pmatrix}0 & -i\\\\ i & 0\\end{pmatrix}$$", - }, - Z: { - desc: "Pauli-Z Gate", - latex: "$$Z = \\begin{pmatrix} 1 & 0 \\\\ 0 & -1 \\end{pmatrix}$$", - }, - S: { - desc: "Phase π/2 Shift", - latex: "$$S = \\begin{pmatrix} 1 & 0 \\\\ 0 & i \\end{pmatrix}$$", - }, - T: { - desc: "Phase π/4 Shift", - latex: "$$T = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{iπ/4} \\end{pmatrix}$$", - }, - H: { - desc: "Hadamard (Superposition) Gate", - latex: "$$H = \\frac{1}{\\sqrt{2}} \\begin{pmatrix}1 & 1\\\\ 1 & -1\\end{pmatrix}$$", - }, - P: { - desc: "General Phase Shift Gate", - latex: "$$P(\\theta) = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{i\\theta} \\end{pmatrix}$$", - }, - Rx: { - desc: "Rotation around X-axis", - latex: "$$R_x(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -i\\sin(\\theta/2) \\\\ -i\\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", - }, - Ry: { - desc: "Rotation around Y-axis", - latex: "$$R_y(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -\\sin(\\theta/2) \\\\ \\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", - }, - Rz: { - desc: "Rotation around Z-axis", - latex: "$$R_z(\\theta) = \\begin{pmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{pmatrix}$$", - }, - CNOT: { - desc: "Controlled-NOT (Entanglement) Gate", - latex: "$$CNOT = \\begin{pmatrix}1 & 0 & 0 & 0\\\\ 0 & 1 & 0 & 0\\\\ 0 & 0 & 0 & 1\\\\ 0 & 0 & 1 & 0\\end{pmatrix}$$", - }, - CZ: { - desc: "Controlled-Z Gate", - latex: "$$CZ = \\begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & -1 \\end{pmatrix}$$", - }, - SWAP: { - desc: "SWAP Gate", - latex: "$$SWAP = \\begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\end{pmatrix}$$", - }, + I: { + desc: "Identity Gate", + latex: "$$I = \\begin{pmatrix} 1 & 0 \\\\ 0 & 1 \\end{pmatrix}$$", + }, + X: { + desc: "Pauli-X (NOT) Gate", + latex: "$$X = \\begin{pmatrix}0 & 1\\\\ 1 & 0\\end{pmatrix}$$", + }, + Y: { + desc: "Pauli-Y Gate", + latex: "$$Y = \\begin{pmatrix}0 & -i\\\\ i & 0\\end{pmatrix}$$", + }, + Z: { + desc: "Pauli-Z Gate", + latex: "$$Z = \\begin{pmatrix} 1 & 0 \\\\ 0 & -1 \\end{pmatrix}$$", + }, + S: { + desc: "Phase π/2 Shift", + latex: "$$S = \\begin{pmatrix} 1 & 0 \\\\ 0 & i \\end{pmatrix}$$", + }, + T: { + desc: "Phase π/4 Shift", + latex: "$$T = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{iπ/4} \\end{pmatrix}$$", + }, + H: { + desc: "Hadamard (Superposition) Gate", + latex: + "$$H = \\frac{1}{\\sqrt{2}} \\begin{pmatrix}1 & 1\\\\ 1 & -1\\end{pmatrix}$$", + }, + P: { + desc: "General Phase Shift Gate", + latex: + "$$P(\\theta) = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{i\\theta} \\end{pmatrix}$$", + }, + Rx: { + desc: "Rotation around X-axis", + latex: + "$$R_x(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -i\\sin(\\theta/2) \\\\ -i\\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", + }, + Ry: { + desc: "Rotation around Y-axis", + latex: + "$$R_y(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -\\sin(\\theta/2) \\\\ \\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", + }, + Rz: { + desc: "Rotation around Z-axis", + latex: + "$$R_z(\\theta) = \\begin{pmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{pmatrix}$$", + }, + CNOT: { + desc: "Controlled-NOT (Entanglement) Gate", + latex: + "$$CNOT = \\begin{pmatrix}1 & 0 & 0 & 0\\\\ 0 & 1 & 0 & 0\\\\ 0 & 0 & 0 & 1\\\\ 0 & 0 & 1 & 0\\end{pmatrix}$$", + }, + CZ: { + desc: "Controlled-Z Gate", + latex: + "$$CZ = \\begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 0 & 0 & -1 \\end{pmatrix}$$", + }, + SWAP: { + desc: "SWAP Gate", + latex: + "$$SWAP = \\begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\end{pmatrix}$$", + }, }; // Helper to clamp a value between min and max @@ -91,1073 +110,1142 @@ const clamp = (value, min, max) => Math.max(min, Math.min(value, max)); // SINGLE-QUBIT GATE COMPONENT // ======================= const QuantumGate = ({ - x, - y, - text, - draggable, - onDragEnd, - fixedY, - onRightClick, - order, - params = {}, + x, + y, + text, + draggable, + onDragEnd, + fixedY, + onRightClick, + order, + params = {}, }) => { - const isRotationGate = params.theta !== undefined; - let thetalength = 0; - if (params.theta != null) { - thetalength = params.theta.toString().length; - } - return ( - ({ - x: clamp(pos.x, canvasMinX, canvasMaxX), - y: fixedY, - }) - : undefined - } - onDragEnd={onDragEnd} - onContextMenu={(e) => { - e.evt.preventDefault(); - onRightClick(); - }} - > - - 1 ? gateSize / 2 - 10 : gateSize / 2 - 5} - y={gateSize / 2 - 10} - /> - {isRotationGate && ( - - )} - {order !== undefined && ( - - )} - - ); + const isRotationGate = params.theta !== undefined; + let thetalength = 0; + if (params.theta != null) { + thetalength = params.theta.toString().length; + } + return ( + ({ + x: clamp(pos.x, canvasMinX, canvasMaxX), + y: fixedY, + }) + : undefined + } + onDragEnd={onDragEnd} + onContextMenu={(e) => { + e.evt.preventDefault(); + onRightClick(); + }} + > + + 1 ? gateSize / 2 - 10 : gateSize / 2 - 5} + y={gateSize / 2 - 10} + /> + {isRotationGate && ( + + )} + {order !== undefined && ( + + )} + + ); }; // ======================= // CNOT GATE COMPONENT // ======================= const CNOTGate = ({ x, control, target, onDragEnd, onRightClick, order }) => { - const yControl = (control + 1) * qubitSpacing; - const yTarget = (target + 1) * qubitSpacing; - return ( - ({ - x: clamp(pos.x, canvasMinX, canvasMaxX), - y: 0, - })} - onDragEnd={onDragEnd} - onContextMenu={(e) => { - e.evt.preventDefault(); - onRightClick(); - }} - > - - - - - - {order !== undefined && ( - - )} - - ); + const yControl = (control + 1) * qubitSpacing; + const yTarget = (target + 1) * qubitSpacing; + return ( + ({ + x: clamp(pos.x, canvasMinX, canvasMaxX), + y: 0, + })} + onDragEnd={onDragEnd} + onContextMenu={(e) => { + e.evt.preventDefault(); + onRightClick(); + }} + > + + + + + + {order !== undefined && ( + + )} + + ); }; // ======================= // CZ GATE COMPONENT // ======================= -const CZGate = ({ x, control, target, onDragEnd, onRightClick, order }) => { - const yControl = (control + 1) * qubitSpacing; - const yTarget = (target + 1) * qubitSpacing; - return ( - ({ - x: clamp(pos.x, canvasMinX, canvasMaxX), - y: 0, - })} - onDragEnd={onDragEnd} - onContextMenu={(e) => { - e.evt.preventDefault(); - onRightClick(); - }} - > - - - - - {order !== undefined && ( - - )} - - ); +const CZGate = ({ + x, + control, + target, + onDragStart, + onDragEnd, + onRightClick, + order, +}) => { + const yControl = (control + 1) * qubitSpacing; + const yTarget = (target + 1) * qubitSpacing; + return ( + ({ + x: clamp(pos.x, canvasMinX, canvasMaxX), + y: 0, + })} + onDragStart={onDragStart} + onDragEnd={onDragEnd} + onContextMenu={(e) => { + e.evt.preventDefault(); + onRightClick(); + }} + > + + + + + {order !== undefined && ( + + )} + + ); }; // ======================= // SWAP GATE COMPONENT // ======================= -const SWAPGate = ({ x, qubit1, qubit2, onDragEnd, onRightClick, order }) => { - const y1 = (qubit1 + 1) * qubitSpacing; - const y2 = (qubit2 + 1) * qubitSpacing; - const topY = Math.min(y1, y2); - const bottomY = Math.max(y1, y2); - return ( - ({ - x: clamp(pos.x, canvasMinX, canvasMaxX), - y: 0, - })} - onDragEnd={onDragEnd} - onContextMenu={(e) => { - e.evt.preventDefault(); - onRightClick(); - }} - > - - {/* 'X' cross on qubit1 */} - - - {/* 'X' cross on qubit2 */} - - - {order !== undefined && ( - - )} - - ); +const SWAPGate = ({ + x, + qubit1, + qubit2, + onDragStart, + onDragEnd, + onRightClick, + order, +}) => { + const y1 = (qubit1 + 1) * qubitSpacing; + const y2 = (qubit2 + 1) * qubitSpacing; + const topY = Math.min(y1, y2); + const bottomY = Math.max(y1, y2); + return ( + ({ + x: clamp(pos.x, canvasMinX, canvasMaxX), + y: 0, + })} + onDragStart={onDragStart} + onDragEnd={onDragEnd} + onContextMenu={(e) => { + e.evt.preventDefault(); + onRightClick(); + }} + > + + {/* 'X' cross on qubit1 */} + + + {/* 'X' cross on qubit2 */} + + + {order !== undefined && ( + + )} + + ); }; // ======================= // QUBIT LINE COMPONENT // ======================= const QubitLine = ({ y, label, onClickQubit }) => ( - - - - + + + + ); // ======================= // Helper: snap single-qubit gates to a line // ======================= const snapY = (pointerY) => { - const desiredCenter = Math.round(pointerY / qubitSpacing) * qubitSpacing; - const clampedCenter = Math.max( - qubitSpacing, - Math.min(desiredCenter, numQubits * qubitSpacing) - ); - return clampedCenter - gateSize / 2; + const desiredCenter = Math.round(pointerY / qubitSpacing) * qubitSpacing; + const clampedCenter = Math.max( + qubitSpacing, + Math.min(desiredCenter, numQubits * qubitSpacing) + ); + return clampedCenter - gateSize / 2; }; // ======================= // MAIN QUANTUM CIRCUIT COMPONENT // ======================= const QuantumCircuit = () => { - // Single-qubit gates - const [gates, setGates] = useState([]); // { x, y, text, params? } - // CNOT gates - const [cnotGates, setCnotGates] = useState([]); // { x, control, target } - // CZ gates - const [czGates, setCzGates] = useState([]); // { x, control, target } - // SWAP gates - const [swapGates, setSwapGates] = useState([]); // { x, qubit1, qubit2 } + // Single-qubit gates + const [gates, setGates] = useState([]); // { x, y, text, params? } + // CNOT gates + const [cnotGates, setCnotGates] = useState([]); // { x, control, target } + // CZ gates + const [czGates, setCzGates] = useState([]); // { x, control, target } + // SWAP gates + const [swapGates, setSwapGates] = useState([]); // { x, qubit1, qubit2 } - // For Bloch sphere popup - const [selectedQubit, setSelectedQubit] = useState(null); - const [modalOpen, setModalOpen] = useState(false); + // For Bloch sphere popup + const [selectedQubit, setSelectedQubit] = useState(null); + const [modalOpen, setModalOpen] = useState(false); - // For rotation/phase gates - const [rotationModalOpen, setRotationModalOpen] = useState(false); - const [rotationValue, setRotationValue] = useState(45); - const [rotationX, setRotationX] = useState(0); - const [rotationY, setRotationY] = useState(0); - const [rotationType, setRotationType] = useState("P"); + // For rotation/phase gates + const [rotationModalOpen, setRotationModalOpen] = useState(false); + const [rotationValue, setRotationValue] = useState(45); + const [rotationX, setRotationX] = useState(0); + const [rotationY, setRotationY] = useState(0); + const [rotationType, setRotationType] = useState("P"); - // For CNOT selection - const [cnotModalOpen, setCnotModalOpen] = useState(false); - const [cnotX, setCnotX] = useState(0); - const [cnotControl, setCnotControl] = useState(0); - const [cnotTarget, setCnotTarget] = useState(1); + // For CNOT selection + const [cnotModalOpen, setCnotModalOpen] = useState(false); + const [cnotX, setCnotX] = useState(0); + const [cnotControl, setCnotControl] = useState(0); + const [cnotTarget, setCnotTarget] = useState(1); - // For CZ selection - const [czModalOpen, setCzModalOpen] = useState(false); - const [czX, setCzX] = useState(0); - const [czControl, setCzControl] = useState(0); - const [czTarget, setCzTarget] = useState(1); + // For CZ selection + const [czModalOpen, setCzModalOpen] = useState(false); + const [czX, setCzX] = useState(0); + const [czControl, setCzControl] = useState(0); + const [czTarget, setCzTarget] = useState(1); - // For SWAP selection - const [swapModalOpen, setSwapModalOpen] = useState(false); - const [swapX, setSwapX] = useState(0); - const [swapQubit1, setSwapQubit1] = useState(0); - const [swapQubit2, setSwapQubit2] = useState(1); + // For SWAP selection + const [swapModalOpen, setSwapModalOpen] = useState(false); + const [swapX, setSwapX] = useState(0); + const [swapQubit1, setSwapQubit1] = useState(0); + const [swapQubit2, setSwapQubit2] = useState(1); - // Tooltip - const [tooltip, setTooltip] = useState({ - visible: false, - x: 0, - y: 0, - desc: "", - latex: "", - }); + // Tooltip + const [isDragging, setIsDragging] = useState(false); + + // Keep the existing tooltip state + const [tooltip, setTooltip] = useState({ + visible: false, + x: 0, + y: 0, + desc: "", + latex: "", + }); - const stageRef = useRef(null); + const stageRef = useRef(null); - // ======================= - // ORDERING: Combined ordering for all gates on a qubit line - // Single-qubit: line = Math.round((y+gateSize/2)/qubitSpacing)-1 - // CNOT, CZ: use control qubit - // SWAP: use Math.min(qubit1, qubit2) - // ======================= - const combinedGroups = {}; - // Single-qubit - gates.forEach((g, i) => { - const qid = Math.round((g.y + gateSize / 2) / qubitSpacing) - 1; - if (!combinedGroups[qid]) combinedGroups[qid] = []; - combinedGroups[qid].push({ type: "single", index: i, x: g.x }); + // ======================= + // ORDERING: Combined ordering for all gates on a qubit line + // Single-qubit: line = Math.round((y+gateSize/2)/qubitSpacing)-1 + // CNOT, CZ: use control qubit + // SWAP: use Math.min(qubit1, qubit2) + // ======================= + const combinedGroups = {}; + // Single-qubit + gates.forEach((g, i) => { + const qid = Math.round((g.y + gateSize / 2) / qubitSpacing) - 1; + if (!combinedGroups[qid]) combinedGroups[qid] = []; + combinedGroups[qid].push({ type: "single", index: i, x: g.x }); + }); + // CNOT + cnotGates.forEach((g, i) => { + const qid = g.control; + if (!combinedGroups[qid]) combinedGroups[qid] = []; + combinedGroups[qid].push({ type: "cnot", index: i, x: g.x }); + }); + // CZ + czGates.forEach((g, i) => { + const qid = g.control; + if (!combinedGroups[qid]) combinedGroups[qid] = []; + combinedGroups[qid].push({ type: "cz", index: i, x: g.x }); + }); + // SWAP + swapGates.forEach((g, i) => { + const qid = Math.min(g.qubit1, g.qubit2); + if (!combinedGroups[qid]) combinedGroups[qid] = []; + combinedGroups[qid].push({ type: "swap", index: i, x: g.x }); + }); + + const combinedOrders = { + single: {}, + cnot: {}, + cz: {}, + swap: {}, + }; + Object.keys(combinedGroups).forEach((qid) => { + combinedGroups[qid].sort((a, b) => a.x - b.x); + combinedGroups[qid].forEach((item, orderIndex) => { + if (item.type === "single") { + combinedOrders.single[item.index] = orderIndex + 1; + } else if (item.type === "cnot") { + combinedOrders.cnot[item.index] = orderIndex + 1; + } else if (item.type === "cz") { + combinedOrders.cz[item.index] = orderIndex + 1; + } else if (item.type === "swap") { + combinedOrders.swap[item.index] = orderIndex + 1; + } }); - // CNOT - cnotGates.forEach((g, i) => { - const qid = g.control; - if (!combinedGroups[qid]) combinedGroups[qid] = []; - combinedGroups[qid].push({ type: "cnot", index: i, x: g.x }); + }); + + // ======================= + // DRAG & DROP LOGIC + // ======================= + useEffect(() => { + const container = stageRef.current.container(); + const handleDrop = (e) => { + e.preventDefault(); + const rect = container.getBoundingClientRect(); + const pointerX = e.clientX - rect.left; + const pointerY = e.clientY - rect.top; + const gateType = e.dataTransfer.getData("text/plain"); + if (!gateType) return; + + if (gateType === "CNOT") { + setCnotModalOpen(true); + setCnotX(pointerX); + } else if (gateType === "CZ") { + setCzModalOpen(true); + setCzX(pointerX); + } else if (gateType === "SWAP") { + setSwapModalOpen(true); + setSwapX(pointerX); + } else if ( + gateType === "P" || + gateType === "Rx" || + gateType === "Ry" || + gateType === "Rz" + ) { + const snappedY = snapY(pointerY); + setRotationModalOpen(true); + setRotationX(pointerX); + setRotationY(snappedY); + setRotationType(gateType); + setRotationValue(45); // default + } else { + // Single-qubit gate + const snappedY = snapY(pointerY); + setGates((prev) => [ + ...prev, + { x: pointerX, y: snappedY, text: gateType }, + ]); + } + }; + const handleDragOver = (e) => e.preventDefault(); + container.addEventListener("drop", handleDrop); + container.addEventListener("dragover", handleDragOver); + return () => { + container.removeEventListener("drop", handleDrop); + container.removeEventListener("dragover", handleDragOver); + }; + }, []); + + // ======================= + // DRAG END HANDLERS + // ======================= + const handleGateDragEnd = (e, index) => { + const { x } = e.target.position(); + setGates((prev) => { + const newGates = [...prev]; + newGates[index] = { + ...newGates[index], + x: clamp(x, canvasMinX, canvasMaxX), + }; + return newGates; }); - // CZ - czGates.forEach((g, i) => { - const qid = g.control; - if (!combinedGroups[qid]) combinedGroups[qid] = []; - combinedGroups[qid].push({ type: "cz", index: i, x: g.x }); + handleDragEnd(); + }; + + const handleCnotDragEnd = (e, index) => { + const { x } = e.target.position(); + setCnotGates((prev) => { + const newArr = [...prev]; + newArr[index].x = clamp(x, canvasMinX, canvasMaxX); + return newArr; }); - // SWAP - swapGates.forEach((g, i) => { - const qid = Math.min(g.qubit1, g.qubit2); - if (!combinedGroups[qid]) combinedGroups[qid] = []; - combinedGroups[qid].push({ type: "swap", index: i, x: g.x }); + handleDragEnd(); + }; + + const handleCzDragEnd = (e, index) => { + const { x } = e.target.position(); + setCzGates((prev) => { + const newArr = [...prev]; + newArr[index].x = clamp(x, canvasMinX, canvasMaxX); + return newArr; }); + handleDragEnd(); + }; - const combinedOrders = { - single: {}, - cnot: {}, - cz: {}, - swap: {}, - }; - Object.keys(combinedGroups).forEach((qid) => { - combinedGroups[qid].sort((a, b) => a.x - b.x); - combinedGroups[qid].forEach((item, orderIndex) => { - if (item.type === "single") { - combinedOrders.single[item.index] = orderIndex + 1; - } else if (item.type === "cnot") { - combinedOrders.cnot[item.index] = orderIndex + 1; - } else if (item.type === "cz") { - combinedOrders.cz[item.index] = orderIndex + 1; - } else if (item.type === "swap") { - combinedOrders.swap[item.index] = orderIndex + 1; - } - }); + const handleSwapDragEnd = (e, index) => { + const { x } = e.target.position(); + setSwapGates((prev) => { + const newArr = [...prev]; + newArr[index].x = clamp(x, canvasMinX, canvasMaxX); + return newArr; }); + handleDragEnd(); + }; - // ======================= - // DRAG & DROP LOGIC - // ======================= - useEffect(() => { - const container = stageRef.current.container(); - const handleDrop = (e) => { - e.preventDefault(); - const rect = container.getBoundingClientRect(); - const pointerX = e.clientX - rect.left; - const pointerY = e.clientY - rect.top; - const gateType = e.dataTransfer.getData("text/plain"); - if (!gateType) return; + // ======================= + // DELETE HANDLERS (Right-click) + // ======================= + const handleDeleteGate = (index) => { + setGates((prev) => prev.filter((_, i) => i !== index)); + }; + const handleDeleteCnot = (index) => { + setCnotGates((prev) => prev.filter((_, i) => i !== index)); + }; + const handleDeleteCz = (index) => { + setCzGates((prev) => prev.filter((_, i) => i !== index)); + }; + const handleDeleteSwap = (index) => { + setSwapGates((prev) => prev.filter((_, i) => i !== index)); + }; - if (gateType === "CNOT") { - setCnotModalOpen(true); - setCnotX(pointerX); - } else if (gateType === "CZ") { - setCzModalOpen(true); - setCzX(pointerX); - } else if (gateType === "SWAP") { - setSwapModalOpen(true); - setSwapX(pointerX); - } else if ( - gateType === "P" || - gateType === "Rx" || - gateType === "Ry" || - gateType === "Rz" - ) { - const snappedY = snapY(pointerY); - setRotationModalOpen(true); - setRotationX(pointerX); - setRotationY(snappedY); - setRotationType(gateType); - setRotationValue(45); // default - } else { - // Single-qubit gate - const snappedY = snapY(pointerY); - setGates((prev) => [ - ...prev, - { x: pointerX, y: snappedY, text: gateType }, - ]); - } - }; - const handleDragOver = (e) => e.preventDefault(); - container.addEventListener("drop", handleDrop); - container.addEventListener("dragover", handleDragOver); - return () => { - container.removeEventListener("drop", handleDrop); - container.removeEventListener("dragover", handleDragOver); - }; - }, []); + // ======================= + // MODALS & POPUPS + // ======================= + // Bloch sphere popup + const openModalForQubit = (qid) => { + setSelectedQubit(qid); + setModalOpen(true); + }; + const closeModal = () => { + setSelectedQubit(null); + setModalOpen(false); + }; - // ======================= - // DRAG END HANDLERS - // ======================= - const handleGateDragEnd = (e, index) => { - const { x } = e.target.position(); - setGates((prev) => { - const newGates = [...prev]; - newGates[index] = { ...newGates[index], x: clamp(x, canvasMinX, canvasMaxX) }; - return newGates; - }); - }; + // ============================ + // TOOLTIP HANDLERS + // ============================ + const handleTooltipEnter = (e, gate) => { + // Don't show tooltip if currently dragging + if (isDragging) return; - const handleCnotDragEnd = (e, index) => { - const { x } = e.target.position(); - setCnotGates((prev) => { - const newArr = [...prev]; - newArr[index].x = clamp(x, canvasMinX, canvasMaxX); - return newArr; - }); - }; + const rect = e.target.getBoundingClientRect(); + setTooltip({ + visible: true, + x: rect.left + 120, // Remove window.scrollX since we'll use fixed positioning + y: rect.bottom - 100, // Remove window.scrollY since we'll use fixed positioning + desc: gateTooltips[gate].desc, + latex: gateTooltips[gate].latex, + }); + }; - const handleCzDragEnd = (e, index) => { - const { x } = e.target.position(); - setCzGates((prev) => { - const newArr = [...prev]; - newArr[index].x = clamp(x, canvasMinX, canvasMaxX); - return newArr; - }); - }; + const handleTooltipLeave = () => { + setTooltip({ visible: false, x: 0, y: 0, desc: "", latex: "" }); + }; - const handleSwapDragEnd = (e, index) => { - const { x } = e.target.position(); - setSwapGates((prev) => { - const newArr = [...prev]; - newArr[index].x = clamp(x, canvasMinX, canvasMaxX); - return newArr; - }); - }; + const handleDragStart = () => { + setIsDragging(true); + // Hide tooltip when dragging starts + setTooltip((prev) => ({ ...prev, visible: false })); + }; - // ======================= - // DELETE HANDLERS (Right-click) - // ======================= - const handleDeleteGate = (index) => { - setGates((prev) => prev.filter((_, i) => i !== index)); - }; - const handleDeleteCnot = (index) => { - setCnotGates((prev) => prev.filter((_, i) => i !== index)); - }; - const handleDeleteCz = (index) => { - setCzGates((prev) => prev.filter((_, i) => i !== index)); - }; - const handleDeleteSwap = (index) => { - setSwapGates((prev) => prev.filter((_, i) => i !== index)); - }; + const handleDragEnd = () => { + setIsDragging(false); + }; - // ======================= - // MODALS & POPUPS - // ======================= - // Bloch sphere popup - const openModalForQubit = (qid) => { - setSelectedQubit(qid); - setModalOpen(true); - }; - const closeModal = () => { - setSelectedQubit(null); - setModalOpen(false); - }; + // Rotation/phase gate modal (unchanged) + const validateRotationValue = (value) => (value === 0 ? 1 : value); + const handleRotationConfirm = () => { + const validTheta = validateRotationValue(rotationValue); + setGates((prev) => [ + ...prev, + { + x: rotationX, + y: rotationY, + text: rotationType, + params: { theta: validTheta }, + }, + ]); + setRotationModalOpen(false); + }; + const handleRotationCancel = () => { + setRotationModalOpen(false); + }; + const handleRotationInputChange = (e) => { + const val = parseFloat(e.target.value) || 1; + setRotationValue(val === 0 ? 1 : val); + }; + const getRotationModalContent = () => { + switch (rotationType) { + case "Rx": + return { + title: "Rotation around X-axis (θ)", + latex: + "$$R_x(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -i\\sin(\\theta/2) \\\\ -i\\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", + }; + case "Ry": + return { + title: "Rotation around Y-axis (θ)", + latex: + "$$R_y(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -\\sin(\\theta/2) \\\\ \\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", + }; + case "Rz": + return { + title: "Rotation around Z-axis (θ)", + latex: + "$$R_z(\\theta) = \\begin{pmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{pmatrix}$$", + }; + default: + return { + title: "Phase Angle (θ)", + latex: + "$$P(\\theta) = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{i\\theta} \\end{pmatrix}$$", + }; + } + }; - // Rotation/phase gate modal (unchanged) - const validateRotationValue = (value) => (value === 0 ? 1 : value); - const handleRotationConfirm = () => { - const validTheta = validateRotationValue(rotationValue); - setGates((prev) => [ - ...prev, - { - x: rotationX, - y: rotationY, - text: rotationType, - params: { theta: validTheta }, - }, - ]); - setRotationModalOpen(false); - }; - const handleRotationCancel = () => { - setRotationModalOpen(false); - }; - const handleRotationInputChange = (e) => { - const val = parseFloat(e.target.value) || 1; - setRotationValue(val === 0 ? 1 : val); - }; - const getRotationModalContent = () => { - switch (rotationType) { - case "Rx": - return { - title: "Rotation around X-axis (θ)", - latex: - "$$R_x(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -i\\sin(\\theta/2) \\\\ -i\\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", - }; - case "Ry": - return { - title: "Rotation around Y-axis (θ)", - latex: - "$$R_y(\\theta) = \\begin{pmatrix} \\cos(\\theta/2) & -\\sin(\\theta/2) \\\\ \\sin(\\theta/2) & \\cos(\\theta/2) \\end{pmatrix}$$", - }; - case "Rz": - return { - title: "Rotation around Z-axis (θ)", - latex: - "$$R_z(\\theta) = \\begin{pmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{pmatrix}$$", - }; - default: - return { - title: "Phase Angle (θ)", - latex: - "$$P(\\theta) = \\begin{pmatrix} 1 & 0 \\\\ 0 & e^{i\\theta} \\end{pmatrix}$$", - }; - } - }; + // CNOT modal + const handleCnotConfirm = () => { + if (cnotControl === cnotTarget) { + alert("Control and target qubits must be different!"); + return; + } + setCnotGates((prev) => [ + ...prev, + { x: cnotX, control: cnotControl, target: cnotTarget }, + ]); + setCnotModalOpen(false); + }; + const handleCnotCancel = () => { + setCnotModalOpen(false); + }; - // CNOT modal - const handleCnotConfirm = () => { - if (cnotControl === cnotTarget) { - alert("Control and target qubits must be different!"); - return; - } - setCnotGates((prev) => [ - ...prev, - { x: cnotX, control: cnotControl, target: cnotTarget }, - ]); - setCnotModalOpen(false); - }; - const handleCnotCancel = () => { - setCnotModalOpen(false); - }; + // CZ modal + const handleCzConfirm = () => { + if (czControl === czTarget) { + alert("Control and target qubits must be different!"); + return; + } + setCzGates((prev) => [ + ...prev, + { x: czX, control: czControl, target: czTarget }, + ]); + setCzModalOpen(false); + }; + const handleCzCancel = () => { + setCzModalOpen(false); + }; - // CZ modal - const handleCzConfirm = () => { - if (czControl === czTarget) { - alert("Control and target qubits must be different!"); - return; - } - setCzGates((prev) => [ - ...prev, - { x: czX, control: czControl, target: czTarget }, - ]); - setCzModalOpen(false); - }; - const handleCzCancel = () => { - setCzModalOpen(false); - }; + // SWAP modal + const handleSwapConfirm = () => { + if (swapQubit1 === swapQubit2) { + alert("SWAP requires two distinct qubits!"); + return; + } + setSwapGates((prev) => [ + ...prev, + { x: swapX, qubit1: swapQubit1, qubit2: swapQubit2 }, + ]); + setSwapModalOpen(false); + }; + const handleSwapCancel = () => { + setSwapModalOpen(false); + }; - // SWAP modal - const handleSwapConfirm = () => { - if (swapQubit1 === swapQubit2) { - alert("SWAP requires two distinct qubits!"); - return; - } - setSwapGates((prev) => [ - ...prev, - { x: swapX, qubit1: swapQubit1, qubit2: swapQubit2 }, - ]); - setSwapModalOpen(false); - }; - const handleSwapCancel = () => { - setSwapModalOpen(false); - }; + // ======================= + // RENDER + // ======================= + return ( + +
+ {/* TOP MENU */} +
+ {gatesList.map((gate, index) => ( +
{ + e.dataTransfer.setData("text/plain", gate); + handleTooltipLeave(); + }} + onMouseEnter={(e) => handleTooltipEnter(e, gate)} + onMouseMove={(e) => { + e.currentTarget.style.background = "#D0E8FF"; + }} + onMouseLeave={(e) => { + e.currentTarget.style.background = "white"; + handleTooltipLeave(e); + }} + > + {gate} +
+ ))} +
- // Tooltip handlers - const handleTooltipEnter = (e, gate) => { - const rect = e.target.getBoundingClientRect(); - setTooltip({ - visible: true, - x: rect.left + window.scrollX + 150, - y: rect.bottom + window.scrollY - 150, - desc: gateTooltips[gate].desc, - latex: gateTooltips[gate].latex, - }); - }; - const handleTooltipLeave = () => { - setTooltip({ visible: false, x: 0, y: 0, desc: "", latex: "" }); - }; + {/* TOOLTIP */} + {tooltip.visible && ( +
+
+ {tooltip.desc} +
+ + {tooltip.latex} + +
+ )} + + {/* STAGE: QUBIT LINES & GATES */} + + + {Array.from({ length: numQubits }).map((_, i) => ( + openModalForQubit(i)} + /> + ))} + {/* Render single-qubit gates */} + {gates.map((g, i) => ( + handleGateDragEnd(e, i)} + onRightClick={() => handleDeleteGate(i)} + order={combinedOrders.single[i]} + /> + ))} + {/* Render CNOT gates */} + {cnotGates.map((g, i) => ( + handleCnotDragEnd(e, i)} + onRightClick={() => handleDeleteCnot(i)} + order={combinedOrders.cnot[i]} + /> + ))} + {/* Render CZ gates */} + {czGates.map((g, i) => ( + handleCzDragEnd(e, i)} + onRightClick={() => handleDeleteCz(i)} + order={combinedOrders.cz[i]} + /> + ))} + {/* Render SWAP gates */} + {swapGates.map((g, i) => ( + handleSwapDragEnd(e, i)} + onRightClick={() => handleDeleteSwap(i)} + order={combinedOrders.swap[i]} + /> + ))} + + + + {/* BLOCH SPHERE MODAL */} + {modalOpen && ( +
+
e.stopPropagation()} + style={{ + background: "white", + padding: "20px", + borderRadius: "10px", + textAlign: "center", + }} + > +

Bloch Sphere for Q{selectedQubit}

+ Bloch Sphere +
+ +
+
+ )} - // ======================= - // RENDER - // ======================= - return ( - + {/* ROTATION/PHASE GATE MODAL */} + {rotationModalOpen && ( +
e.stopPropagation()} + style={{ + background: "white", + padding: "20px", + borderRadius: "10px", + textAlign: "center", + minWidth: "300px", + }} + > +

{getRotationModalContent().title}

+
+ {getRotationModalContent().latex} +
+
- {/* TOP MENU */} + > + + +
+
+
- {gatesList.map((gate, index) => ( -
e.dataTransfer.setData("text/plain", gate)} - onMouseEnter={(e) => handleTooltipEnter(e, gate)} - onMouseMove={(e) => { e.currentTarget.style.background = "#D0E8FF"; }} - onMouseLeave={(e) => { - e.currentTarget.style.background = "white"; - handleTooltipLeave(e); - }} - > - {gate} -
- ))} + Note: Angle must be between 1° and 360°
+
+ + +
+
+ )} - {/* TOOLTIP */} - {tooltip.visible && ( -
-
- {tooltip.desc} -
- - {tooltip.latex} - -
- )} - - {/* STAGE: QUBIT LINES & GATES */} - +
e.stopPropagation()} + style={{ + background: "white", + padding: "20px", + borderRadius: "10px", + textAlign: "center", + minWidth: "300px", + }} + > +

Select Control and Target Qubit

+
+ + -
-
- -
- Note: Angle must be between 1° and 360° -
-
- - -
-
- )} - - {/* CNOT SELECTION MODAL */} - {cnotModalOpen && ( -
-
e.stopPropagation()} - style={{ - background: "white", - padding: "20px", - borderRadius: "10px", - textAlign: "center", - minWidth: "300px", - }} - > -

Select Control and Target Qubit

-
- - -
-
- - -
- - -
-
- )} + {Array.from({ length: numQubits }).map((_, i) => ( + + ))} + + +
+ + +
+ + + + + )} - {/* CZ SELECTION MODAL */} - {czModalOpen && ( -
-
e.stopPropagation()} - style={{ - background: "white", - padding: "20px", - borderRadius: "10px", - textAlign: "center", - minWidth: "300px", - }} - > -

Select Control and Target Qubit (CZ)

-
- - -
-
- - -
- - -
-
- )} + {/* CZ SELECTION MODAL */} + {czModalOpen && ( +
+
e.stopPropagation()} + style={{ + background: "white", + padding: "20px", + borderRadius: "10px", + textAlign: "center", + minWidth: "300px", + }} + > +

Select Control and Target Qubit (CZ)

+
+ + +
+
+ + +
+ + +
+
+ )} - {/* SWAP SELECTION MODAL */} - {swapModalOpen && ( -
-
e.stopPropagation()} - style={{ - background: "white", - padding: "20px", - borderRadius: "10px", - textAlign: "center", - minWidth: "300px", - }} - > -

Select Qubits to SWAP

-
- - -
-
- - -
- - -
-
- )} + {/* SWAP SELECTION MODAL */} + {swapModalOpen && ( +
+
e.stopPropagation()} + style={{ + background: "white", + padding: "20px", + borderRadius: "10px", + textAlign: "center", + minWidth: "300px", + }} + > +

Select Qubits to SWAP

+
+ + +
+
+ + + s +
+ +
+
+ )} + - {/* CircuitDataExtractor or other component that processes the final state */} - -
- ); + {/* CircuitDataExtractor or other component that processes the final state */} + + + ); }; export default QuantumCircuit; diff --git a/qubitverse/visualizer/src/components/circuitDataExtractor.jsx b/qubitverse/visualizer/src/components/circuitDataExtractor.jsx index a70093e..b4422e9 100644 --- a/qubitverse/visualizer/src/components/circuitDataExtractor.jsx +++ b/qubitverse/visualizer/src/components/circuitDataExtractor.jsx @@ -97,10 +97,18 @@ export default function CircuitDataExtractor({ gates, cnotGates, czGates, swapGa const [isOpen, setIsOpen] = useState(false); const [circuitData, setCircuitData] = useState(null); - const handleExtractData = () => { + const handleExtractData =async () => { const data = extractCircuitData(gates, cnotGates, czGates, swapGates); setCircuitData(data); setIsOpen(true); + const response = await fetch("http://localhost:5000/encode", { + method: "POST", + headers: { + "Content-Type": "text/plain", + }, + body: quantum_encode(data), + }); + console.log(response); }; return (