diff --git a/src/main/frontend/package-lock.json b/src/main/frontend/package-lock.json index 790dac60..287e6a3a 100644 --- a/src/main/frontend/package-lock.json +++ b/src/main/frontend/package-lock.json @@ -8,10 +8,8 @@ "name": "codeiq-ui", "version": "0.2.0", "dependencies": { - "@ant-design/icons": "^6.2.1", - "antd": "^6.3.7", - "echarts": "^6.0.0", - "echarts-for-react": "^3.0.2", + "@ossrandom/design-system": "^0.3.0", + "d3-hierarchy": "^3.1.2", "react": "^19.2.5", "react-dom": "^19.2.5", "react-router-dom": "^7.1.5" @@ -27,107 +25,14 @@ "vite": "^6.4.2" } }, - "node_modules/@ant-design/colors": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/@ant-design/colors/-/colors-8.0.1.tgz", - "integrity": "sha512-foPVl0+SWIslGUtD/xBr1p9U4AKzPhNYEseXYRRo5QSzGACYZrQbe11AYJbYfAWnWSpGBx6JjBmSeugUsD9vqQ==", - "license": "MIT", - "dependencies": { - "@ant-design/fast-color": "^3.0.0" - } - }, - "node_modules/@ant-design/cssinjs": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ant-design/cssinjs/-/cssinjs-2.1.2.tgz", - "integrity": "sha512-2Hy8BnCEH31xPeSLbhhB2ctCPXE2ZnASdi+KbSeS79BNbUhL9hAEe20SkUk+BR8aKTmqb6+FKFruk7w8z0VoRQ==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.11.1", - "@emotion/hash": "^0.8.0", - "@emotion/unitless": "^0.7.5", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1", - "csstype": "^3.1.3", - "stylis": "^4.3.4" - }, - "peerDependencies": { - "react": ">=16.0.0", - "react-dom": ">=16.0.0" - } - }, - "node_modules/@ant-design/cssinjs-utils": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ant-design/cssinjs-utils/-/cssinjs-utils-2.1.2.tgz", - "integrity": "sha512-5fTHQ158jJJ5dC/ECeyIdZUzKxE/mpEMRZxthyG1sw/AKRHKgJBg00Yi6ACVXgycdje7KahRNvNET/uBccwCnA==", - "license": "MIT", - "dependencies": { - "@ant-design/cssinjs": "^2.1.2", - "@babel/runtime": "^7.23.2", - "@rc-component/util": "^1.4.0" - }, - "peerDependencies": { - "react": ">=18", - "react-dom": ">=18" - } - }, - "node_modules/@ant-design/fast-color": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@ant-design/fast-color/-/fast-color-3.0.1.tgz", - "integrity": "sha512-esKJegpW4nckh0o6kV3Tkb7NPIZYbPnnFxmQDUmL08ukXZAvV85TZBr70eGuke/CIArLaP6aw8lt9KILjnWuOw==", - "license": "MIT", - "engines": { - "node": ">=8.x" - } - }, - "node_modules/@ant-design/icons": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/@ant-design/icons/-/icons-6.2.1.tgz", - "integrity": "sha512-mYt5ynqj0CsuGoffbYTPKGBy9q8iQtKk6hNLkdH1Wr3a8Z5I9MUWgFsexGxIlDnaskfWIr8M21MA/8If6E0/+Q==", - "license": "MIT", - "dependencies": { - "@ant-design/colors": "^8.0.1", - "@ant-design/icons-svg": "^4.4.2", - "@rc-component/util": "^1.10.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8" - }, - "peerDependencies": { - "react": ">=16.0.0", - "react-dom": ">=16.0.0" - } - }, - "node_modules/@ant-design/icons-svg": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz", - "integrity": "sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA==", - "license": "MIT" - }, - "node_modules/@ant-design/react-slick": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@ant-design/react-slick/-/react-slick-2.0.0.tgz", - "integrity": "sha512-HMS9sRoEmZey8LsE/Yo6+klhlzU12PisjrVcydW3So7RdklyEd2qehyU6a7Yp+OYN72mgsYs3NFCyP2lCPFVqg==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.28.4", - "clsx": "^2.1.1", - "json2mq": "^0.2.0", - "throttle-debounce": "^5.0.0" - }, - "peerDependencies": { - "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", - "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" - } - }, "node_modules/@axe-core/playwright": { - "version": "4.11.1", - "resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.11.1.tgz", - "integrity": "sha512-mKEfoUIB1MkVTht0BGZFXtSAEKXMJoDkyV5YZ9jbBmZCcWDz71tegNsdTkIN8zc/yMi5Gm2kx7Z5YQ9PfWNAWw==", + "version": "4.11.3", + "resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.11.3.tgz", + "integrity": "sha512-h/kfksv4F0cVIDlKpT4700OehdRgpvuVskuQ2nb7/JmtWUXpe9ftHAPtwyXGvVSsa6SJ64A9ER7Zrzc/sIvC4w==", "dev": true, "license": "MPL-2.0", "dependencies": { - "axe-core": "~4.11.1" + "axe-core": "~4.11.4" }, "peerDependencies": { "playwright-core": ">= 1.0.0" @@ -149,9 +54,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz", - "integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==", + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.3.tgz", + "integrity": "sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==", "dev": true, "license": "MIT", "engines": { @@ -320,9 +225,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.29.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", - "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.3.tgz", + "integrity": "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA==", "dev": true, "license": "MIT", "dependencies": { @@ -367,15 +272,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/runtime": { - "version": "7.29.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.2.tgz", - "integrity": "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==", - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/template": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", @@ -424,18 +320,6 @@ "node": ">=6.9.0" } }, - "node_modules/@emotion/hash": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz", - "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==", - "license": "MIT" - }, - "node_modules/@emotion/unitless": { - "version": "0.7.5", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz", - "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==", - "license": "MIT" - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", @@ -928,733 +812,63 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@playwright/test": { - "version": "1.59.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz", - "integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "playwright": "1.59.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@rc-component/async-validator": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@rc-component/async-validator/-/async-validator-5.1.0.tgz", - "integrity": "sha512-n4HcR5siNUXRX23nDizbZBQPO0ZM/5oTtmKZ6/eqL0L2bo747cklFdZGRN2f+c9qWGICwDzrhW0H7tE9PptdcA==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.24.4" - }, - "engines": { - "node": ">=14.x" - } - }, - "node_modules/@rc-component/cascader": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/@rc-component/cascader/-/cascader-1.14.0.tgz", - "integrity": "sha512-Ip9356xwZUR2nbW5PRVGif4B/bDve4pLa/N+PGbvBaTnjbvmN4PFMBGQSmlDlzKP1ovxaYMvwF/dI9lXNLT4iQ==", - "license": "MIT", - "dependencies": { - "@rc-component/select": "~1.6.0", - "@rc-component/tree": "~1.2.0", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/checkbox": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@rc-component/checkbox/-/checkbox-2.0.0.tgz", - "integrity": "sha512-3CXGPpAR9gsPKeO2N78HAPOzU30UdemD6HGJoWVJOpa6WleaGB5kzZj3v6bdTZab31YuWgY/RxV3VKPctn0DwQ==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/collapse": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@rc-component/collapse/-/collapse-1.2.0.tgz", - "integrity": "sha512-ZRYSKSS39qsFx93p26bde7JUZJshsUBEQRlRXPuJYlAiNX0vyYlF5TsAm8JZN3LcF8XvKikdzPbgAtXSbkLUkw==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.10.1", - "@rc-component/motion": "^1.1.4", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/color-picker": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@rc-component/color-picker/-/color-picker-3.1.1.tgz", - "integrity": "sha512-OHaCHLHszCegdXmIq2ZRIZBN/EtpT6Wm8SG/gpzLATHbVKc/avvuKi+zlOuk05FTWvgaMmpxAko44uRJ3M+2pg==", - "license": "MIT", - "dependencies": { - "@ant-design/fast-color": "^3.0.1", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/context": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/context/-/context-2.0.1.tgz", - "integrity": "sha512-HyZbYm47s/YqtP6pKXNMjPEMaukyg7P0qVfgMLzr7YiFNMHbK2fKTAGzms9ykfGHSfyf75nBbgWw+hHkp+VImw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/dialog": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/@rc-component/dialog/-/dialog-1.8.4.tgz", - "integrity": "sha512-Ay6PM7phkTkquplG8fWfUGFZ2GTLx9diTl4f0d8Eqxd7W1u1KjE9AQooFQHOHnhZf0Ya3z51+5EKCWHmt/dNEw==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.1.3", - "@rc-component/portal": "^2.1.0", - "@rc-component/util": "^1.9.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/drawer": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/@rc-component/drawer/-/drawer-1.4.2.tgz", - "integrity": "sha512-1ib+fZEp6FBu+YvcIktm+nCQ+Q+qIpwpoaJH6opGr4ofh2QMq+qdr5DLC4oCf5qf3pcWX9lUWPYX652k4ini8Q==", + "node_modules/@ossrandom/design-system": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@ossrandom/design-system/-/design-system-0.3.0.tgz", + "integrity": "sha512-flW4PBob1WCjyero4HA8/gYHbQe+ufy2XpQ5EpjO988LdNaM/oArj4gONQSdXdGGlQ4zoXzuRTgPjDDBB61o2A==", "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.1.4", - "@rc-component/portal": "^2.1.3", - "@rc-component/util": "^1.9.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/dropdown": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@rc-component/dropdown/-/dropdown-1.0.2.tgz", - "integrity": "sha512-6PY2ecUSYhDPhkNHHb4wfeAya04WhpmUSKzdR60G+kMNVUCX2vjT/AgTS0Lz0I/K6xrPMJ3enQbwVpeN3sHCgg==", - "license": "MIT", - "dependencies": { - "@rc-component/trigger": "^3.0.0", - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.11.0", - "react-dom": ">=16.11.0" - } - }, - "node_modules/@rc-component/form": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@rc-component/form/-/form-1.8.1.tgz", - "integrity": "sha512-8O7TB55Fi2mWIGvSnwZjk8jFqVNYyKDAswglwGShcbndxqzKz4cHwNtNaLjZlAeRge9wcB0LL8IWsC/Bl18raQ==", - "license": "MIT", - "dependencies": { - "@rc-component/async-validator": "^5.1.0", - "@rc-component/util": "^1.6.2", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/image": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@rc-component/image/-/image-1.9.0.tgz", - "integrity": "sha512-khF7w7xkBH5B1bsBcI1FSUZdkyd1aqpl2eYyILCqCzzQH3XdfehGUaZTnptyaJJfs09/R5hv9jXWyazOMFIClQ==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.0.0", - "@rc-component/portal": "^2.1.2", - "@rc-component/util": "^1.10.1", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/input": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@rc-component/input/-/input-1.1.2.tgz", - "integrity": "sha512-Q61IMR47piUBudgixJ30CciKIy9b1H95qe7GgEKOmSJVJXvFRWJllJfQry9tif+MX2cWFXWJf/RXz4kaCeq/Fg==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.0.0", - "react-dom": ">=16.0.0" - } - }, - "node_modules/@rc-component/input-number": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@rc-component/input-number/-/input-number-1.6.2.tgz", - "integrity": "sha512-Gjcq7meZlCOiWN1t1xCC+7/s85humHVokTBI7PJgTfoyw5OWF74y3e6P8PHX104g9+b54jsodFIzyaj6p8LI9w==", - "license": "MIT", - "dependencies": { - "@rc-component/mini-decimal": "^1.0.1", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/mentions": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@rc-component/mentions/-/mentions-1.6.0.tgz", - "integrity": "sha512-KIkQNP6habNuTsLhUv0UGEOwG67tlmE7KNIJoQZZNggEZl5lQJTytFDb69sl5CK3TDdISCTjKP3nGEBKgT61CQ==", - "license": "MIT", - "dependencies": { - "@rc-component/input": "~1.1.0", - "@rc-component/menu": "~1.2.0", - "@rc-component/textarea": "~1.1.0", - "@rc-component/trigger": "^3.0.0", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/menu": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@rc-component/menu/-/menu-1.2.0.tgz", - "integrity": "sha512-VWwDuhvYHSnTGj4n6bV3ISrLACcPAzdPOq3d0BzkeiM5cve8BEYfvkEhNoM0PLzv51jpcejeyrLXeMVIJ+QJlg==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.1.4", - "@rc-component/overflow": "^1.0.0", - "@rc-component/trigger": "^3.0.0", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/mini-decimal": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@rc-component/mini-decimal/-/mini-decimal-1.1.3.tgz", - "integrity": "sha512-bk/FJ09fLf+NLODMAFll6CfYrHPBioTedhW6lxDBuuWucJEqFUd4l/D/5JgIi3dina6sYahB8iuPAZTNz2pMxw==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.18.0" - }, "engines": { - "node": ">=8.x" - } - }, - "node_modules/@rc-component/motion": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@rc-component/motion/-/motion-1.3.2.tgz", - "integrity": "sha512-itfd+GztzJYAb04Z4RkEub1TbJAfZc2Iuy8p44U44xD1F5+fNYFKI3897ijlbIyfvXkTmMm+KGcjkQQGMHywEQ==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.0", - "clsx": "^2.1.1" + "node": ">=18.18" }, "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/mutate-observer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/mutate-observer/-/mutate-observer-2.0.1.tgz", - "integrity": "sha512-AyarjoLU5YlxuValRi+w8JRH2Z84TBbFO2RoGWz9d8bSu0FqT8DtugH3xC3BV7mUwlmROFauyWuXFuq4IFbH+w==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.0" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/notification": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@rc-component/notification/-/notification-1.2.0.tgz", - "integrity": "sha512-OX3J+zVU7rvoJCikjrfW7qOUp7zlDeFBK2eA3SFbGSkDqo63Sl4Ss8A04kFP+fxHSxMDIS9jYVEZtU1FNCFuBA==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.1.4", - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/overflow": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/overflow/-/overflow-1.0.1.tgz", - "integrity": "sha512-syfmgAABaHCnCDzPwHZ/2tuvIcpOO3jefYZMmfkN+pmo8HKTzsfhS57vxo4ksPdN0By+uWVJhJWNFozNBxi2eA==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.11.1", - "@rc-component/resize-observer": "^1.0.1", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/pagination": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@rc-component/pagination/-/pagination-1.2.0.tgz", - "integrity": "sha512-YcpUFE8dMLfSo6OARJlK6DbHHvrxz7pMGPGmC/caZSJJz6HRKHC1RPP001PRHCvG9Z/veD039uOQmazVuLJzlw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/picker": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@rc-component/picker/-/picker-1.9.1.tgz", - "integrity": "sha512-9FBYYsvH3HMLICaPDA/1Th5FLaDkFa7qAtangIdlhKb3ZALaR745e9PsOhheJb6asS4QXc12ffiAcjdkZ4C5/g==", - "license": "MIT", - "dependencies": { - "@rc-component/overflow": "^1.0.0", - "@rc-component/resize-observer": "^1.0.0", - "@rc-component/trigger": "^3.6.15", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=12.x" - }, - "peerDependencies": { - "date-fns": ">= 2.x", - "dayjs": ">= 1.x", - "luxon": ">= 3.x", - "moment": ">= 2.x", - "react": ">=16.9.0", - "react-dom": ">=16.9.0" + "@deck.gl/core": "^9.0.0", + "@deck.gl/layers": "^9.0.0", + "cytoscape": "^3.30.0", + "cytoscape-cose-bilkent": "^4.1.0", + "d3-force": "^3.0.0", + "d3-hierarchy": "^3.0.0", + "react": ">=18", + "react-dom": ">=18", + "uplot": "^1.6.0" }, "peerDependenciesMeta": { - "date-fns": { + "@deck.gl/core": { + "optional": true + }, + "@deck.gl/layers": { "optional": true }, - "dayjs": { + "cytoscape": { "optional": true }, - "luxon": { + "cytoscape-cose-bilkent": { "optional": true }, - "moment": { + "d3-force": { + "optional": true + }, + "d3-hierarchy": { + "optional": true + }, + "uplot": { "optional": true } } }, - "node_modules/@rc-component/portal": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@rc-component/portal/-/portal-2.2.0.tgz", - "integrity": "sha512-oc6FlA+uXCMiwArHsJyHcIkX4q6uKyndrPol2eWX8YPkAnztHOPsFIRtmWG4BMlGE5h7YIRE3NiaJ5VS8Lb1QQ==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=12.x" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/progress": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@rc-component/progress/-/progress-1.0.2.tgz", - "integrity": "sha512-WZUnH9eGxH1+xodZKqdrHke59uyGZSWgj5HBM5Kwk5BrTMuAORO7VJ2IP5Qbm9aH3n9x3IcesqHHR0NWPBC7fQ==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/qrcode": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@rc-component/qrcode/-/qrcode-1.1.1.tgz", - "integrity": "sha512-LfLGNymzKdUPjXUbRP+xOhIWY4jQ+YMj5MmWAcgcAq1Ij8XP7tRmAXqyuv96XvLUBE/5cA8hLFl9eO1JQMujrA==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.24.7" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/rate": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/rate/-/rate-1.0.1.tgz", - "integrity": "sha512-bkXxeBqDpl5IOC7yL7GcSYjQx9G8H+6kLYQnNZWeBYq2OYIv1MONd6mqKTjnnJYpV0cQIU2z3atdW0j1kttpTw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/resize-observer": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@rc-component/resize-observer/-/resize-observer-1.1.2.tgz", - "integrity": "sha512-t/Bb0W8uvL4PYKAB3YcChC+DlHh0Wt5kM7q/J+0qpVEUMLe7Hk5zuvc9km0hMnTFPSx5Z7Wu/fzCLN6erVLE8Q==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.0" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/segmented": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@rc-component/segmented/-/segmented-1.3.0.tgz", - "integrity": "sha512-5J/bJ01mbDnoA6P/FW8SxUvKn+OgUSTZJPzCNnTBntG50tzoP7DydGhqxp7ggZXZls7me3mc2EQDXakU3iTVFg==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.11.1", - "@rc-component/motion": "^1.1.4", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.0.0", - "react-dom": ">=16.0.0" - } - }, - "node_modules/@rc-component/select": { - "version": "1.6.15", - "resolved": "https://registry.npmjs.org/@rc-component/select/-/select-1.6.15.tgz", - "integrity": "sha512-SyVCWnqxCQZZcQvQJ/CxSjx2bGma6ds/HtnpkIfZVnt6RoEgbqUmHgD6vrzNarNXwbLXerwVzWwq8F3d1sst7g==", - "license": "MIT", - "dependencies": { - "@rc-component/overflow": "^1.0.0", - "@rc-component/trigger": "^3.0.0", - "@rc-component/util": "^1.3.0", - "@rc-component/virtual-list": "^1.0.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": "*", - "react-dom": "*" - } - }, - "node_modules/@rc-component/slider": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/slider/-/slider-1.0.1.tgz", - "integrity": "sha512-uDhEPU1z3WDfCJhaL9jfd2ha/Eqpdfxsn0Zb0Xcq1NGQAman0TWaR37OWp2vVXEOdV2y0njSILTMpTfPV1454g==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/steps": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@rc-component/steps/-/steps-1.2.2.tgz", - "integrity": "sha512-/yVIZ00gDYYPHSY0JP+M+s3ZvuXLu2f9rEjQqiUDs7EcYsUYrpJ/1bLj9aI9R7MBR3fu/NGh6RM9u2qGfqp+Nw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/switch": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rc-component/switch/-/switch-1.0.3.tgz", - "integrity": "sha512-Jgi+EbOBquje/XNdofr7xbJQZPYJP+BlPfR0h+WN4zFkdtB2EWqEfvkXJWeipflwjWip0/17rNbxEAqs8hVHfw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/table": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@rc-component/table/-/table-1.9.1.tgz", - "integrity": "sha512-FVI5ZS/GdB3BcgexfCYKi3iHhZS3Fr59EtsxORszYGrfpH1eWr33eDNSYkVfLI6tfJ7vftJDd9D5apfFWqkdJg==", - "license": "MIT", - "dependencies": { - "@rc-component/context": "^2.0.1", - "@rc-component/resize-observer": "^1.0.0", - "@rc-component/util": "^1.1.0", - "@rc-component/virtual-list": "^1.0.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/tabs": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@rc-component/tabs/-/tabs-1.7.0.tgz", - "integrity": "sha512-J48cs2iBi7Ho3nptBxxIqizEliUC+ExE23faspUQKGQ550vaBlv3aGF8Epv/UB1vFWeoJDTW/dNzgIU0Qj5i/w==", - "license": "MIT", - "dependencies": { - "@rc-component/dropdown": "~1.0.0", - "@rc-component/menu": "~1.2.0", - "@rc-component/motion": "^1.1.3", - "@rc-component/resize-observer": "^1.0.0", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/textarea": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@rc-component/textarea/-/textarea-1.1.2.tgz", - "integrity": "sha512-9rMUEODWZDMovfScIEHXWlVZuPljZ2pd1LKNjslJVitn4SldEzq5vO1CL3yy3Dnib6zZal2r2DPtjy84VVpF6A==", - "license": "MIT", - "dependencies": { - "@rc-component/input": "~1.1.0", - "@rc-component/resize-observer": "^1.0.0", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/tooltip": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@rc-component/tooltip/-/tooltip-1.4.0.tgz", - "integrity": "sha512-8Rx5DCctIlLI4raR0I0xHjVTf1aF48+gKCNeAAo5bmF5VoR5YED+A/XEqzXv9KKqrJDRcd3Wndpxh2hyzrTtSg==", - "license": "MIT", - "dependencies": { - "@rc-component/trigger": "^3.7.1", - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/tour": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@rc-component/tour/-/tour-2.3.0.tgz", - "integrity": "sha512-K04K9r32kUC+auBSQfr+Fss4SpSIS9JGe56oq/ALAX0p+i2ylYOI1MgR83yBY7v96eO6ZFXcM/igCQmubps0Ow==", - "license": "MIT", - "dependencies": { - "@rc-component/portal": "^2.2.0", - "@rc-component/trigger": "^3.0.0", - "@rc-component/util": "^1.7.0", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/tree": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@rc-component/tree/-/tree-1.2.4.tgz", - "integrity": "sha512-5Gli43+m4R7NhpYYz3Z61I6LOw9yI6CNChxgVtvrO6xB1qML7iE6QMLVMB3+FTjo2yF6uFdAHtqWPECz/zbX5w==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.0.0", - "@rc-component/util": "^1.8.1", - "@rc-component/virtual-list": "^1.0.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=10.x" - }, - "peerDependencies": { - "react": "*", - "react-dom": "*" - } - }, - "node_modules/@rc-component/tree-select": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@rc-component/tree-select/-/tree-select-1.8.0.tgz", - "integrity": "sha512-iYsPq3nuLYvGqdvFAW+l+I9ASRIOVbMXyA8FGZg2lGym/GwkaWeJGzI4eJ7c9IOEhRj0oyfIN4S92Fl3J05mjQ==", - "license": "MIT", - "dependencies": { - "@rc-component/select": "~1.6.0", - "@rc-component/tree": "~1.2.0", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": "*", - "react-dom": "*" - } - }, - "node_modules/@rc-component/trigger": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/@rc-component/trigger/-/trigger-3.9.0.tgz", - "integrity": "sha512-X8btpwfrT27AgrZVOz4swclhEHTZcqaHeQMXXBgveagOiakTa36uObXbdwerXffgV8G9dH1fAAE0DHtVQs8EHg==", - "license": "MIT", - "dependencies": { - "@rc-component/motion": "^1.1.4", - "@rc-component/portal": "^2.2.0", - "@rc-component/resize-observer": "^1.1.1", - "@rc-component/util": "^1.2.1", - "clsx": "^2.1.1" - }, - "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/upload": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@rc-component/upload/-/upload-1.1.0.tgz", - "integrity": "sha512-LIBV90mAnUE6VK5N4QvForoxZc4XqEYZimcp7fk+lkE4XwHHyJWxpIXQQwMU8hJM+YwBbsoZkGksL1sISWHQxw==", - "license": "MIT", - "dependencies": { - "@rc-component/util": "^1.3.0", - "clsx": "^2.1.1" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" - } - }, - "node_modules/@rc-component/util": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@rc-component/util/-/util-1.10.1.tgz", - "integrity": "sha512-q++9S6rUa5Idb/xIBNz6jtvumw5+O5YV5V0g4iK9mn9jWs4oGJheE3ZN1kAnE723AXyaD8v95yeOASmdk8Jnng==", - "license": "MIT", + "node_modules/@playwright/test": { + "version": "1.59.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz", + "integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==", + "dev": true, + "license": "Apache-2.0", "dependencies": { - "is-mobile": "^5.0.0", - "react-is": "^18.2.0" + "playwright": "1.59.1" }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, - "node_modules/@rc-component/virtual-list": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@rc-component/virtual-list/-/virtual-list-1.0.2.tgz", - "integrity": "sha512-uvTol/mH74FYsn5loDGJxo+7kjkO4i+y4j87Re1pxJBs0FaeuMuLRzQRGaXwnMcV1CxpZLi2Z56Rerj2M00fjQ==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.20.0", - "@rc-component/resize-observer": "^1.0.1", - "@rc-component/util": "^1.4.0", - "clsx": "^2.1.1" + "bin": { + "playwright": "cli.js" }, "engines": { - "node": ">=8.x" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" + "node": ">=18" } }, "node_modules/@rolldown/pluginutils": { @@ -1665,9 +879,9 @@ "license": "MIT" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.1.tgz", - "integrity": "sha512-d6FinEBLdIiK+1uACUttJKfgZREXrF0Qc2SmLII7W2AD8FfiZ9Wjd+rD/iRuf5s5dWrr1GgwXCvPqOuDquOowA==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.2.tgz", + "integrity": "sha512-dnlp69efPPg6Uaw2dVqzWRfAWRnYVb1XJ8CyyhIbZeaq4CA5/mLeZ1IEt9QqQxmbdvagjLIm2ZL8BxXv5lH4Yw==", "cpu": [ "arm" ], @@ -1679,9 +893,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.1.tgz", - "integrity": "sha512-YjG/EwIDvvYI1YvYbHvDz/BYHtkY4ygUIXHnTdLhG+hKIQFBiosfWiACWortsKPKU/+dUwQQCKQM3qrDe8c9BA==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.2.tgz", + "integrity": "sha512-OqZTwDRDchGRHHm/hwLOL7uVPB9aUvI0am/eQuWMNyFHf5PSEQmyEeYYheA0EPPKUO/l0uigCp+iaTjoLjVoHg==", "cpu": [ "arm64" ], @@ -1693,9 +907,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.1.tgz", - "integrity": "sha512-mjCpF7GmkRtSJwon+Rq1N8+pI+8l7w5g9Z3vWj4T7abguC4Czwi3Yu/pFaLvA3TTeMVjnu3ctigusqWUfjZzvw==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.2.tgz", + "integrity": "sha512-UwRE7CGpvSVEQS8gUMBe1uADWjNnVgP3Iusyda1nSRwNDCsRjnGc7w6El6WLQsXmZTbLZx9cecegumcitNfpmA==", "cpu": [ "arm64" ], @@ -1707,9 +921,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.1.tgz", - "integrity": "sha512-haZ7hJ1JT4e9hqkoT9R/19XW2QKqjfJVv+i5AGg57S+nLk9lQnJ1F/eZloRO3o9Scy9CM3wQ9l+dkXtcBgN5Ew==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.2.tgz", + "integrity": "sha512-gjEtURKLCC5VXm1I+2i1u9OhxFsKAQJKTVB8WvDAHF+oZlq0GTVFOlTlO1q3AlCTE/DF32c16ESvfgqR7343/g==", "cpu": [ "x64" ], @@ -1721,9 +935,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.1.tgz", - "integrity": "sha512-czw90wpQq3ZsAVBlinZjAYTKduOjTywlG7fEeWKUA7oCmpA8xdTkxZZlwNJKWqILlq0wehoZcJYfBvOyhPTQ6w==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.2.tgz", + "integrity": "sha512-Bcl6CYDeAgE70cqZaMojOi/eK63h5Me97ZqAQoh77VPjMysA/4ORQBRGo3rRy45x4MzVlU9uZxs8Uwy7ZaKnBw==", "cpu": [ "arm64" ], @@ -1735,9 +949,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.1.tgz", - "integrity": "sha512-KVB2rqsxTHuBtfOeySEyzEOB7ltlB/ux38iu2rBQzkjbwRVlkhAGIEDiiYnO2kFOkJp+Z7pUXKyrRRFuFUKt+g==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.2.tgz", + "integrity": "sha512-LU+TPda3mAE2QB0/Hp5VyeKJivpC6+tlOXd1VMoXV/YFMvk/MNk5iXeBfB4MQGRWyOYVJ01625vjkr0Az98OJQ==", "cpu": [ "x64" ], @@ -1749,13 +963,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.1.tgz", - "integrity": "sha512-L+34Qqil+v5uC0zEubW7uByo78WOCIrBvci69E7sFASRl0X7b/MB6Cqd1lky/CtcSVTydWa2WZwFuWexjS5o6g==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.2.tgz", + "integrity": "sha512-2QxQrM+KQ7DAW4o22j+XZ6RKdxjLD7BOWTP0Bv0tmjdyhXSsr2Ul1oJDQqh9Zf5qOwTuTc7Ek83mOFaKnodPjg==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1763,13 +980,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.1.tgz", - "integrity": "sha512-n83O8rt4v34hgFzlkb1ycniJh7IR5RCIqt6mz1VRJD6pmhRi0CXdmfnLu9dIUS6buzh60IvACM842Ffb3xd6Gg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.2.tgz", + "integrity": "sha512-TbziEu2DVsTEOPif2mKWkMeDMLoYjx95oESa9fkQQK7r/Orta0gnkcDpzwufEcAO2BLBsD7mZkXGFqEdMRRwfw==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1777,13 +997,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.1.tgz", - "integrity": "sha512-Nql7sTeAzhTAja3QXeAI48+/+GjBJ+QmAH13snn0AJSNL50JsDqotyudHyMbO2RbJkskbMbFJfIJKWA6R1LCJQ==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.2.tgz", + "integrity": "sha512-bO/rVDiDUuM2YfuCUwZ1t1cP+/yqjqz+Xf2VtkdppefuOFS2OSeAfgafaHNkFn0t02hEyXngZkxtGqXcXwO8Rg==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1791,13 +1014,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.1.tgz", - "integrity": "sha512-+pUymDhd0ys9GcKZPPWlFiZ67sTWV5UU6zOJat02M1+PiuSGDziyRuI/pPue3hoUwm2uGfxdL+trT6Z9rxnlMA==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.2.tgz", + "integrity": "sha512-hr26p7e93Rl0Za+JwW7EAnwAvKkehh12BU1Llm9Ykiibg4uIr2rbpxG9WCf56GuvidlTG9KiiQT/TXT1yAWxTA==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1805,13 +1031,16 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.1.tgz", - "integrity": "sha512-VSvgvQeIcsEvY4bKDHEDWcpW4Yw7BtlKG1GUT4FzBUlEKQK0rWHYBqQt6Fm2taXS+1bXvJT6kICu5ZwqKCnvlQ==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.2.tgz", + "integrity": "sha512-pOjB/uSIyDt+ow3k/RcLvUAOGpysT2phDn7TTUB3n75SlIgZzM6NKAqlErPhoFU+npgY3/n+2HYIQVbF70P9/A==", "cpu": [ "loong64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1819,13 +1048,16 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.1.tgz", - "integrity": "sha512-4LqhUomJqwe641gsPp6xLfhqWMbQV04KtPp7/dIp0nzPxAkNY1AbwL5W0MQpcalLYk07vaW9Kp1PBhdpZYYcEw==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.2.tgz", + "integrity": "sha512-2/w+q8jszv9Ww1c+6uJT3OwqhdmGP2/4T17cu8WuwyUuuaCDDJ2ojdyYwZzCxx0GcsZBhzi3HmH+J5pZNXnd+Q==", "cpu": [ "loong64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1833,13 +1065,16 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.1.tgz", - "integrity": "sha512-tLQQ9aPvkBxOc/EUT6j3pyeMD6Hb8QF2BTBnCQWP/uu1lhc9AIrIjKnLYMEroIz/JvtGYgI9dF3AxHZNaEH0rw==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.2.tgz", + "integrity": "sha512-11+aL5vKheYgczxtPVVRhdptAM2H7fcDR5Gw4/bTcteuZBlH4oP9f5s9zYO9aGZvoGeBpqXI/9TZZihZ609wKw==", "cpu": [ "ppc64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1847,13 +1082,16 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.1.tgz", - "integrity": "sha512-RMxFhJwc9fSXP6PqmAz4cbv3kAyvD1etJFjTx4ONqFP9DkTkXsAMU4v3Vyc5BgzC+anz7nS/9tp4obsKfqkDHg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.2.tgz", + "integrity": "sha512-i16fokAGK46IVZuV8LIIwMdtqhin9hfYkCh8pf8iC3QU3LpwL+1FSFGej+O7l3E/AoknL6Dclh2oTdnRMpTzFQ==", "cpu": [ "ppc64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1861,13 +1099,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.1.tgz", - "integrity": "sha512-QKgFl+Yc1eEk6MmOBfRHYF6lTxiiiV3/z/BRrbSiW2I7AFTXoBFvdMEyglohPj//2mZS4hDOqeB0H1ACh3sBbg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.2.tgz", + "integrity": "sha512-49FkKS6RGQoriDSK/6E2GkAsAuU5kETFCh7pG4yD/ylj9rKhTmO3elsnmBvRD4PgJPds5W2PkhC82aVwmUcJ7A==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1875,13 +1116,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.1.tgz", - "integrity": "sha512-RAjXjP/8c6ZtzatZcA1RaQr6O1TRhzC+adn8YZDnChliZHviqIjmvFwHcxi4JKPSDAt6Uhf/7vqcBzQJy0PDJg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.2.tgz", + "integrity": "sha512-mjYNkHPfGpUR00DuM1ZZIgs64Hpf4bWcz9Z41+4Q+pgDx73UwWdAYyf6EG/lRFldmdHHzgrYyge5akFUW0D3mQ==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1889,13 +1133,16 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.1.tgz", - "integrity": "sha512-wcuocpaOlaL1COBYiA89O6yfjlp3RwKDeTIA0hM7OpmhR1Bjo9j31G1uQVpDlTvwxGn2nQs65fBFL5UFd76FcQ==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.2.tgz", + "integrity": "sha512-ALyvJz965BQk8E9Al/JDKKDLH2kfKFLTGMlgkAbbYtZuJt9LU8DW3ZoDMCtQpXAltZxwBHevXz5u+gf0yA0YoA==", "cpu": [ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1903,13 +1150,16 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.1.tgz", - "integrity": "sha512-77PpsFQUCOiZR9+LQEFg9GClyfkNXj1MP6wRnzYs0EeWbPcHs02AXu4xuUbM1zhwn3wqaizle3AEYg5aeoohhg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.2.tgz", + "integrity": "sha512-UQjrkIdWrKI626Du8lCQ6MJp/6V1LAo2bOK9OTu4mSn8GGXIkPXk/Vsp4bLHCd9Z9Iz2OTEaokUE90VweJgIYQ==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1917,13 +1167,16 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.1.tgz", - "integrity": "sha512-5cIATbk5vynAjqqmyBjlciMJl1+R/CwX9oLk/EyiFXDWd95KpHdrOJT//rnUl4cUcskrd0jCCw3wpZnhIHdD9w==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.2.tgz", + "integrity": "sha512-bTsRGj6VlSdn/XD4CGyzMnzaBs9bsRxy79eTqTCBsA8TMIEky7qg48aPkvJvFe1HyzQ5oMZdg7AnVlWQSKLTnw==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1931,9 +1184,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.1.tgz", - "integrity": "sha512-cl0w09WsCi17mcmWqqglez9Gk8isgeWvoUZ3WiJFYSR3zjBQc2J5/ihSjpl+VLjPqjQ/1hJRcqBfLjssREQILw==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.2.tgz", + "integrity": "sha512-6d4Z3534xitaA1FcMWP7mQPq5zGwBmGbhphh2DwaA1aNIXUu3KTOfwrWpbwI4/Gr0uANo7NTtaykFyO2hPuFLg==", "cpu": [ "x64" ], @@ -1945,9 +1198,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.1.tgz", - "integrity": "sha512-4Cv23ZrONRbNtbZa37mLSueXUCtN7MXccChtKpUnQNgF010rjrjfHx3QxkS2PI7LqGT5xXyYs1a7LbzAwT0iCA==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.2.tgz", + "integrity": "sha512-NetAg5iO2uN7eB8zE5qrZ3CSil+7IJt4WDFLcC75Ymywq1VZVD6qJ6EvNLjZ3rEm6gB7XW5JdT60c6MN35Z85Q==", "cpu": [ "arm64" ], @@ -1959,9 +1212,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.1.tgz", - "integrity": "sha512-i1okWYkA4FJICtr7KpYzFpRTHgy5jdDbZiWfvny21iIKky5YExiDXP+zbXzm3dUcFpkEeYNHgQ5fuG236JPq0g==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.2.tgz", + "integrity": "sha512-NCYhOotpgWZ5kdxCZsv6Iudx0wX8980Q/oW4pNFNihpBKsDbEA1zpkfxJGC0yugsUuyDZ7gL37dbzwhR0VI7pQ==", "cpu": [ "arm64" ], @@ -1973,9 +1226,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.1.tgz", - "integrity": "sha512-u09m3CuwLzShA0EYKMNiFgcjjzwqtUMLmuCJLeZWjjOYA3IT2Di09KaxGBTP9xVztWyIWjVdsB2E9goMjZvTQg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.2.tgz", + "integrity": "sha512-RXsaOqXxfoUBQoOgvmmijVxJnW2IGB0eoMO7F8FAjaj0UTywUO/luSqimWBJn04WNgUkeNhh7fs7pESXajWmkg==", "cpu": [ "ia32" ], @@ -1987,9 +1240,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.1.tgz", - "integrity": "sha512-k+600V9Zl1CM7eZxJgMyTUzmrmhB/0XZnF4pRypKAlAgxmedUA+1v9R+XOFv56W4SlHEzfeMtzujLJD22Uz5zg==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.2.tgz", + "integrity": "sha512-qdAzEULD+/hzObedtmV6iBpdL5TIbKVztGiK7O3/KYSf+HIzU257+MX1EXJcyIiDbMAqmbwaufcYPvyRryeZtA==", "cpu": [ "x64" ], @@ -2001,9 +1254,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.1.tgz", - "integrity": "sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.2.tgz", + "integrity": "sha512-Nd/SgG27WoA9e+/TdK74KnHz852TLa94ovOYySo/yMPuTmpckK/jIF2jSwS3g7ELSKXK13/cVdmg1Z/DaCWKxA==", "cpu": [ "x64" ], @@ -2117,74 +1370,10 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, - "node_modules/antd": { - "version": "6.3.7", - "resolved": "https://registry.npmjs.org/antd/-/antd-6.3.7.tgz", - "integrity": "sha512-WTHi4bHVNKpYXLHESzU0Tts7rRNQeL84Bph9dfI3Qw7mHbTulExDcYKNHny5CTXcrBBOpraXbU9miBAwUR5vaw==", - "license": "MIT", - "dependencies": { - "@ant-design/colors": "^8.0.1", - "@ant-design/cssinjs": "^2.1.2", - "@ant-design/cssinjs-utils": "^2.1.2", - "@ant-design/fast-color": "^3.0.1", - "@ant-design/icons": "^6.1.1", - "@ant-design/react-slick": "~2.0.0", - "@babel/runtime": "^7.28.4", - "@rc-component/cascader": "~1.14.0", - "@rc-component/checkbox": "~2.0.0", - "@rc-component/collapse": "~1.2.0", - "@rc-component/color-picker": "~3.1.1", - "@rc-component/dialog": "~1.8.4", - "@rc-component/drawer": "~1.4.2", - "@rc-component/dropdown": "~1.0.2", - "@rc-component/form": "~1.8.1", - "@rc-component/image": "~1.9.0", - "@rc-component/input": "~1.1.2", - "@rc-component/input-number": "~1.6.2", - "@rc-component/mentions": "~1.6.0", - "@rc-component/menu": "~1.2.0", - "@rc-component/motion": "^1.3.2", - "@rc-component/mutate-observer": "^2.0.1", - "@rc-component/notification": "~1.2.0", - "@rc-component/pagination": "~1.2.0", - "@rc-component/picker": "~1.9.1", - "@rc-component/progress": "~1.0.2", - "@rc-component/qrcode": "~1.1.1", - "@rc-component/rate": "~1.0.1", - "@rc-component/resize-observer": "^1.1.2", - "@rc-component/segmented": "~1.3.0", - "@rc-component/select": "~1.6.15", - "@rc-component/slider": "~1.0.1", - "@rc-component/steps": "~1.2.2", - "@rc-component/switch": "~1.0.3", - "@rc-component/table": "~1.9.1", - "@rc-component/tabs": "~1.7.0", - "@rc-component/textarea": "~1.1.2", - "@rc-component/tooltip": "~1.4.0", - "@rc-component/tour": "~2.3.0", - "@rc-component/tree": "~1.2.4", - "@rc-component/tree-select": "~1.8.0", - "@rc-component/trigger": "^3.9.0", - "@rc-component/upload": "~1.1.0", - "@rc-component/util": "^1.10.1", - "clsx": "^2.1.1", - "dayjs": "^1.11.11", - "scroll-into-view-if-needed": "^3.1.0", - "throttle-debounce": "^5.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/ant-design" - }, - "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" - } - }, "node_modules/axe-core": { - "version": "4.11.2", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.11.2.tgz", - "integrity": "sha512-byD6KPdvo72y/wj2T/4zGEvvlis+PsZsn/yPS3pEO+sFpcrqRpX/TJCxvVaEsNeMrfQbCr7w163YqoD9IYwHXw==", + "version": "4.11.4", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.11.4.tgz", + "integrity": "sha512-KunSNx+TVpkAw/6ULfhnx+HWRecjqZGTOyquAoWHYLRSdK1tB5Ihce1ZW+UY3fj33bYAFWPu7W/GRSmmrCGuxA==", "dev": true, "license": "MPL-2.0", "engines": { @@ -2192,9 +1381,9 @@ } }, "node_modules/baseline-browser-mapping": { - "version": "2.10.15", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.15.tgz", - "integrity": "sha512-1nfKCq9wuAZFTkA2ey/3OXXx7GzFjLdkTiFVNwlJ9WqdI706CZRIhEqjuwanjMIja+84jDLa9rcyZDPDiVkASQ==", + "version": "2.10.27", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.27.tgz", + "integrity": "sha512-zEs/ufmZoUd7WftKpKyXaT6RFxpQ5Qm9xytKRHvJfxFV9DFJkZph9RvJ1LcOUi0Z1ZVijMte65JbILeV+8QQEA==", "dev": true, "license": "Apache-2.0", "bin": { @@ -2239,9 +1428,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001785", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001785.tgz", - "integrity": "sha512-blhOL/WNR+Km1RI/LCVAvA73xplXA7ZbjzI4YkMK9pa6T/P3F2GxjNpEkyw5repTw9IvkyrjyHpwjnhZ5FOvYQ==", + "version": "1.0.30001791", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001791.tgz", + "integrity": "sha512-yk0l/YSrOnFZk3UROpDLQD9+kC1l4meK/wed583AXrzoarMGJcbRi2Q4RaUYbKxYAsZ8sWmaSa/DsLmdBeI1vQ==", "dev": true, "funding": [ { @@ -2259,21 +1448,6 @@ ], "license": "CC-BY-4.0" }, - "node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/compute-scroll-into-view": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/compute-scroll-into-view/-/compute-scroll-into-view-3.1.1.tgz", - "integrity": "sha512-VRhuHOLoKYOy4UbilLbUzbYg93XLjv2PncJC50EuTWPA3gaja1UjBsUP/D/9/juV3vQFr6XBEzn9KCAHdUvOHw==", - "license": "MIT" - }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -2298,13 +1472,17 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, "license": "MIT" }, - "node_modules/dayjs": { - "version": "1.11.20", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.20.tgz", - "integrity": "sha512-YbwwqR/uYpeoP4pu043q+LTDLFBLApUP6VxRihdfNTqu4ubqMlGDLd6ErXhEgsyvY0K6nCs7nggYumAN+9uEuQ==", - "license": "MIT" + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "license": "ISC", + "engines": { + "node": ">=12" + } }, "node_modules/debug": { "version": "4.4.3", @@ -2324,34 +1502,10 @@ } } }, - "node_modules/echarts": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/echarts/-/echarts-6.0.0.tgz", - "integrity": "sha512-Tte/grDQRiETQP4xz3iZWSvoHrkCQtwqd6hs+mifXcjrCuo2iKWbajFObuLJVBlDIJlOzgQPd1hsaKt/3+OMkQ==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "2.3.0", - "zrender": "6.0.0" - } - }, - "node_modules/echarts-for-react": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/echarts-for-react/-/echarts-for-react-3.0.6.tgz", - "integrity": "sha512-4zqLgTGWS3JvkQDXjzkR1k1CHRdpd6by0988TWMJgnvDytegWLbeP/VNZmMa+0VJx2eD7Y632bi2JquXDgiGJg==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "size-sensor": "^1.0.1" - }, - "peerDependencies": { - "echarts": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0", - "react": "^15.0.0 || >=16.0.0" - } - }, "node_modules/electron-to-chromium": { - "version": "1.5.331", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.331.tgz", - "integrity": "sha512-IbxXrsTlD3hRodkLnbxAPP4OuJYdWCeM3IOdT+CpcMoIwIoDfCmRpEtSPfwBXxVkg9xmBeY7Lz2Eo2TDn/HC3Q==", + "version": "1.5.349", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.349.tgz", + "integrity": "sha512-QsWVGyRuY07Aqb234QytTfwd5d9AJlfNIQ5wIOl1L+PZDzI9d9+Fn0FRale/QYlFxt/bUnB0/nLd1jFPGxGK1A==", "dev": true, "license": "ISC" }, @@ -2407,12 +1561,6 @@ "node": ">=6" } }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -2456,12 +1604,6 @@ "node": ">=6.9.0" } }, - "node_modules/is-mobile": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-mobile/-/is-mobile-5.0.0.tgz", - "integrity": "sha512-Tz/yndySvLAEXh+Uk8liFCxOwVH6YutuR74utvOcu7I9Di+DwM0mtdPVZNaVvvBUM2OXxne/NhOs1zAO7riusQ==", - "license": "MIT" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -2482,15 +1624,6 @@ "node": ">=6" } }, - "node_modules/json2mq": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/json2mq/-/json2mq-0.2.0.tgz", - "integrity": "sha512-SzoRg7ux5DWTII9J2qkrZrqV1gt+rTaoufMxEzXbS26Uid0NwaJd123HcoB80TgubEppxxIGdNxCx50fEoEWQA==", - "license": "MIT", - "dependencies": { - "string-convert": "^0.2.0" - } - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -2522,9 +1655,9 @@ "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", + "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==", "dev": true, "funding": [ { @@ -2541,9 +1674,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.37", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.37.tgz", - "integrity": "sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==", + "version": "2.0.38", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.38.tgz", + "integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==", "dev": true, "license": "MIT" }, @@ -2600,9 +1733,9 @@ } }, "node_modules/postcss": { - "version": "8.5.10", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.10.tgz", - "integrity": "sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==", + "version": "8.5.13", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.13.tgz", + "integrity": "sha512-qif0+jGGZoLWdHey3UFHHWP0H7Gbmsk8T5VEqyYFbWqPr1XqvLGBbk/sl8V5exGmcYJklJOhOQq1pV9IcsiFag==", "dev": true, "funding": [ { @@ -2649,12 +1782,6 @@ "react": "^19.2.5" } }, - "node_modules/react-is": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", - "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", - "license": "MIT" - }, "node_modules/react-refresh": { "version": "0.17.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz", @@ -2666,9 +1793,9 @@ } }, "node_modules/react-router": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.14.0.tgz", - "integrity": "sha512-m/xR9N4LQLmAS0ZhkY2nkPA1N7gQ5TUVa5n8TgANuDTARbn1gt+zLPXEm7W0XDTbrQ2AJSJKhoa6yx1D8BcpxQ==", + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.14.2.tgz", + "integrity": "sha512-yCqNne6I8IB6rVCH7XUvlBK7/QKyqypBFGv+8dj4QBFJiiRX+FG7/nkdAvGElyvVZ/HQP5N19wzteuTARXi5Gw==", "license": "MIT", "dependencies": { "cookie": "^1.0.1", @@ -2688,12 +1815,12 @@ } }, "node_modules/react-router-dom": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.14.0.tgz", - "integrity": "sha512-2G3ajSVSZMEtmTjIklRWlNvo8wICEpLihfD/0YMDxbWK2UyP5EGfnoIn9AIQGnF3G/FX0MRbHXdFcD+rL1ZreQ==", + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.14.2.tgz", + "integrity": "sha512-YZcM5ES8jJSM+KrJ9BdvHHqlnGTg5tH3sC5ChFRj4inosKctdyzBDhOyyHdGk597q2OT6NTrCA1OvB/YDwfekQ==", "license": "MIT", "dependencies": { - "react-router": "7.14.0" + "react-router": "7.14.2" }, "engines": { "node": ">=20.0.0" @@ -2704,9 +1831,9 @@ } }, "node_modules/rollup": { - "version": "4.60.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.1.tgz", - "integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==", + "version": "4.60.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.2.tgz", + "integrity": "sha512-J9qZyW++QK/09NyN/zeO0dG/1GdGfyp9lV8ajHnRVLfo/uFsbji5mHnDgn/qYdUHyCkM2N+8VyspgZclfAh0eQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2720,31 +1847,31 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.60.1", - "@rollup/rollup-android-arm64": "4.60.1", - "@rollup/rollup-darwin-arm64": "4.60.1", - "@rollup/rollup-darwin-x64": "4.60.1", - "@rollup/rollup-freebsd-arm64": "4.60.1", - "@rollup/rollup-freebsd-x64": "4.60.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.60.1", - "@rollup/rollup-linux-arm-musleabihf": "4.60.1", - "@rollup/rollup-linux-arm64-gnu": "4.60.1", - "@rollup/rollup-linux-arm64-musl": "4.60.1", - "@rollup/rollup-linux-loong64-gnu": "4.60.1", - "@rollup/rollup-linux-loong64-musl": "4.60.1", - "@rollup/rollup-linux-ppc64-gnu": "4.60.1", - "@rollup/rollup-linux-ppc64-musl": "4.60.1", - "@rollup/rollup-linux-riscv64-gnu": "4.60.1", - "@rollup/rollup-linux-riscv64-musl": "4.60.1", - "@rollup/rollup-linux-s390x-gnu": "4.60.1", - "@rollup/rollup-linux-x64-gnu": "4.60.1", - "@rollup/rollup-linux-x64-musl": "4.60.1", - "@rollup/rollup-openbsd-x64": "4.60.1", - "@rollup/rollup-openharmony-arm64": "4.60.1", - "@rollup/rollup-win32-arm64-msvc": "4.60.1", - "@rollup/rollup-win32-ia32-msvc": "4.60.1", - "@rollup/rollup-win32-x64-gnu": "4.60.1", - "@rollup/rollup-win32-x64-msvc": "4.60.1", + "@rollup/rollup-android-arm-eabi": "4.60.2", + "@rollup/rollup-android-arm64": "4.60.2", + "@rollup/rollup-darwin-arm64": "4.60.2", + "@rollup/rollup-darwin-x64": "4.60.2", + "@rollup/rollup-freebsd-arm64": "4.60.2", + "@rollup/rollup-freebsd-x64": "4.60.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.60.2", + "@rollup/rollup-linux-arm-musleabihf": "4.60.2", + "@rollup/rollup-linux-arm64-gnu": "4.60.2", + "@rollup/rollup-linux-arm64-musl": "4.60.2", + "@rollup/rollup-linux-loong64-gnu": "4.60.2", + "@rollup/rollup-linux-loong64-musl": "4.60.2", + "@rollup/rollup-linux-ppc64-gnu": "4.60.2", + "@rollup/rollup-linux-ppc64-musl": "4.60.2", + "@rollup/rollup-linux-riscv64-gnu": "4.60.2", + "@rollup/rollup-linux-riscv64-musl": "4.60.2", + "@rollup/rollup-linux-s390x-gnu": "4.60.2", + "@rollup/rollup-linux-x64-gnu": "4.60.2", + "@rollup/rollup-linux-x64-musl": "4.60.2", + "@rollup/rollup-openbsd-x64": "4.60.2", + "@rollup/rollup-openharmony-arm64": "4.60.2", + "@rollup/rollup-win32-arm64-msvc": "4.60.2", + "@rollup/rollup-win32-ia32-msvc": "4.60.2", + "@rollup/rollup-win32-x64-gnu": "4.60.2", + "@rollup/rollup-win32-x64-msvc": "4.60.2", "fsevents": "~2.3.2" } }, @@ -2754,15 +1881,6 @@ "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", "license": "MIT" }, - "node_modules/scroll-into-view-if-needed": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/scroll-into-view-if-needed/-/scroll-into-view-if-needed-3.1.0.tgz", - "integrity": "sha512-49oNpRjWRvnU8NyGVmUaYG4jtTkNonFZI86MmGRDqBphEK2EXT9gdEUoQPZhuBM8yWHxCWbobltqYO5M4XrUvQ==", - "license": "MIT", - "dependencies": { - "compute-scroll-into-view": "^3.0.2" - } - }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -2779,12 +1897,6 @@ "integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==", "license": "MIT" }, - "node_modules/size-sensor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/size-sensor/-/size-sensor-1.0.3.tgz", - "integrity": "sha512-+k9mJ2/rQMiRmQUcjn+qznch260leIXY8r4FyYKKyRBO/s5UoeMAHGkCJyE1R/4wrIhTJONfyloY55SkE7ve3A==", - "license": "ISC" - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -2795,36 +1907,15 @@ "node": ">=0.10.0" } }, - "node_modules/string-convert": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", - "integrity": "sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==", - "license": "MIT" - }, - "node_modules/stylis": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.4.0.tgz", - "integrity": "sha512-5Z9ZpRzfuH6l/UAvCPAPUo3665Nk2wLaZU3x+TLHKVzIz33+sbJqbtrYoC3KD4/uVOr2Zp+L0LySezP9OHV9yA==", - "license": "MIT" - }, - "node_modules/throttle-debounce": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-5.0.2.tgz", - "integrity": "sha512-B71/4oyj61iNH0KeCamLuE2rmKuTO5byTOSVwECM5FA7TiAiAW+UqTKZ9ERueC4qvgSttUhdmq1mXC3kJqGX7A==", - "license": "MIT", - "engines": { - "node": ">=12.22" - } - }, "node_modules/tinyglobby": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", - "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", + "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", - "picomatch": "^4.0.3" + "picomatch": "^4.0.4" }, "engines": { "node": ">=12.0.0" @@ -2833,12 +1924,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tslib": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", - "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", - "license": "0BSD" - }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -2987,15 +2072,6 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "license": "ISC" - }, - "node_modules/zrender": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/zrender/-/zrender-6.0.0.tgz", - "integrity": "sha512-41dFXEEXuJpNecuUQq6JlbybmnHaqqpGlbH1yxnA5V9MMP4SbohSVZsJIwz+zdjQXSSlR1Vc34EgH1zxyTDvhg==", - "license": "BSD-3-Clause", - "dependencies": { - "tslib": "2.3.0" - } } } } diff --git a/src/main/frontend/package.json b/src/main/frontend/package.json index ad2b29f4..f16a702e 100644 --- a/src/main/frontend/package.json +++ b/src/main/frontend/package.json @@ -12,10 +12,8 @@ "test:e2e:report": "playwright show-report" }, "dependencies": { - "@ant-design/icons": "^6.2.1", - "antd": "^6.3.7", - "echarts": "^6.0.0", - "echarts-for-react": "^3.0.2", + "@ossrandom/design-system": "^0.3.0", + "d3-hierarchy": "^3.1.2", "react": "^19.2.5", "react-dom": "^19.2.5", "react-router-dom": "^7.1.5" diff --git a/src/main/frontend/src/components/AppLayout.tsx b/src/main/frontend/src/components/AppLayout.tsx index 8baf8894..eda3718e 100644 --- a/src/main/frontend/src/components/AppLayout.tsx +++ b/src/main/frontend/src/components/AppLayout.tsx @@ -1,45 +1,88 @@ import { Outlet } from 'react-router-dom'; -import { Layout, Switch, Typography, Space } from 'antd'; -import { SunOutlined, MoonOutlined } from '@ant-design/icons'; +import { useState } from 'react'; +import { AppShell, IconButton } from '@ossrandom/design-system'; import { useTheme } from '@/context/ThemeContext'; -const { Header, Content } = Layout; +function SunIcon() { + return ( + + ); +} -export default function AppLayout() { +function MoonIcon() { + return ( + + ); +} + +function CopyIcon({ ok }: { ok: boolean }) { + if (ok) { + return ( + + ); + } + return ( + + ); +} + +function McpUrlPill() { + const [copied, setCopied] = useState(false); + const url = (typeof window !== 'undefined' ? window.location.origin : '') + '/mcp'; + const onCopy = async () => { + try { + await navigator.clipboard.writeText(url); + setCopied(true); + setTimeout(() => setCopied(false), 1200); + } catch { + /* clipboard blocked — silent */ + } + }; + return ( +
+ MCP · {url} + +
+ ); +} + +function Header() { const { isDark, toggle } = useTheme(); + return ( +
+
Code IQ
+
+ + : } + aria-label={isDark ? 'Switch to light mode' : 'Switch to dark mode'} + variant="ghost" + size="sm" + onClick={toggle} + /> +
+
+ ); +} +export default function AppLayout() { return ( - -
- - Code IQ - - - } - unCheckedChildren={} - /> - -
- + }> +
- - +
+
); } diff --git a/src/main/frontend/src/components/Icons.tsx b/src/main/frontend/src/components/Icons.tsx new file mode 100644 index 00000000..cbfdeab3 --- /dev/null +++ b/src/main/frontend/src/components/Icons.tsx @@ -0,0 +1,27 @@ +import type { CSSProperties } from 'react'; + +const base: CSSProperties = { display: 'inline-block', verticalAlign: '-2px' }; + +function Svg({ d, size = 14 }: { d: string; size?: number }) { + return ( + + ); +} + +export const Icon = { + Nodes: () => , + Branches: () => , + File: () => , + Code: () => , + Api: () => , + Safety: () => , + Appstore: () => , + Build: () => , + Play: () => , + Clock: () => , + Search: () => , + History: () => , +}; diff --git a/src/main/frontend/src/index.css b/src/main/frontend/src/index.css index b895e769..39d1a1b3 100644 --- a/src/main/frontend/src/index.css +++ b/src/main/frontend/src/index.css @@ -2,13 +2,133 @@ body { margin: 0; padding: 0; } -/* Ant Design handles all theming */ - -/* MCP tool list: allow multiline descriptions */ -.mcp-tool-menu .ant-menu-item { - height: auto !important; - line-height: normal !important; - padding-top: 4px !important; - padding-bottom: 4px !important; - white-space: normal !important; + +/* Layout-only — visuals come from design-system tokens. */ +.codeiq-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 0 16px; + height: 56px; +} + +.codeiq-brand { + color: var(--accent); + font-size: var(--fs-h4); + font-weight: var(--fw-semibold); + letter-spacing: -0.01em; + white-space: nowrap; +} + +.codeiq-content { + padding: 16px; +} + +.codeiq-header-actions { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; +} + +.codeiq-mcp-url { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 4px 8px; + border: 1px solid var(--border-1); + border-radius: 6px; + background: var(--bg-2); + color: var(--fg-2); + font-family: var(--font-mono); + font-size: 12px; + max-width: 360px; + overflow: hidden; +} + +.codeiq-mcp-url > span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.codeiq-mcp-url > button { + flex: none; + background: transparent; + border: 0; + padding: 2px; + color: var(--fg-3); + cursor: pointer; + border-radius: 4px; +} + +.codeiq-mcp-url > button:hover { + color: var(--fg-1); + background: var(--bg-3); +} + +/* Stats grid — auto-fit so cards flow on mobile. */ +.codeiq-stats-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 8px; +} + +/* Hide the design-system Treemap's engine badge (renders "canvas"/"webgl" + in a corner — debug affordance, not desired in app chrome). */ +.rcs-treemap-engine-badge { + display: none !important; +} + +.codeiq-breadcrumb { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 4px; + padding: 6px 10px; + border: 1px solid var(--border-1); + border-radius: 6px; + background: var(--bg-1); + font-size: 12px; + color: var(--fg-2); + font-family: var(--font-mono); +} + +.codeiq-breadcrumb button { + background: transparent; + border: 0; + padding: 2px 6px; + border-radius: 4px; + color: inherit; + font-family: inherit; + font-size: inherit; + cursor: pointer; +} + +.codeiq-breadcrumb button:hover:not(:disabled) { + background: var(--bg-3); + color: var(--fg-1); +} + +.codeiq-breadcrumb button:disabled { + cursor: default; + opacity: 0.7; +} + +.codeiq-breadcrumb-sep { + opacity: 0.4; + user-select: none; +} + +@media (max-width: 600px) { + .codeiq-header { + padding: 0 12px; + } + .codeiq-content { + padding: 12px; + } + .codeiq-mcp-url { + display: none; + } } diff --git a/src/main/frontend/src/main.tsx b/src/main/frontend/src/main.tsx index 8b1356b0..4ab5648f 100644 --- a/src/main/frontend/src/main.tsx +++ b/src/main/frontend/src/main.tsx @@ -1,91 +1,19 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; -import { ConfigProvider, theme, App as AntApp } from 'antd'; +import { ToastRegion } from '@ossrandom/design-system'; import AppRoot from './App'; -import { ThemeProvider, useTheme } from './context/ThemeContext'; +import { ThemeProvider } from './context/ThemeContext'; +import '@ossrandom/design-system/styles.css'; import './index.css'; -function ThemedApp() { - const { isDark } = useTheme(); - return ( - - - - - - - - ); -} - ReactDOM.createRoot(document.getElementById('root')!).render( - + + + + ); diff --git a/src/main/frontend/src/pages/CodebaseMap.tsx b/src/main/frontend/src/pages/CodebaseMap.tsx deleted file mode 100644 index 43a3706f..00000000 --- a/src/main/frontend/src/pages/CodebaseMap.tsx +++ /dev/null @@ -1,294 +0,0 @@ -import { useState, useMemo, useCallback } from 'react'; -import { Typography, Spin, Alert, Drawer } from 'antd'; -import ReactECharts from 'echarts-for-react'; -import { useApi } from '@/hooks/useApi'; -import { api } from '@/lib/api'; -import { useTheme } from '@/context/ThemeContext'; -import type { FileTreeResponse, FileTreeNode } from '@/types/api'; - -const LANG_COLORS: Record = { - java: '#b07219', python: '#3572A5', typescript: '#3178c6', javascript: '#f1e05a', - go: '#00ADD8', csharp: '#178600', rust: '#dea584', kotlin: '#A97BFF', - yaml: '#cb171e', json: '#555', ruby: '#701516', scala: '#c22d40', - cpp: '#f34b7d', shell: '#89e051', markdown: '#083fa1', html: '#e34c26', - css: '#563d7c', sql: '#e38c00', proto: '#60a0b0', dockerfile: '#384d54', - other: '#888', -}; - -const EXT_TO_LANG: Record = { - java: 'java', py: 'python', ts: 'typescript', tsx: 'typescript', - js: 'javascript', jsx: 'javascript', go: 'go', cs: 'csharp', - rs: 'rust', kt: 'kotlin', yml: 'yaml', yaml: 'yaml', - json: 'json', rb: 'ruby', scala: 'scala', cpp: 'cpp', - h: 'cpp', sh: 'shell', md: 'markdown', html: 'html', - css: 'css', sql: 'sql', proto: 'proto', -}; - -interface EChartsTreeNode { - name: string; - value?: number; - children?: EChartsTreeNode[]; - itemStyle?: { color: string }; -} - -function inferLang(name: string): string { - const ext = name.split('.').pop()?.toLowerCase() ?? ''; - return EXT_TO_LANG[ext] ?? 'other'; -} - -function dominantLang(nodes: FileTreeNode[]): string { - const counts: Record = {}; - function walk(items: FileTreeNode[]) { - for (const item of items) { - if (item.type === 'file') { - const lang = inferLang(item.name); - counts[lang] = (counts[lang] ?? 0) + (item.nodeCount || 1); - } - if (item.children) walk(item.children); - } - } - walk(nodes); - return Object.entries(counts).sort((a, b) => b[1] - a[1])[0]?.[0] ?? 'other'; -} - -function collapseTree(nodes: FileTreeNode[]): FileTreeNode[] { - return nodes.map(n => { - if (n.type !== 'directory' || !n.children || n.children.length === 0) return n; - - let current = n; - let collapsedName = n.name; - while ( - current.type === 'directory' && - current.children && - current.children.length === 1 && - current.children[0].type === 'directory' && - current.children[0].children && - current.children[0].children.length > 0 - ) { - current = current.children[0]; - collapsedName += '/' + current.name; - } - - const collapsedChildren = collapseTree(current.children ?? []); - return { ...current, name: collapsedName, children: collapsedChildren, nodeCount: n.nodeCount }; - }); -} - -function toEChartsNodes(nodes: FileTreeNode[]): EChartsTreeNode[] { - const result: EChartsTreeNode[] = []; - for (const n of nodes) { - if (n.nodeCount <= 0 && (!n.children || n.children.length === 0)) continue; - - if (n.type === 'directory' && n.children && n.children.length > 0) { - const children = toEChartsNodes(n.children); - if (children.length === 0) continue; - const lang = dominantLang(n.children); - result.push({ - name: n.name, - children, - itemStyle: { color: LANG_COLORS[lang] ?? '#666' }, - }); - } else { - const lang = inferLang(n.name); - result.push({ - name: n.name, - value: Math.max(n.nodeCount, 1), - itemStyle: { color: LANG_COLORS[lang] ?? '#666' }, - }); - } - } - return result; -} - -function fileTreeToECharts(nodes: FileTreeNode[]): EChartsTreeNode[] { - return toEChartsNodes(collapseTree(nodes)); -} - -export default function CodebaseMap() { - const { isDark } = useTheme(); - const [fileDrawer, setFileDrawer] = useState<{ path: string; content: string } | null>(null); - const [fileLoading, setFileLoading] = useState(false); - - const { data: treeData, loading, error } = useApi( - () => api.getFileTree(), [] - ); - - const tree = treeData?.tree ?? []; - const totalFiles = treeData?.total_files ?? 0; - const treemapData = useMemo(() => fileTreeToECharts(tree), [tree]); - - // On click: if leaf node (no children), open file in drawer - const onClickNode = useCallback(async (params: { - data?: { children?: unknown[] }; - treePathInfo?: Array<{ name: string }>; - }) => { - if (params.data?.children && (params.data.children as unknown[]).length > 0) return; - const pathParts = params.treePathInfo?.map(p => p.name).filter(Boolean) ?? []; - if (pathParts.length === 0) return; - const filePath = pathParts.join('/'); - setFileLoading(true); - try { - const content = await api.readFile(filePath); - setFileDrawer({ path: filePath, content }); - } catch { - setFileDrawer({ path: filePath, content: '// Could not load file' }); - } finally { - setFileLoading(false); - } - }, []); - - const onEvents = useMemo(() => ({ - click: onClickNode, - }), [onClickNode]); - - const chartOption = useMemo(() => ({ - tooltip: { - formatter: (info: { name: string; value: number; treePathInfo?: Array<{ name: string }> }) => { - const path = info.treePathInfo?.map(p => p.name).filter(Boolean).join('/') ?? info.name; - return `${path}
Nodes: ${(info.value ?? 0).toLocaleString()}`; - }, - }, - series: [{ - type: 'treemap', - data: treemapData, - top: 0, - left: 0, - right: 0, - bottom: 0, - width: '100%', - height: '100%', - leafDepth: 2, - drillDownIcon: '▶ ', - roam: false, - nodeClick: 'zoomToNode', - breadcrumb: { - show: true, - bottom: 8, - left: 'center', - height: 28, - itemStyle: { - color: isDark ? '#1f1f1f' : '#fff', - borderColor: isDark ? '#444' : '#bbb', - borderWidth: 1, - shadowBlur: 3, - shadowColor: isDark ? 'rgba(0,0,0,0.5)' : 'rgba(0,0,0,0.15)', - }, - textStyle: { - color: isDark ? '#e0e0e0' : '#333', - fontSize: 14, - fontWeight: 'bold' as const, - }, - }, - levels: [ - { - itemStyle: { - borderColor: isDark ? '#303030' : '#bbb', - borderWidth: 3, - gapWidth: 3, - }, - upperLabel: { - show: true, - height: 30, - color: isDark ? '#e0e0e0' : '#333', - fontSize: 14, - fontWeight: 'bold' as const, - }, - }, - { - itemStyle: { - borderColor: isDark ? '#404040' : '#ccc', - borderWidth: 2, - gapWidth: 2, - }, - upperLabel: { - show: true, - height: 24, - fontSize: 12, - color: isDark ? '#ccc' : '#555', - }, - }, - { - itemStyle: { - borderColor: isDark ? '#4a4a4a' : '#ddd', - borderWidth: 1, - gapWidth: 1, - }, - label: { show: true, fontSize: 11 }, - }, - ], - label: { - show: true, - formatter: '{b}', - fontSize: 12, - color: isDark ? '#ddd' : '#333', - }, - }], - }), [treemapData, isDark]); - - if (loading) { - return
; - } - - if (error) { - return ; - } - - return ( -
- {treemapData.length > 0 ? ( - <> -
- {totalFiles.toLocaleString()} files -
- - - ) : ( -
- No file data available. Run index + enrich first. -
- )} - - setFileDrawer(null)} - styles={{ body: { padding: 0 } }} - > - {fileLoading ? ( -
- ) : ( -
-            {fileDrawer?.content}
-          
- )} -
-
- ); -} diff --git a/src/main/frontend/src/pages/Dashboard.tsx b/src/main/frontend/src/pages/Dashboard.tsx index 13d67f66..6ce8829c 100644 --- a/src/main/frontend/src/pages/Dashboard.tsx +++ b/src/main/frontend/src/pages/Dashboard.tsx @@ -1,23 +1,15 @@ -import { useState, useMemo, useCallback } from 'react'; +import { useState, useMemo, useCallback, useEffect, Fragment } from 'react'; import { - Card, Col, Row, Statistic, Spin, Alert, Typography, Modal, Table, Drawer, Menu, - Form, Input, InputNumber, Select, Button, Space, Tag, -} from 'antd'; -import { - NodeIndexOutlined, BranchesOutlined, FileOutlined, CodeOutlined, - ApiOutlined, SafetyOutlined, AppstoreOutlined, BuildOutlined, - PlayCircleOutlined, ClockCircleOutlined, SearchOutlined, - BarChartOutlined, ThunderboltOutlined, SafetyCertificateOutlined, - HistoryOutlined, -} from '@ant-design/icons'; -import ReactECharts from 'echarts-for-react'; + Card, Spin, Alert, Modal, Drawer, Stat, Table, ScrollDiv, Space, +} from '@ossrandom/design-system'; +import { Treemap } from '@ossrandom/design-system/charts'; +import type { TreemapNode } from '@ossrandom/design-system/charts'; import { useApi } from '@/hooks/useApi'; import { api } from '@/lib/api'; -import { useTheme } from '@/context/ThemeContext'; -import { TOOLS, CATEGORIES, toolsByCategory, type McpTool } from '@/lib/mcp-tools'; import type { StatsResponse, FileTreeResponse, FileTreeNode } from '@/types/api'; +import { Icon } from '@/components/Icons'; -// ── Stats ── +// ── Stats helpers ── function flattenToRecord(val: unknown): Record { if (!val || typeof val !== 'object') return {}; @@ -35,39 +27,62 @@ function sumValues(rec: Record): number { return Object.values(rec).reduce((a, b) => a + b, 0); } +function isComputedStats(s: StatsResponse): s is StatsResponse & { + graph: { nodes: number; edges: number; files: number }; + languages: Record; frameworks: Record; + connections?: unknown; auth?: unknown; architecture?: unknown; +} { return 'graph' in s; } + +interface BreakdownRow { key: string; name: string; count: number } + function StatCard({ title, value, icon, detail, detailTitle }: { title: string; value: number | string; icon: React.ReactNode; detail?: Record; detailTitle?: string; }) { const [open, setOpen] = useState(false); const hasDetail = detail && Object.keys(detail).length > 0 && sumValues(detail) > 0; - const tableData = hasDetail + const tableData: BreakdownRow[] = hasDetail ? Object.entries(detail!).sort((a, b) => b[1] - a[1]).map(([name, count]) => ({ key: name, name, count })) : []; + + const cardEl = ( + + {icon}{title}} + value={value} + /> + + ); + return ( <> - hasDetail && setOpen(true)} - style={{ cursor: hasDetail ? 'pointer' : 'default', height: '100%' }} size="small"> - - - setOpen(false)} footer={null} width={600}> - 15 ? { pageSize: 15 } : false} size="small" - columns={[ - { title: 'Name', dataIndex: 'name', key: 'name' }, - { title: 'Count', dataIndex: 'count', key: 'count', align: 'right' as const, render: (v: number) => v.toLocaleString() }, - ]} /> + {hasDetail ? ( +
setOpen(true)} + onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setOpen(true); } }} + style={{ cursor: 'pointer', height: '100%' }}> + {cardEl} +
+ ) : cardEl} + setOpen(false)} title={detailTitle ?? title} size="md"> + + + rowKey="key" + density="compact" + data={tableData} + columns={[ + { key: 'name', title: 'Name', dataKey: 'name' }, + { key: 'count', title: 'Count', dataKey: 'count', align: 'right', + render: (v) => (typeof v === 'number' ? v.toLocaleString() : String(v)) }, + ]} + /> + ); } -function isComputedStats(s: StatsResponse): s is StatsResponse & { - graph: { nodes: number; edges: number; files: number }; - languages: Record; frameworks: Record; - connections?: unknown; auth?: unknown; architecture?: unknown; -} { return 'graph' in s; } - -// ── Treemap ── +// ── Treemap data ── const LANG_COLORS: Record = { java: '#b07219', python: '#3572A5', typescript: '#3178c6', javascript: '#f1e05a', @@ -86,8 +101,6 @@ const EXT_TO_LANG: Record = { css: 'css', sql: 'sql', proto: 'proto', }; -interface EChartsTreeNode { name: string; value?: number; children?: EChartsTreeNode[]; itemStyle?: { color: string } } - function inferLang(name: string): string { return EXT_TO_LANG[name.split('.').pop()?.toLowerCase() ?? ''] ?? 'other'; } @@ -115,47 +128,56 @@ function collapseTree(nodes: FileTreeNode[]): FileTreeNode[] { }); } -function toEChartsNodes(nodes: FileTreeNode[]): EChartsTreeNode[] { - const result: EChartsTreeNode[] = []; - for (const n of nodes) { +function buildTreemapTree( + nodes: FileTreeNode[], + parentPath: string, + pathMap: WeakMap, +): TreemapNode[] { + // Sort children by name so the treemap layout is stable across page + // loads regardless of API result ordering. d3-hierarchy's squarified + // layout is deterministic in input order; so deterministic input ⇒ + // deterministic visual. + const sorted = [...nodes].sort((a, b) => a.name.localeCompare(b.name)); + const out: TreemapNode[] = []; + for (const n of sorted) { + const fullPath = parentPath ? `${parentPath}/${n.name}` : n.name; if (n.nodeCount <= 0 && (!n.children || n.children.length === 0)) continue; if (n.type === 'directory' && n.children && n.children.length > 0) { - const children = toEChartsNodes(n.children); + const children = buildTreemapTree(n.children, fullPath, pathMap); if (children.length === 0) continue; - result.push({ name: n.name, children, itemStyle: { color: LANG_COLORS[dominantLang(n.children)] ?? '#666' } }); + const node: TreemapNode = { + name: n.name, + children, + color: LANG_COLORS[dominantLang(n.children)] ?? '#666', + }; + pathMap.set(node, fullPath); + out.push(node); } else { - result.push({ name: n.name, value: Math.max(n.nodeCount, 1), itemStyle: { color: LANG_COLORS[inferLang(n.name)] ?? '#666' } }); + const node: TreemapNode = { + name: n.name, + value: Math.max(n.nodeCount, 1), + color: LANG_COLORS[inferLang(n.name)] ?? '#666', + }; + pathMap.set(node, fullPath); + out.push(node); } } - return result; + return out; } -// ── MCP ── - -const CATEGORY_ICONS: Record = { - stats: , query: , topology: , - flow: , analysis: , security: , - code: , -}; - -function resolveUrl(tool: McpTool, params: Record): string { - return typeof tool.url === 'function' ? tool.url(params) : tool.url; -} - -function countResults(json: unknown): number | null { - if (Array.isArray(json)) return json.length; - if (json && typeof json === 'object') { - const obj = json as Record; - for (const k of ['nodes', 'services', 'kinds']) if (Array.isArray(obj[k])) return (obj[k] as unknown[]).length; - } - return null; +function useViewportHeight(offset: number): number { + const [h, setH] = useState(() => (typeof window === 'undefined' ? 600 : window.innerHeight - offset)); + useEffect(() => { + const onResize = () => setH(window.innerHeight - offset); + window.addEventListener('resize', onResize); + return () => window.removeEventListener('resize', onResize); + }, [offset]); + return Math.max(360, h); } // ── Main ── export default function Dashboard() { - const { isDark } = useTheme(); - // Stats const { data: stats, loading: statsLoading, error: statsError } = useApi(() => api.getStats(), []); const { data: kinds } = useApi(() => api.getKinds(), []); @@ -182,272 +204,152 @@ export default function Dashboard() { if (g?.edges_by_kind && typeof g.edges_by_kind === 'object') Object.assign(edgeKindBreakdown, flattenToRecord(g.edges_by_kind)); } + // Treemap height — header(56) + content padding(32) + stats row(~110) + + // breadcrumb(38) + gaps(24) + const treemapHeight = useViewportHeight(56 + 32 + 110 + 38 + 24); + // Treemap const { data: treeData, loading: treeLoading } = useApi(() => api.getFileTree(), []); - const treemapData = useMemo(() => toEChartsNodes(collapseTree(treeData?.tree ?? [])), [treeData]); + const { treemapRoot, pathMap } = useMemo(() => { + const map = new WeakMap(); + const children = buildTreemapTree(collapseTree(treeData?.tree ?? []), '', map); + const root: TreemapNode = { name: 'root', children }; + return { treemapRoot: root, pathMap: map }; + }, [treeData]); + + // Drill state — names of the directories we've drilled into, in order. + // Empty = full tree. Single-click on a directory pushes; clicking a + // breadcrumb segment slices back to that depth. + const [focusPath, setFocusPath] = useState([]); + + // Reset focus when the underlying tree changes (e.g., re-fetch after enrich). + useEffect(() => { setFocusPath([]); }, [treemapRoot]); + + // Walk treemapRoot along focusPath. Falls back to root if any segment is + // missing (defensive — shouldn't happen since focusPath only ever holds + // names we just clicked). + const focusedRoot = useMemo(() => { + let cur: TreemapNode = treemapRoot; + for (const name of focusPath) { + const child = cur.children?.find(c => c.name === name); + if (!child) return treemapRoot; + cur = child; + } + return cur; + }, [treemapRoot, focusPath]); - // File viewer — dblclick only (single click = treemap navigate) + // File viewer const [fileDrawer, setFileDrawer] = useState<{ path: string; content: string } | null>(null); const [fileLoading, setFileLoading] = useState(false); - const onDblClickNode = useCallback(async (params: { data?: { children?: unknown[] }; treePathInfo?: Array<{ name: string }> }) => { - if (params.data?.children && (params.data.children as unknown[]).length > 0) return; - const pathParts = params.treePathInfo?.map(p => p.name).filter(Boolean) ?? []; - if (pathParts.length === 0) return; - const filePath = pathParts.join('/'); + const onTreemapNodeClick = useCallback(async (node: TreemapNode) => { + // Directory — drill down one level. + if (node.children && node.children.length > 0) { + setFocusPath(prev => [...prev, node.name]); + return; + } + // Leaf — open file in drawer. + const filePath = pathMap.get(node); + if (!filePath) return; setFileLoading(true); + setFileDrawer({ path: filePath, content: '' }); try { setFileDrawer({ path: filePath, content: await api.readFile(filePath) }); } catch { setFileDrawer({ path: filePath, content: '// Could not load file' }); } finally { setFileLoading(false); } - }, []); - const treemapEvents = useMemo(() => ({ dblclick: onDblClickNode }), [onDblClickNode]); - - const chartOption = useMemo(() => ({ - tooltip: { - formatter: (info: { name: string; value: number; treePathInfo?: Array<{ name: string }> }) => { - const path = info.treePathInfo?.map(p => p.name).filter(Boolean).join('/') ?? info.name; - return `${path}
Nodes: ${(info.value ?? 0).toLocaleString()}
Double-click to view source`; - }, - }, - series: [{ - type: 'treemap', data: treemapData, top: 0, left: 0, right: 0, bottom: 0, width: '100%', height: '100%', - leafDepth: 2, drillDownIcon: '▶ ', roam: false, nodeClick: 'zoomToNode', - breadcrumb: { - show: true, bottom: 8, left: 'center', height: 28, - itemStyle: { - color: isDark ? '#000' : '#1a1a1a', - borderColor: isDark ? '#555' : '#333', - borderWidth: 1, - shadowBlur: 6, - shadowColor: 'rgba(0,0,0,0.4)', - borderRadius: 4, - }, - textStyle: { color: '#fff', fontSize: 13, fontWeight: 'bold' as const }, - emphasis: { - itemStyle: { color: isDark ? '#1a1a1a' : '#333' }, - textStyle: { color: '#fff' }, - }, - }, - levels: [ - { itemStyle: { borderColor: isDark ? '#303030' : '#bbb', borderWidth: 3, gapWidth: 3 }, - upperLabel: { show: true, height: 28, color: isDark ? '#e0e0e0' : '#333', fontSize: 13, fontWeight: 'bold' as const } }, - { itemStyle: { borderColor: isDark ? '#404040' : '#ccc', borderWidth: 2, gapWidth: 2 }, - upperLabel: { show: true, height: 22, fontSize: 11, color: isDark ? '#ccc' : '#555' } }, - { itemStyle: { borderColor: isDark ? '#4a4a4a' : '#ddd', borderWidth: 1, gapWidth: 1 }, label: { show: true, fontSize: 10 } }, - ], - label: { show: true, formatter: '{b}', fontSize: 11, color: isDark ? '#ddd' : '#333' }, - }], - }), [treemapData, isDark]); - - // MCP Console - const [selectedTool, setSelectedTool] = useState(TOOLS[0] ?? null); - const [toolModalOpen, setToolModalOpen] = useState(false); - const [mcpResponse, setMcpResponse] = useState(''); - const [mcpStatus, setMcpStatus] = useState(null); - const [mcpDuration, setMcpDuration] = useState(null); - const [executing, setExecuting] = useState(false); - const [mcpResultCount, setMcpResultCount] = useState(null); - const [responseModalOpen, setResponseModalOpen] = useState(false); - const [history, setHistory] = useState>([]); - const [paletteQuery, setPaletteQuery] = useState(''); - const [form] = Form.useForm(); - const grouped = toolsByCategory(); - - - const selectTool = useCallback((tool: McpTool) => { - setSelectedTool(tool); - const defaults: Record = {}; - tool.params.forEach(p => { if (p.default !== undefined) defaults[p.name] = p.default; }); - form.setFieldsValue(defaults); - }, [form]); + }, [pathMap]); - const execute = useCallback(async () => { - if (!selectedTool) return; - const values = form.getFieldsValue(); - const params: Record = {}; - for (const [k, v] of Object.entries(values)) { if (v !== undefined && v !== null && v !== '') params[k] = String(v); } - if (selectedTool.params.filter(p => p.required && !params[p.name]?.trim()).length) { form.validateFields(); return; } - setExecuting(true); - const start = performance.now(); - try { - const res = await fetch(resolveUrl(selectedTool, params), { - method: selectedTool.method ?? 'GET', - ...(selectedTool.method === 'POST' ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params) } : {}), - }); - const elapsed = Math.round(performance.now() - start); - setMcpStatus(res.status); setMcpDuration(elapsed); - const ct = res.headers.get('content-type') ?? ''; - let text: string; - if (ct.includes('json')) { const json = await res.json(); text = JSON.stringify(json, null, 2); setMcpResultCount(countResults(json)); } - else { text = await res.text(); setMcpResultCount(null); } - setMcpResponse(text); setResponseModalOpen(true); - setHistory(prev => [{ toolName: selectedTool.name, status: res.status, duration: elapsed, response: text }, ...prev.slice(0, 19)]); - } catch (err) { - const elapsed = Math.round(performance.now() - start); - setMcpStatus(0); setMcpDuration(elapsed); - const text = JSON.stringify({ error: err instanceof Error ? err.message : String(err) }, null, 2); - setMcpResponse(text); setMcpResultCount(null); setResponseModalOpen(true); - setHistory(prev => [{ toolName: selectedTool.name, status: 0, duration: elapsed, response: text }, ...prev.slice(0, 19)]); - } finally { setExecuting(false); } - }, [selectedTool, form]); - - const q = paletteQuery.toLowerCase().trim(); - const filteredMenuItems = CATEGORIES.map(cat => { - const tools = (grouped[cat.id] ?? []).filter(t => !q || t.name.includes(q) || t.description.toLowerCase().includes(q)); - return { - key: cat.id, icon: CATEGORY_ICONS[cat.id] ?? , label: cat.label, - children: tools.map(tool => ({ - key: tool.name, - label: ( -
-
{tool.name}
-
{tool.description}
-
- ), - })), - }; - }).filter(cat => cat.children.length > 0); - - if (statsLoading || treeLoading) return
; - if (statsError) return ; + if (statsLoading || treeLoading) { + return
; + } + if (statsError) { + return {statsError}; + } return ( -
- {/* Stats row */} - +
+
{[ - { t: 'Nodes', v: nodeCount.toLocaleString(), i: , d: nodeKindBreakdown, dt: 'Nodes by Kind' }, - { t: 'Edges', v: edgeCount.toLocaleString(), i: , d: edgeKindBreakdown, dt: 'Edges by Kind' }, - { t: 'Files', v: fileCount.toLocaleString(), i: }, - { t: 'Languages', v: Object.keys(languages).length, i: , d: languages, dt: 'Languages' }, - { t: 'Frameworks', v: Object.keys(frameworks).length, i: , d: frameworks, dt: 'Frameworks' }, - { t: 'Connections', v: sumValues(connections), i: , d: connections, dt: 'Connections' }, - { t: 'Security', v: sumValues(auth), i: , d: auth, dt: 'Auth Patterns' }, - { t: 'Code Structure', v: sumValues(architecture), i: , d: architecture, dt: 'Code Structure' }, + { t: 'Nodes', v: nodeCount.toLocaleString(), i: , d: nodeKindBreakdown, dt: 'Nodes by Kind' }, + { t: 'Edges', v: edgeCount.toLocaleString(), i: , d: edgeKindBreakdown, dt: 'Edges by Kind' }, + { t: 'Files', v: fileCount.toLocaleString(), i: }, + { t: 'Languages', v: Object.keys(languages).length, i: , d: languages, dt: 'Languages' }, + { t: 'Frameworks', v: Object.keys(frameworks).length, i: , d: frameworks, dt: 'Frameworks' }, + { t: 'Connections', v: sumValues(connections), i: , d: connections, dt: 'Connections' }, + { t: 'Security', v: sumValues(auth), i: , d: auth, dt: 'Auth Patterns' }, + { t: 'Code Structure', v: sumValues(architecture), i: , d: architecture, dt: 'Code Structure' }, ].map(s => ( -
- - + ))} - - - {/* Main area: Treemap (left) + MCP Console (right) */} -
- {/* Treemap */} -
- {treemapData.length > 0 ? ( - - ) : ( -
- No file data. Run index + enrich first. -
- )} -
- - {/* MCP Tools — 20% */} -
-
- MCP Tools - } - allowClear value={paletteQuery} onChange={e => setPaletteQuery(e.target.value)} style={{ marginTop: 6 }} /> -
-
- c.id) : ['stats']} - items={filteredMenuItems} - onClick={({ key }: { key: string }) => { - const t = TOOLS.find(t => t.name === key); - if (t) { selectTool(t); setToolModalOpen(true); } - }} - style={{ borderRight: 'none', fontSize: 11 }} /> -
-
- {/* MCP Tool Form Modal */} - - {selectedTool.name} - {selectedTool.method ?? 'GET'} - - ) : 'Tool'} - open={toolModalOpen} - onCancel={() => setToolModalOpen(false)} - footer={null} - width={500} - > - {selectedTool && ( - <> - {selectedTool.description} - {selectedTool.params.length > 0 ? ( -
{ execute(); setToolModalOpen(false); }} size="small"> - {selectedTool.params.map(param => ( - {param.name}{param.required && required}} - rules={param.required ? [{ required: true, message: `${param.name} is required` }] : []} - tooltip={param.description}> - {param.options ? ( - - ) : ( - { execute(); setToolModalOpen(false); }} /> - )} - - ))} - - - ) : ( - - )} +
+ + {focusPath.map((seg, i) => ( + + / + + + ))} +
- {history.length > 0 && ( -
- Recent - {history.slice(0, 5).map((entry, i) => ( -
{ setMcpResponse(entry.response); setMcpStatus(entry.status); setMcpDuration(entry.duration); setResponseModalOpen(true); }} - style={{ padding: '3px 0', cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 6, fontSize: 11 }}> - = 200 && entry.status < 300 ? 'green' : 'red'} style={{ fontSize: 10 }}>{entry.status} - {entry.toolName} - {entry.duration}ms -
- ))} -
- )} - +
+ {focusedRoot.children && focusedRoot.children.length > 0 ? ( + v.toLocaleString()} + /> + ) : ( + +
+ {treemapRoot.children && treemapRoot.children.length > 0 + ? 'This folder is empty. Use the breadcrumb above to go back.' + : 'No file data. Run index + enrich first.'} +
+
)} - - - {/* MCP Response Modal */} - - Response - {mcpStatus !== null && = 200 && mcpStatus < 300 ? 'green' : mcpStatus >= 400 ? 'red' : 'orange'}>{mcpStatus}} - {mcpDuration !== null && {mcpDuration}ms} - {mcpResultCount !== null && {mcpResultCount} results} - - } open={responseModalOpen} onCancel={() => setResponseModalOpen(false)} footer={null} width={700}> -
{mcpResponse}
-
+
- {/* File viewer Drawer (double-click on leaf file) */} - setFileDrawer(null)} styles={{ body: { padding: 0 } }}> - {fileLoading ?
: ( -
{fileDrawer?.content}
+ setFileDrawer(null)} + placement="right" + width="60vw" + title={fileDrawer?.path} + > + {fileLoading ? ( +
+ ) : ( +
+            {fileDrawer?.content}
+          
)}
- ); } diff --git a/src/main/frontend/src/pages/Explorer.tsx b/src/main/frontend/src/pages/Explorer.tsx deleted file mode 100644 index a6f5d33d..00000000 --- a/src/main/frontend/src/pages/Explorer.tsx +++ /dev/null @@ -1,354 +0,0 @@ -import { useState, useCallback, useEffect } from 'react'; -import { useParams, useNavigate } from 'react-router-dom'; -import { Tabs, Table, Tag, Input, Drawer, Descriptions, Spin, Alert, Typography, Space, List } from 'antd'; -import type { ColumnsType } from 'antd/es/table'; -import { useApi } from '@/hooks/useApi'; -import { api } from '@/lib/api'; -import type { KindsResponse, NodeResponse, NodesListResponse, SearchResult } from '@/types/api'; - -const KIND_COLORS: Record = { - endpoint: 'green', entity: 'blue', class: 'purple', method: 'cyan', - module: 'orange', guard: 'red', config_key: 'gold', infra_resource: 'volcano', - component: 'geekblue', service: 'magenta', interface: 'lime', function: 'cyan', - enum: 'gold', field: 'default', route: 'green', middleware: 'orange', - producer: 'volcano', consumer: 'blue', topic: 'purple', schema: 'geekblue', -}; - -export default function Explorer() { - const { kind: urlKind } = useParams<{ kind?: string }>(); - const navigate = useNavigate(); - const [activeKind, setActiveKind] = useState(urlKind ?? ''); - const [page, setPage] = useState(1); - const [pageSize, setPageSize] = useState(50); - const [searchQuery, setSearchQuery] = useState(''); - const [searchResults, setSearchResults] = useState(null); - const [searchLoading, setSearchLoading] = useState(false); - const [drawerOpen, setDrawerOpen] = useState(false); - const [selectedNode, setSelectedNode] = useState(null); - const [detailLoading, setDetailLoading] = useState(false); - const [neighbors, setNeighbors] = useState<{ incoming: Array<{ edge: { kind: string }; node: NodeResponse }>; outgoing: Array<{ edge: { kind: string }; node: NodeResponse }> } | null>(null); - - const { data: kinds, loading: kindsLoading } = useApi(() => api.getKinds(), []); - - const { data: nodesData, loading: nodesLoading } = useApi( - () => activeKind - ? api.getNodesByKind(activeKind, pageSize, (page - 1) * pageSize) - : api.getNodes(undefined, undefined, pageSize, (page - 1) * pageSize), - [activeKind, page, pageSize] - ); - - // Sync URL with active kind - useEffect(() => { - if (urlKind && urlKind !== activeKind) { - setActiveKind(urlKind); - setPage(1); - } - }, [urlKind]); - - const handleKindChange = useCallback((kind: string) => { - setActiveKind(kind); - setPage(1); - setSearchResults(null); - setSearchQuery(''); - navigate(kind ? `/explorer/${kind}` : '/explorer', { replace: true }); - }, [navigate]); - - const handleSearch = useCallback(async (value: string) => { - if (!value.trim()) { - setSearchResults(null); - return; - } - setSearchLoading(true); - try { - const results = await api.search(value, 50); - setSearchResults(results); - } catch { - setSearchResults([]); - } finally { - setSearchLoading(false); - } - }, []); - - const openDetail = useCallback(async (nodeId: string) => { - setDrawerOpen(true); - setDetailLoading(true); - setNeighbors(null); - try { - const [detail, nbrs] = await Promise.all([ - api.getNodeDetail(nodeId), - api.getNodeNeighbors(nodeId).catch(() => null), - ]); - setSelectedNode(detail); - if (nbrs && typeof nbrs === 'object') { - setNeighbors(nbrs as typeof neighbors); - } - } catch { - setSelectedNode(null); - } finally { - setDetailLoading(false); - } - }, []); - - const columns: ColumnsType = [ - { - title: 'Label', - dataIndex: 'label', - key: 'label', - ellipsis: true, - render: (text: string, record: NodeResponse) => ( - openDetail(record.id)}>{text} - ), - }, - { - title: 'Kind', - dataIndex: 'kind', - key: 'kind', - width: 130, - render: (kind: string) => {kind}, - }, - { - title: 'Module', - dataIndex: 'module', - key: 'module', - width: 180, - ellipsis: true, - }, - { - title: 'File Path', - dataIndex: 'file_path', - key: 'file_path', - ellipsis: true, - width: 300, - }, - { - title: 'Layer', - dataIndex: 'layer', - key: 'layer', - width: 100, - render: (layer: string) => layer ? {layer} : null, - }, - ]; - - const searchColumns: ColumnsType = [ - { - title: 'Label', - key: 'label', - ellipsis: true, - render: (_: unknown, record: SearchResult) => ( - openDetail(record.id)}>{record.label ?? record.name ?? record.id} - ), - }, - { - title: 'Kind', - dataIndex: 'kind', - key: 'kind', - width: 130, - render: (kind: string) => {kind}, - }, - { - title: 'File', - key: 'file', - ellipsis: true, - width: 300, - render: (_: unknown, record: SearchResult) => record.file_path ?? record.filePath ?? '', - }, - { - title: 'Score', - dataIndex: 'score', - key: 'score', - width: 80, - render: (score: number) => score !== undefined ? score.toFixed(2) : '', - }, - ]; - - if (kindsLoading) { - return
; - } - - const kindTabs = [ - { key: '', label: `All (${kinds?.total ?? 0})` }, - ...(kinds?.kinds ?? []) - .sort((a, b) => b.count - a.count) - .map(k => ({ - key: k.kind, - label: `${k.kind} (${k.count})`, - })), - ]; - - return ( -
- Explorer - - setSearchQuery(e.target.value)} - onSearch={handleSearch} - loading={searchLoading} - /> - - {searchResults ? ( -
-
- - {searchResults.length} search result{searchResults.length !== 1 ? 's' : ''} - - { setSearchResults(null); setSearchQuery(''); }} style={{ marginLeft: 12 }}> - Clear search - -
-
- - ) : ( - <> - -
{ setPage(p); setPageSize(ps); }, - }} - onRow={(record) => ({ - style: { cursor: 'pointer' }, - onClick: () => openDetail(record.id), - })} - /> - - )} - - { setDrawerOpen(false); setSelectedNode(null); setNeighbors(null); }} - > - {detailLoading ? ( -
- ) : selectedNode ? ( -
- - - - {selectedNode.id} - - - - {selectedNode.kind} - - {selectedNode.fqn && ( - {selectedNode.fqn} - )} - {selectedNode.module && ( - {selectedNode.module} - )} - {selectedNode.file_path && ( - {selectedNode.file_path} - )} - {selectedNode.line_start != null && ( - - {selectedNode.line_start}{selectedNode.line_end ? ` - ${selectedNode.line_end}` : ''} - - )} - {selectedNode.layer && ( - {selectedNode.layer} - )} - {selectedNode.annotations && selectedNode.annotations.length > 0 && ( - - - {selectedNode.annotations.map((a, i) => {a})} - - - )} - - - {/* Properties */} - {selectedNode.properties && Object.keys(selectedNode.properties).length > 0 && ( - <> - Properties - - {Object.entries(selectedNode.properties).map(([key, val]) => ( - - - {typeof val === 'object' ? JSON.stringify(val) : String(val)} - - - ))} - - - )} - - {/* Neighbors */} - {neighbors && ( - <> - {neighbors.incoming && neighbors.incoming.length > 0 && ( - <> - Incoming ({neighbors.incoming.length}) - ( - - - {item.node.kind} - openDetail(item.node.id)}>{item.node.label} - {item.edge.kind} - - - )} - /> - - )} - {neighbors.outgoing && neighbors.outgoing.length > 0 && ( - <> - Outgoing ({neighbors.outgoing.length}) - ( - - - {item.edge.kind} - openDetail(item.node.id)}>{item.node.label} - {item.node.kind} - - - )} - /> - - )} - - )} -
- ) : ( - - )} -
- - ); -} diff --git a/src/main/frontend/src/pages/McpConsole.tsx b/src/main/frontend/src/pages/McpConsole.tsx deleted file mode 100644 index e55f6001..00000000 --- a/src/main/frontend/src/pages/McpConsole.tsx +++ /dev/null @@ -1,415 +0,0 @@ -import { useState, useCallback, useEffect } from 'react'; -import { - Layout, Menu, Card, Form, Input, InputNumber, Select, Button, Typography, - Space, Tag, Tooltip, Modal, Empty, -} from 'antd'; -import { - PlayCircleOutlined, - ClockCircleOutlined, - SearchOutlined, - BarChartOutlined, - BranchesOutlined, - ApiOutlined, - ThunderboltOutlined, - SafetyCertificateOutlined, - CodeOutlined, - AppstoreOutlined, - HistoryOutlined, -} from '@ant-design/icons'; -import { TOOLS, CATEGORIES, toolsByCategory, type McpTool } from '@/lib/mcp-tools'; - -const { Sider, Content } = Layout; - -const CATEGORY_ICONS: Record = { - stats: , - query: , - topology: , - flow: , - analysis: , - security: , - code: , -}; - -interface HistoryEntry { - toolName: string; - status: number; - duration: number; - response: string; - timestamp: number; -} - -function resolveUrl(tool: McpTool, params: Record): string { - return typeof tool.url === 'function' ? tool.url(params) : tool.url; -} - -function countResults(json: unknown): number | null { - if (Array.isArray(json)) return json.length; - if (json && typeof json === 'object') { - const obj = json as Record; - if (Array.isArray(obj.nodes)) return (obj.nodes as unknown[]).length; - if (Array.isArray(obj.services)) return (obj.services as unknown[]).length; - if (Array.isArray(obj.kinds)) return (obj.kinds as unknown[]).length; - } - return null; -} - -export default function McpConsole() { - const [selectedTool, setSelectedTool] = useState(TOOLS[0] ?? null); - const [response, setResponse] = useState(''); - const [status, setStatus] = useState(null); - const [duration, setDuration] = useState(null); - const [executing, setExecuting] = useState(false); - const [resultCount, setResultCount] = useState(null); - const [history, setHistory] = useState([]); - const [paletteOpen, setPaletteOpen] = useState(false); - const [paletteQuery, setPaletteQuery] = useState(''); - const [form] = Form.useForm(); - const grouped = toolsByCategory(); - - // Cmd+K shortcut - useEffect(() => { - const handler = (e: KeyboardEvent) => { - if ((e.metaKey || e.ctrlKey) && e.key === 'k') { - e.preventDefault(); - setPaletteOpen(v => !v); - } - }; - window.addEventListener('keydown', handler); - return () => window.removeEventListener('keydown', handler); - }, []); - - const selectTool = useCallback((tool: McpTool) => { - setSelectedTool(tool); - const defaults: Record = {}; - tool.params.forEach(p => { if (p.default !== undefined) defaults[p.name] = p.default; }); - form.setFieldsValue(defaults); - }, [form]); - - const execute = useCallback(async () => { - if (!selectedTool) return; - const values = form.getFieldsValue(); - const params: Record = {}; - for (const [k, v] of Object.entries(values)) { - if (v !== undefined && v !== null && v !== '') params[k] = String(v); - } - - // Validate required - const missing = selectedTool.params - .filter(p => p.required && !params[p.name]?.trim()) - .map(p => p.name); - if (missing.length) { - form.validateFields(); - return; - } - - setExecuting(true); - const start = performance.now(); - try { - const url = resolveUrl(selectedTool, params); - const method = selectedTool.method ?? 'GET'; - const opts: RequestInit = { method }; - if (method === 'POST') { - opts.headers = { 'Content-Type': 'application/json' }; - opts.body = JSON.stringify(params); - } - const res = await fetch(url, opts); - const elapsed = Math.round(performance.now() - start); - setStatus(res.status); - setDuration(elapsed); - - const ct = res.headers.get('content-type') ?? ''; - let text: string; - if (ct.includes('json')) { - const json = await res.json(); - text = JSON.stringify(json, null, 2); - setResultCount(countResults(json)); - } else { - text = await res.text(); - setResultCount(null); - } - setResponse(text); - setHistory(prev => [ - { toolName: selectedTool.name, status: res.status, duration: elapsed, response: text, timestamp: Date.now() }, - ...prev.slice(0, 19), - ]); - } catch (err) { - const elapsed = Math.round(performance.now() - start); - setStatus(0); - setDuration(elapsed); - const text = JSON.stringify({ error: err instanceof Error ? err.message : String(err) }, null, 2); - setResponse(text); - setResultCount(null); - setHistory(prev => [ - { toolName: selectedTool.name, status: 0, duration: elapsed, response: text, timestamp: Date.now() }, - ...prev.slice(0, 19), - ]); - } finally { - setExecuting(false); - } - }, [selectedTool, form]); - - // Build menu items - const menuItems = CATEGORIES.map(cat => ({ - key: cat.id, - icon: CATEGORY_ICONS[cat.id] ?? , - label: cat.label, - children: (grouped[cat.id] ?? []).map(tool => ({ - key: tool.name, - label: ( - - {tool.name} - - ), - })), - })); - - const paletteResults = paletteQuery.trim() - ? TOOLS.filter(t => - t.name.includes(paletteQuery.toLowerCase()) || - t.description.toLowerCase().includes(paletteQuery.toLowerCase()) - ) - : TOOLS; - - return ( -
-
-
- MCP Console - - {TOOLS.length} tools across {CATEGORIES.length} categories - -
- -
- - - - - { - const tool = TOOLS.find(t => t.name === key); - if (tool) selectTool(tool); - }} - style={{ borderRight: 'none' }} - /> - - - - -
- {/* Tool form */} - - {selectedTool.name} - - {selectedTool.method ?? 'GET'} - - - ) : 'Select a tool'} - extra={selectedTool && ( - - )} - > - {selectedTool ? ( - <> - - {selectedTool.description} - - {selectedTool.params.length > 0 ? ( -
- {selectedTool.params.map(param => ( - - {param.name} - {param.required && required} - {param.type} - - } - name={param.name} - rules={param.required ? [{ required: true, message: `${param.name} is required` }] : []} - tooltip={param.description} - > - {param.options ? ( - - ) : ( - - )} - - ))} - - ) : ( - No parameters required. Click Run to execute. - )} - - {resolveUrl(selectedTool, form.getFieldsValue() ?? {})} - - - ) : ( - - )} -
- - {/* Response */} - - Response - {status !== null && ( - = 200 && status < 300 ? 'green' : status >= 400 ? 'red' : 'orange'}> - {status} - - )} - {duration !== null && ( - - {duration}ms - - )} - {resultCount !== null && ( - - {resultCount} results - - )} - - } - style={{ flex: 1 }} - styles={{ body: { overflow: 'auto', maxHeight: 400 } }} - > - {response ? ( -
-                  {response}
-                
- ) : ( - - )} -
- - {/* History */} - {history.length > 0 && ( - History ({history.length})} - styles={{ body: { padding: 0 } }} - size="small" - > - {history.map((entry, i) => ( -
setResponse(entry.response)} - style={{ - padding: '8px 16px', - cursor: 'pointer', - display: 'flex', - alignItems: 'center', - gap: 8, - borderBottom: '1px solid rgba(128,128,128,0.1)', - }} - > - = 200 && entry.status < 300 ? 'green' : 'red'}> - {entry.status} - - {entry.toolName} - - {entry.duration}ms - -
- ))} -
- )} -
-
- - - {/* Command Palette */} - { setPaletteOpen(false); setPaletteQuery(''); }} - footer={null} - width={500} - > - setPaletteQuery(e.target.value)} - prefix={} - style={{ marginBottom: 16 }} - onKeyDown={e => { - if (e.key === 'Enter' && paletteResults.length > 0) { - selectTool(paletteResults[0]); - setPaletteOpen(false); - setPaletteQuery(''); - } - }} - /> -
- {paletteResults.length === 0 ? ( - - ) : ( - paletteResults.map(tool => { - const cat = CATEGORIES.find(c => c.id === tool.category); - return ( -
{ - selectTool(tool); - setPaletteOpen(false); - setPaletteQuery(''); - }} - style={{ - padding: '8px 12px', - cursor: 'pointer', - borderBottom: '1px solid rgba(128,128,128,0.1)', - display: 'flex', - alignItems: 'center', - gap: 8, - }} - > -
- {tool.name} -
- - {tool.description} - -
- {cat && {cat.label}} -
- ); - }) - )} -
-
-
- ); -} diff --git a/src/main/frontend/vite.config.ts b/src/main/frontend/vite.config.ts index 1ea464d6..b0686b1d 100644 --- a/src/main/frontend/vite.config.ts +++ b/src/main/frontend/vite.config.ts @@ -18,8 +18,8 @@ export default defineConfig({ output: { manualChunks: { 'vendor-react': ['react', 'react-dom', 'react-router-dom'], - 'vendor-antd': ['antd', '@ant-design/icons'], - 'vendor-echarts': ['echarts', 'echarts-for-react'], + 'vendor-ds': ['@ossrandom/design-system'], + 'vendor-ds-charts': ['@ossrandom/design-system/charts', 'd3-hierarchy'], }, }, }, diff --git a/src/main/java/io/github/randomcodespace/iq/config/security/BearerAuthFilter.java b/src/main/java/io/github/randomcodespace/iq/config/security/BearerAuthFilter.java index 508feee4..8e17106b 100644 --- a/src/main/java/io/github/randomcodespace/iq/config/security/BearerAuthFilter.java +++ b/src/main/java/io/github/randomcodespace/iq/config/security/BearerAuthFilter.java @@ -75,10 +75,21 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { if (!tokenResolver.isAuthRequired()) { - // mode=none with allow_unauthenticated=true. Pass through; the - // SecurityFilterChain's authorizeHttpRequests rules still apply, - // but anonymous principals will satisfy permitAll endpoints only. - chain.doFilter(request, response); + // mode=none with allow_unauthenticated=true. Set a fake + // authenticated principal so /api/**, /mcp/**, /actuator/** + // (all `.authenticated()` in SecurityConfig) actually pass. + // Without this, the bypass branch is inert because the chain + // still requires a Principal and `.anonymous()` is disabled. + var auth = new PreAuthenticatedAuthenticationToken( + "anonymous-mcp-client", "N/A", + List.of(new SimpleGrantedAuthority("ROLE_MCP_CLIENT"))); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + try { + chain.doFilter(request, response); + } finally { + SecurityContextHolder.clearContext(); + } return; } diff --git a/src/main/java/io/github/randomcodespace/iq/config/unified/ConfigDefaults.java b/src/main/java/io/github/randomcodespace/iq/config/unified/ConfigDefaults.java index 4ebdf158..beea1207 100644 --- a/src/main/java/io/github/randomcodespace/iq/config/unified/ConfigDefaults.java +++ b/src/main/java/io/github/randomcodespace/iq/config/unified/ConfigDefaults.java @@ -40,7 +40,12 @@ public static CodeIqUnifiedConfig builtIn() { true, "http", "/mcp", - new McpAuthConfig("none", "CODEIQ_MCP_TOKEN", null, null), + // Default: no auth out of the box. Operators opt into + // bearer for production by setting mcp.auth.mode=bearer + // (and providing a token via CODEIQ_MCP_TOKEN env var or + // mcp.auth.token). Setting mode=none + allow_unauthenticated=false + // explicitly remains a fail-fast safety valve — see TokenResolver. + new McpAuthConfig("none", "CODEIQ_MCP_TOKEN", null, Boolean.TRUE), new McpLimitsConfig(15_000, 500, 2_000_000L, 300, 10), new McpToolsConfig(List.of("*"), List.of()) ), diff --git a/src/main/java/io/github/randomcodespace/iq/config/unified/McpAuthConfig.java b/src/main/java/io/github/randomcodespace/iq/config/unified/McpAuthConfig.java index efeb7b41..de82aaa9 100644 --- a/src/main/java/io/github/randomcodespace/iq/config/unified/McpAuthConfig.java +++ b/src/main/java/io/github/randomcodespace/iq/config/unified/McpAuthConfig.java @@ -5,19 +5,24 @@ * *

{@code mode} selects the authentication scheme. Supported values: *

    - *
  • {@code none} — no auth. Permitted only outside the {@code serving} profile, - * OR with {@code allowUnauthenticated=true} (logs a startup warning). Production - * deploys (serving profile) with {@code mode=none} fail-fast at startup.
  • - *
  • {@code bearer} — opaque bearer token. Source priority: {@code CODEIQ_MCP_TOKEN} - * env var > {@code token} field below > startup failure.
  • + *
  • {@code none} — no auth. Default. Built-in defaults set + * {@code allowUnauthenticated=true} so the server starts unauthenticated + * out of the box. Operators who want hard-fail can override + * {@code mcp.auth.allow_unauthenticated: false} explicitly; the resolver + * will then refuse to start under the {@code serving} profile.
  • + *
  • {@code bearer} — opaque bearer token. Recommended for production. + * Source priority: {@code CODEIQ_MCP_TOKEN} env var > {@code token} field + * below > startup failure.
  • *
  • {@code mtls} — reserved; not yet wired (tracked under follow-up).
  • *
* *

{@code tokenEnv} is the env-var name to read the token from (defaults to * {@code CODEIQ_MCP_TOKEN} when null). {@code token} is a fallback in-config token — * not recommended for production (use the env var + a Kubernetes Secret); allowed for - * local development. {@code allowUnauthenticated} is the explicit escape hatch for - * {@code mode=none} in serving — must be set deliberately. + * local development. {@code allowUnauthenticated} is the explicit acknowledgement + * flag for {@code mode=none} in serving — defaulted to {@code true} via + * {@code ConfigDefaults} so a fresh install just works; override to {@code false} + * to make {@code mode=none} a fail-fast misconfiguration in serving. */ public record McpAuthConfig( String mode, diff --git a/src/main/java/io/github/randomcodespace/iq/detector/auth/CertificateAuthDetector.java b/src/main/java/io/github/randomcodespace/iq/detector/auth/CertificateAuthDetector.java index 5dd1616f..9195d94d 100644 --- a/src/main/java/io/github/randomcodespace/iq/detector/auth/CertificateAuthDetector.java +++ b/src/main/java/io/github/randomcodespace/iq/detector/auth/CertificateAuthDetector.java @@ -78,6 +78,20 @@ private record PatternDef(Pattern regex, String authType) {} private static final Pattern CERT_PATH_RE = Pattern.compile("['\"]([^'\"]*\\.(?:pem|crt|key|cert|pfx|p12))['\"]"); private static final Pattern TENANT_ID_RE = Pattern.compile("AZURE_TENANT_ID\\s*[=:]\\s*['\"]?([a-f0-9-]+)['\"]?"); + // Quick-reject pre-screen: a single regex pass over file content. If no + // distinctive literal substring from any pattern in ALL_PATTERNS is + // present, the file cannot match — short-circuit before the lines × patterns + // double loop. Profiling on polyglot-bench (29.7K files, 14 languages) showed + // this detector accounting for ~27% of detector CPU because it scanned every + // YAML/JSON in supported-languages even when no auth keyword was present. + private static final Pattern PRE_SCREEN = Pattern.compile( + "ssl_verify_client|requestCert|clientAuth|X509|" + + "AddCertificateForwarding|CertificateAuthenticationDefaults|" + + "\\.x509\\(|javax\\.net\\.ssl|SSLContext|tls\\.createServer|" + + "trustStore|AzureAd|AZURE_TENANT_ID|AZURE_CLIENT_ID|" + + "ClientCertificateCredential|AddMicrosoftIdentityWebApi|" + + "msal|MSAL|@azure/msal|\\.pem|\\.crt|\\.cert"); + @Override public String getName() { return "certificate_auth"; @@ -95,6 +109,9 @@ public DetectorResult detect(DetectorContext ctx) { if (text == null || text.isEmpty()) { return DetectorResult.empty(); } + if (!PRE_SCREEN.matcher(text).find()) { + return DetectorResult.empty(); + } String filePath = ctx.filePath(); String[] lines = text.split("\n", -1); diff --git a/src/main/java/io/github/randomcodespace/iq/detector/auth/LdapAuthDetector.java b/src/main/java/io/github/randomcodespace/iq/detector/auth/LdapAuthDetector.java index d46f38ae..2044cd67 100644 --- a/src/main/java/io/github/randomcodespace/iq/detector/auth/LdapAuthDetector.java +++ b/src/main/java/io/github/randomcodespace/iq/detector/auth/LdapAuthDetector.java @@ -59,6 +59,12 @@ public class LdapAuthDetector extends AbstractRegexDetector { "csharp", CSHARP_PATTERNS ); + // Quick-reject pre-screen — see CertificateAuthDetector for rationale. + // Most code files don't mention LDAP at all; one regex pass over content + // skips the lines × patterns double loop in those cases. + private static final Pattern PRE_SCREEN = Pattern.compile( + "(?i:ldap)|DirectoryServices|DirectoryEntry"); + @Override public String getName() { return "ldap_auth"; @@ -80,6 +86,9 @@ public DetectorResult detect(DetectorContext ctx) { if (text == null || text.isEmpty()) { return DetectorResult.empty(); } + if (!PRE_SCREEN.matcher(text).find()) { + return DetectorResult.empty(); + } List nodes = new ArrayList<>(); String[] lines = text.split("\n", -1); diff --git a/src/main/java/io/github/randomcodespace/iq/detector/auth/SessionHeaderAuthDetector.java b/src/main/java/io/github/randomcodespace/iq/detector/auth/SessionHeaderAuthDetector.java index 6ffe5718..1bbdbde2 100644 --- a/src/main/java/io/github/randomcodespace/iq/detector/auth/SessionHeaderAuthDetector.java +++ b/src/main/java/io/github/randomcodespace/iq/detector/auth/SessionHeaderAuthDetector.java @@ -78,6 +78,17 @@ private record PatternDef(Pattern regex, String authType, NodeKind nodeKind) {} PROP_CSRF, PROP_CSRF ); + // Quick-reject pre-screen — see CertificateAuthDetector for rationale. + // Single regex pass over file content; if no distinctive substring of any + // pattern in ALL_PATTERNS is present, the file cannot match — short-circuit + // before the lines × patterns double loop. Profiling on polyglot-bench + // showed this detector at ~23% of detector CPU; most TS/Python files have + // no auth keyword at all. + private static final Pattern PRE_SCREEN = Pattern.compile( + "express-session|cookie-session|@SessionAttributes|SessionMiddleware|" + + "HttpSession|SESSION_ENGINE|" + + "(?i:X-API|Authorization|api[_-]?key|csurf|csrf|getHeader)"); + @Override public String getName() { return "session_header_auth"; @@ -98,6 +109,9 @@ public DetectorResult detect(DetectorContext ctx) { if (text == null || text.isEmpty()) { return DetectorResult.empty(); } + if (!PRE_SCREEN.matcher(text).find()) { + return DetectorResult.empty(); + } List nodes = new ArrayList<>(); String[] lines = text.split("\n", -1); diff --git a/src/main/java/io/github/randomcodespace/iq/detector/jvm/java/ActiveMqDetector.java b/src/main/java/io/github/randomcodespace/iq/detector/jvm/java/ActiveMqDetector.java new file mode 100644 index 00000000..d27a4f79 --- /dev/null +++ b/src/main/java/io/github/randomcodespace/iq/detector/jvm/java/ActiveMqDetector.java @@ -0,0 +1,287 @@ +package io.github.randomcodespace.iq.detector.jvm.java; + +import io.github.randomcodespace.iq.detector.DetectorContext; +import io.github.randomcodespace.iq.detector.DetectorInfo; +import io.github.randomcodespace.iq.detector.DetectorResult; +import io.github.randomcodespace.iq.model.CodeEdge; +import io.github.randomcodespace.iq.model.CodeNode; +import io.github.randomcodespace.iq.model.EdgeKind; +import io.github.randomcodespace.iq.model.NodeKind; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Detects Apache ActiveMQ usage — both ActiveMQ Classic ({@code + * org.apache.activemq}) and ActiveMQ Artemis ({@code + * org.apache.activemq.artemis}). Both products ship a class literally + * named {@code ActiveMQConnectionFactory}, so the broker flavour is + * disambiguated by the surrounding import / FQN. + */ +@DetectorInfo( + name = "active_mq", + category = "messaging", + description = "Detects Apache ActiveMQ (Classic and Artemis) queue and topic connections", + languages = {"java"}, + nodeKinds = {NodeKind.MESSAGE_QUEUE, NodeKind.QUEUE, NodeKind.TOPIC}, + edgeKinds = {EdgeKind.CONNECTS_TO, EdgeKind.RECEIVES_FROM, EdgeKind.SENDS_TO}, + properties = {"broker", "queue", "topic", "broker_url", "factory_type"} +) +@Component +public class ActiveMqDetector extends AbstractJavaMessagingDetector { + private static final String PROP_BROKER = "broker"; + private static final String PROP_BROKER_URL = "broker_url"; + private static final String PROP_FACTORY_TYPE = "factory_type"; + private static final String PROP_QUEUE = "queue"; + private static final String PROP_TOPIC = "topic"; + + private static final String BROKER_AMQ_CLASSIC = "activemq"; + private static final String BROKER_AMQ_ARTEMIS = "activemq_artemis"; + + // Distinguishes Classic vs Artemis by import path or FQN. If neither + // shows up but the bare class name does, default to Classic (it's the + // older, more common product). + private static final Pattern ARTEMIS_IMPORT_RE = Pattern.compile( + "import\\s+org\\.apache\\.activemq\\.artemis\\.|org\\.apache\\.activemq\\.artemis\\."); + private static final Pattern CLASSIC_IMPORT_RE = Pattern.compile( + "import\\s+org\\.apache\\.activemq\\.(?!artemis\\.)"); + + // Connection-factory class references (both products share names). + private static final Pattern FACTORY_RE = Pattern.compile( + "\\b(ActiveMQConnectionFactory|ActiveMQQueueConnectionFactory|" + + "ActiveMQTopicConnectionFactory|ActiveMQJMSConnectionFactory|" + + "ActiveMQXAConnectionFactory|PooledConnectionFactory)\\b"); + + // Broker URLs. Two grammars to support: + // 1. scheme://host:port — tcp/ssl/nio/udp/vm/amqp/stomp/mqtt/ws/wss + // with optional ActiveMQ +nio / +ssl modifiers. + // 2. failover:(...) — ActiveMQ's failover transport, which uses + // the form `failover:(tcp://a,tcp://b)?opts` or + // `failover:tcp://a,tcp://b`. The scheme is followed by ":" and + // then either "(" or another scheme — NOT "://". + private static final Pattern BROKER_URL_RE = Pattern.compile( + "\"((?:(?:tcp|ssl|nio|udp|vm|amqp|stomp|mqtt|ws|wss)" + + "(?:\\+nio|\\+ssl)?://[^\"]+|failover:[^\"]+))\""); + + // Spring Boot config keys — application.properties / application.yml. + private static final Pattern SPRING_BROKER_URL_RE = Pattern.compile( + "(?m)^\\s*spring\\.(activemq|artemis)\\.broker[._-]url\\s*[=:]\\s*(\\S+)"); + + // Destination instantiation and per-API patterns. + private static final Pattern AMQ_QUEUE_RE = Pattern.compile( + "new\\s+ActiveMQQueue\\s*\\(\\s*\"([^\"]+)\""); + private static final Pattern AMQ_TOPIC_RE = Pattern.compile( + "new\\s+ActiveMQTopic\\s*\\(\\s*\"([^\"]+)\""); + private static final Pattern CREATE_QUEUE_RE = Pattern.compile( + "createQueue\\s*\\(\\s*\"([^\"]+)\""); + private static final Pattern CREATE_TOPIC_RE = Pattern.compile( + "createTopic\\s*\\(\\s*\"([^\"]+)\""); + + // Producer/consumer affordances. + private static final Pattern SEND_RE = Pattern.compile("\\bsend\\s*\\("); + private static final Pattern PUBLISH_RE = Pattern.compile("\\bpublish\\s*\\("); + private static final Pattern RECEIVE_RE = Pattern.compile("\\breceive\\s*\\("); + private static final Pattern ON_MESSAGE_RE = Pattern.compile("\\bonMessage\\s*\\("); + private static final Pattern PRODUCER_RE = Pattern.compile("\\bMessageProducer\\b"); + private static final Pattern CONSUMER_RE = Pattern.compile("\\bMessageConsumer\\b"); + + @Override + public String getName() { + return "active_mq"; + } + + @Override + public Set getSupportedLanguages() { + return Set.of("java"); + } + + @Override + public DetectorResult detect(DetectorContext ctx) { + String text = ctx.content(); + if (text == null || text.isEmpty()) return DetectorResult.empty(); + + // Quick-reject: must mention either an import/FQN of activemq or one + // of the distinctive class names. Avoids the lines×patterns loop on + // ~all non-messaging Java files. + boolean hasArtemis = ARTEMIS_IMPORT_RE.matcher(text).find(); + boolean hasClassic = !hasArtemis && CLASSIC_IMPORT_RE.matcher(text).find(); + boolean hasClassRef = text.contains("ActiveMQConnectionFactory") + || text.contains("ActiveMQQueue") + || text.contains("ActiveMQTopic") + || text.contains("ActiveMQJMSConnectionFactory"); + boolean hasSpringConfig = text.contains("spring.activemq.") + || text.contains("spring.artemis."); + if (!hasArtemis && !hasClassic && !hasClassRef && !hasSpringConfig) { + return DetectorResult.empty(); + } + + // Disambiguate broker flavour. Default to Classic when the bare class + // name appears with no import context (older codebases sometimes + // shadow imports via wildcards). + String broker = hasArtemis ? BROKER_AMQ_ARTEMIS : BROKER_AMQ_CLASSIC; + + List nodes = new ArrayList<>(); + List edges = new ArrayList<>(); + Set seenQueues = new LinkedHashSet<>(); + Set seenTopics = new LinkedHashSet<>(); + + // Spring Boot config — application.properties / application.yml. + // These files don't have a class context, so we emit a broker node + // alone; the application-level CONNECTS_TO edge is added by the + // class-context branch below if any. + Matcher springM = SPRING_BROKER_URL_RE.matcher(text); + while (springM.find()) { + String flavor = springM.group(1).toLowerCase(); + String detectedBroker = "artemis".equals(flavor) ? BROKER_AMQ_ARTEMIS : BROKER_AMQ_CLASSIC; + String url = springM.group(2).replaceAll("[\"']", ""); + String nodeId = "amq:server:" + detectedBroker + ":" + url; + CodeNode node = new CodeNode(); + node.setId(nodeId); + node.setKind(NodeKind.MESSAGE_QUEUE); + node.setLabel(detectedBroker + ":" + url); + node.getProperties().put(PROP_BROKER, detectedBroker); + node.getProperties().put(PROP_BROKER_URL, url); + nodes.add(node); + } + + // For class-context edges we need a class name. .properties / .yaml + // won't have one — that's fine, we already emitted the broker node + // above, just skip the rest. + String className = extractClassName(text); + if (className == null) { + return DetectorResult.of(nodes, edges); + } + + String classNodeId = ctx.filePath() + ":" + className; + String[] lines = text.split("\n", -1); + + boolean isProducer = SEND_RE.matcher(text).find() + || PUBLISH_RE.matcher(text).find() + || PRODUCER_RE.matcher(text).find(); + boolean isConsumer = RECEIVE_RE.matcher(text).find() + || ON_MESSAGE_RE.matcher(text).find() + || CONSUMER_RE.matcher(text).find(); + + // Connection factory + nearby broker URL. + for (int i = 0; i < lines.length; i++) { + Matcher m = FACTORY_RE.matcher(lines[i]); + if (!m.find()) continue; + String factoryType = m.group(1); + String url = null; + for (int j = Math.max(0, i - 1); j < Math.min(lines.length, i + 4); j++) { + Matcher urlM = BROKER_URL_RE.matcher(lines[j]); + if (urlM.find()) { + url = urlM.group(1); + break; + } + } + + String nodeId = "amq:server:" + broker + ":" + factoryType + + (url != null ? ":" + url : ""); + CodeNode node = new CodeNode(); + node.setId(nodeId); + node.setKind(NodeKind.MESSAGE_QUEUE); + node.setLabel(broker + ":" + factoryType); + node.getProperties().put(PROP_BROKER, broker); + node.getProperties().put(PROP_FACTORY_TYPE, factoryType); + if (url != null) node.getProperties().put(PROP_BROKER_URL, url); + nodes.add(node); + + CodeEdge edge = new CodeEdge(); + edge.setId(classNodeId + "->connects_to->" + nodeId); + edge.setKind(EdgeKind.CONNECTS_TO); + edge.setSourceId(classNodeId); + edge.setTarget(node); + edge.setProperties(Map.of(PROP_FACTORY_TYPE, factoryType)); + edges.add(edge); + } + + // Direct destination instantiation: new ActiveMQQueue("...") / + // new ActiveMQTopic("..."). + for (String line : lines) { + Matcher mq = AMQ_QUEUE_RE.matcher(line); + if (mq.find()) { + String name = mq.group(1); + String qid = ensureQueueNode(name, broker, seenQueues, nodes); + if (isProducer) addMessagingEdge(classNodeId, qid, EdgeKind.SENDS_TO, + className + " sends to " + name, Map.of(PROP_QUEUE, name), edges); + if (isConsumer) addMessagingEdge(classNodeId, qid, EdgeKind.RECEIVES_FROM, + className + " receives from " + name, Map.of(PROP_QUEUE, name), edges); + } + Matcher mt = AMQ_TOPIC_RE.matcher(line); + if (mt.find()) { + String name = mt.group(1); + String tid = ensureTopicNode(name, broker, seenTopics, nodes); + if (isProducer) addMessagingEdge(classNodeId, tid, EdgeKind.SENDS_TO, + className + " sends to " + name, Map.of(PROP_TOPIC, name), edges); + if (isConsumer) addMessagingEdge(classNodeId, tid, EdgeKind.RECEIVES_FROM, + className + " receives from " + name, Map.of(PROP_TOPIC, name), edges); + } + } + + // session.createQueue("...") / session.createTopic("...") — only + // attribute these to ActiveMQ when the file already mentions an AMQ + // factory or import to avoid double-counting against JmsDetector. + boolean isAmqContext = hasArtemis || hasClassic || hasClassRef; + if (isAmqContext) { + for (String line : lines) { + Matcher cq = CREATE_QUEUE_RE.matcher(line); + if (cq.find()) { + String name = cq.group(1); + String qid = ensureQueueNode(name, broker, seenQueues, nodes); + if (isProducer) addMessagingEdge(classNodeId, qid, EdgeKind.SENDS_TO, + className + " sends to " + name, Map.of(PROP_QUEUE, name), edges); + if (isConsumer) addMessagingEdge(classNodeId, qid, EdgeKind.RECEIVES_FROM, + className + " receives from " + name, Map.of(PROP_QUEUE, name), edges); + } + Matcher ct = CREATE_TOPIC_RE.matcher(line); + if (ct.find()) { + String name = ct.group(1); + String tid = ensureTopicNode(name, broker, seenTopics, nodes); + if (isProducer) addMessagingEdge(classNodeId, tid, EdgeKind.SENDS_TO, + className + " sends to " + name, Map.of(PROP_TOPIC, name), edges); + if (isConsumer) addMessagingEdge(classNodeId, tid, EdgeKind.RECEIVES_FROM, + className + " receives from " + name, Map.of(PROP_TOPIC, name), edges); + } + } + } + + return DetectorResult.of(nodes, edges); + } + + private String ensureQueueNode(String name, String broker, Set seen, List nodes) { + String id = "amq:queue:" + broker + ":" + name; + if (!seen.contains(name)) { + seen.add(name); + CodeNode node = new CodeNode(); + node.setId(id); + node.setKind(NodeKind.QUEUE); + node.setLabel(broker + ":queue:" + name); + node.getProperties().put(PROP_BROKER, broker); + node.getProperties().put(PROP_QUEUE, name); + nodes.add(node); + } + return id; + } + + private String ensureTopicNode(String name, String broker, Set seen, List nodes) { + String id = "amq:topic:" + broker + ":" + name; + if (!seen.contains(name)) { + seen.add(name); + CodeNode node = new CodeNode(); + node.setId(id); + node.setKind(NodeKind.TOPIC); + node.setLabel(broker + ":topic:" + name); + node.getProperties().put(PROP_BROKER, broker); + node.getProperties().put(PROP_TOPIC, name); + nodes.add(node); + } + return id; + } +} diff --git a/src/main/java/io/github/randomcodespace/iq/health/GraphHealthIndicator.java b/src/main/java/io/github/randomcodespace/iq/health/GraphHealthIndicator.java index 73f222f5..d26b8c19 100644 --- a/src/main/java/io/github/randomcodespace/iq/health/GraphHealthIndicator.java +++ b/src/main/java/io/github/randomcodespace/iq/health/GraphHealthIndicator.java @@ -3,9 +3,9 @@ import io.github.randomcodespace.iq.graph.GraphStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.health.contributor.Health; import org.springframework.boot.health.contributor.HealthIndicator; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import java.time.Duration; @@ -37,8 +37,16 @@ * name + a static reason — operators correlate via the WARN log line that * carries the full exception. */ +// Profile-gated rather than @ConditionalOnBean(GraphStore.class) — the +// latter is documented as fragile on user @Component classes (its +// evaluation depends on bean-definition ordering during scan, and the +// readiness group config in application.yml references this bean by +// name). @Profile("serving") activates earlier, in lockstep with +// GraphStore (also a serving-profile bean), so Spring's +// "Included health contributor 'graphHealthIndicator' in group +// 'readiness' does not exist" startup validation passes deterministically. @Component -@ConditionalOnBean(GraphStore.class) +@Profile("serving") public class GraphHealthIndicator implements HealthIndicator { private static final Logger log = LoggerFactory.getLogger(GraphHealthIndicator.class); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 65c22a1e..a2ef2586 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -31,6 +31,18 @@ management: web: exposure: include: health,info,metrics + endpoint: + health: + # Spring Boot 4 enabled strict group-membership validation by default, + # which fails startup if a `health.group.*.include` references a + # health-contributor bean that hasn't registered yet (or is profile- + # gated and not active in the current profile). The serving profile + # references `graphHealthIndicator` from a profile-gated bean, and the + # validation runs before all profile-conditional beans are visible — + # so the readiness include trips it. Disable the strict validation; + # missing health contributors are silently skipped at probe time, + # which is the desired behaviour. + validate-group-membership: false # Runtime codeiq.* values (cache dir, limits, pipeline tuning, MCP auth, etc.) # are sourced from codeiq.yml / env / CLI via CodeIqUnifiedConfig (see diff --git a/src/main/resources/static/assets/BricolageGrotesque-Variable-C5Lc8Qmc.woff2 b/src/main/resources/static/assets/BricolageGrotesque-Variable-C5Lc8Qmc.woff2 new file mode 100644 index 00000000..42c558b6 Binary files /dev/null and b/src/main/resources/static/assets/BricolageGrotesque-Variable-C5Lc8Qmc.woff2 differ diff --git a/src/main/resources/static/assets/GeistMono-Variable-BNLlm6Cd.woff2 b/src/main/resources/static/assets/GeistMono-Variable-BNLlm6Cd.woff2 new file mode 100644 index 00000000..dbdb8c2d Binary files /dev/null and b/src/main/resources/static/assets/GeistMono-Variable-BNLlm6Cd.woff2 differ diff --git a/src/main/resources/static/assets/PlusJakartaSans-Variable-eXO_dkmS.woff2 b/src/main/resources/static/assets/PlusJakartaSans-Variable-eXO_dkmS.woff2 new file mode 100644 index 00000000..a180dc40 Binary files /dev/null and b/src/main/resources/static/assets/PlusJakartaSans-Variable-eXO_dkmS.woff2 differ diff --git a/src/main/resources/static/assets/design-system-BIHI7g3E.js b/src/main/resources/static/assets/design-system-BIHI7g3E.js new file mode 100644 index 00000000..b480ffe6 --- /dev/null +++ b/src/main/resources/static/assets/design-system-BIHI7g3E.js @@ -0,0 +1 @@ +const e={};export{e as default}; diff --git a/src/main/resources/static/assets/design-system-Df6KNeSA.js b/src/main/resources/static/assets/design-system-Df6KNeSA.js new file mode 100644 index 00000000..b480ffe6 --- /dev/null +++ b/src/main/resources/static/assets/design-system-Df6KNeSA.js @@ -0,0 +1 @@ +const e={};export{e as default}; diff --git a/src/main/resources/static/assets/tesselator-D_j4OGEy.js b/src/main/resources/static/assets/tesselator-D_j4OGEy.js new file mode 100644 index 00000000..4ae28e49 --- /dev/null +++ b/src/main/resources/static/assets/tesselator-D_j4OGEy.js @@ -0,0 +1,1916 @@ +var el=Object.defineProperty;var tl=(e,t,r)=>t in e?el(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var f=(e,t,r)=>tl(e,typeof t!="symbol"?t+"":t,r);function zs(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Do=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),js=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);js&&parseFloat(js[1]);const Bt=globalThis,Ue=globalThis.process||{},rl=globalThis.navigator||{};function Fo(e){var i,s;if(typeof window<"u"&&((i=window.process)==null?void 0:i.type)==="renderer"||typeof process<"u"&&((s=process.versions)!=null&&s.electron))return!0;const r=typeof navigator<"u"&&navigator.userAgent;return!!(r&&r.indexOf("Electron")>=0)}function it(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||Fo()}function il(e){return it()?Fo()?"Electron":(rl.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const Uo="4.1.1";function ps(e,t){if(!e)throw new Error("Assertion failed")}function Lo(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return ps(Number.isFinite(t)&&t>=0),t}function sl(e){const{logLevel:t,message:r}=e;e.logLevel=Lo(t);const i=e.args?Array.from(e.args):[];for(;i.length&&i.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&i.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break}typeof e.message=="function"&&(e.message=e.message());const s=typeof e.message;return ps(s==="string"||s==="object"),Object.assign(e,{args:i},e.opts)}const We=()=>{};class nl{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...r){return this._log("warn",0,t,r,{once:!0})}error(t,...r){return this._log("error",0,t,r)}log(t,r,...i){return this._log("log",t,r,i)}info(t,r,...i){return this._log("info",t,r,i)}once(t,r,...i){return this._log("once",t,r,i,{once:!0})}_log(t,r,i,s,n={}){const o=sl({logLevel:r,message:i,args:this._buildArgs(r,i,s),opts:n});return this._createLogFunction(t,o,n)}_buildArgs(t,r,i){return[t,r,...i]}_createLogFunction(t,r,i){if(!this._shouldLog(r.logLevel))return We;const s=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return We;this._onceCache.add(s)}return this._emit(t,r)}_shouldLog(t){return this.getLevel()>=Lo(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}}function ol(e){try{const t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}class al{constructor(t,r,i="sessionStorage"){this.storage=ol(i),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){const r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){const r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}}function cl(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function ll(e,t=8){const r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var rr;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(rr||(rr={}));const fl=10;function Hs(e){return typeof e!="string"?e:(e=e.toUpperCase(),rr[e]||rr.WHITE)}function ul(e,t,r){return!it&&typeof e=="string"&&(t&&(e=`\x1B[${Hs(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${Hs(r)+fl}m${e}\x1B[49m`)),e}function hl(e,t=["constructor"]){const r=Object.getPrototypeOf(e),i=Object.getOwnPropertyNames(r),s=e;for(const n of i){const o=s[n];typeof o=="function"&&(t.find(a=>n===a)||(s[n]=o.bind(e)))}}function ct(){var t,r,i;let e;if(it()&&Bt.performance)e=(r=(t=Bt==null?void 0:Bt.performance)==null?void 0:t.now)==null?void 0:r.call(t);else if("hrtime"in Ue){const s=(i=Ue==null?void 0:Ue.hrtime)==null?void 0:i.call(Ue);e=s[0]*1e3+s[1]/1e6}else e=Date.now();return e}const Le={debug:it()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Qr={enabled:!0,level:0};class xt extends nl{constructor({id:t}={id:""}){super({level:0}),this.VERSION=Uo,this._startTs=ct(),this._deltaTs=ct(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new al(`__probe-${this.id}__`,{[this.id]:Qr}),this.timeStamp(`${this.id} started`),hl(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ct()-this._startTs).toPrecision(10))}getDelta(){return Number((ct()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,r){this._updateConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t,...r){return this._log("warn",0,t,r,{method:Le.warn,once:!0})}error(t,...r){return this._log("error",0,t,r,{method:Le.error})}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r,...i){return this._log("log",t,r,i,{method:Le.log,time:!0,once:!0})}log(t,r,...i){return this._log("log",t,r,i,{method:Le.debug})}info(t,r,...i){return this._log("info",t,r,i,{method:console.info})}once(t,r,...i){return this._log("once",t,r,i,{method:Le.debug||Le.info,once:!0})}table(t,r,i){return r?this._log("table",t,r,i&&[i]||[],{method:console.table||We,tag:gl(r)}):We}time(t,r){return this._log("time",t,r,[],{method:console.time?console.time:console.info})}timeEnd(t,r){return this._log("time",t,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,r){return this._log("time",t,r,[],{method:console.timeStamp||We})}group(t,r,i={collapsed:!1}){const s=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,r,[],{method:s})}groupCollapsed(t,r,i={}){return this.group(t,r,Object.assign({},i,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||We})}withGroup(t,r,i){this.group(t,r)();try{i()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,r){const i=r.method;ps(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=ct();const s=dl(this.id,r.message,r);return i.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Qr),this._storage.config[this.id]}_updateConfiguration(t){const r=this._storage.config[this.id]||{...Qr};this._storage.setConfiguration({[this.id]:{...r,...t}})}}xt.VERSION=Uo;function dl(e,t,r){if(typeof t=="string"){const i=r.time?ll(cl(r.total)):"";t=r.time?`${e}: ${i} ${t}`:`${e}: ${t}`,t=ul(t,r.color,r.background)}return t}function gl(e){for(const t in e)for(const r in e[t])return r||"untitled";return"empty"}const qr="4.4.1",pl=qr[0]>="0"&&qr[0]<="9"?`v${qr}`:"";function _l(){const e=new xt({id:"loaders.gl"});return globalThis.loaders||(globalThis.loaders={}),globalThis.loaders.log=e,globalThis.loaders.version=pl,globalThis.probe||(globalThis.probe={}),globalThis.probe.loaders=e,e}const ml=_l(),bl=e=>typeof e=="boolean",ae=e=>typeof e=="function",Be=e=>e!==null&&typeof e=="object",Vs=e=>Be(e)&&e.constructor==={}.constructor,ko=e=>typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer,_s=e=>Be(e)&&typeof e.byteLength=="number"&&typeof e.slice=="function",Tl=e=>!!e&&ae(e[Symbol.iterator]),Al=e=>!!e&&ae(e[Symbol.asyncIterator]),De=e=>typeof Response<"u"&&e instanceof Response||Be(e)&&ae(e.arrayBuffer)&&ae(e.text)&&ae(e.json),Fe=e=>typeof Blob<"u"&&e instanceof Blob,yl=e=>typeof ReadableStream<"u"&&e instanceof ReadableStream||Be(e)&&ae(e.tee)&&ae(e.cancel)&&ae(e.getReader),Rl=e=>Be(e)&&ae(e.read)&&ae(e.pipe)&&bl(e.readable),Wo=e=>yl(e)||Rl(e);function El(e,t){return $o(e||{},t)}function $o(e,t,r=0){if(r>3)return t;const i={...e};for(const[s,n]of Object.entries(t))n&&typeof n=="object"&&!Array.isArray(n)?i[s]=$o(i[s]||{},t[s],r+1):i[s]=t[s];return i}const Sl="latest";function Cl(){var e;return(e=globalThis._loadersgl_)!=null&&e.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}const vl=Cl();function Te(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const Ce=typeof process!="object"||String(process)!=="[object process]"||process.browser,Pl=typeof window<"u"&&typeof window.orientation<"u",Xs=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);Xs&&parseFloat(Xs[1]);class wl{constructor(t,r){f(this,"name");f(this,"workerThread");f(this,"isRunning",!0);f(this,"result");f(this,"_resolve",()=>{});f(this,"_reject",()=>{});this.name=t,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(t,r){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:r})}done(t){Te(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){Te(this.isRunning),this.isRunning=!1,this._reject(t)}}class Zr{terminate(){}}const Jr=new Map;function Ol(e){Te(e.source&&!e.url||!e.source&&e.url);let t=Jr.get(e.source||e.url);return t||(e.url&&(t=xl(e.url),Jr.set(e.url,t)),e.source&&(t=zo(e.source),Jr.set(e.source,t))),Te(t),t}function xl(e){if(!e.startsWith("http"))return e;const t=Ml(e);return zo(t)}function zo(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Ml(e){return`try { + importScripts('${e}'); +} catch (error) { + console.error(error); + throw error; +}`}function jo(e,t=!0,r){const i=r||new Set;if(e){if(Ys(e))i.add(e);else if(Ys(e.buffer))i.add(e.buffer);else if(!ArrayBuffer.isView(e)){if(t&&typeof e=="object")for(const s in e)jo(e[s],t,i)}}return r===void 0?Array.from(i):[]}function Ys(e){return e?e instanceof ArrayBuffer||typeof MessagePort<"u"&&e instanceof MessagePort||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas:!1}const Gr=()=>{};class Ni{constructor(t){f(this,"name");f(this,"source");f(this,"url");f(this,"terminated",!1);f(this,"worker");f(this,"onMessage");f(this,"onError");f(this,"_loadableURL","");const{name:r,source:i,url:s}=t;Te(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=Gr,this.onError=n=>console.log(n),this.worker=Ce?this._createBrowserWorker():this._createNodeWorker()}static isSupported(){return typeof Worker<"u"&&Ce||typeof Zr<"u"&&!Ce}destroy(){this.onMessage=Gr,this.onError=Gr,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(t,r){r=r||jo(t),this.worker.postMessage(t,r)}_getErrorFromErrorEvent(t){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,t.message&&(r+=`${t.message} in `),t.lineno&&(r+=`:${t.lineno}:${t.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=Ol({source:this.source,url:this.url});const t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},t.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},t.onmessageerror=r=>console.error(r),t}_createNodeWorker(){let t;if(this.url){const i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,s=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";t=new Zr(i,{eval:!1,type:s})}else if(this.source)t=new Zr(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",r=>{this.onMessage(r)}),t.on("error",r=>{this.onError(r)}),t.on("exit",r=>{}),t}}class Il{constructor(t){f(this,"name","unnamed");f(this,"source");f(this,"url");f(this,"maxConcurrency",1);f(this,"maxMobileConcurrency",1);f(this,"onDebug",()=>{});f(this,"reuseWorkers",!0);f(this,"props",{});f(this,"jobQueue",[]);f(this,"idleQueue",[]);f(this,"count",0);f(this,"isDestroyed",!1);this.source=t.source,this.url=t.url,this.setProps(t)}static isSupported(){return Ni.isSupported()}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,r=(s,n,o)=>s.done(o),i=(s,n)=>s.error(n)){const s=new Promise(n=>(this.jobQueue.push({name:t,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const t=this._getAvailableWorker();if(!t)return;const r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:t,backlog:this.jobQueue.length});const i=new wl(r.name,t);t.onMessage=s=>r.onMessage(i,s.type,s.payload),t.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!Ce||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},ge=class ge{constructor(t){f(this,"props");f(this,"workerPools",new Map);this.props={...Nl},this.setProps(t),this.workerPools=new Map}static isSupported(){return Ni.isSupported()}static getWorkerFarm(t={}){return ge._workerFarm=ge._workerFarm||new ge({}),ge._workerFarm.setProps(t),ge._workerFarm}destroy(){for(const t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(const r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(t){const{name:r,source:i,url:s}=t;let n=this.workerPools.get(r);return n||(n=new Il({name:r,source:i,url:s}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};f(ge,"_workerFarm");let ir=ge;function Bl(e,t={}){var o;const r=t[e.id]||{},i=Ce?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let s=r.workerUrl;if(!s&&e.id==="compression"&&(s=t.workerUrl),(t._workerType||((o=t==null?void 0:t.core)==null?void 0:o._workerType))==="test"&&(Ce?s=`modules/${e.module}/dist/${i}`:s=`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!s){let a=e.version;a==="latest"&&(a=Sl);const c=a?`@${a}`:"";s=`https://unpkg.com/@loaders.gl/${e.module}${c}/dist/${i}`}return Te(s),s}function Dl(e,t=vl){Te(e,"no worker provided");const r=e.version;return!(!t||!r)}function Fl(e,t){var s,n;if(!ir.isSupported())return!1;const r=(t==null?void 0:t._nodeWorkers)??((s=t==null?void 0:t.core)==null?void 0:s._nodeWorkers);if(!Ce&&!r)return!1;const i=(t==null?void 0:t.worker)??((n=t==null?void 0:t.core)==null?void 0:n.worker);return!!(e.worker&&i)}async function Ul(e,t,r,i,s){const n=e.id,o=Bl(e,r),c=ir.getWorkerFarm(r==null?void 0:r.core).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));const l=await c.startJob("process-on-worker",Ll.bind(null,s));return l.postMessage("process",{input:t,options:r,context:i}),await(await l.result).result}async function Ll(e,t,r,i){switch(r){case"done":t.done(i);break;case"error":t.error(new Error(i.error));break;case"process":const{id:s,input:n,options:o}=i;try{const a=await e(n,o);t.postMessage("done",{id:s,result:a})}catch(a){const c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function kl(e,t,r){if(r=r||e.byteLength,e.byteLengthn instanceof ArrayBuffer?new Uint8Array(n):n),r=t.reduce((n,o)=>n+o.byteLength,0),i=new Uint8Array(r);let s=0;for(const n of t)i.set(n,s),s+=n.byteLength;return i.buffer}async function zl(e){const t=[];for await(const r of e)t.push(jl(r));return Wl(...t)}function jl(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const{buffer:t,byteOffset:r,byteLength:i}=e;return Ks(t,r,i)}return Ks(e)}function Ks(e,t=0,r=e.byteLength-t){const i=new Uint8Array(e,t,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function Qs(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){const t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}class qs{constructor(t,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Qs(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Qs()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Hl{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(const t of Object.values(this.stats))t.reset();return this}forEach(t){for(const r of Object.values(this.stats))t(r)}getTable(){const t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){const{name:r,type:i}=t;let s=this.stats[r];return s||(t instanceof qs?s=t:s=new qs(r,i),this.stats[r]=s),s}}let Vl="";const Zs={};function Xl(e){for(const t in Zs)if(e.startsWith(t)){const r=Zs[t];e=e.replace(t,r)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Vl}${e}`),e}function Ho(e){return e&&typeof e=="object"&&e.isBuffer}function ms(e){if(Ho(e))return e;if(e instanceof ArrayBuffer)return e;if(ko(e))return Bi(e);if(ArrayBuffer.isView(e)){const t=e.buffer;return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof e=="string"){const t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e=="object"&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Vo(e){if(e instanceof ArrayBuffer)return e;if(ko(e))return Bi(e);const{buffer:t,byteOffset:r,byteLength:i}=e;return t instanceof ArrayBuffer&&r===0&&i===t.byteLength?t:Bi(t,r,i)}function Bi(e,t=0,r=e.byteLength-t){const i=new Uint8Array(e,t,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function Yl(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}function Xo(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function Yo(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}class Kl extends Error{constructor(r,i){super(r);f(this,"reason");f(this,"url");f(this,"response");this.reason=i.reason,this.url=i.url,this.response=i.response}}const Ql=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ql=/^([-\w.]+\/[-\w.+]+)/;function Js(e,t){return e.toLowerCase()===t.toLowerCase()}function Zl(e){const t=ql.exec(e);return t?t[1]:e}function Gs(e){const t=Ql.exec(e);return t?t[1]:""}const Ko=/\?.*/;function Jl(e){const t=e.match(Ko);return t&&t[0]}function Wr(e){return e.replace(Ko,"")}function Gl(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function $r(e){return De(e)?e.url:Fe(e)?("name"in e?e.name:"")||"":typeof e=="string"?e:""}function zr(e){if(De(e)){const t=e.headers.get("content-type")||"",r=Wr(e.url);return Zl(t)||Gs(r)}return Fe(e)?e.type||"":typeof e=="string"?Gs(e):""}function ef(e){return De(e)?e.headers["content-length"]||-1:Fe(e)?e.size:typeof e=="string"?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function Qo(e){if(De(e))return e;const t={},r=ef(e);r>=0&&(t["content-length"]=String(r));const i=$r(e),s=zr(e);s&&(t["content-type"]=s);const n=await sf(e);n&&(t["x-first-bytes"]=n),typeof e=="string"&&(e=new TextEncoder().encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:i}),o}async function tf(e){if(!e.ok)throw await rf(e)}async function rf(e){const t=Gl(e.url);let r=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;r=r.length>100?`${r.slice(0,100)}...`:r;const i={reason:e.statusText,url:e.url,response:e};try{const s=e.headers.get("Content-Type");i.reason=!e.bodyUsed&&(s!=null&&s.includes("application/json"))?await e.json():await e.text()}catch{}return new Kl(r,i)}async function sf(e){if(typeof e=="string")return`data:,${e.slice(0,5)}`;if(e instanceof Blob){const r=e.slice(0,5);return await new Promise(i=>{const s=new FileReader;s.onload=n=>{var o;return i((o=n==null?void 0:n.target)==null?void 0:o.result)},s.readAsDataURL(r)})}if(e instanceof ArrayBuffer){const r=e.slice(0,5);return`data:base64,${nf(r)}`}return null}function nf(e){let t="";const r=new Uint8Array(e);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}class ff{constructor(){f(this,"console");this.console=console}log(...t){return this.console.log.bind(this.console,...t)}info(...t){return this.console.info.bind(this.console,...t)}warn(...t){return this.console.warn.bind(this.console,...t)}error(...t){return this.console.error.bind(this.console,...t)}}const Di={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new ff,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Do,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},uf={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"},bs=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function qo(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function Zo(){const e=qo();return e.globalOptions=e.globalOptions||{...Di,core:{...Di.core}},xe(e.globalOptions)}function hf(e,t,r,i){return r=r||[],r=Array.isArray(r)?r:[r],df(e,r),xe(pf(t,e,i))}function xe(e){const t=mf(e);Jo(t);for(const r of bs)t.core&&t.core[r]!==void 0&&delete t[r];return t.core&&t.core._workerType!==void 0&&delete t._worker,t}function df(e,t){tn(e,null,Di,uf,t);for(const r of t){const i=e&&e[r.id]||{},s=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};tn(i,r.id,s,n,t)}}function tn(e,t,r,i,s){const n=t||"Top level",o=t?`${t}.`:"";for(const a in e){const c=!t&&Be(e[a]),l=a==="baseUri"&&!t,u=a==="workerUrl"&&t;if(!(a in r)&&!l&&!u){if(a in i)Dt.level>0&&Dt.warn(`${n} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&Dt.level>0){const h=gf(a,s);Dt.warn(`${n} loader option '${o}${a}' not recognized. ${h}`)()}}}}function gf(e,t){const r=e.toLowerCase();let i="";for(const s of t)for(const n in s.options){if(e===n)return`Did you mean '${s.id}.${n}'?`;const o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(i=i||`Did you mean '${s.id}.${n}'?`)}return i}function pf(e,t,r){var o;const i=e.options||{},s={...i};i.core&&(s.core={...i.core}),Jo(s),((o=s.core)==null?void 0:o.log)===null&&(s.core={...s.core,log:new lf}),rn(s,xe(Zo()));const n=xe(t);return rn(s,n),_f(s,r),bf(s),s}function rn(e,t){for(const r in t)if(r in t){const i=t[r];Vs(i)&&Vs(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function _f(e,t){var i;if(!t)return;((i=e.core)==null?void 0:i.baseUrl)!==void 0||(e.core||(e.core={}),e.core.baseUrl=Yo(Wr(t)))}function mf(e){const t={...e};return e.core&&(t.core={...e.core}),t}function Jo(e){e.baseUri!==void 0&&(e.core||(e.core={}),e.core.baseUrl===void 0&&(e.core.baseUrl=e.baseUri));for(const r of bs)if(e[r]!==void 0){const s=e.core=e.core||{};s[r]===void 0&&(s[r]=e[r])}const t=e._worker;t!==void 0&&(e.core||(e.core={}),e.core._workerType===void 0&&(e.core._workerType=t))}function bf(e){const t=e.core;if(t)for(const r of bs)t[r]!==void 0&&(e[r]=t[r])}function Ts(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e==null?void 0:e.extensions)):!1}function As(e){zs(e,"null loader"),zs(Ts(e),"invalid loader");let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e!=null&&e.parseTextSync||e!=null&&e.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const Go=()=>{const e=qo();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function RA(e){const t=Go();e=Array.isArray(e)?e:[e];for(const r of e){const i=As(r);t.find(s=>i===s)||t.unshift(i)}}function Tf(){return Go()}const Af=/\.([^.]+)$/;async function yf(e,t=[],r,i){if(!ea(e))return null;const s=xe(r||{});if(s.core||(s.core={}),e instanceof Response&&sn(e)){const o=await e.clone().text(),a=Ft(o,t,{...s,core:{...s.core,nothrow:!0}},i);if(a)return a}let n=Ft(e,t,{...s,core:{...s.core,nothrow:!0}},i);if(n)return n;if(Fe(e)&&(e=await e.slice(0,10).arrayBuffer(),n=Ft(e,t,s,i)),!n&&e instanceof Response&&sn(e)){const o=await e.clone().text();n=Ft(o,t,s,i)}if(!n&&!s.core.nothrow)throw new Error(ta(e));return n}function sn(e){const t=zr(e);return!!(t&&(t.startsWith("text/")||t==="application/json"||t.endsWith("+json")))}function Ft(e,t=[],r,i){if(!ea(e))return null;const s=xe(r||{});if(s.core||(s.core={}),t&&!Array.isArray(t))return As(t);let n=[];t&&(n=n.concat(t)),s.core.ignoreRegisteredLoaders||n.push(...Tf()),Ef(n);const o=Rf(e,n,s,i);if(!o&&!s.core.nothrow)throw new Error(ta(e));return o}function Rf(e,t,r,i){var l,u,h,d,g;const s=$r(e),n=zr(e),o=Wr(s)||(i==null?void 0:i.url);let a=null,c="";return(l=r==null?void 0:r.core)!=null&&l.mimeType&&(a=ei(t,(u=r==null?void 0:r.core)==null?void 0:u.mimeType),c=`match forced by supplied MIME type ${(h=r==null?void 0:r.core)==null?void 0:h.mimeType}`),a=a||Sf(t,o),c=c||(a?`matched url ${o}`:""),a=a||ei(t,n),c=c||(a?`matched MIME type ${n}`:""),a=a||vf(t,e),c=c||(a?`matched initial data ${ra(e)}`:""),(d=r==null?void 0:r.core)!=null&&d.fallbackMimeType&&(a=a||ei(t,(g=r==null?void 0:r.core)==null?void 0:g.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&ml.log(1,`selectLoader selected ${a==null?void 0:a.name}: ${c}.`),a}function ea(e){return!(e instanceof Response&&e.status===204)}function ta(e){const t=$r(e),r=zr(e);let i="No valid loader found (";i+=t?`${Xo(t)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;const s=e?ra(e):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function Ef(e){for(const t of e)As(t)}function Sf(e,t){const r=t&&Af.exec(t),i=r&&r[1];return i?Cf(e,i):null}function Cf(e,t){t=t.toLowerCase();for(const r of e)for(const i of r.extensions)if(i.toLowerCase()===t)return r;return null}function ei(e,t){var r;for(const i of e)if((r=i.mimeTypes)!=null&&r.some(s=>Js(t,s))||Js(t,`application/x.${i.id}`))return i;return null}function vf(e,t){if(!t)return null;for(const r of e)if(typeof t=="string"){if(Pf(t,r))return r}else if(ArrayBuffer.isView(t)){if(nn(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer&&nn(t,0,r))return r;return null}function Pf(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(i=>e.startsWith(i))}function nn(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>wf(e,t,r,s))}function wf(e,t,r,i){if(_s(i))return kl(i,e,i.byteLength);switch(typeof i){case"function":return i(Vo(e));case"string":const s=Fi(e,t,i.length);return i===s;default:return!1}}function ra(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?Fi(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?Fi(e,0,t):""}function Fi(e,t,r){if(e.byteLengthen(o,s):t!=null&&t.fetch?t==null?void 0:t.fetch:en}function Wf(e,t,r){if(r)return r;const i={fetch:sa(t,e),...e};if(i.url){const s=Wr(i.url);i.baseUrl=s,i.queryString=Jl(i.url),i.filename=Xo(s),i.baseUrl=Yo(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function $f(e,t){if(e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){const i=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function sr(e,t,r,i){t&&!Array.isArray(t)&&!Ts(t)&&(i=void 0,r=t,t=void 0),e=await e,r=r||{};const s=$r(e),o=$f(t,i),a=await yf(e,o,r);if(!a)return null;const c=hf(r,a,o,s);return i=Wf({url:s,_parse:sr,loaders:o},c,i||null),await zf(a,e,c,i)}async function zf(e,t,r,i){if(Dl(e),r=El(e.options,r),De(t)){const{ok:n,redirected:o,status:a,statusText:c,type:l,url:u}=t,h=Object.fromEntries(t.headers.entries());i.response={headers:h,ok:n,redirected:o,status:a,statusText:c,type:l,url:u}}t=await kf(t,e,r);const s=e;if(s.parseTextSync&&typeof t=="string")return s.parseTextSync(t,r,i);if(Fl(e,r))return await Ul(e,t,r,i,sr);if(s.parseText&&typeof t=="string")return await s.parseText(t,r,i);if(s.parse)return await s.parse(t,r,i);throw Te(!s.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}function jf(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Hf(e){return Array.isArray(e)?e.length===0||typeof e[0]=="number":!1}function Vf(e){return jf(e)||Hf(e)}async function an(e,t,r,i){var c;let s,n;!Array.isArray(t)&&!Ts(t)?(s=[],n=t):(s=t,n=r);const o=sa(n);let a=e;return typeof e=="string"&&(a=await o(e)),Fe(e)&&(a=await o(e)),typeof e=="string"&&((c=xe(n||{}).core)!=null&&c.baseUrl||(n={...n,core:{...n==null?void 0:n.core,baseUrl:e}})),Array.isArray(s)?await sr(a,s,n):await sr(a,s,n)}const G=new xt({id:"deck"});let Ui={};function EA(e){Ui=e}function X(e,t,r,i){G.level>0&&Ui[e]&&Ui[e].call(null,t,r,i)}function Mt(e,t){var r;if(!e){const i=new Error(t||"shadertools: assertion failed.");throw(r=Error.captureStackTrace)==null||r.call(Error,i,Mt),i}}const ti={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function Xf(e){const t={};for(const[r,i]of Object.entries(e))t[r]=Yf(i);return t}function Yf(e){let t=cn(e);if(t!=="object")return{value:e,...ti[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...ti[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=cn(e.value),{...e,...ti[t],type:t}):{type:"object",value:null};throw new Error("props")}function cn(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const Kf=`#ifdef MODULE_LOGDEPTH + logdepth_adjustPosition(gl_Position); +#endif +`,Qf=`#ifdef MODULE_MATERIAL + fragColor = material_filterColor(fragColor); +#endif + +#ifdef MODULE_LIGHTING + fragColor = lighting_filterColor(fragColor); +#endif + +#ifdef MODULE_FOG + fragColor = fog_filterColor(fragColor); +#endif + +#ifdef MODULE_PICKING + fragColor = picking_filterHighlightColor(fragColor); + fragColor = picking_filterPickingColor(fragColor); +#endif + +#ifdef MODULE_LOGDEPTH + logdepth_setFragDepth(); +#endif +`,qf={vertex:Kf,fragment:Qf},ln=/void\s+main\s*\([^)]*\)\s*\{\n?/,fn=/}\n?[^{}]*$/,ri=[],Jt="__LUMA_INJECT_DECLARATIONS__";function Zf(e){const t={vertex:{},fragment:{}};for(const r in e){let i=e[r];const s=Jf(r);typeof i=="string"&&(i={order:0,injection:i}),t[s][r]=i}return t}function Jf(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function nr(e,t,r,i=!1){const s=t==="vertex";for(const n in r){const o=r[n];o.sort((c,l)=>c.order-l.order),ri.length=o.length;for(let c=0,l=o.length;cc+a));break;case"vs:#main-end":s&&(e=e.replace(fn,c=>a+c));break;case"fs:#decl":s||(e=e.replace(Jt,a));break;case"fs:#main-start":s||(e=e.replace(ln,c=>c+a));break;case"fs:#main-end":s||(e=e.replace(fn,c=>a+c));break;default:e=e.replace(n,c=>c+a)}}return e=e.replace(Jt,""),i&&(e=e.replace(/\}\s*$/,n=>n+qf[t])),e}function or(e){e.map(t=>Gf(t))}function Gf(e){if(e.instance)return;or(e.dependencies||[]);const{propTypes:t={},deprecations:r=[],inject:i={}}=e,s={normalizedInjections:Zf(i),parsedDeprecations:eu(r)};t&&(s.propValidators=Xf(t)),e.instance=s;let n={};t&&(n=Object.entries(t).reduce((o,[a,c])=>{const l=c==null?void 0:c.value;return l&&(o[a]=l),o},{})),e.defaultUniforms={...e.defaultUniforms,...n}}function na(e,t,r){var i;(i=e.deprecations)==null||i.forEach(s=>{var n;(n=s.regex)!=null&&n.test(t)&&(s.deprecated?r.deprecated(s.old,s.new)():r.removed(s.old,s.new)())})}function eu(e){return e.forEach(t=>{switch(t.type){case"function":t.regex=new RegExp(`\\b${t.old}\\(`);break;default:t.regex=new RegExp(`${t.type} ${t.old};`)}}),e}function ys(e){or(e);const t={},r={};oa({modules:e,level:0,moduleMap:t,moduleDepth:r});const i=Object.keys(r).sort((s,n)=>r[n]-r[s]).map(s=>t[s]);return or(i),i}function oa(e){const{modules:t,level:r,moduleMap:i,moduleDepth:s}=e;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(const n of t)i[n.name]=n,(s[n.name]===void 0||s[n.name]]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,ru=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function aa(e){return`${e.name}Uniforms`}function iu(e,t){const r=t==="wgsl"?e.source:t==="vertex"?e.vs:e.fs;if(!r)return null;const i=aa(e);return au(r,t==="wgsl"?"wgsl":"glsl",i)}function su(e,t){const r=Object.keys(e.uniformTypes||{});if(!r.length)return null;const i=iu(e,t);return i?{moduleName:e.name,uniformBlockName:aa(e),stage:t,expectedUniformNames:r,actualUniformNames:i,matches:fu(r,i)}:null}function nu(e,t,r={}){var n,o;const i=su(e,t);if(!i||i.matches)return i;const s=uu(i);return(o=(n=r.log)==null?void 0:n.error)==null||o.call(n,s,i)(),r.throwOnError!==!1&&Mt(!1,s),i}function ca(e){var i;const t=[],r=hu(e);for(const s of r.matchAll(ru)){const n=((i=s[1])==null?void 0:i.trim())||null;t.push({blockName:s[2],body:s[3],instanceName:s[4]||null,layoutQualifier:n,hasLayoutQualifier:!!n,isStd140:!!(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return t}function ou(e,t,r,i){var o;const s=ca(e).filter(a=>!a.isStd140),n=new Set;for(const a of s){if(n.has(a.blockName))continue;n.add(a.blockName);const c="",l=a.hasLayoutQualifier?`declares ${du(a.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",u=`${c}${t} shader uniform block ${a.blockName} ${l}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;(o=r==null?void 0:r.warn)==null||o.call(r,u,a)()}return s}function au(e,t,r){const i=t==="wgsl"?cu(e,r):lu(e,r);if(!i)return null;const s=[];for(const n of i.split(` +`)){const o=n.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;const a=t==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(tu);a&&s.push(a[1])}return s}function cu(e,t){const r=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!r)return null;const i=e.indexOf("{",r.index);if(i<0)return null;let s=0;for(let n=i;ni.blockName===t);return(r==null?void 0:r.body)||null}function fu(e,t){if(e.length!==t.length)return!1;for(let r=0;r!r.includes(a)),s=r.filter(a=>!t.includes(a)),n=[`Expected ${t.length} fields, found ${r.length}.`],o=gu(t,r);return o&&n.push(o),i.length&&n.push(`Missing from shader block (${i.length}): ${un(i)}.`),s.length&&n.push(`Unexpected in shader block (${s.length}): ${un(s)}.`),t.length<=12&&r.length<=12&&(i.length||s.length)&&(n.push(`Expected: ${t.join(", ")}.`),n.push(`Actual: ${r.join(", ")}.`)),`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${n.join(" ")}`}function hu(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function du(e){return e.replace(/\s+/g," ").trim()}function gu(e,t){const r=Math.min(e.length,t.length);for(let i=0;it.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}function un(e,t=8){if(e.length<=t)return e.join(", ");const r=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${r} more)`}function pu(e){switch(e==null?void 0:e.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +// Apple optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"nvidia":return`#define NVIDIA_GPU +// Nvidia optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +`;case"intel":return`#define INTEL_GPU +// Intel optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Intel's built-in 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"amd":return`#define AMD_GPU +`;default:return`#define DEFAULT_GPU +// Prevent driver from optimizing away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Headless Chrome's software shader 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// If the GPU doesn't have full 32 bits precision, will causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`}}function _u(e,t){var i;if(Number(((i=e.match(/^#version[ \t]+(\d+)/m))==null?void 0:i[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return e=hn(e,mu),e;case"fragment":return e=hn(e,bu),e;default:throw new Error(t)}}const la=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],mu=[...la,[Li("attribute"),"in $1"],[Li("varying"),"out $1"]],bu=[...la,[Li("varying"),"in $1"]];function hn(e,t){for(const[r,i]of t)e=e.replace(r,i);return e}function Li(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function fa(e,t){let r="";for(const i in e){const s=e[i];if(r+=`void ${s.signature} { +`,s.header&&(r+=` ${s.header}`),t[i]){const n=t[i];n.sort((o,a)=>o.order-a.order);for(const o of n)r+=` ${o.injection} +`}s.footer&&(r+=` ${s.footer}`),r+=`} +`}return r}function ua(e){const t={vertex:{},fragment:{}};for(const r of e){let i,s;typeof r!="string"?(i=r,s=i.hook):(i={},s=r),s=s.trim();const[n,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(i,{signature:o});switch(n){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(n)}}return t}function Tu(e,t){return{name:Au(e,t),language:"glsl",version:yu(e)}}function Au(e,t="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function yu(e){let t=100;const r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){const i=parseInt(r[1],10);Number.isFinite(i)&&(t=i)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}const Q="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",q="\\s*",St=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${q}@group\\(\\s*(\\d+)\\s*\\)${q}${Q}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${q}@binding\\(\\s*(auto|\\d+)\\s*\\)${q}${Q}`,"g")],ki=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${q}@group\\(\\s*(\\d+)\\s*\\)${q}${Q}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${q}@binding\\(\\s*(auto|\\d+)\\s*\\)${q}${Q}`,"g")],Ru=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${q}@group\\(\\s*(\\d+)\\s*\\)${q}${Q}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${q}@binding\\(\\s*(\\d+)\\s*\\)${q}${Q}`,"g")],Eu=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Q}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${Q}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Q}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Q}`,"g")];function Rs(e){const t=e.split("");let r=0,i=0,s=!1,n=!1,o=!1;for(;r0){if(a==="/"&&c==="*"){t[r]=" ",t[r+1]=" ",i++,r+=2;continue}if(a==="*"&&c==="/"){t[r]=" ",t[r+1]=" ",i--,r+=2;continue}a!==` +`&&a!=="\r"&&(t[r]=" "),r++;continue}if(a==='"'){n=!0,r++;continue}if(a==="/"&&c==="/"){t[r]=" ",t[r+1]=" ",s=!0,r+=2;continue}if(a==="/"&&c==="*"){t[r]=" ",t[r+1]=" ",i=1,r+=2;continue}r++}return t.join("")}function st(e,t){var s;const r=Rs(e),i=[];for(const n of t){n.lastIndex=0;let o;for(o=n.exec(r);o;){const a=n===t[0],c=o.index,l=o[0].length;i.push({match:e.slice(c,c+l),index:c,length:l,bindingToken:o[a?1:2],groupToken:o[a?2:1],accessDeclaration:(s=o[3])==null?void 0:s.trim(),name:o[4]}),o=n.exec(r)}}return i.sort((n,o)=>n.index-o.index)}function ha(e,t,r){const i=st(e,t);if(!i.length)return e;let s="",n=0;for(const o of i)s+=e.slice(n,o.index),s+=r(o),n=o.index+o.length;return s+=e.slice(n),s}function da(e){return/@binding\(\s*auto\s*\)/.test(Rs(e))}function Su(e,t){return st(e,t===St||t===ki?Eu:t).find(i=>i.bindingToken==="auto")}const dn=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Q}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${Q}\\s*:\\s*([^;]+);`,"g")];function ga(e,t=[]){var n;const r=Rs(e),i=new Map;for(const o of t)i.set(gn(o.name,o.group,o.location),o.moduleName);const s=[];for(const o of dn){o.lastIndex=0;let a;for(a=o.exec(r);a;){const c=o===dn[0],l=Number(a[c?1:2]),u=Number(a[c?2:1]),h=(n=a[3])==null?void 0:n.trim(),d=a[4],g=a[5].trim(),p=i.get(gn(d,u,l));s.push(Cu({name:d,group:u,binding:l,owner:p?"module":"application",moduleName:p,accessDeclaration:h,resourceType:g})),a=o.exec(r)}}return s.sort((o,a)=>o.group!==a.group?o.group-a.group:o.binding!==a.binding?o.binding-a.binding:o.name.localeCompare(a.name))}function Cu(e){const t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){const r=e.accessDeclaration.split(",").map(i=>i.trim());if(r[0]==="uniform")return{...t,kind:"uniform",access:"uniform"};if(r[0]==="storage"){const i=r[1]||"read_write";return{...t,kind:i==="read"?"read-only-storage":"storage",access:i}}}return e.resourceType==="sampler"||e.resourceType==="sampler_comparison"?{...t,kind:"sampler",samplerKind:e.resourceType==="sampler_comparison"?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:Pu(e.resourceType),viewDimension:pn(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:pn(e.resourceType),sampleType:vu(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t}function gn(e,t,r){return`${t}:${r}:${e}`}function pn(e){if(e.includes("cube_array"))return"cube-array";if(e.includes("2d_array"))return"2d-array";if(e.includes("cube"))return"cube";if(e.includes("3d"))return"3d";if(e.includes("2d"))return"2d";if(e.includes("1d"))return"1d"}function vu(e){if(e.startsWith("texture_depth_"))return"depth";if(e.includes(""))return"sint";if(e.includes(""))return"uint";if(e.includes(""))return"float"}function Pu(e){const t=/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e);return t==null?void 0:t[1]}const Es=` + +${Jt} +`,Ct=100,wu=`precision highp float; +`;function Ou(e){const t=ys(e.modules||[]),{source:r,bindingAssignments:i}=Mu(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:r,getUniforms:pa(t),bindingAssignments:i,bindingTable:ga(r,i)}}function xu(e){const{vs:t,fs:r}=e,i=ys(e.modules||[]);return{vs:_n(e.platformInfo,{...e,source:t,stage:"vertex",modules:i}),fs:_n(e.platformInfo,{...e,source:r,stage:"fragment",modules:i}),getUniforms:pa(i)}}function Mu(e,t){var T;const{source:r,stage:i,modules:s,hookFunctions:n=[],inject:o={},log:a}=t;Mt(typeof r=="string","shader source must be a string");const c=r;let l="";const u=ua(n),h={},d={},g={};for(const y in o){const E=typeof o[y]=="string"?{injection:o[y],order:0}:o[y],S=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(S){const C=S[2],v=S[3];C?v==="decl"?d[y]=[E]:g[y]=[E]:h[y]=[E]}else g[y]=[E]}const p=s,_=Bu(c),m=Nu(_.source),b=Lu(p,t._bindingRegistry,m),R=[];for(const y of p){a&&na(y,c,a);const E=Du(_a(y,"wgsl",a),y,{usedBindingsByGroup:m,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:b});R.push(...E.bindingAssignments);const S=E.source;l+=S;const C=((T=y.injections)==null?void 0:T[i])||{};for(const v in C){const w=/^(v|f)s:#([\w-]+)$/.exec(v);if(w){const B=w[2]==="decl"?d:g;B[v]=B[v]||[],B[v].push(C[v])}else h[v]=h[v]||[],h[v].push(C[v])}}return l+=Es,l=nr(l,i,d),l+=fa(u[i],h),l+=ju(R),l+=_.source,l=nr(l,i,g),zu(l),{source:l,bindingAssignments:R}}function _n(e,t){var S;const{source:r,stage:i,language:s="glsl",modules:n,defines:o={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:u}=t;Mt(typeof r=="string","shader source must be a string");const h=s==="glsl"?Tu(r).version:-1,d=e.shaderLanguageVersion,g=h===100?"#version 100":"#version 300 es",_=r.split(` +`).slice(1).join(` +`),m={};n.forEach(C=>{Object.assign(m,C.defines)}),Object.assign(m,o);let b="";switch(s){case"wgsl":break;case"glsl":b=l?`${g} + +// ----- PROLOGUE ------------------------- +${`#define SHADER_TYPE_${i.toUpperCase()}`} + +${pu(e)} +${i==="fragment"?wu:""} + +// ----- APPLICATION DEFINES ------------------------- + +${Iu(m)} + +`:`${g} +`;break}const R=ua(a),T={},y={},E={};for(const C in c){const v=typeof c[C]=="string"?{injection:c[C],order:0}:c[C],w=/^(v|f)s:(#)?([\w-]+)$/.exec(C);if(w){const x=w[2],B=w[3];x?B==="decl"?y[C]=[v]:E[C]=[v]:T[C]=[v]}else E[C]=[v]}for(const C of n){u&&na(C,_,u);const v=_a(C,i,u);b+=v;const w=((S=C.instance)==null?void 0:S.normalizedInjections[i])||{};for(const x in w){const B=/^(v|f)s:#([\w-]+)$/.exec(x);if(B){const H=B[2]==="decl"?y:E;H[x]=H[x]||[],H[x].push(w[x])}else T[x]=T[x]||[],T[x].push(w[x])}}return b+="// ----- MAIN SHADER SOURCE -------------------------",b+=Es,b=nr(b,i,y),b+=fa(R[i],T),b+=_,b=nr(b,i,E),s==="glsl"&&h!==d&&(b=_u(b,i)),s==="glsl"&&ou(b,i,u),b.trim()}function pa(e){return function(r){var s;const i={};for(const n of e){const o=(s=n.getUniforms)==null?void 0:s.call(n,r,i);Object.assign(i,o)}return i}}function Iu(e={}){let t="";for(const r in e){const i=e[r];(i||Number.isFinite(i))&&(t+=`#define ${r.toUpperCase()} ${e[r]} +`)}return t}function _a(e,t,r){let i;switch(t){case"vertex":i=e.vs||"";break;case"fragment":i=e.fs||"";break;case"wgsl":i=e.source||"";break;default:Mt(!1)}if(!e.name)throw new Error("Shader module must have a name");nu(e,t,{log:r});const s=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let n=`// ----- MODULE ${e.name} --------------- + +`;return t!=="wgsl"&&(n+=`#define MODULE_${s} +`),n+=`${i} +`,n}function Nu(e){const t=new Map;for(const r of st(e,Ru)){const i=Number(r.bindingToken),s=Number(r.groupToken);Ss(s,i,r.name),qe(t,s,i,`application binding "${r.name}"`)}return t}function Bu(e){const t=st(e,ki),r=new Map;for(const n of t){if(n.bindingToken==="auto")continue;const o=Number(n.bindingToken),a=Number(n.groupToken);Ss(a,o,n.name),qe(r,a,o,`application binding "${n.name}"`)}const i={sawSupportedBindingDeclaration:t.length>0},s=ha(e,ki,n=>Uu(n,r,i));if(da(e)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:s}}function Du(e,t,r){const i=[],n={sawSupportedBindingDeclaration:st(e,St).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot=="number"?t.firstBindingSlot:null},o=ha(e,St,a=>Fu(a,{module:t,context:r,bindingAssignments:i,relocationState:n}));if(da(e)&&!n.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function Fu(e,t){var d,g;const{module:r,context:i,bindingAssignments:s,relocationState:n}=t,{match:o,bindingToken:a,groupToken:c,name:l}=e,u=Number(c);if(a==="auto"){const p=ma(u,r.name,l),_=(d=i.bindingRegistry)==null?void 0:d.get(p),m=_!==void 0?_:n.nextHintedBindingLocation===null?bn(u,i.usedBindingsByGroup):bn(u,i.usedBindingsByGroup,n.nextHintedBindingLocation);return mn(r.name,u,m,l),_!==void 0&&ku(i.reservedBindingKeysByGroup,u,m,p)?(s.push({moduleName:r.name,name:l,group:u,location:m}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(qe(i.usedBindingsByGroup,u,m,`module "${r.name}" binding "${l}"`),(g=i.bindingRegistry)==null||g.set(p,m),s.push({moduleName:r.name,name:l,group:u,location:m}),n.nextHintedBindingLocation!==null&&_===void 0&&(n.nextHintedBindingLocation=m+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}const h=Number(a);return mn(r.name,u,h,l),qe(i.usedBindingsByGroup,u,h,`module "${r.name}" binding "${l}"`),s.push({moduleName:r.name,name:l,group:u,location:h}),o}function Uu(e,t,r){const{match:i,bindingToken:s,groupToken:n,name:o}=e,a=Number(n);if(s==="auto"){const c=$u(a,t);return Ss(a,c,o),qe(t,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return r.sawSupportedBindingDeclaration=!0,i}function Lu(e,t,r){const i=new Map;if(!t)return i;for(const s of e)for(const n of Wu(s)){const o=ma(n.group,s.name,n.name),a=t.get(o);if(a!==void 0){const c=i.get(n.group)||new Map,l=c.get(a);if(l&&l!==o)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${o}": group ${n.group}, binding ${a}.`);qe(r,n.group,a,`registered module binding "${o}"`),c.set(a,o),i.set(n.group,c)}}return i}function ku(e,t,r,i){const s=e.get(t);if(!s)return!1;const n=s.get(r);if(!n)return!1;if(n!==i)throw new Error(`Registered module binding "${i}" collided with "${n}": group ${t}, binding ${r}.`);return!0}function Wu(e){const t=[],r=e.source||"";for(const i of st(r,St))t.push({name:i.name,group:Number(i.groupToken)});return t}function Ss(e,t,r){if(e===0&&t>=Ct)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${Ct}.`)}function mn(e,t,r,i){if(t===0&&r0?Math.max(...i)+1:0);for(;i.has(s);)s++;return s}function $u(e,t){const r=t.get(e)||new Set;let i=0;for(;r.has(i);)i++;return i}function zu(e){const t=Su(e,St);if(!t)return;const r=Hu(e,t.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${t.name}" remained in assembled WGSL source.`):Vu(e,t.index)?new Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${Xu(t.match)}".`)}function ju(e){if(e.length===0)return"";let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`;for(const r of e)t+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location}) +`;return t+=` +`,t}function ma(e,t,r){return`${e}:${t}:${r}`}function Hu(e,t){const r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;let i,s;for(s=r.exec(e);s&&s.index<=t;)i=s[1],s=r.exec(e);return i}function Vu(e,t){const r=e.indexOf(Es);return r>=0?t>r:!0}function Xu(e){return e.replace(/\s+/g," ").trim()}const Cs="([a-zA-Z_][a-zA-Z0-9_]*)",Yu=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Cs}\\s*$`),Ku=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Cs}\\s*(?:\\/\\/.*)?$`),Qu=/^\s*\#\s*else\s*(?:\/\/.*)?$/,qu=/^\s*\#\s*endif\s*$/,Zu=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Cs}\\s*(?:\\/\\/.*)?$`),Ju=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function Gu(e,t){var o,a;const r=e.split(` +`),i=[],s=[];let n=!0;for(const c of r){const l=c.match(Zu)||c.match(Yu),u=c.match(Ku),h=c.match(Qu),d=c.match(Ju)||c.match(qu);if(l||u){const g=(o=l||u)==null?void 0:o[1],p=!!((a=t==null?void 0:t.defines)!=null&&a[g]),_=l?p:!p,m=n&&_;s.push({parentActive:n,branchTaken:_,active:m}),n=m}else if(h){const g=s[s.length-1];if(!g)throw new Error("Encountered #else without matching #ifdef or #ifndef");g.active=g.parentActive&&!g.branchTaken,g.branchTaken=!0,n=g.active}else d?(s.pop(),n=s.length?s[s.length-1].active:!0):n&&i.push(c)}if(s.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` +`)}const Re=class Re{constructor(){f(this,"_hookFunctions",[]);f(this,"_defaultModules",[]);f(this,"_wgslBindingRegistry",new Map)}static getDefaultShaderAssembler(){return Re.defaultShaderAssembler=Re.defaultShaderAssembler||new Re,Re.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(r=>r.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){const r=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleWGSLShader(t){const r=this._getModuleList(t.modules),i=this._hookFunctions,{source:s,getUniforms:n,bindingAssignments:o}=Ou({...t,source:t.source,_bindingRegistry:this._wgslBindingRegistry,modules:r,hookFunctions:i}),a={...r.reduce((l,u)=>(Object.assign(l,u.defines),l),{}),...t.defines},c=t.platformInfo.shaderLanguage==="wgsl"?Gu(s,{defines:a}):s;return{source:c,getUniforms:n,modules:r,bindingAssignments:o,bindingTable:ga(c,o)}}assembleGLSLShaderPair(t){const r=this._getModuleList(t.modules),i=this._hookFunctions;return{...xu({...t,vs:t.vs,fs:t.fs,modules:r,hookFunctions:i}),modules:r}}_getModuleList(t=[]){const r=new Array(this._defaultModules.length+t.length),i={};let s=0;for(let n=0,o=this._defaultModules.length;nr*oh,t)}function CA(e,t){return vs(e,r=>r*nh,t)}function ar(e,t,r){return vs(e,i=>Math.max(t,Math.min(r,i)))}function ba(e,t,r){return Ze(e)?e.map((i,s)=>ba(i,t[s],r)):r*t+(1-r)*e}function cr(e,t,r){const i=Z.EPSILON;try{if(e===t)return!0;if(Ze(e)&&Ze(t)){if(e.length!==t.length)return!1;for(let s=0;s0?", ":"")+ch(this[i],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r=0&&t=0&&tMath.PI*2)throw Error("expected radians")}function ed(e,t,r,i,s,n){const o=2*n/(r-t),a=2*n/(s-i),c=(r+t)/(r-t),l=(s+i)/(s-i),u=-1,h=-1,d=-2*n;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0,e}function Ca(e,t=[],r=0){const i=Math.fround(e),s=e-i;return t[r]=i,t[r+1]=s,t}function td(e){return e-Math.fround(e)}function rd(e){const t=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){const s=r*4+i;Ca(e[i*4+r],t,s*2)}return t}function va(e,t=!0){return e??t}function Pa(e=[0,0,0],t=!0){return t?e.map(r=>r/255):[...e]}function id(e,t=!0){const r=Pa(e.slice(0,3),t),i=Number.isFinite(e[3]),s=i?e[3]:1;return[r[0],r[1],r[2],t&&i?s/255:s]}const sd=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + +// All these functions are for substituting tan() function from Intel GPU only +const float TWO_PI = 6.2831854820251465; +const float PI_2 = 1.5707963705062866; +const float PI_16 = 0.1963495463132858; + +const float SIN_TABLE_0 = 0.19509032368659973; +const float SIN_TABLE_1 = 0.3826834261417389; +const float SIN_TABLE_2 = 0.5555702447891235; +const float SIN_TABLE_3 = 0.7071067690849304; + +const float COS_TABLE_0 = 0.9807852506637573; +const float COS_TABLE_1 = 0.9238795042037964; +const float COS_TABLE_2 = 0.8314695954322815; +const float COS_TABLE_3 = 0.7071067690849304; + +const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3! +const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5! +const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7! +const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9! + +float sin_taylor_fp32(float a) { + float r, s, t, x; + + if (a == 0.0) { + return 0.0; + } + + x = -a * a; + s = a; + r = a; + + r = r * x; + t = r * INVERSE_FACTORIAL_3; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_5; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_7; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_9; + s = s + t; + + return s; +} + +void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { + if (a == 0.0) { + sin_t = 0.0; + cos_t = 1.0; + } + sin_t = sin_taylor_fp32(a); + cos_t = sqrt(1.0 - sin_t * sin_t); +} + +float tan_taylor_fp32(float a) { + float sin_a; + float cos_a; + + if (a == 0.0) { + return 0.0; + } + + // 2pi range reduction + float z = floor(a / TWO_PI); + float r = a - TWO_PI * z; + + float t; + float q = floor(r / PI_2 + 0.5); + int j = int(q); + + if (j < -2 || j > 2) { + return 1.0 / 0.0; + } + + t = r - PI_2 * q; + + q = floor(t / PI_16 + 0.5); + int k = int(q); + int abs_k = int(abs(float(k))); + + if (abs_k > 4) { + return 1.0 / 0.0; + } else { + t = t - PI_16 * q; + } + + float u = 0.0; + float v = 0.0; + + float sin_t, cos_t; + float s, c; + sincos_taylor_fp32(t, sin_t, cos_t); + + if (k == 0) { + s = sin_t; + c = cos_t; + } else { + if (abs(float(abs_k) - 1.0) < 0.5) { + u = COS_TABLE_0; + v = SIN_TABLE_0; + } else if (abs(float(abs_k) - 2.0) < 0.5) { + u = COS_TABLE_1; + v = SIN_TABLE_1; + } else if (abs(float(abs_k) - 3.0) < 0.5) { + u = COS_TABLE_2; + v = SIN_TABLE_2; + } else if (abs(float(abs_k) - 4.0) < 0.5) { + u = COS_TABLE_3; + v = SIN_TABLE_3; + } + if (k > 0) { + s = u * sin_t + v * cos_t; + c = u * cos_t - v * sin_t; + } else { + s = u * sin_t - v * cos_t; + c = u * cos_t + v * sin_t; + } + } + + if (j == 0) { + sin_a = s; + cos_a = c; + } else if (j == 1) { + sin_a = c; + cos_a = -s; + } else if (j == -1) { + sin_a = -c; + cos_a = s; + } else { + sin_a = -s; + cos_a = -c; + } + return sin_a / cos_a; +} +#endif + +float tan_fp32(float a) { +#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + return tan_taylor_fp32(a); +#else + return tan(a); +#endif +} +`,nd={name:"fp32",vs:sd},Rn=` +layout(std140) uniform fp64arithmeticUniforms { + uniform float ONE; + uniform float SPLIT; +} fp64; + +/* +About LUMA_FP64_CODE_ELIMINATION_WORKAROUND + +The purpose of this workaround is to prevent shader compilers from +optimizing away necessary arithmetic operations by swapping their sequences +or transform the equation to some 'equivalent' form. + +These helpers implement Dekker/Veltkamp-style error tracking. If the compiler +folds constants or reassociates the arithmetic, the high/low split can stop +tracking the rounding error correctly. That failure mode tends to look fine in +simple coordinate setup, but then breaks down inside iterative arithmetic such +as fp64 Mandelbrot loops. + +The method is to multiply an artifical variable, ONE, which will be known to +the compiler to be 1 only at runtime. The whole expression is then represented +as a polynomial with respective to ONE. In the coefficients of all terms, only one a +and one b should appear + +err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE +*/ + +float prevent_fp64_optimization(float value) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + return value + fp64.ONE * 0.0; +#else + return value; +#endif +} + +// Divide float number to high and low floats to extend fraction bits +vec2 split(float a) { + // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker + // split into a constant expression and reassociate the recovery steps. + float split = prevent_fp64_optimization(fp64.SPLIT); + float t = prevent_fp64_optimization(a * split); + float temp = t - a; + float a_hi = t - temp; + float a_lo = a - a_hi; + return vec2(a_hi, a_lo); +} + +// Divide float number again when high float uses too many fraction bits +vec2 split2(vec2 a) { + vec2 b = split(a.x); + b.y += a.y; + return b; +} + +// Special sum operation when a > b +vec2 quickTwoSum(float a, float b) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float sum = (a + b) * fp64.ONE; + float err = b - (sum - a) * fp64.ONE; +#else + float sum = a + b; + float err = b - (sum - a); +#endif + return vec2(sum, err); +} + +// General sum operation +vec2 twoSum(float a, float b) { + float s = (a + b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v); +#else + float v = s - a; + float err = (a - (s - v)) + (b - v); +#endif + return vec2(s, err); +} + +vec2 twoSub(float a, float b) { + float s = (a - b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v); +#else + float v = s - a; + float err = (a - (s - v)) - (b + v); +#endif + return vec2(s, err); +} + +vec2 twoSqr(float a) { + float prod = a * a; + vec2 a_fp64 = split(a); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x * + a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; +#endif + return vec2(prod, err); +} + +vec2 twoProd(float a, float b) { + float prod = a * b; + vec2 a_fp64 = split(a); + vec2 b_fp64 = split(b); + // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend + // on the split terms and cross terms staying in the original evaluation + // order. If the compiler folds or reassociates them, the low part tends to + // collapse to zero or NaN on some drivers. + float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x); + float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y); + float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x); + float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err1 = (highProduct - prod) * fp64.ONE; + float err2 = crossProduct1 * fp64.ONE * fp64.ONE; + float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE; + float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err1 = highProduct - prod; + float err2 = crossProduct1; + float err3 = crossProduct2; + float err4 = lowProduct; +#endif + float err = ((err1 + err2) + err3) + err4; + return vec2(prod, err); +} + +vec2 sum_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSum(a.x, b.x); + t = twoSum(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 sub_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSub(a.x, b.x); + t = twoSub(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 mul_fp64(vec2 a, vec2 b) { + vec2 prod = twoProd(a.x, b.x); + // y component is for the error + prod.y += a.x * b.y; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + prod.y += a.y * b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +vec2 div_fp64(vec2 a, vec2 b) { + float xn = 1.0 / b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + vec2 yn = mul_fp64(a, vec2(xn, 0)); +#else + vec2 yn = a * xn; +#endif + float diff = (sub_fp64(a, mul_fp64(b, yn))).x; + vec2 prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +vec2 sqrt_fp64(vec2 a) { + if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); + if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); + + float x = 1.0 / sqrt(a.x); + float yn = a.x * x; +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + vec2 yn_sqr = twoSqr(yn) * fp64.ONE; +#else + vec2 yn_sqr = twoSqr(yn); +#endif + float diff = sub_fp64(a, yn_sqr).x; + vec2 prod = twoProd(x * 0.5, diff); +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2(yn, 0.0), prod); +#endif +} +`,od=`struct Fp64ArithmeticUniforms { + ONE: f32, + SPLIT: f32, +}; + +@group(0) @binding(auto) var fp64arithmetic : Fp64ArithmeticUniforms; + +fn fp64_nan(seed: f32) -> f32 { + let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); + return bitcast(nanBits); +} + +fn fp64_runtime_zero() -> f32 { + return fp64arithmetic.ONE * 0.0; +} + +fn prevent_fp64_optimization(value: f32) -> f32 { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + return value + fp64_runtime_zero(); +#else + return value; +#endif +} + +fn split(a: f32) -> vec2f { + let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); + let t = prevent_fp64_optimization(a * splitValue); + let temp = prevent_fp64_optimization(t - a); + let aHi = prevent_fp64_optimization(t - temp); + let aLo = prevent_fp64_optimization(a - aHi); + return vec2f(aHi, aLo); +} + +fn split2(a: vec2f) -> vec2f { + var b = split(a.x); + b.y = b.y + a.y; + return b; +} + +fn quickTwoSum(a: f32, b: f32) -> vec2f { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE); + let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE); +#else + let sum = prevent_fp64_optimization(a + b); + let err = prevent_fp64_optimization(b - (sum - a)); +#endif + return vec2f(sum, err); +} + +fn twoSum(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a + b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) + + prevent_fp64_optimization(b - v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v); +#endif + return vec2f(s, err); +} + +fn twoSub(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a - b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) - + prevent_fp64_optimization(b + v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v); +#endif + return vec2f(s, err); +} + +fn twoSqr(a: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * a); + let aFp64 = split(a); + let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x); + let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y); + let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err = + (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE + + crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) + + lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; +#else + let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct); +#endif + return vec2f(prod, err); +} + +fn twoProd(a: f32, b: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * b); + let aFp64 = split(a); + let bFp64 = split(b); + let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x); + let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y); + let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x); + let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err1 = (highProduct - prod) * fp64arithmetic.ONE; + let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err4 = + lowProduct * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE; +#else + let err1 = highProduct - prod; + let err2 = crossProduct1; + let err3 = crossProduct2; + let err4 = lowProduct; +#endif + let err12InputA = prevent_fp64_optimization(err1); + let err12InputB = prevent_fp64_optimization(err2); + let err12 = prevent_fp64_optimization(err12InputA + err12InputB); + let err123InputA = prevent_fp64_optimization(err12); + let err123InputB = prevent_fp64_optimization(err3); + let err123 = prevent_fp64_optimization(err123InputA + err123InputB); + let err1234InputA = prevent_fp64_optimization(err123); + let err1234InputB = prevent_fp64_optimization(err4); + let err = prevent_fp64_optimization(err1234InputA + err1234InputB); + return vec2f(prod, err); +} + +fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSum(a.x, b.x); + let t = twoSum(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSub(a.x, b.x); + let t = twoSub(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { + var prod = twoProd(a.x, b.x); + let crossProduct1 = prevent_fp64_optimization(a.x * b.y); + prod.y = prevent_fp64_optimization(prod.y + crossProduct1); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + let crossProduct2 = prevent_fp64_optimization(a.y * b.x); + prod.y = prevent_fp64_optimization(prod.y + crossProduct2); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +fn div_fp64(a: vec2f, b: vec2f) -> vec2f { + let xn = prevent_fp64_optimization(1.0 / b.x); + let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero())); + let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x); + let prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +fn sqrt_fp64(a: vec2f) -> vec2f { + if (a.x == 0.0 && a.y == 0.0) { + return vec2f(0.0, 0.0); + } + if (a.x < 0.0) { + let nanValue = fp64_nan(a.x); + return vec2f(nanValue, nanValue); + } + + let x = prevent_fp64_optimization(1.0 / sqrt(a.x)); + let yn = prevent_fp64_optimization(a.x * x); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let ynSqr = twoSqr(yn) * fp64arithmetic.ONE; +#else + let ynSqr = twoSqr(yn); +#endif + let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x); + let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2f(yn, 0.0), prod); +#endif +} +`,ad={ONE:1,SPLIT:4097},cd={name:"fp64arithmetic",source:od,fs:Rn,vs:Rn,defaultUniforms:ad,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Ca,fp64LowPart:td,fp64ifyMatrix4:rd},En=`layout(std140) uniform floatColorsUniforms { + float useByteColors; +} floatColors; + +vec3 floatColors_normalize(vec3 inputColor) { + return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 floatColors_normalize(vec4 inputColor) { + return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 floatColors_premultiplyAlpha(vec4 inputColor) { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) { + return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0); +} + +vec4 floatColors_premultiply_alpha(vec4 inputColor) { + return floatColors_premultiplyAlpha(inputColor); +} + +vec4 floatColors_unpremultiply_alpha(vec4 inputColor) { + return floatColors_unpremultiplyAlpha(inputColor); +} +`,ld=`struct floatColorsUniforms { + useByteColors: f32 +}; + +@group(0) @binding(auto) var floatColors : floatColorsUniforms; + +fn floatColors_normalize(inputColor: vec3) -> vec3 { + return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); +} + +fn floatColors_normalize4(inputColor: vec4) -> vec4 { + return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); +} + +fn floatColors_premultiplyAlpha(inputColor: vec4) -> vec4 { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +fn floatColors_unpremultiplyAlpha(inputColor: vec4) -> vec4 { + return select( + vec4(0.0), + vec4(inputColor.rgb / inputColor.a, inputColor.a), + inputColor.a > 0.0 + ); +} + +fn floatColors_premultiply_alpha(inputColor: vec4) -> vec4 { + return floatColors_premultiplyAlpha(inputColor); +} + +fn floatColors_unpremultiply_alpha(inputColor: vec4) -> vec4 { + return floatColors_unpremultiplyAlpha(inputColor); +} +`,wa={name:"floatColors",props:{},uniforms:{},vs:En,fs:En,source:ld,uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},fd=[0,1,1,1],ud=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +out vec4 picking_vRGBcolor_Avalid; + +// Normalize unsigned byte color to 0-1 range +vec3 picking_normalizeColor(vec3 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +// Normalize unsigned byte color to 0-1 range +vec4 picking_normalizeColor(vec4 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +bool picking_isColorZero(vec3 color) { + return dot(color, vec3(1.0)) < 0.00001; +} + +bool picking_isColorValid(vec3 color) { + return dot(color, vec3(1.0)) > 0.00001; +} + +// Check if this vertex is highlighted +bool isVertexHighlighted(vec3 vertexColor) { + vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + return + bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); +} + +// Set the current picking color +void picking_setPickingColor(vec3 pickingColor) { + pickingColor = picking_normalizeColor(pickingColor); + + if (bool(picking.isActive)) { + // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable + picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); + + if (!bool(picking.isAttribute)) { + // Stores the picking color so that the fragment shader can render it during picking + picking_vRGBcolor_Avalid.rgb = pickingColor; + } + } else { + // Do the comparison with selected item color in vertex shader as it should mean fewer compares + picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); + } +} + +void picking_setPickingAttribute(float value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.r = value; + } +} + +void picking_setPickingAttribute(vec2 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rg = value; + } +} + +void picking_setPickingAttribute(vec3 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rgb = value; + } +} +`,hd=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +in vec4 picking_vRGBcolor_Avalid; + +/* + * Returns highlight color if this item is selected. + */ +vec4 picking_filterHighlightColor(vec4 color) { + // If we are still picking, we don't highlight + if (picking.isActive > 0.5) { + return color; + } + + bool selected = bool(picking_vRGBcolor_Avalid.a); + + if (selected) { + // Blend in highlight color based on its alpha value + float highLightAlpha = picking.highlightColor.a; + float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); + float highLightRatio = highLightAlpha / blendedAlpha; + + vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); + return vec4(blendedRGB, blendedAlpha); + } else { + return color; + } +} + +/* + * Returns picking color if picking enabled else unmodified argument. + */ +vec4 picking_filterPickingColor(vec4 color) { + if (bool(picking.isActive)) { + if (picking_vRGBcolor_Avalid.a == 0.0) { + discard; + } + return picking_vRGBcolor_Avalid; + } + return color; +} + +/* + * Returns picking color if picking is enabled if not + * highlight color if this item is selected, otherwise unmodified argument. + */ +vec4 picking_filterColor(vec4 color) { + vec4 highlightColor = picking_filterHighlightColor(color); + return picking_filterPickingColor(highlightColor); +} +`,Sn={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:fd},vs:ud,fs:hd,getUniforms:dd};function dd(e={},t){const r={},i=va(e.useByteColors,!0);if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;const s=e.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=s}return e.highlightColor&&(r.highlightColor=id(e.highlightColor,i)),e.isActive!==void 0&&(r.isActive=!!e.isActive,r.isAttribute=!!e.isAttribute),e.useByteColors!==void 0&&(r.useByteColors=!!e.useByteColors),r}const gd="GPU Time and Memory",pd=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],Cn=new WeakMap,vn=new WeakMap;class _d{constructor(){f(this,"stats",new Map)}getStats(t){return this.get(t)}get(t){this.stats.has(t)||this.stats.set(t,new Hl({id:t}));const r=this.stats.get(t);return t===gd&&bd(r,pd),r}}const md=new _d;function bd(e,t){const r=e.stats;let i=!1;for(const c of t)r[c]||(e.get(c),i=!0);const s=Object.keys(r).length,n=Cn.get(e);if(!i&&(n==null?void 0:n.orderedStatNames)===t&&n.statCount===s)return;const o={};let a=vn.get(t);a||(a=new Set(t),vn.set(t,a));for(const c of t)r[c]&&(o[c]=r[c]);for(const[c,l]of Object.entries(r))a.has(c)||(o[c]=l);for(const c of Object.keys(r))delete r[c];Object.assign(r,o),Cn.set(e,{orderedStatNames:t,statCount:s})}const A=new xt({id:"luma.gl"}),ai={};function Nt(e="id"){ai[e]=ai[e]||1;const t=ai[e]++;return`${e}-${t}`}const Td="cpu-hotspot-profiler",Pn="GPU Resource Counts",wn="Resource Counts",On="GPU Time and Memory",Ad=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],yd=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],Rd=Ad.flatMap(e=>[`${e} Created`,`${e} Active`]),Ed=yd.flatMap(e=>[`${e} Created`,`${e} Active`]),xn=new WeakMap,Mn=new WeakMap;class O{constructor(t,r,i){f(this,"id");f(this,"props");f(this,"userData",{});f(this,"_device");f(this,"destroyed",!1);f(this,"allocatedBytes",0);f(this,"allocatedBytesName",null);f(this,"_attachedResources",new Set);if(!t)throw new Error("no device");this._device=t,this.props=Sd(r,i);const s=this.props.id!=="undefined"?this.props.id:Nt(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(t){this._attachedResources.add(t)}detachResource(t){this._attachedResources.delete(t)}destroyAttachedResource(t){this._attachedResources.delete(t)&&t.destroy()}destroyAttachedResources(){for(const t of this._attachedResources)t.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){const t=gt(this._device),r=t?ue():0,i=[this._device.statsManager.getStats(Pn),this._device.statsManager.getStats(wn)],s=Nn(this._device);for(const o of i)In(o,s);const n=this.getStatsName();for(const o of i)o.get("Resources Active").decrementCount(),o.get(`${n}s Active`).decrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(ue()-r))}trackAllocatedMemory(t,r=this.getStatsName()){const i=gt(this._device),s=i?ue():0,n=this._device.statsManager.getStats(On);this.allocatedBytes>0&&this.allocatedBytesName&&(n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),n.get("GPU Memory").addCount(t),n.get(`${r} Memory`).addCount(t),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(ue()-s)),this.allocatedBytes=t,this.allocatedBytesName=r}trackReferencedMemory(t,r=this.getStatsName()){this.trackAllocatedMemory(t,`Referenced ${r}`)}trackDeallocatedMemory(t=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}const r=gt(this._device),i=r?ue():0,s=this._device.statsManager.getStats(On);s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName||t} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ue()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(t=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${t}`)}addStats(){const t=this.getStatsName(),r=gt(this._device),i=r?ue():0,s=[this._device.statsManager.getStats(Pn),this._device.statsManager.getStats(wn)],n=Nn(this._device);for(const o of s)In(o,n);for(const o of s)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${t}s Created`).incrementCount(),o.get(`${t}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ue()-i)),Cd(this._device,t)}getStatsName(){return vd(this)}}f(O,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Sd(e,t){const r={...t};for(const i in e)e[i]!==void 0&&(r[i]=e[i]);return r}function In(e,t){const r=e.stats;let i=!1;for(const c of t)r[c]||(e.get(c),i=!0);const s=Object.keys(r).length,n=xn.get(e);if(!i&&(n==null?void 0:n.orderedStatNames)===t&&n.statCount===s)return;const o={};let a=Mn.get(t);a||(a=new Set(t),Mn.set(t,a));for(const c of t)r[c]&&(o[c]=r[c]);for(const[c,l]of Object.entries(r))a.has(c)||(o[c]=l);for(const c of Object.keys(r))delete r[c];Object.assign(r,o),xn.set(e,{orderedStatNames:t,statCount:s})}function Nn(e){return e.type==="webgl"?Ed:Rd}function gt(e){const t=e.userData[Td];return t!=null&&t.enabled?t:null}function ue(){var e,t;return((t=(e=globalThis.performance)==null?void 0:e.now)==null?void 0:t.call(e))??Date.now()}function Cd(e,t){const r=gt(e);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,t){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break}}function vd(e){let t=Object.getPrototypeOf(e);for(;t;){const r=Object.getPrototypeOf(t);if(!r||r===O.prototype)return Pd(t)||e[Symbol.toStringTag]||e.constructor.name;t=r}return e[Symbol.toStringTag]||e.constructor.name}function Pd(e){const t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return typeof(t==null?void 0:t.get)=="function"?t.get.call(e):typeof(t==null?void 0:t.value)=="string"?t.value:null}const z=class z extends O{constructor(r,i){const s={...i};(i.usage||0)&z.INDEX&&!i.indexType&&(i.data instanceof Uint32Array?s.indexType="uint32":i.data instanceof Uint16Array?s.indexType="uint16":i.data instanceof Uint8Array&&(s.indexType="uint8")),delete s.data;super(r,s,z.defaultProps);f(this,"usage");f(this,"indexType");f(this,"updateTimestamp");f(this,"debugData",new ArrayBuffer(0));this.usage=s.usage||0,this.indexType=s.indexType,this.updateTimestamp=r.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(r){return this.device.createBuffer({...this.props,...r})}_setDebugData(r,i,s){let n=null,o;ArrayBuffer.isView(r)?(n=r,o=r.buffer):o=r;const a=Math.min(r?r.byteLength:s,z.DEBUG_DATA_MAX_LENGTH);if(o===null)this.debugData=new ArrayBuffer(a);else{const c=Math.min((n==null?void 0:n.byteOffset)||0,o.byteLength),l=Math.max(0,o.byteLength-c),u=Math.min(a,l);this.debugData=new Uint8Array(o,c,u).slice().buffer}}};f(z,"INDEX",16),f(z,"VERTEX",32),f(z,"UNIFORM",64),f(z,"STORAGE",128),f(z,"INDIRECT",256),f(z,"QUERY_RESOLVE",512),f(z,"MAP_READ",1),f(z,"MAP_WRITE",2),f(z,"COPY_SRC",4),f(z,"COPY_DST",8),f(z,"DEBUG_DATA_MAX_LENGTH",32),f(z,"defaultProps",{...O.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let N=z;class wd{getDataTypeInfo(t){const[r,i,s]=ci[t],n=t.includes("norm"),o=!n&&!t.startsWith("float"),a=t.startsWith("s");return{signedType:r,primitiveType:i,byteLength:s,normalized:n,integer:o,signed:a}}getNormalizedDataType(t){const r=t;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(t,r){switch(r){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}getDataType(t){const r=ArrayBuffer.isView(t)?t.constructor:t;if(r===Uint8ClampedArray)return"uint8";const i=Object.values(ci).find(s=>r===s[4]);if(!i)throw new Error(r.name);return i[0]}getTypedArrayConstructor(t){const[,,,,r]=ci[t];return r}}const le=new wd,ci={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};class Od{getVertexFormatInfo(t){let r;t.endsWith("-webgl")&&(t.replace("-webgl",""),r=!0);const[i,s]=t.split("x"),n=i,o=s?parseInt(s):1,a=le.getDataTypeInfo(n),c={type:n,components:o,byteLength:a.byteLength*o,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(t,r,i){const s=i?le.getNormalizedDataType(t):t;switch(s){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${s}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${s}x${r}`;case"uint8":case"sint8":if(r===1||r===3)throw new Error(`size: ${r}`);return`${s}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${s}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${s}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${s}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${s}x${r}`;case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${s}x${r}`;default:return r===1?s:`${s}x${r}`}}getVertexFormatFromAttribute(t,r,i){if(!r||r>4)throw new Error(`size ${r}`);const s=r,n=le.getDataType(t);return this.makeVertexFormat(n,s,i)}getCompatibleVertexFormat(t){let r;switch(t.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return t.components<=2?"float16x2":"float16x4"}return t.components===1?r:`${r}x${t.components}`}}const vt=new Od,j="texture-compression-bc",M="texture-compression-astc",ne="texture-compression-etc2",xd="texture-compression-etc1-webgl",Wt="texture-compression-pvrtc-webgl",li="texture-compression-atc-webgl",$t="float32-renderable-webgl",fi="float16-renderable-webgl",Md="rgb9e5ufloat-renderable-webgl",ui="snorm8-renderable-webgl",he="norm16-webgl",hi="norm16-renderable-webgl",di="snorm16-renderable-webgl",zt="float32-filterable",Bn="float16-filterable-webgl";function Oa(e){const t=xa[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}function Id(){return xa}const Nd={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ui},rg8snorm:{render:ui},"rgb8snorm-webgl":{},rgba8snorm:{render:ui},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:he,render:hi},rg16unorm:{f:he,render:hi},"rgb16unorm-webgl":{f:he,render:!1},rgba16unorm:{f:he,render:hi},r16snorm:{f:he,render:di},rg16snorm:{f:he,render:di},"rgb16snorm-webgl":{f:he,render:!1},rgba16snorm:{f:he,render:di},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:fi,filter:"float16-filterable-webgl"},rg16float:{render:fi,filter:Bn},rgba16float:{render:fi,filter:Bn},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:$t,filter:zt},rg32float:{render:!1,filter:zt},"rgb32float-webgl":{render:$t,filter:zt},rgba32float:{render:$t,filter:zt},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Md},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:$t},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},Bd={"bc1-rgb-unorm-webgl":{f:j},"bc1-rgb-unorm-srgb-webgl":{f:j},"bc1-rgba-unorm":{f:j},"bc1-rgba-unorm-srgb":{f:j},"bc2-rgba-unorm":{f:j},"bc2-rgba-unorm-srgb":{f:j},"bc3-rgba-unorm":{f:j},"bc3-rgba-unorm-srgb":{f:j},"bc4-r-unorm":{f:j},"bc4-r-snorm":{f:j},"bc5-rg-unorm":{f:j},"bc5-rg-snorm":{f:j},"bc6h-rgb-ufloat":{f:j},"bc6h-rgb-float":{f:j},"bc7-rgba-unorm":{f:j},"bc7-rgba-unorm-srgb":{f:j},"etc2-rgb8unorm":{f:ne},"etc2-rgb8unorm-srgb":{f:ne},"etc2-rgb8a1unorm":{f:ne},"etc2-rgb8a1unorm-srgb":{f:ne},"etc2-rgba8unorm":{f:ne},"etc2-rgba8unorm-srgb":{f:ne},"eac-r11unorm":{f:ne},"eac-r11snorm":{f:ne},"eac-rg11unorm":{f:ne},"eac-rg11snorm":{f:ne},"astc-4x4-unorm":{f:M},"astc-4x4-unorm-srgb":{f:M},"astc-5x4-unorm":{f:M},"astc-5x4-unorm-srgb":{f:M},"astc-5x5-unorm":{f:M},"astc-5x5-unorm-srgb":{f:M},"astc-6x5-unorm":{f:M},"astc-6x5-unorm-srgb":{f:M},"astc-6x6-unorm":{f:M},"astc-6x6-unorm-srgb":{f:M},"astc-8x5-unorm":{f:M},"astc-8x5-unorm-srgb":{f:M},"astc-8x6-unorm":{f:M},"astc-8x6-unorm-srgb":{f:M},"astc-8x8-unorm":{f:M},"astc-8x8-unorm-srgb":{f:M},"astc-10x5-unorm":{f:M},"astc-10x5-unorm-srgb":{f:M},"astc-10x6-unorm":{f:M},"astc-10x6-unorm-srgb":{f:M},"astc-10x8-unorm":{f:M},"astc-10x8-unorm-srgb":{f:M},"astc-10x10-unorm":{f:M},"astc-10x10-unorm-srgb":{f:M},"astc-12x10-unorm":{f:M},"astc-12x10-unorm-srgb":{f:M},"astc-12x12-unorm":{f:M},"astc-12x12-unorm-srgb":{f:M},"pvrtc-rgb4unorm-webgl":{f:Wt},"pvrtc-rgba4unorm-webgl":{f:Wt},"pvrtc-rgb2unorm-webgl":{f:Wt},"pvrtc-rgba2unorm-webgl":{f:Wt},"etc1-rbg-unorm-webgl":{f:xd},"atc-rgb-unorm-webgl":{f:li},"atc-rgba-unorm-webgl":{f:li},"atc-rgbai-unorm-webgl":{f:li}},xa={...Nd,...Bd},Dd=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,Fd=["rgb","rgba","bgra"],Ud=["depth","stencil"],Ld=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"];class kd{isColor(t){return Fd.some(r=>t.startsWith(r))}isDepthStencil(t){return Ud.some(r=>t.startsWith(r))}isCompressed(t){return Ld.some(r=>t.startsWith(r))}getInfo(t){return Ma(t)}getCapabilities(t){return $d(t)}computeMemoryLayout(t){return Wd(t)}}const re=new kd;function Wd({format:e,width:t,height:r,depth:i,byteAlignment:s}){const n=re.getInfo(e),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=n,h=u?Math.ceil(t/c):t,d=u?Math.ceil(r/l):r,g=h*a,p=Math.ceil(g/s)*s,_=d,m=p*_*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:_,depthOrArrayLayers:i,bytesPerImage:p*_,byteLength:m}}function $d(e){const t=Oa(e),r={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},i=Ma(e),s=e.startsWith("depth")||e.startsWith("stencil"),n=i==null?void 0:i.signed,o=i==null?void 0:i.integer,a=i==null?void 0:i.webgl,c=!!(i!=null&&i.compressed);return r.render&&(r.render=!s&&!c),r.filter&&(r.filter=!s&&!n&&!o&&!a),r}function Ma(e){let t=zd(e);if(re.isCompressed(e)){t.channels="rgb",t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0,t.bytesPerBlock=Hd(e);const i=jd(e);i&&(t.blockWidth=i.blockWidth,t.blockHeight=i.blockHeight)}const r=t.packed?null:Dd.exec(e);if(r){const[,i,s,n,o,a]=r,c=`${n}${s}`,l=le.getDataTypeInfo(c),u=l.byteLength*8,h=(i==null?void 0:i.length)??1,d=[u,h>=2?u:0,h>=3?u:0,h>=4?u:0];t={format:e,attachment:t.attachment,dataType:l.signedType,components:h,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*h,packed:t.packed,srgb:t.srgb},a==="-webgl"&&(t.webgl=!0),o==="-srgb"&&(t.srgb=!0)}return e.endsWith("-webgl")&&(t.webgl=!0),e.endsWith("-srgb")&&(t.srgb=!0),t}function zd(e){var n;const t=Oa(e),r=t.bytesPerPixel||1,i=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:e,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||((n=t.channels)==null?void 0:n.length)||1,bytesPerPixel:r,bitsPerChannel:i,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function jd(e){const r=/.*-(\d+)x(\d+)-.*/.exec(e);if(r){const[,i,s]=r;return{blockWidth:Number(i),blockHeight:Number(s)}}return e.startsWith("bc")||e.startsWith("etc1")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("atc")?{blockWidth:4,blockHeight:4}:e.startsWith("pvrtc-rgb4")||e.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:e.startsWith("pvrtc-rgb2")||e.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function Hd(e){return e.startsWith("bc1")||e.startsWith("bc4")||e.startsWith("etc1")||e.startsWith("etc2-rgb8")||e.startsWith("etc2-rgb8a1")||e.startsWith("eac-r11")||e==="atc-rgb-unorm-webgl"?8:e.startsWith("bc2")||e.startsWith("bc3")||e.startsWith("bc5")||e.startsWith("bc6h")||e.startsWith("bc7")||e.startsWith("etc2-rgba8")||e.startsWith("eac-rg11")||e.startsWith("astc")||e==="atc-rgba-unorm-webgl"||e==="atc-rgbai-unorm-webgl"?16:e.startsWith("pvrtc")?8:16}function ws(e){return typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof VideoFrame<"u"&&e instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}function Ia(e){if(typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<"u"&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}class Vd{}function Xd(e,t){const r=ji(e),i=t.map(ji).filter(s=>s!==void 0);return[r,...i].filter(s=>s!==void 0)}function ji(e){var t;if(e!==void 0){if(e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(ji);if(typeof e=="object"){if(Yd(e)){const r=String(e);if(r!=="[object Object]")return r}return Kd(e)?Qd(e):((t=e.constructor)==null?void 0:t.name)||"Object"}return String(e)}}function Yd(e){return"toString"in e&&typeof e.toString=="function"&&e.toString!==Object.prototype.toString}function Kd(e){return"message"in e&&"type"in e}function Qd(e){const t=typeof e.type=="string"?e.type:"message",r=typeof e.message=="string"?e.message:"",i=typeof e.lineNum=="number"?e.lineNum:null,s=typeof e.linePos=="number"?e.linePos:null,n=i!==null&&s!==null?` @ ${i}:${s}`:i!==null?` @ ${i}`:"";return`${t}${n}: ${r}`.trim()}class qd{constructor(t=[],r){f(this,"features");f(this,"disabledFeatures");this.features=new Set(t),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(t){var r;return!((r=this.disabledFeatures)!=null&&r[t])&&this.features.has(t)}}const Sr=class Sr{constructor(t){f(this,"id");f(this,"props");f(this,"userData",{});f(this,"statsManager",md);f(this,"_factories",{});f(this,"timestamp",0);f(this,"_reused",!1);f(this,"_moduleData",{});f(this,"_textureCaps",{});f(this,"_debugGPUTimeQuery",null);this.props={...Sr.defaultProps,...t},this.id=this.props.id||Nt(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(t){return vt.getVertexFormatInfo(t)}isVertexFormatSupported(t){return!0}getTextureFormatInfo(t){return re.getInfo(t)}getTextureFormatCapabilities(t){let r=this._textureCaps[t];if(!r){const i=this._getDeviceTextureFormatCapabilities(t);r=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[t]=r}return r}getMipLevelCount(t,r,i=1){const s=Math.max(t,r,i);return 1+Math.floor(Math.log2(s))}isExternalImage(t){return ws(t)}getExternalImageSize(t){return Ia(t)}isTextureFormatSupported(t){return this.getTextureFormatCapabilities(t).create}isTextureFormatFilterable(t){return this.getTextureFormatCapabilities(t).filter}isTextureFormatRenderable(t){return this.getTextureFormatCapabilities(t).render}isTextureFormatCompressed(t){return re.isCompressed(t)}getSupportedCompressedTextureFormats(){const t=[];for(const r of Object.keys(Id()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&t.push(r);return t}pushDebugGroup(t){this.commandEncoder.pushDebugGroup(t)}popDebugGroup(){var t;(t=this.commandEncoder)==null||t.popDebugGroup()}insertDebugMarker(t){var r;(r=this.commandEncoder)==null||r.insertDebugMarker(t)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(t,r,...i){if(!this.props.onError(t,r)){const n=Xd(r,i);return A.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",t.message,...n)}return()=>{}}debug(){if(this.props.debug)debugger;else A.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(t){return this.commandEncoder.beginRenderPass(t)}beginComputePass(t){return this.commandEncoder.beginComputePass(t)}generateMipmapsWebGPU(t){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(t){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(t,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(t,r,i,s,n){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(t=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:t}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(t,r){throw new Error("not implemented")}readPixelsToBufferWebGL(t,r){throw new Error("not implemented")}setParametersWebGL(t){throw new Error("not implemented")}getParametersWebGL(t){throw new Error("not implemented")}withParametersWebGL(t,r){throw new Error("not implemented")}clearWebGL(t){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(t){var r;return(r=this._moduleData)[t]||(r[t]={}),this._moduleData[t]}static _getCanvasContextProps(t){return t.createCanvasContext===!0?{}:t.createCanvasContext}_getDeviceTextureFormatCapabilities(t){const r=re.getCapabilities(t),i=n=>(typeof n=="string"?this.features.has(n):n)??!0,s=i(r.create);return{format:t,create:s,render:s&&i(r.render),filter:s&&i(r.filter),blend:s&&i(r.blend),store:s&&i(r.store)}}_normalizeBufferProps(t){(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const r={...t};if((t.usage||0)&N.INDEX&&(t.indexType||(t.data instanceof Uint32Array?r.indexType="uint32":t.data instanceof Uint16Array?r.indexType="uint16":t.data instanceof Uint8Array&&(r.data=new Uint16Array(t.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}};f(Sr,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(t,r)=>{},onResize:(t,r)=>{const[i,s]=t.getDevicePixelSize();A.log(1,`${t} resized => ${i}x${s}px`)()},onPositionChange:(t,r)=>{const[i,s]=t.getPosition();A.log(1,`${t} repositioned => ${i},${s}`)()},onVisibilityChange:t=>A.log(1,`${t} Visibility changed ${t.isVisible}`)(),onDevicePixelRatioChange:(t,r)=>A.log(1,`${t} DPR changed ${r.oldRatio} => ${t.devicePixelRatio}`)(),debug:Jd(),debugGPUTime:!1,debugShaders:A.get("debug-shaders")||void 0,debugFramebuffers:!!A.get("debug-framebuffers"),debugFactories:!!A.get("debug-factories"),debugWebGL:!!A.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let fr=Sr;function Zd(e,t){return e!=null?!!e:t!==void 0?t!=="production":!1}function Jd(){return Zd(A.get("debug"),Gd())}function Gd(){const e=globalThis.process;if(e!=null&&e.env)return e.env.NODE_ENV}class eg{constructor(t){f(this,"props");f(this,"_resizeObserver");f(this,"_intersectionObserver");f(this,"_observeDevicePixelRatioTimeout",null);f(this,"_observeDevicePixelRatioMediaQuery",null);f(this,"_handleDevicePixelRatioChange",()=>this._refreshDevicePixelRatio());f(this,"_trackPositionInterval",null);f(this,"_started",!1);this.props=t}get started(){return this._started}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||(this._intersectionObserver=new IntersectionObserver(t=>this.props.onIntersection(t))),this._resizeObserver||(this._resizeObserver=new ResizeObserver(t=>this.props.onResize(t))),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){var t,r;this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),(t=this._resizeObserver)==null||t.disconnect(),(r=this._intersectionObserver)==null||r.disconnect())}_refreshDevicePixelRatio(){var t;this._started&&(this.props.onDevicePixelRatioChange(),(t=this._observeDevicePixelRatioMediaQuery)==null||t.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(t=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},t))}}function tg(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}function Na(e,t){var r;if(!e){const i=new Error(t??"luma.gl assertion failed.");throw(r=Error.captureStackTrace)==null||r.call(Error,i,Na),i}}function Os(e,t){return Na(e,t),e}const Ye=class Ye{constructor(t){f(this,"id");f(this,"props");f(this,"canvas");f(this,"htmlCanvas");f(this,"offscreenCanvas");f(this,"type");f(this,"initialized");f(this,"isInitialized",!1);f(this,"isVisible",!0);f(this,"cssWidth");f(this,"cssHeight");f(this,"devicePixelRatio");f(this,"devicePixelWidth");f(this,"devicePixelHeight");f(this,"drawingBufferWidth");f(this,"drawingBufferHeight");f(this,"_initializedResolvers",tg());f(this,"_canvasObserver");f(this,"_position",[0,0]);f(this,"destroyed",!1);f(this,"_needsDrawingBufferResize",!0);var r,i;this.props={...Ye.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,it()?t.canvas?typeof t.canvas=="string"?this.canvas=ig(t.canvas):this.canvas=t.canvas:this.canvas=sg(t):this.canvas={width:t.width||1,height:t.height||1},Ye.isHTMLCanvas(this.canvas)?(this.id=t.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Ye.isOffscreenCanvas(this.canvas)?(this.id=t.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=t.id||"node-canvas-context",this.type="node"),this.cssWidth=((r=this.htmlCanvas)==null?void 0:r.clientWidth)||this.canvas.width,this.cssHeight=((i=this.htmlCanvas)==null?void 0:i.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new eg({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:s=>this._handleResize(s),onIntersection:s=>this._handleIntersection(s),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}static isHTMLCanvas(t){return typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement}static isOffscreenCanvas(t){return typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(t){return"useDevicePixels"in t&&(this.props.useDevicePixels=t.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(t){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(t)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const t=this.device.limits.maxTextureDimension2D;return[t,t]}setDrawingBufferSize(t,r){t=Math.floor(t),r=Math.floor(r),!(this.drawingBufferWidth===t&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=t,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(t,r=!0){const i=this.cssToDeviceRatio(),[s,n]=this.getDrawingBufferSize();return ng(t,i,s,n,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[t,r]=this.getDrawingBufferSize();return t>0&&r>0?t/r:1}cssToDeviceRatio(){try{const[t]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?t/r:1}catch{return 1}}resize(t){this.setDrawingBufferSize(t.width,t.height)}_setAutoCreatedCanvasId(t){var r;((r=this.htmlCanvas)==null?void 0:r.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=t)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(t){if(this.destroyed)return;const r=t.find(s=>s.target===this.canvas);if(!r)return;const i=r.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(t){var l,u,h,d,g;if(this.destroyed)return;const r=t.find(p=>p.target===this.canvas);if(!r)return;const i=Os((l=r.contentBoxSize)==null?void 0:l[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;const s=this.getDevicePixelSize(),n=((h=(u=r.devicePixelContentBoxSize)==null?void 0:u[0])==null?void 0:h.inlineSize)||i.inlineSize*devicePixelRatio,o=((g=(d=r.devicePixelContentBoxSize)==null?void 0:d[0])==null?void 0:g.blockSize)||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,a)),this.devicePixelHeight=Math.max(1,Math.min(o,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:s})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){const t=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*t,this.cssHeight*t)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){var r,i;if(this.destroyed||!this._canvasObserver.started)return;const t=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),(i=(r=this.device.props).onDevicePixelRatioChange)==null||i.call(r,this,{oldRatio:t})}updatePosition(){var r,i,s;if(this.destroyed)return;const t=(r=this.htmlCanvas)==null?void 0:r.getBoundingClientRect();if(t){const n=[t.left,t.top];if(this._position??(this._position=n),n[0]!==this._position[0]||n[1]!==this._position[1]){const a=this._position;this._position=n,(s=(i=this.device.props).onPositionChange)==null||s.call(i,this,{oldPosition:a})}}}};f(Ye,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let et=Ye;function rg(e){if(typeof e=="string"){const t=document.getElementById(e);if(!t)throw new Error(`${e} is not an HTML element`);return t}return e||document.body}function ig(e){const t=document.getElementById(e);if(!et.isHTMLCanvas(t))throw new Error("Object is not a canvas element");return t}function sg(e){const{width:t,height:r}=e,i=document.createElement("canvas");i.id=Nt("lumagl-auto-created-canvas"),i.width=t||1,i.height=r||1,i.style.width=Number.isFinite(t)?`${t}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",e!=null&&e.visible||(i.style.visibility="hidden");const s=rg((e==null?void 0:e.container)||null);return s.insertBefore(i,s.firstChild),i}function ng(e,t,r,i,s){const n=e,o=Dn(n[0],t,r);let a=Fn(n[1],t,i,s),c=Dn(n[0]+1,t,r);const l=c===r-1?c:c-1;c=Fn(n[1]+1,t,i,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function Dn(e,t,r){return Math.min(Math.round(e*t),r-1)}function Fn(e,t,r,i){return i?Math.max(0,r-1-Math.round(e*t)):Math.min(Math.round(e*t),r-1)}class Ba extends et{}f(Ba,"defaultProps",et.defaultProps);class og extends et{}const Rt=class Rt extends O{get[Symbol.toStringTag](){return"Sampler"}constructor(t,r){r=Rt.normalizeProps(t,r),super(t,r,Rt.defaultProps)}static normalizeProps(t,r){return r}};f(Rt,"defaultProps",{...O.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let tt=Rt;const ag={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},F=class F extends O{constructor(r,i,s){i=F.normalizeProps(r,i);super(r,i,F.defaultProps);f(this,"dimension");f(this,"baseDimension");f(this,"format");f(this,"width");f(this,"height");f(this,"depth");f(this,"mipLevels");f(this,"samples");f(this,"byteAlignment");f(this,"ready",Promise.resolve(this));f(this,"isReady",!0);f(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=ag[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(r.isExternalImage(i.data)){const n=r.getExternalImageSize(i.data);this.width=(n==null?void 0:n.width)||1,this.height=(n==null?void 0:n.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&A.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=(s==null?void 0:s.byteAlignment)||1,this.updateTimestamp=r.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}clone(r){return this.device.createTexture({...this.props,...r})}setSampler(r){this.sampler=r instanceof tt?r:this.device.createSampler(r)}copyImageData(r){const{data:i,depth:s,...n}=r;this.writeData(i,{...n,depthOrArrayLayers:n.depthOrArrayLayers??s})}computeMemoryLayout(r={}){const i=this._normalizeTextureReadOptions(r),{width:s=this.width,height:n=this.height,depthOrArrayLayers:o=this.depth}=i,{format:a,byteAlignment:c}=this;return re.computeMemoryLayout({format:a,width:s,height:n,depth:o,byteAlignment:c})}readBuffer(r,i){throw new Error("readBuffer not implemented")}readDataAsync(r){throw new Error("readBuffer not implemented")}writeBuffer(r,i){throw new Error("readBuffer not implemented")}writeData(r,i){throw new Error("readBuffer not implemented")}readDataSyncWebGL(r){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(r,i){const s={...i},{width:n,height:o}=s;return typeof n=="number"&&(s.width=Math.max(1,Math.ceil(n))),typeof o=="number"&&(s.height=Math.max(1,Math.ceil(o))),s}_initializeData(r){this.device.isExternalImage(r)?this.copyExternalImage({image:r,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):r&&this.copyImageData({data:r,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(r){const{data:i,depth:s,...n}=r,o=this._normalizeTextureWriteOptions({...n,depthOrArrayLayers:n.depthOrArrayLayers??s});return{data:i,depth:o.depthOrArrayLayers,...o}}_normalizeCopyExternalImageOptions(r){const i=F._omitUndefined(r),s=i.mipLevel??0,n=this._getMipLevelSize(s),o=this.device.getExternalImageSize(r.image),a={...F.defaultCopyExternalImageOptions,...n,...o,...i};return a.width=Math.min(a.width,n.width-a.x),a.height=Math.min(a.height,n.height-a.y),a.depth=Math.min(a.depth,n.depthOrArrayLayers-a.z),a}_normalizeTextureReadOptions(r){const i=F._omitUndefined(r),s=i.mipLevel??0,n=this._getMipLevelSize(s),o={...F.defaultTextureReadOptions,...n,...i};return o.width=Math.min(o.width,n.width-o.x),o.height=Math.min(o.height,n.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,n.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(r){const i=this._normalizeTextureReadOptions(r),s=re.getInfo(this.format);switch(this._validateColorReadAspect(i),this._validateColorReadFormat(s),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return i;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(r){if(r.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(r){if(r.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(r.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(r){const i=F._omitUndefined(r),s=i.mipLevel??0,n=this._getMipLevelSize(s),o={...F.defaultTextureWriteOptions,...n,...i};o.width=Math.min(o.width,n.width-o.x),o.height=Math.min(o.height,n.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,n.depthOrArrayLayers-o.z);const a=re.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),c=a.bytesPerPixel*o.width;if(o.bytesPerRow=i.bytesPerRow??a.bytesPerRow,o.rowsPerImage=i.rowsPerImage??o.height,o.bytesPerRow>r),s=this.baseDimension==="1d"?1:Math.max(1,this.height>>r),n=this.dimension==="3d"?Math.max(1,this.depth>>r):this.depth;return{width:i,height:s,depthOrArrayLayers:n}}getAllocatedByteLength(){let r=0;for(let i=0;ii!==void 0))}};f(F,"SAMPLE",4),f(F,"STORAGE",8),f(F,"RENDER",16),f(F,"COPY_SRC",1),f(F,"COPY_DST",2),f(F,"TEXTURE",4),f(F,"RENDER_ATTACHMENT",16),f(F,"defaultProps",{...O.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:F.SAMPLE|F.RENDER|F.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),f(F,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),f(F,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}),f(F,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),f(F,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"});let U=F;const Cr=class Cr extends O{get[Symbol.toStringTag](){return"TextureView"}constructor(t,r){super(t,r,Cr.defaultProps)}};f(Cr,"defaultProps",{...O.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let ur=Cr;function cg(e,t,r){let i="";const s=t.split(/\r?\n/),n=e.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((r==null?void 0:r.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++){const c=s[a-1],l=n[o];for(c&&l&&(i+=Da(c,a,r));n.length>o&&l.lineNum===a;){const u=n[o++];u&&(i+=gi(u,s,u.lineNum,{...r,inlineSource:!1}))}}for(;n.length>o;){const a=n[o++];a&&(i+=gi(a,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(const a of e)i+=gi(a,s,a.lineNum,{inlineSource:(r==null?void 0:r.showSourceCode)!=="no"});return i}}function gi(e,t,r,i){if(i!=null&&i.inlineSource){const n=lg(t,r),o=e.linePos>0?`${" ".repeat(e.linePos+5)}^^^ +`:"";return` +${n}${o}${e.type.toUpperCase()}: ${e.message} + +`}const s=e.type==="error"?"red":"orange";return i!=null&&i.html?`

${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function lg(e,t,r){let i="";for(let s=t-2;s<=t;s++){const n=e[s-1];n!==void 0&&(i+=Da(n,t,r))}return i}function Da(e,t,r){const i=r!=null&&r.html?ug(e):e;return`${fg(String(t),4)}: ${i}${r!=null&&r.html?"
":` +`}`}function fg(e,t){let r="";for(let i=e.length;i",">").replaceAll('"',""").replaceAll("'","'")}const vr=class vr extends O{constructor(r,i){i={...i,debugShaders:i.debugShaders||r.props.debugShaders||"errors"};super(r,{id:hg(i),...i},vr.defaultProps);f(this,"stage");f(this,"source");f(this,"compilationStatus","pending");this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const r=this.props.debugShaders;switch(r){case"never":return;case"errors":if(this.compilationStatus==="success")return;break}const i=await this.getCompilationInfo();r==="warnings"&&(i==null?void 0:i.length)===0||this._displayShaderLog(i,this.id)}_displayShaderLog(r,i){if(typeof document>"u"||!(document!=null&&document.createElement))return;const s=i,n=`${this.stage} shader "${s}"`,o=cg(r,this.source,{showSourceCode:"all",html:!0}),a=this.getTranslatedSource(),c=document.createElement("div");c.innerHTML=`

Compilation error in ${n}

+
+
+ +
+
${o}
`,a&&(c.innerHTML+=`

Translated Source



${a}
`),c.style.top="0",c.style.left="0",c.style.background="white",c.style.position="fixed",c.style.zIndex="9999",c.style.maxWidth="100vw",c.style.maxHeight="100vh",c.style.overflowY="auto",document.body.appendChild(c);const l=c.querySelector(".luma-compiler-log-error");l==null||l.scrollIntoView(),c.querySelector("button#close").onclick=()=>{c.remove()},c.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}};f(vr,"defaultProps",{...O.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let hr=vr;function hg(e){return dg(e.source)||e.id||Nt(`unnamed ${e.stage}-shader`)}function dg(e,t="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return(i==null?void 0:i[1])??t}const Pr=class Pr extends O{constructor(r,i={}){super(r,i,Pr.defaultProps);f(this,"width");f(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(r){const i=this.colorAttachments.map(n=>n.texture.clone(r)),s=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(r);return this.device.createFramebuffer({...this.props,...r,colorAttachments:i,depthStencilAttachment:s})}resize(r){let i=!r;if(r){const[s,n]=Array.isArray(r)?r:[r.width,r.height];i=i||n!==this.height||s!==this.width,this.width=s,this.height=n}i&&(A.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((i,s)=>{if(typeof i=="string"){const n=this.createColorTexture(i,s);return this.attachResource(n),n.view}return i instanceof U?i.view:i});const r=this.props.depthStencilAttachment;if(r)if(typeof r=="string"){const i=this.createDepthStencilTexture(r);this.attachResource(i),this.depthStencilAttachment=i.view}else r instanceof U?this.depthStencilAttachment=r.view:this.depthStencilAttachment=r}createColorTexture(r,i){return this.device.createTexture({id:`${this.id}-color-attachment-${i}`,usage:U.RENDER_ATTACHMENT,format:r,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(r){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:U.RENDER_ATTACHMENT,format:r,width:this.width,height:this.height})}resizeAttachments(r,i){if(this.colorAttachments.forEach((s,n)=>{const o=s.texture.clone({width:r,height:i});this.destroyAttachedResource(s),this.colorAttachments[n]=o.view,this.attachResource(o.view)}),this.depthStencilAttachment){const s=this.depthStencilAttachment.texture.clone({width:r,height:i});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=s.view,this.attachResource(s)}this.updateAttachments()}};f(Pr,"defaultProps",{...O.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let dr=Pr;const wr=class wr extends O{constructor(r,i){super(r,i,wr.defaultProps);f(this,"shaderLayout");f(this,"bufferLayout");f(this,"linkStatus","pending");f(this,"hash","");f(this,"sharedRenderPipeline",null);this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}get[Symbol.toStringTag](){return"RenderPipeline"}get isPending(){var r;return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||((r=this.fs)==null?void 0:r.compilationStatus)==="pending"}get isErrored(){var r;return this.linkStatus==="error"||this.vs.compilationStatus==="error"||((r=this.fs)==null?void 0:r.compilationStatus)==="error"}};f(wr,"defaultProps",{...O.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0});let _e=wr;class gg extends O{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(t,r){super(t,r,{...O.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}const Or=class Or extends O{constructor(r,i){super(r,i,Or.defaultProps);f(this,"hash","");f(this,"shaderLayout");this.shaderLayout=i.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};f(Or,"defaultProps",{...O.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let gr=Or;const xr=class xr{constructor(t){f(this,"device");f(this,"_hashCounter",0);f(this,"_hashes",{});f(this,"_renderPipelineCache",{});f(this,"_computePipelineCache",{});f(this,"_sharedRenderPipelineCache",{});this.device=t}static getDefaultPipelineFactory(t){const r=t.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||(r.defaultPipelineFactory=new xr(t)),r.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(t){var o;if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(t);const r={..._e.defaultProps,...t},i=this._renderPipelineCache,s=this._hashRenderPipeline(r);let n=(o=i[s])==null?void 0:o.resource;if(n)i[s].useCount++,this.device.props.debugFactories&&A.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${t.id})`)();else{const a=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;n=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:Nt("unnamed-cached"),_sharedRenderPipeline:a}),n.hash=s,i[s]={resource:n,useCount:1},this.device.props.debugFactories&&A.log(3,`${this}: ${n} created, count=${i[s].useCount}`)()}return n}createComputePipeline(t){var o;if(!this.device.props._cachePipelines)return this.device.createComputePipeline(t);const r={...gr.defaultProps,...t},i=this._computePipelineCache,s=this._hashComputePipeline(r);let n=(o=i[s])==null?void 0:o.resource;return n?(i[s].useCount++,this.device.props.debugFactories&&A.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${t.id})`)()):(n=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),n.hash=s,i[s]={resource:n,useCount:1},this.device.props.debugFactories&&A.log(3,`${this}: ${n} created, count=${i[s].useCount}`)()),n}release(t){if(!this.device.props._cachePipelines){t.destroy();return}const r=this._getCache(t),i=t.hash;r[i].useCount--,r[i].useCount===0?(this._destroyPipeline(t),this.device.props.debugFactories&&A.log(3,`${this}: ${t} released and destroyed`)()):r[i].useCount<0?(A.error(`${this}: ${t} released, useCount < 0, resetting`)(),r[i].useCount=0):this.device.props.debugFactories&&A.log(3,`${this}: ${t} released, count=${r[i].useCount}`)()}createSharedRenderPipeline(t){const r=this._hashSharedRenderPipeline(t);let i=this._sharedRenderPipelineCache[r];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(t),useCount:0},this._sharedRenderPipelineCache[r]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(t){if(!t.sharedRenderPipeline)return;const r=this._hashSharedRenderPipeline(t.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[r];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(t){const r=this._getCache(t);return this.device.props._destroyPipelines?(delete r[t.hash],t.destroy(),t instanceof _e&&this.releaseSharedRenderPipeline(t),!0):!1}_getCache(t){let r;if(t instanceof gr&&(r=this._computePipelineCache),t instanceof _e&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return r}_hashComputePipeline(t){const{type:r}=this.device,i=this._getHash(t.shader.source),s=this._getHash(JSON.stringify(t.shaderLayout));return`${r}/C/${i}SL${s}`}_hashRenderPipeline(t){const r=t.vs?this._getHash(t.vs.source):0,i=t.fs?this._getHash(t.fs.source):0,s=this._getWebGLVaryingHash(t),n=this._getHash(JSON.stringify(t.shaderLayout)),o=this._getHash(JSON.stringify(t.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":const c=this._getHash(JSON.stringify(t.parameters));return`${a}/R/${r}/${i}V${s}T${t.topology}P${c}SL${n}BL${o}`;case"webgpu":default:const l=this._getHash(JSON.stringify({vertexEntryPoint:t.vertexEntryPoint,fragmentEntryPoint:t.fragmentEntryPoint})),u=this._getHash(JSON.stringify(t.parameters)),h=this._getWebGPUAttachmentHash(t);return`${a}/R/${r}/${i}V${s}T${t.topology}EP${l}P${u}SL${n}BL${o}A${h}`}}_hashSharedRenderPipeline(t){const r=t.vs?this._getHash(t.vs.source):0,i=t.fs?this._getHash(t.fs.source):0,s=this._getWebGLVaryingHash(t);return`webgl/S/${r}/${i}V${s}`}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}_getWebGLVaryingHash(t){const{varyings:r=[],bufferMode:i=null}=t;return this._getHash(JSON.stringify({varyings:r,bufferMode:i}))}_getWebGPUAttachmentHash(t){var s;const r=t.colorAttachmentFormats??[this.device.preferredColorFormat],i=(s=t.parameters)!=null&&s.depthWriteEnabled?t.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:i}))}};f(xr,"defaultProps",{..._e.defaultProps});let Hi=xr;const Mr=class Mr{constructor(t){f(this,"device");f(this,"_cache",{});this.device=t}static getDefaultShaderFactory(t){const r=t.getModuleData("@luma.gl/core");return r.defaultShaderFactory||(r.defaultShaderFactory=new Mr(t)),r.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(t){if(!this.device.props._cacheShaders)return this.device.createShader(t);const r=this._hashShader(t);let i=this._cache[r];if(i)i.useCount++,this.device.props.debugFactories&&A.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{const s=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[r]=i={resource:s,useCount:1},this.device.props.debugFactories&&A.log(3,`${this}: Created new shader ${s.id}`)()}return i.resource}release(t){if(!this.device.props._cacheShaders){t.destroy();return}const r=this._hashShader(t),i=this._cache[r];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],i.resource.destroy(),this.device.props.debugFactories&&A.log(3,`${this}: Releasing shader ${t.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${t.id} released too many times`);this.device.props.debugFactories&&A.log(3,`${this}: Releasing shader ${t.id} count=${i.useCount}`)()}}_hashShader(t){return`${t.stage}:${t.source}`}};f(Mr,"defaultProps",{...hr.defaultProps});let Vi=Mr;function pg(e,t,r){const i=e.bindings.find(s=>s.name===t||`${s.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return i||A.warn(`Binding ${t} not set: Not found in shader layout.`)(),i||null}function Fa(e,t){if(!t)return{};if(_g(t))return Object.fromEntries(Object.entries(t).map(([s,n])=>[Number(s),{...n}]));const r={};for(const[i,s]of Object.entries(t)){const n=pg(e,i),o=(n==null?void 0:n.group)??0;r[o]||(r[o]={}),r[o][i]=s}return r}function Un(e){const t={};for(const r of Object.values(e))Object.assign(t,r);return t}function _g(e){const t=Object.keys(e);return t.length>0&&t.every(r=>/^\d+$/.test(r))}const te=class te extends O{get[Symbol.toStringTag](){return"RenderPass"}constructor(t,r){r=te.normalizeProps(t,r),super(t,r,te.defaultProps)}static normalizeProps(t,r){return r}};f(te,"defaultClearColor",[0,0,0,1]),f(te,"defaultClearDepth",1),f(te,"defaultClearStencil",0),f(te,"defaultProps",{...O.defaultProps,framebuffer:null,parameters:void 0,clearColor:te.defaultClearColor,clearColors:void 0,clearDepth:te.defaultClearDepth,clearStencil:te.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let Xi=te;const Ir=class Ir extends O{constructor(r,i){super(r,i,Ir.defaultProps);f(this,"_timeProfilingQuerySet",null);f(this,"_timeProfilingSlotCount",0);f(this,"_gpuTimeMs");this._timeProfilingQuerySet=i.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}get[Symbol.toStringTag](){return"CommandEncoder"}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;const r=Math.floor(this._timeProfilingSlotCount/2);if(r<=0)return;const i=r*2,s=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:i});let n=0n;for(let o=0;o=this._timeProfilingQuerySet.props.count?i:(this._timeProfilingSlotCount+=2,{...i,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:s,endTimestampIndex:s+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}};f(Ir,"defaultProps",{...O.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0});let Yi=Ir;const Nr=class Nr extends O{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(t,r){super(t,r,Nr.defaultProps)}};f(Nr,"defaultProps",{...O.defaultProps});let Ki=Nr;function xs(e){const t=Ms(e),r=Eg[t];if(!r)throw new Error(`Unsupported variable shader type: ${e}`);return r}function mg(e){const t=Ua(e),r=Rg[t];if(!r)throw new Error(`Unsupported attribute shader type: ${e}`);const[i,s]=r,n=i==="i32"||i==="u32",o=i!=="u32",a=yg[i]*s;return{primitiveType:i,components:s,byteLength:a,integer:n,signed:o}}class bg{getVariableShaderTypeInfo(t){return xs(t)}getAttributeShaderTypeInfo(t){return mg(t)}makeShaderAttributeType(t,r){return Tg(t,r)}resolveAttributeShaderTypeAlias(t){return Ua(t)}resolveVariableShaderTypeAlias(t){return Ms(t)}}function Tg(e,t){return t===1?e:`vec${t}<${e}>`}function Ua(e){return Sg[e]||e}function Ms(e){return Cg[e]||e}const Ag=new bg,yg={f32:4,f16:2,i32:4,u32:4},Rg={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Eg={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},Sg={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},Cg={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"};function La(e,t){const r={};for(const i of e.attributes){const s=Pg(e,t,i.name);s&&(r[i.name]=s)}return r}function vg(e,t,r=16){const i=La(e,t),s=new Array(r).fill(null);for(const n of Object.values(i))s[n.location]=n;return s}function Pg(e,t,r){const i=wg(e,r),s=Og(t,r);if(!i)return null;const n=Ag.getAttributeShaderTypeInfo(i.type),o=vt.getCompatibleVertexFormat(n),a=(s==null?void 0:s.vertexFormat)||o,c=vt.getVertexFormatInfo(a);return{attributeName:(s==null?void 0:s.attributeName)||i.name,bufferName:(s==null?void 0:s.bufferName)||i.name,location:i.location,shaderType:i.type,primitiveType:n.primitiveType,shaderComponents:n.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:n.integer,stepMode:(s==null?void 0:s.stepMode)||i.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function wg(e,t){const r=e.attributes.find(i=>i.name===t);return r||A.warn(`shader layout attribute "${t}" not present in shader`),r||null}function Og(e,t){xg(e);let r=Mg(e,t);return r||(r=Ig(e,t),r)?r:(A.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function xg(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&A.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Mg(e,t){for(const r of e)if(r.format&&r.name===t)return{attributeName:r.name,bufferName:t,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function Ig(e,t){var r;for(const i of e){let s=i.byteStride;if(typeof i.byteStride!="number")for(const o of i.attributes||[]){const a=vt.getVertexFormatInfo(o.format);s+=a.byteLength}const n=(r=i.attributes)==null?void 0:r.find(o=>o.attribute===t);if(n)return{attributeName:n.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:s}}return null}const Br=class Br extends O{constructor(r,i){super(r,i,Br.defaultProps);f(this,"maxVertexAttributes");f(this,"attributeInfos");f(this,"indexBuffer",null);f(this,"attributes");this.maxVertexAttributes=r.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=vg(i.shaderLayout,i.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(r,i){this.device.reportError(new Error("constant attributes not supported"),this)()}};f(Br,"defaultProps",{...O.defaultProps,shaderLayout:void 0,bufferLayout:[]});let Qi=Br;const Dr=class Dr extends O{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,r){super(t,r,Dr.defaultProps)}};f(Dr,"defaultProps",{...O.defaultProps,layout:void 0,buffers:{}});let qi=Dr;const Fr=class Fr extends O{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,r){super(t,r,Fr.defaultProps)}};f(Fr,"defaultProps",{...O.defaultProps,type:void 0,count:void 0});let Zi=Fr;const Ur=class Ur extends O{get[Symbol.toStringTag](){return"Fence"}constructor(t,r={}){super(t,r,Ur.defaultProps)}};f(Ur,"defaultProps",{...O.defaultProps});let Ji=Ur;function ce(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function ka(e){const[,,,,t]=Ng[e];return t}const Ng={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function Bg(e,t={}){const r={...e},i=t.layout??"std140",s={};let n=0;for(const[o,a]of Object.entries(r))n=Gi(s,o,a,n,i);return n=ce(n,Ae(r,i)),{layout:i,byteLength:n*4,uniformTypes:r,fields:s}}function jr(e,t){const r=Ms(e),i=xs(r),s=/^mat(\d)x(\d)<.+>$/.exec(r);if(s){const o=Number(s[1]),a=Number(s[2]),c=Ln(a,r,i.type),l=Fg(c.size,c.alignment,t);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:r,type:i.type}}const n=/^vec(\d)<.+>$/.exec(r);return n?Ln(Number(n[1]),r,i.type):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:i.type}}function Wa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Gi(e,t,r,i,s){if(typeof r=="string"){const n=jr(r,s),o=ce(i,n.alignment);return e[t]={offset:o,...n},o+n.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${t}`);const n=r[0],o=r[1],a=za(n,s),c=ce(i,Ae(r,s));for(let l=0;l=o.length)break;c===1?t[`${r}[${l}]`]=Number(o[u]):t[`${r}[${l}]`]=zg(n,u,u+c)}}_writeLeafValue(t,r,i){const s=this.layout.fields[r];if(!s){A.warn(`Uniform ${r} not found in layout`)();return}const{type:n,components:o,columns:a,rows:c,offset:l,columnStride:u}=s,h=t[n];if(o===1){h[l]=Number(i);return}const d=i;if(a===1){for(let p=0;pn)return!1;for(let o=0;on.type==="uniform"&&n.name===(t==null?void 0:t.name));if(!i)throw new Error(t==null?void 0:t.name);const s=i;for(const n of s.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(t){for(const[r,i]of Object.entries(t))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,r){Hg(this.uniforms[t],r)||(this.uniforms[t]=Vg(r),this.modifiedUniforms[t]=!0,this.modified=!0)}}const Yg=1024;class Kg{constructor(t,r){f(this,"device");f(this,"uniformBlocks",new Map);f(this,"shaderBlockLayouts",new Map);f(this,"shaderBlockWriters",new Map);f(this,"uniformBuffers",new Map);this.device=t;for(const[i,s]of Object.entries(r)){const n=i,o=Bg(s.uniformTypes??{},{layout:s.layout??Qg(t)}),a=new Wg(o);this.shaderBlockLayouts.set(n,o),this.shaderBlockWriters.set(n,a);const c=new Xg({name:i});c.setUniforms(a.getFlatUniformValues(s.defaultUniforms||{})),this.uniformBlocks.set(n,c)}}destroy(){for(const t of this.uniformBuffers.values())t.destroy()}setUniforms(t){var r;for(const[i,s]of Object.entries(t)){const n=i,o=this.shaderBlockWriters.get(n),a=o==null?void 0:o.getFlatUniformValues(s||{});(r=this.uniformBlocks.get(n))==null||r.setUniforms(a||{})}this.updateUniformBuffers()}getUniformBufferByteLength(t){var i;const r=((i=this.shaderBlockLayouts.get(t))==null?void 0:i.byteLength)||0;return Math.max(r,Yg)}getUniformBufferData(t){var s;const r=((s=this.uniformBlocks.get(t))==null?void 0:s.getAllUniforms())||{},i=this.shaderBlockWriters.get(t);return(i==null?void 0:i.getData(r))||new Uint8Array(0)}createUniformBuffer(t,r){r&&this.setUniforms(r);const i=this.getUniformBufferByteLength(t),s=this.device.createBuffer({usage:N.UNIFORM|N.COPY_DST,byteLength:i}),n=this.getUniformBufferData(t);return s.write(n),s}getManagedUniformBuffer(t){if(!this.uniformBuffers.get(t)){const r=this.getUniformBufferByteLength(t),i=this.device.createBuffer({usage:N.UNIFORM|N.COPY_DST,byteLength:r});this.uniformBuffers.set(t,i)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let t=!1;for(const r of this.uniformBlocks.keys()){const i=this.updateUniformBuffer(r);t||(t=i)}return t&&A.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(t){var n;const r=this.uniformBlocks.get(t);let i=this.uniformBuffers.get(t),s=!1;if(i&&(r!=null&&r.needsRedraw)){s||(s=r.needsRedraw);const o=this.getUniformBufferData(t);i=this.uniformBuffers.get(t),i==null||i.write(o);const a=(n=this.uniformBlocks.get(t))==null?void 0:n.getAllUniforms();A.log(4,`Writing to uniform buffer ${String(t)}`,o,a)()}return s}}function Qg(e){return e.type==="webgpu"?"wgsl-uniform":"std140"}const kn=`precision highp int; + +// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { + vec3 color; +}; + +struct PointLight { + vec3 color; + vec3 position; + vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +struct DirectionalLight { + vec3 color; + vec3 direction; +}; + +struct UniformLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +layout(std140) uniform lightingUniforms { + int enabled; + int directionalLightCount; + int pointLightCount; + int spotLightCount; + vec3 ambientColor; + UniformLight lights[5]; +} lighting; + +PointLight lighting_getPointLight(int index) { + UniformLight light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +SpotLight lighting_getSpotLight(int index) { + UniformLight light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +DirectionalLight lighting_getDirectionalLight(int index) { + UniformLight light = + lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +float getPointLightAttenuation(PointLight pointLight, float distance) { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { + vec3 light_direction = normalize(positionWorldspace - spotLight.position); + float coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), light_direction) + ); + float distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} + +// #endif +`,qg=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +const MAX_LIGHTS: i32 = 5; + +struct AmbientLight { + color: vec3, +}; + +struct PointLight { + color: vec3, + position: vec3, + attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct DirectionalLight { + color: vec3, + direction: vec3, +}; + +struct UniformLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct lightingUniforms { + enabled: i32, + directionalLightCount: i32, + pointLightCount: i32, + spotLightCount: i32, + ambientColor: vec3, + lights: array, +}; + +@group(2) @binding(auto) var lighting : lightingUniforms; + +fn lighting_getPointLight(index: i32) -> PointLight { + let light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +fn lighting_getSpotLight(index: i32) -> SpotLight { + let light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { + let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) -> f32 { + let lightDirection = normalize(positionWorldspace - spotLight.position); + let coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), lightDirection) + ); + let distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} +`,ye=5,Zg={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},Va={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[Zg,ye]},defaultUniforms:er(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:qg,vs:kn,fs:kn,getUniforms:Jg};function Jg(e,t={}){if(e=e&&{...e},!e)return er();e.lights&&(e={...e,...ep(e.lights),lights:void 0});const{useByteColors:r,ambientLight:i,pointLights:s,spotLights:n,directionalLights:o}=e||{};if(!(i||s&&s.length>0||n&&n.length>0||o&&o.length>0))return{...er(),enabled:0};const c={...er(),...Gg({useByteColors:r,ambientLight:i,pointLights:s,spotLights:n,directionalLights:o})};return e.enabled!==void 0&&(c.enabled=e.enabled?1:0),c}function Gg({useByteColors:e,ambientLight:t,pointLights:r=[],spotLights:i=[],directionalLights:s=[]}){const n=Xa();let o=0,a=0,c=0,l=0;for(const u of r){if(o>=ye)break;n[o]={...n[o],color:Ht(u,e),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(const u of i){if(o>=ye)break;n[o]={...n[o],color:Ht(u,e),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:rp(u)},o++,c++}for(const u of s){if(o>=ye)break;n[o]={...n[o],color:Ht(u,e),direction:u.direction},o++,l++}return r.length+i.length+s.length>ye&&A.warn(`MAX_LIGHTS exceeded, truncating to ${ye}`)(),{ambientColor:Ht(t,e),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:n}}function ep(e){var r,i,s;const t={pointLights:[],spotLights:[],directionalLights:[]};for(const n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":(r=t.directionalLights)==null||r.push(n);break;case"point":(i=t.pointLights)==null||i.push(n);break;case"spot":(s=t.spotLights)==null||s.push(n);break}return t}function Ht(e={},t){const{color:r=[0,0,0],intensity:i=1}=e;return Pa(r,va(t,!0)).map(n=>n*i)}function er(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Xa()}}function Xa(){return Array.from({length:ye},()=>tp())}function tp(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function rp(e){const t=e.innerConeAngle??0,r=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(r)]}const Ya=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; +`,Ka=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { + vec3 halfway_direction = normalize(light_direction + view_direction); + float lambertian = dot(light_direction, normal_worldspace); + float specular = 0.0; + if (lambertian > 0.0) { + float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, material.shininess); + } + lambertian = max(lambertian, 0.0); + return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color; +} + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { + vec3 lightColor = surfaceColor; + + if (material.unlit) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + vec3 view_direction = normalize(cameraPosition - position_worldspace); + lightColor = material.ambient * surfaceColor * lighting.ambientColor; + + for (int i = 0; i < lighting.pointLightCount; i++) { + PointLight pointLight = lighting_getPointLight(i); + vec3 light_position_worldspace = pointLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.spotLightCount; i++) { + SpotLight spotLight = lighting_getSpotLight(i); + vec3 light_position_worldspace = spotLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.directionalLightCount; i++) { + DirectionalLight directionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} +`,Qa=`struct phongMaterialUniforms { + unlit: u32, + ambient: f32, + diffuse: f32, + shininess: f32, + specularColor: vec3, +}; + +@group(3) @binding(auto) var phongMaterial : phongMaterialUniforms; + +fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { + let halfway_direction: vec3 = normalize(light_direction + view_direction); + var lambertian: f32 = dot(light_direction, normal_worldspace); + var specular: f32 = 0.0; + if (lambertian > 0.0) { + let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, phongMaterial.shininess); + } + lambertian = max(lambertian, 0.0); + return ( + lambertian * phongMaterial.diffuse * surfaceColor + + specular * floatColors_normalize(phongMaterial.specularColor) + ) * color; +} + +fn lighting_getLightColor2(surfaceColor: vec3, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { + var lightColor: vec3 = surfaceColor; + + if (phongMaterial.unlit != 0u) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + let view_direction: vec3 = normalize(cameraPosition - position_worldspace); + lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor; + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} + +fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ + var lightColor = vec3(0, 0, 0); + let surfaceColor = vec3(0, 0, 0); + + if (lighting.enabled != 0) { + let view_direction = normalize(cameraPosition - position_worldspace); + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + } + return lightColor; +} +`,ip=[38.25,38.25,38.25],sp={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ka.replace("phongMaterial","gouraudMaterial"),fs:Ya.replace("phongMaterial","gouraudMaterial"),source:Qa.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Va,wa],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:ip},getUniforms(e){return{...sp.defaultUniforms,...e}}},np=[38.25,38.25,38.25],op={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[Va,wa],source:Qa,vs:Ya,fs:Ka,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:np},getUniforms(e){return{...op.defaultUniforms,...e}}},ap=` + +@must_use +fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { + return vec4(fragColor.rgb * fragColor.a, fragColor.a); +}; +`,MA={name:"color",dependencies:[],source:ap,getUniforms:e=>({})},cp=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; + +struct VertexGeometry { + position: vec4, + worldPosition: vec3, + worldPositionAlt: vec3, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry_: VertexGeometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec2(0.0, 0.0), + vec3(0.0, 0.0, 0.0) +); + +struct FragmentGeometry { + uv: vec2, +}; + +var fragmentGeometry: FragmentGeometry; + +fn smoothedge(edge: f32, x: f32) -> f32 { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,qa="#define SMOOTH_EDGE_RADIUS 0.5",lp=`${qa} + +struct VertexGeometry { + vec4 position; + vec3 worldPosition; + vec3 worldPositionAlt; + vec3 normal; + vec2 uv; + vec3 pickingColor; +} geometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0), + vec3(0.0), + vec3(0.0), + vec2(0.0), + vec3(0.0) +); +`,fp=`${qa} + +struct FragmentGeometry { + vec2 uv; +} geometry; + +float smoothedge(float edge, float x) { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,up={name:"geometry",source:cp,vs:lp,fs:fp},hp=25;var W;(function(e){e[e.Start=1]="Start",e[e.Move=2]="Move",e[e.End=4]="End",e[e.Cancel=8]="Cancel"})(W||(W={}));var $;(function(e){e[e.None=0]="None",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Up=4]="Up",e[e.Down=8]="Down",e[e.Horizontal=3]="Horizontal",e[e.Vertical=12]="Vertical",e[e.All=15]="All"})($||($={}));var P;(function(e){e[e.Possible=1]="Possible",e[e.Began=2]="Began",e[e.Changed=4]="Changed",e[e.Ended=8]="Ended",e[e.Recognized=8]="Recognized",e[e.Cancelled=16]="Cancelled",e[e.Failed=32]="Failed"})(P||(P={}));const IA="compute",NA="auto",dp="manipulation",gp="none",pp="pan-x",_p="pan-y";function Za(e){return e.trim().split(/\s+/g)}function pi(e,t,r){if(e)for(const i of Za(t))e.addEventListener(i,r,!1)}function _i(e,t,r){if(e)for(const i of Za(t))e.removeEventListener(i,r,!1)}function Wn(e){return(e.ownerDocument||e).defaultView}function mp(e,t){let r=e;for(;r;){if(r===t)return!0;r=r.parentNode}return!1}function Ja(e){const t=e.length;if(t===1)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let r=0,i=0,s=0;for(;s=Math.abs(t)?e<0?$.Left:$.Right:t<0?$.Up:$.Down}function Tp(e,t){const r=t.center;let i=e.offsetDelta,s=e.prevDelta;const n=e.prevInput;return(t.eventType===W.Start||(n==null?void 0:n.eventType)===W.End)&&(s=e.prevDelta={x:(n==null?void 0:n.deltaX)||0,y:(n==null?void 0:n.deltaY)||0},i=e.offsetDelta={x:r.x,y:r.y}),{deltaX:s.x+(r.x-i.x),deltaY:s.y+(r.y-i.y)}}function tc(e,t,r){return{x:t/e||0,y:r/e||0}}function Ap(e,t){return zn(t[0],t[1])/zn(e[0],e[1])}function yp(e,t){return jn(t[1],t[0])-jn(e[1],e[0])}function Rp(e,t){const r=e.lastInterval||t,i=t.timeStamp-r.timeStamp;let s,n,o,a;if(t.eventType!==W.Cancel&&(i>hp||r.velocity===void 0)){const c=t.deltaX-r.deltaX,l=t.deltaY-r.deltaY,u=tc(i,c,l);n=u.x,o=u.y,s=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=ec(c,l),e.lastInterval=t}else s=r.velocity,n=r.velocityX,o=r.velocityY,a=r.direction;t.velocity=s,t.velocityX=n,t.velocityY=o,t.direction=a}function Ep(e,t){const{session:r}=e,{pointers:i}=t,{length:s}=i;r.firstInput||(r.firstInput=$n(t)),s>1&&!r.firstMultiple?r.firstMultiple=$n(t):s===1&&(r.firstMultiple=!1);const{firstInput:n,firstMultiple:o}=r,a=o?o.center:n.center,c=t.center=Ja(i);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-n.timeStamp,t.angle=bp(a,c),t.distance=Ga(a,c);const{deltaX:l,deltaY:u}=Tp(r,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=ec(t.deltaX,t.deltaY);const h=tc(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=h.x,t.overallVelocityY=h.y,t.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,t.scale=o?Ap(o.pointers,i):1,t.rotation=o?yp(o.pointers,i):0,t.maxPointers=r.prevInput?t.pointers.length>r.prevInput.maxPointers?t.pointers.length:r.prevInput.maxPointers:t.pointers.length;let d=e.element;return mp(t.srcEvent.target,d)&&(d=t.srcEvent.target),t.target=d,Rp(r,t),t}function Sp(e,t,r){const i=r.pointers.length,s=r.changedPointers.length,n=t&W.Start&&i-s===0,o=t&(W.End|W.Cancel)&&i-s===0;r.isFirst=!!n,r.isFinal=!!o,n&&(e.session={}),r.eventType=t;const a=Ep(e,r);e.emit("hammer.input",a),e.recognize(a),e.session.prevInput=a}let Cp=class{constructor(t){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=t,this.element=t.element,this.target=t.options.inputTarget||t.element}callback(t,r){Sp(this.manager,t,r)}init(){pi(this.element,this.evEl,this.domHandler),pi(this.target,this.evTarget,this.domHandler),pi(Wn(this.element),this.evWin,this.domHandler)}destroy(){_i(this.element,this.evEl,this.domHandler),_i(this.target,this.evTarget,this.domHandler),_i(Wn(this.element),this.evWin,this.domHandler)}};const vp={pointerdown:W.Start,pointermove:W.Move,pointerup:W.End,pointercancel:W.Cancel,pointerout:W.Cancel},Pp="pointerdown",wp="pointermove pointerup pointercancel";class DA extends Cp{constructor(t){super(t),this.evEl=Pp,this.evWin=wp,this.store=this.manager.session.pointerEvents=[],this.init()}handler(t){const{store:r}=this;let i=!1;const s=vp[t.type],n=t.pointerType,o=n==="touch";let a=r.findIndex(c=>c.pointerId===t.pointerId);s&W.Start&&(t.buttons||o)?a<0&&(r.push(t),a=r.length-1):s&(W.End|W.Cancel)&&(i=!0),!(a<0)&&(r[a]=t,this.callback(s,{pointers:r,changedPointers:[t],eventType:s,pointerType:n,srcEvent:t}),i&&r.splice(a,1))}}let Op=1;function xp(){return Op++}function Hn(e){return e&P.Cancelled?"cancel":e&P.Ended?"end":e&P.Changed?"move":e&P.Began?"start":""}class rc{constructor(t){this.options=t,this.id=xp(),this.state=P.Possible,this.simultaneous={},this.requireFail=[]}set(t){return Object.assign(this.options,t),this.manager.touchAction.update(),this}recognizeWith(t){if(Array.isArray(t)){for(const s of t)this.recognizeWith(s);return this}let r;if(typeof t=="string"){if(r=this.manager.get(t),!r)throw new Error(`Cannot find recognizer ${t}`)}else r=t;const{simultaneous:i}=this;return i[r.id]||(i[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(t){if(Array.isArray(t)){for(const i of t)this.dropRecognizeWith(i);return this}let r;return typeof t=="string"?r=this.manager.get(t):r=t,r&&delete this.simultaneous[r.id],this}requireFailure(t){if(Array.isArray(t)){for(const s of t)this.requireFailure(s);return this}let r;if(typeof t=="string"){if(r=this.manager.get(t),!r)throw new Error(`Cannot find recognizer ${t}`)}else r=t;const{requireFail:i}=this;return i.indexOf(r)===-1&&(i.push(r),r.requireFailure(this)),this}dropRequireFailure(t){if(Array.isArray(t)){for(const i of t)this.dropRequireFailure(i);return this}let r;if(typeof t=="string"?r=this.manager.get(t):r=t,r){const i=this.requireFail.indexOf(r);i>-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(t=>t.options.enable)}canRecognizeWith(t){return!!this.simultaneous[t.id]}emit(t){if(!t)return;const{state:r}=this;r=P.Ended&&this.manager.emit(this.options.event+Hn(r),t)}tryEmit(t){this.canEmit()?this.emit(t):this.state=P.Failed}canEmit(){let t=0;for(;t{this.state=P.Recognized,this.tryEmit(this._input)},r.interval),P.Began):P.Recognized}return P.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=P.Failed},this.options.interval),P.Failed}reset(){clearTimeout(this._timer)}emit(t){this.state===P.Recognized&&(t.tapCount=this.count,this.manager.emit(this.options.event,t))}}const Mp=["","start","move","end","cancel","up","down","left","right"];class Xn extends ic{constructor(t={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:$.All,...t}),this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:t}}=this,r=[];return t&$.Horizontal&&r.push(_p),t&$.Vertical&&r.push(pp),r}getEventNames(){return Mp.map(t=>this.options.event+t)}directionTest(t){const{options:r}=this;let i=!0,{distance:s}=t,{direction:n}=t;const o=t.deltaX,a=t.deltaY;return n&r.direction||(r.direction&$.Horizontal?(n=o===0?$.None:o<0?$.Left:$.Right,i=o!==this.pX,s=Math.abs(t.deltaX)):(n=a===0?$.None:a<0?$.Up:$.Down,i=a!==this.pY,s=Math.abs(t.deltaY))),t.direction=n,i&&s>r.threshold&&!!(n&r.direction)}attrTest(t){return super.attrTest(t)&&(!!(this.state&P.Began)||!(this.state&P.Began)&&this.directionTest(t))}emit(t){this.pX=t.deltaX,this.pY=t.deltaY;const r=$[t.direction].toLowerCase();r&&(t.additionalEvent=this.options.event+r),super.emit(t)}}const Ip=["","start","move","end","cancel","in","out"];class Np extends ic{constructor(t={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...t})}getTouchAction(){return[gp]}getEventNames(){return Ip.map(t=>this.options.event+t)}attrTest(t){return super.attrTest(t)&&(Math.abs(t.scale-1)>this.options.threshold||!!(this.state&P.Began))}emit(t){if(t.scale!==1){const r=t.scale<1?"in":"out";t.additionalEvent=this.options.event+r}super.emit(t)}}class Bp{constructor(t,r,i){this.element=t,this.callback=r,this.options=i}}const Dp=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Fp=Dp.indexOf("firefox")!==-1,Yn=4.000244140625,Up=40,Lp=.25;class FA extends Bp{constructor(t,r,i){super(t,r,{enable:!0,...i}),this.handleEvent=s=>{if(!this.options.enable)return;let n=s.deltaY;globalThis.WheelEvent&&(Fp&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(n/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(n*=Up)),n!==0&&n%Yn===0&&(n=Math.floor(n/Yn)),s.shiftKey&&n&&(n=n*Lp),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-n,srcEvent:s,pointerType:"mouse",target:s.target})},t.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(t,r){t==="wheel"&&(this.options.enable=r)}}const Kn={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Kn,"IDENTITY",{get:()=>(G.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Kn.CARTESIAN)});const ie={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},_r={common:0,meters:1,pixels:2},UA={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},LA={multipan:[Xn,{threshold:10,direction:$.Vertical,pointers:2}],pinch:[Np,{},null,["multipan"]],pan:[Xn,{threshold:1},["pinch"],["multipan"]],dblclick:[Vn,{event:"dblclick",taps:2}],click:[Vn,{event:"click"},null,["dblclick"]]},kA={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function kp(e,t){if(e===t)return!0;if(Array.isArray(e)){const r=e.length;if(!t||t.length!==r)return!1;for(let i=0;i{for(const s in i)if(!kp(i[s],t[s])){r=e(i),t=i;break}return r}}const Qn=[0,0,0,0],Wp=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],sc=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],$p=[0,0,0],nc=[0,0,0],zp={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Ns(e){const t=zp[e];if(t===void 0)throw new Error(`Invalid coordinateSystem: ${e}`);return t}const jp=Is(Xp);function oc(e,t,r=nc){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,n=!0;switch(t==="lnglat-offsets"||t==="meter-offsets"?s=r:s=e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case ie.WEB_MERCATOR:(t==="lnglat"||t==="cartesian")&&(s=[0,0,0],n=!1);break;case ie.WEB_MERCATOR_AUTO_OFFSET:t==="lnglat"?i=s:t==="cartesian"&&(i=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],s=e.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case ie.IDENTITY:i=e.position.map(Math.fround),i[2]=i[2]||0;break;case ie.GLOBE:n=!1,s=null;break;default:n=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:n}}function Hp(e,t,r){const{viewMatrixUncentered:i,projectionMatrix:s}=e;let{viewMatrix:n,viewProjectionMatrix:o}=e,a=Qn,c=Qn,l=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=oc(e,t,r);return d&&(c=e.projectPosition(u||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=It([],c,o),n=i||n,o=ve([],s,n),o=ve([],o,Wp)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:u}}function Vp({viewport:e,devicePixelRatio:t=1,modelMatrix:r=null,coordinateSystem:i="default",coordinateOrigin:s=nc,autoWrapLongitude:n=!1}){i==="default"&&(i=e.isGeospatial?"lnglat":"cartesian");const o=jp({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:s});return o.wrapLongitude=n,o.modelMatrix=r||sc,o}function Xp({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i}){const{projectionCenter:s,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=Hp(e,r,i),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=It([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,g={coordinateSystem:Ns(r),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:s,pseudoMeters:!!e._pseudoMeters,viewportSize:h,devicePixelRatio:t,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:$p,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:n,modelMatrix:sc,cameraPosition:a};if(l){const p=e.getDistanceScales(l);switch(r){case"meter-offsets":g.commonUnitsPerWorldUnit=p.unitsPerMeter,g.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":e._pseudoMeters||(g.commonUnitsPerMeter=p.unitsPerMeter),g.commonUnitsPerWorldUnit=p.unitsPerDegree,g.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":g.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],g.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break}}return g}const Yp=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],Kp=Yp.map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")}: i32 = ${Ns(e)};`).join(""),Qp=Object.keys(ie).map(e=>`const PROJECTION_MODE_${e}: i32 = ${ie[e]};`).join(""),qp=Object.keys(_r).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${_r[e]};`).join(""),Zp=`${Kp} +${Qp} +${qp} + +const TILE_SIZE: f32 = 512.0; +const PI: f32 = 3.1415926536; +const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0); +const ZERO_64_LOW: vec3 = vec3(0.0, 0.0, 0.0); +const EARTH_RADIUS: f32 = 6370972.0; // meters +const GLOBE_RADIUS: f32 = 256.0; + +// ----------------------------------------------------------------------------- +// Uniform block (converted from GLSL uniform block) +// ----------------------------------------------------------------------------- +struct ProjectUniforms { + wrapLongitude: i32, + coordinateSystem: i32, + commonUnitsPerMeter: vec3, + projectionMode: i32, + scale: f32, + commonUnitsPerWorldUnit: vec3, + commonUnitsPerWorldUnit2: vec3, + center: vec4, + modelMatrix: mat4x4, + viewProjectionMatrix: mat4x4, + viewportSize: vec2, + devicePixelRatio: f32, + focalDistance: f32, + cameraPosition: vec3, + coordinateOrigin: vec3, + commonOrigin: vec3, + pseudoMeters: i32, +}; + +@group(0) @binding(auto) +var project: ProjectUniforms; + +// ----------------------------------------------------------------------------- +// Geometry data shared across the project helpers. +// The active layer shader is responsible for populating this private module +// state before calling the project functions below. +// ----------------------------------------------------------------------------- + +// Structure to carry additional geometry data used by deck.gl filters. +struct Geometry { + worldPosition: vec3, + worldPositionAlt: vec3, + position: vec4, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry: Geometry; +`,Jp=`${Zp} + +// ----------------------------------------------------------------------------- +// Functions +// ----------------------------------------------------------------------------- + +// Returns an adjustment factor for commonUnitsPerMeter +fn _project_size_at_latitude(lat: f32) -> f32 { + let y = clamp(lat, -89.9, 89.9); + return 1.0 / cos(radians(y)); +} + +// Overloaded version: scales a value in meters at a given latitude. +fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat); +} + +// Computes a non-linear scale factor based on geometry. +// (Note: This function relies on "geometry" being provided.) +fn project_size() -> f32 { + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && + project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && + project.pseudoMeters == 0) { + if (geometry.position.w == 0.0) { + return _project_size_at_latitude(geometry.worldPosition.y); + } + let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0; + let y2 = y * y; + let y4 = y2 * y2; + let y6 = y4 * y2; + return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; + } + return 1.0; +} + +// Overloads to scale offsets (meters to world units) +fn project_size_float(meters: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * project_size(); +} + +fn project_size_vec2(meters: vec2) -> vec2 { + return meters * project.commonUnitsPerMeter.xy * project_size(); +} + +fn project_size_vec3(meters: vec3) -> vec3 { + return meters * project.commonUnitsPerMeter * project_size(); +} + +fn project_size_vec4(meters: vec4) -> vec4 { + return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} + +// Returns a rotation matrix aligning the z‑axis with the given up vector. +fn project_get_orientation_matrix(up: vec3) -> mat3x3 { + let uz = normalize(up); + let ux = select( + vec3(1.0, 0.0, 0.0), + normalize(vec3(uz.y, -uz.x, 0.0)), + abs(uz.z) == 1.0 + ); + let uy = cross(uz, ux); + return mat3x3(ux, uy, uz); +} + +// Since WGSL does not support "out" parameters, we return a struct. +struct RotationResult { + needsRotation: bool, + transform: mat3x3, +}; + +fn project_needs_rotation(commonPosition: vec3) -> RotationResult { + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + return RotationResult(true, project_get_orientation_matrix(commonPosition)); + } else { + return RotationResult(false, mat3x3()); // identity alternative if needed + }; +} + +// Projects a normal vector from the current coordinate system to world space. +fn project_normal(vector: vec3) -> vec3 { + let normal_modelspace = project.modelMatrix * vec4(vector, 0.0); + var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); + let rotResult = project_needs_rotation(geometry.position.xyz); + if (rotResult.needsRotation) { + n = rotResult.transform * n; + } + return n; +} + +// Applies a scale offset based on y-offset (dy) +fn project_offset_(offset: vec4) -> vec4 { + let dy: f32 = offset.y; + let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; + return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} + +// Projects lng/lat coordinates to a unit tile [0,1] +fn project_mercator_(lnglat: vec2) -> vec2 { + var x = lnglat.x; + if (project.wrapLongitude != 0) { + x = ((x + 180.0) % 360.0) - 180.0; + } + let y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// Projects lng/lat/z coordinates for a globe projection. +fn project_globe_(lnglatz: vec3) -> vec3 { + let lambda = radians(lnglatz.x); + let phi = radians(lnglatz.y); + let cosPhi = cos(phi); + let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; + return vec3( + sin(lambda) * cosPhi, + -cos(lambda) * cosPhi, + sin(phi) + ) * D; +} + +// Projects positions (with an optional 64-bit low part) from the input +// coordinate system to the common space. +fn project_position_vec4_f64(position: vec4, position64Low: vec3) -> vec4 { + var position_world = project.modelMatrix * position; + + // Work around for a Mac+NVIDIA bug: + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_mercator_(position_world.xy), + _project_size_at_latitude_m(position_world.z, position_world.y), + position_world.w + ); + } + if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { + position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w); + } + } + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_globe_(position_world.xyz), + position_world.w + ); + } + } + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { + return vec4( + project_mercator_(position_world.xy) - project.commonOrigin.xy, + project_size_float(position_world.z), + position_world.w + ); + } + } + } + if (project.projectionMode == PROJECTION_MODE_IDENTITY || + (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && + (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || + project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { + position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w); + } + + return project_offset_(position_world) + + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} + +// Overloaded versions for different input types. +fn project_position_vec4_f32(position: vec4) -> vec4 { + return project_position_vec4_f64(position, ZERO_64_LOW); +} + +fn project_position_vec3_f64(position: vec3, position64Low: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), position64Low); + return projected_position.xyz; +} + +fn project_position_vec3_f32(position: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), ZERO_64_LOW); + return projected_position.xyz; +} + +fn project_position_vec2_f32(position: vec2) -> vec2 { + let projected_position = project_position_vec4_f64(vec4(position, 0.0, 1.0), ZERO_64_LOW); + return projected_position.xy; +} + +// Transforms a common space position to clip space. +fn project_common_position_to_clipspace_with_projection(position: vec4, viewProjectionMatrix: mat4x4, center: vec4) -> vec4 { + return viewProjectionMatrix * position + center; +} + +// Uses the project viewProjectionMatrix and center. +fn project_common_position_to_clipspace(position: vec4) -> vec4 { + return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center); +} + +// Returns a clip space offset corresponding to a given number of screen pixels. +fn project_pixel_size_to_clipspace(pixels: vec2) -> vec2 { + let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; + return offset * project.focalDistance; +} + +fn project_meter_size_to_pixel(meters: f32) -> f32 { + return project_size_float(meters) * project.scale; +} + +fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 { + if (unit == UNIT_METERS) { + return project_meter_size_to_pixel(size); + } else if (unit == UNIT_COMMON) { + return size * project.scale; + } + // UNIT_PIXELS: no scaling applied. + return size; +} + +fn project_pixel_size_float(pixels: f32) -> f32 { + return pixels / project.scale; +} + +fn project_pixel_size_vec2(pixels: vec2) -> vec2 { + return pixels / project.scale; +} +`,Gp=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],e_=Gp.map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")} = ${Ns(e)};`).join(""),t_=Object.keys(ie).map(e=>`const int PROJECTION_MODE_${e} = ${ie[e]};`).join(""),r_=Object.keys(_r).map(e=>`const int UNIT_${e.toUpperCase()} = ${_r[e]};`).join(""),i_=`${e_} +${t_} +${r_} +layout(std140) uniform projectUniforms { +bool wrapLongitude; +int coordinateSystem; +vec3 commonUnitsPerMeter; +int projectionMode; +float scale; +vec3 commonUnitsPerWorldUnit; +vec3 commonUnitsPerWorldUnit2; +vec4 center; +mat4 modelMatrix; +mat4 viewProjectionMatrix; +vec2 viewportSize; +float devicePixelRatio; +float focalDistance; +vec3 cameraPosition; +vec3 coordinateOrigin; +vec3 commonOrigin; +bool pseudoMeters; +} project; +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); +const vec3 ZERO_64_LOW = vec3(0.0); +const float EARTH_RADIUS = 6370972.0; +const float GLOBE_RADIUS = 256.0; +float project_size_at_latitude(float lat) { +float y = clamp(lat, -89.9, 89.9); +return 1.0 / cos(radians(y)); +} +float project_size() { +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && +project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && +project.pseudoMeters == false) { +if (geometry.position.w == 0.0) { +return project_size_at_latitude(geometry.worldPosition.y); +} +float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; +float y2 = y * y; +float y4 = y2 * y2; +float y6 = y4 * y2; +return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; +} +return 1.0; +} +float project_size_at_latitude(float meters, float lat) { +return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat); +} +float project_size(float meters) { +return meters * project.commonUnitsPerMeter.z * project_size(); +} +vec2 project_size(vec2 meters) { +return meters * project.commonUnitsPerMeter.xy * project_size(); +} +vec3 project_size(vec3 meters) { +return meters * project.commonUnitsPerMeter * project_size(); +} +vec4 project_size(vec4 meters) { +return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} +mat3 project_get_orientation_matrix(vec3 up) { +vec3 uz = normalize(up); +vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); +vec3 uy = cross(uz, ux); +return mat3(ux, uy, uz); +} +bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +transform = project_get_orientation_matrix(commonPosition); +return true; +} +return false; +} +vec3 project_normal(vec3 vector) { +vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0); +vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); +mat3 rotation; +if (project_needs_rotation(geometry.position.xyz, rotation)) { +n = rotation * n; +} +return n; +} +vec4 project_offset_(vec4 offset) { +float dy = offset.y; +vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; +return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} +vec2 project_mercator_(vec2 lnglat) { +float x = lnglat.x; +if (project.wrapLongitude) { +x = mod(x + 180., 360.0) - 180.; +} +float y = clamp(lnglat.y, -89.9, 89.9); +return vec2( +radians(x) + PI, +PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) +) * WORLD_SCALE; +} +vec3 project_globe_(vec3 lnglatz) { +float lambda = radians(lnglatz.x); +float phi = radians(lnglatz.y); +float cosPhi = cos(phi); +float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; +return vec3( +sin(lambda) * cosPhi, +-cos(lambda) * cosPhi, +sin(phi) +) * D; +} +vec4 project_position(vec4 position, vec3 position64Low) { +vec4 position_world = project.modelMatrix * position; +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_mercator_(position_world.xy), +project_size_at_latitude(position_world.z, position_world.y), +position_world.w +); +} +if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { +position_world.xyz += project.coordinateOrigin; +} +} +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_globe_(position_world.xyz), +position_world.w +); +} +} +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { +return vec4( +project_mercator_(position_world.xy) - project.commonOrigin.xy, +project_size(position_world.z), +position_world.w +); +} +} +} +if (project.projectionMode == PROJECTION_MODE_IDENTITY || +(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && +(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { +position_world.xyz -= project.coordinateOrigin; +} +return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} +vec4 project_position(vec4 position) { +return project_position(position, ZERO_64_LOW); +} +vec3 project_position(vec3 position, vec3 position64Low) { +vec4 projected_position = project_position(vec4(position, 1.0), position64Low); +return projected_position.xyz; +} +vec3 project_position(vec3 position) { +vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); +return projected_position.xyz; +} +vec2 project_position(vec2 position) { +vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); +return projected_position.xy; +} +vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { +return viewProjectionMatrix * position + center; +} +vec4 project_common_position_to_clipspace(vec4 position) { +return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center); +} +vec2 project_pixel_size_to_clipspace(vec2 pixels) { +vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; +return offset * project.focalDistance; +} +float project_size_to_pixel(float meters) { +return project_size(meters) * project.scale; +} +vec2 project_size_to_pixel(vec2 meters) { +return project_size(meters) * project.scale; +} +float project_size_to_pixel(float size, int unit) { +if (unit == UNIT_METERS) return project_size_to_pixel(size); +if (unit == UNIT_COMMON) return size * project.scale; +return size; +} +float project_pixel_size(float pixels) { +return pixels / project.scale; +} +vec2 project_pixel_size(vec2 pixels) { +return pixels / project.scale; +} +`,s_={};function n_(e=s_){return"viewport"in e?Vp(e):{}}const o_={name:"project",dependencies:[nd,up],source:Jp,vs:i_,getUniforms:n_,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}},a_=`// Define a structure to hold both the clip-space position and the common position. +struct ProjectResult { + clipPosition: vec4, + commonPosition: vec4, +}; + +// This function mimics the GLSL version with the 'out' parameter by returning both values. +fn project_position_to_clipspace_and_commonspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> ProjectResult { + // Compute the projected position. + let projectedPosition: vec3 = project_position_vec3_f64(position, position64Low); + + // Start with the provided offset. + var finalOffset: vec3 = offset; + + // Get whether a rotation is needed and the rotation matrix. + let rotationResult = project_needs_rotation(projectedPosition); + + // If rotation is needed, update the offset. + if (rotationResult.needsRotation) { + finalOffset = rotationResult.transform * offset; + } + + // Compute the common position. + let commonPosition: vec4 = vec4(projectedPosition + finalOffset, 1.0); + + // Convert to clip-space. + let clipPosition: vec4 = project_common_position_to_clipspace(commonPosition); + + return ProjectResult(clipPosition, commonPosition); +} + +// A convenience overload that returns only the clip-space position. +fn project_position_to_clipspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> vec4 { + return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; +} +`,c_=`vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition +) { + vec3 projectedPosition = project_position(position, position64Low); + mat3 rotation; + if (project_needs_rotation(projectedPosition, rotation)) { + // offset is specified as ENU + // when in globe projection, rotate offset so that the ground alighs with the surface of the globe + offset = rotation * offset; + } + commonPosition = vec4(projectedPosition + offset, 1.0); + return project_common_position_to_clipspace(commonPosition); +} + +vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset +) { + vec4 commonPosition; + return project_position_to_clipspace(position, position64Low, offset, commonPosition); +} +`,WA={name:"project32",dependencies:[o_],source:a_,vs:c_};function l_(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ke(e,t){const r=It([],t,e);return Kh(r,r,1/r[3]),r}function $A(e,t,r){return r*t+(1-r)*e}function es(e,t,r){return er?r:e}function f_(e){return Math.log(e)*Math.LOG2E}const ac=Math.log2||f_;function fe(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const se=Math.PI,cc=se/4,J=se/180,ts=180/se,rt=512,mr=4003e4,Vt=85.051129,u_=1.5;function zA(e){return Math.pow(2,e)}function h_(e){return ac(e)}function br(e){const[t,r]=e;fe(Number.isFinite(t)),fe(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");const i=t*J,s=r*J,n=rt*(i+se)/(2*se),o=rt*(se+Math.log(Math.tan(cc+s*.5)))/(2*se);return[n,o]}function Hr(e){const[t,r]=e,i=t/rt*(2*se)-se,s=2*(Math.atan(Math.exp(r/rt*(2*se)-se))-cc);return[i*ts,s*ts]}function d_(e){const{latitude:t}=e;fe(Number.isFinite(t));const r=Math.cos(t*J);return h_(mr*r)-9}function mi(e){const t=Math.cos(e*J);return rt/mr/t}function rs(e){const{latitude:t,longitude:r,highPrecision:i=!1}=e;fe(Number.isFinite(t)&&Number.isFinite(r));const s=rt,n=Math.cos(t*J),o=s/360,a=o/n,c=s/mr/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){const u=J*Math.tan(t*J)/n,h=o*u/2,d=s/mr*u,g=d/a*c;l.unitsPerDegree2=[0,h,d],l.unitsPerMeter2=[g,0,g]}return l}function lc(e,t){const[r,i,s]=e,[n,o,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=rs({longitude:r,latitude:i,highPrecision:!0}),u=br(e);u[0]+=n*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);const h=Hr(u),d=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[h[0],h[1],d]:h}function g_(e){const{height:t,pitch:r,bearing:i,altitude:s,scale:n,center:o}=e,a=l_();lr(a,a,[0,0,-s]),Ea(a,a,-r*J),Sa(a,a,i*J);const c=n/t;return Ps(a,a,[c,c,c]),o&&lr(a,a,Sh([],o)),a}function p_(e){const{width:t,height:r,altitude:i,pitch:s=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e;let{fovy:u=Tr(u_)}=e;i!==void 0&&(u=Tr(i));const h=u*J,d=s*J,g=fc(u);let p=g;o&&(p+=o[2]*a/Math.cos(d)/r);const _=h*(.5+(n?n[1]:0)/r),m=Math.sin(_)*p/Math.sin(es(Math.PI/2-d-_,.01,Math.PI-.01)),b=Math.sin(d)*m+p,R=p*10,T=Math.min(b*l,R);return{fov:h,aspect:t/r,focalDistance:g,near:c,far:T}}function Tr(e){return 2*Math.atan(.5/e)*ts}function fc(e){return .5/Math.tan(.5*e*J)}function uc(e,t){const[r,i,s=0]=e;return fe(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(s)),Ke(t,[r,i,s,1])}function hc(e,t,r=0){const[i,s,n]=e;if(fe(Number.isFinite(i)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(n))return Ke(t,[i,s,n,1]);const o=Ke(t,[i,s,0,1]),a=Ke(t,[i,s,1,1]),c=o[2],l=a[2],u=c===l?0:((r||0)-c)/(l-c);return Aa([],o,a,u)}function __(e){const{width:t,height:r,bounds:i,minExtent:s=0,maxZoom:n=24,offset:o=[0,0]}=e,[[a,c],[l,u]]=i,h=m_(e.padding),d=br([a,es(u,-Vt,Vt)]),g=br([l,es(c,-Vt,Vt)]),p=[Math.max(Math.abs(g[0]-d[0]),s),Math.max(Math.abs(g[1]-d[1]),s)],_=[t-h.left-h.right-Math.abs(o[0])*2,r-h.top-h.bottom-Math.abs(o[1])*2];fe(_[0]>0&&_[1]>0);const m=_[0]/p[0],b=_[1]/p[1],R=(h.right-h.left)/2/m,T=(h.top-h.bottom)/2/b,y=[(g[0]+d[0])/2+R,(g[1]+d[1])/2+T],E=Hr(y),S=Math.min(n,ac(Math.abs(Math.min(m,b))));return fe(Number.isFinite(S)),{longitude:E[0],latitude:E[1],zoom:S}}function m_(e=0){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(fe(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}const qn=Math.PI/180;function b_(e,t=0){const{width:r,height:i,unproject:s}=e,n={targetZ:t},o=s([0,i],n),a=s([r,i],n);let c,l;const u=e.fovy?.5*e.fovy*qn:Math.atan(.5/e.altitude),h=(90-e.pitch)*qn;return u>h-.01?(c=Zn(e,0,t),l=Zn(e,r,t)):(c=s([0,0],n),l=s([r,0],n)),[o,a,l,c]}function Zn(e,t,r){const{pixelUnprojectionMatrix:i}=e,s=Ke(i,[t,0,1,1]),n=Ke(i,[t,e.height,1,1]),a=(r*e.distanceScales.unitsPerMeter[2]-s[2])/(n[2]-s[2]),c=Aa([],s,n,a),l=Hr(c);return l.push(r),l}const T_=`struct pickingUniforms { + isActive: f32, + isAttribute: f32, + isHighlightActive: f32, + useByteColors: f32, + highlightedObjectColor: vec3, + highlightColor: vec4, +}; + +@group(0) @binding(auto) var picking: pickingUniforms; + +fn picking_normalizeColor(color: vec3) -> vec3 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_normalizeColor4(color: vec4) -> vec4 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_isColorZero(color: vec3) -> bool { + return dot(color, vec3(1.0)) < 0.00001; +} + +fn picking_isColorValid(color: vec3) -> bool { + return dot(color, vec3(1.0)) > 0.00001; +} +`,jA={...Sn,source:T_,defaultUniforms:{...Sn.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":` + // for picking depth values + picking_setPickingAttribute(position.z / position.w); + `,"vs:DECKGL_FILTER_COLOR":` + picking_setPickingColor(geometry.pickingColor); + `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` + // use highlight color if this fragment belongs to the selected object. + color = picking_filterHighlightColor(color); + + // use picking color if rendering to picking FBO. + color = picking_filterPickingColor(color); + `}}};class A_{constructor(t={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(t)}setOptions(t){Object.assign(this.opts,t)}allocate(t,r,{size:i=1,type:s,padding:n=0,copy:o=!1,initialize:a=!1,maxCount:c}){const l=s||t&&t.constructor||Float32Array,u=r*i+n;if(ArrayBuffer.isView(t)){if(u<=t.length)return t;if(u*t.BYTES_PER_ELEMENT<=t.buffer.byteLength)return new l(t.buffer,0,u)}let h=1/0;c&&(h=c*i+n);const d=this._allocate(l,u,a,h);return t&&o?d.set(t):a||d.fill(0,0,4),this._release(t),d}release(t){this._release(t)}_allocate(t,r,i,s){let n=Math.max(Math.ceil(r*this.opts.overAlloc),1);n>s&&(n=s);const o=this._pool,a=t.BYTES_PER_ELEMENT*n,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){const l=new t(o.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new t(n)}_release(t){if(!ArrayBuffer.isView(t))return;const r=this._pool,{buffer:i}=t,{byteLength:s}=i,n=r.findIndex(o=>o.byteLength>=s);n<0?r.push(i):(n>0||r.lengththis.opts.poolSize&&r.shift()}}const Pt=new A_;function pt(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function HA(e,t){const r=e%t;return r<0?t+r:r}function y_(e){return[e[12],e[13],e[14]]}function VA(e){const t=e[10],r=e[14];return{near:r/(t-1),far:r/(t+1)}}function R_(e){return{left:ke(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:ke(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:ke(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:ke(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:ke(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:ke(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}const Jn=new Ge;function ke(e,t,r,i){Jn.set(e,t,r);const s=Jn.len();return{distance:i/s,normal:new Ge(-e/s,-t/s,-r/s)}}function E_(e){return e-Math.fround(e)}let lt;function bi(e,t){const{size:r=1,startIndex:i=0}=t,s=t.endIndex!==void 0?t.endIndex:e.length,n=(s-i)/r;lt=Pt.allocate(lt,n,{type:Float32Array,size:r*2});let o=i,a=0;for(;or.name===t)||null}getAttributeNamesForBuffer(t){var r;return t.attributes?(r=t.attributes)==null?void 0:r.map(i=>i.attribute):[t.name]}mergeBufferLayouts(t,r){const i=[...t];for(const s of r){const n=i.findIndex(o=>o.name===s.name);n<0?i.push(s):i[n]=s}return i}getBufferIndex(t){const r=this.bufferLayouts.findIndex(i=>i.name===t);return r===-1&&A.warn(`BufferLayout: Missing buffer for "${t}".`)(),r}}function io(e,t){let r=1/0;for(const i of e){const s=t[i];s!==void 0&&(r=Math.min(r,s))}return r}function $_(e,t){const r=Object.fromEntries(e.attributes.map(s=>[s.name,s.location])),i=t.slice();return i.sort((s,n)=>{const o=s.attributes?s.attributes.map(u=>u.attribute):[s.name],a=n.attributes?n.attributes.map(u=>u.attribute):[n.name],c=io(o,r),l=io(a,r);return c-l}),i}function so(e,t){if(!e||!t.some(i=>{var s;return(s=i.bindingLayout)==null?void 0:s.length}))return e;const r={...e,bindings:e.bindings.map(i=>({...i}))};"attributes"in(e||{})&&(r.attributes=(e==null?void 0:e.attributes)||[]);for(const i of t)for(const s of i.bindingLayout||[])for(const n of j_(s.name)){const o=r.bindings.find(a=>a.name===n);(o==null?void 0:o.group)===0&&(o.group=s.group)}return r}function z_(e){return!!(e.uniformTypes&&!H_(e.uniformTypes))}function j_(e){const t=new Set([e,`${e}Uniforms`]);return e.endsWith("Uniforms")||t.add(`${e}Sampler`),[...t]}function H_(e){for(const t in e)return!1;return!0}function V_(e){return Vf(e)||typeof e=="number"||typeof e=="boolean"}function X_(e,t={}){const r={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const s=e[i];Object.prototype.hasOwnProperty.call(t,i)||V_(s)?r.uniforms[i]=s:r.bindings[i]=s}),r}class Y_{constructor(t,r){f(this,"options",{disableWarnings:!1});f(this,"modules");f(this,"moduleUniforms");f(this,"moduleBindings");Object.assign(this.options,r);const i=ys(Object.values(t).filter(K_));for(const s of i)t[s.name]=s;A.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(const[s,n]of Object.entries(t))n&&(this._addModule(n),n.name&&s!==n.name&&!this.options.disableWarnings&&A.warn(`Module name: ${s} vs ${n.name}`)())}destroy(){}setProps(t){var r;for(const i of Object.keys(t)){const s=i,n=t[s]||{},o=this.modules[s];if(!o)this.options.disableWarnings||A.warn(`Module ${i} not found`)();else{const a=this.moduleUniforms[s],c=this.moduleBindings[s],l=((r=o.getUniforms)==null?void 0:r.call(o,n,a))||n,{uniforms:u,bindings:h}=X_(l,o.uniformTypes);this.moduleUniforms[s]=no(a,u,o.uniformTypes),this.moduleBindings[s]={...c,...h}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const t={};for(const r of Object.values(this.moduleBindings))Object.assign(t,r);return t}getDebugTable(){var r;const t={};for(const[i,s]of Object.entries(this.moduleUniforms))for(const[n,o]of Object.entries(s))t[`${i}.${n}`]={type:(r=this.modules[i].uniformTypes)==null?void 0:r[n],value:String(o)};return t}_addModule(t){const r=t.name;this.moduleUniforms[r]=no({},t.defaultUniforms||{},t.uniformTypes),this.moduleBindings[r]={}}}function no(e={},t={},r={}){const i={...e};for(const[s,n]of Object.entries(t))n!==void 0&&(i[s]=ss(e[s],n,r[s]));return i}function ss(e,t,r){if(!r||typeof r=="string")return bt(t);if(Array.isArray(r)){if(ns(t)||!Array.isArray(t))return bt(t);const o=Array.isArray(e)&&!ns(e)?[...e]:[],a=o.slice();for(let c=0;cr===void 0?void 0:bt(r)):os(e)?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r===void 0?void 0:bt(r)])):e}function ns(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(e.length===0||typeof e[0]=="number")}function os(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function K_(e){return!!(e!=null&&e.dependencies)}const dc={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function ft(e){return e?Array.isArray(e)?e[0]??null:e:null}function Q_(e){const{dimension:t,data:r}=e;if(!r)return null;switch(t){case"1d":{const i=ft(r);if(!i)return null;const{width:s}=ut(i);return{width:s,height:1}}case"2d":{const i=ft(r);return i?ut(i):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;const i=ft(r[0]);return i?ut(i):null}case"cube":{const i=Object.keys(r)[0]??null;if(!i)return null;const s=r[i],n=ft(s);return n?ut(n):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;const i=r[0],s=Object.keys(i)[0]??null;if(!s)return null;const n=ft(i[s]);return n?ut(n):null}default:return null}}function ut(e){if(ws(e))return Ia(e);if(typeof e=="object"&&"width"in e&&"height"in e)return{width:e.width,height:e.height};throw new Error("Unsupported mip-level data")}function q_(e){return typeof e=="object"&&e!==null&&"data"in e&&"width"in e&&"height"in e}function Z_(e){return ArrayBuffer.isView(e)}function gc(e){const{textureFormat:t,format:r}=e;if(t&&r&&t!==r)throw new Error(`Conflicting texture formats "${t}" and "${r}" provided for the same mip level`);return t??r}function pc(e){const t=dc[e];if(t===void 0)throw new Error(`Invalid cube face: ${e}`);return t}function J_(e,t){return 6*e+pc(t)}function _c(e){throw new Error("setTexture1DData not supported in WebGL.")}function G_(e){return Array.isArray(e)?e:[e]}function nt(e,t,r,i){const s=G_(t),n=e,o=[];for(let a=0;a>a),height:Math.max(1,r.height>>a),...i?{format:i}:{}},textureFormat:i,z:n,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return o}function mc(e){const t=[];for(let r=0;r{for(const[s,n]of Object.entries(r)){const o=J_(i,s);t.push(...nt(o,n))}}),t}const Lr=class Lr{constructor(t,r){f(this,"device");f(this,"id");f(this,"props");f(this,"_texture",null);f(this,"_sampler",null);f(this,"_view",null);f(this,"ready");f(this,"isReady",!1);f(this,"destroyed",!1);f(this,"resolveReady",()=>{});f(this,"rejectReady",()=>{});this.device=t;const i=Xr("dynamic-texture"),s=r;this.props={...Lr.defaultProps,id:i,...r,data:null},this.id=this.props.id,this.ready=new Promise((n,o)=>{this.resolveReady=n,this.rejectReady=o}),this.initAsync(s)}get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){var i,s;const t=((i=this._texture)==null?void 0:i.width)??this.props.width??"?",r=((s=this._texture)==null?void 0:s.height)??this.props.height??"?";return`DynamicTexture:"${this.id}":${t}x${r}px:(${this.isReady?"ready":"loading..."})`}async initAsync(t){try{const r=await this._loadAllData(t);this._checkNotDestroyed();const i=r.data?em({...r,width:t.width,height:t.height,format:t.format}):[],s="format"in t&&t.format!==void 0,n="usage"in t&&t.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};const _=Q_(r);return _||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);const c=tm(this.device,i,a,{format:s?t.format:void 0}),l=c.format??this.props.format,u={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!n&&(u.usage=U.SAMPLE|U.COPY_DST);const h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){const _=this.props.dimension==="3d"?U.SAMPLE|U.STORAGE|U.COPY_DST|U.COPY_SRC:U.SAMPLE|U.RENDER|U.COPY_DST|U.COPY_SRC;u.usage|=_}const d=this.device.getMipLevelCount(u.width,u.height),g=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?d:Math.max(1,Math.min(d,this.props.mipLevels??1)),p={...u,mipLevels:g};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&A.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),A.info(0,`${this} created`)()}catch(r){const i=r instanceof Error?r:new Error(String(r));this.rejectReady(i)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):A.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(t={}){this._checkReady();const r=t instanceof tt?t:this.device.createSampler(t);this.texture.setSampler(r),this._sampler=r}async readBuffer(t={}){this.isReady||await this.ready;const r=t.width??this.texture.width,i=t.height??this.texture.height,s=t.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:s}),o=this.device.createBuffer({byteLength:n.byteLength,usage:N.COPY_DST|N.MAP_READ});this.texture.readBuffer({...t,width:r,height:i,depthOrArrayLayers:s},o);const a=this.device.createFence();return await a.signaled,a.destroy(),o}async readAsync(t={}){this.isReady||await this.ready;const r=t.width??this.texture.width,i=t.height??this.texture.height,s=t.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:s}),o=await this.readBuffer(t),a=await o.readAsync(0,n.byteLength);return o.destroy(),a.buffer}resize(t){if(this._checkReady(),t.width===this.texture.width&&t.height===this.texture.height)return!1;const r=this.texture;return this._texture=r.clone(t),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),A.info(`${this} resized`),!0}getCubeFaceIndex(t){const r=dc[t];if(r===void 0)throw new Error(`Invalid cube face: ${t}`);return r}getCubeArrayFaceIndex(t,r){return 6*t+this.getCubeFaceIndex(r)}setTexture1DData(t){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);const r=_c();this._setTextureSubresources(r)}setTexture2DData(t,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);const i=nt(r,t);this._setTextureSubresources(i)}setTexture3DData(t){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);const r=mc(t);this._setTextureSubresources(r)}setTextureArrayData(t){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);const r=bc(t);this._setTextureSubresources(r)}setTextureCubeData(t){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);const r=Tc(t);this._setTextureSubresources(r)}setTextureCubeArrayData(t){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);const r=Ac(t);this._setTextureSubresources(r)}_setTextureSubresources(t){for(const r of t){const{z:i,mipLevel:s}=r;switch(r.type){case"external-image":const{image:n,flipY:o}=r;this.texture.copyExternalImage({image:n,z:i,mipLevel:s,flipY:o});break;case"texture-data":const{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${s} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:i,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:s});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(t){const r=await as(t.data);return{dimension:t.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&A.warn(`${this} already destroyed`)}_checkReady(){this.isReady||A.warn(`${this} Cannot perform this operation before ready`)}};f(Lr,"defaultProps",{...U.defaultProps,dimension:"2d",data:null,mipmaps:!1});let $e=Lr;function em(e){if(!e.data)return[];const t=e.width&&e.height?{width:e.width,height:e.height}:void 0,r="format"in e?e.format:void 0;switch(e.dimension){case"1d":return _c();case"2d":return nt(0,e.data,t,r);case"3d":return mc(e.data);case"2d-array":return bc(e.data);case"cube":return Tc(e.data);case"cube-array":return Ac(e.data);default:throw new Error(`Unhandled dimension ${e.dimension}`)}}function tm(e,t,r,i){if(t.length===0)return{subresources:t,mipLevels:1,format:i.format,hasExplicitMipChain:!1};const s=new Map;for(const u of t){const h=s.get(u.z)??[];h.push(u),s.set(u.z,h)}const n=t.some(u=>u.mipLevel>0);let o=i.format,a=Number.POSITIVE_INFINITY;const c=[];for(const[u,h]of s){const d=[...h].sort((R,T)=>R.mipLevel-T.mipLevel),g=d[0];if(!g||g.mipLevel!==0)throw new Error(`DynamicTexture: slice ${u} is missing mip level 0`);const p=ao(e,g);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${u} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);const _=oo(g);if(_){if(o&&o!==_)throw new Error(`DynamicTexture: slice ${u} base level format "${_}" does not match texture format "${o}"`);o=_}const m=o&&e.isTextureFormatCompressed(o)?rm(e,p.width,p.height,o):e.getMipLevelCount(p.width,p.height);let b=0;for(let R=0;R=m)break;const y=ao(e,T),E=Math.max(1,p.width>>R),S=Math.max(1,p.height>>R);if(y.width!==E||y.height!==S)break;const C=oo(T);if(C&&(o||(o=C),C!==o))break;b++,c.push(T)}a=Math.min(a,b)}const l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(u=>u.mipLevel>a),l=Math.max(1,r>>a);if(c[d.name,d]))||[]),s=r.shaderInputs||new Y_(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);const n=sm(t),o=(((l=this.props.modules)==null?void 0:l.length)>0?this.props.modules:(u=this.shaderInputs)==null?void 0:u.getModules())||[];if(this.props.shaderLayout=so(this.props.shaderLayout,o)||null,this.device.type==="webgpu"&&this.props.source){const{source:d,getUniforms:g,bindingTable:p}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:n,...this.props,modules:o});this.source=d,this._getModuleUniforms=g,this._bindingTable=p;const _=(h=t.getShaderLayout)==null?void 0:h.call(t,this.source);this.props.shaderLayout=so(this.props.shaderLayout||_||null,o)||null}else{const{vs:d,fs:g,getUniforms:p}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:n,...this.props,modules:o});this.vs=d,this.fs=g,this._getModuleUniforms=p,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||Hi.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Vi.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var t;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(t=this._gpuGeometry)==null||t.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||(this._needsRedraw=t)}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(t){const r=this._areBindingsLoading();if(r)return A.info(de,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{t.pushDebugGroup(`${this}.predraw(${t})`),this.predraw()}finally{t.popDebugGroup()}let i,s=this.pipeline.isErrored;try{if(t.pushDebugGroup(`${this}.draw(${t})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),s=this.pipeline.isErrored,s)A.info(de,`>>> DRAWING ABORTED ${this.id}: ${co}`)(),i=!1;else{const n=this._getBindings(),o=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:n,bindGroups:o,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{t.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(t),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):s?this._needsRedraw=co:this._needsRedraw="waiting for resource initialization",i}setGeometry(t){var i;(i=this._gpuGeometry)==null||i.destroy();const r=t&&M_(this.device,t);if(r){this.setTopology(r.topology||"triangle-list");const s=new Ri(this.bufferLayout);this.bufferLayout=s.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){const r=new Ri(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.mergeBufferLayouts(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){is(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,this.isInstanced===void 0&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){var r;this.shaderInputs=t,this._uniformStore=new Kg(this.device,this.shaderInputs.modules);for(const[i,s]of Object.entries(this.shaderInputs.modules))if(z_(s)&&!((r=this.material)!=null&&r.ownsModule(i))){const n=this._uniformStore.getManagedUniformBuffer(i);this.bindings[`${i}Uniforms`]=n}this.setNeedsRedraw("shaderInputs")}setMaterial(t){this.material=t,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(t,r){const i=(r==null?void 0:r.disableWarnings)??this.props.disableWarnings;t.indices&&A.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=$_(this.pipeline.shaderLayout,this.bufferLayout);const s=new Ri(this.bufferLayout);for(const[n,o]of Object.entries(t)){const a=s.getBufferLayout(n);if(!a){i||A.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}const c=s.getAttributeNamesForBuffer(a);let l=!1;for(const u of c){const h=this._attributeInfos[u];if(h){const d=this.device.type==="webgpu"?s.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(d,o),l=!0}}!l&&!i&&A.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${n}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,r){for(const[i,s]of Object.entries(t)){const n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,s):((r==null?void 0:r.disableWarnings)??this.props.disableWarnings)||A.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){var t;for(const r of Object.values(this.bindings))if(r instanceof $e&&!r.isReady)return r.id;for(const r of Object.values(((t=this.material)==null?void 0:t.bindings)||{}))if(r instanceof $e&&!r.isReady)return r.id;return!1}_getBindings(){const t={};for(const[r,i]of Object.entries(this.bindings))i instanceof $e?i.isReady&&(t[r]=i.texture):t[r]=i;return t}_getBindGroups(){var i;const t=((i=this.pipeline)==null?void 0:i.shaderLayout)||this.props.shaderLayout||{bindings:[]},r=t.bindings.length?Fa(t,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(const[s,n]of Object.entries(this.material.getBindingsByGroup())){const o=Number(s);r[o]={...r[o]||{},...n}}return r}_getBindGroupCacheKeys(){var r;const t=(r=this.material)==null?void 0:r.getBindGroupCacheKey(3);return t?{3:t}:{}}_getBindingsUpdateTimestamp(){var r;let t=0;for(const i of Object.values(this.bindings))i instanceof ur?t=Math.max(t,i.texture.updateTimestamp):i instanceof N||i instanceof U?t=Math.max(t,i.updateTimestamp):i instanceof $e?t=i.texture?Math.max(t,i.texture.updateTimestamp):1/0:i instanceof tt||(t=Math.max(t,i.buffer.updateTimestamp));return Math.max(t,((r=this.material)==null?void 0:r.getBindingsUpdateTimestamp())||0)}_setGeometryAttributes(t){const r={...t.attributes};for(const[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=t),this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null,r=null;this.pipeline&&(A.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=i:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:i,fs:s}),this._attributeInfos=La(this.pipeline.shaderLayout,this.bufferLayout),t&&this.shaderFactory.release(t),r&&r!==t&&this.shaderFactory.release(r)}return this.pipeline}_logDrawCallStart(){const t=A.level>3?0:im;A.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:A.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const t=B_(this.pipeline.shaderLayout,this.id);A.table(de,t)();const r=this.shaderInputs.getDebugTable();A.table(de,r)();const i=this._getAttributeDebugTable();A.table(de,this._attributeInfos)(),A.table(de,i)(),A.groupEnd(de)(),this._logOpen=!1}}_logFramebuffer(t){const r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;const i=t.props.framebuffer;D_(t,i,{id:(i==null?void 0:i.id)||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const t={};for(const[r,i]of Object.entries(this._attributeInfos)){const s=this.vertexArray.attributes[i.location];t[i.location]={name:r,type:i.shaderType,values:s?this._getBufferOrConstantValues(s,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);t.indices={name:"indices",type:r.indexType,values:i.toString()}}return t}_getBufferOrConstantValues(t,r){const i=le.getTypedArrayConstructor(r);return(t instanceof N?new i(t.debugData):t).toString()}_getNonMaterialBindings(t){if(!this.material)return t;const r={};for(const[i,s]of Object.entries(t))this.material.ownsBinding(i)||(r[i]=s);return r}};f(kr,"defaultProps",{..._e.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Wi.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let Ar=kr;function sm(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}const Et=class Et{constructor(t,r=Et.defaultProps){f(this,"device");f(this,"model");f(this,"transformFeedback");if(!Et.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new Ar(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||rh(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}static isSupported(t){var r;return((r=t==null?void 0:t.info)==null?void 0:r.type)==="webgl"}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(t){t!=null&&t.inputBuffers&&this.model.setAttributes(t.inputBuffers),t!=null&&t.outputBuffers&&this.transformFeedback.setBuffers(t.outputBuffers);const r=this.device.beginRenderPass(t);this.model.draw(r),r.end()}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(t){const r=this.getBuffer(t);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof N)return r.readAsync();const{buffer:i,byteOffset:s=0,byteLength:n=i.byteLength}=r;return i.readAsync(s,n)}};f(Et,"defaultProps",{...Ar.defaultProps,outputs:void 0,feedbackBuffers:void 0});let Ot=Et;class XA{constructor(t){f(this,"id");f(this,"topology");f(this,"vertexCount");f(this,"indices");f(this,"attributes");f(this,"userData",{});const{attributes:r={},indices:i=null,vertexCount:s=null}=t;this.id=t.id||Xr("geometry"),this.topology=t.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(const[n,o]of Object.entries(r)){const a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(n)}: must be typed array or object with value as typed array`);if((n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,r){return this}_calculateVertexCount(t,r){if(r)return r.value.length;let i=1/0;for(const s of Object.values(t)){const{value:n,size:o,constant:a}=s;!a&&n&&o!==void 0&&o>=1&&(i=Math.min(i,n.length/o))}return i}}const nm={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},yr=Symbol.for("component"),be=Symbol.for("propTypes"),Ei=Symbol.for("deprecatedProps"),Qe=Symbol.for("asyncPropDefaults"),Ie=Symbol.for("asyncPropOriginal"),me=Symbol.for("asyncPropResolved");function om(e,t=()=>!0){return Array.isArray(e)?yc(e,t,[]):t(e)?[e]:[]}function yc(e,t,r){let i=-1;for(;++i{i.onload=s,i.onerror=o=>n(new Error(`Unable to load script '${e}': ${o}`)),r.appendChild(i)})}function Rr(e){const t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??(t._polyfilled=!1),t.extensions||(t.extensions={}),e.luma=t,t}const cm=1;let I=null,lo=!1;const Ec={debugSpectorJS:A.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function YA(e){if(!globalThis.SPECTOR)try{await Rc(e.debugSpectorJSUrl||Ec.debugSpectorJSUrl)}catch(t){A.warn(String(t))}}function lm(e){var t;if(e={...Ec,...e},!e.debugSpectorJS)return null;if(!I&&globalThis.SPECTOR&&!((t=globalThis.luma)!=null&&t.spector)){A.probe(cm,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:r}=globalThis.SPECTOR;I=new r,globalThis.luma&&(globalThis.luma.spector=I)}if(!I)return null;if(lo||(lo=!0,I.spyCanvases(),I==null||I.onCaptureStarted.add(r=>A.info("Spector capture started:",r)()),I==null||I.onCapture.add(r=>{A.info("Spector capture complete:",r)(),I==null||I.getResultUI(),I==null||I.resultView.display(),I==null||I.resultView.addCapture(r)})),e.gl){const r=e.gl,i=Rr(r),s=i.device;I==null||I.startCapture(e.gl,500),i.device=s,new Promise(n=>setTimeout(n,2e3)).then(n=>{A.info("Spector capture stopped after 2 seconds")(),I==null||I.stopCapture()})}return I}const fm="https://unpkg.com/webgl-debug@2.0.1/index.js";function Sc(e){return e.luma=e.luma||{},e.luma}async function KA(){it()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Rc(fm))}function um(e,t={}){return t.debugWebGL||t.traceWebGL?dm(e,t):hm(e)}function hm(e){const t=Sc(e);return t.realContext?t.realContext:e}function dm(e,t){if(!globalThis.WebGLDebugUtils)return A.warn("webgl-debug not loaded")(),e;const r=Sc(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...je,...e});const i=globalThis.WebGLDebugUtils.makeDebugContext(e,gm.bind(null,t),pm.bind(null,t));for(const o in je)!(o in i)&&typeof je[o]=="number"&&(i[o]=je[o]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.setPrototypeOf(s,i);const n=Object.create(s);return r.realContext=e,r.debugContext=n,n.luma=r,n.debug=!0,n}function fo(e,t){t=Array.from(t).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function gm(e,t,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(t),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),o=`${s} in gl.${r}(${n})`;A.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",o)();debugger;throw new Error(o)}function pm(e,t,r){let i="";e.traceWebGL&&A.level>=1&&(i=fo(t,r),A.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(const s of r)if(s===void 0){i=i||fo(t,r);debugger}}const Fs={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},k=(e,t,r)=>t?e.enable(r):e.disable(r),uo=(e,t,r)=>e.hint(r,t),V=(e,t,r)=>e.pixelStorei(r,t),ho=(e,t,r)=>{const i=r===36006?36009:36008;return e.bindFramebuffer(i,t)},ht=(e,t,r)=>{const s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];e.bindBuffer(s,t)};function Si(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const _m={3042:k,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:k,2885:(e,t)=>e.cullFace(t),2929:k,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:k,35723:uo,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>{var r;return(r=e.bindTransformFeedback)==null?void 0:r.call(e,36386,t)},34229:(e,t)=>e.bindVertexArray(t),36006:ho,36010:ho,34964:ht,36662:ht,36663:ht,35053:ht,35055:ht,2886:(e,t)=>e.frontFace(t),33170:uo,2849:(e,t)=>e.lineWidth(t),32823:k,32824:"polygonOffset",10752:"polygonOffset",35977:k,32926:k,32928:k,32938:"sampleCoverage",32939:"sampleCoverage",3089:k,3088:(e,t)=>e.scissor(...t),2960:k,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:k,10754:k,12288:k,12289:k,12290:k,12291:k,12292:k,12293:k,12294:k,12295:k,3333:V,3317:V,37440:V,37441:V,37443:V,3330:V,3332:V,3331:V,3314:V,32878:V,3316:V,3315:V,32877:V,framebuffer:(e,t)=>{const r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{const r=(t==null?void 0:t.length)===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Si(t)?t:[t,t];const[r,i]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=Si(t)&&t.length===3?[...t,...t]:t;const[r,i,s,n,o,a]=t;e.stencilFuncSeparate(1028,r,i,s),e.stencilFuncSeparate(1029,n,o,a)},stencilOp:(e,t)=>{t=Si(t)&&t.length===3?[...t,...t]:t;const[r,i,s,n,o,a]=t;e.stencilOpSeparate(1028,r,i,s),e.stencilOpSeparate(1029,n,o,a)},viewport:(e,t)=>e.viewport(...t)};function L(e,t,r){return t[e]!==void 0?t[e]:r[e]}const mm={blendEquation:(e,t,r)=>e.blendEquationSeparate(L(32777,t,r),L(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(L(32969,t,r),L(32968,t,r),L(32971,t,r),L(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(L(32824,t,r),L(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(L(32938,t,r),L(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,L(2962,t,r),L(2967,t,r),L(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,L(34816,t,r),L(36003,t,r),L(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,L(2964,t,r),L(2965,t,r),L(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,L(34817,t,r),L(34818,t,r),L(34819,t,r))},go={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,r)=>e({36007:r}),bindTransformFeedback:(e,t,r)=>e({36389:r}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({36006:r,36010:r});case 36009:return e({36006:r});case 36008:return e({36010:r});default:return null}},bindBuffer:(e,t,r)=>{const i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return i?e({[i]:r}):{valueChanged:!0}},blendColor:(e,t,r,i,s)=>e({32773:new Float32Array([t,r,i,s])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,r)=>e({32777:t,34877:r}),blendFunc:(e,t,r)=>e({32969:t,32968:r,32971:t,32970:r}),blendFuncSeparate:(e,t,r,i,s)=>e({32969:t,32968:r,32971:i,32970:s}),clearColor:(e,t,r,i,s)=>e({3106:new Float32Array([t,r,i,s])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,r,i,s)=>e({3107:[t,r,i,s]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,r)=>e({2928:new Float32Array([t,r])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,r)=>e({32824:t,10752:r}),sampleCoverage:(e,t,r)=>e({32938:t,32939:r}),scissor:(e,t,r,i,s)=>e({3088:new Int32Array([t,r,i,s])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,i)=>e({2962:t,2967:r,2963:i,34816:t,36003:r,36004:i}),stencilFuncSeparate:(e,t,r,i,s)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:i,[t===1028?2963:36004]:s}),stencilOp:(e,t,r,i)=>e({2964:t,2965:r,2966:i,34817:t,34818:r,34819:i}),stencilOpSeparate:(e,t,r,i,s)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:i,[t===1028?2966:34819]:s}),viewport:(e,t,r,i,s)=>e({2978:[t,r,i,s]})},oe=(e,t)=>e.isEnabled(t),po={3042:oe,2884:oe,2929:oe,3024:oe,32823:oe,32926:oe,32928:oe,3089:oe,2960:oe,35977:oe},bm=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function ot(e,t){var s;if(Am(t))return;const r={};for(const n in t){const o=Number(n),a=_m[n];a&&(typeof a=="string"?r[a]=!0:a(e,t[n],o))}const i=(s=e.lumaState)==null?void 0:s.cache;if(i)for(const n in r){const o=mm[n];o(e,t,i)}}function Cc(e,t=Fs){if(typeof t=="number"){const s=t,n=po[s];return n?n(e,s):e.getParameter(s)}const r=Array.isArray(t)?t:Object.keys(t),i={};for(const s of r){const n=po[s];i[s]=n?n(e,Number(s)):e.getParameter(Number(s))}return i}function Tm(e){ot(e,Fs)}function Am(e){for(const t in e)return!1;return!0}function ym(e,t){if(e===t)return!0;if(_o(e)&&_o(t)&&e.length===t.length){for(let r=0;r{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(t){return t.lumaState}push(t={}){this.stateStack.push({})}pop(){const t=this.stateStack[this.stateStack.length-1];ot(this.gl,t),this.stateStack.pop()}trackState(t,r){if(this.cache=r!=null&&r.copyState?Cc(t):Object.assign({},Fs),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,Em(t);for(const i in go){const s=go[i];Rm(t,i,s)}mo(t,"getParameter"),mo(t,"isEnabled")}_updateCache(t){let r=!1,i;const s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const n in t){const o=t[n],a=this.cache[n];ym(o,a)||(r=!0,i=a,s&&!(n in s)&&(s[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:i}}}function mo(e,t){const r=e[t].bind(e);e[t]=function(s){if(s===void 0||bm.has(s))return r(s);const n=Pe.get(e);return s in n.cache||(n.cache[s]=r(s)),n.enable?n.cache[s]:r(s)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Rm(e,t,r){if(!e[t])return;const i=e[t].bind(e);e[t]=function(...n){const o=Pe.get(e),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&i(...n),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Em(e){const t=e.useProgram.bind(e);e.useProgram=function(i){const s=Pe.get(e);s.program!==i&&(t(i),s.program=i)}}function Sm(e,t,r){let i="";const s=c=>{const l=c.statusMessage;l&&(i||(i=l))};e.addEventListener("webglcontextcreationerror",s,!1);const n=r.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0};let a=null;try{a||(a=e.getContext("webgl2",o)),!a&&o.failIfMajorPerformanceCaveat&&(i||(i="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow."));let c=!1;if(!a&&n&&(o.failIfMajorPerformanceCaveat=!1,a=e.getContext("webgl2",o),c=!0),a||(a=e.getContext("webgl",{}),a&&(a=null,i||(i="Your browser only supports WebGL1"))),!a)throw i||(i="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${i}`);const l=Rr(a);l.softwareRenderer=c;const{onContextLost:u,onContextRestored:h}=t;return e.addEventListener("webglcontextlost",d=>u(d),!1),e.addEventListener("webglcontextrestored",d=>h(d),!1),a}finally{e.removeEventListener("webglcontextcreationerror",s,!1)}}function Ne(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}function Cm(e,t){const r=e.getParameter(7936),i=e.getParameter(7937);Ne(e,"WEBGL_debug_renderer_info",t);const s=t.WEBGL_debug_renderer_info,n=e.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||i,l=e.getParameter(7938),u=vc(a,c),h=vm(a,c),d=Pm(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function vc(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function vm(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function Pm(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(vc(e,t)){case"apple":return wm(e,t)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function wm(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}function Pc(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const _t="WEBGL_compressed_texture_s3tc",mt="WEBGL_compressed_texture_s3tc_srgb",He="EXT_texture_compression_rgtc",Ve="EXT_texture_compression_bptc",Om="WEBGL_compressed_texture_etc",xm="WEBGL_compressed_texture_astc",Mm="WEBGL_compressed_texture_etc1",Im="WEBGL_compressed_texture_pvrtc",Nm="WEBGL_compressed_texture_atc",Bm="EXT_texture_norm16",bo="EXT_render_snorm",wc="EXT_color_buffer_float",Ci="snorm8-renderable-webgl",vi="norm16-renderable-webgl",Pi="snorm16-renderable-webgl",wi="float16-renderable-webgl",Yt="float32-renderable-webgl",Dm="rgb9e5ufloat-renderable-webgl",Us={"float32-renderable-webgl":{extensions:[wc]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[bo]},"norm16-webgl":{extensions:[Bm]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[bo]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[_t,mt,He,Ve]},"texture-compression-bc5-webgl":{extensions:[He]},"texture-compression-bc7-webgl":{extensions:[Ve]},"texture-compression-etc2":{extensions:[Om]},"texture-compression-astc":{extensions:[xm]},"texture-compression-etc1-webgl":{extensions:[Mm]},"texture-compression-pvrtc-webgl":{extensions:[Im]},"texture-compression-atc-webgl":{extensions:[Nm]}};function Fm(e){return e in Us}function Oc(e,t,r){return xc(e,t,r,new Set)}function xc(e,t,r,i){const s=Us[t];if(!s||i.has(t))return!1;i.add(t);const n=(s.features||[]).every(o=>xc(e,o,r,i));return i.delete(t),n?(s.extensions||[]).every(o=>!!Ne(e,o,r)):!1}const Yr={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:Ci},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:Ci},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:wi},r16unorm:{gl:33322,rb:!0,r:vi},r16snorm:{gl:36760,r:Pi},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:Ci},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:wi},rg16unorm:{gl:33324,r:vi},rg16snorm:{gl:36761,r:Pi},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Yt},rgb9e5ufloat:{gl:35901,r:Dm},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Yt},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:wi},rgba16unorm:{gl:32859,rb:!0,r:vi},rgba16snorm:{gl:36763,r:Pi},"rgb32float-webgl":{gl:34837,x:wc,r:Yt,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Yt},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:_t},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:mt},"bc1-rgba-unorm":{gl:33777,x:_t},"bc1-rgba-unorm-srgb":{gl:35916,x:mt},"bc2-rgba-unorm":{gl:33778,x:_t},"bc2-rgba-unorm-srgb":{gl:35918,x:mt},"bc3-rgba-unorm":{gl:33779,x:_t},"bc3-rgba-unorm-srgb":{gl:35919,x:mt},"bc4-r-unorm":{gl:36283,x:He},"bc4-r-snorm":{gl:36284,x:He},"bc5-rg-unorm":{gl:36285,x:He},"bc5-rg-snorm":{gl:36286,x:He},"bc6h-rgb-ufloat":{gl:36495,x:Ve},"bc6h-rgb-float":{gl:36494,x:Ve},"bc7-rgba-unorm":{gl:36492,x:Ve},"bc7-rgba-unorm-srgb":{gl:36493,x:Ve},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function Um(e,t,r){let i=t.create;const s=Yr[t.format];(s==null?void 0:s.gl)===void 0&&(i=!1),s!=null&&s.x&&(i=i&&!!Ne(e,s.x,r)),t.format==="stencil8"&&(i=!1);const n=(s==null?void 0:s.r)===!1?!1:(s==null?void 0:s.r)===void 0||Oc(e,s.r,r),o=i&&t.render&&n&&Lm(e,t.format,r);return{format:t.format,create:i&&t.create,render:o,filter:i&&t.filter,blend:i&&t.blend,store:i&&t.store}}function Lm(e,t,r){const i=Yr[t],s=i==null?void 0:i.gl;if(s===void 0||i!=null&&i.x&&!Ne(e,i.x,r))return!1;const n=e.getParameter(32873),o=e.getParameter(36006),a=e.createTexture(),c=e.createFramebuffer();if(!a||!c)return!1;const l=0;let u=Number(e.getError());for(;u!==l;)u=e.getError();let h=!1;try{if(e.bindTexture(3553,a),e.texStorage2D(3553,1,s,1,1),Number(e.getError())!==l)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,a,0),h=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===l}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,n),e.deleteTexture(a)}return h}function Mc(e){var s;const t=Yr[e],r=$m(e),i=re.getInfo(e);return i.compressed&&(t.dataFormat=r),{internalFormat:r,format:(t==null?void 0:t.dataFormat)||Wm(i.channels,i.integer,i.normalized,r),type:i.dataType?Pc(i.dataType):((s=t==null?void 0:t.types)==null?void 0:s[0])||5121,compressed:i.compressed||!1}}function km(e){switch(re.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${e}`)}}function Wm(e,t,r,i){if(i===6408||i===6407)return i;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function $m(e){const t=Yr[e],r=t==null?void 0:t.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}const To={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class zm extends qd{constructor(r,i,s){super([],s);f(this,"gl");f(this,"extensions");f(this,"testedFeatures",new Set);this.gl=r,this.extensions=i,Ne(r,"EXT_color_buffer_float",i)}*[Symbol.iterator](){const r=this.getFeatures();for(const i of r)this.has(i)&&(yield i);return[]}has(r){var i;return(i=this.disabledFeatures)!=null&&i[r]?!1:(this.testedFeatures.has(r)||(this.testedFeatures.add(r),Fm(r)&&Oc(this.gl,r,this.extensions)&&this.features.add(r),this.getWebGLFeature(r)&&this.features.add(r)),this.features.has(r))}initializeFeatures(){const r=this.getFeatures().filter(i=>i!=="polygon-mode-webgl");for(const i of r)this.has(i)}getFeatures(){return[...Object.keys(To),...Object.keys(Us)]}getWebGLFeature(r){const i=To[r];return typeof i=="string"?!!Ne(this.gl,i,this.extensions):!!i}}class jm extends Vd{constructor(r){super();f(this,"gl");f(this,"limits",{});this.gl=r}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(r){return this.limits[r]===void 0&&(this.limits[r]=this.gl.getParameter(r)),this.limits[r]||0}}class Tt extends dr{constructor(r,i){super(r,i);f(this,"device");f(this,"gl");f(this,"handle");f(this,"colorAttachments",[]);f(this,"depthStencilAttachment",null);const s=i.handle===null;this.device=r,this.gl=r.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),s||(r._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),i.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const r=this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const r=this.device.gl.getShaderInfoLog(this.handle);return r?Zm(r):[]}getTranslatedSource(){const i=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(i==null?void 0:i.getTranslatedShaderSource(this.handle))||null}_compile(r){r=r.startsWith("#version ")?r:`#version 300 es +${r}`;const{gl:i}=this.device;if(i.shaderSource(this.handle,r),i.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return A.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{A.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){const r=async n=>await new Promise(o=>setTimeout(o,n));if(!this.device.features.has("compilation-status-async-webgl")){await r(10);return}const{gl:s}=this.device;for(;;){if(s.getShaderParameter(this.handle,37297))return;await r(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function Gm(e,t,r,i){if(ib(t))return i(e);const s=e;s.pushState();try{return eb(e,t),ot(s.gl,r),i(e)}finally{s.popState()}}function eb(e,t){const r=e,{gl:i}=r;if(t.cullMode)switch(t.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(t.frontFace&&i.frontFace(we("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&i.enable(34383),t.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=we("provokingVertex",t.provokingVertex,{first:36429,last:36430});n==null||n.provokingVertexWEBGL(o)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=we("polygonMode",t.polygonMode,{fill:6914,line:6913});n==null||n.polygonModeWEBGL(1028,o),n==null||n.polygonModeWEBGL(1029,o)}t.polygonOffsetLine&&i.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&i.enable(12288),t.clipDistance1&&i.enable(12289),t.clipDistance2&&i.enable(12290),t.clipDistance3&&i.enable(12291),t.clipDistance4&&i.enable(12292),t.clipDistance5&&i.enable(12293),t.clipDistance6&&i.enable(12294),t.clipDistance7&&i.enable(12295)),t.depthWriteEnabled!==void 0&&i.depthMask(rb("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(cs("depthCompare",t.depthCompare))),t.clearDepth!==void 0&&i.clearDepth(t.clearDepth),t.stencilWriteMask){const s=t.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(t.stencilReadMask&&A.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){const s=t.stencilReadMask||4294967295,n=cs("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,s),i.stencilFuncSeparate(1029,n,0,s)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const s=xi("stencilPassOperation",t.stencilPassOperation),n=xi("stencilFailOperation",t.stencilFailOperation),o=xi("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,o,s),i.stencilOpSeparate(1029,n,o,s)}switch(t.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break}if(t.blendColorOperation||t.blendAlphaOperation){const s=Ao("blendColorOperation",t.blendColorOperation||"add"),n=Ao("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(s,n);const o=Qt("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=Qt("blendColorDstFactor",t.blendColorDstFactor||"zero"),c=Qt("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=Qt("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function cs(e,t){return we(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function xi(e,t){return we(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Ao(e,t){return we(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Qt(e,t,r="color"){return we(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function tb(e,t){return`Illegal parameter ${t} for ${e}`}function we(e,t,r){if(!(t in r))throw new Error(tb(e,t));return r[t]}function rb(e,t){return t}function ib(e){let t=!0;for(const r in e){t=!1;break}return t}function Ic(e){const t={};return e.addressModeU&&(t[10242]=Mi(e.addressModeU)),e.addressModeV&&(t[10243]=Mi(e.addressModeV)),e.addressModeW&&(t[32882]=Mi(e.addressModeW)),e.magFilter&&(t[10240]=ls(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=sb(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=cs("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function Mi(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function ls(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function sb(e,t="none"){if(!t)return ls(e);switch(t){case"none":return ls(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}class nb extends tt{constructor(r,i){super(r,i);f(this,"device");f(this,"handle");f(this,"parameters");this.device=r,this.parameters=Ic(i),this.handle=i.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(r){for(const[i,s]of Object.entries(r)){const n=Number(i);switch(n){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,n,s);break;default:this.device.gl.samplerParameteri(this.handle,n,s);break}}}}function Ee(e,t,r){if(ob(t))return r(e);const{nocatch:i=!0}=t,s=Pe.get(e);s.push(),ot(e,t);let n;if(i)n=r(e),s.pop();else try{n=r(e)}finally{s.pop()}return n}function ob(e){for(const t in e)return!1;return!0}class Xe extends ur{constructor(r,i){super(r,{...U.defaultProps,...i});f(this,"device");f(this,"gl");f(this,"handle");f(this,"texture");this.device=r,this.gl=this.device.gl,this.handle=null,this.texture=i.texture}}function Nc(e){return ab[e]}const ab={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};class yt extends U{constructor(r,i){super(r,i,{byteAlignment:1});f(this,"device");f(this,"gl");f(this,"handle");f(this,"sampler");f(this,"view");f(this,"glTarget");f(this,"glFormat");f(this,"glType");f(this,"glInternalFormat");f(this,"compressed");f(this,"_textureUnit",0);f(this,"_framebuffer",null);f(this,"_framebufferAttachmentKey",null);this.device=r,this.gl=this.device.gl;const s=Mc(this.props.format);this.glTarget=fb(this.props.dimension),this.glInternalFormat=s.internalFormat,this.glFormat=s.format,this.glType=s.type,this.compressed=s.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:n,width:o,height:a,depth:c,mipLevels:l,glTarget:u,glInternalFormat:h}=this;if(!this.compressed)switch(n){case"2d":case"cube":this.gl.texStorage2D(u,l,h,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(u,l,h,o,a,c);break;default:throw new Error(n)}this.gl.bindTexture(this.glTarget,null),this._initializeData(i.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new Xe(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){var r;this.handle&&((r=this._framebuffer)==null||r.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(r){return new Xe(this.device,{...r,texture:this})}setSampler(r={}){super.setSampler(r);const i=Ic(this.sampler.props);this._setSamplerParameters(i)}copyExternalImage(r){const i=this._normalizeCopyExternalImageOptions(r);if(i.sourceX||i.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:s,glType:n}=this,{image:o,depth:a,mipLevel:c,x:l,y:u,z:h,width:d,height:g}=i,p=qt(this.glTarget,this.dimension,h),_=i.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Ee(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(p,c,l,u,d,g,s,n,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(p,c,l,u,h,d,g,a,s,n,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:i.width,height:i.height}}copyImageData(r){super.copyImageData(r)}readBuffer(r={},i){if(!i)throw new Error(`${this} readBuffer requires a destination buffer`);const s=this._getSupportedColorReadOptions(r),n=r.byteOffset??0,o=this.computeMemoryLayout(s);if(i.byteLength{this.gl.readPixels(s.x,s.y,s.width,s.height,this.glFormat,this.glType,n+c)})}finally{this.gl.bindBuffer(35051,null)}return i}async readDataAsync(r={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(r,i={}){const s=this._normalizeTextureWriteOptions(i),{width:n,height:o,depthOrArrayLayers:a,mipLevel:c,byteOffset:l,x:u,y:h,z:d}=s,{glFormat:g,glType:p,compressed:_}=this,m=qt(this.glTarget,this.dimension,d);if(_)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");const{bytesPerPixel:b}=this.device.getTextureFormatInfo(this.format),R=b?s.bytesPerRow/b:void 0,T={3317:this.byteAlignment,...R!==void 0?{3314:R}:{},32878:s.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,r.handle),Ee(this.gl,T,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,c,u,h,n,o,g,p,l);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,c,u,h,d,n,o,a,g,p,l);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(r,i={}){const s=this._normalizeTextureWriteOptions(i),n=ArrayBuffer.isView(r)?r:new Uint8Array(r),{width:o,height:a,depthOrArrayLayers:c,mipLevel:l,x:u,y:h,z:d,byteOffset:g}=s,{glFormat:p,glType:_,compressed:m}=this,b=qt(this.glTarget,this.dimension,d);let R;if(!m){const{bytesPerPixel:v}=this.device.getTextureFormatInfo(this.format);v&&(R=s.bytesPerRow/v)}const T=this.compressed?{}:{3317:this.byteAlignment,...R!==void 0?{3314:R}:{},32878:s.rowsPerImage},y=lb(n,g),E=m?cb(n,g):n,S=this._getMipLevelSize(l),C=u===0&&h===0&&d===0&&o===S.width&&a===S.height&&c===S.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),Ee(this.gl,T,()=>{switch(this.dimension){case"2d":case"cube":m?C?this.gl.compressedTexImage2D(b,l,p,o,a,0,E):this.gl.compressedTexSubImage2D(b,l,u,h,o,a,p,E):this.gl.texSubImage2D(b,l,u,h,o,a,p,_,n,y);break;case"2d-array":case"3d":m?C?this.gl.compressedTexImage3D(b,l,p,o,a,c,0,E):this.gl.compressedTexSubImage3D(b,l,u,h,d,o,a,c,p,E):this.gl.texSubImage3D(b,l,u,h,d,o,a,c,p,_,n,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(r,i){return 1}_getFramebuffer(){return this._framebuffer||(this._framebuffer=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]})),this._framebuffer}readDataSyncWebGL(r={}){const i=this._getSupportedColorReadOptions(r),s=this.computeMemoryLayout(i),n=Nc(this.glType),o=ka(n),a=new o(s.byteLength/o.BYTES_PER_ELEMENT);return this._readColorTextureLayers(i,s,c=>{const l=new o(a.buffer,a.byteOffset+c,s.bytesPerImage/o.BYTES_PER_ELEMENT);this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,l)}),a.buffer}_readColorTextureLayers(r,i,s){const n=this._getFramebuffer(),o=i.bytesPerRow/i.bytesPerPixel,a={3333:this.byteAlignment,...o!==r.width?{3330:o}:{}},c=this.gl.getParameter(3074),l=this.gl.bindFramebuffer(36160,n.handle);try{this.gl.readBuffer(36064),Ee(this.gl,a,()=>{for(let u=0;u`"${l.name}"`).join(", ");i!=null&&i.disableWarnings||A.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${c}`,o)()}}}draw(r){var R;this._syncLinkStatus();const i=r.bindGroups?Un(r.bindGroups):r.bindings||this.bindings,{renderPass:s,parameters:n=this.props.parameters,topology:o=this.props.topology,vertexArray:a,vertexCount:c,instanceCount:l,isInstanced:u=!1,firstVertex:h=0,transformFeedback:d,uniforms:g=this.uniforms}=r,p=hb(o),_=!!a.indexBuffer,m=(R=a.indexBuffer)==null?void 0:R.glIndexType;if(this.linkStatus!=="success")return A.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(i))return A.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(s),d&&d.begin(this.props.topology),this._applyBindings(i,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(g);const b=s;return Gm(this.device,n,b.glParameters,()=>{_&&u?this.device.gl.drawElementsInstanced(p,c||0,m,h,l||0):_?this.device.gl.drawElements(p,c||0,m,h):u?this.device.gl.drawArraysInstanced(p,h,c||0,l||0):this.device.gl.drawArrays(p,h,c||0),d&&d.end()}),a.unbindAfterRender(s),!0}_areTexturesRenderable(r){let i=!0;for(const s of this.shaderLayout.bindings)yo(r,s.name)||(A.warn(`Binding ${s.name} not found in ${this.id}`)(),i=!1);return i}_applyBindings(r,i){if(this._syncLinkStatus(),this.linkStatus!=="success")return;const{gl:s}=this.device;s.useProgram(this.handle);let n=0,o=0;for(const a of this.shaderLayout.bindings){const c=yo(r,a.name);if(!c)throw new Error(`No value for binding ${a.name} in ${this.id}`);switch(a.type){case"uniform":const{name:l}=a,u=s.getUniformBlockIndex(this.handle,l);if(u===4294967295)throw new Error(`Invalid uniform block name ${l}`);if(s.uniformBlockBinding(this.handle,u,o),c instanceof At)s.bindBufferBase(35345,o,c.handle);else{const d=c;s.bindBufferRange(35345,o,d.buffer.handle,d.offset||0,d.size||d.buffer.byteLength-(d.offset||0))}o+=1;break;case"texture":if(!(c instanceof Xe||c instanceof yt||c instanceof Tt))throw new Error("texture");let h;if(c instanceof Xe)h=c.texture;else if(c instanceof yt)h=c;else if(c instanceof Tt&&c.colorAttachments[0]instanceof Xe)A.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),h=c.colorAttachments[0].texture;else throw new Error("No texture");s.activeTexture(33984+n),s.bindTexture(h.glTarget,h.handle),n+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${a.type}' not supported in WebGL`)}}}_applyUniforms(r){for(const i of this.shaderLayout.uniforms||[]){const{name:s,location:n,type:o,textureUnit:a}=i,c=r[s]??a;c!==void 0&&ub(this.device.gl,n,o,c)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}function pb(e,t){const r={...e,attributes:e.attributes.map(i=>({...i})),bindings:e.bindings.map(i=>({...i}))};for(const i of(t==null?void 0:t.attributes)||[]){const s=r.attributes.find(n=>n.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):A.warn(`shader layout attribute ${i.name} not present in shader`)}for(const i of(t==null?void 0:t.bindings)||[]){const s=Bc(r,i.name);if(!s){A.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(s,i)}return r}function Bc(e,t){return e.bindings.find(r=>r.name===t||r.name===`${t}Uniforms`||`${r.name}Uniforms`===t)}function yo(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}function _b(e){return Tb[e]}function Ls(e){return bb[e]}function Dc(e){return!!Fc[e]}function mb(e){return Fc[e]}const bb={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},Fc={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Tb={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Ab(e,t){const r={attributes:[],bindings:[]};r.attributes=yb(e,t);const i=Sb(e,t);for(const a of i){const c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}const s=Eb(e,t);let n=0;for(const a of s)if(Dc(a.type)){const{viewDimension:c,sampleType:l}=mb(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}s.length&&(r.uniforms=s);const o=Rb(e,t);return o!=null&&o.length&&(r.varyings=o),r}function yb(e,t){const r=[],i=e.getProgramParameter(t,35721);for(let s=0;s=0){const l=Ls(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:u,type:l})}}return r.sort((s,n)=>s.location-n.location),r}function Rb(e,t){const r=[],i=e.getProgramParameter(t,35971);for(let s=0;ss.location-n.location),r}function Eb(e,t){const r=[],i=e.getProgramParameter(t,35718);for(let s=0;s1)for(let g=0;ge.getActiveUniformBlockParameter(t,n,o),i=[],s=e.getProgramParameter(t,35382);for(let n=0;np.name.split(".")[0]).filter(p=>!!p)),g=o.name.replace(/Uniforms$/,"");if(d.size===1&&!d.has(o.name)&&!d.has(g)){const[p]=d;A.warn(`Uniform block "${o.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${o.name}") and alias ("${g}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(o)}return i.sort((n,o)=>n.location-o.location),i}function Cb(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};const r=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:Os(r==null?void 0:r[1],`Failed to parse GLSL uniform name ${e}`),length:r!=null&&r[2]?1:0,isArray:!!(r!=null&&r[2])}}const Ro=4;class vb extends gg{constructor(r,i){super(r,i);f(this,"device");f(this,"handle");f(this,"vs");f(this,"fs");f(this,"introspectedLayout",{attributes:[],bindings:[],uniforms:[]});f(this,"linkStatus","pending");this.device=r,this.handle=i.handle||this.device.gl.createProgram(),this.vs=i.vs,this.fs=i.fs,i.varyings&&i.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,i.varyings,i.bufferMode||35981),this._linkShaders(),A.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Ab(this.device.gl,this.handle),A.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){const{gl:r}=this.device;if(r.attachShader(this.handle,this.vs.handle),r.attachShader(this.handle,this.fs.handle),A.time(Ro,`linkProgram for ${this.id}`)(),r.linkProgram(this.handle),A.timeEnd(Ro,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){const s=this._getLinkStatus();this._reportLinkStatus(s);return}A.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),A.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const i=this._getLinkStatus();this._reportLinkStatus(i)}async _reportLinkStatus(r){var i;switch(r){case"success":return;default:const s=r==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${s} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((i=this.fs)==null?void 0:i.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${s} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${s} during ${r}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:r}=this.device;return r.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),r.validateProgram(this.handle),r.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){const{gl:r}=this.device;r.useProgram(this.handle);let i=0;const s=r.getProgramParameter(this.handle,35718);for(let n=0;n1){const a=Int32Array.from({length:i.size},(c,l)=>n+l);return o.uniform1iv(r,a),n+i.size}return o.uniform1i(r,n),n+1}async _waitForLinkComplete(){const r=async n=>await new Promise(o=>setTimeout(o,n));if(!this.device.features.has("compilation-status-async-webgl")){await r(10);return}const{gl:s}=this.device;for(;;){if(s.getProgramParameter(this.handle,37297))return;await r(10)}}}class Pb extends Ki{constructor(r,i={}){super(r,i);f(this,"device");f(this,"handle",null);f(this,"commands",[]);this.device=r}_executeCommands(r=this.commands){for(const i of r)switch(i.name){case"copy-buffer-to-buffer":wb(this.device,i.options);break;case"copy-buffer-to-texture":Ob(this.device,i.options);break;case"copy-texture-to-buffer":xb(this.device,i.options);break;case"copy-texture-to-texture":Mb(this.device,i.options);break;default:throw new Error(i.name)}}}function wb(e,t){const r=t.sourceBuffer,i=t.destinationBuffer;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,i.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Ob(e,t){throw new Error("copyBufferToTexture is not supported in WebGL")}function xb(e,t){const{sourceTexture:r,mipLevel:i=0,aspect:s="all",width:n=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if(r instanceof U){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:n,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:s,byteOffset:u},l);return}if(s!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||h||d)throw new Error("not implemented");const{framebuffer:g,destroyFramebuffer:p}=Uc(r);let _;try{const m=l,b=n||g.width,R=o||g.height,T=Os(g.colorAttachments[0]),y=Mc(T.texture.props.format),E=y.format,S=y.type;e.gl.bindBuffer(35051,m.handle),_=e.gl.bindFramebuffer(36160,g.handle),e.gl.readPixels(c[0],c[1],b,R,E,S,u)}finally{e.gl.bindBuffer(35051,null),_!==void 0&&e.gl.bindFramebuffer(36160,_),p&&g.destroy()}}function Mb(e,t){const{sourceTexture:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:n=[0,0,0],destinationTexture:o}=t;let{width:a=t.destinationTexture.width,height:c=t.destinationTexture.height}=t;const{framebuffer:l,destroyFramebuffer:u}=Uc(r),[h=0,d=0]=s,[g,p,_]=n,m=e.gl.bindFramebuffer(36160,l.handle);let b,R;if(o instanceof yt)b=o,a=Number.isFinite(a)?a:b.width,c=Number.isFinite(c)?c:b.height,b._bind(0),R=b.glTarget;else throw new Error("invalid destination");switch(R){case 3553:case 34067:e.gl.copyTexSubImage2D(R,i,g,p,h,d,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(R,i,g,p,_,h,d,a,c);break}b&&b._unbind(),e.gl.bindFramebuffer(36160,m),u&&l.destroy()}function Uc(e){if(e instanceof U){const{width:t,height:r,id:i}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}const Ib=[1,2,4,8];class Nb extends Xi{constructor(r,i){var a;super(r,i);f(this,"device");f(this,"handle",null);f(this,"glParameters",{});this.device=r;const s=this.props.framebuffer,n=!s||s.handle===null;n&&r.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let o;if(!((a=i==null?void 0:i.parameters)!=null&&a.viewport))if(!n&&s){const{width:c,height:l}=s;o=[0,0,c,l]}else{const[c,l]=r.getDefaultCanvasContext().getDrawingBufferSize();o=[0,0,c,l]}if(this.device.pushState(),this.setParameters({viewport:o,...this.props.parameters}),!n&&(s!=null&&s.colorAttachments.length)){const c=s.colorAttachments.map((l,u)=>36064+u);this.device.gl.drawBuffers(c)}else n&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(r){}popDebugGroup(){}insertDebugMarker(r){}setParameters(r={}){const i={...this.glParameters};i.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(i.depthMask=!this.props.depthReadOnly),i.stencilMask=this.props.stencilReadOnly?0:1,i[35977]=this.props.discard,r.viewport&&(r.viewport.length>=6?(i.viewport=r.viewport.slice(0,4),i.depthRange=[r.viewport[4],r.viewport[5]]):i.viewport=r.viewport),r.scissorRect&&(i.scissorTest=!0,i.scissor=r.scissorRect),r.blendConstant&&(i.blendColor=r.blendConstant),r.stencilReference!==void 0&&(i[2967]=r.stencilReference,i[36003]=r.stencilReference),"colorMask"in r&&(i.colorMask=Ib.map(s=>!!(s&r.colorMask))),this.glParameters=i,ot(this.device.gl,i)}beginOcclusionQuery(r){const i=this.props.occlusionQuerySet;i==null||i.beginOcclusionQuery()}endOcclusionQuery(){const r=this.props.occlusionQuerySet;r==null||r.endOcclusionQuery()}clear(){const r={...this.glParameters};let i=0;this.props.clearColors&&this.props.clearColors.forEach((s,n)=>{s&&this.clearColorBuffer(n,s)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(i|=16384,r.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(i|=256,r.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(i|=1024,r.clearStencil=this.props.clearStencil),i!==0&&Ee(this.device.gl,r,()=>{this.device.gl.clear(i)})}clearColorBuffer(r=0,i=[0,0,0,0]){Ee(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(i.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,r,i);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,r,i);break;case Float32Array:this.device.gl.clearBufferfv(6144,r,i);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class Eo extends Yi{constructor(r,i){super(r,i);f(this,"device");f(this,"handle",null);f(this,"commandBuffer");this.device=r,this.commandBuffer=new Pb(r,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(r){return r!=null&&r.id&&this.commandBuffer.id!==r.id&&(this.commandBuffer.id=r.id,this.commandBuffer.props.id=r.id),this.destroy(),this.commandBuffer}beginRenderPass(r={}){return new Nb(this.device,this._applyTimeProfilingToPassProps(r))}beginComputePass(r={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(r){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:r})}copyBufferToTexture(r){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:r})}copyTextureToBuffer(r){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:r})}copyTextureToTexture(r){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:r})}pushDebugGroup(r){}popDebugGroup(){}insertDebugMarker(r){}resolveQuerySet(r,i,s){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(r,i){r.writeTimestamp(i)}}function Bb(e){const{target:t,source:r,start:i=0,count:s=1}=e,n=r.length,o=s*n;let a=0;for(let c=i;a{for(const[i,s]of Object.entries(r))this.setBuffer(i,s)})}setBuffer(r,i){const s=this._getVaryingIndex(r),{buffer:n,byteLength:o,byteOffset:a}=this._getBufferRange(i);if(s<0){this.unusedBuffers[r]=n,A.warn(`${this.id} unusedBuffers varying buffer ${r}`)();return}this.buffers[s]={buffer:n,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(s,n,a,o)}getBuffer(r){if(So(r))return this.buffers[r]||null;const i=this._getVaryingIndex(r);return this.buffers[i]??null}bind(r=this.handle){if(typeof r!="function")return this.gl.bindTransformFeedback(36386,r),this;let i;return this._bound?i=r():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,i=r(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),i}unbind(){this.bind(null)}_getBufferRange(r){if(r instanceof At)return{buffer:r,byteOffset:0,byteLength:r.byteLength};const{buffer:i,byteOffset:s=0,byteLength:n=r.buffer.byteLength}=r;return{buffer:i,byteOffset:s,byteLength:n}}_getVaryingIndex(r){if(So(r))return Number(r);for(const i of this.layout.varyings||[])if(r===i.name)return i.location;return-1}_bindBuffers(){for(const[r,i]of Object.entries(this.buffers)){const{buffer:s,byteLength:n,byteOffset:o}=this._getBufferRange(i);this._bindBuffer(Number(r),s,o,n)}}_unbindBuffers(){for(const r in this.buffers)this.gl.bindBufferBase(35982,Number(r),null)}_bindBuffer(r,i,s=0,n){const o=i&&i.handle;!o||n===void 0?this.gl.bindBufferBase(35982,r,o):this.gl.bindBufferRange(35982,r,o,s,n)}}function So(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}class Lb extends Zi{constructor(r,i){super(r,i);f(this,"device");f(this,"handle");f(this,"_timestampPairs",[]);f(this,"_pendingReads",new Set);f(this,"_occlusionQuery",null);f(this,"_occlusionActive",!1);if(this.device=r,i.type==="timestamp"){if(i.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(i.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(i.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");const s=this.device.gl.createQuery();if(!s)throw new Error("WebGL query not supported");this.handle=s}Object.seal(this)}get[Symbol.toStringTag](){return"QuerySet"}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(const r of this._timestampPairs){r.activeQuery&&(this._cancelPendingQuery(r.activeQuery),this.device.gl.deleteQuery(r.activeQuery.handle));for(const i of r.completedQueries)this._cancelPendingQuery(i),this.device.gl.deleteQuery(i.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(const r of Array.from(this._pendingReads))this._cancelPendingQuery(r);this.destroyResource()}}isResultAvailable(r){return this.props.type==="timestamp"?r===void 0?this._timestampPairs.some((i,s)=>this._isTimestampPairAvailable(s)):this._isTimestampPairAvailable(this._getTimestampPairIndex(r)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(r){const i=(r==null?void 0:r.firstQuery)||0,s=(r==null?void 0:r.queryCount)||this.props.count-i;if(this._validateRange(i,s),this.props.type==="timestamp"){const n=new Array(s).fill(0n),o=Math.floor(i/2),a=Math.floor((i+s-1)/2);for(let c=o;c<=a;c++){const l=await this._consumeTimestampPairResult(c),u=c*2,h=u+1;u>=i&&u=i&&h=this.props.count||i<=r)throw new Error("Timestamp duration range is out of bounds");if(r%2!==0||i!==r+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");const s=await this._consumeTimestampPairResult(this._getTimestampPairIndex(r));return Number(s)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(r){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");const i=this._getTimestampPairIndex(r),s=this._timestampPairs[i];if(r%2===0){if(s.activeQuery)throw new Error("Timestamp query pair is already active");const n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");const o={handle:n,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,n),s.activeQuery=o;return}if(!s.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),s.completedQueries.push(s.activeQuery),s.activeQuery=null}_validateRange(r,i){if(r<0||i<0||r+i>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(r){if(r<0||r>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(r/2)}_isTimestampPairAvailable(r){const i=this._timestampPairs[r];return!i||i.completedQueries.length===0?!1:this._pollQueryAvailability(i.completedQueries[0])}_pollQueryAvailability(r){if(r.cancelled||this.destroyed)return r.result=0n,!0;if(r.result!==null||r.disjoint)return!0;if(!this.device.gl.getQueryParameter(r.handle,34919))return!1;const s=!!this.device.gl.getParameter(36795);return r.disjoint=s,r.result=s?0n:BigInt(this.device.gl.getQueryParameter(r.handle,34918)),!0}async _consumeTimestampPairResult(r){const i=this._timestampPairs[r];if(!i||i.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");const s=i.completedQueries.shift();try{return await this._consumeQueryResult(s)}finally{this.device.gl.deleteQuery(s.handle)}}_consumeQueryResult(r){return r.promise||(this._pendingReads.add(r),r.promise=new Promise((i,s)=>{r.resolve=i,r.reject=s;const n=()=>{if(r.pollRequestId=null,r.cancelled||this.destroyed){this._pendingReads.delete(r),r.promise=null,r.resolve=null,r.reject=null,i(0n);return}if(!this._pollQueryAvailability(r)){r.pollRequestId=this._requestAnimationFrame(n);return}this._pendingReads.delete(r),r.promise=null,r.resolve=null,r.reject=null,r.disjoint?s(new Error("GPU timestamp query was invalidated by a disjoint event")):i(r.result||0n)};n()})),r.promise}_cancelPendingQuery(r){if(this._pendingReads.delete(r),r.cancelled=!0,r.pollRequestId!==null&&(this._cancelAnimationFrame(r.pollRequestId),r.pollRequestId=null),r.resolve){const i=r.resolve;r.promise=null,r.resolve=null,r.reject=null,i(0n)}}_requestAnimationFrame(r){return requestAnimationFrame(r)}_cancelAnimationFrame(r){cancelAnimationFrame(r)}}class kb extends Ji{constructor(r,i={}){super(r,{});f(this,"device");f(this,"gl");f(this,"handle");f(this,"signaled");f(this,"_signaled",!1);this.device=r,this.gl=r.gl;const s=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!s)throw new Error("Failed to create WebGL fence");this.handle=s,this.signaled=new Promise(n=>{const o=()=>{const a=this.gl.clientWaitSync(this.handle,0,0);a===this.gl.ALREADY_SIGNALED||a===this.gl.CONDITION_SATISFIED?(this._signaled=!0,n()):setTimeout(o,1)};o()})}isSignaled(){if(this._signaled)return!0;const r=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=r===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}function Lc(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function Wb(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function $b(e,t){var R;const{sourceX:r=0,sourceY:i=0,sourceAttachment:s=0}=t||{};let{target:n=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=t||{};const{framebuffer:h,deleteFramebuffer:d}=kc(e),{gl:g,handle:p}=h;o||(o=h.width),a||(a=h.height);const _=(R=h.colorAttachments[s])==null?void 0:R.texture;if(!_)throw new Error(`Invalid framebuffer attachment ${s}`);c=(_==null?void 0:_.depth)||1,l||(l=(_==null?void 0:_.glFormat)||6408),u||(u=(_==null?void 0:_.glType)||5121),n=Hb(n,u,l,o,a);const m=le.getDataType(n);u=u||_b(m);const b=g.bindFramebuffer(36160,p);return g.readBuffer(36064+s),g.readPixels(r,i,o,a,l,u,n),g.readBuffer(36064),g.bindFramebuffer(36160,b||null),d&&h.destroy(),n}function zb(e,t){const{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:n=6408,targetByteOffset:o=0}=t||{};let{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{};const{framebuffer:u,deleteFramebuffer:h}=kc(e);a=a||u.width,c=c||u.height;const d=u;l=l||5121;let g=r;if(!g){const _=Lc(n),m=Wb(l),b=o+a*c*_*m;g=d.device.createBuffer({byteLength:b})}const p=e.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:e,width:a,height:c,origin:[i,s],destinationBuffer:g,byteOffset:o}),p.destroy(),h&&u.destroy(),g}function kc(e){return e instanceof dr?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:jb(e),deleteFramebuffer:!0}}function jb(e,t){const{device:r,width:i,height:s,id:n}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${n}`,width:i,height:s,colorAttachments:[e]})}function Hb(e,t,r,i,s,n){if(e)return e;t||(t=5121);const o=Nc(t),a=le.getTypedArrayConstructor(o),c=Lc(r);return new a(i*s*c)}class Oe extends fr{constructor(r){var h;super({...r,id:r.id||Km("webgl-device")});f(this,"type","webgl");f(this,"handle");f(this,"features");f(this,"limits");f(this,"info");f(this,"canvasContext");f(this,"preferredColorFormat","rgba8unorm");f(this,"preferredDepthFormat","depth24plus");f(this,"commandEncoder");f(this,"lost");f(this,"_resolveContextLost");f(this,"gl");f(this,"_constants");f(this,"extensions");f(this,"_polyfilled",!1);f(this,"spectorJS");const i=fr._getCanvasContextProps(r);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");const s=((h=i.canvas)==null?void 0:h.gl)??null;let n=Oe.getDeviceFromContext(s);if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Xm(this,i),this.lost=new Promise(d=>{this._resolveContextLost=d});const o={...r.webgl};i.alphaMode==="premultiplied"&&(o.premultipliedAlpha=!0),r.powerPreference!==void 0&&(o.powerPreference=r.powerPreference),r.failIfMajorPerformanceCaveat!==void 0&&(o.failIfMajorPerformanceCaveat=r.failIfMajorPerformanceCaveat);const c=this.props._handle||Sm(this.canvasContext.canvas,{onContextLost:d=>{var g;return(g=this._resolveContextLost)==null?void 0:g.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:d=>console.log("WebGL context restored")},o);if(!c)throw new Error("WebGL context creation failed");if(n=Oe.getDeviceFromContext(c),n){if(r._reuseDevices)return A.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),this.canvasContext.destroy(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=c,this.gl=c,this.spectorJS=lm({...this.props,gl:this.handle});const l=Rr(this.handle);l.device=this,l.extensions||(l.extensions={}),this.extensions=l.extensions,this.info=Cm(this.gl,this.extensions),this.limits=new jm(this.gl),this.features=new zm(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Pe(this.gl,{log:(...d)=>A.log(1,...d)()}).trackState(this.gl,{copyState:!1}),(r.debug||r.debugWebGL)&&(this.gl=um(this.gl,{debugWebGL:!0,traceWebGL:r.debugWebGL}),A.warn("WebGL debug mode activated. Performance reduced.")()),r.debugWebGL&&(A.level=Math.max(A.level,1)),this.commandEncoder=new Eo(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}static getDeviceFromContext(r){var i;return r?((i=r.luma)==null?void 0:i.device)??null:null}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(r){switch(r){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){var r;if((r=this.commandEncoder)==null||r.destroy(),!this.props._reuseDevices&&!this._reused){const i=Rr(this.handle);i.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(r){throw new Error("WebGL only supports a single canvas")}createPresentationContext(r){return new Ym(this,r||{})}createBuffer(r){const i=this._normalizeBufferProps(r);return new At(this,i)}createTexture(r){return new yt(this,r)}createExternalTexture(r){throw new Error("createExternalTexture() not implemented")}createSampler(r){return new nb(this,r)}createShader(r){return new Jm(this,r)}createFramebuffer(r){return new Tt(this,r)}createVertexArray(r){return new ks(this,r)}createTransformFeedback(r){return new Ub(this,r)}createQuerySet(r){return new Lb(this,r)}createFence(){return new kb(this)}createRenderPipeline(r){return new gb(this,r)}_createSharedRenderPipelineWebGL(r){return new vb(this,r)}createComputePipeline(r){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(r={}){return new Eo(this,r)}submit(r){let i=null;r||({submittedCommandEncoder:i,commandBuffer:r}=this._finalizeDefaultCommandEncoderForSubmit());try{r._executeCommands(),i&&i.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=i._gpuTimeMs}).catch(()=>{})}finally{r.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){const r=this.commandEncoder,i=r.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:r.props.id,timeProfilingQuerySet:r.getTimeProfilingQuerySet()}),{submittedCommandEncoder:r,commandBuffer:i}}readPixelsToArrayWebGL(r,i){return $b(r,i)}readPixelsToBufferWebGL(r,i){return zb(r,i)}setParametersWebGL(r){ot(this.gl,r)}getParametersWebGL(r){return Cc(this.gl,r)}withParametersWebGL(r,i){return Ee(this.gl,r,i)}resetWebGL(){A.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Tm(this.gl)}_getDeviceSpecificTextureFormatCapabilities(r){return Um(this.gl,r,this.extensions)}loseDevice(){var n;let r=!1;const s=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return s&&(r=!0,s.loseContext()),(n=this._resolveContextLost)==null||n.call(this,{reason:"destroyed",message:"Application triggered context loss"}),r}pushState(){Pe.get(this.gl).push()}popState(){Pe.get(this.gl).pop()}getGLKey(r,i){const s=Number(r);for(const n in this.gl)if(this.gl[n]===s)return`GL.${n}`;return i!=null&&i.emptyIfUnknown?"":String(r)}getGLKeys(r){const i={emptyIfUnknown:!0};return Object.entries(r).reduce((s,[n,o])=>(s[`${n}:${this.getGLKey(n,i)}`]=`${o}:${this.getGLKey(o,i)}`,s),{})}setConstantAttributeWebGL(r,i){const s=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(s).fill(null);const n=this._constants[r];switch(n&&Kb(n,i)&&A.info(1,`setConstantAttributeWebGL(${r}) could have been skipped, value unchanged`)(),this._constants[r]=i,i.constructor){case Float32Array:Vb(this,r,i);break;case Int32Array:Xb(this,r,i);break;case Uint32Array:Yb(this,r,i);break;default:throw new Error("constant")}}getExtension(r){return Ne(this.gl,r,this.extensions),this.extensions}_setWebGLDebugMetadata(r,i,s){r.luma=i;const n={props:s.spector,id:s.spector.id};r.__SPECTOR_Metadata=n}}function Vb(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break}}function Xb(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Yb(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function Kb(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r4)return null;const i=r==="webgpu"&&t.type==="uint8"?"unorm8":t.type;return{attribute:e,format:t.size>1?`${i}x${t.size}`:t.type,byteOffset:t.offset||0}}function Se(e){return e.stride||e.size*e.bytesPerElement}function Zb(e,t){return e.type===t.type&&e.size===t.size&&Se(e)===Se(t)&&(e.offset||0)===(t.offset||0)}function fs(e,t){t.offset&&G.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const r=Se(e),i=t.vertexOffset!==void 0?t.vertexOffset:e.vertexOffset||0,s=t.elementOffset||0,n=i*r+s*e.bytesPerElement+(e.offset||0);return{...t,offset:n,stride:r}}function Jb(e,t){const r=fs(e,t);return{high:r,low:{...r,offset:r.offset+e.size*4}}}class Gb{constructor(t,r,i){this._buffer=null,this.device=t,this.id=r.id||"",this.size=r.size||1;const s=r.logicalType||r.type,n=s==="float64";let{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=Qb(s||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const t=this.getAccessor();return t.vertexOffset?t.vertexOffset*Se(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Pt.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(t=this.id,r=null){const i={};if(this.state.constant){const s=this.value;if(r){const n=fs(this.getAccessor(),r),o=n.offset/s.BYTES_PER_ELEMENT,a=n.size||this.size;i[t]=s.subarray(o,o+a)}else i[t]=s}else i[t]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${t}64Low`]=i[t]:i[`${t}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(t=this.id,r=null){const i=this.getAccessor(),s=[],n={name:this.id,byteStride:Se(i)};if(this.doublePrecision){const o=Jb(i,r||{});s.push(Zt(t,{...i,...o.high},this.device.type),Zt(`${t}64Low`,{...i,...o.low},this.device.type))}else if(r){const o=fs(i,r);s.push(Zt(t,{...i,...o},this.device.type))}else s.push(Zt(t,i,this.device.type));return n.attributes=s.filter(Boolean),n}setAccessor(t){this.state.bufferAccessor=t}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let t=null;if(this.state.constant&&this.value){const r=Array.from(this.value);t=[r,r]}else{const{value:r,numInstances:i,size:s}=this,n=i*s;if(r&&n&&r.length>=n){const o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}t=[o,a]}}return this.state.bounds=t,t}setData(t){const{state:r}=this;let i;ArrayBuffer.isView(t)?i={value:t}:t instanceof N?i={buffer:t}:i=t;const s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{const o=qb(i.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=Se(s)}if(r.bounds=null,i.constant){let n=i.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(i.buffer){const n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this;const a=Se(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=bi(n,s)),this.settings.isIndexed){const u=this.settings.defaultType;n.constructor!==u&&(n=new u(n))}const l=n.byteLength+c+a*2;(!o||o.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(t).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(t).map(r=>r/255);case"unorm16":return new Float32Array(t).map(r=>r/65535);default:return t}}_normalizeValue(t,r,i){const{defaultValue:s,size:n}=this.settings;if(Number.isFinite(t))return r[i]=t,r;if(!t){let o=n;for(;--o>=0;)r[i+o]=s[o];return r}switch(n){case 4:r[i+3]=Number.isFinite(t[3])?t[3]:s[3];case 3:r[i+2]=Number.isFinite(t[2])?t[2]:s[2];case 2:r[i+1]=Number.isFinite(t[1])?t[1]:s[1];case 1:r[i+0]=Number.isFinite(t[0])?t[0]:s[0];break;default:let o=n;for(;--o>=0;)r[i+o]=Number.isFinite(t[o])?t[o]:s[o]}return r}_areValuesEqual(t,r){if(!t||!r)return!1;const{size:i}=this;for(let s=0;s0&&(vo.length=e.length,i=vo):i=Co,(t>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(t,r),s.index=t-1),{iterable:i,objectInfo:s}}function $c(e){return e&&e[Symbol.asyncIterator]}function zc(e,t){const{size:r,stride:i,offset:s,startIndices:n,nested:o}=t,a=e.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,u=Math.floor((e.length-l)/c);return(h,{index:d,target:g})=>{if(!n){const b=d*c+l;for(let R=0;R=t[1]))return e;const r=[],i=e.length;let s=0;for(let n=0;nt[1]?r.push(o):t=[Math.min(o[0],t[0]),Math.max(o[1],t[1])]}return r.splice(s,0,t),r}const rT={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function jc(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const r=e.type||"interpolation";return{...rT[r],...t,...e,type:r}}class Hc extends Gb{constructor(t,r){super(t,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:tr}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(t){this.state.startIndices=t}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:t=!1}={}){const r=this.state.needsRedraw;return this.state.needsRedraw=r&&!t,r}layoutChanged(){return this.state.layoutChanged}setAccessor(t){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Zb(t,this.getAccessor())),super.setAccessor(t)}getUpdateTriggers(){const{accessor:t}=this.settings;return[this.id].concat(typeof t!="function"&&t||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(t){if(!t||!this.supportsTransition())return null;const{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?t[r.find(n=>t[n])]:t[r];return jc(s,i)}setNeedsUpdate(t=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),r){const{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=tT(this.state.updateRanges,[i,s])}else this.state.updateRanges=tr}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=eT}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){const{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(t,r.updateRanges!==tr),!0):!1}updateBuffer({numInstances:t,data:r,props:i,context:s}){if(!this.needsUpdate())return!1;const{state:{updateRanges:n},settings:{update:o,noAlloc:a}}=this;let c=!0;if(o){for(const[l,u]of n)o.call(s,this,{data:r,startRow:l,endRow:u,props:i,numInstances:t});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(T,_):(t._normalizeValue(T,b.target,0),am({target:l,source:b.target,start:_,count:y}));_+=y*u}else t._normalizeValue(T,l,_),_+=u}}_validateAttributeUpdaters(){const{settings:t}=this;if(!(t.noAlloc||typeof t.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:t}=this,r=Math.min(4,this.size);if(t&&t.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(t[3]);case 3:i=i&&Number.isFinite(t[2]);case 2:i=i&&Number.isFinite(t[1]);case 1:i=i&&Number.isFinite(t[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function Ii(e){const{source:t,target:r,start:i=0,size:s,getData:n}=e,o=e.end||r.length,a=t.length,c=o-i;if(a>c){r.set(t.subarray(0,c),i);return}if(r.set(t,i),!n)return;let l=a;for(;li(u+a,h)),l=Math.min(s.length,n.length);for(let u=1;ua}){const a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,u=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,h=r.startIndices,d=n&&h,g=r.isConstant;if(!d&&t&&i>=s)return t;const p=r.value instanceof Float64Array?Float32Array:r.value.constructor,_=g?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!g){const T=o;o=(y,E)=>r.normalizeConstant(T(y,E))}const m=g?(T,y)=>o(_,y):(T,y)=>o(_.subarray(T+l,T+l+c),y),b=t?new Float32Array(t.readSyncWebGL(u,i*4).buffer):new Float32Array(0),R=new Float32Array(s);return iT({source:b,target:R,sourceStartIndices:n,targetStartIndices:h,size:c,getData:m}),(!t||t.byteLength0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}const hT=`layout(std140) uniform springUniforms { + float damping; + float stiffness; +} spring; +`,dT={name:"spring",vs:hT,uniformTypes:{damping:"f32",stiffness:"f32"}},gT=`#version 300 es +#define SHADER_NAME spring-transition-vertex-shader + +#define EPSILON 0.00001 + +in ATTRIBUTE_TYPE aPrev; +in ATTRIBUTE_TYPE aCur; +in ATTRIBUTE_TYPE aTo; +out ATTRIBUTE_TYPE vNext; +out float vIsTransitioningFlag; + +ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { + ATTRIBUTE_TYPE velocity = cur - prev; + ATTRIBUTE_TYPE delta = dest - cur; + ATTRIBUTE_TYPE force = delta * spring.stiffness; + ATTRIBUTE_TYPE resistance = velocity * spring.damping; + return force - resistance + velocity + cur; +} + +void main(void) { + bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; + vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; + + vNext = getNextValue(aCur, aPrev, aTo); + gl_Position = vec4(0, 0, 0, 1); + gl_PointSize = 100.0; +} +`,pT=`#version 300 es +#define SHADER_NAME spring-transition-is-transitioning-fragment-shader + +in float vIsTransitioningFlag; + +out vec4 fragColor; + +void main(void) { + if (vIsTransitioningFlag == 0.0) { + discard; + } + fragColor = vec4(1.0); +}`;function _T(e,t){const r=Vc(t.size),i=Xc(t.size);return new Ot(e,{vs:gT,fs:pT,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[dT],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function mT(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function bT(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}const TT={interpolation:oT,spring:uT};class AT{constructor(t,{id:r,timeline:i}){if(!t)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=t,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:r,numInstances:i}){this.numInstances=i||1;for(const s in t){const n=t[s],o=n.getTransitionSetting(r);o&&this._updateAttribute(s,n,o)}for(const s in this.transitions){const n=t[s];(!n||!n.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(t){const r=this.transitions[t];return r&&r.inProgress}getAttributes(){const t={};for(const r in this.transitions){const i=this.transitions[r];i.inProgress&&(t[r]=i.attributeInTransition)}return t}run(){if(this.numInstances===0)return!1;for(const r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);const t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].delete(),delete this.transitions[t]}_updateAttribute(t,r,i){const s=this.transitions[t];let n=!s||s.type!==i.type;if(n){s&&this._removeTransition(t);const o=TT[i.type];o?this.transitions[t]=new o({attribute:r,timeline:this.timeline,device:this.device}):(G.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[t].start(i,this.numInstances))}}const wo="attributeManager.invalidate",yT="attributeManager.updateStart",RT="attributeManager.updateEnd",ET="attribute.updateStart",ST="attribute.allocate",CT="attribute.updateEnd";class vT{constructor(t,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=Is(S_),this.id=r,this.device=t,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new AT(t,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(const t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){const r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{stepMode:"instance"})}remove(t){for(const r of t)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(t,r){const i=this._invalidateTrigger(t,r);X(wo,this,t,i)}invalidateAll(t){for(const r in this.attributes)this.attributes[r].setNeedsUpdate(r,t);X(wo,this,"all")}update({data:t,numInstances:r,startIndices:i=null,transitions:s,props:n={},buffers:o={},context:a={}}){let c=!1;X(yT,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const l in this.attributes){const u=this.attributes[l],h=u.settings.accessor;u.startIndices=i,u.numInstances=r,n[l]&&G.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof h=="string"?o[h]:void 0,t.startIndices)||typeof h=="string"&&!o[h]&&u.setConstantValue(a,n[h])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:r,data:t,props:n,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&X(RT,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){const{attributeTransitionManager:t}=this,r=t.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(t){const r=t.map(i=>{var s;return(s=this.attributes[i])==null?void 0:s.getBounds()});return this.mergeBoundsMemoized(r)}getChangedAttributes(t={clearChangedFlags:!1}){const{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(const n in r){const o=r[n];o.needsRedraw(t)&&!i.hasAttribute(n)&&(s[n]=o)}return s}getBufferLayouts(t){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(t))}_add(t,r){for(const i in t){const s=t[i],n={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new Hc(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const t={};for(const r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{t[s]||(t[s]=[]),t[s].push(r)});this.updateTriggers=t}_invalidateTrigger(t,r){const{attributes:i,updateTriggers:s}=this,n=s[t];return n&&n.forEach(o=>{const a=i[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(t){const{attribute:r,numInstances:i}=t;if(X(ET,r),r.constant){r.setConstantValue(t.context,r.value);return}r.allocate(i)&&X(ST,r,i),r.updateBuffer(t)&&(this.needsRedraw=!0,X(CT,r,i))}}class PT extends Ds{get value(){return this._value}_onUpdate(){const{time:t,settings:{fromValue:r,toValue:i,duration:s,easing:n}}=this,o=n(t/s);this._value=ba(r,i,o)}}const Oo=1e-5;function xo(e,t,r,i,s){const n=t-e,a=(r-t)*s,c=-n*i;return a+c+n+t}function wT(e,t,r,i,s){if(Array.isArray(r)){const n=[];for(let o=0;o0}add(t,r,i,s){const{transitions:n}=this;if(n.has(t)){const c=n.get(t),{value:l=c.settings.fromValue}=c;r=l,this.remove(t)}if(s=jc(s),!s)return;const o=xT[s.type];if(!o){G.error(`unsupported transition type '${s.type}'`)();return}const a=new o(this.timeline);a.start({...s,fromValue:r,toValue:i}),n.set(t,a)}remove(t){const{transitions:r}=this;r.has(t)&&(r.get(t).cancel(),r.delete(t))}update(){const t={};for(const[r,i]of this.transitions)i.update(),t[r]=i.value,i.inProgress||this.remove(r);return t}clear(){for(const t of this.transitions.keys())this.remove(t)}}function IT(e){const t=e[be];for(const r in t){const i=t[r],{validate:s}=i;if(s&&!s(e[r],i))throw new Error(`Invalid prop ${r}: ${e[r]}`)}}function NT(e,t){const r=Jc({newProps:e,oldProps:t,propTypes:e[be],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=DT(e,t);let s=!1;return i||(s=FT(e,t)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:UT(e,t),transitionsChanged:BT(e,t)}}function BT(e,t){if(!e.transitions)return!1;const r={},i=e[be];let s=!1;for(const n in e.transitions){const o=i[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&us(e[n],t[n],o)&&(r[n]=!0,s=!0)}return s?r:!1}function Jc({newProps:e,oldProps:t,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(t===e)return!1;if(typeof e!="object"||e===null)return`${s} changed shallowly`;if(typeof t!="object"||t===null)return`${s} changed shallowly`;for(const n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${s}.${n} added`;const o=us(e[n],t[n],i[n]);if(o)return`${s}.${n} ${o}`}for(const n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${s}.${n} dropped`;if(!Object.hasOwnProperty.call(e,n)){const o=us(e[n],t[n],i[n]);if(o)return`${s}.${n} ${o}`}}return!1}function us(e,t,r){let i=r&&r.equal;return i&&!i(e,t,r)||!i&&(i=e&&t&&e.equals,i&&!i.call(e,t))?"changed deeply":!i&&t!==e?"changed shallowly":null}function DT(e,t){if(t===null)return"oldProps is null, initial diff";let r=!1;const{dataComparator:i,_dataDiff:s}=e;return i?i(e.data,t.data)||(r="Data comparator detected a change"):e.data!==t.data&&(r="A new data container was supplied"),r&&s&&(r=s(e.data,t.data)||r),r}function FT(e,t){if(t===null)return{all:!0};if("all"in e.updateTriggers&&Io(e,t,"all"))return{all:!0};const r={};let i=!1;for(const s in e.updateTriggers)s!=="all"&&Io(e,t,s)&&(r[s]=!0,i=!0);return i?r:!1}function UT(e,t){if(t===null)return!0;const r=t.extensions,{extensions:i}=e;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;si.name==="project64"))){const i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in t)if(!e.inject)r.inject=t.inject;else{const i={...e.inject};for(const s in t.inject)i[s]=(i[s]||"")+t.inject[s];r.inject=i}return r}const jT={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},hs={};function HT(e,t,r,i){if(r instanceof U)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});const{width:n,height:o}=r.data,a=t.createTexture({...r,sampler:{...jT,...s,...i},mipLevels:t.getMipLevelCount(n,o)});return t.type==="webgl"?a.generateMipmapsWebGL():t.type==="webgpu"&&t.generateMipmapsWebGPU(a),hs[a.id]=e,a}function VT(e,t){!t||!(t instanceof U)||hs[t.id]===e&&(t.delete(),delete hs[t.id])}const XT={boolean:{validate(e,t){return!0},equal(e,t,r){return!!e==!!t}},number:{validate(e,t){return Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)}},color:{validate(e,t){return t.optional&&!e||ds(e)&&(e.length===3||e.length===4)},equal(e,t,r){return ze(e,t,1)}},accessor:{validate(e,t){const r=Er(e);return r==="function"||r===Er(t.value)},equal(e,t,r){return typeof t=="function"?!0:ze(e,t,1)}},array:{validate(e,t){return t.optional&&!e||ds(e)},equal(e,t,r){const{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?ze(e,t,s):e===t}},object:{equal(e,t,r){if(r.ignore)return!0;const{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?ze(e,t,s):e===t}},function:{validate(e,t){return t.optional&&!e||typeof e=="function"},equal(e,t,r){return!r.compare&&r.ignore!==!1||e===t}},data:{transform:(e,t,r)=>{if(!e)return e;const{dataTransform:i}=r.props;return i?i(e):typeof e.shape=="string"&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,r)=>{const i=r.context;return!i||!i.device?null:HT(r.id,i.device,e,{...t.parameters,...r.props.textureParameters})},release:(e,t,r)=>{VT(r.id,e)}}};function YT(e){const t={},r={},i={};for(const[s,n]of Object.entries(e)){const o=n==null?void 0:n.deprecatedFor;if(o)i[s]=Array.isArray(o)?o:[o];else{const a=KT(s,n);t[s]=a,r[s]=a.value}}return{propTypes:t,defaultProps:r,deprecatedProps:i}}function KT(e,t){switch(Er(t)){case"object":return dt(e,t);case"array":return dt(e,{type:"array",value:t,compare:!1});case"boolean":return dt(e,{type:"boolean",value:t});case"number":return dt(e,{type:"number",value:t});case"function":return dt(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function dt(e,t){return"type"in t?{name:e,...XT[t.type],...t}:"value"in t?{name:e,type:Er(t.value),...t}:{name:e,type:"object",value:t}}function ds(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function Er(e){return ds(e)?"array":e===null?"null":typeof e}function QT(e,t){let r;for(let n=t.length-1;n>=0;n--){const o=t[n];"extensions"in o&&(r=o.extensions)}const i=gs(e.constructor,r),s=Object.create(i);s[yr]=e,s[Ie]={},s[me]={};for(let n=0;n{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const t in this.asyncProps){const r=this.asyncProps[t];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||sA}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){const r=this.asyncProps[t];return r&&r.resolvedValue}isAsyncPropLoading(t){if(t){const r=this.asyncProps[t];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(const r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(t,r){this._watchPromise(t,Promise.resolve(r))}setAsyncProps(t){this.component=t[yr]||this.component;const r=t[me]||{},i=t[Ie]||t,s=t[Qe]||{};for(const n in r){const o=r[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(const n in i){const o=i[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o)}}_fetch(t,r){return null}_onResolve(t,r){}_onError(t,r){}_updateAsyncProp(t,r){if(this._didAsyncInputValueChange(t,r)){if(typeof r=="string"&&(r=this._fetch(t,r)),r instanceof Promise){this._watchPromise(t,r);return}if($c(r)){this._resolveAsyncIterable(t,r);return}this._setPropValue(t,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,r){const i=this.asyncProps[t];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(t,r){this._freezeAsyncOldProps();const i=this.asyncProps[t];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(t,r,i){const s=this.asyncProps[t];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(t,r))}_watchPromise(t,r){const i=this.asyncProps[t];if(i){i.pendingLoadCount++;const s=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(t,n,s),this._onResolve(t,n))}).catch(n=>{this._onError(t,n)})}}async _resolveAsyncIterable(t,r){if(t!=="data"){this._setPropValue(t,r);return}const i=this.asyncProps[t];if(!i)return;i.pendingLoadCount++;const s=i.pendingLoadCount;let n=[],o=0;for await(const a of r){if(!this.component)return;const{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(t,n,s)}this._onResolve(t,n)}_postProcessValue(t,r){const i=t.type;return i&&this.component&&(i.release&&i.release(t.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(t,r){if(!this.asyncProps[t]){const s=this.component&&this.component.props[be];this.asyncProps[t]={type:s&&s[t],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}}class oA extends nA{constructor({attributeManager:t,layer:r}){super(r),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(t,r){const i=this.layer,s=i==null?void 0:i.props.fetch;return s?s(r,{propName:t,layer:i}):super._fetch(t,r)}_onResolve(t,r){const i=this.layer;if(i){const s=i.props.onDataLoad;t==="data"&&s&&s(r,{propName:t,layer:i})}}_onError(t,r){const i=this.layer;i&&i.raiseError(r,`loading ${t} of ${this.layer}`)}}const aA="layer.changeFlag",cA="layer.initialize",lA="layer.update",fA="layer.finalize",uA="layer.matched",Bo=2**24-1,hA=Object.freeze([]),dA=Is(({oldViewport:e,viewport:t})=>e.equals(t));let ee=new Uint8ClampedArray(0);const gA={data:{type:"data",value:hA,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:t,layer:r,loaders:i,loadOptions:s,signal:n})=>{var c;const{resourceManager:o}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,n&&(s={...s,core:{...s==null?void 0:s.core,fetch:{...(c=s==null?void 0:s.core)==null?void 0:c.fetch,signal:n}}});let a=o.contains(e);return!a&&!s&&(o.add({resourceId:e,data:an(e,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:l=>{var u;return(u=r.internalState)==null?void 0:u.reloadAsyncProp(t,l)},consumerId:r.id,requestId:t}):an(e,i,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class $s extends Kr{constructor(){super(...arguments),this.internalState=null,this.lifecycle=nm.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(t){pe(this.internalState);const r=this.internalState.viewport||this.context.viewport,i=Bs(t,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,n,o]=uc(i,r.pixelProjectionMatrix);return t.length===2?[s,n]:[s,n,o]}unproject(t){return pe(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(t)}projectPosition(t,r){pe(this.internalState);const i=this.internalState.viewport||this.context.viewport;return x_(t,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const t=this.state;return t&&(t.models||t.model&&[t.model])||[]}setShaderModuleProps(...t){for(const r of this.getModels())r.shaderInputs.setProps(...t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:t}=this.props;return t==="default"||t==="lnglat"||t==="cartesian"}onHover(t,r){return this.props.onHover&&this.props.onHover(t,r)||!1}onClick(t,r){return this.props.onClick&&this.props.onClick(t,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,r=[]){return r[0]=t+1&255,r[1]=t+1>>8&255,r[2]=t+1>>8>>8&255,r}decodePickingColor(t){pe(t instanceof Uint8Array);const[r,i,s]=t;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:WT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var t;return(t=this.getAttributeManager())==null?void 0:t.getBounds(["positions","instancePositions"])}getShaders(t){t=No(t,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const r of this.props.extensions)t=No(t,r.getShaders.call(this,r));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){const r=this.getAttributeManager(),{dataChanged:i}=t.changeFlags;if(i&&r)if(Array.isArray(i))for(const s of i)r.invalidateAll(s);else r.invalidateAll();if(r){const{props:s}=t,n=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||!!s.pickable||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==o){this.internalState.hasPickingBuffer=o;const{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(t){for(const i of this.getModels())i.destroy();const r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(const r of this.getModels())r.draw(t.renderPass)}getPickingInfo({info:t,mode:r,sourceLayer:i}){const{index:s}=t;return s>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[s]),t}raiseError(t,r){var i,s,n,o;r&&(t=new Error(`${r}: ${t.message}`,{cause:t})),(s=(i=this.props).onError)!=null&&s.call(i,t)||(o=(n=this.context)==null?void 0:n.onError)==null||o.call(n,t,this)}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){var t;return((t=this.internalState)==null?void 0:t.uniformTransitions.active)||!1}activateViewport(t){if(!this.internalState)return;const r=this.internalState.viewport;this.internalState.viewport=t,(!r||!dA({oldViewport:r,viewport:t}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){const r=this.getAttributeManager();r&&(t==="all"?r.invalidateAll():r.invalidate(t))}updateAttributes(t){let r=!1;for(const i in t)t[i].layoutChanged()&&(r=!0);for(const i of this.getModels())this._setModelAttributes(i,t,r)}_updateAttributes(){const t=this.getAttributeManager();if(!t)return;const r=this.props,i=this.getNumInstances(),s=this.getStartIndices();t.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});const n=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){const t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){const{uniformTransitions:t}=this.internalState;if(t.active){const r=t.update(),i=Object.create(this.props);for(const s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(t,{numInstances:r}){if(t.constant)return;const i=Math.floor(ee.length/4);if(this.internalState.usesPickingColorCache=!0,iBo&&G.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),ee=Pt.allocate(ee,r,{size:4,copy:!0,maxCount:Math.max(r,Bo)});const s=Math.floor(ee.length/4),n=[0,0,0];for(let o=i;o(G.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),t)}),this.internalState.uniformTransitions=new MT(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(t){X(uA,this,this===t);const{state:r,internalState:i}=t;this!==t&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const t=this.needsUpdate();if(X(lA,this,t),!t)return;this.context.stats.get("Layer updates").incrementCount();const r=this.props,i=this.context,s=this.internalState,n=i.viewport,o=this._updateUniformTransition();s.propsInTransition=o,i.viewport=s.viewport||n,this.props=o;try{const a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(const u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();const l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=n,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){X(fA,this),this.finalizeState(this.context);for(const t of this.props.extensions)t.finalizeState.call(this,this.context,t)}_drawLayer({renderPass:t,shaderModuleProps:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();const n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;try{r&&this.setShaderModuleProps(r);const{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof Oe&&o.device.setParametersWebGL({polygonOffset:c});const l=o.device instanceof Oe?null:pA(s);if(_A(this.getModels(),t,s,l),o.device instanceof Oe)o.device.withParametersWebGL(s,()=>{const u={renderPass:t,shaderModuleProps:r,uniforms:i,parameters:s,context:o};for(const h of this.props.extensions)h.draw.call(this,u,h);this.draw(u)});else{l!=null&&l.renderPassParameters&&t.setParameters(l.renderPassParameters);const u={renderPass:t,shaderModuleProps:r,uniforms:i,parameters:s,context:o};for(const h of this.props.extensions)h.draw.call(this,u,h);this.draw(u)}}finally{this.props=n}}getChangeFlags(){var t;return(t=this.internalState)==null?void 0:t.changeFlags}setChangeFlags(t){if(!this.internalState)return;const{changeFlags:r}=this.internalState;for(const s in t)if(t[s]){let n=!1;switch(s){case"dataChanged":const o=t[s],a=r[s];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[s]||(r[s]=t[s],n=!0)}n&&X(aA,this,s,t)}const i=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,r){var s;const i=NT(t,r);if(i.updateTriggersChanged)for(const n in i.updateTriggersChanged)i.updateTriggersChanged[n]&&this.invalidateAttribute(n);if(i.transitionsChanged)for(const n in i.transitionsChanged)this.internalState.uniformTransitions.add(n,r[n],t[n],(s=t.transitions)==null?void 0:s[n]);return this.setChangeFlags(i)}validateProps(){IT(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){const r={highlightedObjectColor:t.picked?t.color:null},{highlightColor:i}=this.props;t.picked&&typeof i=="function"&&(r.highlightColor=i(t)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){const t=this.context;return new vT(t.device,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,r){const{props:i,oldProps:s}=t,n=this.state.model;n!=null&&n.isInstanced&&n.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){const l={};Array.isArray(c)&&(l.highlightColor=c),(r||s.autoHighlight!==o||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;const i=this.getAttributeManager(),s=i?i.getNeedsRedraw(t):!1;if(r=r||s,r)for(const n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}$s.defaultProps=gA;$s.layerName="Layer";function pA(e){const{blendConstant:t,...r}=e;return t?{pipelineParameters:r,renderPassParameters:{blendConstant:t}}:{pipelineParameters:r}}function _A(e,t,r,i){for(const s of e)s.device.type==="webgpu"?(mA(s,t),s.setParameters({...s.parameters,...i==null?void 0:i.pipelineParameters})):s.setParameters(r)}function mA(e,t){var o,a;const r=t.props.framebuffer||(t.framebuffer??null);if(!r)return;const i=r.colorAttachments.map(c=>{var l;return((l=c==null?void 0:c.texture)==null?void 0:l.format)??null}),s=(a=(o=r.depthStencilAttachment)==null?void 0:o.texture)==null?void 0:a.format,n=e;(!bA(n.props.colorAttachmentFormats,i)||n.props.depthStencilAttachmentFormat!==s)&&(n.props.colorAttachmentFormats=i,n.props.depthStencilAttachmentFormat=s,n._setPipelineNeedsUpdate("attachment formats"))}function bA(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let r=0;rt.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){const{object:r}=t;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(t.object=r.__source.object,t.index=r.__source.index),t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,r){return r&&r.length}getSubLayerClass(t,r){const{_subLayerProps:i}=this.props;return i&&i[t]&&i[t].type||r}getSubLayerRow(t,r,i){return t.__source={parent:this,object:r,index:i},t}getSubLayerAccessor(t){if(typeof t=="function"){const r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,t(i.__source.object,r)):t(i,s)}return t}getSubLayerProps(t={}){var C;const{opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:h,wrapLongitude:d,positionFormat:g,modelMatrix:p,extensions:_,fetch:m,operation:b,_subLayerProps:R}=this.props,T={id:"",updateTriggers:{},opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:h,wrapLongitude:d,positionFormat:g,modelMatrix:p,extensions:_,fetch:m,operation:b},y=R&&t.id&&R[t.id],E=y&&y.updateTriggers,S=t.id||"sublayer";if(y){const v=this.props[be],w=t.type?t.type._propTypes:{};for(const x in y){const B=w[x]||v[x];B&&B.type==="accessor"&&(y[x]=this.getSubLayerAccessor(y[x]))}}Object.assign(T,t,y),T.id=`${this.props.id}-${S}`,T.updateTriggers={all:(C=this.props.updateTriggers)==null?void 0:C.all,...t.updateTriggers,...E};for(const v of _){const w=v.getSubLayerProps.call(this,v);w&&Object.assign(T,w,{updateTriggers:Object.assign(T.updateTriggers,w.updateTriggers)})}return T}_updateAutoHighlight(t){for(const r of this.getSubLayers())r.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(t,r){let i=this.internalState.subLayers;const s=!i||this.needsUpdate();if(s){const n=this.renderLayers();i=om(n,Boolean),this.internalState.subLayers=i}X(TA,this,s,i);for(const n of i)n.parent=this}}AA.layerName="CompositeLayer";class qA{constructor(t){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:r={}}=t;this.typedArrayManager=Pt,this.attributes={},this._attributeDefs=r,this.opts=t,this.updateGeometry(t)}updateGeometry(t){Object.assign(this.opts,t);const{data:r,buffers:i={},getGeometry:s,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(pe(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(const l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:r}){this._rebuildGeometry({startRow:t,endRow:r})}getGeometryFromBuffer(t){const r=t.value||t;return ArrayBuffer.isView(r)?zc(r,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,r){const{attributes:i,buffers:s,_attributeDefs:n,typedArrayManager:o}=this;for(const a in n)if(a in s)o.release(i[a]),i[a]=null;else{const c=n[a];c.copy=r,i[a]=o.allocate(i[a],t,c)}}_forEachGeometry(t,r,i){const{data:s,getGeometry:n}=this,{iterable:o,objectInfo:a}=Wc(s,r,i);for(const c of o){a.index++;const l=n?n(c,a):null;t(l,a.index)}}_rebuildGeometry(t){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this;const{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=t||{},l={};if(t||(r=[0],i=[0]),this.normalize||!o)this._forEachGeometry((h,d)=>{const g=h&&this.normalizeGeometry(h);l[d]=g,i[d+1]=i[d]+(g?this.getGeometrySize(g):0)},a,c),s=i[i.length-1];else if(i=n.startIndices,s=i[n.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof N){const h=this.positionSize*4;s=s||o.byteLength/h}else if(o.buffer){const h=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/h}else if(o.value){const h=o.value,d=o.stride/h.BYTES_PER_ELEMENT||this.positionSize;s=s||h.length/d}this._allocate(s,!!t),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;const u={};this._forEachGeometry((h,d)=>{const g=l[d]||h;u.vertexStart=i[d],u.indexStart=r[d];const p=d langs = detector.getSupportedLanguages(); + assertEquals(Set.of("java"), langs); + } + + // --------------------------------------------------------------- + // Early exit + // --------------------------------------------------------------- + + @Test + void emptyContent_returnsEmpty() { + DetectorContext ctx = DetectorTestUtils.contextFor("Foo.java", "java", ""); + DetectorResult r = detector.detect(ctx); + assertTrue(r.nodes().isEmpty()); + assertTrue(r.edges().isEmpty()); + } + + @Test + void nullContent_returnsEmpty() { + DetectorContext ctx = new DetectorContext("Foo.java", "java", null); + DetectorResult r = detector.detect(ctx); + assertTrue(r.nodes().isEmpty()); + assertTrue(r.edges().isEmpty()); + } + + @Test + void fileWithoutActiveMqKeywords_returnsEmpty() { + String code = """ + package app; + public class Plain { + public int add(int a, int b) { return a + b; } + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("Plain.java", "java", code); + DetectorResult r = detector.detect(ctx); + assertTrue(r.nodes().isEmpty()); + assertTrue(r.edges().isEmpty()); + } + + // --------------------------------------------------------------- + // ActiveMQ Classic: connection factory + queue + topic + // --------------------------------------------------------------- + + @Test + void detectsClassicConnectionFactoryWithBrokerUrl() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + public class OrdersClient { + private final ActiveMQConnectionFactory cf = + new ActiveMQConnectionFactory("tcp://localhost:61616"); + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("OrdersClient.java", "java", code); + DetectorResult r = detector.detect(ctx); + + // MESSAGE_QUEUE node for the broker, broker=activemq, broker_url present + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.MESSAGE_QUEUE + && "activemq".equals(n.getProperties().get("broker")) + && "tcp://localhost:61616".equals(n.getProperties().get("broker_url"))); + // CONNECTS_TO from class to broker + assertThat(r.edges()).anyMatch(e -> e.getKind() == EdgeKind.CONNECTS_TO); + } + + @Test + void detectsClassicNamedQueueProducer() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + import org.apache.activemq.command.ActiveMQQueue; + public class OrdersProducer { + private final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); + private final ActiveMQQueue q = new ActiveMQQueue("orders"); + public void publish() { producer.send(msg); } + private javax.jms.MessageProducer producer; + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("OrdersProducer.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.QUEUE + && "amq:queue:activemq:orders".equals(n.getId())); + assertThat(r.edges()).anyMatch(e -> + e.getKind() == EdgeKind.SENDS_TO + && "amq:queue:activemq:orders".equals(e.getTarget().getId())); + } + + @Test + void detectsClassicNamedTopicConsumer() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + import org.apache.activemq.command.ActiveMQTopic; + public class TickerListener { + private final ActiveMQTopic t = new ActiveMQTopic("ticker"); + public void onMessage(javax.jms.Message m) { /* ... */ } + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("TickerListener.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.TOPIC + && "amq:topic:activemq:ticker".equals(n.getId())); + assertThat(r.edges()).anyMatch(e -> e.getKind() == EdgeKind.RECEIVES_FROM); + } + + @Test + void detectsSessionCreateQueueWhenAmqContext() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + public class JmsApi { + public void send(javax.jms.Session s) { + javax.jms.Queue q = s.createQueue("workers"); + producer.send(msg); + } + private javax.jms.MessageProducer producer; + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("JmsApi.java", "java", code); + DetectorResult r = detector.detect(ctx); + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.QUEUE + && "amq:queue:activemq:workers".equals(n.getId())); + } + + // --------------------------------------------------------------- + // ActiveMQ Artemis: distinguished by package path + // --------------------------------------------------------------- + + @Test + void detectsArtemisFlavourViaImport() { + String code = """ + package app; + import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; + public class ArtemisClient { + private final ActiveMQConnectionFactory cf = + new ActiveMQConnectionFactory("tcp://artemis:61616"); + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("ArtemisClient.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.MESSAGE_QUEUE + && "activemq_artemis".equals(n.getProperties().get("broker"))); + } + + @Test + void detectsArtemisJmsConnectionFactoryClass() { + String code = """ + package app; + import org.apache.activemq.artemis.api.jms.ActiveMQJMSConnectionFactory; + public class ArtemisJms { + private final ActiveMQJMSConnectionFactory cf = + new ActiveMQJMSConnectionFactory("tcp://artemis:61616"); + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("ArtemisJms.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.MESSAGE_QUEUE + && "activemq_artemis".equals(n.getProperties().get("broker")) + && "ActiveMQJMSConnectionFactory".equals(n.getProperties().get("factory_type"))); + } + + // --------------------------------------------------------------- + // Transport URL variants + // --------------------------------------------------------------- + + @Test + void capturesFailoverTransportUrl() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + public class HaClient { + private final ActiveMQConnectionFactory cf = + new ActiveMQConnectionFactory("failover:(tcp://a:61616,tcp://b:61616)"); + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("HaClient.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> { + Object url = n.getProperties().get("broker_url"); + return url != null && url.toString().startsWith("failover:"); + }); + } + + @Test + void capturesPooledConnectionFactory() { + String code = """ + package app; + import org.apache.activemq.pool.PooledConnectionFactory; + public class PoolClient { + private final PooledConnectionFactory pcf = new PooledConnectionFactory(); + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("PoolClient.java", "java", code); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + "PooledConnectionFactory".equals(n.getProperties().get("factory_type"))); + } + + // --------------------------------------------------------------- + // Spring Boot config keys (no class context — config files / property files) + // --------------------------------------------------------------- + + @Test + void detectsSpringActivemqBrokerUrl_emitsBrokerNodeOnly() { + // application.properties content — no class declaration; detector + // emits a broker node but no class-context CONNECTS_TO edge. + String props = "spring.activemq.broker-url=tcp://broker:61616\n"; + DetectorContext ctx = DetectorTestUtils.contextFor("application.properties", "java", props); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.MESSAGE_QUEUE + && "activemq".equals(n.getProperties().get("broker")) + && "tcp://broker:61616".equals(n.getProperties().get("broker_url"))); + assertTrue(r.edges().isEmpty(), + "No class context in a .properties file → no edges expected"); + } + + @Test + void detectsSpringArtemisBrokerUrl() { + String props = "spring.artemis.broker-url=tcp://artemis-broker:61616\n"; + DetectorContext ctx = DetectorTestUtils.contextFor("application.properties", "java", props); + DetectorResult r = detector.detect(ctx); + + assertThat(r.nodes()).anyMatch(n -> + n.getKind() == NodeKind.MESSAGE_QUEUE + && "activemq_artemis".equals(n.getProperties().get("broker"))); + } + + // --------------------------------------------------------------- + // Negative: JMS without ActiveMQ context should NOT be claimed + // --------------------------------------------------------------- + + @Test + void plainJmsCreateQueue_withoutActiveMqContext_isIgnored() { + // JmsDetector handles bare JMS; ActiveMqDetector should only claim + // createQueue/createTopic when an ActiveMQ import or class ref is + // present in the same file. This avoids double-counting. + String code = """ + package app; + public class PlainJms { + public void send(javax.jms.Session s) { + javax.jms.Queue q = s.createQueue("anywhere"); + } + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("PlainJms.java", "java", code); + DetectorResult r = detector.detect(ctx); + assertTrue(r.nodes().isEmpty(), + "createQueue without an AMQ import/class ref must not be attributed to ActiveMQ"); + } + + // --------------------------------------------------------------- + // Determinism + // --------------------------------------------------------------- + + @Test + void deterministic_sameInputSameOutput() { + String code = """ + package app; + import org.apache.activemq.ActiveMQConnectionFactory; + import org.apache.activemq.command.ActiveMQQueue; + import org.apache.activemq.command.ActiveMQTopic; + public class Mixed { + ActiveMQConnectionFactory cf = + new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQQueue q = new ActiveMQQueue("orders"); + ActiveMQTopic t = new ActiveMQTopic("events"); + public void publish() { producer.send(msg); } + public void onMessage(javax.jms.Message m) { /* ... */ } + private javax.jms.MessageProducer producer; + } + """; + DetectorContext ctx = DetectorTestUtils.contextFor("Mixed.java", "java", code); + DetectorTestUtils.assertDeterministic(detector, ctx); + } +}