diff --git a/client/simple/package-lock.json b/client/simple/package-lock.json index 2cde437b1..1ebd59953 100644 --- a/client/simple/package-lock.json +++ b/client/simple/package-lock.json @@ -11,26 +11,26 @@ "dependencies": { "ionicons": "^8.0.13", "normalize.css": "8.0.1", - "ol": "^10.8.0", + "ol": "^10.9.0", "swiped-events": "1.2.0" }, "devDependencies": { - "@biomejs/biome": "2.4.10", - "@types/node": "^25.5.0", + "@biomejs/biome": "2.4.12", + "@types/node": "^25.6.0", "browserslist": "^4.28.2", "browserslist-to-esbuild": "^2.1.1", "edge.js": "^6.5.0", "less": "^4.6.4", - "mathjs": "^15.1.1", + "mathjs": "^15.2.0", "sharp": "~0.34.5", "sort-package-json": "^3.6.1", - "stylelint": "^17.6.0", + "stylelint": "^17.8.0", "stylelint-config-standard-less": "^4.1.0", "stylelint-prettier": "^5.0.3", "svgo": "^4.0.1", - "typescript": "~6.0.2", - "vite": "^8.0.3", - "vite-bundle-analyzer": "^1.3.6" + "typescript": "~6.0.3", + "vite": "^8.0.8", + "vite-bundle-analyzer": "^1.3.7" } }, "node_modules/@babel/code-frame": { @@ -69,9 +69,9 @@ } }, "node_modules/@biomejs/biome": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.10.tgz", - "integrity": "sha512-xxA3AphFQ1geij4JTHXv4EeSTda1IFn22ye9LdyVPoJU19fNVl0uzfEuhsfQ4Yue/0FaLs2/ccVi4UDiE7R30w==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.12.tgz", + "integrity": "sha512-Rro7adQl3NLq/zJCIL98eElXKI8eEiBtoeu5TbXF/U3qbjuSc7Jb5rjUbeHHcquDWeSf3HnGP7XI5qGrlRk/pA==", "dev": true, "license": "MIT OR Apache-2.0", "bin": { @@ -85,20 +85,20 @@ "url": "https://opencollective.com/biome" }, "optionalDependencies": { - "@biomejs/cli-darwin-arm64": "2.4.10", - "@biomejs/cli-darwin-x64": "2.4.10", - "@biomejs/cli-linux-arm64": "2.4.10", - "@biomejs/cli-linux-arm64-musl": "2.4.10", - "@biomejs/cli-linux-x64": "2.4.10", - "@biomejs/cli-linux-x64-musl": "2.4.10", - "@biomejs/cli-win32-arm64": "2.4.10", - "@biomejs/cli-win32-x64": "2.4.10" + "@biomejs/cli-darwin-arm64": "2.4.12", + "@biomejs/cli-darwin-x64": "2.4.12", + "@biomejs/cli-linux-arm64": "2.4.12", + "@biomejs/cli-linux-arm64-musl": "2.4.12", + "@biomejs/cli-linux-x64": "2.4.12", + "@biomejs/cli-linux-x64-musl": "2.4.12", + "@biomejs/cli-win32-arm64": "2.4.12", + "@biomejs/cli-win32-x64": "2.4.12" } }, "node_modules/@biomejs/cli-darwin-arm64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.4.10.tgz", - "integrity": "sha512-vuzzI1cWqDVzOMIkYyHbKqp+AkQq4K7k+UCXWpkYcY/HDn1UxdsbsfgtVpa40shem8Kax4TLDLlx8kMAecgqiw==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.4.12.tgz", + "integrity": "sha512-BnMU4Pc3ciEVteVpZ0BK33MLr7X57F5w1dwDLDn+/iy/yTrA4Q/N2yftidFtsA4vrDh0FMXDpacNV/Tl3fbmng==", "cpu": [ "arm64" ], @@ -113,9 +113,9 @@ } }, "node_modules/@biomejs/cli-darwin-x64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.4.10.tgz", - "integrity": "sha512-14fzASRo+BPotwp7nWULy2W5xeUyFnTaq1V13Etrrxkrih+ez/2QfgFm5Ehtf5vSjtgx/IJycMMpn5kPd5ZNaA==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.4.12.tgz", + "integrity": "sha512-x9uJ0bI1rJsWICp3VH8w/5PnAVD3A7SqzDpbrfoUQX1QyWrK5jSU4fRLo/wSgGeplCivbxBRKmt5Xq4/nWvq8A==", "cpu": [ "x64" ], @@ -130,9 +130,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.4.10.tgz", - "integrity": "sha512-7MH1CMW5uuxQ/s7FLST63qF8B3Hgu2HRdZ7tA1X1+mk+St4JOuIrqdhIBnnyqeyWJNI+Bww7Es5QZ0wIc1Cmkw==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.4.12.tgz", + "integrity": "sha512-tOwuCuZZtKi1jVzbk/5nXmIsziOB6yqN8c9r9QM0EJYPU6DpQWf11uBOSCfFKKM4H3d9ZoarvlgMfbcuD051Pw==", "cpu": [ "arm64" ], @@ -147,9 +147,9 @@ } }, "node_modules/@biomejs/cli-linux-arm64-musl": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.4.10.tgz", - "integrity": "sha512-WrJY6UuiSD/Dh+nwK2qOTu8kdMDlLV3dLMmychIghHPAysWFq1/DGC1pVZx8POE3ZkzKR3PUUnVrtZfMfaJjyQ==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.4.12.tgz", + "integrity": "sha512-FhfpkAAlKL6kwvcVap0Hgp4AhZmtd3YImg0kK1jd7C/aSoh4SfsB2f++yG1rU0lr8Y5MCFJrcSkmssiL9Xnnig==", "cpu": [ "arm64" ], @@ -164,9 +164,9 @@ } }, "node_modules/@biomejs/cli-linux-x64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.4.10.tgz", - "integrity": "sha512-tZLvEEi2u9Xu1zAqRjTcpIDGVtldigVvzug2fTuPG0ME/g8/mXpRPcNgLB22bGn6FvLJpHHnqLnwliOu8xjYrg==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.4.12.tgz", + "integrity": "sha512-8pFeAnLU9QdW9jCIslB/v82bI0lhBmz2ZAKc8pVMFPO0t0wAHsoEkrUQUbMkIorTRIjbqyNZHA3lEXavsPWYSw==", "cpu": [ "x64" ], @@ -181,9 +181,9 @@ } }, "node_modules/@biomejs/cli-linux-x64-musl": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.4.10.tgz", - "integrity": "sha512-kDTi3pI6PBN6CiczsWYOyP2zk0IJI08EWEQyDMQWW221rPaaEz6FvjLhnU07KMzLv8q3qSuoB93ua6inSQ55Tw==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.4.12.tgz", + "integrity": "sha512-dwTIgZrGutzhkQCuvHynCkyW6hJxUuyZqKKO0YNfaS2GUoRO+tOvxXZqZB6SkWAOdfZTzwaw8IEdUnIkHKHoew==", "cpu": [ "x64" ], @@ -198,9 +198,9 @@ } }, "node_modules/@biomejs/cli-win32-arm64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.4.10.tgz", - "integrity": "sha512-umwQU6qPzH+ISTf/eHyJ/QoQnJs3V9Vpjz2OjZXe9MVBZ7prgGafMy7yYeRGnlmDAn87AKTF3Q6weLoMGpeqdQ==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.4.12.tgz", + "integrity": "sha512-B0DLnx0vA9ya/3v7XyCaP+/lCpnbWbMOfUFFve+xb5OxyYvdHaS55YsSddr228Y+JAFk58agCuZTsqNiw2a6ig==", "cpu": [ "arm64" ], @@ -215,9 +215,9 @@ } }, "node_modules/@biomejs/cli-win32-x64": { - "version": "2.4.10", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.4.10.tgz", - "integrity": "sha512-aW/JU5GuyH4uxMrNYpoC2kjaHlyJGLgIa3XkhPEZI0uKhZhJZU8BuEyJmvgzSPQNGozBwWjC972RaNdcJ9KyJg==", + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.4.12.tgz", + "integrity": "sha512-yMckRzTyZ83hkk8iDFWswqSdU8tvZxspJKnYNh7JZr/zhZNOlzH13k4ecboU6MurKExCe2HUkH75pGI/O2JwGA==", "cpu": [ "x64" ], @@ -256,9 +256,9 @@ } }, "node_modules/@csstools/css-calc": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.1.1.tgz", - "integrity": "sha512-HJ26Z/vmsZQqs/o3a6bgKslXGFAungXGbinULZO3eMsOyNJHeBBZfup5FiZInOghgoM4Hwnmw+OgbJCNg1wwUQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.2.0.tgz", + "integrity": "sha512-bR9e6o2BDB12jzN/gIbjHa5wLJ4UjD1CB9pM7ehlc0ddk6EBz+yYS1EV2MF55/HUxrHcB/hehAyt5vhsA3hx7w==", "dev": true, "funding": [ { @@ -304,9 +304,9 @@ } }, "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.2.tgz", - "integrity": "sha512-5GkLzz4prTIpoyeUiIu3iV6CSG3Plo7xRVOFPKI7FVEJ3mZ0A8SwK0XU3Gl7xAkiQ+mDyam+NNp875/C5y+jSA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.3.tgz", + "integrity": "sha512-SH60bMfrRCJF3morcdk57WklujF4Jr/EsQUzqkarfHXEFcAR1gg7fS/chAE922Sehgzc1/+Tz5H3Ypa1HiEKrg==", "dev": true, "funding": [ { @@ -945,9 +945,9 @@ "license": "MIT" }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.2.tgz", - "integrity": "sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", + "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", "dev": true, "license": "MIT", "optional": true, @@ -1002,9 +1002,9 @@ } }, "node_modules/@oxc-project/types": { - "version": "0.122.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.122.0.tgz", - "integrity": "sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==", + "version": "0.124.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.124.0.tgz", + "integrity": "sha512-VBFWMTBvHxS11Z5Lvlr3IWgrwhMTXV+Md+EQF0Xf60+wAdsGFTBx7X7K/hP4pi8N7dcm1RvcHwDxZ16Qx8keUg==", "dev": true, "license": "MIT", "funding": { @@ -1086,9 +1086,9 @@ } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.12.tgz", - "integrity": "sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-YYe6aWruPZDtHNpwu7+qAHEMbQ/yRl6atqb/AhznLTnD3UY99Q1jE7ihLSahNWkF4EqRPVC4SiR4O0UkLK02tA==", "cpu": [ "arm64" ], @@ -1103,9 +1103,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.12.tgz", - "integrity": "sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-oArR/ig8wNTPYsXL+Mzhs0oxhxfuHRfG7Ikw7jXsw8mYOtk71W0OkF2VEVh699pdmzjPQsTjlD1JIOoHkLP1Fg==", "cpu": [ "arm64" ], @@ -1120,9 +1120,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.12.tgz", - "integrity": "sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.15.tgz", + "integrity": "sha512-YzeVqOqjPYvUbJSWJ4EDL8ahbmsIXQpgL3JVipmN+MX0XnXMeWomLN3Fb+nwCmP/jfyqte5I3XRSm7OfQrbyxw==", "cpu": [ "x64" ], @@ -1137,9 +1137,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.12.tgz", - "integrity": "sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.15.tgz", + "integrity": "sha512-9Erhx956jeQ0nNTyif1+QWAXDRD38ZNjr//bSHrt6wDwB+QkAfl2q6Mn1k6OBPerznjRmbM10lgRb1Pli4xZPw==", "cpu": [ "x64" ], @@ -1154,9 +1154,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.12.tgz", - "integrity": "sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.15.tgz", + "integrity": "sha512-cVwk0w8QbZJGTnP/AHQBs5yNwmpgGYStL88t4UIaqcvYJWBfS0s3oqVLZPwsPU6M0zlW4GqjP0Zq5MnAGwFeGA==", "cpu": [ "arm" ], @@ -1171,9 +1171,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.12.tgz", - "integrity": "sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-eBZ/u8iAK9SoHGanqe/jrPnY0JvBN6iXbVOsbO38mbz+ZJsaobExAm1Iu+rxa4S1l2FjG0qEZn4Rc6X8n+9M+w==", "cpu": [ "arm64" ], @@ -1188,9 +1188,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.12.tgz", - "integrity": "sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.15.tgz", + "integrity": "sha512-ZvRYMGrAklV9PEkgt4LQM6MjQX2P58HPAuecwYObY2DhS2t35R0I810bKi0wmaYORt6m/2Sm+Z+nFgb0WhXNcQ==", "cpu": [ "arm64" ], @@ -1205,9 +1205,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.12.tgz", - "integrity": "sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-VDpgGBzgfg5hLg+uBpCLoFG5kVvEyafmfxGUV0UHLcL5irxAK7PKNeC2MwClgk6ZAiNhmo9FLhRYgvMmedLtnQ==", "cpu": [ "ppc64" ], @@ -1222,9 +1222,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.12.tgz", - "integrity": "sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-y1uXY3qQWCzcPgRJATPSOUP4tCemh4uBdY7e3EZbVwCJTY3gLJWnQABgeUetvED+bt1FQ01OeZwvhLS2bpNrAQ==", "cpu": [ "s390x" ], @@ -1239,9 +1239,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.12.tgz", - "integrity": "sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-023bTPBod7J3Y/4fzAN6QtpkSABR0rigtrwaP+qSEabUh5zf6ELr9Nc7GujaROuPY3uwdSIXWrvhn1KxOvurWA==", "cpu": [ "x64" ], @@ -1256,9 +1256,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.12.tgz", - "integrity": "sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.15.tgz", + "integrity": "sha512-witB2O0/hU4CgfOOKUoeFgQ4GktPi1eEbAhaLAIpgD6+ZnhcPkUtPsoKKHRzmOoWPZue46IThdSgdo4XneOLYw==", "cpu": [ "x64" ], @@ -1273,9 +1273,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.12.tgz", - "integrity": "sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-UCL68NJ0Ud5zRipXZE9dF5PmirzJE4E4BCIOOssEnM7wLDsxjc6Qb0sGDxTNRTP53I6MZpygyCpY8Aa8sPfKPg==", "cpu": [ "arm64" ], @@ -1290,9 +1290,9 @@ } }, "node_modules/@rolldown/binding-wasm32-wasi": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.12.tgz", - "integrity": "sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.15.tgz", + "integrity": "sha512-ApLruZq/ig+nhaE7OJm4lDjayUnOHVUa77zGeqnqZ9pn0ovdVbbNPerVibLXDmWeUZXjIYIT8V3xkT58Rm9u5Q==", "cpu": [ "wasm32" ], @@ -1300,16 +1300,41 @@ "license": "MIT", "optional": true, "dependencies": { - "@napi-rs/wasm-runtime": "^1.1.1" + "@emnapi/core": "1.9.2", + "@emnapi/runtime": "1.9.2", + "@napi-rs/wasm-runtime": "^1.1.3" }, "engines": { "node": ">=14.0.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz", + "integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz", + "integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.12.tgz", - "integrity": "sha512-5eOND4duWkwx1AzCxadcOrNeighiLwMInEADT0YM7xeEOOFcovWZCq8dadXgcRHSf3Ulh1kFo/qvzoFiCLOL1Q==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.15.tgz", + "integrity": "sha512-KmoUoU7HnN+Si5YWJigfTws1jz1bKBYDQKdbLspz0UaqjjFkddHsqorgiW1mxcAj88lYUE6NC/zJNwT+SloqtA==", "cpu": [ "arm64" ], @@ -1324,9 +1349,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.12.tgz", - "integrity": "sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.15.tgz", + "integrity": "sha512-3P2A8L+x75qavWLe/Dll3EYBJLQmtkJN8rfh+U/eR3MqMgL/h98PhYI+JFfXuDPgPeCB7iZAKiqii5vqOvnA0g==", "cpu": [ "x64" ], @@ -1341,9 +1366,9 @@ } }, "node_modules/@rolldown/pluginutils": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.12.tgz", - "integrity": "sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.15.tgz", + "integrity": "sha512-UromN0peaE53IaBRe9W7CjrZgXl90fqGpK+mIZbA3qSTeYqg3pqpROBdIPvOG3F5ereDHNwoHBI2e50n1BDr1g==", "dev": true, "license": "MIT" }, @@ -1465,9 +1490,9 @@ } }, "node_modules/@stencil/core": { - "version": "4.43.3", - "resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.43.3.tgz", - "integrity": "sha512-w41W6txhGULvvEfa5AEgwfNGAbK3YGowQYMTWuRvXSIbnkiyRDGLogsYSYtHDlz1JJe645JJIK9Lvh5uquFiSw==", + "version": "4.43.4", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.43.4.tgz", + "integrity": "sha512-QWawMM1XIpSz4k+k+VyHZMr2YSxlCNAPWO/jTdJ+2kdgdN7ZQVEFZpc4WBm3E3mrDPTZ79lLcnIPa399bg4XOg==", "license": "MIT", "bin": { "stencil": "bin/stencil" @@ -1499,14 +1524,14 @@ } }, "node_modules/@types/node": { - "version": "25.5.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.2.tgz", - "integrity": "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==", + "version": "25.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.6.0.tgz", + "integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "undici-types": "~7.18.0" + "undici-types": "~7.19.0" } }, "node_modules/@types/pluralize": { @@ -1523,13 +1548,13 @@ "license": "MIT" }, "node_modules/@zarrita/storage": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@zarrita/storage/-/storage-0.1.4.tgz", - "integrity": "sha512-qURfJAQcQGRfDQ4J9HaCjGaj3jlJKc66bnRk6G/IeLUsM7WKyG7Bzsuf1EZurSXyc0I4LVcu6HaeQQ4d3kZ16g==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@zarrita/storage/-/storage-0.2.0.tgz", + "integrity": "sha512-855ZXqtnds7spnT8vNvD+MXa3QExP1m2GqShe8yt7uZXHnQLgJHgkpVwFjE1B0KDDRO0ki09hmk6OboTaIfPsQ==", "license": "MIT", "dependencies": { "reference-spec-reader": "^0.2.0", - "unzipit": "1.4.3" + "unzipit": "2.0.0" } }, "node_modules/acorn": { @@ -1619,9 +1644,9 @@ } }, "node_modules/baseline-browser-mapping": { - "version": "2.10.16", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.16.tgz", - "integrity": "sha512-Lyf3aK28zpsD1yQMiiHD4RvVb6UdMoo8xzG2XzFIfR9luPzOpcBlAsT/qfB1XWS1bxWT+UtE4WmQgsp297FYOA==", + "version": "2.10.19", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.19.tgz", + "integrity": "sha512-qCkNLi2sfBOn8XhZQ0FXsT1Ki/Yo5P90hrkRamVFRS7/KV9hpfA4HkoWNU152+8w0zPjnxo5psx5NL3PSGgv5g==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1730,9 +1755,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001786", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001786.tgz", - "integrity": "sha512-4oxTZEvqmLLrERwxO76yfKM7acZo310U+v4kqexI2TL1DkkUEMT8UijrxxcnVdxR3qkVf5awGRX+4Z6aPHVKrA==", + "version": "1.0.30001788", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001788.tgz", + "integrity": "sha512-6q8HFp+lOQtcf7wBK+uEenxymVWkGKkjFpCvw5W25cmMwEDU45p1xQFBQv8JDlMMry7eNxyBaR+qxgmTUZkIRQ==", "dev": true, "funding": [ { @@ -2149,9 +2174,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.332", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.332.tgz", - "integrity": "sha512-7OOtytmh/rINMLwaFTbcMVvYXO3AUm029X0LcyfYk0B557RlPkdpTpnH9+htMlfu5dKwOmT0+Zs2Aw+lnn6TeQ==", + "version": "1.5.340", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.340.tgz", + "integrity": "sha512-908qahOGocRMinT2nM3ajCEM99H4iPdv84eagPP3FfZy/1ZGeOy2CZYzjhms81ckOPCXPlW7LkY4XpxD8r1DrA==", "dev": true, "license": "ISC" }, @@ -3150,9 +3175,9 @@ } }, "node_modules/mathjs": { - "version": "15.1.1", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-15.1.1.tgz", - "integrity": "sha512-rM668DTtpSzMVoh/cKAllyQVEbBApM5g//IMGD8vD7YlrIz9ITRr3SrdhjaDxcBNTdyETWwPebj2unZyHD7ZdA==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-15.2.0.tgz", + "integrity": "sha512-UAQzSVob9rNLdGpqcFMYmSu9dkuLYy7Lr2hBEQS5SHQdknA9VppJz3cy2KkpMzTODunad6V6cNv+5kOLsePLow==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3332,17 +3357,17 @@ } }, "node_modules/ol": { - "version": "10.8.0", - "resolved": "https://registry.npmjs.org/ol/-/ol-10.8.0.tgz", - "integrity": "sha512-kLk7jIlJvKyhVMAjORTXKjzlM6YIByZ1H/d0DBx3oq8nSPCG6/gbLr5RxukzPgwbhnAqh+xHNCmrvmFKhVMvoQ==", + "version": "10.9.0", + "resolved": "https://registry.npmjs.org/ol/-/ol-10.9.0.tgz", + "integrity": "sha512-svbbgVQUmEHaKpLQ8kRySojs59Brvgl2zYIrqG9eQNXGfsbi55rQasZIDpwpQzDL6OlzrUb0H4hQaiX9wDoGmA==", "license": "BSD-2-Clause", "dependencies": { "@types/rbush": "4.0.0", "earcut": "^3.0.0", - "geotiff": "^3.0.2", + "geotiff": "^3.0.5 || ^3.1.0-beta.0", "pbf": "4.0.1", "rbush": "^4.0.0", - "zarrita": "^0.6.0" + "zarrita": "^0.7.1" }, "funding": { "type": "opencollective", @@ -3457,9 +3482,9 @@ } }, "node_modules/postcss": { - "version": "8.5.8", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", - "integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==", + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.10.tgz", + "integrity": "sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==", "dev": true, "funding": [ { @@ -3556,9 +3581,9 @@ "license": "MIT" }, "node_modules/prettier": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", - "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz", + "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", "dev": true, "license": "MIT", "peer": true, @@ -3725,14 +3750,14 @@ } }, "node_modules/rolldown": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.12.tgz", - "integrity": "sha512-yP4USLIMYrwpPHEFB5JGH1uxhcslv6/hL0OyvTuY+3qlOSJvZ7ntYnoWpehBxufkgN0cvXxppuTu5hHa/zPh+A==", + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.15.tgz", + "integrity": "sha512-Ff31guA5zT6WjnGp0SXw76X6hzGRk/OQq2hE+1lcDe+lJdHSgnSX6nK3erbONHyCbpSj9a9E+uX/OvytZoWp2g==", "dev": true, "license": "MIT", "dependencies": { - "@oxc-project/types": "=0.122.0", - "@rolldown/pluginutils": "1.0.0-rc.12" + "@oxc-project/types": "=0.124.0", + "@rolldown/pluginutils": "1.0.0-rc.15" }, "bin": { "rolldown": "bin/cli.mjs" @@ -3741,21 +3766,21 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm64": "1.0.0-rc.12", - "@rolldown/binding-darwin-arm64": "1.0.0-rc.12", - "@rolldown/binding-darwin-x64": "1.0.0-rc.12", - "@rolldown/binding-freebsd-x64": "1.0.0-rc.12", - "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.12", - "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.12", - "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.12", - "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.12", - "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.12", - "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.12", - "@rolldown/binding-linux-x64-musl": "1.0.0-rc.12", - "@rolldown/binding-openharmony-arm64": "1.0.0-rc.12", - "@rolldown/binding-wasm32-wasi": "1.0.0-rc.12", - "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.12", - "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.12" + "@rolldown/binding-android-arm64": "1.0.0-rc.15", + "@rolldown/binding-darwin-arm64": "1.0.0-rc.15", + "@rolldown/binding-darwin-x64": "1.0.0-rc.15", + "@rolldown/binding-freebsd-x64": "1.0.0-rc.15", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.15", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.15", + "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-x64-musl": "1.0.0-rc.15", + "@rolldown/binding-openharmony-arm64": "1.0.0-rc.15", + "@rolldown/binding-wasm32-wasi": "1.0.0-rc.15", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.15", + "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.15" } }, "node_modules/run-parallel": { @@ -4043,9 +4068,9 @@ } }, "node_modules/stylelint": { - "version": "17.6.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-17.6.0.tgz", - "integrity": "sha512-tokrsMIVAR9vAQ/q3UVEr7S0dGXCi7zkCezPRnS2kqPUulvUh5Vgfwngrk4EoAoW7wnrThqTdnTFN5Ra7CaxIg==", + "version": "17.8.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-17.8.0.tgz", + "integrity": "sha512-oHkld9T60LDSaUQ4CSVc+tlt9eUoDlxhaGWShsUCKyIL14boZfmK5bSphZqx64aiC5tCqX+BsQMTMoSz8D1zIg==", "dev": true, "funding": [ { @@ -4062,7 +4087,7 @@ "dependencies": { "@csstools/css-calc": "^3.1.1", "@csstools/css-parser-algorithms": "^4.0.0", - "@csstools/css-syntax-patches-for-csstree": "^1.1.1", + "@csstools/css-syntax-patches-for-csstree": "^1.1.2", "@csstools/css-tokenizer": "^4.0.0", "@csstools/media-query-list-parser": "^5.0.0", "@csstools/selector-resolve-nested": "^4.0.0", @@ -4076,7 +4101,7 @@ "fastest-levenshtein": "^1.0.16", "file-entry-cache": "^11.1.2", "global-modules": "^2.0.0", - "globby": "^16.1.1", + "globby": "^16.2.0", "globjoin": "^0.1.4", "html-tags": "^5.1.0", "ignore": "^7.0.5", @@ -4087,7 +4112,7 @@ "micromatch": "^4.0.8", "normalize-path": "^3.0.0", "picocolors": "^1.1.1", - "postcss": "^8.5.8", + "postcss": "^8.5.9", "postcss-safe-parser": "^7.0.1", "postcss-selector-parser": "^7.1.1", "postcss-value-parser": "^4.2.0", @@ -4370,14 +4395,14 @@ "license": "MIT" }, "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" @@ -4450,9 +4475,9 @@ } }, "node_modules/typescript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", - "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", "dev": true, "license": "Apache-2.0", "peer": true, @@ -4465,9 +4490,9 @@ } }, "node_modules/undici-types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", - "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "version": "7.19.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.19.2.tgz", + "integrity": "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==", "dev": true, "license": "MIT" }, @@ -4485,15 +4510,12 @@ } }, "node_modules/unzipit": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/unzipit/-/unzipit-1.4.3.tgz", - "integrity": "sha512-gsq2PdJIWWGhx5kcdWStvNWit9FVdTewm4SEG7gFskWs+XCVaULt9+BwuoBtJiRE8eo3L1IPAOrbByNLtLtIlg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unzipit/-/unzipit-2.0.0.tgz", + "integrity": "sha512-DVeVIWUZCAQPNzm5sB0hpsG1GygTTdBnzNtYYEpInkttx5evkyqRgZi6rTczoySqp8hO5jHVKzrH0f23X8FZLg==", "license": "MIT", - "dependencies": { - "uzip-module": "^1.0.2" - }, "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/update-browserslist-db": { @@ -4534,23 +4556,17 @@ "dev": true, "license": "MIT" }, - "node_modules/uzip-module": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/uzip-module/-/uzip-module-1.0.3.tgz", - "integrity": "sha512-AMqwWZaknLM77G+VPYNZLEruMGWGzyigPK3/Whg99B3S6vGHuqsyl5ZrOv1UUF3paGK1U6PM0cnayioaryg/fA==", - "license": "MIT" - }, "node_modules/vite": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.5.tgz", - "integrity": "sha512-nmu43Qvq9UopTRfMx2jOYW5l16pb3iDC1JH6yMuPkpVbzK0k+L7dfsEDH4jRgYFmsg0sTAqkojoZgzLMlwHsCQ==", + "version": "8.0.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.8.tgz", + "integrity": "sha512-dbU7/iLVa8KZALJyLOBOQ88nOXtNG8vxKuOT4I2mD+Ya70KPceF4IAmDsmU0h1Qsn5bPrvsY9HJstCRh3hG6Uw==", "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.32.0", "picomatch": "^4.0.4", "postcss": "^8.5.8", - "rolldown": "1.0.0-rc.12", + "rolldown": "1.0.0-rc.15", "tinyglobby": "^0.2.15" }, "bin": { @@ -4680,12 +4696,12 @@ "license": "CC0-1.0" }, "node_modules/zarrita": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/zarrita/-/zarrita-0.6.2.tgz", - "integrity": "sha512-8IV+2bWt5yiHNVK9GVEVK1tscpqDcJj8iz5cIKFOiWiWYUsK4V5njgMtnpkvKu6L7K+Og6zUShd8f+dwb6LvTA==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/zarrita/-/zarrita-0.7.1.tgz", + "integrity": "sha512-Nu4liRKJES1kkIjWALXSryglJf2+WJURUxgndklfX+mTBCd0lk4MV797p00lt4NzmU3Bbdbs10uxeN8LWwPyWA==", "license": "MIT", "dependencies": { - "@zarrita/storage": "^0.1.4", + "@zarrita/storage": "^0.2.0", "numcodecs": "^0.3.2" } }, diff --git a/client/simple/package.json b/client/simple/package.json index 0633f2238..446a950f8 100644 --- a/client/simple/package.json +++ b/client/simple/package.json @@ -25,25 +25,25 @@ "dependencies": { "ionicons": "^8.0.13", "normalize.css": "8.0.1", - "ol": "^10.8.0", + "ol": "^10.9.0", "swiped-events": "1.2.0" }, "devDependencies": { - "@biomejs/biome": "2.4.10", - "@types/node": "^25.5.0", + "@biomejs/biome": "2.4.12", + "@types/node": "^25.6.0", "browserslist": "^4.28.2", "browserslist-to-esbuild": "^2.1.1", "edge.js": "^6.5.0", "less": "^4.6.4", - "mathjs": "^15.1.1", + "mathjs": "^15.2.0", "sharp": "~0.34.5", "sort-package-json": "^3.6.1", - "stylelint": "^17.6.0", + "stylelint": "^17.8.0", "stylelint-config-standard-less": "^4.1.0", "stylelint-prettier": "^5.0.3", "svgo": "^4.0.1", - "typescript": "~6.0.2", - "vite": "^8.0.3", - "vite-bundle-analyzer": "^1.3.6" + "typescript": "~6.0.3", + "vite": "^8.0.8", + "vite-bundle-analyzer": "^1.3.7" } } diff --git a/searx/static/themes/simple/chunk/4sMJQOad.min.js b/searx/static/themes/simple/chunk/4sMJQOad.min.js new file mode 100644 index 000000000..ffd0f2efd --- /dev/null +++ b/searx/static/themes/simple/chunk/4sMJQOad.min.js @@ -0,0 +1,15 @@ +import{t as e}from"./Cq566EWy.min.js";import{t}from"./vehLS1_D.min.js";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;tthis.has(e)).values()}get(e){return p(this.wrappedObject,e)}set(e,t){return m(this.wrappedObject,e,t),this}has(e){return h(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return te(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){h(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},ee=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return te(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function te(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function ne(){return new Map}function C(e){if(!e)return ne();if(I(e))return e;if(F(e))return new S(e);throw Error(`createMap can create maps from objects or Maps`)}function w(e){return typeof e==`number`}function T(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function re(e){return typeof e==`bigint`}function E(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function D(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function O(e){return e&&e.constructor.prototype.isUnit===!0||!1}function k(e){return typeof e==`string`}var A=Array.isArray;function j(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function M(e){return Array.isArray(e)||j(e)}function N(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function ie(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function ae(e){return e&&e.constructor.prototype.isRange===!0||!1}function P(e){return e&&e.constructor.prototype.isIndex===!0||!1}function oe(e){return typeof e==`boolean`}function se(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function ce(e){return e&&e.constructor.prototype.isHelp===!0||!1}function le(e){return typeof e==`function`}function ue(e){return e instanceof Date}function de(e){return e instanceof RegExp}function F(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!E(e)&&!D(e))}function I(e){return e?e instanceof Map||e instanceof S||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function fe(e){return I(e)&&I(e.a)&&I(e.b)}function pe(e){return I(e)&&F(e.wrappedObject)}function me(e){return e===null}function he(e){return e===void 0}function L(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function ge(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function _e(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ve(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function ye(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function R(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function be(e){return R(e)||we(e)&&e.args.length===1&&R(e.args[0])&&`-+~`.includes(e.op)}function xe(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Se(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function z(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function B(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ce(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function we(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Te(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ee(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function De(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function V(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Oe(e){return e&&e.constructor.prototype.isChain===!0||!1}function ke(e){var t=typeof e;return t===`object`?e===null?`null`:T(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function Ae(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return Ae(e)});if(e instanceof Date)return new Date(e.valueOf());if(T(e))return e;if(F(e))return je(e,Ae);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function je(e,t){var n={};for(var r in e)H(e,r)&&(n[r]=t(e[r]));return n}function Me(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(H(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?Me(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function Ne(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function Ve(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}function W(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function He(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var Ue=Math.sign||function(e){return e>0?1:e<0?-1:0},We=Math.log2||function(e){return Math.log(e)/Math.LN2},Ge=Math.log10||function(e){return Math.log(e)/Math.LN10},Ke=Math.log1p||function(e){return Math.log(e+1)},qe=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},Je=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Ye(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!W(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!W(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function Xe(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=Ze(t);switch(n){case`fixed`:return et(e,r);case`exponential`:return tt(e,r);case`engineering`:return $e(e,r);case`bin`:return Ye(e,2,i);case`oct`:return Ye(e,8,i);case`hex`:return Ye(e,16,i);case`auto`:return nt(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function Ze(e){var t=`auto`,n,r;if(e!==void 0)if(w(e))n=e;else if(T(e))n=e.toNumber();else if(F(e))e.precision!==void 0&&(n=ot(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=ot(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function Qe(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function $e(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=rt(Qe(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(w(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s0;)l++,c--;var u=i.slice(l).join(``),d=w(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function et(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Qe(e),r=typeof t==`number`?rt(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function nt(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=st(n?.lowerExp,-3),i=st(n?.upperExp,5),a=Qe(e),o=t?rt(a,t):a;if(o.exponent=i)return tt(e,t);var s=o.coefficients,c=o.exponent;s.length0?c:0;return lt&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function it(e){for(var t=[],n=0;n1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)throw Error(`Root must be non-zero`);if(e<0&&Math.abs(t)%2!=1)throw Error(`Root must be odd when a is negative.`);if(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.abs(e)**(1/t);return r=e<0?-r:r,n?1/r:r}function Ot(e){return Ue(e)}Ot.signature=G;function kt(e){return Math.sqrt(e)}kt.signature=G;function At(e){return e*e}At.signature=G;function jt(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!W(e)||!W(t))throw Error(`Parameters in function xgcd must be integer numbers`);for(;t;)r=Math.floor(e/t),i=e-r*t,n=a,a=o-r*a,o=n,n=s,s=c-r*s,c=n,e=t,t=i;return e<0?[-e,-o,-c]:[e,e?o:0,c]}jt.signature=ct;function Mt(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}Mt.signature=ct;function Nt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!W(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(et(e,t))}function Pt(e){return Math.abs(e)}Pt.signature=G;function Ft(e,t){if(t>1;return Ft(e,n)*Ft(n+1,t)}function It(e,t){if(!W(e)||e<0||!W(t)||t<0)throw TypeError(`Positive integer value expected in function combinations`);if(t>e)throw TypeError(`k must be less than or equal to n`);for(var n=e-t,r=1,i=t171?1/0:Ft(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*zt(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,a=i*e;return Math.sqrt(2*Math.PI/e)*(e/Math.E)**+e*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=Vt[0];for(var o=1;o=1;r--)n+=Ut[r]/(e+r);return Ht+(e+.5)*Math.log(t)-t+Math.log(n)}Wt.signature=`number`;function K(e,t,n,r){function i(r){var i=Le(r,t.map(Jt));return Kt(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function Gt(e){return typeof e==`function`&&typeof e.fn==`string`&&Array.isArray(e.dependencies)}function Kt(e,t,n){if(!t.filter(e=>!qt(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function qt(e){return e&&e[0]===`?`}function Jt(e){return e&&e[0]===`?`?e.slice(1):e}function Yt(){throw Error(`No "bignumber" implementation available`)}function Xt(){throw Error(`No "fraction" implementation available`)}function Zt(){throw Error(`No "matrix" implementation available`)}function Qt(){throw Error(`No "matrix" implementation available`)}var $t=u(c(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=ne(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,i+=e.name+`|`,{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function ee(e){let t=ie(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function te(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function ne(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=w(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=w(e[0]),r=w(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(w),function(e){for(let n=0;n{let r=E(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function k(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s{let r=w(re(n.params,s));(s0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return C(e.params)?1/0:e.params.length});if(t.lengthl)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e0)return .001;let r=j(e),i=j(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function N(e,t){let n=e.params,r=t.params,i=pe(n),a=pe(r),o=C(n),s=C(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;ee.hasConversion)){let i=C(e),a=e.map(P);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;te.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return L(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function se(e,t){let n=Math.max(e.length,t.length);for(let r=0;r=r:o?r>=i:r===i}function ce(e){return e.map(e=>R(e)?ve(e.referToSelf.callback):ye(e)?_e(e.referTo.references,e.referTo.callback):e)}function le(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function ue(e,t,n){let r=ce(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function F(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&de(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=ne(c);if(!e)continue;i.forEach(function(t){if(se(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(ee),l;for(l of oe(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(N);let l=ue(a,o,z),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!C(f[0].params),h=f[1]&&f[1].params.length<=2&&!C(f[1].params),g=f[2]&&f[2].params.length<=2&&!C(f[2].params),_=f[3]&&f[3].params.length<=2&&!C(f[3].params),v=f[4]&&f[4].params.length<=2&&!C(f[4].params),y=f[5]&&f[5].params.length<=2&&!C(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;ee.test),xe=f.map(e=>e.implementation),Se=function(){for(let e=ye;ex(ne(e))),t=pe(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return _e(e,t)}function _e(e,t){return{referTo:{references:e,callback:t}}}function ve(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function ye(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function R(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function be(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function xe(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=be(t,e[n].name));return t}function Se(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let z=d;d=function(e){let t=typeof e==`string`,n=+!!t,r=t?e:``,i={};for(let e=n;e1&&arguments[1]!==void 0?arguments[1]:{override:!1};B(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){B(e);let t=f(e.to),n=he(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;ek&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971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u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD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F90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\u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-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:k},{name:`Chain`,test:Oe},{name:`Array`,test:A},{name:`Matrix`,test:j},{name:`DenseMatrix`,test:N},{name:`SparseMatrix`,test:ie},{name:`Range`,test:ae},{name:`Index`,test:P},{name:`boolean`,test:oe},{name:`ResultSet`,test:se},{name:`Help`,test:ce},{name:`function`,test:le},{name:`Date`,test:ue},{name:`RegExp`,test:de},{name:`null`,test:me},{name:`undefined`,test:he},{name:`AccessorNode`,test:L},{name:`ArrayNode`,test:ge},{name:`AssignmentNode`,test:_e},{name:`BlockNode`,test:ve},{name:`ConditionalNode`,test:ye},{name:`ConstantNode`,test:R},{name:`FunctionNode`,test:Se},{name:`FunctionAssignmentNode`,test:xe},{name:`IndexNode`,test:z},{name:`Node`,test:B},{name:`ObjectNode`,test:Ce},{name:`OperatorNode`,test:we},{name:`ParenthesisNode`,test:Te},{name:`RangeNode`,test:Ee},{name:`RelationalNode`,test:De},{name:`SymbolNode`,test:V},{name:`Map`,test:I},{name:`Object`,test:F}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||nn(e),at(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||rn(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||rn(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw TypeError(`Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: `+e+`)`);return Number(e)}},{from:`bigint`,to:`BigNumber`,convert:function(e){return t||nn(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||on(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw TypeError(`Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.`)}},{from:`Fraction`,to:`Complex`,convert:function(e){return n||rn(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||on(e);var t=new i(e);if(t.valueOf()!==e)throw TypeError(`Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: `+e+`). Use function fraction(x) to convert to Fraction.`);return t}},{from:`string`,to:`number`,convert:function(e){var t=Number(e);if(isNaN(t))throw Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||nn(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||on(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||rn(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||nn(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||on(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||an(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&M(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&M(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function nn(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function rn(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function an(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function on(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var sn=K(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0});function cn(e,t,n){var r=e.constructor,i=new r(2),a=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!W(n))throw Error(`size must be an integer`);if(e.greaterThan(i.pow(n-1).sub(1))||e.lessThan(i.pow(n-1).mul(-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!e.isInteger())throw Error(`Value must be an integer`);e.lessThan(0)&&(e=e.add(i.pow(n))),a=`i${n}`}switch(t){case 2:return`${e.toBinary()}${a}`;case 8:return`${e.toOctal()}${a}`;case 16:return`${e.toHexadecimal()}${a}`;default:throw Error(`Base ${t} not supported `)}}function ln(e,t){if(typeof t==`function`)return t(e);if(!e.isFinite())return e.isNaN()?`NaN`:e.gt(0)?`Infinity`:`-Infinity`;var{notation:n,precision:r,wordSize:i}=Ze(t);switch(n){case`fixed`:return fn(e,r);case`exponential`:return dn(e,r);case`engineering`:return un(e,r);case`bin`:return cn(e,2,i);case`oct`:return cn(e,8,i);case`hex`:return cn(e,16,i);case`auto`:var a=pn(t?.lowerExp,-3),o=pn(t?.upperExp,5);if(e.isZero())return`0`;var s,c=e.toSignificantDigits(r),l=c.e;return s=l>=a&&l=0?`+`:``)+r.toString()}function dn(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function fn(e,t){return e.toFixed(t)}function pn(e,t){return w(e)?e:T(e)?e.toNumber():t}function mn(e,t){var n=hn(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function hn(e,t){return typeof e==`number`?Xe(e,t):T(e)?ln(e,t):yn(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?vn(e,t):k(e)?gn(e):typeof e==`function`?e.syntax?String(e.syntax):`function`:e&&typeof e==`object`?typeof e.format==`function`?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):`{`+Object.keys(e).map(n=>gn(n)+`: `+mn(e[n],t)).join(`, `)+`}`:String(e)}function gn(e){for(var t=String(e),n=``,r=0;r/g,`>`),t}function vn(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;i`,associativity:`left`,associativeWith:[]},"OperatorNode:smallerEq":{op:`<=`,associativity:`left`,associativeWith:[]},"OperatorNode:largerEq":{op:`>=`,associativity:`left`,associativeWith:[]},RelationalNode:{associativity:`left`,associativeWith:[]}},{"OperatorNode:leftShift":{op:`<<`,associativity:`left`,associativeWith:[]},"OperatorNode:rightArithShift":{op:`>>`,associativity:`left`,associativeWith:[]},"OperatorNode:rightLogShift":{op:`>>>`,associativity:`left`,associativeWith:[]}},{"OperatorNode:to":{op:`to`,associativity:`left`,associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:`+`,associativity:`left`,associativeWith:[`OperatorNode:add`,`OperatorNode:subtract`]},"OperatorNode:subtract":{op:`-`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{op:`*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]},"OperatorNode:divide":{op:`/`,associativity:`left`,associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:`.*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`OperatorNode:dotMultiply`,`OperatorNode:doDivide`]},"OperatorNode:dotDivide":{op:`./`,associativity:`left`,associativeWith:[]},"OperatorNode:mod":{op:`mod`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]}},{"OperatorNode:unaryPlus":{op:`+`,associativity:`right`},"OperatorNode:unaryMinus":{op:`-`,associativity:`right`},"OperatorNode:bitNot":{op:`~`,associativity:`right`},"OperatorNode:not":{op:`not`,associativity:`right`}},{"OperatorNode:pow":{op:`^`,associativity:`right`,associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:`.^`,associativity:`right`,associativeWith:[]}},{"OperatorNode:nullish":{op:`??`,associativity:`left`,associativeWith:[]}},{"OperatorNode:factorial":{op:`!`,associativity:`left`}},{"OperatorNode:ctranspose":{op:`'`,associativity:`left`}}];function wn(e,t){if(!t||t!==`auto`)return e;for(var n=e;Te(n);)n=n.content;return n}function Y(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s=this.max?this.message=`Index out of range (`+this.index+` > `+(this.max-1)+`)`:this.message=`Index out of range (`+this.index+`)`,this.stack=Error().stack}Dn.prototype=RangeError(),Dn.prototype.constructor=RangeError,Dn.prototype.name=`IndexError`,Dn.prototype.isIndexError=!0;function On(e,t,n){if(!(this instanceof On))throw SyntaxError(`Constructor must be called with the new operator`);this.actual=e,this.expected=t,this.relation=n,this.message=`Dimension mismatch (`+(Array.isArray(e)?`[`+e.join(`, `)+`]`:e)+` `+(this.relation||`!=`)+` `+(Array.isArray(t)?`[`+t.join(`, `)+`]`:t)+`)`,this.stack=Error().stack}On.prototype=RangeError(),On.prototype.constructor=RangeError,On.prototype.name=`DimensionError`,On.prototype.isDimensionError=!0;function kn(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function An(e,t){return Array.prototype.map.call(e,t)}function jn(e,t){Array.prototype.forEach.call(e,t)}function Mn(e,t){return Array.prototype.join.call(e,t)}function Nn(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(n)return a(e);var r=[];return i(e,0);function i(n,a){if(Array.isArray(n)){for(var o=n.length,s=Array(o),c=0;ct(e),!1,!0):Nn(e,t,!0);var r=e=>e===0?e:t(e);return j(e)?e.map(e=>r(e),!1,!0):Nn(e,r,!0)}function Fn(e){var t=0,n=1,r=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete r[o],delete i[e],--t,n===o)){if(!t){a=0,n=1;return}for(;!Object.prototype.hasOwnProperty.call(r,++n););}};return e=Math.abs(e),{hit:function(s){var c=i[s],l=++a;if(r[l]=s,i[s]=l,!c)return++t,t<=e?void 0:(s=r[n],o(s),s);if(delete r[c],n===c)for(;!Object.prototype.hasOwnProperty.call(r,++n););},delete:o,clear:function(){t=a=0,n=1,r=Object.create(null),i=Object.create(null)}}}function In(e){var{hasher:t,limit:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n??=1/0,t??=JSON.stringify,function r(){typeof r.cache!=`object`&&(r.cache={values:new Map,lru:Fn(n||1/0)});var i=[...arguments],a=t(i);if(r.cache.values.has(a))return r.cache.lru.hit(a),r.cache.values.get(a);var o=e.apply(e,i);return r.cache.values.set(a,o),r.cache.values.delete(r.cache.lru.hit(a)),o}}var Ln=In(function(e){return new e(1).exp()},{hasher:zn});In(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:zn});var Rn=In(function(e){return e.acos(-1)},{hasher:zn});In(function(e){return Rn(e).times(2)},{hasher:zn});function zn(e){return e[0].precision}var Bn=Hn(`pi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Rn(n):Lt}),Vn=Hn(`e`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Ln(n):Rt});function Hn(e,t,n){return K(e,t,n,{recreateOnConfigChange:!0})}var Un=`number`,Wn=[`typed`];function Gn(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}function Kn(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r{var{typed:t}=e,n=t(`number`,{"":function(){return 0},number:function(e){return e},string:function(e){if(e===`NaN`)return NaN;var t=Gn(e);if(t)return Kn(t);var n=0,r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);r&&(n=Number(r[2]),e=r[1]);var i=Number(e);if(isNaN(i))throw SyntaxError(`String "`+e+`" is not a valid number`);if(r){if(i>2**n-1)throw SyntaxError(`String "${e}" is out of range`);i>=2**(n-1)&&(i-=2**n)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(e=>t=>Pn(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),Jn=new Set([`end`]),Yn=K(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...Jn])if(e.has(t))throw Error(`Scope contains an illegal symbol, "`+t+`" is a reserved keyword`)}class r{get type(){return`Node`}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={},i=null;function a(t){var a=C(t);return n(a),e(a,r,i)}return{evaluate:a}}_compile(e,t){throw Error(`Method _compile must be implemented by type `+this.type)}forEach(e){throw Error(`Cannot run forEach on a Node interface`)}map(e){throw Error(`Cannot run map on a Node interface`)}_ifNode(e){if(!B(e))throw TypeError(`Callback function must return a Node`);return e}traverse(e){e(this,null,null);function t(e,n){e.forEach(function(e,r,i){n(e,r,i),t(e,n)})}t(this,e)}transform(e){function t(n,r,i){var a=e(n,r,i);return a===n?n.map(t):a}return t(this,null,null)}filter(e){var t=[];return this.traverse(function(n,r,i){e(n,r,i)&&t.push(n)}),t}clone(){throw Error(`Cannot clone a Node interface`)}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return e?this.type===e.type&&Ne(this,e):!1}toString(e){var t=this._getCustomString(e);return t===void 0?this._toString(e):t}_toString(){throw Error(`_toString not implemented for `+this.type)}toJSON(){throw Error(`Cannot serialize object: toJSON not implemented by `+this.type)}toHTML(e){var t=this._getCustomString(e);return t===void 0?this._toHTML(e):t}_toHTML(){throw Error(`_toHTML not implemented for `+this.type)}toTex(e){var t=this._getCustomString(e);return t===void 0?this._toTex(e):t}_toTex(e){throw Error(`_toTex not implemented for `+this.type)}_getCustomString(e){if(e&&typeof e==`object`)switch(typeof e.handler){case`object`:case`undefined`:return;case`function`:return e.handler(this,e);default:throw TypeError(`Object or function expected as callback`)}}getIdentifier(){return this.type}getContent(){return this}}return r},{isClass:!0,isNode:!0});function Xn(e){return e&&e.isIndexError?new Dn(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function Zn(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&typeof e.subset==`function`)return e.subset(n);if(typeof e==`string`)return t(e,n);if(typeof e==`object`){if(!n.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return p(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Xn(e)}}}var Qn=`AccessorNode`,$n=K(Qn,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=Zn({subset:t});function i(e){return!(L(e)||ge(e)||R(e)||Se(e)||Ce(e)||Te(e)||V(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!B(e))throw TypeError(`Node expected for parameter "object"`);if(!z(t))throw TypeError(`IndexNode expected for parameter "index"`);this.object=e,this.index=t,this.optionalChaining=n}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return Qn}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=L(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,t,r){var i=r||{},c=n(e,t,i);if(a&&c==null){i.optionalShortCircuit=!0;return}if(!(o&&i!=null&&i.optionalShortCircuit))return p(c,s)}}else return function(e,t,s){var c=s||{},l=n(e,t,c);if(a&&l==null){c.optionalShortCircuit=!0;return}if(!(o&&c!=null&&c.optionalShortCircuit))return r(l,i(e,t,l))}}forEach(e){e(this.object,`object`,this),e(this.index,`index`,this)}map(e){return new a(this._ifNode(e(this.object,`object`,this)),this._ifNode(e(this.index,`index`,this)),this.optionalChaining)}clone(){return new a(this.object,this.index,this.optionalChaining)}_toString(e){var t=this.object.toString(e);i(this.object)&&(t=`(`+t+`)`);var n=this.optionalChaining?this.index.dotNotation?`?`:`?.`:``;return t+n+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t=`(`+t+`)`),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t=`\\left(' + object + '\\right)`),t+this.index.toTex(e)}toJSON(){return{mathjs:Qn,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return J(a,`name`,Qn),a},{isClass:!0,isNode:!0}),er=`ArrayNode`,tr=K(er,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(B))throw TypeError(`Array containing Nodes expected`)}get type(){return er}get isArrayNode(){return!0}_compile(e,t){var n=An(this.items,function(n){return n._compile(e,t)});if(e.config.matrix!==`Array`){var r=e.matrix;return function(e,t,i){return r(An(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return An(n,function(n){return n(e,t,r)})}}forEach(e){for(var t=0;t[`+this.items.map(function(t){return t.toHTML(e)}).join(`,`)+`]`}_toTex(e){function t(n,r){var i=n.some(ge)&&!n.every(ge),a=r||i,o=a?`&`:`\\\\`,s=n.map(function(n){return n.items?t(n.items,!r):n.toTex(e)}).join(o);return i||!a||a&&!r?`\\begin{bmatrix}`+s+`\\end{bmatrix}`:s}return t(this.items,!1)}}return J(n,`name`,er),n},{isClass:!0,isNode:!0});function nr(e){var{subset:t,matrix:n}=e;return function(e,r,i){try{if(Array.isArray(e))return n(e).subset(r,i).valueOf().forEach((t,n)=>{e[n]=t}),e;if(e&&typeof e.subset==`function`)return e.subset(r,i);if(typeof e==`string`)return t(e,r,i);if(typeof e==`object`){if(!r.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return m(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Xn(e)}}}var rr=`AssignmentNode`,ir=K(rr,[`subset`,`?matrix`,`Node`],e=>{var{subset:t,matrix:n,Node:r}=e,i=Zn({subset:t}),a=nr({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=Y(e,t,n),i=Y(e.value,t,n);return t===`all`||i!==null&&i<=r}class s extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!V(e)&&!L(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(V(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!z(this.index))throw TypeError(`IndexNode expected as "index"`);if(!B(this.value))throw TypeError(`Node expected as "value"`)}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return rr}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(!this.index){if(!V(this.object))throw TypeError(`SymbolNode expected as object`);return function(e,t,n){var r=o(e,t,n);return e.set(s,r),r}}else if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(e,t,r){var i=n(e,t,r),a=o(e,t,r);return m(i,c,a),a}}else if(V(this.object))return function(e,t,i){var c=n(e,t,i),l=o(e,t,i),u=r(e,t,c);return e.set(s,a(c,u,l)),l};else{var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var u=this.object.index.getObjectProperty();return function(e,t,n){var i=l(e,t,n),s=p(i,u),c=r(e,t,s),d=o(e,t,n);return m(i,u,a(s,c,d)),d}}else{var d=this.object.index._compile(e,t);return function(e,t,n){var s=l(e,t,n),c=d(e,t,s),u=i(s,c),f=r(e,t,u),p=o(e,t,n);return a(s,c,a(u,f,p)),p}}}}forEach(e){e(this.object,`object`,this),this.index&&e(this.index,`index`,this),e(this.value,`value`,this)}map(e){return new s(this._ifNode(e(this.object,`object`,this)),this.index?this._ifNode(e(this.index,`index`,this)):null,this._ifNode(e(this.value,`value`,this)))}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):``,r=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+` = `+r}toJSON(){return{mathjs:rr,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):``,r=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+`=`+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):``,r=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`\\left(${r}\\right)`),t+n+`=`+r}}return J(s,`name`,rr),s},{isClass:!0,isNode:!0}),ar=`BlockNode`,or=K(ar,[`ResultSet`,`Node`],e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw Error(`Array expected`);this.blocks=e.map(function(e){var t=e&&e.node,n=e&&e.visible!==void 0?e.visible:!0;if(!B(t))throw TypeError(`Property "node" must be a Node`);if(typeof n!=`boolean`)throw TypeError(`Property "visible" must be a boolean`);return{node:t,visible:n}})}get type(){return ar}get isBlockNode(){return!0}_compile(e,n){var r=An(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return jn(r,function(t){var r=t.evaluate(e,n,i);t.visible&&a.push(r)}),new t(a)}}forEach(e){for(var t=0;t;`)}).join(`
`)}_toTex(e){return this.blocks.map(function(t){return t.node.toTex(e)+(t.visible?``:`;`)}).join(`\\;\\; +`)}}return J(r,`name`,ar),r},{isClass:!0,isNode:!0}),sr=`ConditionalNode`,cr=K(sr,[`Node`],e=>{var{Node:t}=e;function n(e){if(typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return!!e;if(e){if(T(e))return!e.isZero();if(E(e))return!!(e.re||e.im);if(O(e))return!!e.value}if(e==null)return!1;throw TypeError(`Unsupported type of condition "`+ke(e)+`"`)}class r extends t{constructor(e,t,n){if(super(),!B(e))throw TypeError(`Parameter condition must be a Node`);if(!B(t))throw TypeError(`Parameter trueExpr must be a Node`);if(!B(n))throw TypeError(`Parameter falseExpr must be a Node`);this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return sr}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,o){return n(r(e,t,o))?i(e,t,o):a(e,t,o)}}forEach(e){e(this.condition,`condition`,this),e(this.trueExpr,`trueExpr`,this),e(this.falseExpr,`falseExpr`,this)}map(e){return new r(this._ifNode(e(this.condition,`condition`,this)),this._ifNode(e(this.trueExpr,`trueExpr`,this)),this._ifNode(e(this.falseExpr,`falseExpr`,this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.condition.toString(e),i=Y(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toString(e),o=Y(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toString(e),c=Y(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+` ? `+a+` : `+s}toJSON(){return{mathjs:sr,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.condition.toHTML(e),i=Y(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toHTML(e),o=Y(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toHTML(e),c=Y(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+`?`+a+`:`+s}_toTex(e){return`\\begin{cases} {`+this.trueExpr.toTex(e)+`}, &\\quad{\\text{if }\\;`+this.condition.toTex(e)+`}\\\\{`+this.falseExpr.toTex(e)+`}, &\\quad{\\text{otherwise}}\\end{cases}`}}return J(r,`name`,sr),r},{isClass:!0,isNode:!0}),lr=u(c(((e,t)=>{var n=Object.assign||function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{},o=t.preserveFormatting,s=o===void 0?!1:o,c=t.escapeMapFn,l=c===void 0?a:c,u=String(e),d=``,f=l(n({},r),s?n({},i):{}),p=Object.keys(f),m=function(){var e=!1;p.forEach(function(t,n){e||u.length>=t.length&&u.slice(0,t.length)===t&&(d+=f[p[n]],u=u.slice(t.length,u.length),e=!0)}),e||(d+=u.slice(0,1),u=u.slice(1,u.length))};u;)m();return d}}))(),1),ur={Alpha:`A`,alpha:`\\alpha`,Beta:`B`,beta:`\\beta`,Gamma:`\\Gamma`,gamma:`\\gamma`,Delta:`\\Delta`,delta:`\\delta`,Epsilon:`E`,epsilon:`\\epsilon`,varepsilon:`\\varepsilon`,Zeta:`Z`,zeta:`\\zeta`,Eta:`H`,eta:`\\eta`,Theta:`\\Theta`,theta:`\\theta`,vartheta:`\\vartheta`,Iota:`I`,iota:`\\iota`,Kappa:`K`,kappa:`\\kappa`,varkappa:`\\varkappa`,Lambda:`\\Lambda`,lambda:`\\lambda`,Mu:`M`,mu:`\\mu`,Nu:`N`,nu:`\\nu`,Xi:`\\Xi`,xi:`\\xi`,Omicron:`O`,omicron:`o`,Pi:`\\Pi`,pi:`\\pi`,varpi:`\\varpi`,Rho:`P`,rho:`\\rho`,varrho:`\\varrho`,Sigma:`\\Sigma`,sigma:`\\sigma`,varsigma:`\\varsigma`,Tau:`T`,tau:`\\tau`,Upsilon:`\\Upsilon`,upsilon:`\\upsilon`,Phi:`\\Phi`,phi:`\\phi`,varphi:`\\varphi`,Chi:`X`,chi:`\\chi`,Psi:`\\Psi`,psi:`\\psi`,Omega:`\\Omega`,omega:`\\omega`,true:`\\mathrm{True}`,false:`\\mathrm{False}`,i:`i`,inf:`\\infty`,Inf:`\\infty`,infinity:`\\infty`,Infinity:`\\infty`,oo:`\\infty`,lim:`\\lim`,undefined:`\\mathbf{?}`},X={transpose:`^\\top`,ctranspose:`^H`,factorial:`!`,pow:`^`,dotPow:`.^\\wedge`,unaryPlus:`+`,unaryMinus:`-`,bitNot:`\\~`,not:`\\neg`,multiply:`\\cdot`,divide:`\\frac`,dotMultiply:`.\\cdot`,dotDivide:`.:`,mod:`\\mod`,add:`+`,subtract:`-`,to:`\\rightarrow`,leftShift:`<<`,rightArithShift:`>>`,rightLogShift:`>>>`,equal:`=`,unequal:`\\neq`,smaller:`<`,larger:`>`,smallerEq:`\\leq`,largerEq:`\\geq`,bitAnd:`\\&`,bitXor:`\\underline{|}`,bitOr:`|`,and:`\\wedge`,xor:`\\veebar`,or:`\\vee`},dr={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${X.add}\${args[1]}\\right)`},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:`\\left(\${args[0]}${X.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${X.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${X.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${X.pow}{\${args[0]}}-1\\right)`,fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:`\\left(\${args[0]}${X.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${X.multiply}\${args[1]}\\right)`},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : y^${args[1]} = {${args[0]}}\\}"},pow:{2:`\\left(\${args[0]}\\right)${X.pow}{\${args[1]}}`},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:`\\left(\${args[0]}${X.subtract}\${args[1]}\\right)`},unaryMinus:{1:`${X.unaryMinus}\\left(\${args[0]}\\right)`},unaryPlus:{1:`${X.unaryPlus}\\left(\${args[0]}\\right)`},bitAnd:{2:`\\left(\${args[0]}${X.bitAnd}\${args[1]}\\right)`},bitNot:{1:X.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${X.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${X.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${X.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${X.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${X.rightLogShift}\${args[1]}\\right)`},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:`\\left(\${args[0]}${X.and}\${args[1]}\\right)`},not:{1:X.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${X.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${X.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:`\\left(\${args[0]}\\right)${X.ctranspose}`},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:`{\${args[0]}}${X.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:`\\left(\${args[0]}\\right)${X.transpose}`},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:`\\left(\${args[0]}\\right)${X.factorial}`},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${X.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${X.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${X.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${X.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${X.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${X.unequal}\${args[1]}\\right)`},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:`\\left(\${args[0]}${X.to}\${args[1]}\\right)`},numeric:function(e,t){return e.args[0].toTex()},number:{0:`0`,1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:`\\mathtt{""}`,1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:`0`,1:"\\left(${args[0]}\\right)"},bigint:{0:`0`,1:"\\left(${args[0]}\\right)"},complex:{0:`0`,1:"\\left(${args[0]}\\right)",2:`\\left(\\left(\${args[0]}\\right)+${ur.i}\\cdot\\left(\${args[1]}\\right)\\right)`},matrix:{0:`\\begin{bmatrix}\\end{bmatrix}`,1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:`\\begin{bsparse}\\end{bsparse}`,1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},fr="\\mathrm{${name}}\\left(${args}\\right)",pr={deg:`^\\circ`};function mr(e){return(0,lr.default)(e,{preserveFormatting:!0})}function hr(e,t){return t=t===void 0?!1:t,t?H(pr,e)?pr[e]:`\\mathrm{`+mr(e)+`}`:H(ur,e)?ur[e]:mr(e)}var gr=`ConstantNode`,_r=K(gr,[`Node`,`isBounded`],e=>{var{Node:t,isBounded:n}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return gr}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return mn(this.value,e)}_toHTML(e){var t=this._toString(e);switch(ke(this.value)){case`number`:case`bigint`:case`BigNumber`:case`Fraction`:return``+t+``;case`string`:return``+t+``;case`boolean`:return``+t+``;case`null`:return``+t+``;case`undefined`:return``+t+``;default:return``+t+``}}toJSON(){return{mathjs:gr,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e);switch(ke(this.value)){case`string`:return`\\mathtt{`+mr(t)+`}`;case`number`:case`BigNumber`:if(!n(this.value))return this.value.valueOf()<0?`-\\infty`:`\\infty`;var r=t.toLowerCase().indexOf(`e`);return r===-1?t:t.substring(0,r)+`\\cdot10^{`+t.substring(r+1)+`}`;case`bigint`:return t.toString();case`Fraction`:return this.value.toLatex();default:return t}}}return J(r,`name`,gr),r},{isClass:!0,isNode:!0}),vr=`FunctionAssignmentNode`,yr=K(vr,[`typed`,`Node`],e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=Y(e,t,n),i=Y(e.expr,t,n);return t===`all`||i!==null&&i<=r}class i extends n{constructor(e,t,n){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);if(!Array.isArray(t))throw TypeError(`Array containing strings or objects expected for parameter "params"`);if(!B(n))throw TypeError(`Node expected for parameter "expr"`);if(Jn.has(e))throw Error(`Illegal function name, "`+e+`" is a reserved keyword`);var r=new Set;for(var i of t){var a=typeof i==`string`?i:i.name;if(r.has(a))throw Error(`Duplicate parameter name "${a}"`);r.add(a)}this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||`any`}),this.expr=n}get type(){return vr}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);jn(this.params,function(e){r[e]=!0});var i=this.expr,a=i._compile(e,r),o=this.name,s=this.params,c=Mn(this.types,`,`),l=o+`(`+Mn(this.params,`, `)+`)`;return function(e,n,r){var u={};u[c]=function(){for(var t=Object.create(n),i=0;i`+q(this.params[i])+``);var a=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(a=`(`+a+`)`),``+q(this.name)+`(`+n.join(`,`)+`)=`+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n=`\\left(${n}\\right)`),`\\mathrm{`+this.name+`}\\left(`+this.params.map(hr).join(`,`)+`\\right)=`+n}}return J(i,`name`,vr),i},{isClass:!0,isNode:!0}),br=`IndexNode`,xr=K(br,[`Node`,`size`],e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(B))throw TypeError(`Array containing Nodes expected for parameter "dimensions"`);if(this.dotNotation&&!this.isObjectProperty())throw Error(`dotNotation only applicable for object properties`)}get type(){return br}get isIndexNode(){return!0}_compile(e,t){var r=An(this.dimensions,function(r,i){if(r.filter(e=>e.isSymbolNode&&e.name===`end`).length>0){var a=Object.create(t);a.end=!0;var o=r._compile(e,a);return function(e,t,r){if(!j(r)&&!A(r)&&!k(r))throw TypeError(`Cannot resolve "end": context must be a Matrix, Array, or string but is `+ke(r));var a=n(r),s=Object.create(t);return s.end=a[i],o(e,s,r)}}else return r._compile(e,t)}),i=p(e,`index`);return function(e,t,n){return i(...An(r,function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t.`+q(this.getObjectProperty())+``:`[`+t.join(`,`)+`]`}_toTex(e){var t=this.dimensions.map(function(t){return t.toTex(e)});return this.dotNotation?`.`+this.getObjectProperty():`_{`+t.join(`,`)+`}`}}return J(r,`name`,br),r},{isClass:!0,isNode:!0}),Sr=`ObjectNode`,Cr=K(Sr,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&(typeof e!=`object`||!Object.keys(e).every(function(t){return B(e[t])})))throw TypeError(`Object containing Nodes expected`)}get type(){return Sr}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(H(this.properties,r)){var i=gn(r),a=JSON.parse(i);n[a]=p(this.properties,r)._compile(e,t)}return function(e,t,r){var i={};for(var a in n)H(n,a)&&(i[a]=n[a](e,t,r));return i}}forEach(e){for(var t in this.properties)H(this.properties,t)&&e(this.properties[t],`properties[`+gn(t)+`]`,this)}map(e){var t={};for(var r in this.properties)H(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],`properties[`+gn(r)+`]`,this)));return new n(t)}clone(){var e={};for(var t in this.properties)H(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)H(this.properties,n)&&t.push(gn(n)+`: `+this.properties[n].toString(e));return`{`+t.join(`, `)+`}`}toJSON(){return{mathjs:Sr,properties:this.properties}}static fromJSON(e){return new n(e.properties)}_toHTML(e){var t=[];for(var n in this.properties)H(this.properties,n)&&t.push(``+q(n)+`:`+this.properties[n].toHTML(e));return`{`+t.join(`,`)+`}`}_toTex(e){var t=[];for(var n in this.properties)H(this.properties,n)&&t.push(`\\mathbf{`+n+`:} & `+this.properties[n].toTex(e)+`\\\\`);return`\\left\\{\\begin{array}{ll}`+t.join(` +`)+`\\end{array}\\right\\}`}}return J(n,`name`,Sr),n},{isClass:!0,isNode:!0});function wr(e,t){return new ee(e,new S(t),new Set(Object.keys(t)))}var Tr=`OperatorNode`,Er=K(Tr,[`Node`],e=>{var{Node:t}=e;function n(e,t){var r=e;if(t===`auto`)for(;Te(r);)r=r.content;return R(r)?!0:we(r)?n(r.args[0],t):!1}function r(e,t,r,i,a){var o=Y(e,t,r),s=Tn(e,t);if(t===`all`||i.length>2&&e.getIdentifier()!==`OperatorNode:add`&&e.getIdentifier()!==`OperatorNode:multiply`)return i.map(function(e){switch(e.getContent().type){case`ArrayNode`:case`ConstantNode`:case`SymbolNode`:case`ParenthesisNode`:return!1;default:return!0}});var c;switch(i.length){case 0:c=[];break;case 1:var l=Y(i[0],t,r,e);if(a&&l!==null){var u,d;if(t===`keep`?(u=i[0].getIdentifier(),d=e.getIdentifier()):(u=i[0].getContent().getIdentifier(),d=e.getContent().getIdentifier()),Cn[o][d].latexLeftParens===!1){c=[!1];break}if(Cn[l][u].latexParens===!1){c=[!1];break}}if(l===null){c=[!1];break}if(l<=o){c=[!0];break}c=[!1];break;case 2:var f,p=Y(i[0],t,r,e),m=En(e,i[0],t);f=p===null?!1:p===o&&s===`right`&&!m?!0:p=2&&e.getIdentifier()===`OperatorNode:multiply`&&e.implicit&&t!==`all`&&r===`hide`)for(var x=1;x2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var d=i.map(function(t,n){return t=t.toString(e),a[n]&&(t=`(`+t+`)`),t});return this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?d.join(` `):d.join(` `+this.op+` `)}else return this.fn+`(`+this.args.join(`, `)+`)`}toJSON(){return{mathjs:Tr,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=Tn(this,t),s=i[0].toHTML(e);return a[0]&&(s=`(`+s+`)`),o===`right`?``+q(this.op)+``+s:s+``+q(this.op)+``}else if(i.length===2){var c=i[0].toHTML(e),l=i[1].toHTML(e);return a[0]&&(c=`(`+c+`)`),a[1]&&(l=`(`+l+`)`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?c+``+l:c+``+q(this.op)+``+l}else{var u=i.map(function(t,n){return t=t.toHTML(e),a[n]&&(t=`(`+t+`)`),t});return i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)?this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?u.join(``):u.join(``+q(this.op)+``):``+q(this.fn)+`(`+u.join(`,`)+`)`}}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!0),o=X[this.fn];if(o=o===void 0?this.op:o,i.length===1){var s=Tn(this,t),c=i[0].toTex(e);return a[0]&&(c=`\\left(${c}\\right)`),s===`right`?o+c:c+o}else if(i.length===2){var l=i[0],u=l.toTex(e);a[0]&&(u=`\\left(${u}\\right)`);var d=i[1].toTex(e);a[1]&&(d=`\\left(${d}\\right)`);var f=t===`keep`?l.getIdentifier():l.getContent().getIdentifier();switch(this.getIdentifier()){case`OperatorNode:divide`:return o+`{`+u+`}{`+d+`}`;case`OperatorNode:pow`:switch(u=`{`+u+`}`,d=`{`+d+`}`,f){case`ConditionalNode`:case`OperatorNode:divide`:u=`\\left(${u}\\right)`}break;case`OperatorNode:multiply`:if(this.implicit&&n===`hide`)return u+`~`+d}return u+o+d}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var p=i.map(function(t,n){return t=t.toTex(e),a[n]&&(t=`\\left(${t}\\right)`),t});return this.getIdentifier()===`OperatorNode:multiply`&&this.implicit&&n===`hide`?p.join(`~`):p.join(o)}else return`\\mathrm{`+this.fn+`}\\left(`+i.map(function(t){return t.toTex(e)}).join(`,`)+`\\right)`}getIdentifier(){return this.type+`:`+this.fn}}return J(i,`name`,Tr),i},{isClass:!0,isNode:!0}),Dr=`ParenthesisNode`,Or=K(Dr,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!B(e))throw TypeError(`Node expected for parameter "content"`);this.content=e}get type(){return Dr}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,`content`,this)}map(e){return new n(e(this.content,`content`,this))}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toString(e)+`)`:this.content.toString(e)}toJSON(){return{mathjs:Dr,content:this.content}}static fromJSON(e){return new n(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toHTML(e)+`)`:this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return J(n,`name`,Dr),n},{isClass:!0,isNode:!0}),kr=`RangeNode`,Ar=K(kr,[`Node`],e=>{var{Node:t}=e;function n(e,t,n){var r=Y(e,t,n),i={},a=Y(e.start,t,n);if(i.start=a!==null&&a<=r||t===`all`,e.step){var o=Y(e.step,t,n);i.step=o!==null&&o<=r||t===`all`}var s=Y(e.end,t,n);return i.end=s!==null&&s<=r||t===`all`,i}class r extends t{constructor(e,t,n){if(super(),!B(e)||!B(t)||n&&!B(n))throw TypeError(`Node expected`);if(arguments.length>3)throw Error(`Too many arguments`);this.start=e,this.end=t,this.step=n||null}get type(){return kr}get isRangeNode(){return!0}needsEnd(){return this.filter(function(e){return V(e)&&e.name===`end`}).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return n(r(e,t,o),i(e,t,o),a(e,t,o))}}else return function(e,t,a){return n(r(e,t,a),i(e,t,a))}}forEach(e){e(this.start,`start`,this),e(this.end,`end`,this),this.step&&e(this.step,`step`,this)}map(e){return new r(this._ifNode(e(this.start,`start`,this)),this._ifNode(e(this.end,`end`,this)),this.step&&this._ifNode(e(this.step,`step`,this)))}clone(){return new r(this.start,this.end,this.step&&this.step)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toString(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toString(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toString(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}toJSON(){return{mathjs:kr,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toHTML(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toHTML(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toHTML(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i=this.start.toTex(e);if(r.start&&(i=`\\left(${i}\\right)`),this.step){var a=this.step.toTex(e);r.step&&(a=`\\left(${a}\\right)`),i+=`:`+a}var o=this.end.toTex(e);return r.end&&(o=`\\left(${o}\\right)`),i+=`:`+o,i}}return J(r,`name`,kr),r},{isClass:!0,isNode:!0}),jr=`RelationalNode`,Mr=K(jr,[`Node`],e=>{var{Node:t}=e,n={equal:`==`,unequal:`!=`,smaller:`<`,larger:`>`,smallerEq:`<=`,largerEq:`>=`};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw TypeError(`Parameter conditionals must be an array`);if(!Array.isArray(t))throw TypeError(`Parameter params must be an array`);if(e.length!==t.length-1)throw TypeError(`Parameter params must contain exactly one more element than parameter conditionals`);this.conditionals=e,this.params=t}get type(){return jr}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map(n=>n._compile(e,t));return function(t,i,a){for(var o,s=r[0](t,i,a),c=0;ce(t,`params[`+n+`]`,this),this)}map(e){return new r(this.conditionals.slice(),this.params.map((t,n)=>this._ifNode(e(t,`params[`+n+`]`,this)),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=Y(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=Y(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`(`+n.toString(e)+`)`:n.toString(e)}),a=i[0],o=0;o(`+n.toHTML(e)+`)`:n.toHTML(e)}),a=i[0],o=0;o`+q(n[this.conditionals[o]])+``+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.params.map(function(r,i){var a=Y(r,t,e&&e.implicit);return t===`all`||a!==null&&a<=n?`\\left(`+r.toTex(e)+`\right)`:r.toTex(e)}),i=r[0],a=0;a{var{math:t,Unit:n,Node:r}=e;function i(e){return n?n.isValuelessUnit(e):!1}class a extends r{constructor(e){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);this.name=e}get type(){return`SymbolNode`}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(t[r]===!0)return function(e,t,n){return p(t,r)};if(r in e)return function(t,n,i){return t.has(r)?t.get(r):p(e,r)};var o=i(r);return function(e,t,i){return e.has(r)?e.get(r):o?new n(null,r):a.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error(`Undefined symbol `+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=q(this.name);return t===`true`||t===`false`?``+t+``:t===`i`?``+t+``:t===`Infinity`?``+t+``:t===`NaN`?``+t+``:t===`null`?``+t+``:t===`undefined`?``+t+``:``+t+``}toJSON(){return{mathjs:`SymbolNode`,name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var n=!1;t[this.name]===void 0&&i(this.name)&&(n=!0);var r=hr(this.name,n);return r[0]===`\\`?r:` `+r}}return a},{isClass:!0,isNode:!0}),Pr=`FunctionNode`,Fr=K(Pr,[`math`,`Node`,`SymbolNode`],e=>{var t,{math:n,Node:r,SymbolNode:i}=e,a=e=>mn(e,{truncate:78});function o(e,t,n){for(var r=``,i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,a=0,o;(o=i.exec(e))!==null;)if(r+=e.substring(a,o.index),a=o.index,o[0]===`$$`)r+=`$`,a++;else{a+=o[0].length;var s=t[o[1]];if(!s)throw ReferenceError(`Template: Property `+o[1]+` does not exist.`);if(o[2]===void 0)switch(typeof s){case`string`:r+=s;break;case`object`:if(B(s))r+=s.toTex(n);else if(Array.isArray(s))r+=s.map(function(e,t){if(B(e))return e.toTex(n);throw TypeError(`Template: `+o[1]+`[`+t+`] is not a Node.`)}).join(`,`);else throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`);break;default:throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`)}else if(B(s[o[2]]&&s[o[2]]))r+=s[o[2]].toTex(n);else throw TypeError(`Template: `+o[1]+`[`+o[2]+`] is not a Node.`)}return r+=e.slice(a),r}class s extends r{constructor(e,t,n){if(super(),typeof e==`string`&&(e=new i(e)),!B(e))throw TypeError(`Node expected as parameter "fn"`);if(!Array.isArray(t)||!t.every(B))throw TypeError(`Array containing Nodes expected for parameter "args"`);var r=typeof n;if(!(r===`undefined`||r===`boolean`))throw TypeError(`optional flag, if specified, must be boolean`);this.fn=e,this.args=t||[],this.optional=!!n}get name(){return this.fn.name||``}get type(){return Pr}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map(n=>n._compile(e,t)),r=this.optional||L(this.fn)&&this.fn.optionalChaining;if(V(this.fn)){var i=this.fn.name;if(t[i]){var o=this.args;return function(t,s,c){var l=p(s,i);if(!(r&&l===void 0)){if(typeof l!=`function`)throw TypeError(`Argument '${i}' was not a function; received: ${a(l)}`);if(l.rawArgs)return l(o,e,wr(t,s));var u=n.map(e=>e(t,s,c));return l.apply(l,u)}}}else{var c=i in e?p(e,i):void 0,l=typeof c==`function`&&c.rawArgs===!0,u=t=>{var n;if(t.has(i))n=t.get(i);else if(i in e)n=p(e,i);else if(r)n=void 0;else return s.onUndefinedFunction(i);if(typeof n==`function`||r&&n===void 0)return n;throw TypeError(`'${i}' is not a function; its value is: + ${a(n)}`)};if(l){var d=this.args;return function(t,r,i){var a=u(t);return a.rawArgs===!0?a(d,e,wr(t,r)):a(...n.map(e=>e(t,r,i)))}}else switch(n.length){case 0:return function(e,t,n){var i=u(e);if(!(r&&i===void 0))return i()};case 1:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0];return a(o(e,t,i))}};case 2:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0],s=n[1];return a(o(e,t,i),s(e,t,i))}};default:return function(e,t,i){var a=u(e);if(!(r&&a===void 0))return a(...n.map(n=>n(e,t,i)))}}}}else if(L(this.fn)&&z(this.fn.index)&&this.fn.index.isObjectProperty()){var f=this.fn.object._compile(e,t),m=this.fn.index.getObjectProperty(),h=this.args;return function(t,i,a){var o=f(t,i,a);if(!(r&&(o==null||o[m]===void 0))){var s=v(o,m);if(s!=null&&s.rawArgs)return s(h,e,wr(t,i));var c=n.map(e=>e(t,i,a));return s.apply(o,c)}}}else{var g=this.fn.toString(),_=this.fn._compile(e,t),y=this.args;return function(t,i,o){var s=_(t,i,o);if(!(r&&s===void 0)){if(typeof s!=`function`)throw TypeError(`Expression '${g}' did not evaluate to a function; value is: + ${a(s)}`);if(s.rawArgs)return s(y,e,wr(t,i));var c=n.map(e=>e(t,i,o));return s.apply(s,c)}}}}forEach(e){e(this.fn,`fn`,this);for(var t=0;t`+q(this.fn)+`(`+t.join(`,`)+`)`}toTex(e){var t;return e&&typeof e.handler==`object`&&H(e.handler,this.name)&&(t=e.handler[this.name](this,e)),t===void 0?super.toTex(e):t}_toTex(e){var t=this.args.map(function(t){return t.toTex(e)}),r;dr[this.name]&&(r=dr[this.name]),n[this.name]&&(typeof n[this.name].toTex==`function`||typeof n[this.name].toTex==`object`||typeof n[this.name].toTex==`string`)&&(r=n[this.name].toTex);var i;switch(typeof r){case`function`:i=r(this,e);break;case`string`:i=o(r,this,e);break;case`object`:switch(typeof r[t.length]){case`function`:i=r[t.length](this,e);break;case`string`:i=o(r[t.length],this,e);break}}return i===void 0?o(fr,this,e):i}getIdentifier(){return this.type+`:`+this.name}}return t=s,J(s,`name`,Pr),J(s,`onUndefinedFunction`,function(e){throw Error(`Undefined function `+e)}),J(s,`fromJSON`,function(e){return new t(e.fn,e.args)}),s},{isClass:!0,isNode:!0}),Ir=`parse`,Lr=K(Ir,[`typed`,`numeric`,`config`,`AccessorNode`,`ArrayNode`,`AssignmentNode`,`BlockNode`,`ConditionalNode`,`ConstantNode`,`FunctionAssignmentNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`RangeNode`,`RelationalNode`,`SymbolNode`],e=>{var{typed:t,numeric:n,config:r,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:u,FunctionNode:f,IndexNode:p,ObjectNode:m,OperatorNode:h,ParenthesisNode:g,RangeNode:_,RelationalNode:v,SymbolNode:y}=e,b=t(Ir,{string:function(e){return ie(e,{})},"Array | Matrix":function(e){return x(e,{})},"string, Object":function(e,t){return ie(e,t.nodes===void 0?{}:t.nodes)},"Array | Matrix, Object":x});function x(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.nodes===void 0?{}:t.nodes;return Pn(e,function(e){if(typeof e!=`string`)throw TypeError(`String expected`);return ie(e,n)})}var S={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},ee={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"?.":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},te={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},ne={true:!0,false:!1,null:null,undefined:void 0},C=[`NaN`,`Infinity`],w={'"':`"`,"'":`'`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:` +`,r:`\r`,t:` `};function T(){return{extraNodes:{},expression:``,comment:``,index:0,token:``,tokenType:S.NULL,nestingLevel:0,conditionalLevel:null}}function re(e,t){return e.expression.substr(e.index,t)}function E(e){return re(e,1)}function D(e){e.index++}function O(e){return e.expression.charAt(e.index-1)}function k(e){return e.expression.charAt(e.index+1)}function A(e){for(e.tokenType=S.NULL,e.token=``,e.comment=``;;){if(E(e)===`#`)for(;E(e)!==` +`&&E(e)!==``;)e.comment+=E(e),D(e);if(b.isWhitespace(E(e),e.nestingLevel))D(e);else break}if(E(e)===``){e.tokenType=S.DELIMITER;return}if(E(e)===` +`&&!e.nestingLevel){e.tokenType=S.DELIMITER,e.token=E(e),D(e);return}var t=E(e),n=re(e,2),r=re(e,3);if(r.length===3&&ee[r]){e.tokenType=S.DELIMITER,e.token=r,D(e),D(e),D(e);return}if(n.length===2&&ee[n]&&(n!==`?.`||!b.isDigit(e.expression.charAt(e.index+2)))){e.tokenType=S.DELIMITER,e.token=n,D(e),D(e);return}if(ee[t]){e.tokenType=S.DELIMITER,e.token=t,D(e);return}if(b.isDigitDot(t)){e.tokenType=S.NUMBER;var i=re(e,2);if(i===`0b`||i===`0o`||i===`0x`){for(e.token+=E(e),D(e),e.token+=E(e),D(e);b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);if(E(e)===`.`)for(e.token+=`.`,D(e);b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);else if(E(e)===`i`)for(e.token+=`i`,D(e);b.isDigit(E(e));)e.token+=E(e),D(e);return}if(E(e)===`.`){if(e.token+=E(e),D(e),!b.isDigit(E(e))){e.tokenType=S.DELIMITER;return}}else{for(;b.isDigit(E(e));)e.token+=E(e),D(e);b.isDecimalMark(E(e),k(e))&&(e.token+=E(e),D(e))}for(;b.isDigit(E(e));)e.token+=E(e),D(e);if(E(e)===`E`||E(e)===`e`){if(b.isDigit(k(e))||k(e)===`-`||k(e)===`+`){if(e.token+=E(e),D(e),(E(e)===`+`||E(e)===`-`)&&(e.token+=E(e),D(e)),!b.isDigit(E(e)))throw U(e,`Digit expected, got "`+E(e)+`"`);for(;b.isDigit(E(e));)e.token+=E(e),D(e);if(b.isDecimalMark(E(e),k(e)))throw U(e,`Digit expected, got "`+E(e)+`"`)}else if(b.isDecimalMark(k(e),e.expression.charAt(e.index+2)))throw D(e),U(e,`Digit expected, got "`+E(e)+`"`)}return}if(b.isAlpha(E(e),O(e),k(e))){for(;b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);H(te,e.token)?e.tokenType=S.DELIMITER:e.tokenType=S.SYMBOL;return}for(e.tokenType=S.UNKNOWN;E(e)!==``;)e.token+=E(e),D(e);throw U(e,`Syntax error in part "`+e.token+`"`)}function j(e){do A(e);while(e.token===` +`)}function M(e){e.nestingLevel++}function N(e){e.nestingLevel--}b.isAlpha=function(e,t,n){return b.isValidLatinOrGreek(e)||b.isValidMathSymbol(e,n)||b.isValidMathSymbol(t,e)},b.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},b.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},b.isWhitespace=function(e,t){return e===` `||e===` `||e===`\xA0`||e===` +`&&t>0},b.isDecimalMark=function(e,t){return e===`.`&&t!==`/`&&t!==`*`&&t!==`^`},b.isDigitDot=function(e){return e>=`0`&&e<=`9`||e===`.`},b.isDigit=function(e){return e>=`0`&&e<=`9`};function ie(e,t){var n=T();d(n,{expression:e,extraNodes:t}),A(n);var r=ae(n);if(n.token!==``)throw n.tokenType===S.DELIMITER?Le(n,`Unexpected operator `+n.token):U(n,`Unexpected part "`+n.token+`"`);return r}function ae(e){var t,n=[],r;for(e.token!==``&&e.token!==` +`&&e.token!==`;`&&(t=P(e),e.comment&&(t.comment=e.comment));e.token===` +`||e.token===`;`;)n.length===0&&t&&(r=e.token!==`;`,n.push({node:t,visible:r})),A(e),e.token!==` +`&&e.token!==`;`&&e.token!==``&&(t=P(e),e.comment&&(t.comment=e.comment),r=e.token!==`;`,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}function P(e){var t,n,r,i,a=oe(e);if(e.token===`=`){if(V(a))return t=a.name,j(e),r=P(e),new o(new y(t),r);if(L(a)){if(a.optionalChaining)throw U(e,`Cannot assign to optional chain`);return j(e),r=P(e),new o(a.object,a.index,r)}else if(Se(a)&&V(a.fn)&&(i=!0,n=[],t=a.name,a.args.forEach(function(e,t){V(e)?n[t]=e.name:i=!1}),i))return j(e),r=P(e),new u(t,n,r);throw U(e,`Invalid left hand side of assignment operator =`)}return a}function oe(e){for(var t=se(e);e.token===`?`;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,j(e);var r=t,i=P(e);if(e.token!==`:`)throw U(e,`False part of conditional expression expected`);e.conditionalLevel=null,j(e),t=new c(r,i,P(e)),e.conditionalLevel=n}return t}function se(e){for(var t=ce(e);e.token===`or`;)j(e),t=new h(`or`,`or`,[t,ce(e)]);return t}function ce(e){for(var t=le(e);e.token===`xor`;)j(e),t=new h(`xor`,`xor`,[t,le(e)]);return t}function le(e){for(var t=ue(e);e.token===`and`;)j(e),t=new h(`and`,`and`,[t,ue(e)]);return t}function ue(e){for(var t=de(e);e.token===`|`;)j(e),t=new h(`|`,`bitOr`,[t,de(e)]);return t}function de(e){for(var t=F(e);e.token===`^|`;)j(e),t=new h(`^|`,`bitXor`,[t,F(e)]);return t}function F(e){for(var t=I(e);e.token===`&`;)j(e),t=new h(`&`,`bitAnd`,[t,I(e)]);return t}function I(e){for(var t=[fe(e)],n=[],r={"==":`equal`,"!=":`unequal`,"<":`smaller`,">":`larger`,"<=":`smallerEq`,">=":`largerEq`};H(r,e.token);){var i={name:e.token,fn:r[e.token]};n.push(i),j(e),t.push(fe(e))}return t.length===1?t[0]:t.length===2?new h(n[0].name,n[0].fn,t):new v(n.map(e=>e.fn),t)}function fe(e){for(var t=pe(e),n,r,i,a={"<<":`leftShift`,">>":`rightArithShift`,">>>":`rightLogShift`};H(a,e.token);)n=e.token,r=a[n],j(e),i=[t,pe(e)],t=new h(n,r,i);return t}function pe(e){for(var t=me(e),n,r,i,a={to:`to`,in:`to`};H(a,e.token);)n=e.token,r=a[n],j(e),n===`in`&&`])},;`.includes(e.token)?t=new h(`*`,`multiply`,[t,new y(`in`)],!0):(i=[t,me(e)],t=new h(n,r,i));return t}function me(e){var t,n=[];if(e.token===`:`){if(e.conditionalLevel===e.nestingLevel)throw U(e,`The true-expression of a conditional operator may not be empty`);t=new l(1)}else t=he(e);if(e.token===`:`&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);e.token===`:`&&n.length<3;)j(e),e.token===`)`||e.token===`]`||e.token===`,`||e.token===``?n.push(new y(`end`)):n.push(he(e));t=n.length===3?new _(n[0],n[2],n[1]):new _(n[0],n[1])}return t}function he(e){for(var t=ge(e),n,r,i,a={"+":`add`,"-":`subtract`};H(a,e.token);){n=e.token,r=a[n],j(e);var o=ge(e);i=o.isPercentage?[t,new h(`*`,`multiply`,[t,o])]:[t,o],t=new h(n,r,i)}return t}function ge(e){for(var t=_e(e),n=t,r,i,a={"*":`multiply`,".*":`dotMultiply`,"/":`divide`,"./":`dotDivide`,"%":`mod`,mod:`mod`};H(a,e.token);)r=e.token,i=a[r],j(e),n=_e(e),t=new h(r,i,[t,n]);return t}function _e(e){for(var t=ve(e),n=t;e.tokenType===S.SYMBOL||e.token===`in`&&R(t)||e.token===`in`&&we(t)&&t.fn===`unaryMinus`&&R(t.args[0])||e.tokenType===S.NUMBER&&!R(n)&&(!we(n)||n.op===`!`)||e.token===`(`;)n=ve(e),t=new h(`*`,`multiply`,[t,n],!0);return t}function ve(e){for(var t=ye(e),n=t,r=[];e.token===`/`&&be(n);)if(r.push(d({},e)),j(e),e.tokenType===S.NUMBER)if(r.push(d({},e)),j(e),e.tokenType===S.SYMBOL||e.token===`(`||e.token===`in`)d(e,r.pop()),r.pop(),n=ye(e),t=new h(`/`,`divide`,[t,n]);else{r.pop(),d(e,r.pop());break}else{d(e,r.pop());break}return t}function ye(e){var t=xe(e);if(e.token===`%`){var n=d({},e);j(e);try{xe(e),d(e,n)}catch{t=new h(`/`,`divide`,[t,new l(100)],!1,!0)}}return t}function xe(e){var t,n,r,i={"-":`unaryMinus`,"+":`unaryPlus`,"~":`bitNot`,not:`not`};return H(i,e.token)?(r=i[e.token],t=e.token,j(e),n=[xe(e)],new h(t,r,n)):z(e)}function z(e){var t=B(e),n,r,i;return(e.token===`^`||e.token===`.^`)&&(n=e.token,r=n===`^`?`pow`:`dotPow`,j(e),i=[t,xe(e)],t=new h(n,r,i)),t}function B(e){for(var t=Ce(e);e.token===`??`;)j(e),t=new h(`??`,`nullish`,[t,Ce(e)]);return t}function Ce(e){for(var t=Te(e),n,r,i,a={"!":`factorial`,"'":`ctranspose`};H(a,e.token);)n=e.token,r=a[n],A(e),i=[t],t=new h(n,r,i),t=De(e,t);return t}function Te(e){var t=[];if(e.tokenType===S.SYMBOL&&H(e.extraNodes,e.token)){var n=e.extraNodes[e.token];if(A(e),e.token===`(`){if(t=[],M(e),A(e),e.token!==`)`)for(t.push(P(e));e.token===`,`;)A(e),t.push(P(e));if(e.token!==`)`)throw U(e,`Parenthesis ) expected`);N(e),A(e)}return new n(t)}return Ee(e)}function Ee(e){var t,r;return e.tokenType===S.SYMBOL||e.tokenType===S.DELIMITER&&e.token in te?(r=e.token,A(e),t=H(ne,r)?new l(ne[r]):C.includes(r)?new l(n(r,`number`)):new y(r),t=De(e,t),t):Oe(e)}function De(e,t,n){for(var r;;){var a=!1;e.token===`?.`&&(a=!0,A(e));var o=(e.token===`(`||e.token===`[`||e.token===`.`)&&(!n||n.includes(e.token));if(!(a||o))break;if(r=[],e.token===`(`)if(a||V(t)||L(t)){if(M(e),A(e),e.token!==`)`)for(r.push(P(e));e.token===`,`;)A(e),r.push(P(e));if(e.token!==`)`)throw U(e,`Parenthesis ) expected`);N(e),A(e),t=new f(t,r,a)}else return t;else if(e.token===`[`){if(M(e),A(e),e.token!==`]`)for(r.push(P(e));e.token===`,`;)A(e),r.push(P(e));if(e.token!==`]`)throw U(e,`Parenthesis ] expected`);N(e),A(e),t=new i(t,new p(r),a)}else{if(a||A(e),!(e.tokenType===S.SYMBOL||e.tokenType===S.DELIMITER&&e.token in te)){var s=`Property name expected after `;throw s+=a?`optional chain`:`dot`,U(e,s)}r.push(new l(e.token)),A(e),t=new i(t,new p(r,!0),a)}}return t}function Oe(e){var t,n;return e.token===`"`||e.token===`'`?(n=ke(e,e.token),t=new l(n),t=De(e,t),t):Ae(e)}function ke(e,t){for(var n=``;E(e)!==``&&E(e)!==t;)if(E(e)===`\\`){D(e);var r=E(e),i=w[r];if(i!==void 0)n+=i,e.index+=1;else if(r===`u`){var a=e.expression.slice(e.index+1,e.index+5);if(/^[0-9A-Fa-f]{4}$/.test(a))n+=String.fromCharCode(parseInt(a,16)),e.index+=5;else throw U(e,`Invalid unicode character \\u${a}`)}else throw U(e,`Bad escape character \\${r}`)}else n+=E(e),D(e);if(A(e),e.token!==t)throw U(e,`End of string ${t} expected`);return A(e),n}function Ae(e){var t,n,r,i;if(e.token===`[`){if(M(e),A(e),e.token!==`]`){var o=je(e);if(e.token===`;`){for(r=1,n=[o];e.token===`;`;)A(e),e.token!==`]`&&(n[r]=je(e),r++);if(e.token!==`]`)throw U(e,`End of matrix ] expected`);N(e),A(e),i=n[0].items.length;for(var s=1;s{var{typed:t,parse:n}=e;return t(Rr,{string:function(e){var t=ne();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=ne();return Pn(e,function(e){return n(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return Pn(e,function(e){return n(e).compile().evaluate(t)})}})}),Br=`size`,Vr=K(Br,[`typed`],e=>{var{typed:t}=e;return t(Br,{Matrix:e=>e.size(),Array:kn,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),Hr=`factorial`,Ur=K(Hr,[`typed`,`gamma`],e=>{var{typed:t,gamma:n}=e;return t(Hr,{number:function(e){if(e<0)throw Error(`Value must be non-negative`);return n(e+1)},BigNumber:function(e){if(e.isNegative())throw Error(`Value must be non-negative`);return n(e.plus(1))},"Array | Matrix":t.referToSelf(e=>t=>Pn(t,e))})}),Wr=`isBounded`,Gr=K(Wr,[`typed`],e=>{var{typed:t}=e;return t(Wr,{number:e=>Number.isFinite(e),"BigNumber | Complex":e=>e.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:t.referToSelf(e=>t=>e(t.value)),"Array | Matrix":t.referToSelf(e=>t=>(Array.isArray(t)||(t=t.valueOf()),t.every(t=>e(t))))})}),Kr=K(`numeric`,[`number`,`?bignumber`,`?fraction`],e=>{var{number:t,bignumber:n,fraction:r}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:n?e=>n(e):Yt,bigint:e=>BigInt(e),Fraction:r?e=>r(e):Xt};return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`number`;if((arguments.length>2?arguments[2]:void 0)!==void 0)throw SyntaxError(`numeric() takes one or two arguments`);var n=ke(e);if(!(n in i))throw TypeError(`Cannot convert `+e+` of type "`+n+`"; valid input types are `+Object.keys(i).join(`, `));if(!(t in a))throw TypeError(`Cannot convert `+e+` to type "`+t+`"; valid output types are `+Object.keys(a).join(`, `));return t===n?e:a[t](e)}}),qr=Z(`abs`,lt),Jr=Z(`exp`,vt),Yr=Z(`gcd`,bt),Xr=Z(`lcm`,xt),Zr=Z(`log10`,Ct),Qr=Z(`log2`,wt),$r=Z(`mod`,Et),ei=Z(`multiply`,ft),ti=mi(`nthRoot`,Dt),ni=Z(`sign`,Ot),ri=Z(`sqrt`,kt),ii=Z(`subtract`,dt),ai=Z(`pow`,Mt),oi=mi(`round`,Nt),si=mi(`log`,St),ci=Z(`log1p`,Tt),li=Z(`add`,ut),ui=Z(`divide`,pt),di=K(`matrix`,[],()=>Zt),fi=K(`subset`,[],()=>Qt);Z(`combinations`,It);var pi=Z(`gamma`,zt);Z(`lgamma`,Wt);function Z(e,t){return K(e,[`typed`],e=>{var{typed:n}=e;return n(t)})}function mi(e,t){return K(e,[`typed`],e=>{var{typed:n}=e;return n({number:t,"number,number":t})})}function hi(e,t,n,r){if(!(this instanceof hi))throw SyntaxError(`Constructor must be called with the new operator`);this.fn=e,this.count=t,this.min=n,this.max=r,this.message=`Wrong number of arguments in function `+e+` (`+t+` provided, `+n+(r==null?``:`-`+r)+` expected)`,this.stack=Error().stack}hi.prototype=Error(),hi.prototype.constructor=Error,hi.prototype.name=`ArgumentsError`,hi.prototype.isArgumentsError=!0;var Q={createTyped:tn},gi={typedDependencies:Q,createAbs:qr},$={createNode:Yn},_i={createSubset:fi},vi={NodeDependencies:$,subsetDependencies:_i,createAccessorNode:$n},yi={typedDependencies:Q,createAdd:li},bi={NodeDependencies:$,createArrayNode:tr},xi={matrixDependencies:{createMatrix:di},NodeDependencies:$,subsetDependencies:_i,createAssignmentNode:ir},Si={gammaDependencies:{typedDependencies:Q,createGamma:pi},typedDependencies:Q,createFactorial:Ur},Ci={typedDependencies:Q,createNumber:qn},wi={typedDependencies:Q,createPow:ai},Ti={NodeDependencies:$,ResultSetDependencies:{createResultSet:sn},createBlockNode:or},Ei={typedDependencies:Q,createRound:oi},Di={NodeDependencies:$,createConditionalNode:cr},Oi={NodeDependencies:$,isBoundedDependencies:{typedDependencies:Q,createIsBounded:Gr},createConstantNode:_r},ki={NodeDependencies:$,typedDependencies:Q,createFunctionAssignmentNode:yr},Ai={NodeDependencies:$,createSymbolNode:Nr},ji={AccessorNodeDependencies:vi,ArrayNodeDependencies:bi,AssignmentNodeDependencies:xi,BlockNodeDependencies:Ti,ConditionalNodeDependencies:Di,ConstantNodeDependencies:Oi,FunctionAssignmentNodeDependencies:ki,FunctionNodeDependencies:{NodeDependencies:$,SymbolNodeDependencies:Ai,createFunctionNode:Fr},IndexNodeDependencies:{NodeDependencies:$,sizeDependencies:{typedDependencies:Q,createSize:Vr},createIndexNode:xr},ObjectNodeDependencies:{NodeDependencies:$,createObjectNode:Cr},OperatorNodeDependencies:{NodeDependencies:$,createOperatorNode:Er},ParenthesisNodeDependencies:{NodeDependencies:$,createParenthesisNode:Or},RangeNodeDependencies:{NodeDependencies:$,createRangeNode:Ar},RelationalNodeDependencies:{NodeDependencies:$,createRelationalNode:Mr},SymbolNodeDependencies:Ai,numericDependencies:{numberDependencies:Ci,createNumeric:Kr},typedDependencies:Q,createParse:Lr},Mi={typedDependencies:Q,createDivide:ui},Ni={typedDependencies:Q,createMultiply:ei},Pi={typedDependencies:Q,createSqrt:ri},Fi={typedDependencies:Q,createSubtract:ii},Ii={createE:Vn},Li={parseDependencies:ji,typedDependencies:Q,createEvaluate:zr},Ri={typedDependencies:Q,createExp:Jr},zi={typedDependencies:Q,createGcd:Yr},Bi={typedDependencies:Q,createLcm:Xr},Vi={typedDependencies:Q,createLog:si},Hi={typedDependencies:Q,createLog10:Zr},Ui={typedDependencies:Q,createLog1p:ci},Wi={typedDependencies:Q,createLog2:Qr},Gi={typedDependencies:Q,createMod:$r},Ki={typedDependencies:Q,createNthRoot:ti},qi={createPi:Bn},Ji={typedDependencies:Q,createSign:ni},Yi=u(c(((e,t)=>{function n(){}n.prototype={on:function(e,t,n){var r=this.e||={};return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||={})[e]||[]).slice(),r=0,i=n.length;rr(e,t));else if(F(n)||d(n))for(var a in n)H(n,a)&&r(e,n[a],a);else if(Gt(n)||i!==void 0){var o=Gt(n)?h(n)?n.fn+`.transform`:n.fn:i;if(H(e,o)&&e[o]!==n&&!t.silent)throw Error(`Cannot import "`+o+`" twice`);e[o]=n}else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}var i={};for(var o in r(i,e),i)if(H(i,o)){var s=i[o];if(Gt(s))l(s,t);else if(u(s))a(o,s,t);else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}}function a(t,i,a){if(a.wrap&&typeof i==`function`&&(i=c(i)),f(i)&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(n[t])&&e.isTypedFunction(i)){i=a.override?e(t,i.signatures):e(n[t],i),n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}var s=n[t]!==void 0,l=n.Unit?.isValuelessUnit(t);if(!s&&!l||a.override){n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}if(!a.silent)throw Error(`Cannot import "`+t+`": already exists`)}function o(e,t){t&&typeof t.transform==`function`?(n.expression.transform[e]=t.transform,p(e)&&(n.expression.mathWithTransform[e]=t.transform)):(delete n.expression.transform[e],p(e)&&(n.expression.mathWithTransform[e]=t))}function s(e){delete n.expression.transform[e],p(e)?n.expression.mathWithTransform[e]=n[e]:delete n.expression.mathWithTransform[e]}function c(e){var t=function(){for(var t=[],r=0,i=arguments.length;r2&&arguments[2]!==void 0?arguments[2]:t.fn;if(a.includes(`.`))throw Error(`Factory name should not contain a nested path. Name: `+JSON.stringify(a));var o=h(t)?n.expression.transform:n,c=a in n.expression.transform,l=H(o,a)?o[a]:void 0,u=function(){var r={};t.dependencies.map(Jt).forEach(e=>{if(e.includes(`.`))throw Error(`Factory dependency should not contain a nested path. Name: `+JSON.stringify(e));e===`math`?r.math=n:e===`mathWithTransform`?r.mathWithTransform=n.expression.mathWithTransform:e===`classes`?r.classes=n:r[e]=n[e]});var o=t(r);if(o&&typeof o.transform==`function`)throw Error(`Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"`);if(l===void 0||i.override)return o;if(e.isTypedFunction(l)&&e.isTypedFunction(o))return e(l,o);if(i.silent)return l;throw Error(`Cannot import "`+a+`": already exists`)},d=t.meta?.formerly??``,f=h(t)||m(t),p=n.expression.mathWithTransform;!t.meta||t.meta.lazy!==!1?(Ie(o,a,u),d&&Ie(o,d,u),l&&c?(s(a),d&&s(d)):f&&(Ie(p,a,()=>o[a]),d&&Ie(p,d,()=>o[a]))):(o[a]=u(),d&&(o[d]=o[a]),l&&c?(s(a),d&&s(d)):f&&(Ie(p,a,()=>o[a]),d&&Ie(p,d,()=>o[a]))),r[a]=t,n.emit(`import`,a,u)}function u(e){return typeof e==`function`||typeof e==`number`||typeof e==`string`||typeof e==`boolean`||e===null||O(e)||E(e)||T(e)||D(e)||j(e)||Array.isArray(e)}function d(e){return typeof e==`object`&&e[Symbol.toStringTag]===`Module`}function f(e){return typeof e==`function`&&typeof e.signature==`string`}function p(e){return!H(g,e)}function m(e){return!e.fn.includes(`.`)&&!H(g,e.fn)&&(!e.meta||!e.meta.isClass)}function h(e){return e!==void 0&&e.meta!==void 0&&e.meta.isTransformFunction===!0||!1}var g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return i}function Qi(e,t){var n=d({},f,t);if(typeof Object.create!=`function`)throw Error(`ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.`);var r=Xi({isNumber:w,isComplex:E,isBigNumber:T,isBigInt:re,isFraction:D,isUnit:O,isString:k,isArray:A,isMatrix:j,isCollection:M,isDenseMatrix:N,isSparseMatrix:ie,isRange:ae,isIndex:P,isBoolean:oe,isResultSet:se,isHelp:ce,isFunction:le,isDate:ue,isRegExp:de,isObject:F,isMap:I,isPartitionedMap:fe,isObjectWrappingMap:pe,isNull:me,isUndefined:he,isAccessorNode:L,isArrayNode:ge,isAssignmentNode:_e,isBlockNode:ve,isConditionalNode:ye,isConstantNode:R,isFunctionAssignmentNode:xe,isFunctionNode:Se,isIndexNode:z,isNode:B,isObjectNode:Ce,isOperatorNode:we,isParenthesisNode:Te,isRangeNode:Ee,isRelationalNode:De,isSymbolNode:V,isChain:Oe});r.config=Be(n,r.emit),r.expression={transform:{},mathWithTransform:{config:r.config}};var i=[],a=[];function o(e){if(Gt(e))return e(r);var t=e[Object.keys(e)[0]];if(Gt(t))return t(r);if(!U(e))throw console.warn("Factory object with properties `type`, `name`, and `factory` expected",e),Error("Factory object with properties `type`, `name`, and `factory` expected");var s=i.indexOf(e),c;return s===-1?(c=e.math===!0?e.factory(r.type,n,o,r.typed,r):e.factory(r.type,n,o,r.typed),i.push(e),a.push(c)):c=a[s],c}var s={};function c(){var e=[...arguments];return r.typed.apply(r.typed,e)}c.isTypedFunction=$t.default.isTypedFunction;var l=Zi(c,o,r,s);return r.import=l,r.on(`config`,()=>{Object.values(s).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&l(e,{override:!0})})}),r.create=Qi.bind(null,e),r.factory=K,r.import(Object.values(Pe(e))),r.ArgumentsError=hi,r.DimensionError=On,r.IndexError=Dn,r}var $i=e=>{let n=t(`results`),r=t(`answers`,{assert:!1});if(!r){let e=document.createElement(`h4`);e.setAttribute(`class`,`title`),e.setAttribute(`id`,`answers-title`),e.textContent=`Answers : `,r=document.createElement(`div`),r.setAttribute(`id`,`answers`),r.setAttribute(`role`,`complementary`),r.setAttribute(`aria-labelledby`,`answers-title`),r.appendChild(e)}if(!(e instanceof HTMLElement)){let t=document.createElement(`span`);t.innerHTML=e.toString(),e=t}r.appendChild(e),n.insertAdjacentElement(`afterbegin`,r)},ea=class n extends e{constructor(){super(`calculator`)}static math=Qi({...gi,...yi,...Mi,...Ii,...Li,...Ri,...Si,...zi,...Bi,...Hi,...Ui,...Wi,...Vi,...Gi,...Ni,...Ki,...qi,...wi,...Ei,...Ji,...Pi,...Fi});async run(){let e=t(`q`),r=n.math.parse(e.value);try{return`${r.toString()} = ${r.evaluate()}`}catch{return}}async post(e){$i(e)}};export{ea as default}; +//# sourceMappingURL=4sMJQOad.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/4sMJQOad.min.js.map b/searx/static/themes/simple/chunk/4sMJQOad.min.js.map new file mode 100644 index 000000000..f06496cce --- /dev/null +++ b/searx/static/themes/simple/chunk/4sMJQOad.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"4sMJQOad.min.js","names":["isInteger","format","toFixed","toExponential","toEngineering","_toNumberOrDefault","toFixed","typedFunction","dependencies","name","dependencies","format","formatNumber","formatBigNumber","deepMap","arrayDeepMap","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","Emitter","emitter.mixin","typedFunction"],"sources":["../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/extends.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/config.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/customs.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/map.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/is.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/object.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/config.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/number.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/arithmetic.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/product.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/combinations.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/probability.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/factory.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/noop.js","../../../../../client/simple/node_modules/typed-function/lib/umd/typed-function.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/typed.js","../../../../../client/simple/node_modules/mathjs/lib/esm/type/resultset/ResultSet.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/bignumber/formatter.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/string.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/operators.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/IndexError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/DimensionError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/array.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/collection.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/lruQueue.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/function.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/bignumber/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/type/number.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/keywords.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/Node.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/transform/utils/errorTransform.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/utils/access.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/AccessorNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ArrayNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/utils/assign.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/AssignmentNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/BlockNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ConditionalNode.js","../../../../../client/simple/node_modules/escape-latex/dist/index.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/latex.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ConstantNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/FunctionAssignmentNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/IndexNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ObjectNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/scope.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/OperatorNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ParenthesisNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/RangeNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/RelationalNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/SymbolNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/FunctionNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/parse.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/function/evaluate.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/matrix/size.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/probability/factorial.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/utils/isBounded.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/utils/numeric.js","../../../../../client/simple/node_modules/mathjs/lib/esm/factoriesNumber.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/ArgumentsError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesTyped.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAbs.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSubset.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAccessorNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAdd.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesArrayNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMatrix.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAssignmentNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesGamma.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFactorial.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNumber.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesPow.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesResultSet.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesBlockNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRound.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesConditionalNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesIsBounded.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesConstantNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFunctionAssignmentNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSymbolNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFunctionNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSize.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesIndexNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesObjectNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesOperatorNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesParenthesisNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRangeNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRelationalNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNumeric.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesParse.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesDivide.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMultiply.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSqrt.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSubtract.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesE.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesEvaluate.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesExp.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesGcd.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLcm.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog10.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog1p.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog2.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMod.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNthRoot.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesPi.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSign.generated.js","../../../../../client/simple/node_modules/tiny-emitter/index.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/emitter.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/import.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/create.js","../../../../../client/simple/src/js/util/appendAnswerElement.ts","../../../../../client/simple/src/js/plugin/Calculator.ts"],"sourcesContent":["function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","export var DEFAULT_CONFIG = {\n // minimum relative difference between two compared values,\n // used by all comparison functions\n relTol: 1e-12,\n // minimum absolute difference between two compared values,\n // used by all comparison functions\n absTol: 1e-15,\n // type of default matrix output. Choose 'matrix' (default) or 'array'\n matrix: 'Matrix',\n // type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'\n number: 'number',\n // type of fallback used for config { number: 'bigint' } when a value cannot be represented\n // in the configured numeric type. Choose 'number' (default) or 'BigNumber'.\n numberFallback: 'number',\n // number of significant digits in BigNumbers\n precision: 64,\n // predictable output type of functions. When true, output type depends only\n // on the input types. When false (default), output type can vary depending\n // on input values. For example `math.sqrt(-4)` returns `complex('2i')` when\n // predictable is false, and returns `NaN` when true.\n predictable: false,\n // random seed for seeded pseudo random number generation\n // null = randomly seed\n randomSeed: null,\n // legacy behavior for matrix subset. When true, the subset function\n // returns a matrix or array with the same size as the index (except for scalars).\n // When false, it returns a matrix or array with a size depending on the type of index.\n legacySubset: false\n};","import { hasOwnProperty } from './object.js';\n\n/**\n * Get a property of a plain object or array\n * Throws an error in case the object is not a plain object or the\n * property is not defined on the object itself\n * @param {Object} object\n * @param {string} prop\n * @return {*} Returns the property value when safe\n */\nexport function getSafeProperty(object, prop) {\n if (isSafeObjectProperty(object, prop) || isSafeArrayProperty(object, prop)) {\n return object[prop];\n }\n if (isSafeMethod(object, prop)) {\n throw new Error(\"Cannot access method \\\"\".concat(prop, \"\\\" as a property\"));\n }\n if (object === null || object === undefined) {\n throw new TypeError(\"Cannot access property \\\"\".concat(prop, \"\\\": object is \").concat(object));\n }\n throw new Error('No access to property \"' + prop + '\"');\n}\n\n/**\n * Set a property on a plain object or array.\n * Throws an error in case the object is not a plain object or the\n * property would override an inherited property like .constructor or .toString\n * @param {Object} object\n * @param {string} prop\n * @param {*} value\n * @return {*} Returns the value\n */\nexport function setSafeProperty(object, prop, value) {\n if (isSafeObjectProperty(object, prop) || isSafeArrayProperty(object, prop)) {\n object[prop] = value;\n return value;\n }\n throw new Error(\"No access to property \\\"\".concat(prop, \"\\\"\"));\n}\n\n/**\n * Test whether a property is safe for reading and writing on an object\n * For example .constructor and .__proto__ are not safe\n * @param {Object} object\n * @param {string} prop\n * @return {boolean} Returns true when safe\n */\nexport function isSafeObjectProperty(object, prop) {\n if (!isPlainObject(object)) {\n return false;\n }\n return !(prop in Object.prototype);\n}\n\n/**\n * Test whether a property is safe for reading and writing on an Array\n * For example .__proto__ and .constructor are not safe\n * @param {unknown} array\n * @param {string | number} prop\n * @return {boolean} Returns true when safe\n */\nexport function isSafeArrayProperty(array, prop) {\n if (!Array.isArray(array)) {\n return false;\n }\n return typeof prop === 'number' || typeof prop === 'string' && isInteger(prop) || prop === 'length';\n}\nfunction isInteger(prop) {\n return /^\\d+$/.test(prop);\n}\n\n/**\n * Validate whether a method is safe.\n * Throws an error when that's not the case.\n * @param {Object} object\n * @param {string} method\n * @return {function} Returns the method when valid\n */\nexport function getSafeMethod(object, method) {\n if (!isSafeMethod(object, method)) {\n throw new Error('No access to method \"' + method + '\"');\n }\n return object[method];\n}\n\n/**\n * Check whether a method is safe.\n * Throws an error when that's not the case (for example for `constructor`).\n * @param {Object} object\n * @param {string} method\n * @return {boolean} Returns true when safe, false otherwise\n */\nexport function isSafeMethod(object, method) {\n if (object === null || object === undefined || typeof object[method] !== 'function') {\n return false;\n }\n\n // UNSAFE: ghosted\n // e.g overridden toString\n // Note that IE10 doesn't support __proto__ and we can't do this check there.\n if (hasOwnProperty(object, method) && Object.getPrototypeOf && method in Object.getPrototypeOf(object)) {\n return false;\n }\n\n // SAFE: whitelisted\n // e.g toString\n if (safeNativeMethods.has(method)) {\n return true;\n }\n\n // UNSAFE: inherited from Object prototype\n // e.g constructor\n if (method in Object.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Object.prototype is a root object\n return false;\n }\n\n // UNSAFE: inherited from Function prototype\n // e.g call, apply\n if (method in Function.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Function.prototype is a root object\n return false;\n }\n return true;\n}\nexport function isPlainObject(object) {\n return typeof object === 'object' && object && object.constructor === Object;\n}\nvar safeNativeMethods = new Set(['toString', 'valueOf', 'toLocaleString']);","import { getSafeProperty, isSafeObjectProperty, setSafeProperty } from './customs.js';\nimport { isMap, isObject } from './is.js';\n\n/**\n * A map facade on a bare object.\n *\n * The small number of methods needed to implement a scope,\n * forwarding on to the SafeProperty functions. Over time, the codebase\n * will stop using this method, as all objects will be Maps, rather than\n * more security prone objects.\n */\nexport class ObjectWrappingMap {\n constructor(object) {\n this.wrappedObject = object;\n this[Symbol.iterator] = this.entries;\n }\n keys() {\n return Object.keys(this.wrappedObject).filter(key => this.has(key)).values();\n }\n get(key) {\n return getSafeProperty(this.wrappedObject, key);\n }\n set(key, value) {\n setSafeProperty(this.wrappedObject, key, value);\n return this;\n }\n has(key) {\n return isSafeObjectProperty(this.wrappedObject, key) && key in this.wrappedObject;\n }\n entries() {\n return mapIterator(this.keys(), key => [key, this.get(key)]);\n }\n forEach(callback) {\n for (var key of this.keys()) {\n callback(this.get(key), key, this);\n }\n }\n delete(key) {\n if (isSafeObjectProperty(this.wrappedObject, key)) {\n delete this.wrappedObject[key];\n }\n }\n clear() {\n for (var key of this.keys()) {\n this.delete(key);\n }\n }\n get size() {\n return Object.keys(this.wrappedObject).length;\n }\n}\n\n/**\n * Create a map with two partitions: a and b.\n * The set with bKeys determines which keys/values are read/written to map b,\n * all other values are read/written to map a\n *\n * For example:\n *\n * const a = new Map()\n * const b = new Map()\n * const p = new PartitionedMap(a, b, new Set(['x', 'y']))\n *\n * In this case, values `x` and `y` are read/written to map `b`,\n * all other values are read/written to map `a`.\n */\nexport class PartitionedMap {\n /**\n * @param {Map} a\n * @param {Map} b\n * @param {Set} bKeys\n */\n constructor(a, b, bKeys) {\n this.a = a;\n this.b = b;\n this.bKeys = bKeys;\n this[Symbol.iterator] = this.entries;\n }\n get(key) {\n return this.bKeys.has(key) ? this.b.get(key) : this.a.get(key);\n }\n set(key, value) {\n if (this.bKeys.has(key)) {\n this.b.set(key, value);\n } else {\n this.a.set(key, value);\n }\n return this;\n }\n has(key) {\n return this.b.has(key) || this.a.has(key);\n }\n keys() {\n return new Set([...this.a.keys(), ...this.b.keys()])[Symbol.iterator]();\n }\n entries() {\n return mapIterator(this.keys(), key => [key, this.get(key)]);\n }\n forEach(callback) {\n for (var key of this.keys()) {\n callback(this.get(key), key, this);\n }\n }\n delete(key) {\n return this.bKeys.has(key) ? this.b.delete(key) : this.a.delete(key);\n }\n clear() {\n this.a.clear();\n this.b.clear();\n }\n get size() {\n return [...this.keys()].length;\n }\n}\n\n/**\n * Create a new iterator that maps over the provided iterator, applying a mapping function to each item\n */\nfunction mapIterator(it, callback) {\n return {\n next: () => {\n var n = it.next();\n return n.done ? n : {\n value: callback(n.value),\n done: false\n };\n }\n };\n}\n\n/**\n * Creates an empty map, or whatever your platform's polyfill is.\n *\n * @returns an empty Map or Map like object.\n */\nexport function createEmptyMap() {\n return new Map();\n}\n\n/**\n * Creates a Map from the given object.\n *\n * @param { Map | { [key: string]: unknown } | undefined } mapOrObject\n * @returns\n */\nexport function createMap(mapOrObject) {\n if (!mapOrObject) {\n return createEmptyMap();\n }\n if (isMap(mapOrObject)) {\n return mapOrObject;\n }\n if (isObject(mapOrObject)) {\n return new ObjectWrappingMap(mapOrObject);\n }\n throw new Error('createMap can create maps from objects or Maps');\n}\n\n/**\n * Unwraps a map into an object.\n *\n * @param {Map} map\n * @returns { [key: string]: unknown }\n */\nexport function toObject(map) {\n if (map instanceof ObjectWrappingMap) {\n return map.wrappedObject;\n }\n var object = {};\n for (var key of map.keys()) {\n var value = map.get(key);\n setSafeProperty(object, key, value);\n }\n return object;\n}\n\n/**\n * Copies the contents of key-value pairs from each `objects` in to `map`.\n *\n * Object is `objects` can be a `Map` or object.\n *\n * This is the `Map` analog to `Object.assign`.\n */\nexport function assign(map) {\n for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n objects[_key - 1] = arguments[_key];\n }\n for (var args of objects) {\n if (!args) {\n continue;\n }\n if (isMap(args)) {\n for (var key of args.keys()) {\n map.set(key, args.get(key));\n }\n } else if (isObject(args)) {\n for (var _key2 of Object.keys(args)) {\n map.set(_key2, args[_key2]);\n }\n }\n }\n return map;\n}","// type checks for all known types\n//\n// note that:\n//\n// - check by duck-typing on a property like `isUnit`, instead of checking instanceof.\n// instanceof cannot be used because that would not allow to pass data from\n// one instance of math.js to another since each has it's own instance of Unit.\n// - check the `isUnit` property via the constructor, so there will be no\n// matches for \"fake\" instances like plain objects with a property `isUnit`.\n// That is important for security reasons.\n// - It must not be possible to override the type checks used internally,\n// for security reasons, so these functions are not exposed in the expression\n// parser.\n\nimport { ObjectWrappingMap } from './map.js';\nexport function isNumber(x) {\n return typeof x === 'number';\n}\nexport function isBigNumber(x) {\n if (!x || typeof x !== 'object' || typeof x.constructor !== 'function') {\n return false;\n }\n if (x.isBigNumber === true && typeof x.constructor.prototype === 'object' && x.constructor.prototype.isBigNumber === true) {\n return true;\n }\n if (typeof x.constructor.isDecimal === 'function' && x.constructor.isDecimal(x) === true) {\n return true;\n }\n return false;\n}\nexport function isBigInt(x) {\n return typeof x === 'bigint';\n}\nexport function isComplex(x) {\n return x && typeof x === 'object' && Object.getPrototypeOf(x).isComplex === true || false;\n}\nexport function isFraction(x) {\n return x && typeof x === 'object' && Object.getPrototypeOf(x).isFraction === true || false;\n}\nexport function isUnit(x) {\n return x && x.constructor.prototype.isUnit === true || false;\n}\nexport function isString(x) {\n return typeof x === 'string';\n}\nexport var isArray = Array.isArray;\nexport function isMatrix(x) {\n return x && x.constructor.prototype.isMatrix === true || false;\n}\n\n/**\n * Test whether a value is a collection: an Array or Matrix\n * @param {*} x\n * @returns {boolean} isCollection\n */\nexport function isCollection(x) {\n return Array.isArray(x) || isMatrix(x);\n}\nexport function isDenseMatrix(x) {\n return x && x.isDenseMatrix && x.constructor.prototype.isMatrix === true || false;\n}\nexport function isSparseMatrix(x) {\n return x && x.isSparseMatrix && x.constructor.prototype.isMatrix === true || false;\n}\nexport function isRange(x) {\n return x && x.constructor.prototype.isRange === true || false;\n}\nexport function isIndex(x) {\n return x && x.constructor.prototype.isIndex === true || false;\n}\nexport function isBoolean(x) {\n return typeof x === 'boolean';\n}\nexport function isResultSet(x) {\n return x && x.constructor.prototype.isResultSet === true || false;\n}\nexport function isHelp(x) {\n return x && x.constructor.prototype.isHelp === true || false;\n}\nexport function isFunction(x) {\n return typeof x === 'function';\n}\nexport function isDate(x) {\n return x instanceof Date;\n}\nexport function isRegExp(x) {\n return x instanceof RegExp;\n}\nexport function isObject(x) {\n return !!(x && typeof x === 'object' && x.constructor === Object && !isComplex(x) && !isFraction(x));\n}\n\n/**\n * Returns `true` if the passed object appears to be a Map (i.e. duck typing).\n *\n * Methods looked for are `get`, `set`, `keys` and `has`.\n *\n * @param {Map | object} object\n * @returns\n */\nexport function isMap(object) {\n // We can use the fast instanceof, or a slower duck typing check.\n // The duck typing method needs to cover enough methods to not be confused with DenseMatrix.\n if (!object) {\n return false;\n }\n return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === 'function' && typeof object.get === 'function' && typeof object.keys === 'function' && typeof object.has === 'function';\n}\nexport function isPartitionedMap(object) {\n return isMap(object) && isMap(object.a) && isMap(object.b);\n}\nexport function isObjectWrappingMap(object) {\n return isMap(object) && isObject(object.wrappedObject);\n}\nexport function isNull(x) {\n return x === null;\n}\nexport function isUndefined(x) {\n return x === undefined;\n}\nexport function isAccessorNode(x) {\n return x && x.isAccessorNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isArrayNode(x) {\n return x && x.isArrayNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isAssignmentNode(x) {\n return x && x.isAssignmentNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isBlockNode(x) {\n return x && x.isBlockNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isConditionalNode(x) {\n return x && x.isConditionalNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isConstantNode(x) {\n return x && x.isConstantNode === true && x.constructor.prototype.isNode === true || false;\n}\n\n/* Very specialized: returns true for those nodes which in the numerator of\n a fraction means that the division in that fraction has precedence over implicit\n multiplication, e.g. -2/3 x parses as (-2/3) x and 3/4 x parses as (3/4) x but\n 6!/8 x parses as 6! / (8x). It is located here because it is shared between\n parse.js and OperatorNode.js (for parsing and printing, respectively).\n\n This should *not* be exported from mathjs, unlike most of the tests here.\n Its name does not start with 'is' to prevent utils/snapshot.js from thinking\n it should be exported.\n*/\nexport function rule2Node(node) {\n return isConstantNode(node) || isOperatorNode(node) && node.args.length === 1 && isConstantNode(node.args[0]) && '-+~'.includes(node.op);\n}\nexport function isFunctionAssignmentNode(x) {\n return x && x.isFunctionAssignmentNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isFunctionNode(x) {\n return x && x.isFunctionNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isIndexNode(x) {\n return x && x.isIndexNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isNode(x) {\n return x && x.isNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isObjectNode(x) {\n return x && x.isObjectNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isOperatorNode(x) {\n return x && x.isOperatorNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isParenthesisNode(x) {\n return x && x.isParenthesisNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isRangeNode(x) {\n return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isRelationalNode(x) {\n return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isSymbolNode(x) {\n return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isChain(x) {\n return x && x.constructor.prototype.isChain === true || false;\n}\nexport function typeOf(x) {\n var t = typeof x;\n if (t === 'object') {\n if (x === null) return 'null';\n if (isBigNumber(x)) return 'BigNumber'; // Special: weird mashup with Decimal\n if (x.constructor && x.constructor.name) return x.constructor.name;\n return 'Object'; // just in case\n }\n return t; // can be 'string', 'number', 'boolean', 'function', 'bigint', ...\n}","import { isBigNumber, isObject } from './is.js';\n\n/**\n * Clone an object\n *\n * clone(x)\n *\n * Can clone any primitive type, array, and object.\n * If x has a function clone, this function will be invoked to clone the object.\n *\n * @param {*} x\n * @return {*} clone\n */\nexport function clone(x) {\n var type = typeof x;\n\n // immutable primitive types\n if (type === 'number' || type === 'bigint' || type === 'string' || type === 'boolean' || x === null || x === undefined) {\n return x;\n }\n\n // use clone function of the object when available\n if (typeof x.clone === 'function') {\n return x.clone();\n }\n\n // array\n if (Array.isArray(x)) {\n return x.map(function (value) {\n return clone(value);\n });\n }\n if (x instanceof Date) return new Date(x.valueOf());\n if (isBigNumber(x)) return x; // bignumbers are immutable\n\n // object\n if (isObject(x)) {\n return mapObject(x, clone);\n }\n if (type === 'function') {\n // we assume that the function is immutable\n return x;\n }\n throw new TypeError(\"Cannot clone: unknown type of value (value: \".concat(x, \")\"));\n}\n\n/**\n * Apply map to all properties of an object\n * @param {Object} object\n * @param {function} callback\n * @return {Object} Returns a copy of the object with mapped properties\n */\nexport function mapObject(object, callback) {\n var clone = {};\n for (var key in object) {\n if (hasOwnProperty(object, key)) {\n clone[key] = callback(object[key]);\n }\n }\n return clone;\n}\n\n/**\n * Extend object a with the properties of object b\n * @param {Object} a\n * @param {Object} b\n * @return {Object} a\n */\nexport function extend(a, b) {\n for (var prop in b) {\n if (hasOwnProperty(b, prop)) {\n a[prop] = b[prop];\n }\n }\n return a;\n}\n\n/**\n * Deep extend an object a with the properties of object b\n * @param {Object} a\n * @param {Object} b\n * @returns {Object}\n */\nexport function deepExtend(a, b) {\n // TODO: add support for Arrays to deepExtend\n if (Array.isArray(b)) {\n throw new TypeError('Arrays are not supported by deepExtend');\n }\n for (var prop in b) {\n // We check against prop not being in Object.prototype or Function.prototype\n // to prevent polluting for example Object.__proto__.\n if (hasOwnProperty(b, prop) && !(prop in Object.prototype) && !(prop in Function.prototype)) {\n if (b[prop] && b[prop].constructor === Object) {\n if (a[prop] === undefined) {\n a[prop] = {};\n }\n if (a[prop] && a[prop].constructor === Object) {\n deepExtend(a[prop], b[prop]);\n } else {\n a[prop] = b[prop];\n }\n } else if (Array.isArray(b[prop])) {\n throw new TypeError('Arrays are not supported by deepExtend');\n } else {\n a[prop] = b[prop];\n }\n }\n }\n return a;\n}\n\n/**\n * Deep test equality of all fields in two pairs of arrays or objects.\n * Compares values and functions strictly (ie. 2 is not the same as '2').\n * @param {Array | Object} a\n * @param {Array | Object} b\n * @returns {boolean}\n */\nexport function deepStrictEqual(a, b) {\n var prop, i, len;\n if (Array.isArray(a)) {\n if (!Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (i = 0, len = a.length; i < len; i++) {\n if (!deepStrictEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n } else if (typeof a === 'function') {\n return a === b;\n } else if (a instanceof Object) {\n if (Array.isArray(b) || !(b instanceof Object)) {\n return false;\n }\n for (prop in a) {\n // noinspection JSUnfilteredForInLoop\n if (!(prop in b) || !deepStrictEqual(a[prop], b[prop])) {\n return false;\n }\n }\n for (prop in b) {\n // noinspection JSUnfilteredForInLoop\n if (!(prop in a)) {\n return false;\n }\n }\n return true;\n } else {\n return a === b;\n }\n}\n\n/**\n * Recursively flatten a nested object.\n * @param {Object} nestedObject\n * @return {Object} Returns the flattened object\n */\nexport function deepFlatten(nestedObject) {\n var flattenedObject = {};\n _deepFlatten(nestedObject, flattenedObject);\n return flattenedObject;\n}\n\n// helper function used by deepFlatten\nfunction _deepFlatten(nestedObject, flattenedObject) {\n for (var prop in nestedObject) {\n if (hasOwnProperty(nestedObject, prop)) {\n var value = nestedObject[prop];\n if (typeof value === 'object' && value !== null) {\n _deepFlatten(value, flattenedObject);\n } else {\n flattenedObject[prop] = value;\n }\n }\n }\n}\n\n/**\n * Test whether the current JavaScript engine supports Object.defineProperty\n * @returns {boolean} returns true if supported\n */\nexport function canDefineProperty() {\n // test needed for broken IE8 implementation\n try {\n if (Object.defineProperty) {\n Object.defineProperty({}, 'x', {\n get: function get() {\n return null;\n }\n });\n return true;\n }\n } catch (e) {}\n return false;\n}\n\n/**\n * Attach a lazy loading property to a constant.\n * The given function `fn` is called once when the property is first requested.\n *\n * @param {Object} object Object where to add the property\n * @param {string} prop Property name\n * @param {Function} valueResolver Function returning the property value. Called\n * without arguments.\n */\nexport function lazy(object, prop, valueResolver) {\n var _uninitialized = true;\n var _value;\n Object.defineProperty(object, prop, {\n get: function get() {\n if (_uninitialized) {\n _value = valueResolver();\n _uninitialized = false;\n }\n return _value;\n },\n set: function set(value) {\n _value = value;\n _uninitialized = false;\n },\n configurable: true,\n enumerable: true\n });\n}\n\n/**\n * Traverse a path into an object.\n * When a namespace is missing, it will be created\n * @param {Object} object\n * @param {string | string[]} path A dot separated string like 'name.space'\n * @return {Object} Returns the object at the end of the path\n */\nexport function traverse(object, path) {\n if (path && typeof path === 'string') {\n return traverse(object, path.split('.'));\n }\n var obj = object;\n if (path) {\n for (var i = 0; i < path.length; i++) {\n var key = path[i];\n if (!(key in obj)) {\n obj[key] = {};\n }\n obj = obj[key];\n }\n }\n return obj;\n}\n\n/**\n * A safe hasOwnProperty\n * @param {Object} object\n * @param {string} property\n */\nexport function hasOwnProperty(object, property) {\n return object && Object.hasOwnProperty.call(object, property);\n}\n\n/**\n * Test whether an object is a factory. a factory has fields:\n *\n * - factory: function (type: Object, config: Object, load: function, typed: function [, math: Object]) (required)\n * - name: string (optional)\n * - path: string A dot separated path (optional)\n * - math: boolean If true (false by default), the math namespace is passed\n * as fifth argument of the factory function\n *\n * @param {*} object\n * @returns {boolean}\n */\nexport function isLegacyFactory(object) {\n return object && typeof object.factory === 'function';\n}\n\n/**\n * Get a nested property from an object\n * @param {Object} object\n * @param {string | string[]} path\n * @returns {Object}\n */\nexport function get(object, path) {\n if (typeof path === 'string') {\n if (isPath(path)) {\n return get(object, path.split('.'));\n } else {\n return object[path];\n }\n }\n var child = object;\n for (var i = 0; i < path.length; i++) {\n var key = path[i];\n child = child ? child[key] : undefined;\n }\n return child;\n}\n\n/**\n * Set a nested property in an object\n * Mutates the object itself\n * If the path doesn't exist, it will be created\n * @param {Object} object\n * @param {string | string[]} path\n * @param {*} value\n * @returns {Object}\n */\nexport function set(object, path, value) {\n if (typeof path === 'string') {\n if (isPath(path)) {\n return set(object, path.split('.'), value);\n } else {\n object[path] = value;\n return object;\n }\n }\n var child = object;\n for (var i = 0; i < path.length - 1; i++) {\n var key = path[i];\n if (child[key] === undefined) {\n child[key] = {};\n }\n child = child[key];\n }\n if (path.length > 0) {\n var lastKey = path[path.length - 1];\n child[lastKey] = value;\n }\n return object;\n}\n\n/**\n * Create an object composed of the picked object properties\n * @param {Object} object\n * @param {string[]} properties\n * @param {function} [transform] Optional value to transform a value when picking it\n * @return {Object}\n */\nexport function pick(object, properties, transform) {\n var copy = {};\n for (var i = 0; i < properties.length; i++) {\n var key = properties[i];\n var value = get(object, key);\n if (value !== undefined) {\n set(copy, key, transform ? transform(value, key) : value);\n }\n }\n return copy;\n}\n\n/**\n * Shallow version of pick, creating an object composed of the picked object properties\n * but not for nested properties\n * @param {Object} object\n * @param {string[]} properties\n * @return {Object}\n */\nexport function pickShallow(object, properties) {\n var copy = {};\n for (var i = 0; i < properties.length; i++) {\n var key = properties[i];\n var value = object[key];\n if (value !== undefined) {\n copy[key] = value;\n }\n }\n return copy;\n}\n\n// helper function to test whether a string contains a path like 'user.name'\nfunction isPath(str) {\n return str.includes('.');\n}","import { clone, deepExtend } from '../../utils/object.js';\nimport { DEFAULT_CONFIG } from '../config.js';\nexport var MATRIX_OPTIONS = ['Matrix', 'Array']; // valid values for option matrix\nexport var NUMBER_OPTIONS = ['number', 'BigNumber', 'bigint', 'Fraction']; // valid values for option number\n\nexport function configFactory(config, emit) {\n /**\n * Set configuration options for math.js, and get current options.\n * Will emit a 'config' event, with arguments (curr, prev, changes).\n *\n * This function is only available on a mathjs instance created using `create`.\n *\n * Syntax:\n *\n * math.config(config: Object): Object\n *\n * Examples:\n *\n * import { create, all } from 'mathjs'\n *\n * // create a mathjs instance\n * const math = create(all)\n *\n * math.config().number // outputs 'number'\n * math.evaluate('0.4') // outputs number 0.4\n * math.config({number: 'Fraction'})\n * math.evaluate('0.4') // outputs Fraction 2/5\n *\n * @param {Object} [options] Available options:\n * {number} relTol\n * Minimum relative difference between two\n * compared values, used by all comparison functions.\n * {number} absTol\n * Minimum absolute difference between two\n * compared values, used by all comparison functions.\n * {string} matrix\n * A string 'Matrix' (default) or 'Array'.\n * {string} number\n * A string 'number' (default), 'BigNumber', 'bigint', or 'Fraction'\n * {number} precision\n * The number of significant digits for BigNumbers.\n * Not applicable for Numbers.\n * {string} parenthesis\n * How to display parentheses in LaTeX and string\n * output.\n * {string} randomSeed\n * Random seed for seeded pseudo random number generator.\n * Set to null to randomly seed.\n * @return {Object} Returns the current configuration\n */\n function _config(options) {\n if (options) {\n if (options.epsilon !== undefined) {\n // this if is only for backwards compatibility, it can be removed in the future.\n console.warn('Warning: The configuration option \"epsilon\" is deprecated. Use \"relTol\" and \"absTol\" instead.');\n var optionsFix = clone(options);\n optionsFix.relTol = options.epsilon;\n optionsFix.absTol = options.epsilon * 1e-3;\n delete optionsFix.epsilon;\n return _config(optionsFix);\n }\n if (options.legacySubset === true) {\n // this if is only for backwards compatibility, it can be removed in the future.\n console.warn('Warning: The configuration option \"legacySubset\" is for compatibility only and might be deprecated in the future.');\n }\n var prev = clone(config);\n\n // validate some of the options\n validateOption(options, 'matrix', MATRIX_OPTIONS);\n validateOption(options, 'number', NUMBER_OPTIONS);\n\n // merge options\n deepExtend(config, options);\n var curr = clone(config);\n var changes = clone(options);\n\n // emit 'config' event\n emit('config', curr, prev, changes);\n return curr;\n } else {\n return clone(config);\n }\n }\n\n // attach the valid options to the function so they can be extended\n _config.MATRIX_OPTIONS = MATRIX_OPTIONS;\n _config.NUMBER_OPTIONS = NUMBER_OPTIONS;\n\n // attach the config properties as readonly properties to the config function\n Object.keys(DEFAULT_CONFIG).forEach(key => {\n Object.defineProperty(_config, key, {\n get: () => config[key],\n enumerable: true,\n configurable: true\n });\n });\n return _config;\n}\n\n/**\n * Validate an option\n * @param {Object} options Object with options\n * @param {string} name Name of the option to validate\n * @param {Array.} values Array with valid values for this option\n */\nfunction validateOption(options, name, values) {\n if (options[name] !== undefined && !values.includes(options[name])) {\n // unknown value\n console.warn('Warning: Unknown value \"' + options[name] + '\" for configuration option \"' + name + '\". ' + 'Available options: ' + values.map(value => JSON.stringify(value)).join(', ') + '.');\n }\n}","import { isBigNumber, isNumber, isObject } from './is.js';\n\n/**\n * @typedef {{sign: '+' | '-' | '', coefficients: number[], exponent: number}} SplitValue\n */\n\n/**\n * Check if a number is integer\n * @param {number | boolean} value\n * @return {boolean} isInteger\n */\nexport function isInteger(value) {\n if (typeof value === 'boolean') {\n return true;\n }\n return Number.isFinite(value) ? value === Math.round(value) : false;\n}\n\n/**\n * Ensure the number type is compatible with the provided value.\n * If not, return 'number' instead.\n *\n * For example:\n *\n * safeNumberType('2.3', { number: 'bigint', numberFallback: 'number' })\n *\n * will return 'number' and not 'bigint' because trying to create a bigint with\n * value 2.3 would throw an exception.\n *\n * @param {string} numberStr\n * @param {{\n * number: 'number' | 'BigNumber' | 'bigint' | 'Fraction'\n * numberFallback: 'number' | 'BigNumber'\n * }} config\n * @returns {'number' | 'BigNumber' | 'bigint' | 'Fraction'}\n */\nexport function safeNumberType(numberStr, config) {\n if (config.number === 'bigint') {\n try {\n BigInt(numberStr);\n } catch (_unused) {\n return config.numberFallback;\n }\n }\n return config.number;\n}\n\n/**\n * Calculate the sign of a number\n * @param {number} x\n * @returns {number}\n */\nexport var sign = Math.sign || function (x) {\n if (x > 0) {\n return 1;\n } else if (x < 0) {\n return -1;\n } else {\n return 0;\n }\n};\n\n/**\n * Calculate the base-2 logarithm of a number\n * @param {number} x\n * @returns {number}\n */\nexport var log2 = Math.log2 || function log2(x) {\n return Math.log(x) / Math.LN2;\n};\n\n/**\n * Calculate the base-10 logarithm of a number\n * @param {number} x\n * @returns {number}\n */\nexport var log10 = Math.log10 || function log10(x) {\n return Math.log(x) / Math.LN10;\n};\n\n/**\n * Calculate the natural logarithm of a number + 1\n * @param {number} x\n * @returns {number}\n */\nexport var log1p = Math.log1p || function (x) {\n return Math.log(x + 1);\n};\n\n/**\n * Calculate cubic root for a number\n *\n * Code from es6-shim.js:\n * https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1564-L1577\n *\n * @param {number} x\n * @returns {number} Returns the cubic root of x\n */\nexport var cbrt = Math.cbrt || function cbrt(x) {\n if (x === 0) {\n return x;\n }\n var negate = x < 0;\n var result;\n if (negate) {\n x = -x;\n }\n if (Number.isFinite(x)) {\n result = Math.exp(Math.log(x) / 3);\n // from https://en.wikipedia.org/wiki/Cube_root#Numerical_methods\n result = (x / (result * result) + 2 * result) / 3;\n } else {\n result = x;\n }\n return negate ? -result : result;\n};\n\n/**\n * Calculates exponentiation minus 1\n * @param {number} x\n * @return {number} res\n */\nexport var expm1 = Math.expm1 || function expm1(x) {\n return x >= 2e-4 || x <= -2e-4 ? Math.exp(x) - 1 : x + x * x / 2 + x * x * x / 6;\n};\n\n/**\n * Formats a number in a given base\n * @param {number} n\n * @param {number} base\n * @param {number} size\n * @returns {string}\n */\nfunction formatNumberToBase(n, base, size) {\n var prefixes = {\n 2: '0b',\n 8: '0o',\n 16: '0x'\n };\n var prefix = prefixes[base];\n var suffix = '';\n if (size) {\n if (size < 1) {\n throw new Error('size must be in greater than 0');\n }\n if (!isInteger(size)) {\n throw new Error('size must be an integer');\n }\n if (n > 2 ** (size - 1) - 1 || n < -(2 ** (size - 1))) {\n throw new Error(\"Value must be in range [-2^\".concat(size - 1, \", 2^\").concat(size - 1, \"-1]\"));\n }\n if (!isInteger(n)) {\n throw new Error('Value must be an integer');\n }\n if (n < 0) {\n n = n + 2 ** size;\n }\n suffix = \"i\".concat(size);\n }\n var sign = '';\n if (n < 0) {\n n = -n;\n sign = '-';\n }\n return \"\".concat(sign).concat(prefix).concat(n.toString(base)).concat(suffix);\n}\n\n/**\n * Convert a number to a formatted string representation.\n *\n * Syntax:\n *\n * format(value)\n * format(value, options)\n * format(value, precision)\n * format(value, fn)\n *\n * Where:\n *\n * {number} value The value to be formatted\n * {Object} options An object with formatting options. Available options:\n * {string} notation\n * Number notation. Choose from:\n * 'fixed' Always use regular number notation.\n * For example '123.40' and '14000000'\n * 'exponential' Always use exponential notation.\n * For example '1.234e+2' and '1.4e+7'\n * 'engineering' Always use engineering notation.\n * For example '123.4e+0' and '14.0e+6'\n * 'auto' (default) Regular number notation for numbers\n * having an absolute value between\n * `lowerExp` and `upperExp` bounds, and\n * uses exponential notation elsewhere.\n * Lower bound is included, upper bound\n * is excluded.\n * For example '123.4' and '1.4e7'.\n * 'bin', 'oct, or\n * 'hex' Format the number using binary, octal,\n * or hexadecimal notation.\n * For example '0b1101' and '0x10fe'.\n * {number} wordSize The word size in bits to use for formatting\n * in binary, octal, or hexadecimal notation.\n * To be used only with 'bin', 'oct', or 'hex'\n * values for 'notation' option. When this option\n * is defined the value is formatted as a signed\n * twos complement integer of the given word size\n * and the size suffix is appended to the output.\n * For example\n * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.\n * Default value is undefined.\n * {number} precision A number between 0 and 16 to round\n * the digits of the number.\n * In case of notations 'exponential',\n * 'engineering', and 'auto',\n * `precision` defines the total\n * number of significant digits returned.\n * In case of notation 'fixed',\n * `precision` defines the number of\n * significant digits after the decimal\n * point.\n * `precision` is undefined by default,\n * not rounding any digits.\n * {number} lowerExp Exponent determining the lower boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `-3`.\n * {number} upperExp Exponent determining the upper boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `5`.\n * {Function} fn A custom formatting function. Can be used to override the\n * built-in notations. Function `fn` is called with `value` as\n * parameter and must return a string. Is useful for example to\n * format all values inside a matrix in a particular way.\n *\n * Examples:\n *\n * format(6.4) // '6.4'\n * format(1240000) // '1.24e6'\n * format(1/3) // '0.3333333333333333'\n * format(1/3, 3) // '0.333'\n * format(21385, 2) // '21000'\n * format(12.071, {notation: 'fixed'}) // '12'\n * format(2.3, {notation: 'fixed', precision: 2}) // '2.30'\n * format(52.8, {notation: 'exponential'}) // '5.28e+1'\n * format(12345678, {notation: 'engineering'}) // '12.345678e+6'\n *\n * @param {number} value\n * @param {Object | Function | number} [options]\n * @return {string} str The formatted value\n */\nexport function format(value, options) {\n if (typeof options === 'function') {\n // handle format(value, fn)\n return options(value);\n }\n\n // handle special cases\n if (value === Infinity) {\n return 'Infinity';\n } else if (value === -Infinity) {\n return '-Infinity';\n } else if (isNaN(value)) {\n return 'NaN';\n }\n var {\n notation,\n precision,\n wordSize\n } = normalizeFormatOptions(options);\n\n // handle the various notations\n switch (notation) {\n case 'fixed':\n return toFixed(value, precision);\n case 'exponential':\n return toExponential(value, precision);\n case 'engineering':\n return toEngineering(value, precision);\n case 'bin':\n return formatNumberToBase(value, 2, wordSize);\n case 'oct':\n return formatNumberToBase(value, 8, wordSize);\n case 'hex':\n return formatNumberToBase(value, 16, wordSize);\n case 'auto':\n // remove trailing zeros after the decimal point\n return toPrecision(value, precision, options).replace(/((\\.\\d*?)(0+))($|e)/, function () {\n var digits = arguments[2];\n var e = arguments[4];\n return digits !== '.' ? digits + e : e;\n });\n default:\n throw new Error('Unknown notation \"' + notation + '\". ' + 'Choose \"auto\", \"exponential\", \"fixed\", \"bin\", \"oct\", or \"hex.');\n }\n}\n\n/**\n * Normalize format options into an object:\n * {\n * notation: string,\n * precision: number | undefined,\n * wordSize: number | undefined\n * }\n */\nexport function normalizeFormatOptions(options) {\n // default values for options\n var notation = 'auto';\n var precision;\n var wordSize;\n if (options !== undefined) {\n if (isNumber(options)) {\n precision = options;\n } else if (isBigNumber(options)) {\n precision = options.toNumber();\n } else if (isObject(options)) {\n if (options.precision !== undefined) {\n precision = _toNumberOrThrow(options.precision, () => {\n throw new Error('Option \"precision\" must be a number or BigNumber');\n });\n }\n if (options.wordSize !== undefined) {\n wordSize = _toNumberOrThrow(options.wordSize, () => {\n throw new Error('Option \"wordSize\" must be a number or BigNumber');\n });\n }\n if (options.notation) {\n notation = options.notation;\n }\n } else {\n throw new Error('Unsupported type of options, number, BigNumber, or object expected');\n }\n }\n return {\n notation,\n precision,\n wordSize\n };\n}\n\n/**\n * Split a number into sign, coefficients, and exponent\n * @param {number | string} value\n * @return {SplitValue}\n * Returns an object containing sign, coefficients, and exponent\n */\nexport function splitNumber(value) {\n // parse the input value\n var match = String(value).toLowerCase().match(/^(-?)(\\d+\\.?\\d*)(e([+-]?\\d+))?$/);\n if (!match) {\n throw new SyntaxError('Invalid number ' + value);\n }\n var sign = match[1];\n var digits = match[2];\n var exponent = parseFloat(match[4] || '0');\n var dot = digits.indexOf('.');\n exponent += dot !== -1 ? dot - 1 : digits.length - 1;\n var coefficients = digits.replace('.', '') // remove the dot (must be removed before removing leading zeros)\n .replace(/^0*/, function (zeros) {\n // remove leading zeros, add their count to the exponent\n exponent -= zeros.length;\n return '';\n }).replace(/0*$/, '') // remove trailing zeros\n .split('').map(function (d) {\n return parseInt(d);\n });\n if (coefficients.length === 0) {\n coefficients.push(0);\n exponent++;\n }\n return {\n sign,\n coefficients,\n exponent\n };\n}\n\n/**\n * Format a number in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'\n * @param {number | string} value\n * @param {number} [precision] Optional number of significant figures to return.\n */\nexport function toEngineering(value, precision) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n var split = splitNumber(value);\n var rounded = roundDigits(split, precision);\n var e = rounded.exponent;\n var c = rounded.coefficients;\n\n // find nearest lower multiple of 3 for exponent\n var newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;\n if (isNumber(precision)) {\n // add zeroes to give correct sig figs\n while (precision > c.length || e - newExp + 1 > c.length) {\n c.push(0);\n }\n } else {\n // concatenate coefficients with necessary zeros\n // add zeros if necessary (for example: 1e+8 -> 100e+6)\n var missingZeros = Math.abs(e - newExp) - (c.length - 1);\n for (var i = 0; i < missingZeros; i++) {\n c.push(0);\n }\n }\n\n // find difference in exponents\n var expDiff = Math.abs(e - newExp);\n var decimalIdx = 1;\n\n // push decimal index over by expDiff times\n while (expDiff > 0) {\n decimalIdx++;\n expDiff--;\n }\n\n // if all coefficient values are zero after the decimal point and precision is unset, don't add a decimal value.\n // otherwise concat with the rest of the coefficients\n var decimals = c.slice(decimalIdx).join('');\n var decimalVal = isNumber(precision) && decimals.length || decimals.match(/[1-9]/) ? '.' + decimals : '';\n var str = c.slice(0, decimalIdx).join('') + decimalVal + 'e' + (e >= 0 ? '+' : '') + newExp.toString();\n return rounded.sign + str;\n}\n\n/**\n * Format a number with fixed notation.\n * @param {number | string} value\n * @param {number} [precision=undefined] Optional number of decimals after the\n * decimal point. null by default.\n */\nexport function toFixed(value, precision) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n var splitValue = splitNumber(value);\n var rounded = typeof precision === 'number' ? roundDigits(splitValue, splitValue.exponent + 1 + precision) : splitValue;\n var c = rounded.coefficients;\n var p = rounded.exponent + 1; // exponent may have changed\n\n // append zeros if needed\n var pp = p + (precision || 0);\n if (c.length < pp) {\n c = c.concat(zeros(pp - c.length));\n }\n\n // prepend zeros if needed\n if (p < 0) {\n c = zeros(-p + 1).concat(c);\n p = 1;\n }\n\n // insert a dot if needed\n if (p < c.length) {\n c.splice(p, 0, p === 0 ? '0.' : '.');\n }\n return rounded.sign + c.join('');\n}\n\n/**\n * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'\n * @param {number | string} value\n * @param {number} [precision] Number of digits in formatted output.\n * If not provided, the maximum available digits\n * is used.\n */\nexport function toExponential(value, precision) {\n if (isNaN(value) || !Number.isFinite(Number(value))) {\n return String(value);\n }\n\n // round if needed, else create a clone\n var split = splitNumber(value);\n var rounded = precision ? roundDigits(split, precision) : split;\n var c = rounded.coefficients;\n var e = rounded.exponent;\n\n // append zeros if needed\n if (c.length < precision) {\n c = c.concat(zeros(precision - c.length));\n }\n\n // format as `C.CCCe+EEE` or `C.CCCe-EEE`\n var first = c.shift();\n return rounded.sign + first + (c.length > 0 ? '.' + c.join('') : '') + 'e' + (e >= 0 ? '+' : '') + e;\n}\n\n/**\n * Format a number with a certain precision\n * @param {number | string} value\n * @param {number} [precision=undefined] Optional number of digits.\n * @param {{lowerExp: number | undefined, upperExp: number | undefined}} [options]\n * By default:\n * lowerExp = -3 (incl)\n * upper = +5 (excl)\n * @return {string}\n */\nexport function toPrecision(value, precision, options) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n\n // determine lower and upper bound for exponential notation.\n var lowerExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.lowerExp, -3);\n var upperExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.upperExp, 5);\n var split = splitNumber(value);\n var rounded = precision ? roundDigits(split, precision) : split;\n if (rounded.exponent < lowerExp || rounded.exponent >= upperExp) {\n // exponential notation\n return toExponential(value, precision);\n } else {\n var c = rounded.coefficients;\n var e = rounded.exponent;\n\n // append trailing zeros\n if (c.length < precision) {\n c = c.concat(zeros(precision - c.length));\n }\n\n // append trailing zeros\n // TODO: simplify the next statement\n c = c.concat(zeros(e - c.length + 1 + (c.length < precision ? precision - c.length : 0)));\n\n // prepend zeros\n c = zeros(-e).concat(c);\n var dot = e > 0 ? e : 0;\n if (dot < c.length - 1) {\n c.splice(dot + 1, 0, '.');\n }\n return rounded.sign + c.join('');\n }\n}\n\n/**\n * Round the number of digits of a number *\n * @param {SplitValue} split A value split with .splitNumber(value)\n * @param {number} precision A positive integer\n * @return {SplitValue}\n * Returns an object containing sign, coefficients, and exponent\n * with rounded digits\n */\nexport function roundDigits(split, precision) {\n // create a clone\n var rounded = {\n sign: split.sign,\n coefficients: split.coefficients,\n exponent: split.exponent\n };\n var c = rounded.coefficients;\n\n // prepend zeros if needed\n while (precision <= 0) {\n c.unshift(0);\n rounded.exponent++;\n precision++;\n }\n if (c.length > precision) {\n var removed = c.splice(precision, c.length - precision);\n if (removed[0] >= 5) {\n var i = precision - 1;\n c[i]++;\n while (c[i] === 10) {\n c.pop();\n if (i === 0) {\n c.unshift(0);\n rounded.exponent++;\n i++;\n }\n i--;\n c[i]++;\n }\n }\n }\n return rounded;\n}\n\n/**\n * Create an array filled with zeros.\n * @param {number} length\n * @return {Array}\n */\nfunction zeros(length) {\n var arr = [];\n for (var i = 0; i < length; i++) {\n arr.push(0);\n }\n return arr;\n}\n\n/**\n * Count the number of significant digits of a number.\n *\n * For example:\n * 2.34 returns 3\n * 0.0034 returns 2\n * 120.5e+30 returns 4\n *\n * @param {number} value\n * @return {number} digits Number of significant digits\n */\nexport function digits(value) {\n return value.toExponential().replace(/e.*$/, '') // remove exponential notation\n .replace(/^0\\.?0*|\\./, '') // remove decimal point and leading zeros\n .length;\n}\n\n/**\n * Compares two floating point numbers.\n * @param {number} a - First value to compare\n * @param {number} b - Second value to compare\n * @param {number} [relTol=1e-09] - The relative tolerance, indicating the maximum allowed difference relative to the larger absolute value. Must be greater than 0.\n * @param {number} [absTol=1e-12] - The minimum absolute tolerance, useful for comparisons near zero. Must be at least 0.\n * @return {boolean} whether the two numbers are nearly equal\n *\n * @throws {Error} If `relTol` is less than or equal to 0.\n * @throws {Error} If `absTol` is less than 0.\n *\n * @example\n * nearlyEqual(1.000000001, 1.0, 1e-8); // true\n * nearlyEqual(1.000000002, 1.0, 0); // false\n * nearlyEqual(1.0, 1.009, undefined, 0.01); // true\n * nearlyEqual(0.000000001, 0.0, undefined, 1e-8); // true\n */\nexport function nearlyEqual(a, b) {\n var relTol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1e-8;\n var absTol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n if (relTol <= 0) {\n throw new Error('Relative tolerance must be greater than 0');\n }\n if (absTol < 0) {\n throw new Error('Absolute tolerance must be at least 0');\n }\n\n // NaN\n if (isNaN(a) || isNaN(b)) {\n return false;\n }\n if (!Number.isFinite(a) || !Number.isFinite(b)) {\n return a === b;\n }\n if (a === b) {\n return true;\n }\n\n // abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)\n return Math.abs(a - b) <= Math.max(relTol * Math.max(Math.abs(a), Math.abs(b)), absTol);\n}\n\n/**\n * Calculate the hyperbolic arccos of a number\n * @param {number} x\n * @return {number}\n */\nexport var acosh = Math.acosh || function (x) {\n return Math.log(Math.sqrt(x * x - 1) + x);\n};\nexport var asinh = Math.asinh || function (x) {\n return Math.log(Math.sqrt(x * x + 1) + x);\n};\n\n/**\n * Calculate the hyperbolic arctangent of a number\n * @param {number} x\n * @return {number}\n */\nexport var atanh = Math.atanh || function (x) {\n return Math.log((1 + x) / (1 - x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic cosine of a number\n * @param {number} x\n * @returns {number}\n */\nexport var cosh = Math.cosh || function (x) {\n return (Math.exp(x) + Math.exp(-x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic sine of a number\n * @param {number} x\n * @returns {number}\n */\nexport var sinh = Math.sinh || function (x) {\n return (Math.exp(x) - Math.exp(-x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic tangent of a number\n * @param {number} x\n * @returns {number}\n */\nexport var tanh = Math.tanh || function (x) {\n var e = Math.exp(2 * x);\n return (e - 1) / (e + 1);\n};\n\n/**\n * Returns a value with the magnitude of x and the sign of y.\n * @param {number} x\n * @param {number} y\n * @returns {number}\n */\nexport function copysign(x, y) {\n var signx = x > 0 ? true : x < 0 ? false : 1 / x === Infinity;\n var signy = y > 0 ? true : y < 0 ? false : 1 / y === Infinity;\n return signx ^ signy ? -x : x;\n}\nfunction _toNumberOrThrow(value, onError) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n onError();\n }\n}\nfunction _toNumberOrDefault(value, defaultValue) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n return defaultValue;\n }\n}","import { cbrt, expm1, isInteger, log10, log1p, log2, sign, toFixed } from '../../utils/number.js';\nvar n1 = 'number';\nvar n2 = 'number, number';\nexport function absNumber(a) {\n return Math.abs(a);\n}\nabsNumber.signature = n1;\nexport function addNumber(a, b) {\n return a + b;\n}\naddNumber.signature = n2;\nexport function subtractNumber(a, b) {\n return a - b;\n}\nsubtractNumber.signature = n2;\nexport function multiplyNumber(a, b) {\n return a * b;\n}\nmultiplyNumber.signature = n2;\nexport function divideNumber(a, b) {\n return a / b;\n}\ndivideNumber.signature = n2;\nexport function unaryMinusNumber(x) {\n return -x;\n}\nunaryMinusNumber.signature = n1;\nexport function unaryPlusNumber(x) {\n return x;\n}\nunaryPlusNumber.signature = n1;\nexport function cbrtNumber(x) {\n return cbrt(x);\n}\ncbrtNumber.signature = n1;\nexport function cubeNumber(x) {\n return x * x * x;\n}\ncubeNumber.signature = n1;\nexport function expNumber(x) {\n return Math.exp(x);\n}\nexpNumber.signature = n1;\nexport function expm1Number(x) {\n return expm1(x);\n}\nexpm1Number.signature = n1;\n\n/**\n * Calculate gcd for numbers\n * @param {number} a\n * @param {number} b\n * @returns {number} Returns the greatest common denominator of a and b\n */\nexport function gcdNumber(a, b) {\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function gcd must be integer numbers');\n }\n\n // https://en.wikipedia.org/wiki/Euclidean_algorithm\n var r;\n while (b !== 0) {\n r = a % b;\n a = b;\n b = r;\n }\n return a < 0 ? -a : a;\n}\ngcdNumber.signature = n2;\n\n/**\n * Calculate lcm for two numbers\n * @param {number} a\n * @param {number} b\n * @returns {number} Returns the least common multiple of a and b\n */\nexport function lcmNumber(a, b) {\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function lcm must be integer numbers');\n }\n if (a === 0 || b === 0) {\n return 0;\n }\n\n // https://en.wikipedia.org/wiki/Euclidean_algorithm\n // evaluate lcm here inline to reduce overhead\n var t;\n var prod = a * b;\n while (b !== 0) {\n t = b;\n b = a % t;\n a = t;\n }\n return Math.abs(prod / a);\n}\nlcmNumber.signature = n2;\n\n/**\n * Calculate the logarithm of a value, optionally to a given base.\n * @param {number} x\n * @param {number | null | undefined} base\n * @return {number}\n */\nexport function logNumber(x, y) {\n if (y) {\n return Math.log(x) / Math.log(y);\n }\n return Math.log(x);\n}\n\n/**\n * Calculate the 10-base logarithm of a number\n * @param {number} x\n * @return {number}\n */\nexport function log10Number(x) {\n return log10(x);\n}\nlog10Number.signature = n1;\n\n/**\n * Calculate the 2-base logarithm of a number\n * @param {number} x\n * @return {number}\n */\nexport function log2Number(x) {\n return log2(x);\n}\nlog2Number.signature = n1;\n\n/**\n * Calculate the natural logarithm of a `number+1`\n * @param {number} x\n * @returns {number}\n */\nexport function log1pNumber(x) {\n return log1p(x);\n}\nlog1pNumber.signature = n1;\n\n/**\n * Calculate the modulus of two numbers\n * @param {number} x\n * @param {number} y\n * @returns {number} res\n * @private\n */\nexport function modNumber(x, y) {\n // We don't use JavaScript's % operator here as this doesn't work\n // correctly for x < 0 and x === 0\n // see https://en.wikipedia.org/wiki/Modulo_operation\n return y === 0 ? x : x - y * Math.floor(x / y);\n}\nmodNumber.signature = n2;\n\n/**\n * Calculate the nth root of a, solve x^root == a\n * http://rosettacode.org/wiki/Nth_root#JavaScript\n * @param {number} a\n * @param {number} [2] root\n * @private\n */\nexport function nthRootNumber(a) {\n var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n var inv = root < 0;\n if (inv) {\n root = -root;\n }\n if (root === 0) {\n throw new Error('Root must be non-zero');\n }\n if (a < 0 && Math.abs(root) % 2 !== 1) {\n throw new Error('Root must be odd when a is negative.');\n }\n\n // edge cases zero and infinity\n if (a === 0) {\n return inv ? Infinity : 0;\n }\n if (!isFinite(a)) {\n return inv ? 0 : a;\n }\n var x = Math.pow(Math.abs(a), 1 / root);\n // If a < 0, we require that root is an odd integer,\n // so (-1) ^ (1/root) = -1\n x = a < 0 ? -x : x;\n return inv ? 1 / x : x;\n\n // Very nice algorithm, but fails with nthRoot(-2, 3).\n // Newton's method has some well-known problems at times:\n // https://en.wikipedia.org/wiki/Newton%27s_method#Failure_analysis\n /*\n let x = 1 // Initial guess\n let xPrev = 1\n let i = 0\n const iMax = 10000\n do {\n const delta = (a / Math.pow(x, root - 1) - x) / root\n xPrev = x\n x = x + delta\n i++\n }\n while (xPrev !== x && i < iMax)\n if (xPrev !== x) {\n throw new Error('Function nthRoot failed to converge')\n }\n return inv ? 1 / x : x\n */\n}\nexport function signNumber(x) {\n return sign(x);\n}\nsignNumber.signature = n1;\nexport function sqrtNumber(x) {\n return Math.sqrt(x);\n}\nsqrtNumber.signature = n1;\nexport function squareNumber(x) {\n return x * x;\n}\nsquareNumber.signature = n1;\n\n/**\n * Calculate xgcd for two numbers\n * @param {number} a\n * @param {number} b\n * @return {number} result\n * @private\n */\nexport function xgcdNumber(a, b) {\n // source: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm\n var t; // used to swap two variables\n var q; // quotient\n var r; // remainder\n var x = 0;\n var lastx = 1;\n var y = 1;\n var lasty = 0;\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function xgcd must be integer numbers');\n }\n while (b) {\n q = Math.floor(a / b);\n r = a - q * b;\n t = x;\n x = lastx - q * x;\n lastx = t;\n t = y;\n y = lasty - q * y;\n lasty = t;\n a = b;\n b = r;\n }\n var res;\n if (a < 0) {\n res = [-a, -lastx, -lasty];\n } else {\n res = [a, a ? lastx : 0, lasty];\n }\n return res;\n}\nxgcdNumber.signature = n2;\n\n/**\n * Calculates the power of x to y, x^y, for two numbers.\n * @param {number} x\n * @param {number} y\n * @return {number} res\n */\nexport function powNumber(x, y) {\n // x^Infinity === 0 if -1 < x < 1\n // A real number 0 is returned instead of complex(0)\n if (x * x < 1 && y === Infinity || x * x > 1 && y === -Infinity) {\n return 0;\n }\n return Math.pow(x, y);\n}\npowNumber.signature = n2;\n\n/**\n * round a number to the given number of decimals, or to zero if decimals is\n * not provided\n * @param {number} value\n * @param {number} decimals number of decimals, between 0 and 15 (0 by default)\n * @return {number} roundedValue\n */\nexport function roundNumber(value) {\n var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n if (!isInteger(decimals) || decimals < 0 || decimals > 15) {\n throw new Error('Number of decimals in function round must be an integer from 0 to 15 inclusive');\n }\n return parseFloat(toFixed(value, decimals));\n}\n\n/**\n * Calculate the norm of a number, the absolute value.\n * @param {number} x\n * @return {number}\n */\nexport function normNumber(x) {\n return Math.abs(x);\n}\nnormNumber.signature = n1;","/** @param {number} i\n * @param {number} n\n * @returns {number} product of i to n\n */\nexport function product(i, n) {\n if (n < i) {\n return 1;\n }\n if (n === i) {\n return n;\n }\n var half = n + i >> 1; // divide (n + i) by 2 and truncate to integer\n return product(i, half) * product(half + 1, n);\n}","import { isInteger } from '../../utils/number.js';\nimport { product } from '../../utils/product.js';\nexport function combinationsNumber(n, k) {\n if (!isInteger(n) || n < 0) {\n throw new TypeError('Positive integer value expected in function combinations');\n }\n if (!isInteger(k) || k < 0) {\n throw new TypeError('Positive integer value expected in function combinations');\n }\n if (k > n) {\n throw new TypeError('k must be less than or equal to n');\n }\n var nMinusk = n - k;\n var answer = 1;\n var firstnumerator = k < nMinusk ? nMinusk + 1 : k + 1;\n var nextdivisor = 2;\n var lastdivisor = k < nMinusk ? k : nMinusk;\n // balance multiplications and divisions to try to keep intermediate values\n // in exact-integer range as long as possible\n for (var nextnumerator = firstnumerator; nextnumerator <= n; ++nextnumerator) {\n answer *= nextnumerator;\n while (nextdivisor <= lastdivisor && answer % nextdivisor === 0) {\n answer /= nextdivisor;\n ++nextdivisor;\n }\n }\n // for big n, k, floating point may have caused weirdness in remainder\n if (nextdivisor <= lastdivisor) {\n answer /= product(nextdivisor, lastdivisor);\n }\n return answer;\n}\ncombinationsNumber.signature = 'number, number';","export var pi = Math.PI;\nexport var tau = 2 * Math.PI;\nexport var e = Math.E;\nexport var phi = 1.6180339887498948; // eslint-disable-line no-loss-of-precision","/* eslint-disable no-loss-of-precision */\n\nimport { isInteger } from '../../utils/number.js';\nimport { product } from '../../utils/product.js';\nexport function gammaNumber(n) {\n var x;\n if (isInteger(n)) {\n if (n <= 0) {\n return Number.isFinite(n) ? Infinity : NaN;\n }\n if (n > 171) {\n return Infinity; // Will overflow\n }\n return product(1, n - 1);\n }\n if (n < 0.5) {\n return Math.PI / (Math.sin(Math.PI * n) * gammaNumber(1 - n));\n }\n if (n >= 171.35) {\n return Infinity; // will overflow\n }\n if (n > 85.0) {\n // Extended Stirling Approx\n var twoN = n * n;\n var threeN = twoN * n;\n var fourN = threeN * n;\n var fiveN = fourN * n;\n return Math.sqrt(2 * Math.PI / n) * Math.pow(n / Math.E, n) * (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + 5246819 / (75246796800 * fiveN * n));\n }\n --n;\n x = gammaP[0];\n for (var i = 1; i < gammaP.length; ++i) {\n x += gammaP[i] / (n + i);\n }\n var t = n + gammaG + 0.5;\n return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x;\n}\ngammaNumber.signature = 'number';\n\n// TODO: comment on the variables g and p\n\nexport var gammaG = 4.7421875;\nexport var gammaP = [0.99999999999999709182, 57.156235665862923517, -59.597960355475491248, 14.136097974741747174, -0.49191381609762019978, 0.33994649984811888699e-4, 0.46523628927048575665e-4, -0.98374475304879564677e-4, 0.15808870322491248884e-3, -0.21026444172410488319e-3, 0.21743961811521264320e-3, -0.16431810653676389022e-3, 0.84418223983852743293e-4, -0.26190838401581408670e-4, 0.36899182659531622704e-5];\n\n// lgamma implementation ref: https://mrob.com/pub/ries/lanczos-gamma.html#code\n\n// log(2 * pi) / 2\nexport var lnSqrt2PI = 0.91893853320467274178;\nexport var lgammaG = 5; // Lanczos parameter \"g\"\nexport var lgammaN = 7; // Range of coefficients \"n\"\n\nexport var lgammaSeries = [1.000000000190015, 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5];\nexport function lgammaNumber(n) {\n if (n < 0) return NaN;\n if (n === 0) return Infinity;\n if (!Number.isFinite(n)) return n;\n if (n < 0.5) {\n // Use Euler's reflection formula:\n // gamma(z) = PI / (sin(PI * z) * gamma(1 - z))\n return Math.log(Math.PI / Math.sin(Math.PI * n)) - lgammaNumber(1 - n);\n }\n\n // Compute the logarithm of the Gamma function using the Lanczos method\n\n n = n - 1;\n var base = n + lgammaG + 0.5; // Base of the Lanczos exponential\n var sum = lgammaSeries[0];\n\n // We start with the terms that have the smallest coefficients and largest denominator\n for (var i = lgammaN - 1; i >= 1; i--) {\n sum += lgammaSeries[i] / (n + i);\n }\n return lnSqrt2PI + (n + 0.5) * Math.log(base) - base + Math.log(sum);\n}\nlgammaNumber.signature = 'number';","import { pickShallow } from './object.js';\n\n/**\n * Create a factory function, which can be used to inject dependencies.\n *\n * The created functions are memoized, a consecutive call of the factory\n * with the exact same inputs will return the same function instance.\n * The memoized cache is exposed on `factory.cache` and can be cleared\n * if needed.\n *\n * Example:\n *\n * const name = 'log'\n * const dependencies = ['config', 'typed', 'divideScalar', 'Complex']\n *\n * export const createLog = factory(name, dependencies, ({ typed, config, divideScalar, Complex }) => {\n * // ... create the function log here and return it\n * }\n *\n * @param {string} name Name of the function to be created\n * @param {string[]} dependencies The names of all required dependencies\n * @param {function} create Callback function called with an object with all dependencies\n * @param {Object} [meta]\n * Optional object with meta information that will be attached\n * to the created factory function as property `meta`. For explanation\n * of what meta properties can be specified and what they mean, see\n * docs/core/extension.md.\n * @returns {function}\n */\nexport function factory(name, dependencies, create, meta) {\n function assertAndCreate(scope) {\n // we only pass the requested dependencies to the factory function\n // to prevent functions to rely on dependencies that are not explicitly\n // requested.\n var deps = pickShallow(scope, dependencies.map(stripOptionalNotation));\n assertDependencies(name, dependencies, scope);\n return create(deps);\n }\n assertAndCreate.isFactory = true;\n assertAndCreate.fn = name;\n assertAndCreate.dependencies = dependencies.slice().sort();\n if (meta) {\n assertAndCreate.meta = meta;\n }\n return assertAndCreate;\n}\n\n/**\n * Sort all factories such that when loading in order, the dependencies are resolved.\n *\n * @param {Array} factories\n * @returns {Array} Returns a new array with the sorted factories.\n */\nexport function sortFactories(factories) {\n var factoriesByName = {};\n factories.forEach(factory => {\n factoriesByName[factory.fn] = factory;\n });\n function containsDependency(factory, dependency) {\n // TODO: detect circular references\n if (isFactory(factory)) {\n if (factory.dependencies.includes(dependency.fn || dependency.name)) {\n return true;\n }\n if (factory.dependencies.some(d => containsDependency(factoriesByName[d], dependency))) {\n return true;\n }\n }\n return false;\n }\n var sorted = [];\n function addFactory(factory) {\n var index = 0;\n while (index < sorted.length && !containsDependency(sorted[index], factory)) {\n index++;\n }\n sorted.splice(index, 0, factory);\n }\n\n // sort regular factory functions\n factories.filter(isFactory).forEach(addFactory);\n\n // sort legacy factory functions AFTER the regular factory functions\n factories.filter(factory => !isFactory(factory)).forEach(addFactory);\n return sorted;\n}\n\n// TODO: comment or cleanup if unused in the end\nexport function create(factories) {\n var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n sortFactories(factories).forEach(factory => factory(scope));\n return scope;\n}\n\n/**\n * Test whether an object is a factory. This is the case when it has\n * properties name, dependencies, and a function create.\n * @param {*} obj\n * @returns {boolean}\n */\nexport function isFactory(obj) {\n return typeof obj === 'function' && typeof obj.fn === 'string' && Array.isArray(obj.dependencies);\n}\n\n/**\n * Assert that all dependencies of a list with dependencies are available in the provided scope.\n *\n * Will throw an exception when there are dependencies missing.\n *\n * @param {string} name Name for the function to be created. Used to generate a useful error message\n * @param {string[]} dependencies\n * @param {Object} scope\n */\nexport function assertDependencies(name, dependencies, scope) {\n var allDefined = dependencies.filter(dependency => !isOptionalDependency(dependency)) // filter optionals\n .every(dependency => scope[dependency] !== undefined);\n if (!allDefined) {\n var missingDependencies = dependencies.filter(dependency => scope[dependency] === undefined);\n\n // TODO: create a custom error class for this, a MathjsError or something like that\n throw new Error(\"Cannot create function \\\"\".concat(name, \"\\\", \") + \"some dependencies are missing: \".concat(missingDependencies.map(d => \"\\\"\".concat(d, \"\\\"\")).join(', '), \".\"));\n }\n}\nexport function isOptionalDependency(dependency) {\n return dependency && dependency[0] === '?';\n}\nexport function stripOptionalNotation(dependency) {\n return dependency && dependency[0] === '?' ? dependency.slice(1) : dependency;\n}","export function noBignumber() {\n throw new Error('No \"bignumber\" implementation available');\n}\nexport function noFraction() {\n throw new Error('No \"fraction\" implementation available');\n}\nexport function noMatrix() {\n throw new Error('No \"matrix\" implementation available');\n}\nexport function noIndex() {\n throw new Error('No \"index\" implementation available');\n}\nexport function noSubset() {\n throw new Error('No \"matrix\" implementation available');\n}","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.typed = factory());\n})(this, (function () { 'use strict';\n\n function ok() {\n return true;\n }\n function notOk() {\n return false;\n }\n function undef() {\n return undefined;\n }\n const NOT_TYPED_FUNCTION = 'Argument is not a typed-function.';\n\n /**\n * @typedef {{\n * params: Param[],\n * fn: function,\n * test: function,\n * implementation: function\n * }} Signature\n *\n * @typedef {{\n * types: Type[],\n * hasAny: boolean,\n * hasConversion: boolean,\n * restParam: boolean\n * }} Param\n *\n * @typedef {{\n * name: string,\n * typeIndex: number,\n * test: function,\n * isAny: boolean,\n * conversion?: ConversionDef,\n * conversionIndex: number,\n * }} Type\n *\n * @typedef {{\n * from: string,\n * to: string,\n * convert: function (*) : *\n * }} ConversionDef\n *\n * @typedef {{\n * name: string,\n * test: function(*) : boolean,\n * isAny?: boolean\n * }} TypeDef\n */\n\n /**\n * @returns {() => function}\n */\n function create() {\n // data type tests\n\n /**\n * Returns true if the argument is a non-null \"plain\" object\n */\n function isPlainObject(x) {\n return typeof x === 'object' && x !== null && x.constructor === Object;\n }\n const _types = [{\n name: 'number',\n test: function (x) {\n return typeof x === 'number';\n }\n }, {\n name: 'string',\n test: function (x) {\n return typeof x === 'string';\n }\n }, {\n name: 'boolean',\n test: function (x) {\n return typeof x === 'boolean';\n }\n }, {\n name: 'Function',\n test: function (x) {\n return typeof x === 'function';\n }\n }, {\n name: 'Array',\n test: Array.isArray\n }, {\n name: 'Date',\n test: function (x) {\n return x instanceof Date;\n }\n }, {\n name: 'RegExp',\n test: function (x) {\n return x instanceof RegExp;\n }\n }, {\n name: 'Object',\n test: isPlainObject\n }, {\n name: 'null',\n test: function (x) {\n return x === null;\n }\n }, {\n name: 'undefined',\n test: function (x) {\n return x === undefined;\n }\n }];\n const anyType = {\n name: 'any',\n test: ok,\n isAny: true\n };\n\n // Data structures to track the types. As these are local variables in\n // create(), each typed universe will get its own copy, but the variables\n // will only be accessible through the (closures of the) functions supplied\n // as properties of the typed object, not directly.\n // These will be initialized in clear() below\n let typeMap; // primary store of all types\n let typeList; // Array of just type names, for the sake of ordering\n\n // And similar data structures for the type conversions:\n let nConversions = 0;\n // the actual conversions are stored on a property of the destination types\n\n // This is a temporary object, will be replaced with a function at the end\n let typed = {\n createCount: 0\n };\n\n /**\n * Takes a type name and returns the corresponding official type object\n * for that type.\n *\n * @param {string} typeName\n * @returns {TypeDef} type\n */\n function findType(typeName) {\n const type = typeMap.get(typeName);\n if (type) {\n return type;\n }\n // Remainder is error handling\n let message = 'Unknown type \"' + typeName + '\"';\n const name = typeName.toLowerCase();\n let otherName;\n for (otherName of typeList) {\n if (otherName.toLowerCase() === name) {\n message += '. Did you mean \"' + otherName + '\" ?';\n break;\n }\n }\n throw new TypeError(message);\n }\n\n /**\n * Adds an array `types` of type definitions to this typed instance.\n * Each type definition should be an object with properties:\n * 'name' - a string giving the name of the type; 'test' - function\n * returning a boolean that tests membership in the type; and optionally\n * 'isAny' - true only for the 'any' type.\n *\n * The second optional argument, `before`, gives the name of a type that\n * these types should be added before. The new types are added in the\n * order specified.\n * @param {TypeDef[]} types\n * @param {string | boolean} [beforeSpec='any'] before\n */\n function addTypes(types) {\n let beforeSpec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any';\n const beforeIndex = beforeSpec ? findType(beforeSpec).index : typeList.length;\n const newTypes = [];\n for (let i = 0; i < types.length; ++i) {\n if (!types[i] || typeof types[i].name !== 'string' || typeof types[i].test !== 'function') {\n throw new TypeError('Object with properties {name: string, test: function} expected');\n }\n const typeName = types[i].name;\n if (typeMap.has(typeName)) {\n throw new TypeError('Duplicate type name \"' + typeName + '\"');\n }\n newTypes.push(typeName);\n typeMap.set(typeName, {\n name: typeName,\n test: types[i].test,\n isAny: types[i].isAny,\n index: beforeIndex + i,\n conversionsTo: [] // Newly added type can't have any conversions to it\n });\n }\n // update the typeList\n const affectedTypes = typeList.slice(beforeIndex);\n typeList = typeList.slice(0, beforeIndex).concat(newTypes).concat(affectedTypes);\n // Fix the indices\n for (let i = beforeIndex + newTypes.length; i < typeList.length; ++i) {\n typeMap.get(typeList[i]).index = i;\n }\n }\n\n /**\n * Removes all types and conversions from this typed instance.\n * May cause previously constructed typed-functions to throw\n * strange errors when they are called with types that do not\n * match any of their signatures.\n */\n function clear() {\n typeMap = new Map();\n typeList = [];\n nConversions = 0;\n addTypes([anyType], false);\n }\n\n // initialize the types to the default list\n clear();\n addTypes(_types);\n\n /**\n * Removes all conversions, leaving the types alone.\n */\n function clearConversions() {\n let typeName;\n for (typeName of typeList) {\n typeMap.get(typeName).conversionsTo = [];\n }\n nConversions = 0;\n }\n\n /**\n * Find the type names that match a value.\n * @param {*} value\n * @return {string[]} Array of names of types for which\n * the type test matches the value.\n */\n function findTypeNames(value) {\n const matches = typeList.filter(name => {\n const type = typeMap.get(name);\n return !type.isAny && type.test(value);\n });\n if (matches.length) {\n return matches;\n }\n return ['any'];\n }\n\n /**\n * Check if an entity is a typed function created by any instance\n * @param {any} entity\n * @returns {boolean}\n */\n function isTypedFunction(entity) {\n return entity && typeof entity === 'function' && '_typedFunctionData' in entity;\n }\n\n /**\n * Find a specific signature from a (composed) typed function, for example:\n *\n * typed.findSignature(fn, ['number', 'string'])\n * typed.findSignature(fn, 'number, string')\n * typed.findSignature(fn, 'number,string', {exact: true})\n *\n * This function findSignature will by default return the best match to\n * the given signature, possibly employing type conversions.\n *\n * The (optional) third argument is a plain object giving options\n * controlling the signature search. Currently the only implemented\n * option is `exact`: if specified as true (default is false), only\n * exact matches will be returned (i.e. signatures for which `fn` was\n * directly defined). Note that a (possibly different) type matching\n * `any`, or one or more instances of TYPE matching `...TYPE` are\n * considered exact matches in this regard, as no conversions are used.\n *\n * This function returns a \"signature\" object, as does `typed.resolve()`,\n * which is a plain object with four keys: `params` (the array of parameters\n * for this signature), `fn` (the originally supplied function for this\n * signature), `test` (a generated function that determines if an argument\n * list matches this signature, and `implementation` (the function to call\n * on a matching argument list, that performs conversions if necessary and\n * then calls the originally supplied function).\n *\n * @param {Function} fn A typed-function\n * @param {string | string[]} signature\n * Signature to be found, can be an array or a comma separated string.\n * @param {object} options Controls the signature search as documented\n * @return {{ params: Param[], fn: function, test: function, implementation: function }}\n * Returns the matching signature, or throws an error when no signature\n * is found.\n */\n function findSignature(fn, signature, options) {\n if (!isTypedFunction(fn)) {\n throw new TypeError(NOT_TYPED_FUNCTION);\n }\n\n // Canonicalize input\n const exact = options && options.exact;\n const stringSignature = Array.isArray(signature) ? signature.join(',') : signature;\n const params = parseSignature(stringSignature);\n const canonicalSignature = stringifyParams(params);\n\n // First hope we get lucky and exactly match a signature\n if (!exact || canonicalSignature in fn.signatures) {\n // OK, we can check the internal signatures\n const match = fn._typedFunctionData.signatureMap.get(canonicalSignature);\n if (match) {\n return match;\n }\n }\n\n // Oh well, we did not; so we have to go back and check the parameters\n // one by one, in order to catch things like `any` and rest params.\n // Note here we can assume there is at least one parameter, because\n // the empty signature would have matched successfully above.\n const nParams = params.length;\n let remainingSignatures;\n if (exact) {\n remainingSignatures = [];\n let name;\n for (name in fn.signatures) {\n remainingSignatures.push(fn._typedFunctionData.signatureMap.get(name));\n }\n } else {\n remainingSignatures = fn._typedFunctionData.signatures;\n }\n for (let i = 0; i < nParams; ++i) {\n const want = params[i];\n const filteredSignatures = [];\n let possibility;\n for (possibility of remainingSignatures) {\n const have = getParamAtIndex(possibility.params, i);\n if (!have || want.restParam && !have.restParam) {\n continue;\n }\n if (!have.hasAny) {\n // have to check all of the wanted types are available\n const haveTypes = paramTypeSet(have);\n if (want.types.some(wtype => !haveTypes.has(wtype.name))) {\n continue;\n }\n }\n // OK, this looks good\n filteredSignatures.push(possibility);\n }\n remainingSignatures = filteredSignatures;\n if (remainingSignatures.length === 0) break;\n }\n // Return the first remaining signature that was totally matched:\n let candidate;\n for (candidate of remainingSignatures) {\n if (candidate.params.length <= nParams) {\n return candidate;\n }\n }\n throw new TypeError('Signature not found (signature: ' + (fn.name || 'unnamed') + '(' + stringifyParams(params, ', ') + '))');\n }\n\n /**\n * Find the proper function to call for a specific signature from\n * a (composed) typed function, for example:\n *\n * typed.find(fn, ['number', 'string'])\n * typed.find(fn, 'number, string')\n * typed.find(fn, 'number,string', {exact: true})\n *\n * This function find will by default return the best match to\n * the given signature, possibly employing type conversions (and returning\n * a function that will perform those conversions as needed). The\n * (optional) third argument is a plain object giving options contolling\n * the signature search. Currently only the option `exact` is implemented,\n * which defaults to \"false\". If `exact` is specified as true, then only\n * exact matches will be returned (i.e. signatures for which `fn` was\n * directly defined). Uses of `any` and `...TYPE` are considered exact if\n * no conversions are necessary to apply the corresponding function.\n *\n * @param {Function} fn A typed-function\n * @param {string | string[]} signature\n * Signature to be found, can be an array or a comma separated string.\n * @param {object} options Controls the signature match as documented\n * @return {function}\n * Returns the function to call for the given signature, or throws an\n * error if no match is found.\n */\n function find(fn, signature, options) {\n return findSignature(fn, signature, options).implementation;\n }\n\n /**\n * Convert a given value to another data type, specified by type name.\n *\n * @param {*} value\n * @param {string} typeName\n */\n function convert(value, typeName) {\n // check conversion is needed\n const type = findType(typeName);\n if (type.test(value)) {\n return value;\n }\n const conversions = type.conversionsTo;\n if (conversions.length === 0) {\n throw new Error('There are no conversions to ' + typeName + ' defined.');\n }\n for (let i = 0; i < conversions.length; i++) {\n const fromType = findType(conversions[i].from);\n if (fromType.test(value)) {\n return conversions[i].convert(value);\n }\n }\n throw new Error('Cannot convert ' + value + ' to ' + typeName);\n }\n\n /**\n * Stringify parameters in a normalized way\n * @param {Param[]} params\n * @param {string} [','] separator\n * @return {string}\n */\n function stringifyParams(params) {\n let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';\n return params.map(p => p.name).join(separator);\n }\n\n /**\n * Parse a parameter, like \"...number | boolean\"\n * @param {string} param\n * @return {Param} param\n */\n function parseParam(param) {\n const restParam = param.indexOf('...') === 0;\n const types = !restParam ? param : param.length > 3 ? param.slice(3) : 'any';\n const typeDefs = types.split('|').map(s => findType(s.trim()));\n let hasAny = false;\n let paramName = restParam ? '...' : '';\n const exactTypes = typeDefs.map(function (type) {\n hasAny = type.isAny || hasAny;\n paramName += type.name + '|';\n return {\n name: type.name,\n typeIndex: type.index,\n test: type.test,\n isAny: type.isAny,\n conversion: null,\n conversionIndex: -1\n };\n });\n return {\n types: exactTypes,\n name: paramName.slice(0, -1),\n // remove trailing '|' from above\n hasAny,\n hasConversion: false,\n restParam\n };\n }\n\n /**\n * Expands a parsed parameter with the types available from currently\n * defined conversions.\n * @param {Param} param\n * @return {Param} param\n */\n function expandParam(param) {\n const typeNames = param.types.map(t => t.name);\n const matchingConversions = availableConversions(typeNames);\n let hasAny = param.hasAny;\n let newName = param.name;\n const convertibleTypes = matchingConversions.map(function (conversion) {\n const type = findType(conversion.from);\n hasAny = type.isAny || hasAny;\n newName += '|' + conversion.from;\n return {\n name: conversion.from,\n typeIndex: type.index,\n test: type.test,\n isAny: type.isAny,\n conversion,\n conversionIndex: conversion.index\n };\n });\n return {\n types: param.types.concat(convertibleTypes),\n name: newName,\n hasAny,\n hasConversion: convertibleTypes.length > 0,\n restParam: param.restParam\n };\n }\n\n /**\n * Return the set of type names in a parameter.\n * Caches the result for efficiency\n *\n * @param {Param} param\n * @return {Set} typenames\n */\n function paramTypeSet(param) {\n if (!param.typeSet) {\n param.typeSet = new Set();\n param.types.forEach(type => param.typeSet.add(type.name));\n }\n return param.typeSet;\n }\n\n /**\n * Parse a signature with comma separated parameters,\n * like \"number | boolean, ...string\"\n *\n * @param {string} signature\n * @return {Param[]} params\n */\n function parseSignature(rawSignature) {\n const params = [];\n if (typeof rawSignature !== 'string') {\n throw new TypeError('Signatures must be strings');\n }\n const signature = rawSignature.trim();\n if (signature === '') {\n return params;\n }\n const rawParams = signature.split(',');\n for (let i = 0; i < rawParams.length; ++i) {\n const parsedParam = parseParam(rawParams[i].trim());\n if (parsedParam.restParam && i !== rawParams.length - 1) {\n throw new SyntaxError('Unexpected rest parameter \"' + rawParams[i] + '\": ' + 'only allowed for the last parameter');\n }\n // if invalid, short-circuit (all the types may have been filtered)\n if (parsedParam.types.length === 0) {\n return null;\n }\n params.push(parsedParam);\n }\n return params;\n }\n\n /**\n * Test whether a set of params contains a restParam\n * @param {Param[]} params\n * @return {boolean} Returns true when the last parameter is a restParam\n */\n function hasRestParam(params) {\n const param = last(params);\n return param ? param.restParam : false;\n }\n\n /**\n * Create a type test for a single parameter, which can have one or multiple\n * types.\n * @param {Param} param\n * @return {function(x: *) : boolean} Returns a test function\n */\n function compileTest(param) {\n if (!param || param.types.length === 0) {\n // nothing to do\n return ok;\n } else if (param.types.length === 1) {\n return findType(param.types[0].name).test;\n } else if (param.types.length === 2) {\n const test0 = findType(param.types[0].name).test;\n const test1 = findType(param.types[1].name).test;\n return function or(x) {\n return test0(x) || test1(x);\n };\n } else {\n // param.types.length > 2\n const tests = param.types.map(function (type) {\n return findType(type.name).test;\n });\n return function or(x) {\n for (let i = 0; i < tests.length; i++) {\n if (tests[i](x)) {\n return true;\n }\n }\n return false;\n };\n }\n }\n\n /**\n * Create a test for all parameters of a signature\n * @param {Param[]} params\n * @return {function(args: Array<*>) : boolean}\n */\n function compileTests(params) {\n let tests, test0, test1;\n if (hasRestParam(params)) {\n // variable arguments like '...number'\n tests = initial(params).map(compileTest);\n const varIndex = tests.length;\n const lastTest = compileTest(last(params));\n const testRestParam = function (args) {\n for (let i = varIndex; i < args.length; i++) {\n if (!lastTest(args[i])) {\n return false;\n }\n }\n return true;\n };\n return function testArgs(args) {\n for (let i = 0; i < tests.length; i++) {\n if (!tests[i](args[i])) {\n return false;\n }\n }\n return testRestParam(args) && args.length >= varIndex + 1;\n };\n } else {\n // no variable arguments\n if (params.length === 0) {\n return function testArgs(args) {\n return args.length === 0;\n };\n } else if (params.length === 1) {\n test0 = compileTest(params[0]);\n return function testArgs(args) {\n return test0(args[0]) && args.length === 1;\n };\n } else if (params.length === 2) {\n test0 = compileTest(params[0]);\n test1 = compileTest(params[1]);\n return function testArgs(args) {\n return test0(args[0]) && test1(args[1]) && args.length === 2;\n };\n } else {\n // arguments.length > 2\n tests = params.map(compileTest);\n return function testArgs(args) {\n for (let i = 0; i < tests.length; i++) {\n if (!tests[i](args[i])) {\n return false;\n }\n }\n return args.length === tests.length;\n };\n }\n }\n }\n\n /**\n * Find the parameter at a specific index of a Params list.\n * Handles rest parameters.\n * @param {Param[]} params\n * @param {number} index\n * @return {Param | null} Returns the matching parameter when found,\n * null otherwise.\n */\n function getParamAtIndex(params, index) {\n return index < params.length ? params[index] : hasRestParam(params) ? last(params) : null;\n }\n\n /**\n * Get all type names of a parameter\n * @param {Params[]} params\n * @param {number} index\n * @return {string[]} Returns an array with type names\n */\n function getTypeSetAtIndex(params, index) {\n const param = getParamAtIndex(params, index);\n if (!param) {\n return new Set();\n }\n return paramTypeSet(param);\n }\n\n /**\n * Test whether a type is an exact type or conversion\n * @param {Type} type\n * @return {boolean} Returns true when\n */\n function isExactType(type) {\n return type.conversion === null || type.conversion === undefined;\n }\n\n /**\n * Helper function for creating error messages: create an array with\n * all available types on a specific argument index.\n * @param {Signature[]} signatures\n * @param {number} index\n * @return {string[]} Returns an array with available types\n */\n function mergeExpectedParams(signatures, index) {\n const typeSet = new Set();\n signatures.forEach(signature => {\n const paramSet = getTypeSetAtIndex(signature.params, index);\n let name;\n for (name of paramSet) {\n typeSet.add(name);\n }\n });\n return typeSet.has('any') ? ['any'] : Array.from(typeSet);\n }\n\n /**\n * Create\n * @param {string} name The name of the function\n * @param {array.<*>} args The actual arguments passed to the function\n * @param {Signature[]} signatures A list with available signatures\n * @return {TypeError} Returns a type error with additional data\n * attached to it in the property `data`\n */\n function createError(name, args, signatures) {\n let err, expected;\n const _name = name || 'unnamed';\n\n // test for wrong type at some index\n let matchingSignatures = signatures;\n let index;\n for (index = 0; index < args.length; index++) {\n const nextMatchingDefs = [];\n matchingSignatures.forEach(signature => {\n const param = getParamAtIndex(signature.params, index);\n const test = compileTest(param);\n if ((index < signature.params.length || hasRestParam(signature.params)) && test(args[index])) {\n nextMatchingDefs.push(signature);\n }\n });\n if (nextMatchingDefs.length === 0) {\n // no matching signatures anymore, throw error \"wrong type\"\n expected = mergeExpectedParams(matchingSignatures, index);\n if (expected.length > 0) {\n const actualTypes = findTypeNames(args[index]);\n err = new TypeError('Unexpected type of argument in function ' + _name + ' (expected: ' + expected.join(' or ') + ', actual: ' + actualTypes.join(' | ') + ', index: ' + index + ')');\n err.data = {\n category: 'wrongType',\n fn: _name,\n index,\n actual: actualTypes,\n expected\n };\n return err;\n }\n } else {\n matchingSignatures = nextMatchingDefs;\n }\n }\n\n // test for too few arguments\n const lengths = matchingSignatures.map(function (signature) {\n return hasRestParam(signature.params) ? Infinity : signature.params.length;\n });\n if (args.length < Math.min.apply(null, lengths)) {\n expected = mergeExpectedParams(matchingSignatures, index);\n err = new TypeError('Too few arguments in function ' + _name + ' (expected: ' + expected.join(' or ') + ', index: ' + args.length + ')');\n err.data = {\n category: 'tooFewArgs',\n fn: _name,\n index: args.length,\n expected\n };\n return err;\n }\n\n // test for too many arguments\n const maxLength = Math.max.apply(null, lengths);\n if (args.length > maxLength) {\n err = new TypeError('Too many arguments in function ' + _name + ' (expected: ' + maxLength + ', actual: ' + args.length + ')');\n err.data = {\n category: 'tooManyArgs',\n fn: _name,\n index: args.length,\n expectedLength: maxLength\n };\n return err;\n }\n\n // Generic error\n const argTypes = [];\n for (let i = 0; i < args.length; ++i) {\n argTypes.push(findTypeNames(args[i]).join('|'));\n }\n err = new TypeError('Arguments of type \"' + argTypes.join(', ') + '\" do not match any of the defined signatures of function ' + _name + '.');\n err.data = {\n category: 'mismatch',\n actual: argTypes\n };\n return err;\n }\n\n /**\n * Find the lowest index of all types of a parameter\n * @param {Param} param\n * @return {number} Returns the index of the lowest type in typed.types\n */\n function getLowestTypeIndex(param) {\n let min = typeList.length + 1;\n for (let i = 0; i < param.types.length; i++) {\n min = Math.min(min, param.types[i].typeIndex);\n }\n return min;\n }\n\n /**\n * Find the lowest index of the conversion of all types of the parameter\n * having a conversion\n * @param {Param} param\n * @return {number} Returns the lowest index of the conversions of this type\n */\n function getLowestConversionIndex(param) {\n let min = nConversions + 1;\n for (let i = 0; i < param.types.length; i++) {\n if (!isExactType(param.types[i])) {\n min = Math.min(min, param.types[i].conversionIndex);\n }\n }\n return min;\n }\n\n /**\n * Compare two params. The return value is a number that is\n * negative when param1 should be considered first, positive\n * when param2 should be considered first, and zero when the\n * params are indistinguishable. Primarily as a debugging aid,\n * the value is always less than one in absolute value, and\n * a smaller absolute value indicates a less important distinction\n * between the parameters.\n * @param {Param} param1\n * @param {Param} param2\n * @return {number} negative, positive, or zero depending on whether\n * param1 should be ordered before, after, or equivalently\n * to param2\n */\n function compareParams(param1, param2) {\n // We compare a number of metrics on a param in turn:\n // 1) 'any' parameters are the least preferred\n if (param1.hasAny) {\n if (!param2.hasAny) {\n return 0.1;\n }\n } else if (param2.hasAny) {\n return -0.1;\n }\n\n // 2) Prefer non-rest to rest parameters\n if (param1.restParam) {\n if (!param2.restParam) {\n return 0.01;\n }\n } else if (param2.restParam) {\n return -0.01;\n }\n\n // 3) Prefer lower type index:\n const typeDiff = getLowestTypeIndex(param1) - getLowestTypeIndex(param2);\n if (typeDiff < 0) {\n return -1e-3;\n }\n if (typeDiff > 0) {\n return 0.001;\n }\n\n // 4) Prefer exact type match to conversions, with a strength that\n // grows with the conversion index\n const conv1 = getLowestConversionIndex(param1);\n const conv2 = getLowestConversionIndex(param2);\n if (param1.hasConversion) {\n if (!param2.hasConversion) {\n return (1 + conv1) * 0.000001;\n }\n } else if (param2.hasConversion) {\n return -(1 + conv2) * 0.000001;\n }\n\n // 5) Prefer lower conversion index\n const convDiff = conv1 - conv2;\n if (convDiff < 0) {\n return -1e-7;\n }\n if (convDiff > 0) {\n return 0.0000001;\n }\n\n // Don't have a basis for preference\n return 0;\n }\n\n /**\n * Compare two signatures. The result is a number that is negative\n * when the first signature should be preferred to the second, positive\n * when the second signature should be preferred, and zero in case the\n * two signatures are essentially equivalent. Primarily as a debugging\n * aid, a larger absolute value indicates a more \"important\" difference.\n *\n * @param {Signature} signature1\n * @param {Signature} signature2\n * @return {number} returns a negative number when signature1 must get a\n * lower index than signature2, a positive number when the\n * opposite holds, or zero when both are equivalent.\n */\n function compareSignatures(signature1, signature2) {\n const pars1 = signature1.params;\n const pars2 = signature2.params;\n const last1 = last(pars1);\n const last2 = last(pars2);\n const hasRest1 = hasRestParam(pars1);\n const hasRest2 = hasRestParam(pars2);\n // We compare a number of metrics on signatures in turn:\n // 1) An \"any rest param\" is least preferred\n if (hasRest1 && last1.hasAny) {\n if (!hasRest2 || !last2.hasAny) {\n return 10000000;\n }\n } else if (hasRest2 && last2.hasAny) {\n return -1e7;\n }\n\n // 2) Minimize the number of 'any' parameters\n let any1 = 0;\n let conv1 = 0;\n let par;\n for (par of pars1) {\n if (par.hasAny) ++any1;\n if (par.hasConversion) ++conv1;\n }\n let any2 = 0;\n let conv2 = 0;\n for (par of pars2) {\n if (par.hasAny) ++any2;\n if (par.hasConversion) ++conv2;\n }\n if (any1 !== any2) {\n return (any1 - any2) * 1000000;\n }\n\n // 3) A conversion rest param is less preferred\n if (hasRest1 && last1.hasConversion) {\n if (!hasRest2 || !last2.hasConversion) {\n return 100000;\n }\n } else if (hasRest2 && last2.hasConversion) {\n return -1e5;\n }\n\n // 4) Minimize the number of conversions\n if (conv1 !== conv2) {\n return (conv1 - conv2) * 10000;\n }\n\n // 5) Prefer no rest param\n if (hasRest1) {\n if (!hasRest2) {\n return 1000;\n }\n } else if (hasRest2) {\n return -1e3;\n }\n\n // 6) Prefer shorter with rest param, longer without\n const lengthCriterion = (pars1.length - pars2.length) * (hasRest1 ? -100 : 100);\n if (lengthCriterion !== 0) {\n return lengthCriterion;\n }\n\n // Signatures are identical in each of the above metrics.\n // In particular, they are the same length.\n // We can therefore compare the parameters one by one.\n // First we count which signature has more preferred parameters.\n const comparisons = [];\n let tc = 0;\n for (let i = 0; i < pars1.length; ++i) {\n const thisComparison = compareParams(pars1[i], pars2[i]);\n comparisons.push(thisComparison);\n tc += thisComparison;\n }\n if (tc !== 0) {\n return (tc < 0 ? -10 : 10) + tc;\n }\n\n // They have the same number of preferred parameters, so go by the\n // earliest parameter in which we have a preference.\n // In other words, dispatch is driven somewhat more by earlier\n // parameters than later ones.\n let c;\n let bonus = 9;\n const decrement = bonus / (comparisons.length + 1);\n for (c of comparisons) {\n if (c !== 0) {\n return (c < 0 ? -bonus : bonus) + c;\n }\n bonus -= decrement;\n }\n\n // It's a tossup:\n return 0;\n }\n\n /**\n * Produce a list of all conversions from distinct types to one of\n * the given types.\n *\n * @param {string[]} typeNames\n * @return {ConversionDef[]} Returns the conversions that are available\n * resulting in any given type (if any)\n */\n function availableConversions(typeNames) {\n if (typeNames.length === 0) {\n return [];\n }\n const types = typeNames.map(findType);\n if (typeNames.length === 1) return types[0].conversionsTo;\n\n // Here, for each type that occurs as the from-type of any conversion\n // to any of the types found, we must select the conversion of\n // lowest index from that type. So first collect the types.\n const knownTypes = new Set(typeNames);\n const convertibleTypes = new Set();\n for (let i = 0; i < types.length; ++i) {\n for (const match of types[i].conversionsTo) {\n if (!knownTypes.has(match.from)) convertibleTypes.add(match.from);\n }\n }\n\n // Now get the lowest-index conversion for each type\n const matches = [];\n for (const typeName of convertibleTypes) {\n let bestIndex = nConversions + 1;\n let bestConversion = null;\n for (let i = 0; i < types.length; ++i) {\n for (const match of types[i].conversionsTo) {\n if (match.from === typeName && match.index < bestIndex) {\n bestIndex = match.index;\n bestConversion = match;\n }\n }\n }\n matches.push(bestConversion);\n }\n return matches;\n }\n\n /**\n * Preprocess arguments before calling the original function:\n * - if needed convert the parameters\n * - in case of rest parameters, move the rest parameters into an Array\n * @param {Param[]} params\n * @param {function} fn\n * @return {function} Returns fn or a wrapped function if needed. If it\n * has conversions, the function will be named to indicate\n * what conversions are occurring.\n */\n function compileArgsPreprocessing(params, fn) {\n let fnConvert = fn;\n\n // TODO: can we make this wrapper function smarter/simpler?\n\n let name = '';\n if (params.some(p => p.hasConversion)) {\n const restParam = hasRestParam(params);\n const compiledConversions = params.map(compileArgConversion);\n name = compiledConversions.map(conv => conv.name).join(';');\n fnConvert = function convertArgs() {\n const args = [];\n const last = restParam ? arguments.length - 1 : arguments.length;\n for (let i = 0; i < last; i++) {\n args[i] = compiledConversions[i](arguments[i]);\n }\n if (restParam) {\n args[last] = arguments[last].map(compiledConversions[last]);\n }\n return fn.apply(this, args);\n };\n }\n let fnPreprocess = fnConvert;\n if (hasRestParam(params)) {\n const offset = params.length - 1;\n fnPreprocess = function preprocessRestParams() {\n return fnConvert.apply(this, slice(arguments, 0, offset).concat([slice(arguments, offset)]));\n };\n }\n if (name) Object.defineProperty(fnPreprocess, 'name', {\n value: name\n });\n return fnPreprocess;\n }\n\n /**\n * Compile conversion for a parameter to the right type\n * @param {Param} param\n * @return {function} Returns the wrapped function that will convert arguments\n *\n */\n function compileArgConversion(param) {\n let test0, test1, conversion0, conversion1;\n const tests = [];\n const conversions = [];\n let name = '';\n param.types.forEach(function (type) {\n if (type.conversion) {\n name += type.conversion.from + '~>' + type.conversion.to + ',';\n tests.push(findType(type.conversion.from).test);\n conversions.push(type.conversion.convert);\n }\n });\n if (name) name = name.slice(0, -1);else name = 'pass';\n\n // create optimized conversion functions depending on the number of conversions\n let convertor = arg => arg;\n switch (conversions.length) {\n case 0:\n break;\n case 1:\n test0 = tests[0];\n conversion0 = conversions[0];\n convertor = function convertArg(arg) {\n if (test0(arg)) {\n return conversion0(arg);\n }\n return arg;\n };\n break;\n case 2:\n test0 = tests[0];\n test1 = tests[1];\n conversion0 = conversions[0];\n conversion1 = conversions[1];\n convertor = function convertArg(arg) {\n if (test0(arg)) {\n return conversion0(arg);\n }\n if (test1(arg)) {\n return conversion1(arg);\n }\n return arg;\n };\n break;\n default:\n convertor = function convertArg(arg) {\n for (let i = 0; i < conversions.length; i++) {\n if (tests[i](arg)) {\n return conversions[i](arg);\n }\n }\n return arg;\n };\n }\n Object.defineProperty(convertor, 'name', {\n value: name\n });\n return convertor;\n }\n\n /**\n * Split params with union types in to separate params.\n *\n * For example:\n *\n * splitParams([['Array', 'Object'], ['string', 'RegExp'])\n * // returns:\n * // [\n * // ['Array', 'string'],\n * // ['Array', 'RegExp'],\n * // ['Object', 'string'],\n * // ['Object', 'RegExp']\n * // ]\n *\n * @param {Param[]} params\n * @return {Param[]}\n */\n function splitParams(params) {\n function _splitParams(params, index, paramsSoFar) {\n if (index < params.length) {\n const param = params[index];\n let resultingParams = [];\n if (param.restParam) {\n // split the types of a rest parameter in two:\n // one with only exact types, and one with exact types and conversions\n const exactTypes = param.types.filter(isExactType);\n if (exactTypes.length < param.types.length) {\n resultingParams.push({\n types: exactTypes,\n name: '...' + exactTypes.map(t => t.name).join('|'),\n hasAny: exactTypes.some(t => t.isAny),\n hasConversion: false,\n restParam: true\n });\n }\n resultingParams.push(param);\n } else {\n // split all the types of a regular parameter into one type per param\n resultingParams = param.types.map(function (type) {\n return {\n types: [type],\n name: type.name,\n hasAny: type.isAny,\n hasConversion: type.conversion,\n restParam: false\n };\n });\n }\n\n // recurse over the groups with types\n return flatMap(resultingParams, function (nextParam) {\n return _splitParams(params, index + 1, paramsSoFar.concat([nextParam]));\n });\n } else {\n // we've reached the end of the parameters.\n return [paramsSoFar];\n }\n }\n return _splitParams(params, 0, []);\n }\n\n /**\n * Test whether two param lists represent conflicting signatures\n * @param {Param[]} params1\n * @param {Param[]} params2\n * @return {boolean} Returns true when the signatures conflict, false otherwise.\n */\n function conflicting(params1, params2) {\n const ii = Math.max(params1.length, params2.length);\n for (let i = 0; i < ii; i++) {\n const typeSet1 = getTypeSetAtIndex(params1, i);\n const typeSet2 = getTypeSetAtIndex(params2, i);\n let overlap = false;\n let name;\n for (name of typeSet2) {\n if (typeSet1.has(name)) {\n overlap = true;\n break;\n }\n }\n if (!overlap) {\n return false;\n }\n }\n const len1 = params1.length;\n const len2 = params2.length;\n const restParam1 = hasRestParam(params1);\n const restParam2 = hasRestParam(params2);\n return restParam1 ? restParam2 ? len1 === len2 : len2 >= len1 : restParam2 ? len1 >= len2 : len1 === len2;\n }\n\n /**\n * Helper function for `resolveReferences` that returns a copy of\n * functionList wihe any prior resolutions cleared out, in case we are\n * recycling signatures from a prior typed function construction.\n *\n * @param {Array.} functionList\n * @return {Array.}\n */\n function clearResolutions(functionList) {\n return functionList.map(fn => {\n if (isReferToSelf(fn)) {\n return referToSelf(fn.referToSelf.callback);\n }\n if (isReferTo(fn)) {\n return makeReferTo(fn.referTo.references, fn.referTo.callback);\n }\n return fn;\n });\n }\n\n /**\n * Take a list of references, a list of functions functionList, and a\n * signatureMap indexing signatures into functionList, and return\n * the list of resolutions, or a false-y value if they don't all\n * resolve in a valid way (yet).\n *\n * @param {string[]} references\n * @param {Array} signatureMap\n * @return {function[] | false} resolutions\n */\n function collectResolutions(references, functionList, signatureMap) {\n const resolvedReferences = [];\n let reference;\n for (reference of references) {\n let resolution = signatureMap[reference];\n if (typeof resolution !== 'number') {\n throw new TypeError('No definition for referenced signature \"' + reference + '\"');\n }\n resolution = functionList[resolution];\n if (typeof resolution !== 'function') {\n return false;\n }\n resolvedReferences.push(resolution);\n }\n return resolvedReferences;\n }\n\n /**\n * Resolve any references in the functionList for the typed function\n * itself. The signatureMap tells which index in the functionList a\n * given signature should be mapped to (for use in resolving typed.referTo)\n * and self provides the destions of a typed.referToSelf.\n *\n * @param {Array} functionList\n * @param {Object.} signatureMap\n * @param {function} self The typed-function itself\n * @return {Array} The list of resolved functions\n */\n function resolveReferences(functionList, signatureMap, self) {\n const resolvedFunctions = clearResolutions(functionList);\n const isResolved = new Array(resolvedFunctions.length).fill(false);\n let leftUnresolved = true;\n while (leftUnresolved) {\n leftUnresolved = false;\n let nothingResolved = true;\n for (let i = 0; i < resolvedFunctions.length; ++i) {\n if (isResolved[i]) continue;\n const fn = resolvedFunctions[i];\n if (isReferToSelf(fn)) {\n resolvedFunctions[i] = fn.referToSelf.callback(self);\n // Preserve reference in case signature is reused someday:\n resolvedFunctions[i].referToSelf = fn.referToSelf;\n isResolved[i] = true;\n nothingResolved = false;\n } else if (isReferTo(fn)) {\n const resolvedReferences = collectResolutions(fn.referTo.references, resolvedFunctions, signatureMap);\n if (resolvedReferences) {\n resolvedFunctions[i] = fn.referTo.callback.apply(this, resolvedReferences);\n // Preserve reference in case signature is reused someday:\n resolvedFunctions[i].referTo = fn.referTo;\n isResolved[i] = true;\n nothingResolved = false;\n } else {\n leftUnresolved = true;\n }\n }\n }\n if (nothingResolved && leftUnresolved) {\n throw new SyntaxError('Circular reference detected in resolving typed.referTo');\n }\n }\n return resolvedFunctions;\n }\n\n /**\n * Validate whether any of the function bodies contains a self-reference\n * usage like `this(...)` or `this.signatures`. This self-referencing is\n * deprecated since typed-function v3. It has been replaced with\n * the functions typed.referTo and typed.referToSelf.\n * @param {Object.} signaturesMap\n */\n function validateDeprecatedThis(signaturesMap) {\n // TODO: remove this deprecation warning logic some day (it's introduced in v3)\n\n // match occurrences like 'this(' and 'this.signatures'\n const deprecatedThisRegex = /\\bthis(\\(|\\.signatures\\b)/;\n Object.keys(signaturesMap).forEach(signature => {\n const fn = signaturesMap[signature];\n if (deprecatedThisRegex.test(fn.toString())) {\n throw new SyntaxError('Using `this` to self-reference a function ' + 'is deprecated since typed-function@3. ' + 'Use typed.referTo and typed.referToSelf instead.');\n }\n });\n }\n\n /**\n * Create a typed function\n * @param {String} name The name for the typed function\n * @param {Object.} rawSignaturesMap\n * An object with one or\n * multiple signatures as key, and the\n * function corresponding to the\n * signature as value.\n * @return {function} Returns the created typed function.\n */\n function createTypedFunction(name, rawSignaturesMap) {\n typed.createCount++;\n if (Object.keys(rawSignaturesMap).length === 0) {\n throw new SyntaxError('No signatures provided');\n }\n if (typed.warnAgainstDeprecatedThis) {\n validateDeprecatedThis(rawSignaturesMap);\n }\n\n // Main processing loop for signatures\n const parsedParams = [];\n const originalFunctions = [];\n const signaturesMap = {};\n const preliminarySignatures = []; // may have duplicates from conversions\n let signature;\n for (signature in rawSignaturesMap) {\n // A) Protect against polluted Object prototype:\n if (!Object.prototype.hasOwnProperty.call(rawSignaturesMap, signature)) {\n continue;\n }\n // B) Parse the signature\n const params = parseSignature(signature);\n if (!params) continue;\n // C) Check for conflicts\n parsedParams.forEach(function (pp) {\n if (conflicting(pp, params)) {\n throw new TypeError('Conflicting signatures \"' + stringifyParams(pp) + '\" and \"' + stringifyParams(params) + '\".');\n }\n });\n parsedParams.push(params);\n // D) Store the provided function and add conversions\n const functionIndex = originalFunctions.length;\n originalFunctions.push(rawSignaturesMap[signature]);\n const conversionParams = params.map(expandParam);\n // E) Split the signatures and collect them up\n let sp;\n for (sp of splitParams(conversionParams)) {\n const spName = stringifyParams(sp);\n preliminarySignatures.push({\n params: sp,\n name: spName,\n fn: functionIndex\n });\n if (sp.every(p => !p.hasConversion)) {\n signaturesMap[spName] = functionIndex;\n }\n }\n }\n preliminarySignatures.sort(compareSignatures);\n\n // Note the forward reference to theTypedFn\n const resolvedFunctions = resolveReferences(originalFunctions, signaturesMap, theTypedFn);\n\n // Fill in the proper function for each signature\n let s;\n for (s in signaturesMap) {\n if (Object.prototype.hasOwnProperty.call(signaturesMap, s)) {\n signaturesMap[s] = resolvedFunctions[signaturesMap[s]];\n }\n }\n const signatures = [];\n const internalSignatureMap = new Map(); // benchmarks faster than object\n for (s of preliminarySignatures) {\n // Note it's only safe to eliminate duplicates like this\n // _after_ the signature sorting step above; otherwise we might\n // remove the wrong one.\n if (!internalSignatureMap.has(s.name)) {\n s.fn = resolvedFunctions[s.fn];\n signatures.push(s);\n internalSignatureMap.set(s.name, s);\n }\n }\n\n // we create a highly optimized checks for the first couple of signatures with max 2 arguments\n const ok0 = signatures[0] && signatures[0].params.length <= 2 && !hasRestParam(signatures[0].params);\n const ok1 = signatures[1] && signatures[1].params.length <= 2 && !hasRestParam(signatures[1].params);\n const ok2 = signatures[2] && signatures[2].params.length <= 2 && !hasRestParam(signatures[2].params);\n const ok3 = signatures[3] && signatures[3].params.length <= 2 && !hasRestParam(signatures[3].params);\n const ok4 = signatures[4] && signatures[4].params.length <= 2 && !hasRestParam(signatures[4].params);\n const ok5 = signatures[5] && signatures[5].params.length <= 2 && !hasRestParam(signatures[5].params);\n const allOk = ok0 && ok1 && ok2 && ok3 && ok4 && ok5;\n\n // compile the tests\n for (let i = 0; i < signatures.length; ++i) {\n signatures[i].test = compileTests(signatures[i].params);\n }\n const test00 = ok0 ? compileTest(signatures[0].params[0]) : notOk;\n const test10 = ok1 ? compileTest(signatures[1].params[0]) : notOk;\n const test20 = ok2 ? compileTest(signatures[2].params[0]) : notOk;\n const test30 = ok3 ? compileTest(signatures[3].params[0]) : notOk;\n const test40 = ok4 ? compileTest(signatures[4].params[0]) : notOk;\n const test50 = ok5 ? compileTest(signatures[5].params[0]) : notOk;\n const test01 = ok0 ? compileTest(signatures[0].params[1]) : notOk;\n const test11 = ok1 ? compileTest(signatures[1].params[1]) : notOk;\n const test21 = ok2 ? compileTest(signatures[2].params[1]) : notOk;\n const test31 = ok3 ? compileTest(signatures[3].params[1]) : notOk;\n const test41 = ok4 ? compileTest(signatures[4].params[1]) : notOk;\n const test51 = ok5 ? compileTest(signatures[5].params[1]) : notOk;\n\n // compile the functions\n for (let i = 0; i < signatures.length; ++i) {\n signatures[i].implementation = compileArgsPreprocessing(signatures[i].params, signatures[i].fn);\n }\n const fn0 = ok0 ? signatures[0].implementation : undef;\n const fn1 = ok1 ? signatures[1].implementation : undef;\n const fn2 = ok2 ? signatures[2].implementation : undef;\n const fn3 = ok3 ? signatures[3].implementation : undef;\n const fn4 = ok4 ? signatures[4].implementation : undef;\n const fn5 = ok5 ? signatures[5].implementation : undef;\n const len0 = ok0 ? signatures[0].params.length : -1;\n const len1 = ok1 ? signatures[1].params.length : -1;\n const len2 = ok2 ? signatures[2].params.length : -1;\n const len3 = ok3 ? signatures[3].params.length : -1;\n const len4 = ok4 ? signatures[4].params.length : -1;\n const len5 = ok5 ? signatures[5].params.length : -1;\n\n // simple and generic, but also slow\n const iStart = allOk ? 6 : 0;\n const iEnd = signatures.length;\n // de-reference ahead for execution speed:\n const tests = signatures.map(s => s.test);\n const fns = signatures.map(s => s.implementation);\n const generic = function generic() {\n\n for (let i = iStart; i < iEnd; i++) {\n if (tests[i](arguments)) {\n return fns[i].apply(this, arguments);\n }\n }\n return typed.onMismatch(name, arguments, signatures);\n };\n\n // create the typed function\n // fast, specialized version. Falls back to the slower, generic one if needed\n function theTypedFn(arg0, arg1) {\n\n if (arguments.length === len0 && test00(arg0) && test01(arg1)) {\n return fn0.apply(this, arguments);\n }\n if (arguments.length === len1 && test10(arg0) && test11(arg1)) {\n return fn1.apply(this, arguments);\n }\n if (arguments.length === len2 && test20(arg0) && test21(arg1)) {\n return fn2.apply(this, arguments);\n }\n if (arguments.length === len3 && test30(arg0) && test31(arg1)) {\n return fn3.apply(this, arguments);\n }\n if (arguments.length === len4 && test40(arg0) && test41(arg1)) {\n return fn4.apply(this, arguments);\n }\n if (arguments.length === len5 && test50(arg0) && test51(arg1)) {\n return fn5.apply(this, arguments);\n }\n return generic.apply(this, arguments);\n }\n\n // attach name the typed function\n try {\n Object.defineProperty(theTypedFn, 'name', {\n value: name\n });\n } catch (err) {\n // old browsers do not support Object.defineProperty and some don't support setting the name property\n // the function name is not essential for the functioning, it's mostly useful for debugging,\n // so it's fine to have unnamed functions.\n }\n\n // attach signatures to the function.\n // This property is close to the original collection of signatures\n // used to create the typed-function, just with unions split:\n theTypedFn.signatures = signaturesMap;\n\n // Store internal data for functions like resolve, find, etc.\n // Also serves as the flag that this is a typed-function\n theTypedFn._typedFunctionData = {\n signatures,\n signatureMap: internalSignatureMap\n };\n return theTypedFn;\n }\n\n /**\n * Action to take on mismatch\n * @param {string} name Name of function that was attempted to be called\n * @param {Array} args Actual arguments to the call\n * @param {Array} signatures Known signatures of the named typed-function\n */\n function _onMismatch(name, args, signatures) {\n throw createError(name, args, signatures);\n }\n\n /**\n * Return all but the last items of an array or function Arguments\n * @param {Array | Arguments} arr\n * @return {Array}\n */\n function initial(arr) {\n return slice(arr, 0, arr.length - 1);\n }\n\n /**\n * return the last item of an array or function Arguments\n * @param {Array | Arguments} arr\n * @return {*}\n */\n function last(arr) {\n return arr[arr.length - 1];\n }\n\n /**\n * Slice an array or function Arguments\n * @param {Array | Arguments | IArguments} arr\n * @param {number} start\n * @param {number} [end]\n * @return {Array}\n */\n function slice(arr, start, end) {\n return Array.prototype.slice.call(arr, start, end);\n }\n\n /**\n * Return the first item from an array for which test(arr[i]) returns true\n * @param {Array} arr\n * @param {function} test\n * @return {* | undefined} Returns the first matching item\n * or undefined when there is no match\n */\n function findInArray(arr, test) {\n for (let i = 0; i < arr.length; i++) {\n if (test(arr[i])) {\n return arr[i];\n }\n }\n return undefined;\n }\n\n /**\n * Flat map the result invoking a callback for every item in an array.\n * https://gist.github.com/samgiles/762ee337dff48623e729\n * @param {Array} arr\n * @param {function} callback\n * @return {Array}\n */\n function flatMap(arr, callback) {\n return Array.prototype.concat.apply([], arr.map(callback));\n }\n\n /**\n * Create a reference callback to one or multiple signatures\n *\n * Syntax:\n *\n * typed.referTo(signature1, signature2, ..., function callback(fn1, fn2, ...) {\n * // ...\n * })\n *\n * @returns {{referTo: {references: string[], callback}}}\n */\n function referTo() {\n const references = initial(arguments).map(s => stringifyParams(parseSignature(s)));\n const callback = last(arguments);\n if (typeof callback !== 'function') {\n throw new TypeError('Callback function expected as last argument');\n }\n return makeReferTo(references, callback);\n }\n function makeReferTo(references, callback) {\n return {\n referTo: {\n references,\n callback\n }\n };\n }\n\n /**\n * Create a reference callback to the typed-function itself\n *\n * @param {(self: function) => function} callback\n * @returns {{referToSelf: { callback: function }}}\n */\n function referToSelf(callback) {\n if (typeof callback !== 'function') {\n throw new TypeError('Callback function expected as first argument');\n }\n return {\n referToSelf: {\n callback\n }\n };\n }\n\n /**\n * Test whether something is a referTo object, holding a list with reference\n * signatures and a callback.\n *\n * @param {Object | function} objectOrFn\n * @returns {boolean}\n */\n function isReferTo(objectOrFn) {\n return objectOrFn && typeof objectOrFn.referTo === 'object' && Array.isArray(objectOrFn.referTo.references) && typeof objectOrFn.referTo.callback === 'function';\n }\n\n /**\n * Test whether something is a referToSelf object, holding a callback where\n * to pass `self`.\n *\n * @param {Object | function} objectOrFn\n * @returns {boolean}\n */\n function isReferToSelf(objectOrFn) {\n return objectOrFn && typeof objectOrFn.referToSelf === 'object' && typeof objectOrFn.referToSelf.callback === 'function';\n }\n\n /**\n * Check if name is (A) new, (B) a match, or (C) a mismatch; and throw\n * an error in case (C).\n *\n * @param { string | undefined } nameSoFar\n * @param { string | undefined } newName\n * @returns { string } updated name\n */\n function checkName(nameSoFar, newName) {\n if (!nameSoFar) {\n return newName;\n }\n if (newName && newName !== nameSoFar) {\n const err = new Error('Function names do not match (expected: ' + nameSoFar + ', actual: ' + newName + ')');\n err.data = {\n actual: newName,\n expected: nameSoFar\n };\n throw err;\n }\n return nameSoFar;\n }\n\n /**\n * Retrieve the implied name from an object with signature keys\n * and function values, checking whether all value names match\n *\n * @param { {string: function} } obj\n */\n function getObjectName(obj) {\n let name;\n for (const key in obj) {\n // Only pay attention to own properties, and only if their values\n // are typed functions or functions with a signature property\n if (Object.prototype.hasOwnProperty.call(obj, key) && (isTypedFunction(obj[key]) || typeof obj[key].signature === 'string')) {\n name = checkName(name, obj[key].name);\n }\n }\n return name;\n }\n\n /**\n * Copy all of the signatures from the second argument into the first,\n * which is modified by side effect, checking for conflicts\n *\n * @param {Object.} dest\n * @param {Object.} source\n */\n function mergeSignatures(dest, source) {\n let key;\n for (key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n if (key in dest) {\n if (source[key] !== dest[key]) {\n const err = new Error('Signature \"' + key + '\" is defined twice');\n err.data = {\n signature: key,\n sourceFunction: source[key],\n destFunction: dest[key]\n };\n throw err;\n }\n // else: both signatures point to the same function, that's fine\n }\n dest[key] = source[key];\n }\n }\n }\n const saveTyped = typed;\n\n /**\n * Originally the main function was a typed function itself, but then\n * it might not be able to generate error messages if the client\n * replaced the type system with different names.\n *\n * Main entry: typed([name], functions/objects with signatures...)\n *\n * Assembles and returns a new typed-function from the given items\n * that provide signatures and implementations, each of which may be\n * * a plain object mapping (string) signatures to implementing functions,\n * * a previously constructed typed function, or\n * * any other single function with a string-valued property `signature`.\n * The name of the resulting typed-function will be given by the\n * string-valued name argument if present, or if not, by the name\n * of any of the arguments that have one, as long as any that do are\n * consistent with each other. If no name is specified, the name will be\n * an empty string.\n *\n * @param {string} maybeName [optional]\n * @param {(function|object)[]} signature providers\n * @returns {typed-function}\n */\n typed = function (maybeName) {\n const named = typeof maybeName === 'string';\n const start = named ? 1 : 0;\n let name = named ? maybeName : '';\n const allSignatures = {};\n for (let i = start; i < arguments.length; ++i) {\n const item = arguments[i];\n let theseSignatures = {};\n let thisName;\n if (typeof item === 'function') {\n thisName = item.name;\n if (typeof item.signature === 'string') {\n // Case 1: Ordinary function with a string 'signature' property\n theseSignatures[item.signature] = item;\n } else if (isTypedFunction(item)) {\n // Case 2: Existing typed function\n theseSignatures = item.signatures;\n }\n } else if (isPlainObject(item)) {\n // Case 3: Plain object, assume keys = signatures, values = functions\n theseSignatures = item;\n if (!named) {\n thisName = getObjectName(item);\n }\n }\n if (Object.keys(theseSignatures).length === 0) {\n const err = new TypeError('Argument to \\'typed\\' at index ' + i + ' is not a (typed) function, ' + 'nor an object with signatures as keys and functions as values.');\n err.data = {\n index: i,\n argument: item\n };\n throw err;\n }\n if (!named) {\n name = checkName(name, thisName);\n }\n mergeSignatures(allSignatures, theseSignatures);\n }\n return createTypedFunction(name || '', allSignatures);\n };\n typed.create = create;\n typed.createCount = saveTyped.createCount;\n typed.onMismatch = _onMismatch;\n typed.throwMismatchError = _onMismatch;\n typed.createError = createError;\n typed.clear = clear;\n typed.clearConversions = clearConversions;\n typed.addTypes = addTypes;\n typed._findType = findType; // For unit testing only\n typed.referTo = referTo;\n typed.referToSelf = referToSelf;\n typed.convert = convert;\n typed.findSignature = findSignature;\n typed.find = find;\n typed.isTypedFunction = isTypedFunction;\n typed.warnAgainstDeprecatedThis = true;\n\n /**\n * add a type (convenience wrapper for typed.addTypes)\n * @param {{name: string, test: function}} type\n * @param {boolean} [beforeObjectTest=true]\n * If true, the new test will be inserted before\n * the test with name 'Object' (if any), since\n * tests for Object match Array and classes too.\n */\n typed.addType = function (type, beforeObjectTest) {\n let before = 'any';\n if (beforeObjectTest !== false && typeMap.has('Object')) {\n before = 'Object';\n }\n typed.addTypes([type], before);\n };\n\n /**\n * Verify that the ConversionDef conversion has a valid format.\n *\n * @param {conversionDef} conversion\n * @return {void}\n * @throws {TypeError|SyntaxError}\n */\n function _validateConversion(conversion) {\n if (!conversion || typeof conversion.from !== 'string' || typeof conversion.to !== 'string' || typeof conversion.convert !== 'function') {\n throw new TypeError('Object with properties {from: string, to: string, convert: function} expected');\n }\n if (conversion.to === conversion.from) {\n throw new SyntaxError('Illegal to define conversion from \"' + conversion.from + '\" to itself.');\n }\n }\n\n /**\n * Add a conversion\n *\n * @param {ConversionDef} conversion\n * @param {{override: boolean}} [options]\n * @returns {void}\n * @throws {TypeError}\n */\n typed.addConversion = function (conversion) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n override: false\n };\n _validateConversion(conversion);\n const to = findType(conversion.to);\n const existing = to.conversionsTo.find(other => other.from === conversion.from);\n if (existing) {\n if (options && options.override) {\n typed.removeConversion({\n from: existing.from,\n to: conversion.to,\n convert: existing.convert\n });\n } else {\n throw new Error('There is already a conversion from \"' + conversion.from + '\" to \"' + to.name + '\"');\n }\n }\n to.conversionsTo.push({\n from: conversion.from,\n to: to.name,\n convert: conversion.convert,\n index: nConversions++\n });\n };\n\n /**\n * Convenience wrapper to call addConversion on each conversion in a list.\n *\n * @param {ConversionDef[]} conversions\n * @param {{override: boolean}} [options]\n * @returns {void}\n * @throws {TypeError}\n */\n typed.addConversions = function (conversions, options) {\n conversions.forEach(conversion => typed.addConversion(conversion, options));\n };\n\n /**\n * Remove the specified conversion. The format is the same as for\n * addConversion, and the convert function must match or an error\n * is thrown.\n *\n * @param {{from: string, to: string, convert: function}} conversion\n * @returns {void}\n * @throws {TypeError|SyntaxError|Error}\n */\n typed.removeConversion = function (conversion) {\n _validateConversion(conversion);\n const to = findType(conversion.to);\n const existingConversion = findInArray(to.conversionsTo, c => c.from === conversion.from);\n if (!existingConversion) {\n throw new Error('Attempt to remove nonexistent conversion from ' + conversion.from + ' to ' + conversion.to);\n }\n if (existingConversion.convert !== conversion.convert) {\n throw new Error('Conversion to remove does not match existing conversion');\n }\n const index = to.conversionsTo.indexOf(existingConversion);\n to.conversionsTo.splice(index, 1);\n };\n\n /**\n * Produce the specific signature that a typed function\n * will execute on the given arguments. Here, a \"signature\" is an\n * object with properties 'params', 'test', 'fn', and 'implementation'.\n * This last property is a function that converts params as necessary\n * and then calls 'fn'. Returns null if there is no matching signature.\n * @param {typed-function} tf\n * @param {any[]} argList\n * @returns {{params: string, test: function, fn: function, implementation: function}}\n */\n typed.resolve = function (tf, argList) {\n if (!isTypedFunction(tf)) {\n throw new TypeError(NOT_TYPED_FUNCTION);\n }\n const sigs = tf._typedFunctionData.signatures;\n for (let i = 0; i < sigs.length; ++i) {\n if (sigs[i].test(argList)) {\n return sigs[i];\n }\n }\n return null;\n };\n return typed;\n }\n var typedFunction = create();\n\n return typedFunction;\n\n}));\n//# sourceMappingURL=typed-function.js.map\n","/**\n * Create a typed-function which checks the types of the arguments and\n * can match them against multiple provided signatures. The typed-function\n * automatically converts inputs in order to find a matching signature.\n * Typed functions throw informative errors in case of wrong input arguments.\n *\n * See the library [typed-function](https://github.com/josdejong/typed-function)\n * for detailed documentation.\n *\n * Syntax:\n *\n * math.typed(name, signatures) : function\n * math.typed(signatures) : function\n *\n * Examples:\n *\n * // create a typed function with multiple types per argument (type union)\n * const fn2 = typed({\n * 'number | boolean': function (b) {\n * return 'b is a number or boolean'\n * },\n * 'string, number | boolean': function (a, b) {\n * return 'a is a string, b is a number or boolean'\n * }\n * })\n *\n * // create a typed function with an any type argument\n * const log = typed({\n * 'string, any': function (event, data) {\n * console.log('event: ' + event + ', data: ' + JSON.stringify(data))\n * }\n * })\n *\n * @param {string} [name] Optional name for the typed-function\n * @param {Object} signatures Object with one or multiple function signatures\n * @returns {function} The created typed-function.\n */\n\nimport typedFunction from 'typed-function';\nimport { factory } from '../../utils/factory.js';\nimport { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigInt, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMap, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isRelationalNode, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';\nimport { digits } from '../../utils/number.js';\n\n// returns a new instance of typed-function\nvar _createTyped2 = function _createTyped() {\n // initially, return the original instance of typed-function\n // consecutively, return a new instance from typed.create.\n _createTyped2 = typedFunction.create;\n return typedFunction;\n};\nvar dependencies = ['?BigNumber', '?Complex', '?DenseMatrix', '?Fraction'];\n\n/**\n * Factory function for creating a new typed instance\n * @param {Object} dependencies Object with data types like Complex and BigNumber\n * @returns {Function}\n */\nexport var createTyped = /* #__PURE__ */factory('typed', dependencies, function createTyped(_ref) {\n var {\n BigNumber,\n Complex,\n DenseMatrix,\n Fraction\n } = _ref;\n // TODO: typed-function must be able to silently ignore signatures with unknown data types\n\n // get a new instance of typed-function\n var typed = _createTyped2();\n\n // define all types. The order of the types determines in which order function\n // arguments are type-checked (so for performance it's important to put the\n // most used types first).\n typed.clear();\n typed.addTypes([{\n name: 'number',\n test: isNumber\n }, {\n name: 'Complex',\n test: isComplex\n }, {\n name: 'BigNumber',\n test: isBigNumber\n }, {\n name: 'bigint',\n test: isBigInt\n }, {\n name: 'Fraction',\n test: isFraction\n }, {\n name: 'Unit',\n test: isUnit\n },\n // The following type matches a valid variable name, i.e., an alphanumeric\n // string starting with an alphabetic character. It is used (at least)\n // in the definition of the derivative() function, as the argument telling\n // what to differentiate over must (currently) be a variable.\n // TODO: deprecate the identifier type (it's not used anymore, see https://github.com/josdejong/mathjs/issues/3253)\n {\n name: 'identifier',\n test: s => isString && /^(?:[A-Za-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-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E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-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uDF05-\\uDF0C\\uDF0F\\uDF10\\uDF13-\\uDF28\\uDF2A-\\uDF30\\uDF32\\uDF33\\uDF35-\\uDF39\\uDF3D\\uDF50\\uDF5D-\\uDF61\\uDF80-\\uDF89\\uDF8B\\uDF8E\\uDF90-\\uDFB5\\uDFB7\\uDFD1\\uDFD3]|\\uD805[\\uDC00-\\uDC34\\uDC47-\\uDC4A\\uDC5F-\\uDC61\\uDC80-\\uDCAF\\uDCC4\\uDCC5\\uDCC7\\uDD80-\\uDDAE\\uDDD8-\\uDDDB\\uDE00-\\uDE2F\\uDE44\\uDE80-\\uDEAA\\uDEB8\\uDF00-\\uDF1A\\uDF40-\\uDF46]|\\uD806[\\uDC00-\\uDC2B\\uDCA0-\\uDCDF\\uDCFF-\\uDD06\\uDD09\\uDD0C-\\uDD13\\uDD15\\uDD16\\uDD18-\\uDD2F\\uDD3F\\uDD41\\uDDA0-\\uDDA7\\uDDAA-\\uDDD0\\uDDE1\\uDDE3\\uDE00\\uDE0B-\\uDE32\\uDE3A\\uDE50\\uDE5C-\\uDE89\\uDE9D\\uDEB0-\\uDEF8\\uDFC0-\\uDFE0]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDDB0-\\uDDDB\\uDEE0-\\uDEF2\\uDF02\\uDF04-\\uDF10\\uDF12-\\uDF33\\uDFB0]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC80-\\uDD43]|\\uD80B[\\uDF90-\\uDFF0]|[\\uD80C\\uD80E\\uD80F\\uD81C-\\uD822\\uD840-\\uD868\\uD86A-\\uD86D\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883\\uD885-\\uD88C][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2F\\uDC41-\\uDC46\\uDC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u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C\\u0C5D\\u0C60\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\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\\uDFC0-\\uDFE0]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDDB0-\\uDDDB\\uDEE0-\\uDEF2\\uDF02\\uDF04-\\uDF10\\uDF12-\\uDF33\\uDFB0]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC80-\\uDD43]|\\uD80B[\\uDF90-\\uDFF0]|[\\uD80C\\uD80E\\uD80F\\uD81C-\\uD822\\uD840-\\uD868\\uD86A-\\uD86D\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883\\uD885-\\uD88C][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2F\\uDC41-\\uDC46\\uDC60-\\uDFFF]|\\uD810[\\uDC00-\\uDFFA]|\\uD811[\\uDC00-\\uDE46]|\\uD818[\\uDD00-\\uDD1D]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDE70-\\uDEBE\\uDED0-\\uDEED\\uDF00-\\uDF2F\\uDF40-\\uDF43\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDD40-\\uDD6C\\uDE40-\\uDE7F\\uDEA0-\\uDEB8\\uDEBB-\\uDED3\\uDF00-\\uDF4A\\uDF50\\uDF93-\\uDF9F\\uDFE0\\uDFE1\\uDFE3\\uDFF2\\uDFF3]|\\uD823[\\uDC00-\\uDCD5\\uDCFF-\\uDD1E\\uDD80-\\uDDF2]|\\uD82B[\\uDFF0-\\uDFF3\\uDFF5-\\uDFFB\\uDFFD\\uDFFE]|\\uD82C[\\uDC00-\\uDD22\\uDD32\\uDD50-\\uDD52\\uDD55\\uDD64-\\uDD67\\uDD70-\\uDEFB]|\\uD82F[\\uDC00-\\uDC6A\\uDC70-\\uDC7C\\uDC80-\\uDC88\\uDC90-\\uDC99]|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E7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDEDF\\uDF00-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEAD\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0\\uDFF0-\\uDFFF]|\\uD87B[\\uDC00-\\uDE5D]|\\uD87E[\\uDC00-\\uDE1D]|\\uD884[\\uDC00-\\uDF4A\\uDF50-\\uDFFF]|\\uD88D[\\uDC00-\\uDC79])*$/.test(s)\n }, {\n name: 'string',\n test: isString\n }, {\n name: 'Chain',\n test: isChain\n }, {\n name: 'Array',\n test: isArray\n }, {\n name: 'Matrix',\n test: isMatrix\n }, {\n name: 'DenseMatrix',\n test: isDenseMatrix\n }, {\n name: 'SparseMatrix',\n test: isSparseMatrix\n }, {\n name: 'Range',\n test: isRange\n }, {\n name: 'Index',\n test: isIndex\n }, {\n name: 'boolean',\n test: isBoolean\n }, {\n name: 'ResultSet',\n test: isResultSet\n }, {\n name: 'Help',\n test: isHelp\n }, {\n name: 'function',\n test: isFunction\n }, {\n name: 'Date',\n test: isDate\n }, {\n name: 'RegExp',\n test: isRegExp\n }, {\n name: 'null',\n test: isNull\n }, {\n name: 'undefined',\n test: isUndefined\n }, {\n name: 'AccessorNode',\n test: isAccessorNode\n }, {\n name: 'ArrayNode',\n test: isArrayNode\n }, {\n name: 'AssignmentNode',\n test: isAssignmentNode\n }, {\n name: 'BlockNode',\n test: isBlockNode\n }, {\n name: 'ConditionalNode',\n test: isConditionalNode\n }, {\n name: 'ConstantNode',\n test: isConstantNode\n }, {\n name: 'FunctionNode',\n test: isFunctionNode\n }, {\n name: 'FunctionAssignmentNode',\n test: isFunctionAssignmentNode\n }, {\n name: 'IndexNode',\n test: isIndexNode\n }, {\n name: 'Node',\n test: isNode\n }, {\n name: 'ObjectNode',\n test: isObjectNode\n }, {\n name: 'OperatorNode',\n test: isOperatorNode\n }, {\n name: 'ParenthesisNode',\n test: isParenthesisNode\n }, {\n name: 'RangeNode',\n test: isRangeNode\n }, {\n name: 'RelationalNode',\n test: isRelationalNode\n }, {\n name: 'SymbolNode',\n test: isSymbolNode\n }, {\n name: 'Map',\n test: isMap\n }, {\n name: 'Object',\n test: isObject\n } // order 'Object' last, it matches on other classes too\n ]);\n typed.addConversions([{\n from: 'number',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n\n // note: conversion from number to BigNumber can fail if x has >15 digits\n if (digits(x) > 15) {\n throw new TypeError('Cannot implicitly convert a number with >15 significant digits to BigNumber ' + '(value: ' + x + '). ' + 'Use function bignumber(x) to convert to BigNumber.');\n }\n return new BigNumber(x);\n }\n }, {\n from: 'number',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x, 0);\n }\n }, {\n from: 'BigNumber',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x.toNumber(), 0);\n }\n }, {\n from: 'bigint',\n to: 'number',\n convert: function convert(x) {\n if (x > Number.MAX_SAFE_INTEGER) {\n throw new TypeError('Cannot implicitly convert bigint to number: ' + 'value exceeds the max safe integer value (value: ' + x + ')');\n }\n return Number(x);\n }\n }, {\n from: 'bigint',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n return new BigNumber(x.toString());\n }\n }, {\n from: 'bigint',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n return new Fraction(x);\n }\n }, {\n from: 'Fraction',\n to: 'BigNumber',\n convert: function convert(x) {\n throw new TypeError('Cannot implicitly convert a Fraction to BigNumber or vice versa. ' + 'Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.');\n }\n }, {\n from: 'Fraction',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x.valueOf(), 0);\n }\n }, {\n from: 'number',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n var f = new Fraction(x);\n if (f.valueOf() !== x) {\n throw new TypeError('Cannot implicitly convert a number to a Fraction when there will be a loss of precision ' + '(value: ' + x + '). ' + 'Use function fraction(x) to convert to Fraction.');\n }\n return f;\n }\n }, {\n // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))`\n // from: 'Fraction',\n // to: 'number',\n // convert: function (x) {\n // return x.valueOf()\n // }\n // }, {\n from: 'string',\n to: 'number',\n convert: function convert(x) {\n var n = Number(x);\n if (isNaN(n)) {\n throw new Error('Cannot convert \"' + x + '\" to a number');\n }\n return n;\n }\n }, {\n from: 'string',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n try {\n return new BigNumber(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to BigNumber');\n }\n }\n }, {\n from: 'string',\n to: 'bigint',\n convert: function convert(x) {\n try {\n return BigInt(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to BigInt');\n }\n }\n }, {\n from: 'string',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n try {\n return new Fraction(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to Fraction');\n }\n }\n }, {\n from: 'string',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n try {\n return new Complex(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to Complex');\n }\n }\n }, {\n from: 'boolean',\n to: 'number',\n convert: function convert(x) {\n return +x;\n }\n }, {\n from: 'boolean',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n return new BigNumber(+x);\n }\n }, {\n from: 'boolean',\n to: 'bigint',\n convert: function convert(x) {\n return BigInt(+x);\n }\n }, {\n from: 'boolean',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n return new Fraction(+x);\n }\n }, {\n from: 'boolean',\n to: 'string',\n convert: function convert(x) {\n return String(x);\n }\n }, {\n from: 'Array',\n to: 'Matrix',\n convert: function convert(array) {\n if (!DenseMatrix) {\n throwNoMatrix();\n }\n return new DenseMatrix(array);\n }\n }, {\n from: 'Matrix',\n to: 'Array',\n convert: function convert(matrix) {\n return matrix.valueOf();\n }\n }]);\n\n // Provide a suggestion on how to call a function elementwise\n // This was added primarily as guidance for the v10 -> v11 transition,\n // and could potentially be removed in the future if it no longer seems\n // to be helpful.\n typed.onMismatch = (name, args, signatures) => {\n var usualError = typed.createError(name, args, signatures);\n if (['wrongType', 'mismatch'].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) &&\n // check if the function can be unary:\n signatures.some(sig => !sig.params.includes(','))) {\n var err = new TypeError(\"Function '\".concat(name, \"' doesn't apply to matrices. To call it \") + \"elementwise on a matrix 'M', try 'map(M, \".concat(name, \")'.\"));\n err.data = usualError.data;\n throw err;\n }\n throw usualError;\n };\n\n // Provide a suggestion on how to call a function elementwise\n // This was added primarily as guidance for the v10 -> v11 transition,\n // and could potentially be removed in the future if it no longer seems\n // to be helpful.\n typed.onMismatch = (name, args, signatures) => {\n var usualError = typed.createError(name, args, signatures);\n if (['wrongType', 'mismatch'].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) &&\n // check if the function can be unary:\n signatures.some(sig => !sig.params.includes(','))) {\n var err = new TypeError(\"Function '\".concat(name, \"' doesn't apply to matrices. To call it \") + \"elementwise on a matrix 'M', try 'map(M, \".concat(name, \")'.\"));\n err.data = usualError.data;\n throw err;\n }\n throw usualError;\n };\n return typed;\n});\nfunction throwNoBignumber(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a BigNumber: no class 'BigNumber' provided\"));\n}\nfunction throwNoComplex(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a Complex number: no class 'Complex' provided\"));\n}\nfunction throwNoMatrix() {\n throw new Error('Cannot convert array into a Matrix: no class \\'DenseMatrix\\' provided');\n}\nfunction throwNoFraction(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a Fraction, no class 'Fraction' provided.\"));\n}","import { factory } from '../../utils/factory.js';\nvar name = 'ResultSet';\nvar dependencies = [];\nexport var createResultSet = /* #__PURE__ */factory(name, dependencies, () => {\n /**\n * A ResultSet contains a list or results\n * @class ResultSet\n * @param {Array} entries\n * @constructor ResultSet\n */\n function ResultSet(entries) {\n if (!(this instanceof ResultSet)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.entries = entries || [];\n }\n\n /**\n * Attach type information\n */\n ResultSet.prototype.type = 'ResultSet';\n ResultSet.prototype.isResultSet = true;\n\n /**\n * Returns the array with results hold by this ResultSet\n * @memberof ResultSet\n * @returns {Array} entries\n */\n ResultSet.prototype.valueOf = function () {\n return this.entries;\n };\n\n /**\n * Returns the stringified results of the ResultSet\n * @memberof ResultSet\n * @returns {string} string\n */\n ResultSet.prototype.toString = function () {\n return '[' + this.entries.map(String).join(', ') + ']';\n };\n\n /**\n * Get a JSON representation of the ResultSet\n * @memberof ResultSet\n * @returns {Object} Returns a JSON object structured as:\n * `{\"mathjs\": \"ResultSet\", \"entries\": [...]}`\n */\n ResultSet.prototype.toJSON = function () {\n return {\n mathjs: 'ResultSet',\n entries: this.entries\n };\n };\n\n /**\n * Instantiate a ResultSet from a JSON object\n * @memberof ResultSet\n * @param {Object} json A JSON object structured as:\n * `{\"mathjs\": \"ResultSet\", \"entries\": [...]}`\n * @return {ResultSet}\n */\n ResultSet.fromJSON = function (json) {\n return new ResultSet(json.entries);\n };\n return ResultSet;\n}, {\n isClass: true\n});","import { isBigNumber, isNumber } from '../is.js';\nimport { isInteger, normalizeFormatOptions } from '../number.js';\n\n/**\n * Formats a BigNumber in a given base\n * @param {BigNumber} n\n * @param {number} base\n * @param {number} size\n * @returns {string}\n */\nfunction formatBigNumberToBase(n, base, size) {\n var BigNumberCtor = n.constructor;\n var big2 = new BigNumberCtor(2);\n var suffix = '';\n if (size) {\n if (size < 1) {\n throw new Error('size must be in greater than 0');\n }\n if (!isInteger(size)) {\n throw new Error('size must be an integer');\n }\n if (n.greaterThan(big2.pow(size - 1).sub(1)) || n.lessThan(big2.pow(size - 1).mul(-1))) {\n throw new Error(\"Value must be in range [-2^\".concat(size - 1, \", 2^\").concat(size - 1, \"-1]\"));\n }\n if (!n.isInteger()) {\n throw new Error('Value must be an integer');\n }\n if (n.lessThan(0)) {\n n = n.add(big2.pow(size));\n }\n suffix = \"i\".concat(size);\n }\n switch (base) {\n case 2:\n return \"\".concat(n.toBinary()).concat(suffix);\n case 8:\n return \"\".concat(n.toOctal()).concat(suffix);\n case 16:\n return \"\".concat(n.toHexadecimal()).concat(suffix);\n default:\n throw new Error(\"Base \".concat(base, \" not supported \"));\n }\n}\n\n/**\n * Convert a BigNumber to a formatted string representation.\n *\n * Syntax:\n *\n * format(value)\n * format(value, options)\n * format(value, precision)\n * format(value, fn)\n *\n * Where:\n *\n * {number} value The value to be formatted\n * {Object} options An object with formatting options. Available options:\n * {string} notation\n * Number notation. Choose from:\n * 'fixed' Always use regular number notation.\n * For example '123.40' and '14000000'\n * 'exponential' Always use exponential notation.\n * For example '1.234e+2' and '1.4e+7'\n * 'auto' (default) Regular number notation for numbers\n * having an absolute value between\n * `lower` and `upper` bounds, and uses\n * exponential notation elsewhere.\n * Lower bound is included, upper bound\n * is excluded.\n * For example '123.4' and '1.4e7'.\n * 'bin', 'oct, or\n * 'hex' Format the number using binary, octal,\n * or hexadecimal notation.\n * For example '0b1101' and '0x10fe'.\n * {number} wordSize The word size in bits to use for formatting\n * in binary, octal, or hexadecimal notation.\n * To be used only with 'bin', 'oct', or 'hex'\n * values for 'notation' option. When this option\n * is defined the value is formatted as a signed\n * twos complement integer of the given word size\n * and the size suffix is appended to the output.\n * For example\n * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.\n * Default value is undefined.\n * {number} precision A number between 0 and 16 to round\n * the digits of the number.\n * In case of notations 'exponential',\n * 'engineering', and 'auto',\n * `precision` defines the total\n * number of significant digits returned.\n * In case of notation 'fixed',\n * `precision` defines the number of\n * significant digits after the decimal\n * point.\n * `precision` is undefined by default.\n * {number} lowerExp Exponent determining the lower boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `-3`.\n * {number} upperExp Exponent determining the upper boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `5`.\n * {Function} fn A custom formatting function. Can be used to override the\n * built-in notations. Function `fn` is called with `value` as\n * parameter and must return a string. Is useful for example to\n * format all values inside a matrix in a particular way.\n *\n * Examples:\n *\n * format(6.4) // '6.4'\n * format(1240000) // '1.24e6'\n * format(1/3) // '0.3333333333333333'\n * format(1/3, 3) // '0.333'\n * format(21385, 2) // '21000'\n * format(12e8, {notation: 'fixed'}) // returns '1200000000'\n * format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'\n * format(52.8, {notation: 'exponential'}) // returns '5.28e+1'\n * format(12400, {notation: 'engineering'}) // returns '12.400e+3'\n *\n * @param {BigNumber} value\n * @param {Object | Function | number | BigNumber} [options]\n * @return {string} str The formatted value\n */\nexport function format(value, options) {\n if (typeof options === 'function') {\n // handle format(value, fn)\n return options(value);\n }\n\n // handle special cases\n if (!value.isFinite()) {\n return value.isNaN() ? 'NaN' : value.gt(0) ? 'Infinity' : '-Infinity';\n }\n var {\n notation,\n precision,\n wordSize\n } = normalizeFormatOptions(options);\n\n // handle the various notations\n switch (notation) {\n case 'fixed':\n return toFixed(value, precision);\n case 'exponential':\n return toExponential(value, precision);\n case 'engineering':\n return toEngineering(value, precision);\n case 'bin':\n return formatBigNumberToBase(value, 2, wordSize);\n case 'oct':\n return formatBigNumberToBase(value, 8, wordSize);\n case 'hex':\n return formatBigNumberToBase(value, 16, wordSize);\n case 'auto':\n {\n // determine lower and upper bound for exponential notation.\n // TODO: implement support for upper and lower to be BigNumbers themselves\n var lowerExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.lowerExp, -3);\n var upperExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.upperExp, 5);\n\n // handle special case zero\n if (value.isZero()) return '0';\n\n // determine whether or not to output exponential notation\n var str;\n var rounded = value.toSignificantDigits(precision);\n var exp = rounded.e;\n if (exp >= lowerExp && exp < upperExp) {\n // normal number notation\n str = rounded.toFixed();\n } else {\n // exponential notation\n str = toExponential(value, precision);\n }\n\n // remove trailing zeros after the decimal point\n return str.replace(/((\\.\\d*?)(0+))($|e)/, function () {\n var digits = arguments[2];\n var e = arguments[4];\n return digits !== '.' ? digits + e : e;\n });\n }\n default:\n throw new Error('Unknown notation \"' + notation + '\". ' + 'Choose \"auto\", \"exponential\", \"fixed\", \"bin\", \"oct\", or \"hex.');\n }\n}\n\n/**\n * Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'\n * @param {BigNumber} value\n * @param {number} [precision] Optional number of significant figures to return.\n */\nexport function toEngineering(value, precision) {\n // find nearest lower multiple of 3 for exponent\n var e = value.e;\n var newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;\n\n // find difference in exponents, and calculate the value without exponent\n var valueWithoutExp = value.mul(Math.pow(10, -newExp));\n var valueStr = valueWithoutExp.toPrecision(precision);\n if (valueStr.includes('e')) {\n var BigNumber = value.constructor;\n valueStr = new BigNumber(valueStr).toFixed();\n }\n return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();\n}\n\n/**\n * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'\n * @param {BigNumber} value\n * @param {number} [precision] Number of digits in formatted output.\n * If not provided, the maximum available digits\n * is used.\n * @returns {string} str\n */\nexport function toExponential(value, precision) {\n if (precision !== undefined) {\n return value.toExponential(precision - 1); // Note the offset of one\n } else {\n return value.toExponential();\n }\n}\n\n/**\n * Format a number with fixed notation.\n * @param {BigNumber} value\n * @param {number} [precision=undefined] Optional number of decimals after the\n * decimal point. Undefined by default.\n */\nexport function toFixed(value, precision) {\n return value.toFixed(precision);\n}\nfunction _toNumberOrDefault(value, defaultValue) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n return defaultValue;\n }\n}","import { isBigNumber, isString, typeOf } from './is.js';\nimport { format as formatNumber } from './number.js';\nimport { format as formatBigNumber } from './bignumber/formatter.js';\n\n/**\n * Check if a text ends with a certain string.\n * @param {string} text\n * @param {string} search\n */\nexport function endsWith(text, search) {\n var start = text.length - search.length;\n var end = text.length;\n return text.substring(start, end) === search;\n}\n\n/**\n * Format a value of any type into a string.\n *\n * Usage:\n * math.format(value)\n * math.format(value, precision)\n * math.format(value, options)\n *\n * When value is a function:\n *\n * - When the function has a property `syntax`, it returns this\n * syntax description.\n * - In other cases, a string `'function'` is returned.\n *\n * When `value` is an Object:\n *\n * - When the object contains a property `format` being a function, this\n * function is invoked as `value.format(options)` and the result is returned.\n * - When the object has its own `toString` method, this method is invoked\n * and the result is returned.\n * - In other cases the function will loop over all object properties and\n * return JSON object notation like '{\"a\": 2, \"b\": 3}'.\n *\n * Example usage:\n * math.format(2/7) // '0.2857142857142857'\n * math.format(math.pi, 3) // '3.14'\n * math.format(new Complex(2, 3)) // '2 + 3i'\n * math.format('hello') // '\"hello\"'\n *\n * @param {*} value Value to be stringified\n * @param {Object | number | Function} [options]\n * Formatting options. See src/utils/number.js:format for a\n * description of the available options controlling number output.\n * This generic \"format\" also supports the option property `truncate: NN`\n * giving the maximum number NN of characters to return (if there would\n * have been more, they are deleted and replaced by an ellipsis).\n * @return {string} str\n */\nexport function format(value, options) {\n var result = _format(value, options);\n if (options && typeof options === 'object' && 'truncate' in options && result.length > options.truncate) {\n return result.substring(0, options.truncate - 3) + '...';\n }\n return result;\n}\nfunction _format(value, options) {\n if (typeof value === 'number') {\n return formatNumber(value, options);\n }\n if (isBigNumber(value)) {\n return formatBigNumber(value, options);\n }\n\n // note: we use unsafe duck-typing here to check for Fractions, this is\n // ok here since we're only invoking toString or concatenating its values\n if (looksLikeFraction(value)) {\n if (!options || options.fraction !== 'decimal') {\n // output as ratio, like '1/3'\n return \"\".concat(value.s * value.n, \"/\").concat(value.d);\n } else {\n // output as decimal, like '0.(3)'\n return value.toString();\n }\n }\n if (Array.isArray(value)) {\n return formatArray(value, options);\n }\n if (isString(value)) {\n return stringify(value);\n }\n if (typeof value === 'function') {\n return value.syntax ? String(value.syntax) : 'function';\n }\n if (value && typeof value === 'object') {\n if (typeof value.format === 'function') {\n return value.format(options);\n } else if (value && value.toString(options) !== {}.toString()) {\n // this object has a non-native toString method, use that one\n return value.toString(options);\n } else {\n var entries = Object.keys(value).map(key => {\n return stringify(key) + ': ' + format(value[key], options);\n });\n return '{' + entries.join(', ') + '}';\n }\n }\n return String(value);\n}\n\n/**\n * Stringify a value into a string enclosed in double quotes.\n * Unescaped double quotes and backslashes inside the value are escaped.\n * @param {*} value\n * @return {string}\n */\nexport function stringify(value) {\n var text = String(value);\n var escaped = '';\n var i = 0;\n while (i < text.length) {\n var c = text.charAt(i);\n escaped += c in controlCharacters ? controlCharacters[c] : c;\n i++;\n }\n return '\"' + escaped + '\"';\n}\nvar controlCharacters = {\n '\"': '\\\\\"',\n '\\\\': '\\\\\\\\',\n '\\b': '\\\\b',\n '\\f': '\\\\f',\n '\\n': '\\\\n',\n '\\r': '\\\\r',\n '\\t': '\\\\t'\n};\n\n/**\n * Escape special HTML characters\n * @param {*} value\n * @return {string}\n */\nexport function escape(value) {\n var text = String(value);\n text = text.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(//g, '>');\n return text;\n}\n\n/**\n * Recursively format an n-dimensional matrix\n * Example output: \"[[1, 2], [3, 4]]\"\n * @param {Array} array\n * @param {Object | number | Function} [options] Formatting options. See\n * lib/utils/number:format for a\n * description of the available\n * options.\n * @returns {string} str\n */\nfunction formatArray(array, options) {\n if (Array.isArray(array)) {\n var str = '[';\n var len = array.length;\n for (var i = 0; i < len; i++) {\n if (i !== 0) {\n str += ', ';\n }\n str += formatArray(array[i], options);\n }\n str += ']';\n return str;\n } else {\n return format(array, options);\n }\n}\n\n/**\n * Check whether a value looks like a Fraction (unsafe duck-type check)\n * @param {*} value\n * @return {boolean}\n */\nfunction looksLikeFraction(value) {\n return value && typeof value === 'object' && typeof value.s === 'bigint' && typeof value.n === 'bigint' && typeof value.d === 'bigint' || false;\n}\n\n/**\n * Compare two strings\n * @param {string} x\n * @param {string} y\n * @returns {number}\n */\nexport function compareText(x, y) {\n // we don't want to convert numbers to string, only accept string input\n if (!isString(x)) {\n throw new TypeError('Unexpected type of argument in function compareText ' + '(expected: string or Array or Matrix, actual: ' + typeOf(x) + ', index: 0)');\n }\n if (!isString(y)) {\n throw new TypeError('Unexpected type of argument in function compareText ' + '(expected: string or Array or Matrix, actual: ' + typeOf(y) + ', index: 1)');\n }\n return x === y ? 0 : x > y ? 1 : -1;\n}","function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}\nexport { _typeof as default };","import _typeof from \"./typeof.js\";\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nexport { toPrimitive as default };","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nexport { toPropertyKey as default };","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nexport { _defineProperty as default };","// list of identifiers of nodes in order of their precedence\n// also contains information about left/right associativity\n// and which other operator the operator is associative with\n// Example:\n// addition is associative with addition and subtraction, because:\n// (a+b)+c=a+(b+c)\n// (a+b)-c=a+(b-c)\n//\n// postfix operators are left associative, prefix operators\n// are right associative\n//\n// It's also possible to set the following properties:\n// latexParens: if set to false, this node doesn't need to be enclosed\n// in parentheses when using LaTeX\n// latexLeftParens: if set to false, this !OperatorNode's!\n// left argument doesn't need to be enclosed\n// in parentheses\n// latexRightParens: the same for the right argument\nimport { hasOwnProperty } from '../utils/object.js';\nimport { isConstantNode, isParenthesisNode, rule2Node } from '../utils/is.js';\nexport var properties = [{\n // assignment\n AssignmentNode: {},\n FunctionAssignmentNode: {}\n}, {\n // conditional expression\n ConditionalNode: {\n latexLeftParens: false,\n latexRightParens: false,\n latexParens: false\n // conditionals don't need parentheses in LaTeX because\n // they are 2 dimensional\n }\n}, {\n // logical or\n 'OperatorNode:or': {\n op: 'or',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // logical xor\n 'OperatorNode:xor': {\n op: 'xor',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // logical and\n 'OperatorNode:and': {\n op: 'and',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise or\n 'OperatorNode:bitOr': {\n op: '|',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise xor\n 'OperatorNode:bitXor': {\n op: '^|',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise and\n 'OperatorNode:bitAnd': {\n op: '&',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // relational operators\n 'OperatorNode:equal': {\n op: '==',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:unequal': {\n op: '!=',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:smaller': {\n op: '<',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:larger': {\n op: '>',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:smallerEq': {\n op: '<=',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:largerEq': {\n op: '>=',\n associativity: 'left',\n associativeWith: []\n },\n RelationalNode: {\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitshift operators\n 'OperatorNode:leftShift': {\n op: '<<',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:rightArithShift': {\n op: '>>',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:rightLogShift': {\n op: '>>>',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // unit conversion\n 'OperatorNode:to': {\n op: 'to',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // range\n RangeNode: {}\n}, {\n // addition, subtraction\n 'OperatorNode:add': {\n op: '+',\n associativity: 'left',\n associativeWith: ['OperatorNode:add', 'OperatorNode:subtract']\n },\n 'OperatorNode:subtract': {\n op: '-',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // multiply, divide, modulus\n 'OperatorNode:multiply': {\n op: '*',\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']\n },\n 'OperatorNode:divide': {\n op: '/',\n associativity: 'left',\n associativeWith: [],\n latexLeftParens: false,\n latexRightParens: false,\n latexParens: false\n // fractions don't require parentheses because\n // they're 2 dimensional, so parens aren't needed\n // in LaTeX\n },\n 'OperatorNode:dotMultiply': {\n op: '.*',\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'OperatorNode:dotMultiply', 'OperatorNode:doDivide']\n },\n 'OperatorNode:dotDivide': {\n op: './',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:mod': {\n op: 'mod',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // Repeat multiplication for implicit multiplication\n 'OperatorNode:multiply': {\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']\n }\n}, {\n // unary prefix operators\n 'OperatorNode:unaryPlus': {\n op: '+',\n associativity: 'right'\n },\n 'OperatorNode:unaryMinus': {\n op: '-',\n associativity: 'right'\n },\n 'OperatorNode:bitNot': {\n op: '~',\n associativity: 'right'\n },\n 'OperatorNode:not': {\n op: 'not',\n associativity: 'right'\n }\n}, {\n // exponentiation\n 'OperatorNode:pow': {\n op: '^',\n associativity: 'right',\n associativeWith: [],\n latexRightParens: false\n // the exponent doesn't need parentheses in\n // LaTeX because it's 2 dimensional\n // (it's on top)\n },\n 'OperatorNode:dotPow': {\n op: '.^',\n associativity: 'right',\n associativeWith: []\n }\n}, {\n // nullish coalescing\n 'OperatorNode:nullish': {\n op: '??',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // factorial\n 'OperatorNode:factorial': {\n op: '!',\n associativity: 'left'\n }\n}, {\n // matrix transpose\n 'OperatorNode:ctranspose': {\n op: \"'\",\n associativity: 'left'\n }\n}];\n\n/**\n * Returns the first non-parenthesis internal node, but only\n * when the 'parenthesis' option is unset or auto.\n * @param {Node} _node\n * @param {string} parenthesis\n * @return {Node}\n */\nfunction unwrapParen(_node, parenthesis) {\n if (!parenthesis || parenthesis !== 'auto') return _node;\n var node = _node;\n while (isParenthesisNode(node)) node = node.content;\n return node;\n}\n\n/**\n * Get the precedence of a Node.\n * Higher number for higher precedence, starting with 0.\n * Returns null if the precedence is undefined.\n *\n * @param {Node} _node\n * @param {string} parenthesis\n * @param {string} implicit\n * @param {Node} parent (for determining context for implicit multiplication)\n * @return {number | null}\n */\nexport function getPrecedence(_node, parenthesis, implicit, parent) {\n var node = _node;\n if (parenthesis !== 'keep') {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n node = _node.getContent();\n }\n var identifier = node.getIdentifier();\n var precedence = null;\n for (var i = 0; i < properties.length; i++) {\n if (identifier in properties[i]) {\n precedence = i;\n break;\n }\n }\n // Bump up precedence of implicit multiplication, except when preceded\n // by a \"Rule 2\" fraction ( [unaryOp]constant / constant )\n if (identifier === 'OperatorNode:multiply' && node.implicit && implicit !== 'show') {\n var leftArg = unwrapParen(node.args[0], parenthesis);\n if (!(isConstantNode(leftArg) && parent && parent.getIdentifier() === 'OperatorNode:divide' && rule2Node(unwrapParen(parent.args[0], parenthesis))) && !(leftArg.getIdentifier() === 'OperatorNode:divide' && rule2Node(unwrapParen(leftArg.args[0], parenthesis)) && isConstantNode(unwrapParen(leftArg.args[1])))) {\n precedence += 1;\n }\n }\n return precedence;\n}\n\n/**\n * Get the associativity of an operator (left or right).\n * Returns a string containing 'left' or 'right' or null if\n * the associativity is not defined.\n *\n * @param {Node} _node\n * @param {string} parenthesis\n * @return {string|null}\n * @throws {Error}\n */\nexport function getAssociativity(_node, parenthesis) {\n var node = _node;\n if (parenthesis !== 'keep') {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n node = _node.getContent();\n }\n var identifier = node.getIdentifier();\n var index = getPrecedence(node, parenthesis);\n if (index === null) {\n // node isn't in the list\n return null;\n }\n var property = properties[index][identifier];\n if (hasOwnProperty(property, 'associativity')) {\n if (property.associativity === 'left') {\n return 'left';\n }\n if (property.associativity === 'right') {\n return 'right';\n }\n // associativity is invalid\n throw Error('\\'' + identifier + '\\' has the invalid associativity \\'' + property.associativity + '\\'.');\n }\n\n // associativity is undefined\n return null;\n}\n\n/**\n * Check if an operator is associative with another operator.\n * Returns either true or false or null if not defined.\n *\n * @param {Node} nodeA\n * @param {Node} nodeB\n * @param {string} parenthesis\n * @return {boolean | null}\n */\nexport function isAssociativeWith(nodeA, nodeB, parenthesis) {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n var a = parenthesis !== 'keep' ? nodeA.getContent() : nodeA;\n var b = parenthesis !== 'keep' ? nodeA.getContent() : nodeB;\n var identifierA = a.getIdentifier();\n var identifierB = b.getIdentifier();\n var index = getPrecedence(a, parenthesis);\n if (index === null) {\n // node isn't in the list\n return null;\n }\n var property = properties[index][identifierA];\n if (hasOwnProperty(property, 'associativeWith') && property.associativeWith instanceof Array) {\n for (var i = 0; i < property.associativeWith.length; i++) {\n if (property.associativeWith[i] === identifierB) {\n return true;\n }\n }\n return false;\n }\n\n // associativeWith is not defined\n return null;\n}\n\n/**\n * Get the operator associated with a function name.\n * Returns a string with the operator symbol, or null if the\n * input is not the name of a function associated with an\n * operator.\n *\n * @param {string} Function name\n * @return {string | null} Associated operator symbol, if any\n */\nexport function getOperator(fn) {\n var identifier = 'OperatorNode:' + fn;\n for (var group of properties) {\n if (identifier in group) {\n return group[identifier].op;\n }\n }\n return null;\n}","/**\n * Create a range error with the message:\n * 'Index out of range (index < min)'\n * 'Index out of range (index < max)'\n *\n * @param {number} index The actual index\n * @param {number} [min=0] Minimum index (included)\n * @param {number} [max] Maximum index (excluded)\n * @extends RangeError\n */\nexport function IndexError(index, min, max) {\n if (!(this instanceof IndexError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.index = index;\n if (arguments.length < 3) {\n this.min = 0;\n this.max = min;\n } else {\n this.min = min;\n this.max = max;\n }\n if (this.min !== undefined && this.index < this.min) {\n this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')';\n } else if (this.max !== undefined && this.index >= this.max) {\n this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')';\n } else {\n this.message = 'Index out of range (' + this.index + ')';\n }\n this.stack = new Error().stack;\n}\nIndexError.prototype = new RangeError();\nIndexError.prototype.constructor = RangeError;\nIndexError.prototype.name = 'IndexError';\nIndexError.prototype.isIndexError = true;","/**\n * Create a range error with the message:\n * 'Dimension mismatch ( != )'\n * @param {number | number[]} actual The actual size\n * @param {number | number[]} expected The expected size\n * @param {string} [relation='!='] Optional relation between actual\n * and expected size: '!=', '<', etc.\n * @extends RangeError\n */\nexport function DimensionError(actual, expected, relation) {\n if (!(this instanceof DimensionError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.actual = actual;\n this.expected = expected;\n this.relation = relation;\n this.message = 'Dimension mismatch (' + (Array.isArray(actual) ? '[' + actual.join(', ') + ']' : actual) + ' ' + (this.relation || '!=') + ' ' + (Array.isArray(expected) ? '[' + expected.join(', ') + ']' : expected) + ')';\n this.stack = new Error().stack;\n}\nDimensionError.prototype = new RangeError();\nDimensionError.prototype.constructor = RangeError;\nDimensionError.prototype.name = 'DimensionError';\nDimensionError.prototype.isDimensionError = true;","import _extends from \"@babel/runtime/helpers/extends\";\nimport { isInteger } from './number.js';\nimport { isNumber, isBigNumber, isArray, isString } from './is.js';\nimport { format } from './string.js';\nimport { DimensionError } from '../error/DimensionError.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { deepStrictEqual } from './object.js';\n\n/**\n * Calculate the size of a multi dimensional array.\n * This function checks the size of the first entry, it does not validate\n * whether all dimensions match. (use function `validate` for that)\n * @param {Array} x\n * @return {number[]} size\n */\nexport function arraySize(x) {\n var s = [];\n while (Array.isArray(x)) {\n s.push(x.length);\n x = x[0];\n }\n return s;\n}\n\n/**\n * Recursively validate whether each element in a multi dimensional array\n * has a size corresponding to the provided size array.\n * @param {Array} array Array to be validated\n * @param {number[]} size Array with the size of each dimension\n * @param {number} dim Current dimension\n * @throws DimensionError\n * @private\n */\nfunction _validate(array, size, dim) {\n var i;\n var len = array.length;\n if (len !== size[dim]) {\n throw new DimensionError(len, size[dim]);\n }\n if (dim < size.length - 1) {\n // recursively validate each child array\n var dimNext = dim + 1;\n for (i = 0; i < len; i++) {\n var child = array[i];\n if (!Array.isArray(child)) {\n throw new DimensionError(size.length - 1, size.length, '<');\n }\n _validate(array[i], size, dimNext);\n }\n } else {\n // last dimension. none of the children may be an array\n for (i = 0; i < len; i++) {\n if (Array.isArray(array[i])) {\n throw new DimensionError(size.length + 1, size.length, '>');\n }\n }\n }\n}\n\n/**\n * Validate whether each element in a multi dimensional array has\n * a size corresponding to the provided size array.\n * @param {Array} array Array to be validated\n * @param {number[]} size Array with the size of each dimension\n * @throws DimensionError\n */\nexport function validate(array, size) {\n var isScalar = size.length === 0;\n if (isScalar) {\n // scalar\n if (Array.isArray(array)) {\n throw new DimensionError(array.length, 0);\n }\n } else {\n // array\n _validate(array, size, 0);\n }\n}\n\n/**\n * Validate whether the source of the index matches the size of the Array\n * @param {Array | Matrix} value Array to be validated\n * @param {Index} index Index with the source information to validate\n * @throws DimensionError\n */\nexport function validateIndexSourceSize(value, index) {\n var valueSize = value.isMatrix ? value._size : arraySize(value);\n var sourceSize = index._sourceSize;\n // checks if the source size is not null and matches the valueSize\n sourceSize.forEach((sourceDim, i) => {\n if (sourceDim !== null && sourceDim !== valueSize[i]) {\n throw new DimensionError(sourceDim, valueSize[i]);\n }\n });\n}\n\n/**\n * Test whether index is an integer number with index >= 0 and index < length\n * when length is provided\n * @param {number} index Zero-based index\n * @param {number} [length] Length of the array\n */\nexport function validateIndex(index, length) {\n if (index !== undefined) {\n if (!isNumber(index) || !isInteger(index)) {\n throw new TypeError('Index must be an integer (value: ' + index + ')');\n }\n if (index < 0 || typeof length === 'number' && index >= length) {\n throw new IndexError(index, length);\n }\n }\n}\n\n/**\n * Test if an index has empty values\n * @param {Index} index Zero-based index\n */\nexport function isEmptyIndex(index) {\n for (var i = 0; i < index._dimensions.length; ++i) {\n var dimension = index._dimensions[i];\n if (dimension._data && isArray(dimension._data)) {\n if (dimension._size[0] === 0) {\n return true;\n }\n } else if (dimension.isRange) {\n if (dimension.start === dimension.end) {\n return true;\n }\n } else if (isString(dimension)) {\n if (dimension.length === 0) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Resize a multi dimensional array. The resized array is returned.\n * @param {Array | number} array Array to be resized\n * @param {number[]} size Array with the size of each dimension\n * @param {*} [defaultValue=0] Value to be filled in new entries,\n * zero by default. Specify for example `null`,\n * to clearly see entries that are not explicitly\n * set.\n * @return {Array} array The resized array\n */\nexport function resize(array, size, defaultValue) {\n // check the type of the arguments\n if (!Array.isArray(size)) {\n throw new TypeError('Array expected');\n }\n if (size.length === 0) {\n throw new Error('Resizing to scalar is not supported');\n }\n\n // check whether size contains positive integers\n size.forEach(function (value) {\n if (!isNumber(value) || !isInteger(value) || value < 0) {\n throw new TypeError('Invalid size, must contain positive integers ' + '(size: ' + format(size) + ')');\n }\n });\n\n // convert number to an array\n if (isNumber(array) || isBigNumber(array)) {\n array = [array];\n }\n\n // recursively resize the array\n var _defaultValue = defaultValue !== undefined ? defaultValue : 0;\n _resize(array, size, 0, _defaultValue);\n return array;\n}\n\n/**\n * Recursively resize a multi dimensional array\n * @param {Array} array Array to be resized\n * @param {number[]} size Array with the size of each dimension\n * @param {number} dim Current dimension\n * @param {*} [defaultValue] Value to be filled in new entries,\n * undefined by default.\n * @private\n */\nfunction _resize(array, size, dim, defaultValue) {\n var i;\n var elem;\n var oldLen = array.length;\n var newLen = size[dim];\n var minLen = Math.min(oldLen, newLen);\n\n // apply new length\n array.length = newLen;\n if (dim < size.length - 1) {\n // non-last dimension\n var dimNext = dim + 1;\n\n // resize existing child arrays\n for (i = 0; i < minLen; i++) {\n // resize child array\n elem = array[i];\n if (!Array.isArray(elem)) {\n elem = [elem]; // add a dimension\n array[i] = elem;\n }\n _resize(elem, size, dimNext, defaultValue);\n }\n\n // create new child arrays\n for (i = minLen; i < newLen; i++) {\n // get child array\n elem = [];\n array[i] = elem;\n\n // resize new child array\n _resize(elem, size, dimNext, defaultValue);\n }\n } else {\n // last dimension\n\n // remove dimensions of existing values\n for (i = 0; i < minLen; i++) {\n while (Array.isArray(array[i])) {\n array[i] = array[i][0];\n }\n }\n\n // fill new elements with the default value\n for (i = minLen; i < newLen; i++) {\n array[i] = defaultValue;\n }\n }\n}\n\n/**\n * Re-shape a multi dimensional array to fit the specified dimensions\n * @param {Array} array Array to be reshaped\n * @param {number[]} sizes List of sizes for each dimension\n * @returns {Array} Array whose data has been formatted to fit the\n * specified dimensions\n *\n * @throws {DimensionError} If the product of the new dimension sizes does\n * not equal that of the old ones\n */\nexport function reshape(array, sizes) {\n var flatArray = flatten(array, true); // since it has rectangular\n var currentLength = flatArray.length;\n if (!Array.isArray(array) || !Array.isArray(sizes)) {\n throw new TypeError('Array expected');\n }\n if (sizes.length === 0) {\n throw new DimensionError(0, currentLength, '!=');\n }\n sizes = processSizesWildcard(sizes, currentLength);\n var newLength = product(sizes);\n if (currentLength !== newLength) {\n throw new DimensionError(newLength, currentLength, '!=');\n }\n try {\n return _reshape(flatArray, sizes);\n } catch (e) {\n if (e instanceof DimensionError) {\n throw new DimensionError(newLength, currentLength, '!=');\n }\n throw e;\n }\n}\n\n/**\n * Replaces the wildcard -1 in the sizes array.\n * @param {number[]} sizes List of sizes for each dimension. At most one wildcard.\n * @param {number} currentLength Number of elements in the array.\n * @throws {Error} If more than one wildcard or unable to replace it.\n * @returns {number[]} The sizes array with wildcard replaced.\n */\nexport function processSizesWildcard(sizes, currentLength) {\n var newLength = product(sizes);\n var processedSizes = sizes.slice();\n var WILDCARD = -1;\n var wildCardIndex = sizes.indexOf(WILDCARD);\n var isMoreThanOneWildcard = sizes.indexOf(WILDCARD, wildCardIndex + 1) >= 0;\n if (isMoreThanOneWildcard) {\n throw new Error('More than one wildcard in sizes');\n }\n var hasWildcard = wildCardIndex >= 0;\n var canReplaceWildcard = currentLength % newLength === 0;\n if (hasWildcard) {\n if (canReplaceWildcard) {\n processedSizes[wildCardIndex] = -currentLength / newLength;\n } else {\n throw new Error('Could not replace wildcard, since ' + currentLength + ' is no multiple of ' + -newLength);\n }\n }\n return processedSizes;\n}\n\n/**\n * Computes the product of all array elements.\n * @param {number[]} array Array of factors\n * @returns {number} Product of all elements\n */\nfunction product(array) {\n return array.reduce((prev, curr) => prev * curr, 1);\n}\n\n/**\n * Iteratively re-shape a multi dimensional array to fit the specified dimensions\n * @param {Array} array Array to be reshaped\n * @param {number[]} sizes List of sizes for each dimension\n * @returns {Array} Array whose data has been formatted to fit the\n * specified dimensions\n */\n\nfunction _reshape(array, sizes) {\n // testing if there are enough elements for the requested shape\n var tmpArray = array;\n var tmpArray2;\n // for each dimension starting by the last one and ignoring the first one\n for (var sizeIndex = sizes.length - 1; sizeIndex > 0; sizeIndex--) {\n var size = sizes[sizeIndex];\n tmpArray2 = [];\n\n // aggregate the elements of the current tmpArray in elements of the requested size\n var length = tmpArray.length / size;\n for (var i = 0; i < length; i++) {\n tmpArray2.push(tmpArray.slice(i * size, (i + 1) * size));\n }\n // set it as the new tmpArray for the next loop turn or for return\n tmpArray = tmpArray2;\n }\n return tmpArray;\n}\n\n/**\n * Squeeze a multi dimensional array\n * @param {Array} array\n * @param {Array} [size]\n * @returns {Array} returns the array itself\n */\nexport function squeeze(array, size) {\n var s = size || arraySize(array);\n\n // squeeze outer dimensions\n while (Array.isArray(array) && array.length === 1) {\n array = array[0];\n s.shift();\n }\n\n // find the first dimension to be squeezed\n var dims = s.length;\n while (s[dims - 1] === 1) {\n dims--;\n }\n\n // squeeze inner dimensions\n if (dims < s.length) {\n array = _squeeze(array, dims, 0);\n s.length = dims;\n }\n return array;\n}\n\n/**\n * Recursively squeeze a multi dimensional array\n * @param {Array} array\n * @param {number} dims Required number of dimensions\n * @param {number} dim Current dimension\n * @returns {Array | *} Returns the squeezed array\n * @private\n */\nfunction _squeeze(array, dims, dim) {\n var i, ii;\n if (dim < dims) {\n var next = dim + 1;\n for (i = 0, ii = array.length; i < ii; i++) {\n array[i] = _squeeze(array[i], dims, next);\n }\n } else {\n while (Array.isArray(array)) {\n array = array[0];\n }\n }\n return array;\n}\n\n/**\n * Unsqueeze a multi dimensional array: add dimensions when missing\n *\n * Parameter `size` will be mutated to match the new, unsqueezed matrix size.\n *\n * @param {Array} array\n * @param {number} dims Desired number of dimensions of the array\n * @param {number} [outer] Number of outer dimensions to be added\n * @param {Array} [size] Current size of array.\n * @returns {Array} returns the array itself\n * @private\n */\nexport function unsqueeze(array, dims, outer, size) {\n var s = size || arraySize(array);\n\n // unsqueeze outer dimensions\n if (outer) {\n for (var i = 0; i < outer; i++) {\n array = [array];\n s.unshift(1);\n }\n }\n\n // unsqueeze inner dimensions\n array = _unsqueeze(array, dims, 0);\n while (s.length < dims) {\n s.push(1);\n }\n return array;\n}\n\n/**\n * Recursively unsqueeze a multi dimensional array\n * @param {Array} array\n * @param {number} dims Required number of dimensions\n * @param {number} dim Current dimension\n * @returns {Array | *} Returns the unsqueezed array\n * @private\n */\nfunction _unsqueeze(array, dims, dim) {\n var i, ii;\n if (Array.isArray(array)) {\n var next = dim + 1;\n for (i = 0, ii = array.length; i < ii; i++) {\n array[i] = _unsqueeze(array[i], dims, next);\n }\n } else {\n for (var d = dim; d < dims; d++) {\n array = [array];\n }\n }\n return array;\n}\n/**\n * Flatten a multi dimensional array, put all elements in a one dimensional\n * array\n * @param {Array} array A multi dimensional array\n * @param {boolean} isRectangular Optional. If the array is rectangular (not jagged)\n * @return {Array} The flattened array (1 dimensional)\n */\nexport function flatten(array) {\n var isRectangular = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!Array.isArray(array)) {\n // if not an array, return as is\n return array;\n }\n if (typeof isRectangular !== 'boolean') {\n throw new TypeError('Boolean expected for second argument of flatten');\n }\n var flat = [];\n if (isRectangular) {\n _flattenRectangular(array);\n } else {\n _flatten(array);\n }\n return flat;\n function _flatten(array) {\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n if (Array.isArray(item)) {\n _flatten(item);\n } else {\n flat.push(item);\n }\n }\n }\n function _flattenRectangular(array) {\n if (Array.isArray(array[0])) {\n for (var i = 0; i < array.length; i++) {\n _flattenRectangular(array[i]);\n }\n } else {\n for (var _i = 0; _i < array.length; _i++) {\n flat.push(array[_i]);\n }\n }\n }\n}\n\n/**\n * A safe map\n * @param {Array} array\n * @param {function} callback\n */\nexport function map(array, callback) {\n return Array.prototype.map.call(array, callback);\n}\n\n/**\n * A safe forEach\n * @param {Array} array\n * @param {function} callback\n */\nexport function forEach(array, callback) {\n Array.prototype.forEach.call(array, callback);\n}\n\n/**\n * A safe filter\n * @param {Array} array\n * @param {function} callback\n */\nexport function filter(array, callback) {\n if (arraySize(array).length !== 1) {\n throw new Error('Only one dimensional matrices supported');\n }\n return Array.prototype.filter.call(array, callback);\n}\n\n/**\n * Filter values in an array given a regular expression\n * @param {Array} array\n * @param {RegExp} regexp\n * @return {Array} Returns the filtered array\n * @private\n */\nexport function filterRegExp(array, regexp) {\n if (arraySize(array).length !== 1) {\n throw new Error('Only one dimensional matrices supported');\n }\n return Array.prototype.filter.call(array, entry => regexp.test(entry));\n}\n\n/**\n * A safe join\n * @param {Array} array\n * @param {string} separator\n */\nexport function join(array, separator) {\n return Array.prototype.join.call(array, separator);\n}\n\n/**\n * Assign a numeric identifier to every element of a sorted array\n * @param {Array} a An array\n * @return {Array} An array of objects containing the original value and its identifier\n */\nexport function identify(a) {\n if (!Array.isArray(a)) {\n throw new TypeError('Array input expected');\n }\n if (a.length === 0) {\n return a;\n }\n var b = [];\n var count = 0;\n b[0] = {\n value: a[0],\n identifier: 0\n };\n for (var i = 1; i < a.length; i++) {\n if (a[i] === a[i - 1]) {\n count++;\n } else {\n count = 0;\n }\n b.push({\n value: a[i],\n identifier: count\n });\n }\n return b;\n}\n\n/**\n * Remove the numeric identifier from the elements\n * @param {array} a An array\n * @return {array} An array of values without identifiers\n */\nexport function generalize(a) {\n if (!Array.isArray(a)) {\n throw new TypeError('Array input expected');\n }\n if (a.length === 0) {\n return a;\n }\n var b = [];\n for (var i = 0; i < a.length; i++) {\n b.push(a[i].value);\n }\n return b;\n}\n\n/**\n * Check the datatype of a given object\n * This is a low level implementation that should only be used by\n * parent Matrix classes such as SparseMatrix or DenseMatrix\n * This method does not validate Array Matrix shape\n * @param {Array} array\n * @param {function} typeOf Callback function to use to determine the type of a value\n * @return {string}\n */\nexport function getArrayDataType(array, typeOf) {\n var type; // to hold type info\n var length = 0; // to hold length value to ensure it has consistent sizes\n\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n var _isArray = Array.isArray(item);\n\n // Saving the target matrix row size\n if (i === 0 && _isArray) {\n length = item.length;\n }\n\n // If the current item is an array but the length does not equal the targetVectorSize\n if (_isArray && item.length !== length) {\n return undefined;\n }\n var itemType = _isArray ? getArrayDataType(item, typeOf) // recurse into a nested array\n : typeOf(item);\n if (type === undefined) {\n type = itemType; // first item\n } else if (type !== itemType) {\n return 'mixed';\n } else {\n // we're good, everything has the same type so far\n }\n }\n return type;\n}\n\n/**\n * Return the last item from an array\n * @param {Array} array\n * @returns {*}\n */\nexport function last(array) {\n return array[array.length - 1];\n}\n\n/**\n * Get all but the last element of array.\n * @param {Array} array\n * @returns {Array}\n */\nexport function initial(array) {\n return array.slice(0, array.length - 1);\n}\n\n/**\n * Recursively concatenate two matrices.\n * The contents of the matrices are not cloned.\n * @param {Array} a Multi dimensional array\n * @param {Array} b Multi dimensional array\n * @param {number} concatDim The dimension on which to concatenate (zero-based)\n * @param {number} dim The current dim (zero-based)\n * @return {Array} c The concatenated matrix\n * @private\n */\nfunction concatRecursive(a, b, concatDim, dim) {\n if (dim < concatDim) {\n // recurse into next dimension\n if (a.length !== b.length) {\n throw new DimensionError(a.length, b.length);\n }\n var c = [];\n for (var i = 0; i < a.length; i++) {\n c[i] = concatRecursive(a[i], b[i], concatDim, dim + 1);\n }\n return c;\n } else {\n // concatenate this dimension\n return a.concat(b);\n }\n}\n\n/**\n * Concatenates many arrays in the specified direction\n * @param {...Array} arrays All the arrays to concatenate\n * @param {number} concatDim The dimension on which to concatenate (zero-based)\n * @returns {Array}\n */\nexport function concat() {\n var arrays = Array.prototype.slice.call(arguments, 0, -1);\n var concatDim = Array.prototype.slice.call(arguments, -1);\n if (arrays.length === 1) {\n return arrays[0];\n }\n if (arrays.length > 1) {\n return arrays.slice(1).reduce(function (A, B) {\n return concatRecursive(A, B, concatDim, 0);\n }, arrays[0]);\n } else {\n throw new Error('Wrong number of arguments in function concat');\n }\n}\n\n/**\n * Receives two or more sizes and gets the broadcasted size for both.\n * @param {...number[]} sizes Sizes to broadcast together\n * @returns {number[]} The broadcasted size\n */\nexport function broadcastSizes() {\n for (var _len = arguments.length, sizes = new Array(_len), _key = 0; _key < _len; _key++) {\n sizes[_key] = arguments[_key];\n }\n var dimensions = sizes.map(s => s.length);\n var N = Math.max(...dimensions);\n var sizeMax = new Array(N).fill(null);\n // check for every size\n for (var i = 0; i < sizes.length; i++) {\n var size = sizes[i];\n var dim = dimensions[i];\n for (var j = 0; j < dim; j++) {\n var n = N - dim + j;\n if (size[j] > sizeMax[n]) {\n sizeMax[n] = size[j];\n }\n }\n }\n for (var _i2 = 0; _i2 < sizes.length; _i2++) {\n checkBroadcastingRules(sizes[_i2], sizeMax);\n }\n return sizeMax;\n}\n\n/**\n * Checks if it's possible to broadcast a size to another size\n * @param {number[]} size The size of the array to check\n * @param {number[]} toSize The size of the array to validate if it can be broadcasted to\n */\nexport function checkBroadcastingRules(size, toSize) {\n var N = toSize.length;\n var dim = size.length;\n for (var j = 0; j < dim; j++) {\n var n = N - dim + j;\n if (size[j] < toSize[n] && size[j] > 1 || size[j] > toSize[n]) {\n throw new Error(\"shape mismatch: mismatch is found in arg with shape (\".concat(size, \") not possible to broadcast dimension \").concat(dim, \" with size \").concat(size[j], \" to size \").concat(toSize[n]));\n }\n }\n}\n\n/**\n * Broadcasts a single array to a certain size\n * @param {Array} array Array to be broadcasted\n * @param {number[]} toSize Size to broadcast the array\n * @returns {Array} The broadcasted array\n */\nexport function broadcastTo(array, toSize) {\n var Asize = arraySize(array);\n if (deepStrictEqual(Asize, toSize)) {\n return array;\n }\n checkBroadcastingRules(Asize, toSize);\n var broadcastedSize = broadcastSizes(Asize, toSize);\n var N = broadcastedSize.length;\n var paddedSize = [...Array(N - Asize.length).fill(1), ...Asize];\n var A = clone(array);\n // reshape A if needed to make it ready for concat\n if (Asize.length < N) {\n A = reshape(A, paddedSize);\n Asize = arraySize(A);\n }\n\n // stretches the array on each dimension to make it the same size as index\n for (var dim = 0; dim < N; dim++) {\n if (Asize[dim] < broadcastedSize[dim]) {\n A = stretch(A, broadcastedSize[dim], dim);\n Asize = arraySize(A);\n }\n }\n return A;\n}\n\n/**\n * Broadcasts arrays and returns the broadcasted arrays in an array\n * @param {...Array | any} arrays\n * @returns {Array[]} The broadcasted arrays\n */\nexport function broadcastArrays() {\n for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n arrays[_key2] = arguments[_key2];\n }\n if (arrays.length === 0) {\n throw new Error('Insufficient number of arguments in function broadcastArrays');\n }\n if (arrays.length === 1) {\n return arrays[0];\n }\n var sizes = arrays.map(function (array) {\n return arraySize(array);\n });\n var broadcastedSize = broadcastSizes(...sizes);\n var broadcastedArrays = [];\n arrays.forEach(function (array) {\n broadcastedArrays.push(broadcastTo(array, broadcastedSize));\n });\n return broadcastedArrays;\n}\n\n/**\n * Stretches a matrix up to a certain size in a certain dimension\n * @param {Array} arrayToStretch\n * @param {number[]} sizeToStretch\n * @param {number} dimToStretch\n * @returns {Array} The stretched array\n */\nexport function stretch(arrayToStretch, sizeToStretch, dimToStretch) {\n return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);\n}\n\n/**\n* Retrieves a single element from an array given an index.\n*\n* @param {Array} array - The array from which to retrieve the value.\n* @param {Array} index - An array of indices specifying the position of the desired element in each dimension.\n* @returns {*} - The value at the specified position in the array.\n*\n* @example\n* const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];\n* const index = [1, 0, 1];\n* console.log(get(arr, index)); // 6\n*/\nexport function get(array, index) {\n if (!Array.isArray(array)) {\n throw new Error('Array expected');\n }\n if (!Array.isArray(index)) {\n throw new Error('Array expected for index');\n }\n var size = arraySize(array);\n if (index.length !== size.length) {\n throw new DimensionError(index.length, size.length);\n }\n for (var x = 0; x < index.length; x++) {\n validateIndex(index[x], size[x]);\n }\n return index.reduce((acc, curr) => acc[curr], array);\n}\n\n/**\n * Recursively maps over each element of nested array using a provided callback function.\n *\n * @param {Array} array - The array to be mapped.\n * @param {Function} callback - The function to execute on each element, taking three arguments:\n * - `value` (any): The current element being processed in the array.\n * - `index` (Array): The index of the current element being processed in the array.\n * - `array` (Array): The array `deepMap` was called upon.\n * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.\n * @returns {Array} A new array with each element being the result of the callback function.\n */\nexport function deepMap(array, callback) {\n var skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n if (array.length === 0) {\n return [];\n }\n if (skipIndex) {\n return recursiveMap(array);\n }\n var index = [];\n return recursiveMapWithIndex(array, 0);\n function recursiveMapWithIndex(value, depth) {\n if (Array.isArray(value)) {\n var N = value.length;\n var result = Array(N);\n for (var i = 0; i < N; i++) {\n index[depth] = i;\n result[i] = recursiveMapWithIndex(value[i], depth + 1);\n }\n return result;\n } else {\n return callback(value, index.slice(0, depth), array);\n }\n }\n function recursiveMap(value) {\n if (Array.isArray(value)) {\n var N = value.length;\n var result = Array(N);\n for (var i = 0; i < N; i++) {\n result[i] = recursiveMap(value[i]);\n }\n return result;\n } else {\n return callback(value);\n }\n }\n}\n\n/**\n * Recursively iterates over each element in a multi-dimensional array and applies a callback function.\n *\n * @param {Array} array - The multi-dimensional array to iterate over.\n * @param {Function} callback - The function to execute for each element. It receives three arguments:\n * - {any} value: The current element being processed in the array.\n * - {Array} index: The index of the current element in each dimension.\n * - {Array} array: The original array being processed.\n * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.\n */\nexport function deepForEach(array, callback) {\n var skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n if (array.length === 0) {\n return;\n }\n if (skipIndex) {\n recursiveForEach(array);\n return;\n }\n var index = [];\n recursiveForEachWithIndex(array, 0);\n function recursiveForEachWithIndex(value, depth) {\n if (Array.isArray(value)) {\n var N = value.length;\n for (var i = 0; i < N; i++) {\n index[depth] = i;\n recursiveForEachWithIndex(value[i], depth + 1);\n }\n } else {\n callback(value, index.slice(0, depth), array);\n }\n }\n function recursiveForEach(value) {\n if (Array.isArray(value)) {\n var N = value.length;\n for (var i = 0; i < N; i++) {\n recursiveForEach(value[i]);\n }\n } else {\n callback(value);\n }\n }\n}\n\n/**\n * Deep clones a multidimensional array\n * @param {Array} array\n * @returns {Array} cloned array\n */\nexport function clone(array) {\n return _extends([], array);\n}","import { isCollection, isMatrix } from './is.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { arraySize, deepMap as arrayDeepMap, deepForEach as arrayDeepForEach } from './array.js';\nimport { _switch } from './switch.js';\n\n/**\n * Test whether an array contains collections\n * @param {Array} array\n * @returns {boolean} Returns true when the array contains one or multiple\n * collections (Arrays or Matrices). Returns false otherwise.\n */\nexport function containsCollections(array) {\n for (var i = 0; i < array.length; i++) {\n if (isCollection(array[i])) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Recursively loop over all elements in a given multi dimensional array\n * and invoke the callback on each of the elements.\n * @param {Array | Matrix} array\n * @param {Function} callback The callback method is invoked with one\n * parameter: the current element in the array\n */\nexport function deepForEach(array, callback) {\n if (isMatrix(array)) {\n array.forEach(x => callback(x), false, true);\n } else {\n arrayDeepForEach(array, callback, true);\n }\n}\n\n/**\n * Execute the callback function element wise for each element in array and any\n * nested array\n * Returns an array with the results\n * @param {Array | Matrix} array\n * @param {Function} callback The callback is called with two parameters:\n * value1 and value2, which contain the current\n * element of both arrays.\n * @param {boolean} [skipZeros] Invoke callback function for non-zero values only.\n *\n * @return {Array | Matrix} res\n */\nexport function deepMap(array, callback, skipZeros) {\n if (!skipZeros) {\n if (isMatrix(array)) {\n return array.map(x => callback(x), false, true);\n } else {\n return arrayDeepMap(array, callback, true);\n }\n }\n var skipZerosCallback = x => x === 0 ? x : callback(x);\n if (isMatrix(array)) {\n return array.map(x => skipZerosCallback(x), false, true);\n } else {\n return arrayDeepMap(array, skipZerosCallback, true);\n }\n}\n\n/**\n * Reduce a given matrix or array to a new matrix or\n * array with one less dimension, applying the given\n * callback in the selected dimension.\n * @param {Array | Matrix} mat\n * @param {number} dim\n * @param {Function} callback\n * @return {Array | Matrix} res\n */\nexport function reduce(mat, dim, callback) {\n var size = Array.isArray(mat) ? arraySize(mat) : mat.size();\n if (dim < 0 || dim >= size.length) {\n // TODO: would be more clear when throwing a DimensionError here\n throw new IndexError(dim, size.length);\n }\n if (isMatrix(mat)) {\n return mat.create(_reduce(mat.valueOf(), dim, callback), mat.datatype());\n } else {\n return _reduce(mat, dim, callback);\n }\n}\n\n/**\n * Recursively reduce a matrix\n * @param {Array} mat\n * @param {number} dim\n * @param {Function} callback\n * @returns {Array} ret\n * @private\n */\nfunction _reduce(mat, dim, callback) {\n var i, ret, val, tran;\n if (dim <= 0) {\n if (!Array.isArray(mat[0])) {\n val = mat[0];\n for (i = 1; i < mat.length; i++) {\n val = callback(val, mat[i]);\n }\n return val;\n } else {\n tran = _switch(mat);\n ret = [];\n for (i = 0; i < tran.length; i++) {\n ret[i] = _reduce(tran[i], dim - 1, callback);\n }\n return ret;\n }\n } else {\n ret = [];\n for (i = 0; i < mat.length; i++) {\n ret[i] = _reduce(mat[i], dim - 1, callback);\n }\n return ret;\n }\n}\n\n// TODO: document function scatter\nexport function scatter(a, j, w, x, u, mark, cindex, f, inverse, update, value) {\n // a arrays\n var avalues = a._values;\n var aindex = a._index;\n var aptr = a._ptr;\n\n // vars\n var k, k0, k1, i;\n\n // check we need to process values (pattern matrix)\n if (x) {\n // values in j\n for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {\n // row\n i = aindex[k];\n // check value exists in current j\n if (w[i] !== mark) {\n // i is new entry in j\n w[i] = mark;\n // add i to pattern of C\n cindex.push(i);\n // x(i) = A, check we need to call function this time\n if (update) {\n // copy value to workspace calling callback function\n x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]);\n // function was called on current row\n u[i] = mark;\n } else {\n // copy value to workspace\n x[i] = avalues[k];\n }\n } else {\n // i exists in C already\n x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]);\n // function was called on current row\n u[i] = mark;\n }\n }\n } else {\n // values in j\n for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {\n // row\n i = aindex[k];\n // check value exists in current j\n if (w[i] !== mark) {\n // i is new entry in j\n w[i] = mark;\n // add i to pattern of C\n cindex.push(i);\n } else {\n // indicate function was called on current row\n u[i] = mark;\n }\n }\n }\n}","// (c) 2018, Mariusz Nowak\n// SPDX-License-Identifier: ISC\n// Derived from https://github.com/medikoo/lru-queue\nexport function lruQueue(limit) {\n var size = 0;\n var base = 1;\n var queue = Object.create(null);\n var map = Object.create(null);\n var index = 0;\n var del = function del(id) {\n var oldIndex = map[id];\n if (!oldIndex) return;\n delete queue[oldIndex];\n delete map[id];\n --size;\n if (base !== oldIndex) return;\n if (!size) {\n index = 0;\n base = 1;\n return;\n }\n while (!Object.prototype.hasOwnProperty.call(queue, ++base)) {/* empty */}\n };\n limit = Math.abs(limit);\n return {\n hit: function hit(id) {\n var oldIndex = map[id];\n var nuIndex = ++index;\n queue[nuIndex] = id;\n map[id] = nuIndex;\n if (!oldIndex) {\n ++size;\n if (size <= limit) return undefined;\n id = queue[base];\n del(id);\n return id;\n }\n delete queue[oldIndex];\n if (base !== oldIndex) return undefined;\n while (!Object.prototype.hasOwnProperty.call(queue, ++base)) {/* empty */}\n return undefined;\n },\n delete: del,\n clear: function clear() {\n size = index = 0;\n base = 1;\n queue = Object.create(null);\n map = Object.create(null);\n }\n };\n}","// function utils\n\nimport { lruQueue } from './lruQueue.js';\n\n/**\n * Memoize a given function by caching the computed result.\n * The cache of a memoized function can be cleared by deleting the `cache`\n * property of the function.\n *\n * @param {function} fn The function to be memoized.\n * Must be a pure function.\n * @param {Object} [options]\n * @param {function(args: Array): string} [options.hasher]\n * A custom hash builder. Is JSON.stringify by default.\n * @param {number | undefined} [options.limit]\n * Maximum number of values that may be cached. Undefined indicates\n * unlimited (default)\n * @return {function} Returns the memoized function\n */\nexport function memoize(fn) {\n var {\n hasher,\n limit\n } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n limit = limit == null ? Number.POSITIVE_INFINITY : limit;\n hasher = hasher == null ? JSON.stringify : hasher;\n return function memoize() {\n if (typeof memoize.cache !== 'object') {\n memoize.cache = {\n values: new Map(),\n lru: lruQueue(limit || Number.POSITIVE_INFINITY)\n };\n }\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args[i] = arguments[i];\n }\n var hash = hasher(args);\n if (memoize.cache.values.has(hash)) {\n memoize.cache.lru.hit(hash);\n return memoize.cache.values.get(hash);\n }\n var newVal = fn.apply(fn, args);\n memoize.cache.values.set(hash, newVal);\n memoize.cache.values.delete(memoize.cache.lru.hit(hash));\n return newVal;\n };\n}\n\n/**\n * Memoize a given function by caching all results and the arguments,\n * and comparing against the arguments of previous results before\n * executing again.\n * This is less performant than `memoize` which calculates a hash,\n * which is very fast to compare. Use `memoizeCompare` only when it is\n * not possible to create a unique serializable hash from the function\n * arguments.\n * The isEqual function must compare two sets of arguments\n * and return true when equal (can be a deep equality check for example).\n * @param {function} fn\n * @param {function(a: *, b: *) : boolean} isEqual\n * @returns {function}\n */\nexport function memoizeCompare(fn, isEqual) {\n var memoize = function memoize() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args[i] = arguments[i];\n }\n for (var c = 0; c < memoize.cache.length; c++) {\n var cached = memoize.cache[c];\n if (isEqual(args, cached.args)) {\n // TODO: move this cache entry to the top so recently used entries move up?\n return cached.res;\n }\n }\n var res = fn.apply(fn, args);\n memoize.cache.unshift({\n args,\n res\n });\n return res;\n };\n memoize.cache = [];\n return memoize;\n}","import { memoize } from '../function.js';\n\n/**\n * Calculate BigNumber e\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns e\n */\nexport var createBigNumberE = memoize(function (BigNumber) {\n return new BigNumber(1).exp();\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber golden ratio, phi = (1+sqrt(5))/2\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns phi\n */\nexport var createBigNumberPhi = memoize(function (BigNumber) {\n return new BigNumber(1).plus(new BigNumber(5).sqrt()).div(2);\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber pi.\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns pi\n */\nexport var createBigNumberPi = memoize(function (BigNumber) {\n return BigNumber.acos(-1);\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber tau, tau = 2 * pi\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns tau\n */\nexport var createBigNumberTau = memoize(function (BigNumber) {\n return createBigNumberPi(BigNumber).times(2);\n}, {\n hasher\n});\n\n/**\n * Create a hash for a BigNumber constructor function. The created has is\n * the configured precision\n * @param {Array} args Supposed to contain a single entry with\n * a BigNumber constructor\n * @return {number} precision\n * @private\n */\nfunction hasher(args) {\n return args[0].precision;\n}","import { factory } from './utils/factory.js';\nimport { version } from './version.js';\nimport { createBigNumberE, createBigNumberPhi, createBigNumberPi, createBigNumberTau } from './utils/bignumber/constants.js';\nimport { pi, tau, e, phi } from './plain/number/index.js';\nexport var createTrue = /* #__PURE__ */factory('true', [], () => true);\nexport var createFalse = /* #__PURE__ */factory('false', [], () => false);\nexport var createNull = /* #__PURE__ */factory('null', [], () => null);\nexport var createInfinity = /* #__PURE__ */recreateFactory('Infinity', ['config', '?BigNumber'], _ref => {\n var {\n config,\n BigNumber\n } = _ref;\n return config.number === 'BigNumber' ? new BigNumber(Infinity) : Infinity;\n});\nexport var createNaN = /* #__PURE__ */recreateFactory('NaN', ['config', '?BigNumber'], _ref2 => {\n var {\n config,\n BigNumber\n } = _ref2;\n return config.number === 'BigNumber' ? new BigNumber(NaN) : NaN;\n});\nexport var createPi = /* #__PURE__ */recreateFactory('pi', ['config', '?BigNumber'], _ref3 => {\n var {\n config,\n BigNumber\n } = _ref3;\n return config.number === 'BigNumber' ? createBigNumberPi(BigNumber) : pi;\n});\nexport var createTau = /* #__PURE__ */recreateFactory('tau', ['config', '?BigNumber'], _ref4 => {\n var {\n config,\n BigNumber\n } = _ref4;\n return config.number === 'BigNumber' ? createBigNumberTau(BigNumber) : tau;\n});\nexport var createE = /* #__PURE__ */recreateFactory('e', ['config', '?BigNumber'], _ref5 => {\n var {\n config,\n BigNumber\n } = _ref5;\n return config.number === 'BigNumber' ? createBigNumberE(BigNumber) : e;\n});\n\n// golden ratio, (1+sqrt(5))/2\nexport var createPhi = /* #__PURE__ */recreateFactory('phi', ['config', '?BigNumber'], _ref6 => {\n var {\n config,\n BigNumber\n } = _ref6;\n return config.number === 'BigNumber' ? createBigNumberPhi(BigNumber) : phi;\n});\nexport var createLN2 = /* #__PURE__ */recreateFactory('LN2', ['config', '?BigNumber'], _ref7 => {\n var {\n config,\n BigNumber\n } = _ref7;\n return config.number === 'BigNumber' ? new BigNumber(2).ln() : Math.LN2;\n});\nexport var createLN10 = /* #__PURE__ */recreateFactory('LN10', ['config', '?BigNumber'], _ref8 => {\n var {\n config,\n BigNumber\n } = _ref8;\n return config.number === 'BigNumber' ? new BigNumber(10).ln() : Math.LN10;\n});\nexport var createLOG2E = /* #__PURE__ */recreateFactory('LOG2E', ['config', '?BigNumber'], _ref9 => {\n var {\n config,\n BigNumber\n } = _ref9;\n return config.number === 'BigNumber' ? new BigNumber(1).div(new BigNumber(2).ln()) : Math.LOG2E;\n});\nexport var createLOG10E = /* #__PURE__ */recreateFactory('LOG10E', ['config', '?BigNumber'], _ref0 => {\n var {\n config,\n BigNumber\n } = _ref0;\n return config.number === 'BigNumber' ? new BigNumber(1).div(new BigNumber(10).ln()) : Math.LOG10E;\n});\nexport var createSQRT1_2 = /* #__PURE__ */recreateFactory(\n// eslint-disable-line camelcase\n'SQRT1_2', ['config', '?BigNumber'], _ref1 => {\n var {\n config,\n BigNumber\n } = _ref1;\n return config.number === 'BigNumber' ? new BigNumber('0.5').sqrt() : Math.SQRT1_2;\n});\nexport var createSQRT2 = /* #__PURE__ */recreateFactory('SQRT2', ['config', '?BigNumber'], _ref10 => {\n var {\n config,\n BigNumber\n } = _ref10;\n return config.number === 'BigNumber' ? new BigNumber(2).sqrt() : Math.SQRT2;\n});\nexport var createI = /* #__PURE__ */recreateFactory('i', ['Complex'], _ref11 => {\n var {\n Complex\n } = _ref11;\n return Complex.I;\n});\n\n// for backward compatibility with v5\nexport var createUppercasePi = /* #__PURE__ */factory('PI', ['pi'], _ref12 => {\n var {\n pi\n } = _ref12;\n return pi;\n});\nexport var createUppercaseE = /* #__PURE__ */factory('E', ['e'], _ref13 => {\n var {\n e\n } = _ref13;\n return e;\n});\nexport var createVersion = /* #__PURE__ */factory('version', [], () => version);\n\n// helper function to create a factory with a flag recreateOnConfigChange\n// idea: allow passing optional properties to be attached to the factory function as 4th argument?\nfunction recreateFactory(name, dependencies, create) {\n return factory(name, dependencies, create, {\n recreateOnConfigChange: true\n });\n}","import { factory } from '../utils/factory.js';\nimport { deepMap } from '../utils/collection.js';\nvar name = 'number';\nvar dependencies = ['typed'];\n\n/**\n * Separates the radix, integer part, and fractional part of a non decimal number string\n * @param {string} input string to parse\n * @returns {object} the parts of the string or null if not a valid input\n */\nfunction getNonDecimalNumberParts(input) {\n var nonDecimalWithRadixMatch = input.match(/(0[box])([0-9a-fA-F]*)\\.([0-9a-fA-F]*)/);\n if (nonDecimalWithRadixMatch) {\n var radix = {\n '0b': 2,\n '0o': 8,\n '0x': 16\n }[nonDecimalWithRadixMatch[1]];\n var integerPart = nonDecimalWithRadixMatch[2];\n var fractionalPart = nonDecimalWithRadixMatch[3];\n return {\n input,\n radix,\n integerPart,\n fractionalPart\n };\n } else {\n return null;\n }\n}\n\n/**\n * Makes a number from a radix, and integer part, and a fractional part\n * @param {parts} [x] parts of the number string (from getNonDecimalNumberParts)\n * @returns {number} the number\n */\nfunction makeNumberFromNonDecimalParts(parts) {\n var n = parseInt(parts.integerPart, parts.radix);\n var f = 0;\n for (var i = 0; i < parts.fractionalPart.length; i++) {\n var digitValue = parseInt(parts.fractionalPart[i], parts.radix);\n f += digitValue / Math.pow(parts.radix, i + 1);\n }\n var result = n + f;\n if (isNaN(result)) {\n throw new SyntaxError('String \"' + parts.input + '\" is not a valid number');\n }\n return result;\n}\nexport var createNumber = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Create a number or convert a string, boolean, or unit to a number.\n * When value is a matrix, all elements will be converted to number.\n *\n * Syntax:\n *\n * math.number(value)\n * math.number(unit, valuelessUnit)\n *\n * Examples:\n *\n * math.number(2) // returns number 2\n * math.number('7.2') // returns number 7.2\n * math.number(true) // returns number 1\n * math.number([true, false, true, true]) // returns [1, 0, 1, 1]\n * math.number(math.unit('52cm'), 'm') // returns 0.52\n *\n * See also:\n *\n * bignumber, bigint, boolean, numeric, complex, index, matrix, string, unit\n *\n * @param {string | number | BigNumber | Fraction | boolean | Array | Matrix | Unit | null} [value] Value to be converted\n * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number\n * @return {number | Array | Matrix} The created number\n */\n var number = typed('number', {\n '': function _() {\n return 0;\n },\n number: function number(x) {\n return x;\n },\n string: function string(x) {\n if (x === 'NaN') return NaN;\n var nonDecimalNumberParts = getNonDecimalNumberParts(x);\n if (nonDecimalNumberParts) {\n return makeNumberFromNonDecimalParts(nonDecimalNumberParts);\n }\n var size = 0;\n var wordSizeSuffixMatch = x.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);\n if (wordSizeSuffixMatch) {\n // x includes a size suffix like 0xffffi32, so we extract\n // the suffix and remove it from x\n size = Number(wordSizeSuffixMatch[2]);\n x = wordSizeSuffixMatch[1];\n }\n var num = Number(x);\n if (isNaN(num)) {\n throw new SyntaxError('String \"' + x + '\" is not a valid number');\n }\n if (wordSizeSuffixMatch) {\n // x is a signed bin, oct, or hex literal\n // num is the value of string x if x is interpreted as unsigned\n if (num > 2 ** size - 1) {\n // literal is too large for size suffix\n throw new SyntaxError(\"String \\\"\".concat(x, \"\\\" is out of range\"));\n }\n // check if the bit at index size - 1 is set and if so do the twos complement\n if (num >= 2 ** (size - 1)) {\n num = num - 2 ** size;\n }\n }\n return num;\n },\n BigNumber: function BigNumber(x) {\n return x.toNumber();\n },\n bigint: function bigint(x) {\n return Number(x);\n },\n Fraction: function Fraction(x) {\n return x.valueOf();\n },\n Unit: typed.referToSelf(self => x => {\n var clone = x.clone();\n clone.value = self(x.value);\n return clone;\n }),\n null: function _null(x) {\n return 0;\n },\n 'Unit, string | Unit': function Unit_string__Unit(unit, valuelessUnit) {\n return unit.toNumber(valuelessUnit);\n },\n 'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))\n });\n\n // reviver function to parse a JSON object like:\n //\n // {\"mathjs\":\"number\",\"value\":\"2.3\"}\n //\n // into a number 2.3\n number.fromJSON = function (json) {\n return parseFloat(json.value);\n };\n return number;\n});","// Reserved keywords not allowed to use in the parser\nexport var keywords = new Set(['end']);","import { isNode } from '../../utils/is.js';\nimport { keywords } from '../keywords.js';\nimport { deepStrictEqual } from '../../utils/object.js';\nimport { factory } from '../../utils/factory.js';\nimport { createMap } from '../../utils/map.js';\nvar name = 'Node';\nvar dependencies = ['mathWithTransform'];\nexport var createNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n mathWithTransform\n } = _ref;\n /**\n * Validate the symbol names of a scope.\n * Throws an error when the scope contains an illegal symbol.\n * @param {Object} scope\n */\n function _validateScope(scope) {\n for (var symbol of [...keywords]) {\n if (scope.has(symbol)) {\n throw new Error('Scope contains an illegal symbol, \"' + symbol + '\" is a reserved keyword');\n }\n }\n }\n class Node {\n get type() {\n return 'Node';\n }\n get isNode() {\n return true;\n }\n\n /**\n * Evaluate the node\n * @param {Object} [scope] Scope to read/write variables\n * @return {*} Returns the result\n */\n evaluate(scope) {\n return this.compile().evaluate(scope);\n }\n\n /**\n * Compile the node into an optimized, evauatable JavaScript function\n * @return {{evaluate: function([Object])}} object\n * Returns an object with a function 'evaluate',\n * which can be invoked as expr.evaluate([scope: Object]),\n * where scope is an optional object with\n * variables.\n */\n compile() {\n var expr = this._compile(mathWithTransform, {});\n var args = {};\n var context = null;\n function evaluate(scope) {\n var s = createMap(scope);\n _validateScope(s);\n return expr(s, args, context);\n }\n return {\n evaluate\n };\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n throw new Error('Method _compile must be implemented by type ' + this.type);\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot run forEach on a Node interface');\n }\n\n /**\n * Create a new Node whose children are the results of calling the\n * provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {OperatorNode} Returns a transformed copy of the node\n */\n map(callback) {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot run map on a Node interface');\n }\n\n /**\n * Validate whether an object is a Node, for use with map\n * @param {Node} node\n * @returns {Node} Returns the input if it's a node, else throws an Error\n * @protected\n */\n _ifNode(node) {\n if (!isNode(node)) {\n throw new TypeError('Callback function must return a Node');\n }\n return node;\n }\n\n /**\n * Recursively traverse all nodes in a node tree. Executes given callback for\n * this node and each of its child nodes.\n * @param {function(node: Node, path: string, parent: Node)} callback\n * A callback called for every node in the node tree.\n */\n traverse(callback) {\n // execute callback for itself\n // eslint-disable-next-line\n callback(this, null, null);\n\n // recursively traverse over all children of a node\n function _traverse(node, callback) {\n node.forEach(function (child, path, parent) {\n callback(child, path, parent);\n _traverse(child, callback);\n });\n }\n _traverse(this, callback);\n }\n\n /**\n * Recursively transform a node tree via a transform function.\n *\n * For example, to replace all nodes of type SymbolNode having name 'x' with\n * a ConstantNode with value 2:\n *\n * const res = Node.transform(function (node, path, parent) {\n * if (node && node.isSymbolNode) && (node.name === 'x')) {\n * return new ConstantNode(2)\n * }\n * else {\n * return node\n * }\n * })\n *\n * @param {function(node: Node, path: string, parent: Node) : Node} callback\n * A mapping function accepting a node, and returning\n * a replacement for the node or the original node. The \"signature\"\n * of the callback must be:\n * callback(node: Node, index: string, parent: Node) : Node\n * @return {Node} Returns the original node or its replacement\n */\n transform(callback) {\n function _transform(child, path, parent) {\n var replacement = callback(child, path, parent);\n if (replacement !== child) {\n // stop iterating when the node is replaced\n return replacement;\n }\n return child.map(_transform);\n }\n return _transform(this, null, null);\n }\n\n /**\n * Find any node in the node tree matching given filter function. For\n * example, to find all nodes of type SymbolNode having name 'x':\n *\n * const results = Node.filter(function (node) {\n * return (node && node.isSymbolNode) && (node.name === 'x')\n * })\n *\n * @param {function(node: Node, path: string, parent: Node) : Node} callback\n * A test function returning true when a node matches, and false\n * otherwise. Function signature:\n * callback(node: Node, index: string, parent: Node) : boolean\n * @return {Node[]} nodes\n * An array with nodes matching given filter criteria\n */\n filter(callback) {\n var nodes = [];\n this.traverse(function (node, path, parent) {\n if (callback(node, path, parent)) {\n nodes.push(node);\n }\n });\n return nodes;\n }\n\n /**\n * Create a shallow clone of this node\n * @return {Node}\n */\n clone() {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot clone a Node interface');\n }\n\n /**\n * Create a deep clone of this node\n * @return {Node}\n */\n cloneDeep() {\n return this.map(function (node) {\n return node.cloneDeep();\n });\n }\n\n /**\n * Deep compare this node with another node.\n * @param {Node} other\n * @return {boolean} Returns true when both nodes are of the same type and\n * contain the same values (as do their childs)\n */\n equals(other) {\n return other ? this.type === other.type && deepStrictEqual(this, other) : false;\n }\n\n /**\n * Get string representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\"or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toString(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toString(options);\n }\n\n /**\n * Internal function to generate the string output.\n * This has to be implemented by every Node\n *\n * @throws {Error}\n */\n _toString() {\n // must be implemented by each of the Node implementations\n throw new Error('_toString not implemented for ' + this.type);\n }\n\n /**\n * Get a JSON representation of the node\n * Both .toJSON() and the static .fromJSON(json) should be implemented by all\n * implementations of Node\n * @returns {Object}\n */\n toJSON() {\n throw new Error('Cannot serialize object: toJSON not implemented by ' + this.type);\n }\n\n /**\n * Get HTML representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\" or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toHTML(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toHTML(options);\n }\n\n /**\n * Internal function to generate the HTML output.\n * This has to be implemented by every Node\n *\n * @throws {Error}\n */\n _toHTML() {\n // must be implemented by each of the Node implementations\n throw new Error('_toHTML not implemented for ' + this.type);\n }\n\n /**\n * Get LaTeX representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\"or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toTex(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toTex(options);\n }\n\n /**\n * Internal function to generate the LaTeX output.\n * This has to be implemented by every Node\n *\n * @param {Object} [options]\n * @throws {Error}\n */\n _toTex(options) {\n // must be implemented by each of the Node implementations\n throw new Error('_toTex not implemented for ' + this.type);\n }\n\n /**\n * Helper used by `to...` functions.\n */\n _getCustomString(options) {\n if (options && typeof options === 'object') {\n switch (typeof options.handler) {\n case 'object':\n case 'undefined':\n return;\n case 'function':\n return options.handler(this, options);\n default:\n throw new TypeError('Object or function expected as callback');\n }\n }\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type;\n }\n\n /**\n * Get the content of the current Node.\n * @return {Node} node\n **/\n getContent() {\n return this;\n }\n }\n return Node;\n}, {\n isClass: true,\n isNode: true\n});","import { IndexError } from '../../../error/IndexError.js';\n\n/**\n * Transform zero-based indices to one-based indices in errors\n * @param {Error} err\n * @returns {Error | IndexError} Returns the transformed error\n */\nexport function errorTransform(err) {\n if (err && err.isIndexError) {\n return new IndexError(err.index + 1, err.min + 1, err.max !== undefined ? err.max + 1 : undefined);\n }\n return err;\n}","import { errorTransform } from '../../transform/utils/errorTransform.js';\nimport { getSafeProperty } from '../../../utils/customs.js';\nexport function accessFactory(_ref) {\n var {\n subset\n } = _ref;\n /**\n * Retrieve part of an object:\n *\n * - Retrieve a property from an object\n * - Retrieve a part of a string\n * - Retrieve a matrix subset\n *\n * @param {Object | Array | Matrix | string} object\n * @param {Index} index\n * @return {Object | Array | Matrix | string} Returns the subset\n */\n return function access(object, index) {\n try {\n if (Array.isArray(object)) {\n return subset(object, index);\n } else if (object && typeof object.subset === 'function') {\n // Matrix\n return object.subset(index);\n } else if (typeof object === 'string') {\n // TODO: move getStringSubset into a separate util file, use that\n return subset(object, index);\n } else if (typeof object === 'object') {\n if (!index.isObjectProperty()) {\n throw new TypeError('Cannot apply a numeric index as object property');\n }\n return getSafeProperty(object, index.getObjectProperty());\n } else {\n throw new TypeError('Cannot apply index: unsupported type of object');\n }\n } catch (err) {\n throw errorTransform(err);\n }\n };\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isArrayNode, isConstantNode, isFunctionNode, isIndexNode, isNode, isObjectNode, isParenthesisNode, isSymbolNode } from '../../utils/is.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { accessFactory } from './utils/access.js';\nvar name = 'AccessorNode';\nvar dependencies = ['subset', 'Node'];\nexport var createAccessorNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n subset,\n Node\n } = _ref;\n var access = accessFactory({\n subset\n });\n\n /**\n * Are parenthesis needed?\n * @private\n */\n function needParenthesis(node) {\n // TODO: maybe make a method on the nodes which tells whether they need parenthesis?\n return !(isAccessorNode(node) || isArrayNode(node) || isConstantNode(node) || isFunctionNode(node) || isObjectNode(node) || isParenthesisNode(node) || isSymbolNode(node));\n }\n class AccessorNode extends Node {\n /**\n * @constructor AccessorNode\n * @extends {Node}\n * Access an object property or get a matrix subset\n *\n * @param {Node} object The object from which to retrieve\n * a property or subset.\n * @param {IndexNode} index IndexNode containing ranges\n * @param {boolean} [optionalChaining=false]\n * Optional property, if the accessor was written as optional-chaining\n * using `a?.b`, or `a?.[\"b\"] with bracket notation.\n * Forces evaluate to undefined if the given object is undefined or null.\n */\n constructor(object, index) {\n var optionalChaining = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n super();\n if (!isNode(object)) {\n throw new TypeError('Node expected for parameter \"object\"');\n }\n if (!isIndexNode(index)) {\n throw new TypeError('IndexNode expected for parameter \"index\"');\n }\n this.object = object;\n this.index = index;\n this.optionalChaining = optionalChaining;\n }\n\n // readonly property name\n get name() {\n if (this.index) {\n return this.index.isObjectProperty() ? this.index.getObjectProperty() : '';\n } else {\n return this.object.name || '';\n }\n }\n get type() {\n return name;\n }\n get isAccessorNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalObject = this.object._compile(math, argNames);\n var evalIndex = this.index._compile(math, argNames);\n var optionalChaining = this.optionalChaining;\n var prevOptionalChaining = isAccessorNode(this.object) && this.object.optionalChaining;\n if (this.index.isObjectProperty()) {\n var prop = this.index.getObjectProperty();\n return function evalAccessorNode(scope, args, context) {\n var ctx = context || {};\n var object = evalObject(scope, args, ctx);\n if (optionalChaining && object == null) {\n ctx.optionalShortCircuit = true;\n return undefined;\n }\n if (prevOptionalChaining && ctx !== null && ctx !== void 0 && ctx.optionalShortCircuit) {\n return undefined;\n }\n\n // get a property from an object evaluated using the scope.\n return getSafeProperty(object, prop);\n };\n } else {\n return function evalAccessorNode(scope, args, context) {\n var ctx = context || {};\n var object = evalObject(scope, args, ctx);\n if (optionalChaining && object == null) {\n ctx.optionalShortCircuit = true;\n return undefined;\n }\n if (prevOptionalChaining && ctx !== null && ctx !== void 0 && ctx.optionalShortCircuit) {\n return undefined;\n }\n\n // we pass just object here instead of context:\n var index = evalIndex(scope, args, object);\n return access(object, index);\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.object, 'object', this);\n callback(this.index, 'index', this);\n }\n\n /**\n * Create a new AccessorNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {AccessorNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new AccessorNode(this._ifNode(callback(this.object, 'object', this)), this._ifNode(callback(this.index, 'index', this)), this.optionalChaining);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {AccessorNode}\n */\n clone() {\n return new AccessorNode(this.object, this.index, this.optionalChaining);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string}\n */\n _toString(options) {\n var object = this.object.toString(options);\n if (needParenthesis(this.object)) {\n object = '(' + object + ')';\n }\n var optionalChaining = this.optionalChaining ? this.index.dotNotation ? '?' : '?.' : '';\n return object + optionalChaining + this.index.toString(options);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string}\n */\n _toHTML(options) {\n var object = this.object.toHTML(options);\n if (needParenthesis(this.object)) {\n object = '(' + object + ')';\n }\n return object + this.index.toHTML(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string}\n */\n _toTex(options) {\n var object = this.object.toTex(options);\n if (needParenthesis(this.object)) {\n object = '\\\\left(\\' + object + \\'\\\\right)';\n }\n return object + this.index.toTex(options);\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n object: this.object,\n index: this.index,\n optionalChaining: this.optionalChaining\n };\n }\n\n /**\n * Instantiate an AccessorNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"AccessorNode\", object: ..., index: ...}`,\n * where mathjs is optional\n * @returns {AccessorNode}\n */\n static fromJSON(json) {\n return new AccessorNode(json.object, json.index, json.optionalChaining);\n }\n }\n _defineProperty(AccessorNode, \"name\", name);\n return AccessorNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isArrayNode, isNode } from '../../utils/is.js';\nimport { map } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ArrayNode';\nvar dependencies = ['Node'];\nexport var createArrayNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ArrayNode extends Node {\n /**\n * @constructor ArrayNode\n * @extends {Node}\n * Holds an 1-dimensional array with items\n * @param {Node[]} [items] 1 dimensional array with items\n */\n constructor(items) {\n super();\n this.items = items || [];\n\n // validate input\n if (!Array.isArray(this.items) || !this.items.every(isNode)) {\n throw new TypeError('Array containing Nodes expected');\n }\n }\n get type() {\n return name;\n }\n get isArrayNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalItems = map(this.items, function (item) {\n return item._compile(math, argNames);\n });\n var asMatrix = math.config.matrix !== 'Array';\n if (asMatrix) {\n var matrix = math.matrix;\n return function evalArrayNode(scope, args, context) {\n return matrix(map(evalItems, function (evalItem) {\n return evalItem(scope, args, context);\n }));\n };\n } else {\n return function evalArrayNode(scope, args, context) {\n return map(evalItems, function (evalItem) {\n return evalItem(scope, args, context);\n });\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.items.length; i++) {\n var node = this.items[i];\n callback(node, 'items[' + i + ']', this);\n }\n }\n\n /**\n * Create a new ArrayNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ArrayNode} Returns a transformed copy of the node\n */\n map(callback) {\n var items = [];\n for (var i = 0; i < this.items.length; i++) {\n items[i] = this._ifNode(callback(this.items[i], 'items[' + i + ']', this));\n }\n return new ArrayNode(items);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ArrayNode}\n */\n clone() {\n return new ArrayNode(this.items.slice(0));\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n var items = this.items.map(function (node) {\n return node.toString(options);\n });\n return '[' + items.join(', ') + ']';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n items: this.items\n };\n }\n\n /**\n * Instantiate an ArrayNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ArrayNode\", items: [...]}`,\n * where mathjs is optional\n * @returns {ArrayNode}\n */\n static fromJSON(json) {\n return new ArrayNode(json.items);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var items = this.items.map(function (node) {\n return node.toHTML(options);\n });\n return '[' + items.join(',') + ']';\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n function itemsToTex(items, nested) {\n var mixedItems = items.some(isArrayNode) && !items.every(isArrayNode);\n var itemsFormRow = nested || mixedItems;\n var itemSep = itemsFormRow ? '&' : '\\\\\\\\';\n var itemsTex = items.map(function (node) {\n if (node.items) {\n return itemsToTex(node.items, !nested);\n } else {\n return node.toTex(options);\n }\n }).join(itemSep);\n return mixedItems || !itemsFormRow || itemsFormRow && !nested ? '\\\\begin{bmatrix}' + itemsTex + '\\\\end{bmatrix}' : itemsTex;\n }\n return itemsToTex(this.items, false);\n }\n }\n _defineProperty(ArrayNode, \"name\", name);\n return ArrayNode;\n}, {\n isClass: true,\n isNode: true\n});","import { errorTransform } from '../../transform/utils/errorTransform.js';\nimport { setSafeProperty } from '../../../utils/customs.js';\nexport function assignFactory(_ref) {\n var {\n subset,\n matrix\n } = _ref;\n /**\n * Replace part of an object:\n *\n * - Assign a property to an object\n * - Replace a part of a string\n * - Replace a matrix subset\n *\n * @param {Object | Array | Matrix | string} object\n * @param {Index} index\n * @param {*} value\n * @return {Object | Array | Matrix | string} Returns the original object\n * except in case of a string\n */\n // TODO: change assign to return the value instead of the object\n return function assign(object, index, value) {\n try {\n if (Array.isArray(object)) {\n var result = matrix(object).subset(index, value).valueOf();\n\n // shallow copy all (updated) items into the original array\n result.forEach((item, index) => {\n object[index] = item;\n });\n return object;\n } else if (object && typeof object.subset === 'function') {\n // Matrix\n return object.subset(index, value);\n } else if (typeof object === 'string') {\n // TODO: move setStringSubset into a separate util file, use that\n return subset(object, index, value);\n } else if (typeof object === 'object') {\n if (!index.isObjectProperty()) {\n throw TypeError('Cannot apply a numeric index as object property');\n }\n setSafeProperty(object, index.getObjectProperty(), value);\n return object;\n } else {\n throw new TypeError('Cannot apply index: unsupported type of object');\n }\n } catch (err) {\n throw errorTransform(err);\n }\n };\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';\nimport { getSafeProperty, setSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { accessFactory } from './utils/access.js';\nimport { assignFactory } from './utils/assign.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'AssignmentNode';\nvar dependencies = ['subset', '?matrix',\n// FIXME: should not be needed at all, should be handled by subset\n'Node'];\nexport var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n subset,\n matrix,\n Node\n } = _ref;\n var access = accessFactory({\n subset\n });\n var assign = assignFactory({\n subset,\n matrix\n });\n\n /*\n * Is parenthesis needed?\n * @param {node} node\n * @param {string} [parenthesis='keep']\n * @param {string} implicit\n * @private\n */\n function needParenthesis(node, parenthesis, implicit) {\n if (!parenthesis) {\n parenthesis = 'keep';\n }\n var precedence = getPrecedence(node, parenthesis, implicit);\n var exprPrecedence = getPrecedence(node.value, parenthesis, implicit);\n return parenthesis === 'all' || exprPrecedence !== null && exprPrecedence <= precedence;\n }\n class AssignmentNode extends Node {\n /**\n * @constructor AssignmentNode\n * @extends {Node}\n *\n * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or\n * replace a subset of a matrix like `A[2,2]=42`.\n *\n * Syntax:\n *\n * new AssignmentNode(symbol, value)\n * new AssignmentNode(object, index, value)\n *\n * Usage:\n *\n * new AssignmentNode(new SymbolNode('a'), new ConstantNode(2)) // a=2\n * new AssignmentNode(new SymbolNode('a'),\n * new IndexNode('b'),\n * new ConstantNode(2)) // a.b=2\n * new AssignmentNode(new SymbolNode('a'),\n * new IndexNode(1, 2),\n * new ConstantNode(3)) // a[1,2]=3\n *\n * @param {SymbolNode | AccessorNode} object\n * Object on which to assign a value\n * @param {IndexNode} [index=null]\n * Index, property name or matrix index. Optional. If not provided\n * and `object` is a SymbolNode, the property is assigned to the\n * global scope.\n * @param {Node} value\n * The value to be assigned\n */\n constructor(object, index, value) {\n super();\n this.object = object;\n this.index = value ? index : null;\n this.value = value || index;\n\n // validate input\n if (!isSymbolNode(object) && !isAccessorNode(object)) {\n throw new TypeError('SymbolNode or AccessorNode expected as \"object\"');\n }\n if (isSymbolNode(object) && object.name === 'end') {\n throw new Error('Cannot assign to symbol \"end\"');\n }\n if (this.index && !isIndexNode(this.index)) {\n // index is optional\n throw new TypeError('IndexNode expected as \"index\"');\n }\n if (!isNode(this.value)) {\n throw new TypeError('Node expected as \"value\"');\n }\n }\n\n // class name for typing purposes:\n\n // readonly property name\n get name() {\n if (this.index) {\n return this.index.isObjectProperty() ? this.index.getObjectProperty() : '';\n } else {\n return this.object.name || '';\n }\n }\n get type() {\n return name;\n }\n get isAssignmentNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalObject = this.object._compile(math, argNames);\n var evalIndex = this.index ? this.index._compile(math, argNames) : null;\n var evalValue = this.value._compile(math, argNames);\n var name = this.object.name;\n if (!this.index) {\n // apply a variable to the scope, for example `a=2`\n if (!isSymbolNode(this.object)) {\n throw new TypeError('SymbolNode expected as object');\n }\n return function evalAssignmentNode(scope, args, context) {\n var value = evalValue(scope, args, context);\n scope.set(name, value);\n return value;\n };\n } else if (this.index.isObjectProperty()) {\n // apply an object property for example `a.b=2`\n var prop = this.index.getObjectProperty();\n return function evalAssignmentNode(scope, args, context) {\n var object = evalObject(scope, args, context);\n var value = evalValue(scope, args, context);\n setSafeProperty(object, prop, value);\n return value;\n };\n } else if (isSymbolNode(this.object)) {\n // update a matrix subset, for example `a[2]=3`\n return function evalAssignmentNode(scope, args, context) {\n var childObject = evalObject(scope, args, context);\n var value = evalValue(scope, args, context);\n // Important: we pass childObject instead of context:\n var index = evalIndex(scope, args, childObject);\n scope.set(name, assign(childObject, index, value));\n return value;\n };\n } else {\n // isAccessorNode(node.object) === true\n // update a matrix subset, for example `a.b[2]=3`\n\n // we will not use the compile function of the AccessorNode, but\n // compile it ourselves here as we need the parent object of the\n // AccessorNode:\n // wee need to apply the updated object to parent object\n var evalParentObject = this.object.object._compile(math, argNames);\n if (this.object.index.isObjectProperty()) {\n var parentProp = this.object.index.getObjectProperty();\n return function evalAssignmentNode(scope, args, context) {\n var parent = evalParentObject(scope, args, context);\n var childObject = getSafeProperty(parent, parentProp);\n // Important: we pass childObject instead of context:\n var index = evalIndex(scope, args, childObject);\n var value = evalValue(scope, args, context);\n setSafeProperty(parent, parentProp, assign(childObject, index, value));\n return value;\n };\n } else {\n // if some parameters use the 'end' parameter, we need to calculate\n // the size\n var evalParentIndex = this.object.index._compile(math, argNames);\n return function evalAssignmentNode(scope, args, context) {\n var parent = evalParentObject(scope, args, context);\n // Important: we pass parent instead of context:\n var parentIndex = evalParentIndex(scope, args, parent);\n var childObject = access(parent, parentIndex);\n // Important: we pass childObject instead of context\n var index = evalIndex(scope, args, childObject);\n var value = evalValue(scope, args, context);\n assign(parent, parentIndex, assign(childObject, index, value));\n return value;\n };\n }\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.object, 'object', this);\n if (this.index) {\n callback(this.index, 'index', this);\n }\n callback(this.value, 'value', this);\n }\n\n /**\n * Create a new AssignmentNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {AssignmentNode} Returns a transformed copy of the node\n */\n map(callback) {\n var object = this._ifNode(callback(this.object, 'object', this));\n var index = this.index ? this._ifNode(callback(this.index, 'index', this)) : null;\n var value = this._ifNode(callback(this.value, 'value', this));\n return new AssignmentNode(object, index, value);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {AssignmentNode}\n */\n clone() {\n return new AssignmentNode(this.object, this.index, this.value);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string}\n */\n _toString(options) {\n var object = this.object.toString(options);\n var index = this.index ? this.index.toString(options) : '';\n var value = this.value.toString(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = '(' + value + ')';\n }\n return object + index + ' = ' + value;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n object: this.object,\n index: this.index,\n value: this.value\n };\n }\n\n /**\n * Instantiate an AssignmentNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"AssignmentNode\", object: ..., index: ..., value: ...}`,\n * where mathjs is optional\n * @returns {AssignmentNode}\n */\n static fromJSON(json) {\n return new AssignmentNode(json.object, json.index, json.value);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string}\n */\n _toHTML(options) {\n var object = this.object.toHTML(options);\n var index = this.index ? this.index.toHTML(options) : '';\n var value = this.value.toHTML(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = '(' + value + ')';\n }\n return object + index + '=' + value;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string}\n */\n _toTex(options) {\n var object = this.object.toTex(options);\n var index = this.index ? this.index.toTex(options) : '';\n var value = this.value.toTex(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = \"\\\\left(\".concat(value, \"\\\\right)\");\n }\n return object + index + '=' + value;\n }\n }\n _defineProperty(AssignmentNode, \"name\", name);\n return AssignmentNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { forEach, map } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'BlockNode';\nvar dependencies = ['ResultSet', 'Node'];\nexport var createBlockNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n ResultSet,\n Node\n } = _ref;\n class BlockNode extends Node {\n /**\n * @constructor BlockNode\n * @extends {Node}\n * Holds a set with blocks\n * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks\n * An array with blocks, where a block is constructed as an\n * Object with properties block, which is a Node, and visible,\n * which is a boolean. The property visible is optional and\n * is true by default\n */\n constructor(blocks) {\n super();\n // validate input, copy blocks\n if (!Array.isArray(blocks)) throw new Error('Array expected');\n this.blocks = blocks.map(function (block) {\n var node = block && block.node;\n var visible = block && block.visible !== undefined ? block.visible : true;\n if (!isNode(node)) throw new TypeError('Property \"node\" must be a Node');\n if (typeof visible !== 'boolean') {\n throw new TypeError('Property \"visible\" must be a boolean');\n }\n return {\n node,\n visible\n };\n });\n }\n get type() {\n return name;\n }\n get isBlockNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalBlocks = map(this.blocks, function (block) {\n return {\n evaluate: block.node._compile(math, argNames),\n visible: block.visible\n };\n });\n return function evalBlockNodes(scope, args, context) {\n var results = [];\n forEach(evalBlocks, function evalBlockNode(block) {\n var result = block.evaluate(scope, args, context);\n if (block.visible) {\n results.push(result);\n }\n });\n return new ResultSet(results);\n };\n }\n\n /**\n * Execute a callback for each of the child blocks of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.blocks.length; i++) {\n callback(this.blocks[i].node, 'blocks[' + i + '].node', this);\n }\n }\n\n /**\n * Create a new BlockNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {BlockNode} Returns a transformed copy of the node\n */\n map(callback) {\n var blocks = [];\n for (var i = 0; i < this.blocks.length; i++) {\n var block = this.blocks[i];\n var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this));\n blocks[i] = {\n node,\n visible: block.visible\n };\n }\n return new BlockNode(blocks);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {BlockNode}\n */\n clone() {\n var blocks = this.blocks.map(function (block) {\n return {\n node: block.node,\n visible: block.visible\n };\n });\n return new BlockNode(blocks);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n return this.blocks.map(function (param) {\n return param.node.toString(options) + (param.visible ? '' : ';');\n }).join('\\n');\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n blocks: this.blocks\n };\n }\n\n /**\n * Instantiate an BlockNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"BlockNode\", blocks: [{node: ..., visible: false}, ...]}`,\n * where mathjs is optional\n * @returns {BlockNode}\n */\n static fromJSON(json) {\n return new BlockNode(json.blocks);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n return this.blocks.map(function (param) {\n return param.node.toHTML(options) + (param.visible ? '' : ';');\n }).join('
');\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n return this.blocks.map(function (param) {\n return param.node.toTex(options) + (param.visible ? '' : ';');\n }).join('\\\\;\\\\;\\n');\n }\n }\n _defineProperty(BlockNode, \"name\", name);\n return BlockNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isBigNumber, isComplex, isNode, isUnit, typeOf } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'ConditionalNode';\nvar dependencies = ['Node'];\nexport var createConditionalNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Test whether a condition is met\n * @param {*} condition\n * @returns {boolean} true if condition is true or non-zero, else false\n */\n function testCondition(condition) {\n if (typeof condition === 'number' || typeof condition === 'boolean' || typeof condition === 'string') {\n return !!condition;\n }\n if (condition) {\n if (isBigNumber(condition)) {\n return !condition.isZero();\n }\n if (isComplex(condition)) {\n return !!(condition.re || condition.im);\n }\n if (isUnit(condition)) {\n return !!condition.value;\n }\n }\n if (condition === null || condition === undefined) {\n return false;\n }\n throw new TypeError('Unsupported type of condition \"' + typeOf(condition) + '\"');\n }\n class ConditionalNode extends Node {\n /**\n * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr'\n *\n * @param {Node} condition Condition, must result in a boolean\n * @param {Node} trueExpr Expression evaluated when condition is true\n * @param {Node} falseExpr Expression evaluated when condition is true\n *\n * @constructor ConditionalNode\n * @extends {Node}\n */\n constructor(condition, trueExpr, falseExpr) {\n super();\n if (!isNode(condition)) {\n throw new TypeError('Parameter condition must be a Node');\n }\n if (!isNode(trueExpr)) {\n throw new TypeError('Parameter trueExpr must be a Node');\n }\n if (!isNode(falseExpr)) {\n throw new TypeError('Parameter falseExpr must be a Node');\n }\n this.condition = condition;\n this.trueExpr = trueExpr;\n this.falseExpr = falseExpr;\n }\n get type() {\n return name;\n }\n get isConditionalNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalCondition = this.condition._compile(math, argNames);\n var evalTrueExpr = this.trueExpr._compile(math, argNames);\n var evalFalseExpr = this.falseExpr._compile(math, argNames);\n return function evalConditionalNode(scope, args, context) {\n return testCondition(evalCondition(scope, args, context)) ? evalTrueExpr(scope, args, context) : evalFalseExpr(scope, args, context);\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.condition, 'condition', this);\n callback(this.trueExpr, 'trueExpr', this);\n callback(this.falseExpr, 'falseExpr', this);\n }\n\n /**\n * Create a new ConditionalNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ConditionalNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new ConditionalNode(this._ifNode(callback(this.condition, 'condition', this)), this._ifNode(callback(this.trueExpr, 'trueExpr', this)), this._ifNode(callback(this.falseExpr, 'falseExpr', this)));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ConditionalNode}\n */\n clone() {\n return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n\n // Enclose Arguments in parentheses if they are an OperatorNode\n // or have lower or equal precedence\n // NOTE: enclosing all OperatorNodes in parentheses is a decision\n // purely based on aesthetics and readability\n var condition = this.condition.toString(options);\n var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.condition.type === 'OperatorNode' || conditionPrecedence !== null && conditionPrecedence <= precedence) {\n condition = '(' + condition + ')';\n }\n var trueExpr = this.trueExpr.toString(options);\n var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.trueExpr.type === 'OperatorNode' || truePrecedence !== null && truePrecedence <= precedence) {\n trueExpr = '(' + trueExpr + ')';\n }\n var falseExpr = this.falseExpr.toString(options);\n var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.falseExpr.type === 'OperatorNode' || falsePrecedence !== null && falsePrecedence <= precedence) {\n falseExpr = '(' + falseExpr + ')';\n }\n return condition + ' ? ' + trueExpr + ' : ' + falseExpr;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n condition: this.condition,\n trueExpr: this.trueExpr,\n falseExpr: this.falseExpr\n };\n }\n\n /**\n * Instantiate an ConditionalNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"ConditionalNode\",\n * \"condition\": ...,\n * \"trueExpr\": ...,\n * \"falseExpr\": ...}\n * ```\n * where mathjs is optional\n * @returns {ConditionalNode}\n */\n static fromJSON(json) {\n return new ConditionalNode(json.condition, json.trueExpr, json.falseExpr);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n\n // Enclose Arguments in parentheses if they are an OperatorNode\n // or have lower or equal precedence\n // NOTE: enclosing all OperatorNodes in parentheses is a decision\n // purely based on aesthetics and readability\n var condition = this.condition.toHTML(options);\n var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.condition.type === 'OperatorNode' || conditionPrecedence !== null && conditionPrecedence <= precedence) {\n condition = '(' + condition + ')';\n }\n var trueExpr = this.trueExpr.toHTML(options);\n var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.trueExpr.type === 'OperatorNode' || truePrecedence !== null && truePrecedence <= precedence) {\n trueExpr = '(' + trueExpr + ')';\n }\n var falseExpr = this.falseExpr.toHTML(options);\n var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.falseExpr.type === 'OperatorNode' || falsePrecedence !== null && falsePrecedence <= precedence) {\n falseExpr = '(' + falseExpr + ')';\n }\n return condition + '?' + trueExpr + ':' + falseExpr;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n return '\\\\begin{cases} {' + this.trueExpr.toTex(options) + '}, &\\\\quad{\\\\text{if }\\\\;' + this.condition.toTex(options) + '}\\\\\\\\{' + this.falseExpr.toTex(options) + '}, &\\\\quad{\\\\text{otherwise}}\\\\end{cases}';\n }\n }\n _defineProperty(ConditionalNode, \"name\", name);\n return ConditionalNode;\n}, {\n isClass: true,\n isNode: true\n});","\"use strict\";\n\n// Map the characters to escape to their escaped values. The list is derived\n// from http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar defaultEscapes = {\n \"{\": \"\\\\{\",\n \"}\": \"\\\\}\",\n \"\\\\\": \"\\\\textbackslash{}\",\n \"#\": \"\\\\#\",\n $: \"\\\\$\",\n \"%\": \"\\\\%\",\n \"&\": \"\\\\&\",\n \"^\": \"\\\\textasciicircum{}\",\n _: \"\\\\_\",\n \"~\": \"\\\\textasciitilde{}\"\n};\nvar formatEscapes = {\n \"\\u2013\": \"\\\\--\",\n \"\\u2014\": \"\\\\---\",\n \" \": \"~\",\n \"\\t\": \"\\\\qquad{}\",\n \"\\r\\n\": \"\\\\newline{}\",\n \"\\n\": \"\\\\newline{}\"\n};\n\nvar defaultEscapeMapFn = function defaultEscapeMapFn(defaultEscapes, formatEscapes) {\n return _extends({}, defaultEscapes, formatEscapes);\n};\n\n/**\n * Escape a string to be used in LaTeX documents.\n * @param {string} str the string to be escaped.\n * @param {boolean} params.preserveFormatting whether formatting escapes should\n * be performed (default: false).\n * @param {function} params.escapeMapFn the function to modify the escape maps.\n * @return {string} the escaped string, ready to be used in LaTeX.\n */\nmodule.exports = function (str) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref$preserveFormatti = _ref.preserveFormatting,\n preserveFormatting = _ref$preserveFormatti === undefined ? false : _ref$preserveFormatti,\n _ref$escapeMapFn = _ref.escapeMapFn,\n escapeMapFn = _ref$escapeMapFn === undefined ? defaultEscapeMapFn : _ref$escapeMapFn;\n\n var runningStr = String(str);\n var result = \"\";\n\n var escapes = escapeMapFn(_extends({}, defaultEscapes), preserveFormatting ? _extends({}, formatEscapes) : {});\n var escapeKeys = Object.keys(escapes); // as it is reused later on\n\n // Algorithm: Go through the string character by character, if it matches\n // with one of the special characters then we'll replace it with the escaped\n // version.\n\n var _loop = function _loop() {\n var specialCharFound = false;\n escapeKeys.forEach(function (key, index) {\n if (specialCharFound) {\n return;\n }\n if (runningStr.length >= key.length && runningStr.slice(0, key.length) === key) {\n result += escapes[escapeKeys[index]];\n runningStr = runningStr.slice(key.length, runningStr.length);\n specialCharFound = true;\n }\n });\n if (!specialCharFound) {\n result += runningStr.slice(0, 1);\n runningStr = runningStr.slice(1, runningStr.length);\n }\n };\n\n while (runningStr) {\n _loop();\n }\n return result;\n};","/* eslint no-template-curly-in-string: \"off\" */\n\nimport escapeLatexLib from 'escape-latex';\nimport { hasOwnProperty } from './object.js';\nexport var latexSymbols = {\n // GREEK LETTERS\n Alpha: 'A',\n alpha: '\\\\alpha',\n Beta: 'B',\n beta: '\\\\beta',\n Gamma: '\\\\Gamma',\n gamma: '\\\\gamma',\n Delta: '\\\\Delta',\n delta: '\\\\delta',\n Epsilon: 'E',\n epsilon: '\\\\epsilon',\n varepsilon: '\\\\varepsilon',\n Zeta: 'Z',\n zeta: '\\\\zeta',\n Eta: 'H',\n eta: '\\\\eta',\n Theta: '\\\\Theta',\n theta: '\\\\theta',\n vartheta: '\\\\vartheta',\n Iota: 'I',\n iota: '\\\\iota',\n Kappa: 'K',\n kappa: '\\\\kappa',\n varkappa: '\\\\varkappa',\n Lambda: '\\\\Lambda',\n lambda: '\\\\lambda',\n Mu: 'M',\n mu: '\\\\mu',\n Nu: 'N',\n nu: '\\\\nu',\n Xi: '\\\\Xi',\n xi: '\\\\xi',\n Omicron: 'O',\n omicron: 'o',\n Pi: '\\\\Pi',\n pi: '\\\\pi',\n varpi: '\\\\varpi',\n Rho: 'P',\n rho: '\\\\rho',\n varrho: '\\\\varrho',\n Sigma: '\\\\Sigma',\n sigma: '\\\\sigma',\n varsigma: '\\\\varsigma',\n Tau: 'T',\n tau: '\\\\tau',\n Upsilon: '\\\\Upsilon',\n upsilon: '\\\\upsilon',\n Phi: '\\\\Phi',\n phi: '\\\\phi',\n varphi: '\\\\varphi',\n Chi: 'X',\n chi: '\\\\chi',\n Psi: '\\\\Psi',\n psi: '\\\\psi',\n Omega: '\\\\Omega',\n omega: '\\\\omega',\n // logic\n true: '\\\\mathrm{True}',\n false: '\\\\mathrm{False}',\n // other\n i: 'i',\n // TODO use \\i ??\n inf: '\\\\infty',\n Inf: '\\\\infty',\n infinity: '\\\\infty',\n Infinity: '\\\\infty',\n oo: '\\\\infty',\n lim: '\\\\lim',\n undefined: '\\\\mathbf{?}'\n};\nexport var latexOperators = {\n transpose: '^\\\\top',\n ctranspose: '^H',\n factorial: '!',\n pow: '^',\n dotPow: '.^\\\\wedge',\n // TODO find ideal solution\n unaryPlus: '+',\n unaryMinus: '-',\n bitNot: '\\\\~',\n // TODO find ideal solution\n not: '\\\\neg',\n multiply: '\\\\cdot',\n divide: '\\\\frac',\n // TODO how to handle that properly?\n dotMultiply: '.\\\\cdot',\n // TODO find ideal solution\n dotDivide: '.:',\n // TODO find ideal solution\n mod: '\\\\mod',\n add: '+',\n subtract: '-',\n to: '\\\\rightarrow',\n leftShift: '<<',\n rightArithShift: '>>',\n rightLogShift: '>>>',\n equal: '=',\n unequal: '\\\\neq',\n smaller: '<',\n larger: '>',\n smallerEq: '\\\\leq',\n largerEq: '\\\\geq',\n bitAnd: '\\\\&',\n bitXor: '\\\\underline{|}',\n bitOr: '|',\n and: '\\\\wedge',\n xor: '\\\\veebar',\n or: '\\\\vee'\n};\nexport var latexFunctions = {\n // arithmetic\n abs: {\n 1: '\\\\left|${args[0]}\\\\right|'\n },\n add: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.add, \"${args[1]}\\\\right)\")\n },\n cbrt: {\n 1: '\\\\sqrt[3]{${args[0]}}'\n },\n ceil: {\n 1: '\\\\left\\\\lceil${args[0]}\\\\right\\\\rceil'\n },\n cube: {\n 1: '\\\\left(${args[0]}\\\\right)^3'\n },\n divide: {\n 2: '\\\\frac{${args[0]}}{${args[1]}}'\n },\n dotDivide: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotDivide, \"${args[1]}\\\\right)\")\n },\n dotMultiply: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotMultiply, \"${args[1]}\\\\right)\")\n },\n dotPow: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotPow, \"${args[1]}\\\\right)\")\n },\n exp: {\n 1: '\\\\exp\\\\left(${args[0]}\\\\right)'\n },\n expm1: \"\\\\left(e\".concat(latexOperators.pow, \"{${args[0]}}-1\\\\right)\"),\n fix: {\n 1: '\\\\mathrm{${name}}\\\\left(${args[0]}\\\\right)'\n },\n floor: {\n 1: '\\\\left\\\\lfloor${args[0]}\\\\right\\\\rfloor'\n },\n fraction: {\n 2: '\\\\frac{${args[0]}}{${args[1]}}'\n },\n gcd: '\\\\gcd\\\\left(${args}\\\\right)',\n hypot: '\\\\hypot\\\\left(${args}\\\\right)',\n log: {\n 1: '\\\\ln\\\\left(${args[0]}\\\\right)',\n 2: '\\\\log_{${args[1]}}\\\\left(${args[0]}\\\\right)'\n },\n log10: {\n 1: '\\\\log_{10}\\\\left(${args[0]}\\\\right)'\n },\n log1p: {\n 1: '\\\\ln\\\\left(${args[0]}+1\\\\right)',\n 2: '\\\\log_{${args[1]}}\\\\left(${args[0]}+1\\\\right)'\n },\n log2: '\\\\log_{2}\\\\left(${args[0]}\\\\right)',\n mod: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.mod, \"${args[1]}\\\\right)\")\n },\n multiply: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.multiply, \"${args[1]}\\\\right)\")\n },\n norm: {\n 1: '\\\\left\\\\|${args[0]}\\\\right\\\\|',\n 2: undefined // use default template\n },\n nthRoot: {\n 2: '\\\\sqrt[${args[1]}]{${args[0]}}'\n },\n nthRoots: {\n 2: '\\\\{y : y^${args[1]} = {${args[0]}}\\\\}'\n },\n pow: {\n 2: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.pow, \"{${args[1]}}\")\n },\n round: {\n 1: '\\\\left\\\\lfloor${args[0]}\\\\right\\\\rceil',\n 2: undefined // use default template\n },\n sign: {\n 1: '\\\\mathrm{${name}}\\\\left(${args[0]}\\\\right)'\n },\n sqrt: {\n 1: '\\\\sqrt{${args[0]}}'\n },\n square: {\n 1: '\\\\left(${args[0]}\\\\right)^2'\n },\n subtract: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.subtract, \"${args[1]}\\\\right)\")\n },\n unaryMinus: {\n 1: \"\".concat(latexOperators.unaryMinus, \"\\\\left(${args[0]}\\\\right)\")\n },\n unaryPlus: {\n 1: \"\".concat(latexOperators.unaryPlus, \"\\\\left(${args[0]}\\\\right)\")\n },\n // bitwise\n bitAnd: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitAnd, \"${args[1]}\\\\right)\")\n },\n bitNot: {\n 1: latexOperators.bitNot + '\\\\left(${args[0]}\\\\right)'\n },\n bitOr: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitOr, \"${args[1]}\\\\right)\")\n },\n bitXor: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitXor, \"${args[1]}\\\\right)\")\n },\n leftShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.leftShift, \"${args[1]}\\\\right)\")\n },\n rightArithShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.rightArithShift, \"${args[1]}\\\\right)\")\n },\n rightLogShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.rightLogShift, \"${args[1]}\\\\right)\")\n },\n // combinatorics\n bellNumbers: {\n 1: '\\\\mathrm{B}_{${args[0]}}'\n },\n catalan: {\n 1: '\\\\mathrm{C}_{${args[0]}}'\n },\n stirlingS2: {\n 2: '\\\\mathrm{S}\\\\left(${args}\\\\right)'\n },\n // complex\n arg: {\n 1: '\\\\arg\\\\left(${args[0]}\\\\right)'\n },\n conj: {\n 1: '\\\\left(${args[0]}\\\\right)^*'\n },\n im: {\n 1: '\\\\Im\\\\left\\\\lbrace${args[0]}\\\\right\\\\rbrace'\n },\n re: {\n 1: '\\\\Re\\\\left\\\\lbrace${args[0]}\\\\right\\\\rbrace'\n },\n // logical\n and: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.and, \"${args[1]}\\\\right)\")\n },\n not: {\n 1: latexOperators.not + '\\\\left(${args[0]}\\\\right)'\n },\n or: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.or, \"${args[1]}\\\\right)\")\n },\n xor: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.xor, \"${args[1]}\\\\right)\")\n },\n // matrix\n cross: {\n 2: '\\\\left(${args[0]}\\\\right)\\\\times\\\\left(${args[1]}\\\\right)'\n },\n ctranspose: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.ctranspose)\n },\n det: {\n 1: '\\\\det\\\\left(${args[0]}\\\\right)'\n },\n dot: {\n 2: '\\\\left(${args[0]}\\\\cdot${args[1]}\\\\right)'\n },\n expm: {\n 1: '\\\\exp\\\\left(${args[0]}\\\\right)'\n },\n inv: {\n 1: '\\\\left(${args[0]}\\\\right)^{-1}'\n },\n pinv: {\n 1: '\\\\left(${args[0]}\\\\right)^{+}'\n },\n sqrtm: {\n 1: \"{${args[0]}}\".concat(latexOperators.pow, \"{\\\\frac{1}{2}}\")\n },\n trace: {\n 1: '\\\\mathrm{tr}\\\\left(${args[0]}\\\\right)'\n },\n transpose: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.transpose)\n },\n // probability\n combinations: {\n 2: '\\\\binom{${args[0]}}{${args[1]}}'\n },\n combinationsWithRep: {\n 2: '\\\\left(\\\\!\\\\!{\\\\binom{${args[0]}}{${args[1]}}}\\\\!\\\\!\\\\right)'\n },\n factorial: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.factorial)\n },\n gamma: {\n 1: '\\\\Gamma\\\\left(${args[0]}\\\\right)'\n },\n lgamma: {\n 1: '\\\\ln\\\\Gamma\\\\left(${args[0]}\\\\right)'\n },\n // relational\n equal: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.equal, \"${args[1]}\\\\right)\")\n },\n larger: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.larger, \"${args[1]}\\\\right)\")\n },\n largerEq: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.largerEq, \"${args[1]}\\\\right)\")\n },\n smaller: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.smaller, \"${args[1]}\\\\right)\")\n },\n smallerEq: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.smallerEq, \"${args[1]}\\\\right)\")\n },\n unequal: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.unequal, \"${args[1]}\\\\right)\")\n },\n // special\n erf: {\n 1: 'erf\\\\left(${args[0]}\\\\right)'\n },\n // statistics\n max: '\\\\max\\\\left(${args}\\\\right)',\n min: '\\\\min\\\\left(${args}\\\\right)',\n variance: '\\\\mathrm{Var}\\\\left(${args}\\\\right)',\n // trigonometry\n acos: {\n 1: '\\\\cos^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acosh: {\n 1: '\\\\cosh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acot: {\n 1: '\\\\cot^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acoth: {\n 1: '\\\\coth^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acsc: {\n 1: '\\\\csc^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acsch: {\n 1: '\\\\mathrm{csch}^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asec: {\n 1: '\\\\sec^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asech: {\n 1: '\\\\mathrm{sech}^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asin: {\n 1: '\\\\sin^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asinh: {\n 1: '\\\\sinh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n atan: {\n 1: '\\\\tan^{-1}\\\\left(${args[0]}\\\\right)'\n },\n atan2: {\n 2: '\\\\mathrm{atan2}\\\\left(${args}\\\\right)'\n },\n atanh: {\n 1: '\\\\tanh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n cos: {\n 1: '\\\\cos\\\\left(${args[0]}\\\\right)'\n },\n cosh: {\n 1: '\\\\cosh\\\\left(${args[0]}\\\\right)'\n },\n cot: {\n 1: '\\\\cot\\\\left(${args[0]}\\\\right)'\n },\n coth: {\n 1: '\\\\coth\\\\left(${args[0]}\\\\right)'\n },\n csc: {\n 1: '\\\\csc\\\\left(${args[0]}\\\\right)'\n },\n csch: {\n 1: '\\\\mathrm{csch}\\\\left(${args[0]}\\\\right)'\n },\n sec: {\n 1: '\\\\sec\\\\left(${args[0]}\\\\right)'\n },\n sech: {\n 1: '\\\\mathrm{sech}\\\\left(${args[0]}\\\\right)'\n },\n sin: {\n 1: '\\\\sin\\\\left(${args[0]}\\\\right)'\n },\n sinh: {\n 1: '\\\\sinh\\\\left(${args[0]}\\\\right)'\n },\n tan: {\n 1: '\\\\tan\\\\left(${args[0]}\\\\right)'\n },\n tanh: {\n 1: '\\\\tanh\\\\left(${args[0]}\\\\right)'\n },\n // unit\n to: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.to, \"${args[1]}\\\\right)\")\n },\n // utils\n numeric: function numeric(node, options) {\n // Not sure if this is strictly right but should work correctly for the vast majority of use cases.\n return node.args[0].toTex();\n },\n // type\n number: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(\\\\left(${args[0]}\\\\right)${args[1]}\\\\right)'\n },\n string: {\n 0: '\\\\mathtt{\"\"}',\n 1: '\\\\mathrm{string}\\\\left(${args[0]}\\\\right)'\n },\n bignumber: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n bigint: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n complex: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: \"\\\\left(\\\\left(${args[0]}\\\\right)+\".concat(latexSymbols.i, \"\\\\cdot\\\\left(${args[1]}\\\\right)\\\\right)\")\n },\n matrix: {\n 0: '\\\\begin{bmatrix}\\\\end{bmatrix}',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(${args[0]}\\\\right)'\n },\n sparse: {\n 0: '\\\\begin{bsparse}\\\\end{bsparse}',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n unit: {\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(\\\\left(${args[0]}\\\\right)${args[1]}\\\\right)'\n }\n};\nexport var defaultTemplate = '\\\\mathrm{${name}}\\\\left(${args}\\\\right)';\nvar latexUnits = {\n deg: '^\\\\circ'\n};\nexport function escapeLatex(string) {\n return escapeLatexLib(string, {\n preserveFormatting: true\n });\n}\n\n// @param {string} name\n// @param {boolean} isUnit\nexport function toSymbol(name, isUnit) {\n isUnit = typeof isUnit === 'undefined' ? false : isUnit;\n if (isUnit) {\n if (hasOwnProperty(latexUnits, name)) {\n return latexUnits[name];\n }\n return '\\\\mathrm{' + escapeLatex(name) + '}';\n }\n if (hasOwnProperty(latexSymbols, name)) {\n return latexSymbols[name];\n }\n return escapeLatex(name);\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { format } from '../../utils/string.js';\nimport { typeOf } from '../../utils/is.js';\nimport { escapeLatex } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ConstantNode';\nvar dependencies = ['Node', 'isBounded'];\nexport var createConstantNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node,\n isBounded\n } = _ref;\n class ConstantNode extends Node {\n /**\n * A ConstantNode holds a constant value like a number or string.\n *\n * Usage:\n *\n * new ConstantNode(2.3)\n * new ConstantNode('hello')\n *\n * @param {*} value Value can be any type (number, BigNumber, bigint, string, ...)\n * @constructor ConstantNode\n * @extends {Node}\n */\n constructor(value) {\n super();\n this.value = value;\n }\n get type() {\n return name;\n }\n get isConstantNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var value = this.value;\n return function evalConstantNode() {\n return value;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // nothing to do, we don't have any children\n }\n\n /**\n * Create a new ConstantNode with children produced by the given callback.\n * Trivial because there are no children.\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {ConstantNode} Returns a clone of the node\n */\n map(callback) {\n return this.clone();\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ConstantNode}\n */\n clone() {\n return new ConstantNode(this.value);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n return format(this.value, options);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var value = this._toString(options);\n switch (typeOf(this.value)) {\n case 'number':\n case 'bigint':\n case 'BigNumber':\n case 'Fraction':\n return '' + value + '';\n case 'string':\n return '' + value + '';\n case 'boolean':\n return '' + value + '';\n case 'null':\n return '' + value + '';\n case 'undefined':\n return '' + value + '';\n default:\n return '' + value + '';\n }\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n value: this.value\n };\n }\n\n /**\n * Instantiate a ConstantNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"SymbolNode\", value: 2.3}`,\n * where mathjs is optional\n * @returns {ConstantNode}\n */\n static fromJSON(json) {\n return new ConstantNode(json.value);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var value = this._toString(options);\n var type = typeOf(this.value);\n switch (type) {\n case 'string':\n return '\\\\mathtt{' + escapeLatex(value) + '}';\n case 'number':\n case 'BigNumber':\n {\n if (!isBounded(this.value)) {\n return this.value.valueOf() < 0 ? '-\\\\infty' : '\\\\infty';\n }\n var index = value.toLowerCase().indexOf('e');\n if (index !== -1) {\n return value.substring(0, index) + '\\\\cdot10^{' + value.substring(index + 1) + '}';\n }\n return value;\n }\n case 'bigint':\n {\n return value.toString();\n }\n case 'Fraction':\n return this.value.toLatex();\n default:\n return value;\n }\n }\n }\n _defineProperty(ConstantNode, \"name\", name);\n return ConstantNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { keywords } from '../keywords.js';\nimport { escape } from '../../utils/string.js';\nimport { forEach, join } from '../../utils/array.js';\nimport { toSymbol } from '../../utils/latex.js';\nimport { getPrecedence } from '../operators.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'FunctionAssignmentNode';\nvar dependencies = ['typed', 'Node'];\nexport var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n Node\n } = _ref;\n /**\n * Is parenthesis needed?\n * @param {Node} node\n * @param {Object} parenthesis\n * @param {string} implicit\n * @private\n */\n function needParenthesis(node, parenthesis, implicit) {\n var precedence = getPrecedence(node, parenthesis, implicit);\n var exprPrecedence = getPrecedence(node.expr, parenthesis, implicit);\n return parenthesis === 'all' || exprPrecedence !== null && exprPrecedence <= precedence;\n }\n class FunctionAssignmentNode extends Node {\n /**\n * @constructor FunctionAssignmentNode\n * @extends {Node}\n * Function assignment\n *\n * @param {string} name Function name\n * @param {string[] | Array.<{name: string, type: string}>} params\n * Array with function parameter names, or an\n * array with objects containing the name\n * and type of the parameter\n * @param {Node} expr The function expression\n */\n constructor(name, params, expr) {\n super();\n // validate input\n if (typeof name !== 'string') {\n throw new TypeError('String expected for parameter \"name\"');\n }\n if (!Array.isArray(params)) {\n throw new TypeError('Array containing strings or objects expected for parameter \"params\"');\n }\n if (!isNode(expr)) {\n throw new TypeError('Node expected for parameter \"expr\"');\n }\n if (keywords.has(name)) {\n throw new Error('Illegal function name, \"' + name + '\" is a reserved keyword');\n }\n var paramNames = new Set();\n for (var param of params) {\n var _name = typeof param === 'string' ? param : param.name;\n if (paramNames.has(_name)) {\n throw new Error(\"Duplicate parameter name \\\"\".concat(_name, \"\\\"\"));\n } else {\n paramNames.add(_name);\n }\n }\n this.name = name;\n this.params = params.map(function (param) {\n return param && param.name || param;\n });\n this.types = params.map(function (param) {\n return param && param.type || 'any';\n });\n this.expr = expr;\n }\n get type() {\n return name;\n }\n get isFunctionAssignmentNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var childArgNames = Object.create(argNames);\n forEach(this.params, function (param) {\n childArgNames[param] = true;\n });\n\n // compile the function expression with the child args\n var expr = this.expr;\n var evalExpr = expr._compile(math, childArgNames);\n var name = this.name;\n var params = this.params;\n var signature = join(this.types, ',');\n var syntax = name + '(' + join(this.params, ', ') + ')';\n return function evalFunctionAssignmentNode(scope, args, context) {\n var signatures = {};\n signatures[signature] = function () {\n var childArgs = Object.create(args);\n for (var i = 0; i < params.length; i++) {\n childArgs[params[i]] = arguments[i];\n }\n return evalExpr(scope, childArgs, context);\n };\n var fn = typed(name, signatures);\n fn.syntax = syntax;\n fn.expr = expr.toString();\n scope.set(name, fn);\n return fn;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.expr, 'expr', this);\n }\n\n /**\n * Create a new FunctionAssignmentNode whose children are the results of\n * calling the provided callback function for each child of the original\n * node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {FunctionAssignmentNode} Returns a transformed copy of the node\n */\n map(callback) {\n var expr = this._ifNode(callback(this.expr, 'expr', this));\n return new FunctionAssignmentNode(this.name, this.params.slice(0), expr);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {FunctionAssignmentNode}\n */\n clone() {\n return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr);\n }\n\n /**\n * get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var expr = this.expr.toString(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = '(' + expr + ')';\n }\n return this.name + '(' + this.params.join(', ') + ') = ' + expr;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n var types = this.types;\n return {\n mathjs: name,\n name: this.name,\n params: this.params.map(function (param, index) {\n return {\n name: param,\n type: types[index]\n };\n }),\n expr: this.expr\n };\n }\n\n /**\n * Instantiate an FunctionAssignmentNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"FunctionAssignmentNode\",\n * name: ..., params: ..., expr: ...}\n * ```\n * where mathjs is optional\n * @returns {FunctionAssignmentNode}\n */\n static fromJSON(json) {\n return new FunctionAssignmentNode(json.name, json.params, json.expr);\n }\n\n /**\n * get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var params = [];\n for (var i = 0; i < this.params.length; i++) {\n params.push('' + escape(this.params[i]) + '');\n }\n var expr = this.expr.toHTML(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = '(' + expr + ')';\n }\n return '' + escape(this.name) + '' + '(' + params.join(',') + ')' + '=' + expr;\n }\n\n /**\n * get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var expr = this.expr.toTex(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = \"\\\\left(\".concat(expr, \"\\\\right)\");\n }\n return '\\\\mathrm{' + this.name + '}\\\\left(' + this.params.map(toSymbol).join(',') + '\\\\right)=' + expr;\n }\n }\n _defineProperty(FunctionAssignmentNode, \"name\", name);\n return FunctionAssignmentNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { map } from '../../utils/array.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { isArray, isConstantNode, isMatrix, isNode, isString, typeOf } from '../../utils/is.js';\nimport { escape } from '../../utils/string.js';\nvar name = 'IndexNode';\nvar dependencies = ['Node', 'size'];\nexport var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node,\n size\n } = _ref;\n class IndexNode extends Node {\n /**\n * @constructor IndexNode\n * @extends Node\n *\n * Describes a subset of a matrix or an object property.\n * Cannot be used on its own, needs to be used within an AccessorNode or\n * AssignmentNode.\n *\n * @param {Node[]} dimensions\n * @param {boolean} [dotNotation=false]\n * Optional property describing whether this index was written using dot\n * notation like `a.b`, or using bracket notation like `a[\"b\"]`\n * (which is the default). This property is used for string conversion.\n */\n constructor(dimensions, dotNotation) {\n super();\n this.dimensions = dimensions;\n this.dotNotation = dotNotation || false;\n\n // validate input\n if (!Array.isArray(dimensions) || !dimensions.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"dimensions\"');\n }\n if (this.dotNotation && !this.isObjectProperty()) {\n throw new Error('dotNotation only applicable for object properties');\n }\n }\n get type() {\n return name;\n }\n get isIndexNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // TODO: implement support for bignumber (currently bignumbers are silently\n // reduced to numbers when changing the value to zero-based)\n\n // TODO: Optimization: when the range values are ConstantNodes,\n // we can beforehand resolve the zero-based value\n\n // optimization for a simple object property\n var evalDimensions = map(this.dimensions, function (dimension, i) {\n var needsEnd = dimension.filter(node => node.isSymbolNode && node.name === 'end').length > 0;\n if (needsEnd) {\n // SymbolNode 'end' is used inside the index,\n // like in `A[end]` or `A[end - 2]`\n var childArgNames = Object.create(argNames);\n childArgNames.end = true;\n var _evalDimension = dimension._compile(math, childArgNames);\n return function evalDimension(scope, args, context) {\n if (!isMatrix(context) && !isArray(context) && !isString(context)) {\n throw new TypeError('Cannot resolve \"end\": ' + 'context must be a Matrix, Array, or string but is ' + typeOf(context));\n }\n var s = size(context);\n var childArgs = Object.create(args);\n childArgs.end = s[i];\n return _evalDimension(scope, childArgs, context);\n };\n } else {\n // SymbolNode `end` not used\n return dimension._compile(math, argNames);\n }\n });\n var index = getSafeProperty(math, 'index');\n return function evalIndexNode(scope, args, context) {\n var dimensions = map(evalDimensions, function (evalDimension) {\n return evalDimension(scope, args, context);\n });\n return index(...dimensions);\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.dimensions.length; i++) {\n callback(this.dimensions[i], 'dimensions[' + i + ']', this);\n }\n }\n\n /**\n * Create a new IndexNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {IndexNode} Returns a transformed copy of the node\n */\n map(callback) {\n var dimensions = [];\n for (var i = 0; i < this.dimensions.length; i++) {\n dimensions[i] = this._ifNode(callback(this.dimensions[i], 'dimensions[' + i + ']', this));\n }\n return new IndexNode(dimensions, this.dotNotation);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {IndexNode}\n */\n clone() {\n return new IndexNode(this.dimensions.slice(0), this.dotNotation);\n }\n\n /**\n * Test whether this IndexNode contains a single property name\n * @return {boolean}\n */\n isObjectProperty() {\n return this.dimensions.length === 1 && isConstantNode(this.dimensions[0]) && typeof this.dimensions[0].value === 'string';\n }\n\n /**\n * Returns the property name if IndexNode contains a property.\n * If not, returns null.\n * @return {string | null}\n */\n getObjectProperty() {\n return this.isObjectProperty() ? this.dimensions[0].value : null;\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n // format the parameters like \"[1, 0:5]\"\n return this.dotNotation ? '.' + this.getObjectProperty() : '[' + this.dimensions.join(', ') + ']';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n dimensions: this.dimensions,\n dotNotation: this.dotNotation\n };\n }\n\n /**\n * Instantiate an IndexNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"IndexNode\", dimensions: [...], dotNotation: false}`,\n * where mathjs is optional\n * @returns {IndexNode}\n */\n static fromJSON(json) {\n return new IndexNode(json.dimensions, json.dotNotation);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n // format the parameters like \"[1, 0:5]\"\n var dimensions = [];\n for (var i = 0; i < this.dimensions.length; i++) {\n dimensions[i] = this.dimensions[i].toHTML();\n }\n if (this.dotNotation) {\n return '.' + '' + escape(this.getObjectProperty()) + '';\n } else {\n return '[' + dimensions.join(',') + ']';\n }\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var dimensions = this.dimensions.map(function (range) {\n return range.toTex(options);\n });\n return this.dotNotation ? '.' + this.getObjectProperty() + '' : '_{' + dimensions.join(',') + '}';\n }\n }\n _defineProperty(IndexNode, \"name\", name);\n return IndexNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { isNode } from '../../utils/is.js';\nimport { hasOwnProperty } from '../../utils/object.js';\nimport { escape, stringify } from '../../utils/string.js';\nvar name = 'ObjectNode';\nvar dependencies = ['Node'];\nexport var createObjectNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ObjectNode extends Node {\n /**\n * @constructor ObjectNode\n * @extends {Node}\n * Holds an object with keys/values\n * @param {Object.} [properties] object with key/value pairs\n */\n constructor(properties) {\n super();\n this.properties = properties || {};\n\n // validate input\n if (properties) {\n if (!(typeof properties === 'object') || !Object.keys(properties).every(function (key) {\n return isNode(properties[key]);\n })) {\n throw new TypeError('Object containing Nodes expected');\n }\n }\n }\n get type() {\n return name;\n }\n get isObjectNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalEntries = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n // we stringify/parse the key here to resolve unicode characters,\n // so you cannot create a key like {\"co\\\\u006Estructor\": null}\n var stringifiedKey = stringify(key);\n var parsedKey = JSON.parse(stringifiedKey);\n var prop = getSafeProperty(this.properties, key);\n evalEntries[parsedKey] = prop._compile(math, argNames);\n }\n }\n return function evalObjectNode(scope, args, context) {\n var obj = {};\n for (var _key in evalEntries) {\n if (hasOwnProperty(evalEntries, _key)) {\n obj[_key] = evalEntries[_key](scope, args, context);\n }\n }\n return obj;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n callback(this.properties[key], 'properties[' + stringify(key) + ']', this);\n }\n }\n }\n\n /**\n * Create a new ObjectNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ObjectNode} Returns a transformed copy of the node\n */\n map(callback) {\n var properties = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n properties[key] = this._ifNode(callback(this.properties[key], 'properties[' + stringify(key) + ']', this));\n }\n }\n return new ObjectNode(properties);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ObjectNode}\n */\n clone() {\n var properties = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n properties[key] = this.properties[key];\n }\n }\n return new ObjectNode(properties);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push(stringify(key) + ': ' + this.properties[key].toString(options));\n }\n }\n return '{' + entries.join(', ') + '}';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n properties: this.properties\n };\n }\n\n /**\n * Instantiate an OperatorNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ObjectNode\", \"properties\": {...}}`,\n * where mathjs is optional\n * @returns {ObjectNode}\n */\n static fromJSON(json) {\n return new ObjectNode(json.properties);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push('' + escape(key) + '' + '' + ':' + this.properties[key].toHTML(options));\n }\n }\n return '{' + entries.join(',') + '}';\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push('\\\\mathbf{' + key + ':} & ' + this.properties[key].toTex(options) + '\\\\\\\\');\n }\n }\n var tex = '\\\\left\\\\{\\\\begin{array}{ll}' + entries.join('\\n') + '\\\\end{array}\\\\right\\\\}';\n return tex;\n }\n }\n _defineProperty(ObjectNode, \"name\", name);\n return ObjectNode;\n}, {\n isClass: true,\n isNode: true\n});","import { ObjectWrappingMap, PartitionedMap } from './map.js';\n\n/**\n * Create a new scope which can access the parent scope,\n * but does not affect it when written. This is suitable for variable definitions\n * within a block node, or function definition.\n *\n * If parent scope has a createSubScope method, it delegates to that. Otherwise,\n * creates an empty map, and copies the parent scope to it, adding in\n * the remaining `args`.\n *\n * @param {Map} parentScope\n * @param {Object} args\n * @returns {PartitionedMap}\n */\nexport function createSubScope(parentScope, args) {\n return new PartitionedMap(parentScope, new ObjectWrappingMap(args), new Set(Object.keys(args)));\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode, isConstantNode, isOperatorNode, isParenthesisNode } from '../../utils/is.js';\nimport { map } from '../../utils/array.js';\nimport { createSubScope } from '../../utils/scope.js';\nimport { escape } from '../../utils/string.js';\nimport { getSafeProperty, isSafeMethod } from '../../utils/customs.js';\nimport { getAssociativity, getPrecedence, isAssociativeWith, properties } from '../operators.js';\nimport { latexOperators } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'OperatorNode';\nvar dependencies = ['Node'];\nexport var createOperatorNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Returns true if the expression starts with a constant, under\n * the current parenthesization:\n * @param {Node} expression\n * @param {string} parenthesis\n * @return {boolean}\n */\n function startsWithConstant(expr, parenthesis) {\n var curNode = expr;\n if (parenthesis === 'auto') {\n while (isParenthesisNode(curNode)) curNode = curNode.content;\n }\n if (isConstantNode(curNode)) return true;\n if (isOperatorNode(curNode)) {\n return startsWithConstant(curNode.args[0], parenthesis);\n }\n return false;\n }\n\n /**\n * Calculate which parentheses are necessary. Gets an OperatorNode\n * (which is the root of the tree) and an Array of Nodes\n * (this.args) and returns an array where 'true' means that an argument\n * has to be enclosed in parentheses whereas 'false' means the opposite.\n *\n * @param {OperatorNode} root\n * @param {string} parenthesis\n * @param {Node[]} args\n * @param {boolean} latex\n * @return {boolean[]}\n * @private\n */\n function calculateNecessaryParentheses(root, parenthesis, implicit, args, latex) {\n // precedence of the root OperatorNode\n var precedence = getPrecedence(root, parenthesis, implicit);\n var associativity = getAssociativity(root, parenthesis);\n if (parenthesis === 'all' || args.length > 2 && root.getIdentifier() !== 'OperatorNode:add' && root.getIdentifier() !== 'OperatorNode:multiply') {\n return args.map(function (arg) {\n switch (arg.getContent().type) {\n // Nodes that don't need extra parentheses\n case 'ArrayNode':\n case 'ConstantNode':\n case 'SymbolNode':\n case 'ParenthesisNode':\n return false;\n default:\n return true;\n }\n });\n }\n var result;\n switch (args.length) {\n case 0:\n result = [];\n break;\n case 1:\n // unary operators\n {\n // precedence of the operand\n var operandPrecedence = getPrecedence(args[0], parenthesis, implicit, root);\n\n // handle special cases for LaTeX, where some of the parentheses aren't needed\n if (latex && operandPrecedence !== null) {\n var operandIdentifier;\n var rootIdentifier;\n if (parenthesis === 'keep') {\n operandIdentifier = args[0].getIdentifier();\n rootIdentifier = root.getIdentifier();\n } else {\n // Ignore Parenthesis Nodes when not in 'keep' mode\n operandIdentifier = args[0].getContent().getIdentifier();\n rootIdentifier = root.getContent().getIdentifier();\n }\n if (properties[precedence][rootIdentifier].latexLeftParens === false) {\n result = [false];\n break;\n }\n if (properties[operandPrecedence][operandIdentifier].latexParens === false) {\n result = [false];\n break;\n }\n }\n if (operandPrecedence === null) {\n // if the operand has no defined precedence, no parens are needed\n result = [false];\n break;\n }\n if (operandPrecedence <= precedence) {\n // if the operands precedence is lower, parens are needed\n result = [true];\n break;\n }\n\n // otherwise, no parens needed\n result = [false];\n }\n break;\n case 2:\n // binary operators\n {\n var lhsParens; // left hand side needs parenthesis?\n // precedence of the left hand side\n var lhsPrecedence = getPrecedence(args[0], parenthesis, implicit, root);\n // is the root node associative with the left hand side\n var assocWithLhs = isAssociativeWith(root, args[0], parenthesis);\n if (lhsPrecedence === null) {\n // if the left hand side has no defined precedence, no parens are needed\n // FunctionNode for example\n lhsParens = false;\n } else if (lhsPrecedence === precedence && associativity === 'right' && !assocWithLhs) {\n // In case of equal precedence, if the root node is left associative\n // parens are **never** necessary for the left hand side.\n // If it is right associative however, parens are necessary\n // if the root node isn't associative with the left hand side\n lhsParens = true;\n } else if (lhsPrecedence < precedence) {\n lhsParens = true;\n } else {\n lhsParens = false;\n }\n var rhsParens; // right hand side needs parenthesis?\n // precedence of the right hand side\n var rhsPrecedence = getPrecedence(args[1], parenthesis, implicit, root);\n // is the root node associative with the right hand side?\n var assocWithRhs = isAssociativeWith(root, args[1], parenthesis);\n if (rhsPrecedence === null) {\n // if the right hand side has no defined precedence, no parens are needed\n // FunctionNode for example\n rhsParens = false;\n } else if (rhsPrecedence === precedence && associativity === 'left' && !assocWithRhs) {\n // In case of equal precedence, if the root node is right associative\n // parens are **never** necessary for the right hand side.\n // If it is left associative however, parens are necessary\n // if the root node isn't associative with the right hand side\n rhsParens = true;\n } else if (rhsPrecedence < precedence) {\n rhsParens = true;\n } else {\n rhsParens = false;\n }\n\n // handle special cases for LaTeX, where some of the parentheses aren't needed\n if (latex) {\n var _rootIdentifier;\n var lhsIdentifier;\n var rhsIdentifier;\n if (parenthesis === 'keep') {\n _rootIdentifier = root.getIdentifier();\n lhsIdentifier = root.args[0].getIdentifier();\n rhsIdentifier = root.args[1].getIdentifier();\n } else {\n // Ignore ParenthesisNodes when not in 'keep' mode\n _rootIdentifier = root.getContent().getIdentifier();\n lhsIdentifier = root.args[0].getContent().getIdentifier();\n rhsIdentifier = root.args[1].getContent().getIdentifier();\n }\n if (lhsPrecedence !== null) {\n if (properties[precedence][_rootIdentifier].latexLeftParens === false) {\n lhsParens = false;\n }\n if (properties[lhsPrecedence][lhsIdentifier].latexParens === false) {\n lhsParens = false;\n }\n }\n if (rhsPrecedence !== null) {\n if (properties[precedence][_rootIdentifier].latexRightParens === false) {\n rhsParens = false;\n }\n if (properties[rhsPrecedence][rhsIdentifier].latexParens === false) {\n rhsParens = false;\n }\n }\n }\n result = [lhsParens, rhsParens];\n }\n break;\n default:\n if (root.getIdentifier() === 'OperatorNode:add' || root.getIdentifier() === 'OperatorNode:multiply') {\n result = args.map(function (arg) {\n var argPrecedence = getPrecedence(arg, parenthesis, implicit, root);\n var assocWithArg = isAssociativeWith(root, arg, parenthesis);\n var argAssociativity = getAssociativity(arg, parenthesis);\n if (argPrecedence === null) {\n // if the argument has no defined precedence, no parens are needed\n return false;\n } else if (precedence === argPrecedence && associativity === argAssociativity && !assocWithArg) {\n return true;\n } else if (argPrecedence < precedence) {\n return true;\n }\n return false;\n });\n }\n break;\n }\n\n // Handles an edge case of parentheses with implicit multiplication\n // of ConstantNode.\n // In that case, parenthesize ConstantNodes that follow an unparenthesized\n // expression, even though they normally wouldn't be printed.\n if (args.length >= 2 && root.getIdentifier() === 'OperatorNode:multiply' && root.implicit && parenthesis !== 'all' && implicit === 'hide') {\n for (var i = 1; i < result.length; ++i) {\n if (startsWithConstant(args[i], parenthesis) && !result[i - 1] && (parenthesis !== 'keep' || !isParenthesisNode(args[i - 1]))) {\n result[i] = true;\n }\n }\n }\n return result;\n }\n class OperatorNode extends Node {\n /**\n * @constructor OperatorNode\n * @extends {Node}\n * An operator with two arguments, like 2+3\n *\n * @param {string} op Operator name, for example '+'\n * @param {string} fn Function name, for example 'add'\n * @param {Node[]} args Operator arguments\n * @param {boolean} [implicit] Is this an implicit multiplication?\n * @param {boolean} [isPercentage] Is this an percentage Operation?\n */\n constructor(op, fn, args, implicit, isPercentage) {\n super();\n // validate input\n if (typeof op !== 'string') {\n throw new TypeError('string expected for parameter \"op\"');\n }\n if (typeof fn !== 'string') {\n throw new TypeError('string expected for parameter \"fn\"');\n }\n if (!Array.isArray(args) || !args.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"args\"');\n }\n this.implicit = implicit === true;\n this.isPercentage = isPercentage === true;\n this.op = op;\n this.fn = fn;\n this.args = args || [];\n }\n get type() {\n return name;\n }\n get isOperatorNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // validate fn\n if (typeof this.fn !== 'string' || !isSafeMethod(math, this.fn)) {\n if (!math[this.fn]) {\n throw new Error('Function ' + this.fn + ' missing in provided namespace \"math\"');\n } else {\n throw new Error('No access to function \"' + this.fn + '\"');\n }\n }\n var fn = getSafeProperty(math, this.fn);\n var evalArgs = map(this.args, function (arg) {\n return arg._compile(math, argNames);\n });\n if (typeof fn === 'function' && fn.rawArgs === true) {\n // pass unevaluated parameters (nodes) to the function\n // \"raw\" evaluation\n var rawArgs = this.args;\n return function evalOperatorNode(scope, args, context) {\n return fn(rawArgs, math, createSubScope(scope, args));\n };\n } else if (evalArgs.length === 1) {\n var evalArg0 = evalArgs[0];\n return function evalOperatorNode(scope, args, context) {\n return fn(evalArg0(scope, args, context));\n };\n } else if (evalArgs.length === 2) {\n var _evalArg = evalArgs[0];\n var evalArg1 = evalArgs[1];\n return function evalOperatorNode(scope, args, context) {\n return fn(_evalArg(scope, args, context), evalArg1(scope, args, context));\n };\n } else {\n return function evalOperatorNode(scope, args, context) {\n return fn.apply(null, map(evalArgs, function (evalArg) {\n return evalArg(scope, args, context);\n }));\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.args.length; i++) {\n callback(this.args[i], 'args[' + i + ']', this);\n }\n }\n\n /**\n * Create a new OperatorNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {OperatorNode} Returns a transformed copy of the node\n */\n map(callback) {\n var args = [];\n for (var i = 0; i < this.args.length; i++) {\n args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this));\n }\n return new OperatorNode(this.op, this.fn, args, this.implicit, this.isPercentage);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {OperatorNode}\n */\n clone() {\n return new OperatorNode(this.op, this.fn, this.args.slice(0), this.implicit, this.isPercentage);\n }\n\n /**\n * Check whether this is an unary OperatorNode:\n * has exactly one argument, like `-a`.\n * @return {boolean}\n * Returns true when an unary operator node, false otherwise.\n */\n isUnary() {\n return this.args.length === 1;\n }\n\n /**\n * Check whether this is a binary OperatorNode:\n * has exactly two arguments, like `a + b`.\n * @return {boolean}\n * Returns true when a binary operator node, false otherwise.\n */\n isBinary() {\n return this.args.length === 2;\n }\n\n /**\n * Get string representation.\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toString(options);\n if (parens[0]) {\n operand = '(' + operand + ')';\n }\n\n // for example for \"not\", we want a space between operand and argument\n var opIsNamed = /[a-zA-Z]+/.test(this.op);\n if (assoc === 'right') {\n // prefix operator\n return this.op + (opIsNamed ? ' ' : '') + operand;\n } else if (assoc === 'left') {\n // postfix\n return operand + (opIsNamed ? ' ' : '') + this.op;\n }\n\n // fall back to postfix\n return operand + this.op;\n } else if (args.length === 2) {\n var lhs = args[0].toString(options); // left hand side\n var rhs = args[1].toString(options); // right hand side\n if (parens[0]) {\n // left hand side in parenthesis?\n lhs = '(' + lhs + ')';\n }\n if (parens[1]) {\n // right hand side in parenthesis?\n rhs = '(' + rhs + ')';\n }\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return lhs + ' ' + rhs;\n }\n return lhs + ' ' + this.op + ' ' + rhs;\n } else if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n var stringifiedArgs = args.map(function (arg, index) {\n arg = arg.toString(options);\n if (parens[index]) {\n // put in parenthesis?\n arg = '(' + arg + ')';\n }\n return arg;\n });\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return stringifiedArgs.join(' ');\n }\n return stringifiedArgs.join(' ' + this.op + ' ');\n } else {\n // fallback to formatting as a function call\n return this.fn + '(' + this.args.join(', ') + ')';\n }\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n op: this.op,\n fn: this.fn,\n args: this.args,\n implicit: this.implicit,\n isPercentage: this.isPercentage\n };\n }\n\n /**\n * Instantiate an OperatorNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"OperatorNode\",\n * \"op\": \"+\", \"fn\": \"add\", \"args\": [...],\n * \"implicit\": false,\n * \"isPercentage\":false}\n * ```\n * where mathjs is optional\n * @returns {OperatorNode}\n */\n static fromJSON(json) {\n return new OperatorNode(json.op, json.fn, json.args, json.implicit, json.isPercentage);\n }\n\n /**\n * Get HTML representation.\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toHTML(options);\n if (parens[0]) {\n operand = '(' + operand + ')';\n }\n if (assoc === 'right') {\n // prefix operator\n return '' + escape(this.op) + '' + operand;\n } else {\n // postfix when assoc === 'left' or undefined\n return operand + '' + escape(this.op) + '';\n }\n } else if (args.length === 2) {\n // binary operatoes\n var lhs = args[0].toHTML(options); // left hand side\n var rhs = args[1].toHTML(options); // right hand side\n if (parens[0]) {\n // left hand side in parenthesis?\n lhs = '(' + lhs + ')';\n }\n if (parens[1]) {\n // right hand side in parenthesis?\n rhs = '(' + rhs + ')';\n }\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return lhs + '' + rhs;\n }\n return lhs + '' + escape(this.op) + '' + rhs;\n } else {\n var stringifiedArgs = args.map(function (arg, index) {\n arg = arg.toHTML(options);\n if (parens[index]) {\n // put in parenthesis?\n arg = '(' + arg + ')';\n }\n return arg;\n });\n if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return stringifiedArgs.join('');\n }\n return stringifiedArgs.join('' + escape(this.op) + '');\n } else {\n // fallback to formatting as a function call\n return '' + escape(this.fn) + '' + '(' + stringifiedArgs.join(',') + ')';\n }\n }\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, true);\n var op = latexOperators[this.fn];\n op = typeof op === 'undefined' ? this.op : op; // fall back to using this.op\n\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toTex(options);\n if (parens[0]) {\n operand = \"\\\\left(\".concat(operand, \"\\\\right)\");\n }\n if (assoc === 'right') {\n // prefix operator\n return op + operand;\n } else if (assoc === 'left') {\n // postfix operator\n return operand + op;\n }\n\n // fall back to postfix\n return operand + op;\n } else if (args.length === 2) {\n // binary operators\n var lhs = args[0]; // left hand side\n var lhsTex = lhs.toTex(options);\n if (parens[0]) {\n lhsTex = \"\\\\left(\".concat(lhsTex, \"\\\\right)\");\n }\n var rhs = args[1]; // right hand side\n var rhsTex = rhs.toTex(options);\n if (parens[1]) {\n rhsTex = \"\\\\left(\".concat(rhsTex, \"\\\\right)\");\n }\n\n // handle some exceptions (due to the way LaTeX works)\n var lhsIdentifier;\n if (parenthesis === 'keep') {\n lhsIdentifier = lhs.getIdentifier();\n } else {\n // Ignore ParenthesisNodes if in 'keep' mode\n lhsIdentifier = lhs.getContent().getIdentifier();\n }\n switch (this.getIdentifier()) {\n case 'OperatorNode:divide':\n // op contains '\\\\frac' at this point\n return op + '{' + lhsTex + '}' + '{' + rhsTex + '}';\n case 'OperatorNode:pow':\n lhsTex = '{' + lhsTex + '}';\n rhsTex = '{' + rhsTex + '}';\n switch (lhsIdentifier) {\n case 'ConditionalNode': //\n case 'OperatorNode:divide':\n lhsTex = \"\\\\left(\".concat(lhsTex, \"\\\\right)\");\n }\n break;\n case 'OperatorNode:multiply':\n if (this.implicit && implicit === 'hide') {\n return lhsTex + '~' + rhsTex;\n }\n }\n return lhsTex + op + rhsTex;\n } else if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n var texifiedArgs = args.map(function (arg, index) {\n arg = arg.toTex(options);\n if (parens[index]) {\n arg = \"\\\\left(\".concat(arg, \"\\\\right)\");\n }\n return arg;\n });\n if (this.getIdentifier() === 'OperatorNode:multiply' && this.implicit && implicit === 'hide') {\n return texifiedArgs.join('~');\n }\n return texifiedArgs.join(op);\n } else {\n // fall back to formatting as a function call\n // as this is a fallback, it doesn't use\n // fancy function names\n return '\\\\mathrm{' + this.fn + '}\\\\left(' + args.map(function (arg) {\n return arg.toTex(options);\n }).join(',') + '\\\\right)';\n }\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type + ':' + this.fn;\n }\n }\n _defineProperty(OperatorNode, \"name\", name);\n return OperatorNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ParenthesisNode';\nvar dependencies = ['Node'];\nexport var createParenthesisNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ParenthesisNode extends Node {\n /**\n * @constructor ParenthesisNode\n * @extends {Node}\n * A parenthesis node describes manual parenthesis from the user input\n * @param {Node} content\n * @extends {Node}\n */\n constructor(content) {\n super();\n // validate input\n if (!isNode(content)) {\n throw new TypeError('Node expected for parameter \"content\"');\n }\n this.content = content;\n }\n get type() {\n return name;\n }\n get isParenthesisNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n return this.content._compile(math, argNames);\n }\n\n /**\n * Get the content of the current Node.\n * @return {Node} content\n * @override\n **/\n getContent() {\n return this.content.getContent();\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.content, 'content', this);\n }\n\n /**\n * Create a new ParenthesisNode whose child is the result of calling\n * the provided callback function on the child of this node.\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {ParenthesisNode} Returns a clone of the node\n */\n map(callback) {\n var content = callback(this.content, 'content', this);\n return new ParenthesisNode(content);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ParenthesisNode}\n */\n clone() {\n return new ParenthesisNode(this.content);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return '(' + this.content.toString(options) + ')';\n }\n return this.content.toString(options);\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n content: this.content\n };\n }\n\n /**\n * Instantiate an ParenthesisNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ParenthesisNode\", \"content\": ...}`,\n * where mathjs is optional\n * @returns {ParenthesisNode}\n */\n static fromJSON(json) {\n return new ParenthesisNode(json.content);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return '(' + this.content.toHTML(options) + ')';\n }\n return this.content.toHTML(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toTex(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return \"\\\\left(\".concat(this.content.toTex(options), \"\\\\right)\");\n }\n return this.content.toTex(options);\n }\n }\n _defineProperty(ParenthesisNode, \"name\", name);\n return ParenthesisNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode, isSymbolNode } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'RangeNode';\nvar dependencies = ['Node'];\nexport var createRangeNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Calculate the necessary parentheses\n * @param {Node} node\n * @param {string} parenthesis\n * @param {string} implicit\n * @return {Object} parentheses\n * @private\n */\n function calculateNecessaryParentheses(node, parenthesis, implicit) {\n var precedence = getPrecedence(node, parenthesis, implicit);\n var parens = {};\n var startPrecedence = getPrecedence(node.start, parenthesis, implicit);\n parens.start = startPrecedence !== null && startPrecedence <= precedence || parenthesis === 'all';\n if (node.step) {\n var stepPrecedence = getPrecedence(node.step, parenthesis, implicit);\n parens.step = stepPrecedence !== null && stepPrecedence <= precedence || parenthesis === 'all';\n }\n var endPrecedence = getPrecedence(node.end, parenthesis, implicit);\n parens.end = endPrecedence !== null && endPrecedence <= precedence || parenthesis === 'all';\n return parens;\n }\n class RangeNode extends Node {\n /**\n * @constructor RangeNode\n * @extends {Node}\n * create a range\n * @param {Node} start included lower-bound\n * @param {Node} end included upper-bound\n * @param {Node} [step] optional step\n */\n constructor(start, end, step) {\n super();\n // validate inputs\n if (!isNode(start)) throw new TypeError('Node expected');\n if (!isNode(end)) throw new TypeError('Node expected');\n if (step && !isNode(step)) throw new TypeError('Node expected');\n if (arguments.length > 3) throw new Error('Too many arguments');\n this.start = start; // included lower-bound\n this.end = end; // included upper-bound\n this.step = step || null; // optional step\n }\n get type() {\n return name;\n }\n get isRangeNode() {\n return true;\n }\n\n /**\n * Check whether the RangeNode needs the `end` symbol to be defined.\n * This end is the size of the Matrix in current dimension.\n * @return {boolean}\n */\n needsEnd() {\n // find all `end` symbols in this RangeNode\n var endSymbols = this.filter(function (node) {\n return isSymbolNode(node) && node.name === 'end';\n });\n return endSymbols.length > 0;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var range = math.range;\n var evalStart = this.start._compile(math, argNames);\n var evalEnd = this.end._compile(math, argNames);\n if (this.step) {\n var evalStep = this.step._compile(math, argNames);\n return function evalRangeNode(scope, args, context) {\n return range(evalStart(scope, args, context), evalEnd(scope, args, context), evalStep(scope, args, context));\n };\n } else {\n return function evalRangeNode(scope, args, context) {\n return range(evalStart(scope, args, context), evalEnd(scope, args, context));\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.start, 'start', this);\n callback(this.end, 'end', this);\n if (this.step) {\n callback(this.step, 'step', this);\n }\n }\n\n /**\n * Create a new RangeNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {RangeNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new RangeNode(this._ifNode(callback(this.start, 'start', this)), this._ifNode(callback(this.end, 'end', this)), this.step && this._ifNode(callback(this.step, 'step', this)));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {RangeNode}\n */\n clone() {\n return new RangeNode(this.start, this.end, this.step && this.step);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n\n // format string as start:step:stop\n var str;\n var start = this.start.toString(options);\n if (parens.start) {\n start = '(' + start + ')';\n }\n str = start;\n if (this.step) {\n var step = this.step.toString(options);\n if (parens.step) {\n step = '(' + step + ')';\n }\n str += ':' + step;\n }\n var end = this.end.toString(options);\n if (parens.end) {\n end = '(' + end + ')';\n }\n str += ':' + end;\n return str;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n start: this.start,\n end: this.end,\n step: this.step\n };\n }\n\n /**\n * Instantiate an RangeNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"RangeNode\", \"start\": ..., \"end\": ..., \"step\": ...}`,\n * where mathjs is optional\n * @returns {RangeNode}\n */\n static fromJSON(json) {\n return new RangeNode(json.start, json.end, json.step);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n\n // format string as start:step:stop\n var str;\n var start = this.start.toHTML(options);\n if (parens.start) {\n start = '(' + start + ')';\n }\n str = start;\n if (this.step) {\n var step = this.step.toHTML(options);\n if (parens.step) {\n step = '(' + step + ')';\n }\n str += ':' + step;\n }\n var end = this.end.toHTML(options);\n if (parens.end) {\n end = '(' + end + ')';\n }\n str += ':' + end;\n return str;\n }\n\n /**\n * Get LaTeX representation\n * @params {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n var str = this.start.toTex(options);\n if (parens.start) {\n str = \"\\\\left(\".concat(str, \"\\\\right)\");\n }\n if (this.step) {\n var step = this.step.toTex(options);\n if (parens.step) {\n step = \"\\\\left(\".concat(step, \"\\\\right)\");\n }\n str += ':' + step;\n }\n var end = this.end.toTex(options);\n if (parens.end) {\n end = \"\\\\left(\".concat(end, \"\\\\right)\");\n }\n str += ':' + end;\n return str;\n }\n }\n _defineProperty(RangeNode, \"name\", name);\n return RangeNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { getPrecedence } from '../operators.js';\nimport { escape } from '../../utils/string.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { latexOperators } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'RelationalNode';\nvar dependencies = ['Node'];\nexport var createRelationalNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n var operatorMap = {\n equal: '==',\n unequal: '!=',\n smaller: '<',\n larger: '>',\n smallerEq: '<=',\n largerEq: '>='\n };\n class RelationalNode extends Node {\n /**\n * A node representing a chained conditional expression, such as 'x > y > z'\n *\n * @param {String[]} conditionals\n * An array of conditional operators used to compare the parameters\n * @param {Node[]} params\n * The parameters that will be compared\n *\n * @constructor RelationalNode\n * @extends {Node}\n */\n constructor(conditionals, params) {\n super();\n if (!Array.isArray(conditionals)) {\n throw new TypeError('Parameter conditionals must be an array');\n }\n if (!Array.isArray(params)) {\n throw new TypeError('Parameter params must be an array');\n }\n if (conditionals.length !== params.length - 1) {\n throw new TypeError('Parameter params must contain exactly one more element ' + 'than parameter conditionals');\n }\n this.conditionals = conditionals;\n this.params = params;\n }\n get type() {\n return name;\n }\n get isRelationalNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var self = this;\n var compiled = this.params.map(p => p._compile(math, argNames));\n return function evalRelationalNode(scope, args, context) {\n var evalLhs;\n var evalRhs = compiled[0](scope, args, context);\n for (var i = 0; i < self.conditionals.length; i++) {\n evalLhs = evalRhs;\n evalRhs = compiled[i + 1](scope, args, context);\n var condFn = getSafeProperty(math, self.conditionals[i]);\n if (!condFn(evalLhs, evalRhs)) {\n return false;\n }\n }\n return true;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n this.params.forEach((n, i) => callback(n, 'params[' + i + ']', this), this);\n }\n\n /**\n * Create a new RelationalNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {RelationalNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new RelationalNode(this.conditionals.slice(), this.params.map((n, i) => this._ifNode(callback(n, 'params[' + i + ']', this)), this));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {RelationalNode}\n */\n clone() {\n return new RelationalNode(this.conditionals, this.params);\n }\n\n /**\n * Get string representation.\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '(' + p.toString(options) + ')' : p.toString(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += ' ' + operatorMap[this.conditionals[i]];\n ret += ' ' + paramStrings[i + 1];\n }\n return ret;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n conditionals: this.conditionals,\n params: this.params\n };\n }\n\n /**\n * Instantiate a RelationalNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"RelationalNode\", \"conditionals\": ..., \"params\": ...}`,\n * where mathjs is optional\n * @returns {RelationalNode}\n */\n static fromJSON(json) {\n return new RelationalNode(json.conditionals, json.params);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '(' + p.toHTML(options) + ')' : p.toHTML(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += '' + escape(operatorMap[this.conditionals[i]]) + '' + paramStrings[i + 1];\n }\n return ret;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '\\\\left(' + p.toTex(options) + '\\right)' : p.toTex(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += latexOperators[this.conditionals[i]] + paramStrings[i + 1];\n }\n return ret;\n }\n }\n _defineProperty(RelationalNode, \"name\", name);\n return RelationalNode;\n}, {\n isClass: true,\n isNode: true\n});","import { escape } from '../../utils/string.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { toSymbol } from '../../utils/latex.js';\nvar name = 'SymbolNode';\nvar dependencies = ['math', '?Unit', 'Node'];\nexport var createSymbolNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n math,\n Unit,\n Node\n } = _ref;\n /**\n * Check whether some name is a valueless unit like \"inch\".\n * @param {string} name\n * @return {boolean}\n */\n function isValuelessUnit(name) {\n return Unit ? Unit.isValuelessUnit(name) : false;\n }\n class SymbolNode extends Node {\n /**\n * @constructor SymbolNode\n * @extends {Node}\n * A symbol node can hold and resolve a symbol\n * @param {string} name\n * @extends {Node}\n */\n constructor(name) {\n super();\n // validate input\n if (typeof name !== 'string') {\n throw new TypeError('String expected for parameter \"name\"');\n }\n this.name = name;\n }\n get type() {\n return 'SymbolNode';\n }\n get isSymbolNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var name = this.name;\n if (argNames[name] === true) {\n // this is a FunctionAssignment argument\n // (like an x when inside the expression of a function\n // assignment `f(x) = ...`)\n return function (scope, args, context) {\n return getSafeProperty(args, name);\n };\n } else if (name in math) {\n return function (scope, args, context) {\n return scope.has(name) ? scope.get(name) : getSafeProperty(math, name);\n };\n } else {\n var isUnit = isValuelessUnit(name);\n return function (scope, args, context) {\n return scope.has(name) ? scope.get(name) : isUnit ? new Unit(null, name) : SymbolNode.onUndefinedSymbol(name);\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // nothing to do, we don't have any children\n }\n\n /**\n * Create a new SymbolNode with children produced by the given callback.\n * Trivial since a SymbolNode has no children\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {SymbolNode} Returns a clone of the node\n */\n map(callback) {\n return this.clone();\n }\n\n /**\n * Throws an error 'Undefined symbol {name}'\n * @param {string} name\n */\n static onUndefinedSymbol(name) {\n throw new Error('Undefined symbol ' + name);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {SymbolNode}\n */\n clone() {\n return new SymbolNode(this.name);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n return this.name;\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var name = escape(this.name);\n if (name === 'true' || name === 'false') {\n return '' + name + '';\n } else if (name === 'i') {\n return '' + name + '';\n } else if (name === 'Infinity') {\n return '' + name + '';\n } else if (name === 'NaN') {\n return '' + name + '';\n } else if (name === 'null') {\n return '' + name + '';\n } else if (name === 'undefined') {\n return '' + name + '';\n }\n return '' + name + '';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: 'SymbolNode',\n name: this.name\n };\n }\n\n /**\n * Instantiate a SymbolNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"SymbolNode\", name: \"x\"}`,\n * where mathjs is optional\n * @returns {SymbolNode}\n */\n static fromJSON(json) {\n return new SymbolNode(json.name);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toTex(options) {\n var isUnit = false;\n if (typeof math[this.name] === 'undefined' && isValuelessUnit(this.name)) {\n isUnit = true;\n }\n var symbol = toSymbol(this.name, isUnit);\n if (symbol[0] === '\\\\') {\n // no space needed if the symbol starts with '\\'\n return symbol;\n }\n // the space prevents symbols from breaking stuff like '\\cdot'\n // if it's written right before the symbol\n return ' ' + symbol;\n }\n }\n return SymbolNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isFunctionAssignmentNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';\nimport { escape, format } from '../../utils/string.js';\nimport { hasOwnProperty } from '../../utils/object.js';\nimport { getSafeProperty, getSafeMethod } from '../../utils/customs.js';\nimport { createSubScope } from '../../utils/scope.js';\nimport { factory } from '../../utils/factory.js';\nimport { defaultTemplate, latexFunctions } from '../../utils/latex.js';\nvar name = 'FunctionNode';\nvar dependencies = ['math', 'Node', 'SymbolNode'];\nexport var createFunctionNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var _FunctionNode;\n var {\n math,\n Node,\n SymbolNode\n } = _ref;\n /* format to fixed length */\n var strin = entity => format(entity, {\n truncate: 78\n });\n\n /*\n * Expand a LaTeX template\n *\n * @param {string} template\n * @param {Node} node\n * @param {Object} options\n * @private\n **/\n function expandTemplate(template, node, options) {\n var latex = '';\n\n // Match everything of the form ${identifier} or ${identifier[2]} or $$\n // while submatching identifier and 2 (in the second case)\n var regex = /\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)/gi;\n var inputPos = 0; // position in the input string\n var match;\n while ((match = regex.exec(template)) !== null) {\n // go through all matches\n // add everything in front of the match to the LaTeX string\n latex += template.substring(inputPos, match.index);\n inputPos = match.index;\n if (match[0] === '$$') {\n // escaped dollar sign\n latex += '$';\n inputPos++;\n } else {\n // template parameter\n inputPos += match[0].length;\n var property = node[match[1]];\n if (!property) {\n throw new ReferenceError('Template: Property ' + match[1] + ' does not exist.');\n }\n if (match[2] === undefined) {\n // no square brackets\n switch (typeof property) {\n case 'string':\n latex += property;\n break;\n case 'object':\n if (isNode(property)) {\n latex += property.toTex(options);\n } else if (Array.isArray(property)) {\n // make array of Nodes into comma separated list\n latex += property.map(function (arg, index) {\n if (isNode(arg)) {\n return arg.toTex(options);\n }\n throw new TypeError('Template: ' + match[1] + '[' + index + '] is not a Node.');\n }).join(',');\n } else {\n throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes');\n }\n break;\n default:\n throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes');\n }\n } else {\n // with square brackets\n if (isNode(property[match[2]] && property[match[2]])) {\n latex += property[match[2]].toTex(options);\n } else {\n throw new TypeError('Template: ' + match[1] + '[' + match[2] + '] is not a Node.');\n }\n }\n }\n }\n latex += template.slice(inputPos); // append rest of the template\n\n return latex;\n }\n class FunctionNode extends Node {\n /**\n * @constructor FunctionNode\n * @extends {./Node}\n * invoke a list with arguments on a node\n * @param {./Node | string} fn\n * Item resolving to a function on which to invoke\n * the arguments, typically a SymbolNode or AccessorNode\n * @param {./Node[]} args\n */\n constructor(fn, args, optional) {\n super();\n if (typeof fn === 'string') {\n fn = new SymbolNode(fn);\n }\n\n // validate input\n if (!isNode(fn)) throw new TypeError('Node expected as parameter \"fn\"');\n if (!Array.isArray(args) || !args.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"args\"');\n }\n var optionalType = typeof optional;\n if (!(optionalType === 'undefined' || optionalType === 'boolean')) {\n throw new TypeError('optional flag, if specified, must be boolean');\n }\n this.fn = fn;\n this.args = args || [];\n this.optional = !!optional;\n }\n\n // readonly property name\n get name() {\n return this.fn.name || '';\n }\n get type() {\n return name;\n }\n get isFunctionNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // compile arguments\n var evalArgs = this.args.map(arg => arg._compile(math, argNames));\n var fromOptionalChaining = this.optional || isAccessorNode(this.fn) && this.fn.optionalChaining;\n if (isSymbolNode(this.fn)) {\n var _name = this.fn.name;\n if (!argNames[_name]) {\n // we can statically determine whether the function\n // has the rawArgs property\n var fn = _name in math ? getSafeProperty(math, _name) : undefined;\n var isRaw = typeof fn === 'function' && fn.rawArgs === true;\n var resolveFn = scope => {\n var value;\n if (scope.has(_name)) {\n value = scope.get(_name);\n } else if (_name in math) {\n value = getSafeProperty(math, _name);\n } else if (fromOptionalChaining) value = undefined;else return FunctionNode.onUndefinedFunction(_name);\n if (typeof value === 'function' || fromOptionalChaining && value === undefined) {\n return value;\n }\n throw new TypeError(\"'\".concat(_name, \"' is not a function; its value is:\\n \").concat(strin(value)));\n };\n if (isRaw) {\n // pass unevaluated parameters (nodes) to the function\n // \"raw\" evaluation\n var rawArgs = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n\n // the original function can be overwritten in the scope with a non-rawArgs function\n if (fn.rawArgs === true) {\n return fn(rawArgs, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn(...values);\n }\n };\n } else {\n // \"regular\" evaluation\n switch (evalArgs.length) {\n case 0:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n return fn();\n };\n case 1:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var evalArg0 = evalArgs[0];\n return fn(evalArg0(scope, args, context));\n };\n case 2:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var evalArg0 = evalArgs[0];\n var evalArg1 = evalArgs[1];\n return fn(evalArg0(scope, args, context), evalArg1(scope, args, context));\n };\n default:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn(...values);\n };\n }\n }\n } else {\n // the function symbol is an argName\n var _rawArgs = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = getSafeProperty(args, _name);\n if (fromOptionalChaining && fn === undefined) return undefined;\n if (typeof fn !== 'function') {\n throw new TypeError(\"Argument '\".concat(_name, \"' was not a function; received: \").concat(strin(fn)));\n }\n if (fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs, math, createSubScope(scope, args));\n } else {\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(fn, values);\n }\n };\n }\n } else if (isAccessorNode(this.fn) && isIndexNode(this.fn.index) && this.fn.index.isObjectProperty()) {\n // execute the function with the right context:\n // the object of the AccessorNode\n\n var evalObject = this.fn.object._compile(math, argNames);\n var prop = this.fn.index.getObjectProperty();\n var _rawArgs2 = this.args;\n return function evalFunctionNode(scope, args, context) {\n var object = evalObject(scope, args, context);\n\n // Optional chaining: if the base object is nullish, short-circuit to undefined\n if (fromOptionalChaining && (object == null || object[prop] === undefined)) {\n return undefined;\n }\n var fn = getSafeMethod(object, prop);\n if (fn !== null && fn !== void 0 && fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs2, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(object, values);\n }\n };\n } else {\n // node.fn.isAccessorNode && !node.fn.index.isObjectProperty()\n // we have to dynamically determine whether the function has the\n // rawArgs property\n var fnExpr = this.fn.toString();\n var evalFn = this.fn._compile(math, argNames);\n var _rawArgs3 = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = evalFn(scope, args, context);\n if (fromOptionalChaining && fn === undefined) return undefined;\n if (typeof fn !== 'function') {\n throw new TypeError(\"Expression '\".concat(fnExpr, \"' did not evaluate to a function; value is:\") + \"\\n \".concat(strin(fn)));\n }\n if (fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs3, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(fn, values);\n }\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.fn, 'fn', this);\n for (var i = 0; i < this.args.length; i++) {\n callback(this.args[i], 'args[' + i + ']', this);\n }\n }\n\n /**\n * Create a new FunctionNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {FunctionNode} Returns a transformed copy of the node\n */\n map(callback) {\n var fn = this._ifNode(callback(this.fn, 'fn', this));\n var args = [];\n for (var i = 0; i < this.args.length; i++) {\n args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this));\n }\n return new FunctionNode(fn, args);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {FunctionNode}\n */\n clone() {\n return new FunctionNode(this.fn, this.args.slice(0));\n }\n\n /**\n * Throws an error 'Undefined function {name}'\n * @param {string} name\n */\n\n /**\n * Get string representation. (wrapper function)\n * This overrides parts of Node's toString function.\n * If callback is an object containing callbacks, it\n * calls the correct callback for the current node,\n * otherwise it falls back to calling Node's toString\n * function.\n *\n * @param {Object} options\n * @return {string} str\n * @override\n */\n toString(options) {\n var customString;\n var name = this.fn.toString(options);\n if (options && typeof options.handler === 'object' && hasOwnProperty(options.handler, name)) {\n // callback is a map of callback functions\n customString = options.handler[name](this, options);\n }\n if (typeof customString !== 'undefined') {\n return customString;\n }\n\n // fall back to Node's toString\n return super.toString(options);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var args = this.args.map(function (arg) {\n return arg.toString(options);\n });\n var fn = isFunctionAssignmentNode(this.fn) ? '(' + this.fn.toString(options) + ')' : this.fn.toString(options);\n\n // format the arguments like \"add(2, 4.2)\"\n return fn + '(' + args.join(', ') + ')';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n fn: this.fn,\n args: this.args\n };\n }\n\n /**\n * Instantiate an AssignmentNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"FunctionNode\", fn: ..., args: ...}`,\n * where mathjs is optional\n * @returns {FunctionNode}\n */\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var args = this.args.map(function (arg) {\n return arg.toHTML(options);\n });\n\n // format the arguments like \"add(2, 4.2)\"\n return '' + escape(this.fn) + '(' + args.join(',') + ')';\n }\n\n /**\n * Get LaTeX representation. (wrapper function)\n * This overrides parts of Node's toTex function.\n * If callback is an object containing callbacks, it\n * calls the correct callback for the current node,\n * otherwise it falls back to calling Node's toTex\n * function.\n *\n * @param {Object} options\n * @return {string}\n */\n toTex(options) {\n var customTex;\n if (options && typeof options.handler === 'object' && hasOwnProperty(options.handler, this.name)) {\n // callback is a map of callback functions\n customTex = options.handler[this.name](this, options);\n }\n if (typeof customTex !== 'undefined') {\n return customTex;\n }\n\n // fall back to Node's toTex\n return super.toTex(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var args = this.args.map(function (arg) {\n // get LaTeX of the arguments\n return arg.toTex(options);\n });\n var latexConverter;\n if (latexFunctions[this.name]) {\n latexConverter = latexFunctions[this.name];\n }\n\n // toTex property on the function itself\n if (math[this.name] && (typeof math[this.name].toTex === 'function' || typeof math[this.name].toTex === 'object' || typeof math[this.name].toTex === 'string')) {\n // .toTex is a callback function\n latexConverter = math[this.name].toTex;\n }\n var customToTex;\n switch (typeof latexConverter) {\n case 'function':\n // a callback function\n customToTex = latexConverter(this, options);\n break;\n case 'string':\n // a template string\n customToTex = expandTemplate(latexConverter, this, options);\n break;\n case 'object':\n // an object with different \"converters\" for different\n // numbers of arguments\n switch (typeof latexConverter[args.length]) {\n case 'function':\n customToTex = latexConverter[args.length](this, options);\n break;\n case 'string':\n customToTex = expandTemplate(latexConverter[args.length], this, options);\n break;\n }\n }\n if (typeof customToTex !== 'undefined') {\n return customToTex;\n }\n return expandTemplate(defaultTemplate, this, options);\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type + ':' + this.name;\n }\n }\n _FunctionNode = FunctionNode;\n _defineProperty(FunctionNode, \"name\", name);\n _defineProperty(FunctionNode, \"onUndefinedFunction\", function (name) {\n throw new Error('Undefined function ' + name);\n });\n _defineProperty(FunctionNode, \"fromJSON\", function (json) {\n return new _FunctionNode(json.fn, json.args);\n });\n return FunctionNode;\n}, {\n isClass: true,\n isNode: true\n});","import _extends from \"@babel/runtime/helpers/extends\";\nimport { factory } from '../utils/factory.js';\nimport { isAccessorNode, isConstantNode, isFunctionNode, isOperatorNode, isSymbolNode, rule2Node } from '../utils/is.js';\nimport { deepMap } from '../utils/collection.js';\nimport { safeNumberType } from '../utils/number.js';\nimport { hasOwnProperty } from '../utils/object.js';\nvar name = 'parse';\nvar dependencies = ['typed', 'numeric', 'config', 'AccessorNode', 'ArrayNode', 'AssignmentNode', 'BlockNode', 'ConditionalNode', 'ConstantNode', 'FunctionAssignmentNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'RangeNode', 'RelationalNode', 'SymbolNode'];\nexport var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n numeric,\n config,\n AccessorNode,\n ArrayNode,\n AssignmentNode,\n BlockNode,\n ConditionalNode,\n ConstantNode,\n FunctionAssignmentNode,\n FunctionNode,\n IndexNode,\n ObjectNode,\n OperatorNode,\n ParenthesisNode,\n RangeNode,\n RelationalNode,\n SymbolNode\n } = _ref;\n /**\n * Parse an expression. Returns a node tree, which can be evaluated by\n * invoking node.evaluate() or transformed into a functional object via node.compile().\n *\n * Note the evaluating arbitrary expressions may involve security risks,\n * see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.\n *\n * Syntax:\n *\n * math.parse(expr)\n * math.parse(expr, options)\n * math.parse([expr1, expr2, expr3, ...])\n * math.parse([expr1, expr2, expr3, ...], options)\n *\n * Example:\n *\n * const node1 = math.parse('sqrt(3^2 + 4^2)')\n * node1.compile().evaluate() // 5\n *\n * let scope = {a:3, b:4}\n * const node2 = math.parse('a * b')\n * node2.evaluate(scope) // 12\n * const code2 = node2.compile()\n * code2.evaluate(scope) // 12\n * scope.a = 5\n * code2.evaluate(scope) // 20\n *\n * const nodes = math.parse(['a = 3', 'b = 4', 'a * b'])\n * nodes[2].compile().evaluate() // 12\n *\n * See also:\n *\n * evaluate, compile\n *\n * History:\n *\n * v0.9 Created\n * v0.13 Switched to one-based indices\n * v0.14 Added `[1,2;3,4]` notation for matrices\n * v0.18 Dropped the `function` keyword\n * v0.20 Added ternary conditional\n * v0.27 Allow multi-line expressions; allow functions that receive\n * unevaluated parameters (`rawArgs`)\n * v3 Add object notation; allow assignments internal to other\n * expressions\n * v7.3 Supported binary, octal, and hexadecimal notation\n * v9.5 Support for calculations with percentages\n * v12.4 Allow trailing commas in matrices\n * v14.8 Add nullish coalescing operator\n * v15.1 Add optional chaining operator\n *\n * @param {string | string[] | Matrix} expr Expression to be parsed\n * @param {{nodes: Object}} [options] Available options:\n * - `nodes` a set of custom nodes\n * @return {Node | Node[]} node\n * @throws {Error}\n */\n var parse = typed(name, {\n string: function string(expression) {\n return parseStart(expression, {});\n },\n 'Array | Matrix': function Array__Matrix(expressions) {\n return parseMultiple(expressions, {});\n },\n 'string, Object': function string_Object(expression, options) {\n var extraNodes = options.nodes !== undefined ? options.nodes : {};\n return parseStart(expression, extraNodes);\n },\n 'Array | Matrix, Object': parseMultiple\n });\n function parseMultiple(expressions) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var extraNodes = options.nodes !== undefined ? options.nodes : {};\n\n // parse an array or matrix with expressions\n return deepMap(expressions, function (elem) {\n if (typeof elem !== 'string') throw new TypeError('String expected');\n return parseStart(elem, extraNodes);\n });\n }\n\n // token types enumeration\n var TOKENTYPE = {\n NULL: 0,\n DELIMITER: 1,\n NUMBER: 2,\n SYMBOL: 3,\n UNKNOWN: 4\n };\n\n // map with all delimiters\n var DELIMITERS = {\n ',': true,\n '(': true,\n ')': true,\n '[': true,\n ']': true,\n '{': true,\n '}': true,\n '\"': true,\n '\\'': true,\n ';': true,\n '+': true,\n '-': true,\n '*': true,\n '.*': true,\n '/': true,\n './': true,\n '%': true,\n '^': true,\n '.^': true,\n '~': true,\n '!': true,\n '&': true,\n '|': true,\n '^|': true,\n '=': true,\n ':': true,\n '?': true,\n '?.': true,\n '??': true,\n '==': true,\n '!=': true,\n '<': true,\n '>': true,\n '<=': true,\n '>=': true,\n '<<': true,\n '>>': true,\n '>>>': true\n };\n\n // map with all named delimiters\n var NAMED_DELIMITERS = {\n mod: true,\n to: true,\n in: true,\n and: true,\n xor: true,\n or: true,\n not: true\n };\n var CONSTANTS = {\n true: true,\n false: false,\n null: null,\n undefined\n };\n var NUMERIC_CONSTANTS = ['NaN', 'Infinity'];\n var ESCAPE_CHARACTERS = {\n '\"': '\"',\n \"'\": \"'\",\n '\\\\': '\\\\',\n '/': '/',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t'\n // note that \\u is handled separately in parseStringToken()\n };\n function initialState() {\n return {\n extraNodes: {},\n // current extra nodes, must be careful not to mutate\n expression: '',\n // current expression\n comment: '',\n // last parsed comment\n index: 0,\n // current index in expr\n token: '',\n // current token\n tokenType: TOKENTYPE.NULL,\n // type of the token\n nestingLevel: 0,\n // level of nesting inside parameters, used to ignore newline characters\n conditionalLevel: null // when a conditional is being parsed, the level of the conditional is stored here\n };\n }\n\n /**\n * View upto `length` characters of the expression starting at the current character.\n *\n * @param {Object} state\n * @param {number} [length=1] Number of characters to view\n * @returns {string}\n * @private\n */\n function currentString(state, length) {\n return state.expression.substr(state.index, length);\n }\n\n /**\n * View the current character. Returns '' if end of expression is reached.\n *\n * @param {Object} state\n * @returns {string}\n * @private\n */\n function currentCharacter(state) {\n return currentString(state, 1);\n }\n\n /**\n * Get the next character from the expression.\n * The character is stored into the char c. If the end of the expression is\n * reached, the function puts an empty string in c.\n * @private\n */\n function next(state) {\n state.index++;\n }\n\n /**\n * Preview the previous character from the expression.\n * @return {string} cNext\n * @private\n */\n function prevCharacter(state) {\n return state.expression.charAt(state.index - 1);\n }\n\n /**\n * Preview the next character from the expression.\n * @return {string} cNext\n * @private\n */\n function nextCharacter(state) {\n return state.expression.charAt(state.index + 1);\n }\n\n /**\n * Get next token in the current string expr.\n * The token and token type are available as token and tokenType\n * @private\n */\n function getToken(state) {\n state.tokenType = TOKENTYPE.NULL;\n state.token = '';\n state.comment = '';\n\n // skip over ignored characters:\n while (true) {\n // comments:\n if (currentCharacter(state) === '#') {\n while (currentCharacter(state) !== '\\n' && currentCharacter(state) !== '') {\n state.comment += currentCharacter(state);\n next(state);\n }\n }\n // whitespace: space, tab, and newline when inside parameters\n if (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {\n next(state);\n } else {\n break;\n }\n }\n\n // check for end of expression\n if (currentCharacter(state) === '') {\n // token is still empty\n state.tokenType = TOKENTYPE.DELIMITER;\n return;\n }\n\n // check for new line character\n if (currentCharacter(state) === '\\n' && !state.nestingLevel) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = currentCharacter(state);\n next(state);\n return;\n }\n var c1 = currentCharacter(state);\n var c2 = currentString(state, 2);\n var c3 = currentString(state, 3);\n if (c3.length === 3 && DELIMITERS[c3]) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c3;\n next(state);\n next(state);\n next(state);\n return;\n }\n\n // check for delimiters consisting of 2 characters\n // Special case: the check for '?.' is to prevent a case like 'a?.3:.7' from being interpreted as optional chaining\n // TODO: refactor the tokenization into some better way to deal with cases like 'a?.3:.7', see https://github.com/josdejong/mathjs/pull/3584\n if (c2.length === 2 && DELIMITERS[c2] && (c2 !== '?.' || !parse.isDigit(state.expression.charAt(state.index + 2)))) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c2;\n next(state);\n next(state);\n return;\n }\n\n // check for delimiters consisting of 1 character\n if (DELIMITERS[c1]) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c1;\n next(state);\n return;\n }\n\n // check for a number\n if (parse.isDigitDot(c1)) {\n state.tokenType = TOKENTYPE.NUMBER;\n\n // check for binary, octal, or hex\n var _c = currentString(state, 2);\n if (_c === '0b' || _c === '0o' || _c === '0x') {\n state.token += currentCharacter(state);\n next(state);\n state.token += currentCharacter(state);\n next(state);\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (currentCharacter(state) === '.') {\n // this number has a radix point\n state.token += '.';\n next(state);\n // get the digits after the radix\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n } else if (currentCharacter(state) === 'i') {\n // this number has a word size suffix\n state.token += 'i';\n next(state);\n // get the word size\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n }\n return;\n }\n\n // get number, can have a single dot\n if (currentCharacter(state) === '.') {\n state.token += currentCharacter(state);\n next(state);\n if (!parse.isDigit(currentCharacter(state))) {\n // this is no number, it is just a dot (can be dot notation)\n state.tokenType = TOKENTYPE.DELIMITER;\n return;\n }\n } else {\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (parse.isDecimalMark(currentCharacter(state), nextCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n }\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n // check for exponential notation like \"2.3e-4\", \"1.23e50\" or \"2e+4\"\n if (currentCharacter(state) === 'E' || currentCharacter(state) === 'e') {\n if (parse.isDigit(nextCharacter(state)) || nextCharacter(state) === '-' || nextCharacter(state) === '+') {\n state.token += currentCharacter(state);\n next(state);\n if (currentCharacter(state) === '+' || currentCharacter(state) === '-') {\n state.token += currentCharacter(state);\n next(state);\n }\n // Scientific notation MUST be followed by an exponent\n if (!parse.isDigit(currentCharacter(state))) {\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (parse.isDecimalMark(currentCharacter(state), nextCharacter(state))) {\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n } else if (parse.isDecimalMark(nextCharacter(state), state.expression.charAt(state.index + 2))) {\n next(state);\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n }\n return;\n }\n\n // check for variables, functions, named operators\n if (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state))) {\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (hasOwnProperty(NAMED_DELIMITERS, state.token)) {\n state.tokenType = TOKENTYPE.DELIMITER;\n } else {\n state.tokenType = TOKENTYPE.SYMBOL;\n }\n return;\n }\n\n // something unknown is found, wrong characters -> a syntax error\n state.tokenType = TOKENTYPE.UNKNOWN;\n while (currentCharacter(state) !== '') {\n state.token += currentCharacter(state);\n next(state);\n }\n throw createSyntaxError(state, 'Syntax error in part \"' + state.token + '\"');\n }\n\n /**\n * Get next token and skip newline tokens\n */\n function getTokenSkipNewline(state) {\n do {\n getToken(state);\n } while (state.token === '\\n'); // eslint-disable-line no-unmodified-loop-condition\n }\n\n /**\n * Open parameters.\n * New line characters will be ignored until closeParams(state) is called\n */\n function openParams(state) {\n state.nestingLevel++;\n }\n\n /**\n * Close parameters.\n * New line characters will no longer be ignored\n */\n function closeParams(state) {\n state.nestingLevel--;\n }\n\n /**\n * Checks whether the current character `c` is a valid alpha character:\n *\n * - A latin letter (upper or lower case) Ascii: a-z, A-Z\n * - An underscore Ascii: _\n * - A dollar sign Ascii: $\n * - A latin letter with accents Unicode: \\u00C0 - \\u02AF\n * - A greek letter Unicode: \\u0370 - \\u03FF\n * - A mathematical alphanumeric symbol Unicode: \\u{1D400} - \\u{1D7FF} excluding invalid code points\n *\n * The previous and next characters are needed to determine whether\n * this character is part of a unicode surrogate pair.\n *\n * @param {string} c Current character in the expression\n * @param {string} cPrev Previous character\n * @param {string} cNext Next character\n * @return {boolean}\n */\n parse.isAlpha = function isAlpha(c, cPrev, cNext) {\n return parse.isValidLatinOrGreek(c) || parse.isValidMathSymbol(c, cNext) || parse.isValidMathSymbol(cPrev, c);\n };\n\n /**\n * Test whether a character is a valid latin, greek, or letter-like character\n * @param {string} c\n * @return {boolean}\n */\n parse.isValidLatinOrGreek = function isValidLatinOrGreek(c) {\n return /^[a-zA-Z_$\\u00C0-\\u02AF\\u0370-\\u03FF\\u2100-\\u214F]$/.test(c);\n };\n\n /**\n * Test whether two given 16 bit characters form a surrogate pair of a\n * unicode math symbol.\n *\n * https://unicode-table.com/en/\n * https://www.wikiwand.com/en/Mathematical_operators_and_symbols_in_Unicode\n *\n * Note: In ES6 will be unicode aware:\n * https://stackoverflow.com/questions/280712/javascript-unicode-regexes\n * https://mathiasbynens.be/notes/es6-unicode-regex\n *\n * @param {string} high\n * @param {string} low\n * @return {boolean}\n */\n parse.isValidMathSymbol = function isValidMathSymbol(high, low) {\n return /^[\\uD835]$/.test(high) && /^[\\uDC00-\\uDFFF]$/.test(low) && /^[^\\uDC55\\uDC9D\\uDCA0\\uDCA1\\uDCA3\\uDCA4\\uDCA7\\uDCA8\\uDCAD\\uDCBA\\uDCBC\\uDCC4\\uDD06\\uDD0B\\uDD0C\\uDD15\\uDD1D\\uDD3A\\uDD3F\\uDD45\\uDD47-\\uDD49\\uDD51\\uDEA6\\uDEA7\\uDFCC\\uDFCD]$/.test(low);\n };\n\n /**\n * Check whether given character c is a white space character: space, tab, or enter\n * @param {string} c\n * @param {number} nestingLevel\n * @return {boolean}\n */\n parse.isWhitespace = function isWhitespace(c, nestingLevel) {\n // TODO: also take '\\r' carriage return as newline? Or does that give problems on mac?\n return c === ' ' || c === '\\t' || c === '\\u00A0' || c === '\\n' && nestingLevel > 0;\n };\n\n /**\n * Test whether the character c is a decimal mark (dot).\n * This is the case when it's not the start of a delimiter '.*', './', or '.^'\n * @param {string} c\n * @param {string} cNext\n * @return {boolean}\n */\n parse.isDecimalMark = function isDecimalMark(c, cNext) {\n return c === '.' && cNext !== '/' && cNext !== '*' && cNext !== '^';\n };\n\n /**\n * checks if the given char c is a digit or dot\n * @param {string} c a string with one character\n * @return {boolean}\n */\n parse.isDigitDot = function isDigitDot(c) {\n return c >= '0' && c <= '9' || c === '.';\n };\n\n /**\n * checks if the given char c is a digit\n * @param {string} c a string with one character\n * @return {boolean}\n */\n parse.isDigit = function isDigit(c) {\n return c >= '0' && c <= '9';\n };\n\n /**\n * Start of the parse levels below, in order of precedence\n * @return {Node} node\n * @private\n */\n function parseStart(expression, extraNodes) {\n var state = initialState();\n _extends(state, {\n expression,\n extraNodes\n });\n getToken(state);\n var node = parseBlock(state);\n\n // check for garbage at the end of the expression\n // an expression ends with a empty character '' and tokenType DELIMITER\n if (state.token !== '') {\n if (state.tokenType === TOKENTYPE.DELIMITER) {\n // user entered a not existing operator like \"//\"\n\n // TODO: give hints for aliases, for example with \"<>\" give as hint \" did you mean !== ?\"\n throw createError(state, 'Unexpected operator ' + state.token);\n } else {\n throw createSyntaxError(state, 'Unexpected part \"' + state.token + '\"');\n }\n }\n return node;\n }\n\n /**\n * Parse a block with expressions. Expressions can be separated by a newline\n * character '\\n', or by a semicolon ';'. In case of a semicolon, no output\n * of the preceding line is returned.\n * @return {Node} node\n * @private\n */\n function parseBlock(state) {\n var node;\n var blocks = [];\n var visible;\n if (state.token !== '' && state.token !== '\\n' && state.token !== ';') {\n node = parseAssignment(state);\n if (state.comment) {\n node.comment = state.comment;\n }\n }\n\n // TODO: simplify this loop\n while (state.token === '\\n' || state.token === ';') {\n // eslint-disable-line no-unmodified-loop-condition\n if (blocks.length === 0 && node) {\n visible = state.token !== ';';\n blocks.push({\n node,\n visible\n });\n }\n getToken(state);\n if (state.token !== '\\n' && state.token !== ';' && state.token !== '') {\n node = parseAssignment(state);\n if (state.comment) {\n node.comment = state.comment;\n }\n visible = state.token !== ';';\n blocks.push({\n node,\n visible\n });\n }\n }\n if (blocks.length > 0) {\n return new BlockNode(blocks);\n } else {\n if (!node) {\n node = new ConstantNode(undefined);\n if (state.comment) {\n node.comment = state.comment;\n }\n }\n return node;\n }\n }\n\n /**\n * Assignment of a function or variable,\n * - can be a variable like 'a=2.3'\n * - or a updating an existing variable like 'matrix(2,3:5)=[6,7,8]'\n * - defining a function like 'f(x) = x^2'\n * @return {Node} node\n * @private\n */\n function parseAssignment(state) {\n var name, args, value, valid;\n var node = parseConditional(state);\n if (state.token === '=') {\n if (isSymbolNode(node)) {\n // parse a variable assignment like 'a = 2/3'\n name = node.name;\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new AssignmentNode(new SymbolNode(name), value);\n } else if (isAccessorNode(node)) {\n // parse a matrix subset assignment like 'A[1,2] = 4'\n if (node.optionalChaining) {\n throw createSyntaxError(state, 'Cannot assign to optional chain');\n }\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new AssignmentNode(node.object, node.index, value);\n } else if (isFunctionNode(node) && isSymbolNode(node.fn)) {\n // parse function assignment like 'f(x) = x^2'\n valid = true;\n args = [];\n name = node.name;\n node.args.forEach(function (arg, index) {\n if (isSymbolNode(arg)) {\n args[index] = arg.name;\n } else {\n valid = false;\n }\n });\n if (valid) {\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new FunctionAssignmentNode(name, args, value);\n }\n }\n throw createSyntaxError(state, 'Invalid left hand side of assignment operator =');\n }\n return node;\n }\n\n /**\n * conditional operation\n *\n * condition ? truePart : falsePart\n *\n * Note: conditional operator is right-associative\n *\n * @return {Node} node\n * @private\n */\n function parseConditional(state) {\n var node = parseLogicalOr(state);\n while (state.token === '?') {\n // eslint-disable-line no-unmodified-loop-condition\n // set a conditional level, the range operator will be ignored as long\n // as conditionalLevel === state.nestingLevel.\n var prev = state.conditionalLevel;\n state.conditionalLevel = state.nestingLevel;\n getTokenSkipNewline(state);\n var condition = node;\n var trueExpr = parseAssignment(state);\n if (state.token !== ':') throw createSyntaxError(state, 'False part of conditional expression expected');\n state.conditionalLevel = null;\n getTokenSkipNewline(state);\n var falseExpr = parseAssignment(state); // Note: check for conditional operator again, right associativity\n\n node = new ConditionalNode(condition, trueExpr, falseExpr);\n\n // restore the previous conditional level\n state.conditionalLevel = prev;\n }\n return node;\n }\n\n /**\n * logical or, 'x or y'\n * @return {Node} node\n * @private\n */\n function parseLogicalOr(state) {\n var node = parseLogicalXor(state);\n while (state.token === 'or') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('or', 'or', [node, parseLogicalXor(state)]);\n }\n return node;\n }\n\n /**\n * logical exclusive or, 'x xor y'\n * @return {Node} node\n * @private\n */\n function parseLogicalXor(state) {\n var node = parseLogicalAnd(state);\n while (state.token === 'xor') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd(state)]);\n }\n return node;\n }\n\n /**\n * logical and, 'x and y'\n * @return {Node} node\n * @private\n */\n function parseLogicalAnd(state) {\n var node = parseBitwiseOr(state);\n while (state.token === 'and') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('and', 'and', [node, parseBitwiseOr(state)]);\n }\n return node;\n }\n\n /**\n * bitwise or, 'x | y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseOr(state) {\n var node = parseBitwiseXor(state);\n while (state.token === '|') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor(state)]);\n }\n return node;\n }\n\n /**\n * bitwise exclusive or (xor), 'x ^| y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseXor(state) {\n var node = parseBitwiseAnd(state);\n while (state.token === '^|') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd(state)]);\n }\n return node;\n }\n\n /**\n * bitwise and, 'x & y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseAnd(state) {\n var node = parseRelational(state);\n while (state.token === '&') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('&', 'bitAnd', [node, parseRelational(state)]);\n }\n return node;\n }\n\n /**\n * Parse a chained conditional, like 'a > b >= c'\n * @return {Node} node\n */\n function parseRelational(state) {\n var params = [parseShift(state)];\n var conditionals = [];\n var operators = {\n '==': 'equal',\n '!=': 'unequal',\n '<': 'smaller',\n '>': 'larger',\n '<=': 'smallerEq',\n '>=': 'largerEq'\n };\n while (hasOwnProperty(operators, state.token)) {\n // eslint-disable-line no-unmodified-loop-condition\n var cond = {\n name: state.token,\n fn: operators[state.token]\n };\n conditionals.push(cond);\n getTokenSkipNewline(state);\n params.push(parseShift(state));\n }\n if (params.length === 1) {\n return params[0];\n } else if (params.length === 2) {\n return new OperatorNode(conditionals[0].name, conditionals[0].fn, params);\n } else {\n return new RelationalNode(conditionals.map(c => c.fn), params);\n }\n }\n\n /**\n * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift\n * @return {Node} node\n * @private\n */\n function parseShift(state) {\n var node, name, fn, params;\n node = parseConversion(state);\n var operators = {\n '<<': 'leftShift',\n '>>': 'rightArithShift',\n '>>>': 'rightLogShift'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n params = [node, parseConversion(state)];\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * conversion operators 'to' and 'in'\n * @return {Node} node\n * @private\n */\n function parseConversion(state) {\n var node, name, fn, params;\n node = parseRange(state);\n var operators = {\n to: 'to',\n in: 'to' // alias of 'to'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n if (name === 'in' && '])},;'.includes(state.token)) {\n // end of expression -> this is the unit 'in' ('inch')\n node = new OperatorNode('*', 'multiply', [node, new SymbolNode('in')], true);\n } else {\n // operator 'a to b' or 'a in b'\n params = [node, parseRange(state)];\n node = new OperatorNode(name, fn, params);\n }\n }\n return node;\n }\n\n /**\n * parse range, \"start:end\", \"start:step:end\", \":\", \"start:\", \":end\", etc\n * @return {Node} node\n * @private\n */\n function parseRange(state) {\n var node;\n var params = [];\n if (state.token === ':') {\n if (state.conditionalLevel === state.nestingLevel) {\n // we are in the midst of parsing a conditional operator, so not\n // a range, but rather an empty true-expr, which is considered a\n // syntax error\n throw createSyntaxError(state, 'The true-expression of a conditional operator may not be empty');\n } else {\n // implicit start of range = 1 (one-based)\n node = new ConstantNode(1);\n }\n } else {\n // explicit start\n node = parseAddSubtract(state);\n }\n if (state.token === ':' && state.conditionalLevel !== state.nestingLevel) {\n // we ignore the range operator when a conditional operator is being processed on the same level\n params.push(node);\n\n // parse step and end\n while (state.token === ':' && params.length < 3) {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n if (state.token === ')' || state.token === ']' || state.token === ',' || state.token === '') {\n // implicit end\n params.push(new SymbolNode('end'));\n } else {\n // explicit end\n params.push(parseAddSubtract(state));\n }\n }\n if (params.length === 3) {\n // params = [start, step, end]\n node = new RangeNode(params[0], params[2], params[1]); // start, end, step\n } else {\n // length === 2\n // params = [start, end]\n node = new RangeNode(params[0], params[1]); // start, end\n }\n }\n return node;\n }\n\n /**\n * add or subtract\n * @return {Node} node\n * @private\n */\n function parseAddSubtract(state) {\n var node, name, fn, params;\n node = parseMultiplyDivideModulus(state);\n var operators = {\n '+': 'add',\n '-': 'subtract'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n var rightNode = parseMultiplyDivideModulus(state);\n if (rightNode.isPercentage) {\n params = [node, new OperatorNode('*', 'multiply', [node, rightNode])];\n } else {\n params = [node, rightNode];\n }\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * multiply, divide, modulus\n * @return {Node} node\n * @private\n */\n function parseMultiplyDivideModulus(state) {\n var node, last, name, fn;\n node = parseImplicitMultiplication(state);\n last = node;\n var operators = {\n '*': 'multiply',\n '.*': 'dotMultiply',\n '/': 'divide',\n './': 'dotDivide',\n '%': 'mod',\n mod: 'mod'\n };\n while (true) {\n if (hasOwnProperty(operators, state.token)) {\n // explicit operators\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n last = parseImplicitMultiplication(state);\n node = new OperatorNode(name, fn, [node, last]);\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * implicit multiplication\n * @return {Node} node\n * @private\n */\n function parseImplicitMultiplication(state) {\n var node, last;\n node = parseRule2(state);\n last = node;\n while (true) {\n if (state.tokenType === TOKENTYPE.SYMBOL || state.token === 'in' && isConstantNode(node) || state.token === 'in' && isOperatorNode(node) && node.fn === 'unaryMinus' && isConstantNode(node.args[0]) || state.tokenType === TOKENTYPE.NUMBER && !isConstantNode(last) && (!isOperatorNode(last) || last.op === '!') || state.token === '(') {\n // parse implicit multiplication\n //\n // symbol: implicit multiplication like '2a', '(2+3)a', 'a b'\n // number: implicit multiplication like '(2+3)2'\n // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)'\n last = parseRule2(state);\n node = new OperatorNode('*', 'multiply', [node, last], true /* implicit */);\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * Infamous \"rule 2\" as described in https://github.com/josdejong/mathjs/issues/792#issuecomment-361065370\n * And as amended in https://github.com/josdejong/mathjs/issues/2370#issuecomment-1054052164\n * Explicit division gets higher precedence than implicit multiplication\n * when the division matches this pattern:\n * [unaryPrefixOp]?[number] / [number] [symbol]\n * @return {Node} node\n * @private\n */\n function parseRule2(state) {\n var node = parseUnaryPercentage(state);\n var last = node;\n var tokenStates = [];\n while (true) {\n // Match the \"number /\" part of the pattern \"number / number symbol\"\n if (state.token === '/' && rule2Node(last)) {\n // Look ahead to see if the next token is a number\n tokenStates.push(_extends({}, state));\n getTokenSkipNewline(state);\n\n // Match the \"number / number\" part of the pattern\n if (state.tokenType === TOKENTYPE.NUMBER) {\n // Look ahead again\n tokenStates.push(_extends({}, state));\n getTokenSkipNewline(state);\n\n // Match the \"symbol\" part of the pattern, or a left parenthesis\n if (state.tokenType === TOKENTYPE.SYMBOL || state.token === '(' || state.token === 'in') {\n // We've matched the pattern \"number / number symbol\".\n // Rewind once and build the \"number / number\" node; the symbol will be consumed later\n _extends(state, tokenStates.pop());\n tokenStates.pop();\n last = parseUnaryPercentage(state);\n node = new OperatorNode('/', 'divide', [node, last]);\n } else {\n // Not a match, so rewind\n tokenStates.pop();\n _extends(state, tokenStates.pop());\n break;\n }\n } else {\n // Not a match, so rewind\n _extends(state, tokenStates.pop());\n break;\n }\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * Unary percentage operator (treated as `value / 100`)\n * @return {Node} node\n * @private\n */\n function parseUnaryPercentage(state) {\n var node = parseUnary(state);\n if (state.token === '%') {\n var previousState = _extends({}, state);\n getTokenSkipNewline(state);\n // We need to decide if this is a unary percentage % or binary modulo %\n // So we attempt to parse a unary expression at this point.\n // If it fails, then the only possibility is that this is a unary percentage.\n // If it succeeds, then we presume that this must be binary modulo, since the\n // only things that parseUnary can handle are _higher_ precedence than unary %.\n try {\n parseUnary(state);\n // Not sure if we could somehow use the result of that parseUnary? Without\n // further analysis/testing, safer just to discard and let the parse proceed\n _extends(state, previousState);\n } catch (_unused) {\n // Not seeing a term at this point, so was a unary %\n node = new OperatorNode('/', 'divide', [node, new ConstantNode(100)], false, true);\n }\n }\n return node;\n }\n\n /**\n * Unary plus and minus, and logical and bitwise not\n * @return {Node} node\n * @private\n */\n function parseUnary(state) {\n var name, params, fn;\n var operators = {\n '-': 'unaryMinus',\n '+': 'unaryPlus',\n '~': 'bitNot',\n not: 'not'\n };\n if (hasOwnProperty(operators, state.token)) {\n fn = operators[state.token];\n name = state.token;\n getTokenSkipNewline(state);\n params = [parseUnary(state)];\n return new OperatorNode(name, fn, params);\n }\n return parsePow(state);\n }\n\n /**\n * power\n * Note: power operator is right associative\n * @return {Node} node\n * @private\n */\n function parsePow(state) {\n var node, name, fn, params;\n node = parseNullishCoalescing(state);\n if (state.token === '^' || state.token === '.^') {\n name = state.token;\n fn = name === '^' ? 'pow' : 'dotPow';\n getTokenSkipNewline(state);\n params = [node, parseUnary(state)]; // Go back to unary, we can have '2^-3'\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * nullish coalescing operator\n * @return {Node} node\n * @private\n */\n function parseNullishCoalescing(state) {\n var node = parseLeftHandOperators(state);\n while (state.token === '??') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('??', 'nullish', [node, parseLeftHandOperators(state)]);\n }\n return node;\n }\n\n /**\n * Left hand operators: factorial x!, ctranspose x'\n * @return {Node} node\n * @private\n */\n function parseLeftHandOperators(state) {\n var node, name, fn, params;\n node = parseCustomNodes(state);\n var operators = {\n '!': 'factorial',\n '\\'': 'ctranspose'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getToken(state);\n params = [node];\n node = new OperatorNode(name, fn, params);\n node = parseAccessors(state, node);\n }\n return node;\n }\n\n /**\n * Parse a custom node handler. A node handler can be used to process\n * nodes in a custom way, for example for handling a plot.\n *\n * A handler must be passed as second argument of the parse function.\n * - must extend math.Node\n * - must contain a function _compile(defs: Object) : string\n * - must contain a function find(filter: Object) : Node[]\n * - must contain a function toString() : string\n * - the constructor is called with a single argument containing all parameters\n *\n * For example:\n *\n * nodes = {\n * 'plot': PlotHandler\n * }\n *\n * The constructor of the handler is called as:\n *\n * node = new PlotHandler(params)\n *\n * The handler will be invoked when evaluating an expression like:\n *\n * node = math.parse('plot(sin(x), x)', nodes)\n *\n * @return {Node} node\n * @private\n */\n function parseCustomNodes(state) {\n var params = [];\n if (state.tokenType === TOKENTYPE.SYMBOL && hasOwnProperty(state.extraNodes, state.token)) {\n var CustomNode = state.extraNodes[state.token];\n getToken(state);\n\n // parse parameters\n if (state.token === '(') {\n params = [];\n openParams(state);\n getToken(state);\n if (state.token !== ')') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n }\n\n // create a new custom node\n // noinspection JSValidateTypes\n return new CustomNode(params);\n }\n return parseSymbol(state);\n }\n\n /**\n * parse symbols: functions, variables, constants, units\n * @return {Node} node\n * @private\n */\n function parseSymbol(state) {\n var node, name;\n if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {\n name = state.token;\n getToken(state);\n if (hasOwnProperty(CONSTANTS, name)) {\n // true, false, null, ...\n node = new ConstantNode(CONSTANTS[name]);\n } else if (NUMERIC_CONSTANTS.includes(name)) {\n // NaN, Infinity\n node = new ConstantNode(numeric(name, 'number'));\n } else {\n node = new SymbolNode(name);\n }\n\n // parse function parameters and matrix index\n node = parseAccessors(state, node);\n return node;\n }\n return parseString(state);\n }\n\n /**\n * parse accessors:\n * - function invocation in round brackets (...), for example sqrt(2) or sqrt?.(2) with optional chaining\n * - index enclosed in square brackets [...], for example A[2,3] or A?.[2,3] with optional chaining\n * - dot notation for properties, like foo.bar or foo?.bar with optional chaining\n * @param {Object} state\n * @param {Node} node Node on which to apply the parameters. If there\n * are no parameters in the expression, the node\n * itself is returned\n * @param {string[]} [types] Filter the types of notations\n * can be ['(', '[', '.']\n * @return {Node} node\n * @private\n */\n function parseAccessors(state, node, types) {\n var params;\n\n // Iterate and handle chained accessors, including repeated optional chaining\n while (true) {\n // eslint-disable-line no-unmodified-loop-condition\n // Track whether an optional chaining operator precedes the next accessor\n var optional = false;\n\n // Consume an optional chaining operator if present\n if (state.token === '?.') {\n optional = true;\n // consume the '?.' token\n getToken(state);\n }\n var hasNextAccessor = (state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.includes(state.token));\n if (!(optional || hasNextAccessor)) {\n break;\n }\n params = [];\n if (state.token === '(') {\n if (optional || isSymbolNode(node) || isAccessorNode(node)) {\n // function invocation: fn(2, 3) or obj.fn(2, 3) or (anything)?.(2, 3)\n openParams(state);\n getToken(state);\n if (state.token !== ')') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n node = new FunctionNode(node, params, optional);\n } else {\n // implicit multiplication like (2+3)(4+5) or sqrt(2)(1+2)\n // don't parse it here but let it be handled by parseImplicitMultiplication\n // with correct precedence\n return node;\n }\n } else if (state.token === '[') {\n // index notation like variable[2, 3]\n openParams(state);\n getToken(state);\n if (state.token !== ']') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ']') {\n throw createSyntaxError(state, 'Parenthesis ] expected');\n }\n closeParams(state);\n getToken(state);\n node = new AccessorNode(node, new IndexNode(params), optional);\n } else {\n // dot notation like variable.prop\n // consume the `.` (if it was ?., already consumed):\n if (!optional) getToken(state);\n var isPropertyName = state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS;\n if (!isPropertyName) {\n var message = 'Property name expected after ';\n message += optional ? 'optional chain' : 'dot';\n throw createSyntaxError(state, message);\n }\n params.push(new ConstantNode(state.token));\n getToken(state);\n var dotNotation = true;\n node = new AccessorNode(node, new IndexNode(params, dotNotation), optional);\n }\n }\n return node;\n }\n\n /**\n * Parse a single or double quoted string.\n * @return {Node} node\n * @private\n */\n function parseString(state) {\n var node, str;\n if (state.token === '\"' || state.token === \"'\") {\n str = parseStringToken(state, state.token);\n\n // create constant\n node = new ConstantNode(str);\n\n // parse index parameters\n node = parseAccessors(state, node);\n return node;\n }\n return parseMatrix(state);\n }\n\n /**\n * Parse a string surrounded by single or double quotes\n * @param {Object} state\n * @param {\"'\" | \"\\\"\"} quote\n * @return {string}\n */\n function parseStringToken(state, quote) {\n var str = '';\n while (currentCharacter(state) !== '' && currentCharacter(state) !== quote) {\n if (currentCharacter(state) === '\\\\') {\n next(state);\n var char = currentCharacter(state);\n var escapeChar = ESCAPE_CHARACTERS[char];\n if (escapeChar !== undefined) {\n // an escaped control character like \\\" or \\n\n str += escapeChar;\n state.index += 1;\n } else if (char === 'u') {\n // escaped unicode character\n var unicode = state.expression.slice(state.index + 1, state.index + 5);\n if (/^[0-9A-Fa-f]{4}$/.test(unicode)) {\n // test whether the string holds four hexadecimal values\n str += String.fromCharCode(parseInt(unicode, 16));\n state.index += 5;\n } else {\n throw createSyntaxError(state, \"Invalid unicode character \\\\u\".concat(unicode));\n }\n } else {\n throw createSyntaxError(state, \"Bad escape character \\\\\".concat(char));\n }\n } else {\n // any regular character\n str += currentCharacter(state);\n next(state);\n }\n }\n getToken(state);\n if (state.token !== quote) {\n throw createSyntaxError(state, \"End of string \".concat(quote, \" expected\"));\n }\n getToken(state);\n return str;\n }\n\n /**\n * parse the matrix\n * @return {Node} node\n * @private\n */\n function parseMatrix(state) {\n var array, params, rows, cols;\n if (state.token === '[') {\n // matrix [...]\n openParams(state);\n getToken(state);\n if (state.token !== ']') {\n // this is a non-empty matrix\n var row = parseRow(state);\n if (state.token === ';') {\n // 2 dimensional array\n rows = 1;\n params = [row];\n\n // the rows of the matrix are separated by dot-comma's\n while (state.token === ';') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n if (state.token !== ']') {\n params[rows] = parseRow(state);\n rows++;\n }\n }\n if (state.token !== ']') {\n throw createSyntaxError(state, 'End of matrix ] expected');\n }\n closeParams(state);\n getToken(state);\n\n // check if the number of columns matches in all rows\n cols = params[0].items.length;\n for (var r = 1; r < rows; r++) {\n if (params[r].items.length !== cols) {\n throw createError(state, 'Column dimensions mismatch ' + '(' + params[r].items.length + ' !== ' + cols + ')');\n }\n }\n array = new ArrayNode(params);\n } else {\n // 1 dimensional vector\n if (state.token !== ']') {\n throw createSyntaxError(state, 'End of matrix ] expected');\n }\n closeParams(state);\n getToken(state);\n array = row;\n }\n } else {\n // this is an empty matrix \"[ ]\"\n closeParams(state);\n getToken(state);\n array = new ArrayNode([]);\n }\n return parseAccessors(state, array);\n }\n return parseObject(state);\n }\n\n /**\n * Parse a single comma-separated row from a matrix, like 'a, b, c'\n * @return {ArrayNode} node\n */\n function parseRow(state) {\n var params = [parseAssignment(state)];\n var len = 1;\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n\n // parse expression\n if (state.token !== ']' && state.token !== ';') {\n params[len] = parseAssignment(state);\n len++;\n }\n }\n return new ArrayNode(params);\n }\n\n /**\n * parse an object, enclosed in angle brackets{...}, for example {value: 2}\n * @return {Node} node\n * @private\n */\n function parseObject(state) {\n if (state.token === '{') {\n openParams(state);\n var key;\n var properties = {};\n do {\n getToken(state);\n if (state.token !== '}') {\n // parse key\n if (state.token === '\"' || state.token === \"'\") {\n key = parseStringToken(state, state.token);\n } else if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {\n key = state.token;\n getToken(state);\n } else {\n throw createSyntaxError(state, 'Symbol or string expected as object key');\n }\n\n // parse key/value separator\n if (state.token !== ':') {\n throw createSyntaxError(state, 'Colon : expected after object key');\n }\n getToken(state);\n\n // parse key\n properties[key] = parseAssignment(state);\n }\n } while (state.token === ','); // eslint-disable-line no-unmodified-loop-condition\n\n if (state.token !== '}') {\n throw createSyntaxError(state, 'Comma , or bracket } expected after object value');\n }\n closeParams(state);\n getToken(state);\n var node = new ObjectNode(properties);\n\n // parse index parameters\n node = parseAccessors(state, node);\n return node;\n }\n return parseNumber(state);\n }\n\n /**\n * parse a number\n * @return {Node} node\n * @private\n */\n function parseNumber(state) {\n var numberStr;\n if (state.tokenType === TOKENTYPE.NUMBER) {\n // this is a number\n numberStr = state.token;\n getToken(state);\n var numericType = safeNumberType(numberStr, config);\n var value = numeric(numberStr, numericType);\n return new ConstantNode(value);\n }\n return parseParentheses(state);\n }\n\n /**\n * parentheses\n * @return {Node} node\n * @private\n */\n function parseParentheses(state) {\n var node;\n\n // check if it is a parenthesized expression\n if (state.token === '(') {\n // parentheses (...)\n openParams(state);\n getToken(state);\n node = parseAssignment(state); // start again\n\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n node = new ParenthesisNode(node);\n node = parseAccessors(state, node);\n return node;\n }\n return parseEnd(state);\n }\n\n /**\n * Evaluated when the expression is not yet ended but expected to end\n * @return {Node} res\n * @private\n */\n function parseEnd(state) {\n if (state.token === '') {\n // syntax error or unexpected end of expression\n throw createSyntaxError(state, 'Unexpected end of expression');\n } else {\n throw createSyntaxError(state, 'Value expected');\n }\n }\n\n /**\n * Shortcut for getting the current row value (one based)\n * Returns the line of the currently handled expression\n * @private\n */\n /* TODO: implement keeping track on the row number\n function row () {\n return null\n }\n */\n\n /**\n * Shortcut for getting the current col value (one based)\n * Returns the column (position) where the last state.token starts\n * @private\n */\n function col(state) {\n return state.index - state.token.length + 1;\n }\n\n /**\n * Create an error\n * @param {Object} state\n * @param {string} message\n * @return {SyntaxError} instantiated error\n * @private\n */\n function createSyntaxError(state, message) {\n var c = col(state);\n var error = new SyntaxError(message + ' (char ' + c + ')');\n error.char = c;\n return error;\n }\n\n /**\n * Create an error\n * @param {Object} state\n * @param {string} message\n * @return {Error} instantiated error\n * @private\n */\n function createError(state, message) {\n var c = col(state);\n var error = new SyntaxError(message + ' (char ' + c + ')');\n error.char = c;\n return error;\n }\n\n // Now that we can parse, automatically convert strings to Nodes by parsing\n typed.addConversion({\n from: 'string',\n to: 'Node',\n convert: parse\n });\n return parse;\n});","import { deepMap } from '../../utils/collection.js';\nimport { factory } from '../../utils/factory.js';\nimport { createEmptyMap } from '../../utils/map.js';\nvar name = 'evaluate';\nvar dependencies = ['typed', 'parse'];\nexport var createEvaluate = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n parse\n } = _ref;\n /**\n * Evaluate an expression.\n *\n * The expression parser does not use JavaScript. Its syntax is close\n * to JavaScript but more suited for mathematical expressions.\n * See [https://mathjs.org/docs/expressions/syntax.html](https://mathjs.org/docs/expressions/syntax.html) to learn\n * the syntax and get an overview of the exact differences from JavaScript.\n *\n * Note the evaluating arbitrary expressions may involve security risks,\n * see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.\n *\n * Syntax:\n *\n * math.evaluate(expr)\n * math.evaluate(expr, scope)\n * math.evaluate([expr1, expr2, expr3, ...])\n * math.evaluate([expr1, expr2, expr3, ...], scope)\n *\n * Example:\n *\n * math.evaluate('(2+3)/4') // 1.25\n * math.evaluate('sqrt(3^2 + 4^2)') // 5\n * math.evaluate('sqrt(-4)') // 2i\n * math.evaluate(['a=3', 'b=4', 'a*b']) // [3, 4, 12]\n *\n * let scope = {a:3, b:4}\n * math.evaluate('a * b', scope) // 12\n *\n * See also:\n *\n * parse, compile\n *\n * @param {string | string[] | Matrix} expr The expression to be evaluated\n * @param {Object} [scope] Scope to read/write variables\n * @return {*} The result of the expression\n * @throws {Error}\n */\n return typed(name, {\n string: function string(expr) {\n var scope = createEmptyMap();\n return parse(expr).compile().evaluate(scope);\n },\n 'string, Map | Object': function string_Map__Object(expr, scope) {\n return parse(expr).compile().evaluate(scope);\n },\n 'Array | Matrix': function Array__Matrix(expr) {\n var scope = createEmptyMap();\n return deepMap(expr, function (entry) {\n return parse(entry).compile().evaluate(scope);\n });\n },\n 'Array | Matrix, Map | Object': function Array__Matrix_Map__Object(expr, scope) {\n return deepMap(expr, function (entry) {\n return parse(entry).compile().evaluate(scope);\n });\n }\n });\n});","import { arraySize } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'size';\nvar dependencies = ['typed'];\nexport var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Calculate the size of a matrix or scalar. Always returns an Array containing numbers.\n *\n * Note that in mathjs v14 and older, function size could return a Matrix depending on\n * the input type and configuration.\n *\n * Syntax:\n *\n * math.size(x)\n *\n * Examples:\n *\n * math.size(2.3) // returns []\n * math.size('hello world') // returns [11]\n *\n * const A = [[1, 2, 3], [4, 5, 6]]\n * math.size(A) // returns [2, 3]\n * math.size(math.range(1,6).toArray()) // returns [5]\n *\n * See also:\n *\n * count, resize, squeeze, subset\n *\n * @param {boolean | number | Complex | Unit | string | Array | Matrix} x A matrix\n * @return {Array} A vector with size of `x`.\n */\n return typed(name, {\n Matrix: x => x.size(),\n Array: arraySize,\n string: x => [x.length],\n // scalar\n 'number | Complex | BigNumber | Unit | boolean | null': _x => []\n });\n});","import { deepMap } from '../../utils/collection.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'factorial';\nvar dependencies = ['typed', 'gamma'];\nexport var createFactorial = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n gamma\n } = _ref;\n /**\n * Compute the factorial of a value\n *\n * Factorial only supports an integer value as argument.\n * For matrices, the function is evaluated element wise.\n *\n * Syntax:\n *\n * math.factorial(n)\n *\n * Examples:\n *\n * math.factorial(5) // returns 120\n * math.factorial(3) // returns 6\n *\n * See also:\n *\n * combinations, combinationsWithRep, gamma, permutations\n *\n * @param {number | BigNumber | Array | Matrix} n An integer number\n * @return {number | BigNumber | Array | Matrix} The factorial of `n`\n */\n return typed(name, {\n number: function number(n) {\n if (n < 0) {\n throw new Error('Value must be non-negative');\n }\n return gamma(n + 1);\n },\n BigNumber: function BigNumber(n) {\n if (n.isNegative()) {\n throw new Error('Value must be non-negative');\n }\n return gamma(n.plus(1));\n },\n 'Array | Matrix': typed.referToSelf(self => n => deepMap(n, self))\n });\n});","import { factory } from '../../utils/factory.js';\nvar name = 'isBounded';\nvar dependencies = ['typed'];\nexport var createIsBounded = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Test whether a value is bounded. For scalars, this test is equivalent\n * to the isFinite finiteness test. On the other hand, a Matrix or Array\n * is defined to be bounded if every entry is finite.\n *\n * Syntax:\n *\n * math.isBounded(x)\n *\n * Examples:\n *\n * math.isBounded(0) // returns true\n * math.isBounded(NaN) // returns false\n * math.isBounded(math.bignumber(Infinity)) // returns false\n * math.isBounded(math.fraction(1,3)) // returns true\n * math.isBounded(math.complex('2 - 4i')) // returns true\n * math.isBounded(-10000000000000000n) // returns true\n * math.isBounded(undefined) // returns false\n * math.isBounded(null) // returns false\n * math.isBounded([0.001, -3n, 0]) // returns true\n * math.isBounded([2, -Infinity, -3]) // returns false\n *\n * See also:\n *\n * isFinite, isNumeric, isPositive, isNegative, isNaN\n *\n * @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested\n * @return {boolean} Returns true when `x` is bounded.\n */\n return typed(name, {\n number: n => Number.isFinite(n),\n 'BigNumber | Complex': x => x.isFinite(),\n 'bigint | Fraction': () => true,\n 'null | undefined': () => false,\n Unit: typed.referToSelf(self => x => self(x.value)),\n 'Array | Matrix': typed.referToSelf(self => A => {\n if (!Array.isArray(A)) A = A.valueOf();\n return A.every(entry => self(entry));\n })\n });\n});","import { typeOf } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { noBignumber, noFraction } from '../../utils/noop.js';\nvar name = 'numeric';\nvar dependencies = ['number', '?bignumber', '?fraction'];\nexport var createNumeric = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n number: _number,\n bignumber,\n fraction\n } = _ref;\n var validInputTypes = {\n string: true,\n number: true,\n BigNumber: true,\n Fraction: true\n };\n\n // Load the conversion functions for each output type\n var validOutputTypes = {\n number: x => _number(x),\n BigNumber: bignumber ? x => bignumber(x) : noBignumber,\n bigint: x => BigInt(x),\n Fraction: fraction ? x => fraction(x) : noFraction\n };\n\n /**\n * Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.\n *\n * Syntax:\n *\n * math.numeric(x)\n * math.numeric(value, outputType)\n *\n * Examples:\n *\n * math.numeric('4') // returns 4\n * math.numeric('4', 'number') // returns 4\n * math.numeric('4', 'bigint') // returns 4n\n * math.numeric('4', 'BigNumber') // returns BigNumber 4\n * math.numeric('4', 'Fraction') // returns Fraction 4\n * math.numeric(4, 'Fraction') // returns Fraction 4\n * math.numeric(math.fraction(2, 5), 'number') // returns 0.4\n *\n * See also:\n *\n * number, fraction, bignumber, bigint, string, format\n *\n * History:\n *\n * v6 Created\n * v13 Added `bigint` support\n * v14.2.1 Prefer mathjs `bigint()` to built-in `BigInt()`\n *\n * @param {string | number | BigNumber | bigint | Fraction } value\n * A numeric value or a string containing a numeric value\n * @param {string} outputType\n * Desired numeric output type.\n * Available values: 'number', 'BigNumber', or 'Fraction'\n * @return {number | BigNumber | bigint | Fraction}\n * Returns an instance of the numeric in the requested type\n */\n return function numeric(value) {\n var outputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'number';\n var check = arguments.length > 2 ? arguments[2] : undefined;\n if (check !== undefined) {\n throw new SyntaxError('numeric() takes one or two arguments');\n }\n var inputType = typeOf(value);\n if (!(inputType in validInputTypes)) {\n throw new TypeError('Cannot convert ' + value + ' of type \"' + inputType + '\"; valid input types are ' + Object.keys(validInputTypes).join(', '));\n }\n if (!(outputType in validOutputTypes)) {\n throw new TypeError('Cannot convert ' + value + ' to type \"' + outputType + '\"; valid output types are ' + Object.keys(validOutputTypes).join(', '));\n }\n if (outputType === inputType) {\n return value;\n } else {\n return validOutputTypes[outputType](value);\n }\n };\n});","import { absNumber, acoshNumber, acosNumber, acothNumber, acotNumber, acschNumber, acscNumber, addNumber, andNumber, asechNumber, asecNumber, asinhNumber, asinNumber, atan2Number, atanhNumber, atanNumber, bitAndNumber, bitNotNumber, bitOrNumber, bitXorNumber, cbrtNumber, combinationsNumber, coshNumber, cosNumber, cothNumber, cotNumber, cschNumber, cscNumber, cubeNumber, divideNumber, expm1Number, expNumber, gammaNumber, gcdNumber, isIntegerNumber, isNaNNumber, isNegativeNumber, isPositiveNumber, isZeroNumber, lcmNumber, leftShiftNumber, lgammaNumber, log10Number, log1pNumber, log2Number, logNumber, modNumber, multiplyNumber, normNumber, notNumber, nthRootNumber, orNumber, powNumber, rightArithShiftNumber, rightLogShiftNumber, roundNumber, sechNumber, secNumber, signNumber, sinhNumber, sinNumber, sqrtNumber, squareNumber, subtractNumber, tanhNumber, tanNumber, unaryMinusNumber, unaryPlusNumber, xgcdNumber, xorNumber } from './plain/number/index.js';\nimport { factory } from './utils/factory.js';\nimport { noIndex, noMatrix, noSubset } from './utils/noop.js';\n\n// ----------------------------------------------------------------------------\n// classes and functions\n\n// core\nexport { createTyped } from './core/function/typed.js';\n\n// classes\nexport { createResultSet } from './type/resultset/ResultSet.js';\nexport { createRangeClass } from './type/matrix/Range.js';\nexport { createHelpClass } from './expression/Help.js';\nexport { createChainClass } from './type/chain/Chain.js';\nexport { createHelp } from './expression/function/help.js';\nexport { createChain } from './type/chain/function/chain.js';\n\n// algebra\nexport { createResolve } from './function/algebra/resolve.js';\nexport { createSimplify } from './function/algebra/simplify.js';\nexport { createSimplifyConstant } from './function/algebra/simplifyConstant.js';\nexport { createSimplifyCore } from './function/algebra/simplifyCore.js';\nexport { createDerivative } from './function/algebra/derivative.js';\nexport { createRationalize } from './function/algebra/rationalize.js';\n\n// arithmetic\nexport var createUnaryMinus = /* #__PURE__ */createNumberFactory('unaryMinus', unaryMinusNumber);\nexport var createUnaryPlus = /* #__PURE__ */createNumberFactory('unaryPlus', unaryPlusNumber);\nexport var createAbs = /* #__PURE__ */createNumberFactory('abs', absNumber);\nexport var createAddScalar = /* #__PURE__ */createNumberFactory('addScalar', addNumber);\nexport var createSubtractScalar = /* #__PURE__ */createNumberFactory('subtractScalar', subtractNumber);\nexport var createCbrt = /* #__PURE__ */createNumberFactory('cbrt', cbrtNumber);\nexport { createCeilNumber as createCeil } from './function/arithmetic/ceil.js';\nexport var createCube = /* #__PURE__ */createNumberFactory('cube', cubeNumber);\nexport var createExp = /* #__PURE__ */createNumberFactory('exp', expNumber);\nexport var createExpm1 = /* #__PURE__ */createNumberFactory('expm1', expm1Number);\nexport { createFixNumber as createFix } from './function/arithmetic/fix.js';\nexport { createFloorNumber as createFloor } from './function/arithmetic/floor.js';\nexport var createGcd = /* #__PURE__ */createNumberFactory('gcd', gcdNumber);\nexport var createLcm = /* #__PURE__ */createNumberFactory('lcm', lcmNumber);\nexport var createLog10 = /* #__PURE__ */createNumberFactory('log10', log10Number);\nexport var createLog2 = /* #__PURE__ */createNumberFactory('log2', log2Number);\nexport var createMod = /* #__PURE__ */createNumberFactory('mod', modNumber);\nexport var createMultiplyScalar = /* #__PURE__ */createNumberFactory('multiplyScalar', multiplyNumber);\nexport var createMultiply = /* #__PURE__ */createNumberFactory('multiply', multiplyNumber);\nexport var createNthRoot = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('nthRoot', nthRootNumber);\nexport var createSign = /* #__PURE__ */createNumberFactory('sign', signNumber);\nexport var createSqrt = /* #__PURE__ */createNumberFactory('sqrt', sqrtNumber);\nexport var createSquare = /* #__PURE__ */createNumberFactory('square', squareNumber);\nexport var createSubtract = /* #__PURE__ */createNumberFactory('subtract', subtractNumber);\nexport var createXgcd = /* #__PURE__ */createNumberFactory('xgcd', xgcdNumber);\nexport var createDivideScalar = /* #__PURE__ */createNumberFactory('divideScalar', divideNumber);\nexport var createPow = /* #__PURE__ */createNumberFactory('pow', powNumber);\nexport var createRound = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('round', roundNumber);\nexport var createLog = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('log', logNumber);\nexport var createLog1p = /* #__PURE__ */createNumberFactory('log1p', log1pNumber);\nexport var createAdd = /* #__PURE__ */createNumberFactory('add', addNumber);\nexport { createHypot } from './function/arithmetic/hypot.js';\nexport var createNorm = /* #__PURE__ */createNumberFactory('norm', normNumber);\nexport var createDivide = /* #__PURE__ */createNumberFactory('divide', divideNumber);\n\n// bitwise\nexport var createBitAnd = /* #__PURE__ */createNumberFactory('bitAnd', bitAndNumber);\nexport var createBitNot = /* #__PURE__ */createNumberFactory('bitNot', bitNotNumber);\nexport var createBitOr = /* #__PURE__ */createNumberFactory('bitOr', bitOrNumber);\nexport var createBitXor = /* #__PURE__ */createNumberFactory('bitXor', bitXorNumber);\nexport var createLeftShift = /* #__PURE__ */createNumberFactory('leftShift', leftShiftNumber);\nexport var createRightArithShift = /* #__PURE__ */createNumberFactory('rightArithShift', rightArithShiftNumber);\nexport var createRightLogShift = /* #__PURE__ */createNumberFactory('rightLogShift', rightLogShiftNumber);\n\n// combinatorics\nexport { createStirlingS2 } from './function/combinatorics/stirlingS2.js';\nexport { createBellNumbers } from './function/combinatorics/bellNumbers.js';\nexport { createCatalan } from './function/combinatorics/catalan.js';\nexport { createComposition } from './function/combinatorics/composition.js';\n\n// constants\nexport { createE, createUppercaseE, createFalse,\n// createI,\ncreateInfinity, createLN10, createLN2, createLOG10E, createLOG2E, createNaN, createNull, createPhi, createPi, createUppercasePi, createSQRT1_2,\n// eslint-disable-line camelcase\ncreateSQRT2, createTau, createTrue, createVersion } from './constants.js';\n\n// create\nexport { createNumber } from './type/number.js';\nexport { createBigint } from './type/bigint.js';\nexport { createString } from './type/string.js';\nexport { createBoolean } from './type/boolean.js';\nexport { createParser } from './expression/function/parser.js';\n\n// expression\nexport { createNode } from './expression/node/Node.js';\nexport { createAccessorNode } from './expression/node/AccessorNode.js';\nexport { createArrayNode } from './expression/node/ArrayNode.js';\nexport { createAssignmentNode } from './expression/node/AssignmentNode.js';\nexport { createBlockNode } from './expression/node/BlockNode.js';\nexport { createConditionalNode } from './expression/node/ConditionalNode.js';\nexport { createConstantNode } from './expression/node/ConstantNode.js';\nexport { createFunctionAssignmentNode } from './expression/node/FunctionAssignmentNode.js';\nexport { createIndexNode } from './expression/node/IndexNode.js';\nexport { createObjectNode } from './expression/node/ObjectNode.js';\nexport { createOperatorNode } from './expression/node/OperatorNode.js';\nexport { createParenthesisNode } from './expression/node/ParenthesisNode.js';\nexport { createRangeNode } from './expression/node/RangeNode.js';\nexport { createRelationalNode } from './expression/node/RelationalNode.js';\nexport { createSymbolNode } from './expression/node/SymbolNode.js';\nexport { createFunctionNode } from './expression/node/FunctionNode.js';\nexport { createParse } from './expression/parse.js';\nexport { createCompile } from './expression/function/compile.js';\nexport { createEvaluate } from './expression/function/evaluate.js';\nexport { createParserClass } from './expression/Parser.js';\n\n// logical\nexport var createAnd = /* #__PURE__ */createNumberFactory('and', andNumber);\nexport var createNot = /* #__PURE__ */createNumberFactory('not', notNumber);\nexport var createOr = /* #__PURE__ */createNumberFactory('or', orNumber);\nexport var createXor = /* #__PURE__ */createNumberFactory('xor', xorNumber);\n\n// matrix\nexport { createMapSlices } from './function/matrix/mapSlices.js';\nexport { createFilter } from './function/matrix/filter.js';\nexport { createForEach } from './function/matrix/forEach.js';\nexport { createMap } from './function/matrix/map.js';\nexport { createRange } from './function/matrix/range.js';\nexport { createSize } from './function/matrix/size.js';\n// FIXME: create a lightweight \"number\" implementation of subset only supporting plain objects/arrays\nexport var createIndex = /* #__PURE__ */factory('index', [], () => noIndex);\nexport var createMatrix = /* #__PURE__ */factory('matrix', [], () => noMatrix); // FIXME: needed now because subset transform needs it. Remove the need for it in subset\nexport var createSubset = /* #__PURE__ */factory('subset', [], () => noSubset);\n// TODO: provide number+array implementations for map, filter, forEach, zeros, ...?\n// TODO: create range implementation for range?\nexport { createPartitionSelect } from './function/matrix/partitionSelect.js';\n\n// probability\nexport { createBernoulli } from './function/probability/bernoulli.js';\nexport var createCombinations = createNumberFactory('combinations', combinationsNumber);\nexport var createGamma = createNumberFactory('gamma', gammaNumber);\nexport var createLgamma = createNumberFactory('lgamma', lgammaNumber);\nexport { createCombinationsWithRep } from './function/probability/combinationsWithRep.js';\nexport { createFactorial } from './function/probability/factorial.js';\nexport { createMultinomial } from './function/probability/multinomial.js';\nexport { createPermutations } from './function/probability/permutations.js';\nexport { createPickRandom } from './function/probability/pickRandom.js';\nexport { createRandomNumber as createRandom } from './function/probability/random.js';\nexport { createRandomInt } from './function/probability/randomInt.js';\n\n// relational\nexport { createEqualScalarNumber as createEqualScalar } from './function/relational/equalScalar.js';\nexport { createCompareNumber as createCompare } from './function/relational/compare.js';\nexport { createCompareNatural } from './function/relational/compareNatural.js';\nexport { createCompareTextNumber as createCompareText } from './function/relational/compareText.js';\nexport { createEqualNumber as createEqual } from './function/relational/equal.js';\nexport { createEqualText } from './function/relational/equalText.js';\nexport { createSmallerNumber as createSmaller } from './function/relational/smaller.js';\nexport { createSmallerEqNumber as createSmallerEq } from './function/relational/smallerEq.js';\nexport { createLargerNumber as createLarger } from './function/relational/larger.js';\nexport { createLargerEqNumber as createLargerEq } from './function/relational/largerEq.js';\nexport { createDeepEqual } from './function/relational/deepEqual.js';\nexport { createUnequalNumber as createUnequal } from './function/relational/unequal.js';\n\n// special\nexport { createErf } from './function/special/erf.js';\nexport { createZeta } from './function/special/zeta.js';\n// statistics\nexport { createMode } from './function/statistics/mode.js';\nexport { createProd } from './function/statistics/prod.js';\nexport { createMax } from './function/statistics/max.js';\nexport { createMin } from './function/statistics/min.js';\nexport { createSum } from './function/statistics/sum.js';\nexport { createCumSum } from './function/statistics/cumsum.js';\nexport { createMean } from './function/statistics/mean.js';\nexport { createMedian } from './function/statistics/median.js';\nexport { createMad } from './function/statistics/mad.js';\nexport { createVariance } from './function/statistics/variance.js';\nexport { createQuantileSeq } from './function/statistics/quantileSeq.js';\nexport { createStd } from './function/statistics/std.js';\nexport { createCorr } from './function/statistics/corr.js';\n\n// string\nexport { createFormat } from './function/string/format.js';\nexport { createPrint } from './function/string/print.js';\n\n// trigonometry\nexport var createAcos = /* #__PURE__ */createNumberFactory('acos', acosNumber);\nexport var createAcosh = /* #__PURE__ */createNumberFactory('acosh', acoshNumber);\nexport var createAcot = /* #__PURE__ */createNumberFactory('acot', acotNumber);\nexport var createAcoth = /* #__PURE__ */createNumberFactory('acoth', acothNumber);\nexport var createAcsc = /* #__PURE__ */createNumberFactory('acsc', acscNumber);\nexport var createAcsch = /* #__PURE__ */createNumberFactory('acsch', acschNumber);\nexport var createAsec = /* #__PURE__ */createNumberFactory('asec', asecNumber);\nexport var createAsech = /* #__PURE__ */createNumberFactory('asech', asechNumber);\nexport var createAsin = /* #__PURE__ */createNumberFactory('asin', asinNumber);\nexport var createAsinh = /* #__PURE__ */createNumberFactory('asinh', asinhNumber);\nexport var createAtan = /* #__PURE__ */createNumberFactory('atan', atanNumber);\nexport var createAtan2 = /* #__PURE__ */createNumberFactory('atan2', atan2Number);\nexport var createAtanh = /* #__PURE__ */createNumberFactory('atanh', atanhNumber);\nexport var createCos = /* #__PURE__ */createNumberFactory('cos', cosNumber);\nexport var createCosh = /* #__PURE__ */createNumberFactory('cosh', coshNumber);\nexport var createCot = /* #__PURE__ */createNumberFactory('cot', cotNumber);\nexport var createCoth = /* #__PURE__ */createNumberFactory('coth', cothNumber);\nexport var createCsc = /* #__PURE__ */createNumberFactory('csc', cscNumber);\nexport var createCsch = /* #__PURE__ */createNumberFactory('csch', cschNumber);\nexport var createSec = /* #__PURE__ */createNumberFactory('sec', secNumber);\nexport var createSech = /* #__PURE__ */createNumberFactory('sech', sechNumber);\nexport var createSin = /* #__PURE__ */createNumberFactory('sin', sinNumber);\nexport var createSinh = /* #__PURE__ */createNumberFactory('sinh', sinhNumber);\nexport var createTan = /* #__PURE__ */createNumberFactory('tan', tanNumber);\nexport var createTanh = /* #__PURE__ */createNumberFactory('tanh', tanhNumber);\n\n// transforms\nexport { createMapSlicesTransform } from './expression/transform/mapSlices.transform.js';\nexport { createFilterTransform } from './expression/transform/filter.transform.js';\nexport { createForEachTransform } from './expression/transform/forEach.transform.js';\nexport { createMapTransform } from './expression/transform/map.transform.js';\nexport { createMaxTransform } from './expression/transform/max.transform.js';\nexport { createMeanTransform } from './expression/transform/mean.transform.js';\nexport { createMinTransform } from './expression/transform/min.transform.js';\nexport { createRangeTransform } from './expression/transform/range.transform.js';\nexport var createSubsetTransform = /* #__PURE__ */factory('subset', [], () => noSubset, {\n isTransformFunction: true\n});\nexport { createStdTransform } from './expression/transform/std.transform.js';\nexport { createSumTransform } from './expression/transform/sum.transform.js';\nexport { createCumSumTransform } from './expression/transform/cumsum.transform.js';\nexport { createVarianceTransform } from './expression/transform/variance.transform.js';\n\n// utils\nexport { createClone } from './function/utils/clone.js';\nexport var createIsInteger = /* #__PURE__ */createNumberFactory('isInteger', isIntegerNumber);\nexport var createIsNegative = /* #__PURE__ */createNumberFactory('isNegative', isNegativeNumber);\nexport { createIsNumeric } from './function/utils/isNumeric.js';\nexport { createHasNumericValue } from './function/utils/hasNumericValue.js';\nexport var createIsPositive = /* #__PURE__ */createNumberFactory('isPositive', isPositiveNumber);\nexport var createIsZero = /* #__PURE__ */createNumberFactory('isZero', isZeroNumber);\nexport var createIsNaN = /* #__PURE__ */createNumberFactory('isNaN', isNaNNumber);\nexport { createIsBounded } from './function/utils/isBounded.js';\nexport { createIsFinite } from './function/utils/isFinite.js';\nexport { createTypeOf } from './function/utils/typeOf.js';\nexport { createIsPrime } from './function/utils/isPrime.js';\nexport { createNumeric } from './function/utils/numeric.js';\n\n// json\nexport { createReviver } from './json/reviver.js';\nexport { createReplacer } from './json/replacer.js';\n\n// helper functions to create a factory function for a function which only needs typed-function\nfunction createNumberFactory(name, fn) {\n return factory(name, ['typed'], _ref => {\n var {\n typed\n } = _ref;\n return typed(fn);\n });\n}\nfunction createNumberOptionalSecondArgFactory(name, fn) {\n return factory(name, ['typed'], _ref2 => {\n var {\n typed\n } = _ref2;\n return typed({\n number: fn,\n 'number,number': fn\n });\n });\n}","/**\n * Create a syntax error with the message:\n * 'Wrong number of arguments in function ( provided, - expected)'\n * @param {string} fn Function name\n * @param {number} count Actual argument count\n * @param {number} min Minimum required argument count\n * @param {number} [max] Maximum required argument count\n * @extends Error\n */\nexport function ArgumentsError(fn, count, min, max) {\n if (!(this instanceof ArgumentsError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.fn = fn;\n this.count = count;\n this.min = min;\n this.max = max;\n this.message = 'Wrong number of arguments in function ' + fn + ' (' + count + ' provided, ' + min + (max !== undefined && max !== null ? '-' + max : '') + ' expected)';\n this.stack = new Error().stack;\n}\nArgumentsError.prototype = new Error();\nArgumentsError.prototype.constructor = Error;\nArgumentsError.prototype.name = 'ArgumentsError';\nArgumentsError.prototype.isArgumentsError = true;","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createTyped } from '../../factoriesNumber.js';\nexport var typedDependencies = {\n createTyped\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createAbs } from '../../factoriesNumber.js';\nexport var absDependencies = {\n typedDependencies,\n createAbs\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createNode } from '../../factoriesNumber.js';\nexport var NodeDependencies = {\n createNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createSubset } from '../../factoriesNumber.js';\nexport var subsetDependencies = {\n createSubset\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { subsetDependencies } from './dependenciesSubset.generated.js';\nimport { createAccessorNode } from '../../factoriesNumber.js';\nexport var AccessorNodeDependencies = {\n NodeDependencies,\n subsetDependencies,\n createAccessorNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createAdd } from '../../factoriesNumber.js';\nexport var addDependencies = {\n typedDependencies,\n createAdd\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createArrayNode } from '../../factoriesNumber.js';\nexport var ArrayNodeDependencies = {\n NodeDependencies,\n createArrayNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createMatrix } from '../../factoriesNumber.js';\nexport var matrixDependencies = {\n createMatrix\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { matrixDependencies } from './dependenciesMatrix.generated.js';\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { subsetDependencies } from './dependenciesSubset.generated.js';\nimport { createAssignmentNode } from '../../factoriesNumber.js';\nexport var AssignmentNodeDependencies = {\n matrixDependencies,\n NodeDependencies,\n subsetDependencies,\n createAssignmentNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createGamma } from '../../factoriesNumber.js';\nexport var gammaDependencies = {\n typedDependencies,\n createGamma\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { gammaDependencies } from './dependenciesGamma.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createFactorial } from '../../factoriesNumber.js';\nexport var factorialDependencies = {\n gammaDependencies,\n typedDependencies,\n createFactorial\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createNumber } from '../../factoriesNumber.js';\nexport var numberDependencies = {\n typedDependencies,\n createNumber\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createPow } from '../../factoriesNumber.js';\nexport var powDependencies = {\n typedDependencies,\n createPow\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createResultSet } from '../../factoriesNumber.js';\nexport var ResultSetDependencies = {\n createResultSet\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { ResultSetDependencies } from './dependenciesResultSet.generated.js';\nimport { createBlockNode } from '../../factoriesNumber.js';\nexport var BlockNodeDependencies = {\n NodeDependencies,\n ResultSetDependencies,\n createBlockNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createRound } from '../../factoriesNumber.js';\nexport var roundDependencies = {\n typedDependencies,\n createRound\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createConditionalNode } from '../../factoriesNumber.js';\nexport var ConditionalNodeDependencies = {\n NodeDependencies,\n createConditionalNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createIsBounded } from '../../factoriesNumber.js';\nexport var isBoundedDependencies = {\n typedDependencies,\n createIsBounded\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { isBoundedDependencies } from './dependenciesIsBounded.generated.js';\nimport { createConstantNode } from '../../factoriesNumber.js';\nexport var ConstantNodeDependencies = {\n NodeDependencies,\n isBoundedDependencies,\n createConstantNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createFunctionAssignmentNode } from '../../factoriesNumber.js';\nexport var FunctionAssignmentNodeDependencies = {\n NodeDependencies,\n typedDependencies,\n createFunctionAssignmentNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createSymbolNode } from '../../factoriesNumber.js';\nexport var SymbolNodeDependencies = {\n NodeDependencies,\n createSymbolNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { SymbolNodeDependencies } from './dependenciesSymbolNode.generated.js';\nimport { createFunctionNode } from '../../factoriesNumber.js';\nexport var FunctionNodeDependencies = {\n NodeDependencies,\n SymbolNodeDependencies,\n createFunctionNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSize } from '../../factoriesNumber.js';\nexport var sizeDependencies = {\n typedDependencies,\n createSize\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { sizeDependencies } from './dependenciesSize.generated.js';\nimport { createIndexNode } from '../../factoriesNumber.js';\nexport var IndexNodeDependencies = {\n NodeDependencies,\n sizeDependencies,\n createIndexNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createObjectNode } from '../../factoriesNumber.js';\nexport var ObjectNodeDependencies = {\n NodeDependencies,\n createObjectNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createOperatorNode } from '../../factoriesNumber.js';\nexport var OperatorNodeDependencies = {\n NodeDependencies,\n createOperatorNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createParenthesisNode } from '../../factoriesNumber.js';\nexport var ParenthesisNodeDependencies = {\n NodeDependencies,\n createParenthesisNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createRangeNode } from '../../factoriesNumber.js';\nexport var RangeNodeDependencies = {\n NodeDependencies,\n createRangeNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createRelationalNode } from '../../factoriesNumber.js';\nexport var RelationalNodeDependencies = {\n NodeDependencies,\n createRelationalNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { numberDependencies } from './dependenciesNumber.generated.js';\nimport { createNumeric } from '../../factoriesNumber.js';\nexport var numericDependencies = {\n numberDependencies,\n createNumeric\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { AccessorNodeDependencies } from './dependenciesAccessorNode.generated.js';\nimport { ArrayNodeDependencies } from './dependenciesArrayNode.generated.js';\nimport { AssignmentNodeDependencies } from './dependenciesAssignmentNode.generated.js';\nimport { BlockNodeDependencies } from './dependenciesBlockNode.generated.js';\nimport { ConditionalNodeDependencies } from './dependenciesConditionalNode.generated.js';\nimport { ConstantNodeDependencies } from './dependenciesConstantNode.generated.js';\nimport { FunctionAssignmentNodeDependencies } from './dependenciesFunctionAssignmentNode.generated.js';\nimport { FunctionNodeDependencies } from './dependenciesFunctionNode.generated.js';\nimport { IndexNodeDependencies } from './dependenciesIndexNode.generated.js';\nimport { ObjectNodeDependencies } from './dependenciesObjectNode.generated.js';\nimport { OperatorNodeDependencies } from './dependenciesOperatorNode.generated.js';\nimport { ParenthesisNodeDependencies } from './dependenciesParenthesisNode.generated.js';\nimport { RangeNodeDependencies } from './dependenciesRangeNode.generated.js';\nimport { RelationalNodeDependencies } from './dependenciesRelationalNode.generated.js';\nimport { SymbolNodeDependencies } from './dependenciesSymbolNode.generated.js';\nimport { numericDependencies } from './dependenciesNumeric.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createParse } from '../../factoriesNumber.js';\nexport var parseDependencies = {\n AccessorNodeDependencies,\n ArrayNodeDependencies,\n AssignmentNodeDependencies,\n BlockNodeDependencies,\n ConditionalNodeDependencies,\n ConstantNodeDependencies,\n FunctionAssignmentNodeDependencies,\n FunctionNodeDependencies,\n IndexNodeDependencies,\n ObjectNodeDependencies,\n OperatorNodeDependencies,\n ParenthesisNodeDependencies,\n RangeNodeDependencies,\n RelationalNodeDependencies,\n SymbolNodeDependencies,\n numericDependencies,\n typedDependencies,\n createParse\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createDivide } from '../../factoriesNumber.js';\nexport var divideDependencies = {\n typedDependencies,\n createDivide\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createMultiply } from '../../factoriesNumber.js';\nexport var multiplyDependencies = {\n typedDependencies,\n createMultiply\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSqrt } from '../../factoriesNumber.js';\nexport var sqrtDependencies = {\n typedDependencies,\n createSqrt\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSubtract } from '../../factoriesNumber.js';\nexport var subtractDependencies = {\n typedDependencies,\n createSubtract\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createE } from '../../factoriesNumber.js';\nexport var eDependencies = {\n createE\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { parseDependencies } from './dependenciesParse.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createEvaluate } from '../../factoriesNumber.js';\nexport var evaluateDependencies = {\n parseDependencies,\n typedDependencies,\n createEvaluate\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createExp } from '../../factoriesNumber.js';\nexport var expDependencies = {\n typedDependencies,\n createExp\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createGcd } from '../../factoriesNumber.js';\nexport var gcdDependencies = {\n typedDependencies,\n createGcd\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLcm } from '../../factoriesNumber.js';\nexport var lcmDependencies = {\n typedDependencies,\n createLcm\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog } from '../../factoriesNumber.js';\nexport var logDependencies = {\n typedDependencies,\n createLog\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog10 } from '../../factoriesNumber.js';\nexport var log10Dependencies = {\n typedDependencies,\n createLog10\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog1p } from '../../factoriesNumber.js';\nexport var log1pDependencies = {\n typedDependencies,\n createLog1p\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog2 } from '../../factoriesNumber.js';\nexport var log2Dependencies = {\n typedDependencies,\n createLog2\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createMod } from '../../factoriesNumber.js';\nexport var modDependencies = {\n typedDependencies,\n createMod\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createNthRoot } from '../../factoriesNumber.js';\nexport var nthRootDependencies = {\n typedDependencies,\n createNthRoot\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createPi } from '../../factoriesNumber.js';\nexport var piDependencies = {\n createPi\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSign } from '../../factoriesNumber.js';\nexport var signDependencies = {\n typedDependencies,\n createSign\n};","function E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n","import Emitter from 'tiny-emitter';\n\n/**\n * Extend given object with emitter functions `on`, `off`, `once`, `emit`\n * @param {Object} obj\n * @return {Object} obj\n */\nexport function mixin(obj) {\n // create event emitter\n var emitter = new Emitter();\n\n // bind methods to obj (we don't want to expose the emitter.e Array...)\n obj.on = emitter.on.bind(emitter);\n obj.off = emitter.off.bind(emitter);\n obj.once = emitter.once.bind(emitter);\n obj.emit = emitter.emit.bind(emitter);\n return obj;\n}","import { isBigNumber, isComplex, isFraction, isMatrix, isObject, isUnit } from '../../utils/is.js';\nimport { isFactory, stripOptionalNotation } from '../../utils/factory.js';\nimport { hasOwnProperty, lazy } from '../../utils/object.js';\nimport { ArgumentsError } from '../../error/ArgumentsError.js';\nexport function importFactory(typed, load, math, importedFactories) {\n /**\n * Import functions from an object or a module.\n *\n * This function is only available on a mathjs instance created using `create`.\n *\n * Syntax:\n *\n * math.import(functions)\n * math.import(functions, options)\n *\n * Where:\n *\n * - `functions: Object`\n * An object with functions or factories to be imported.\n * - `options: Object` An object with import options. Available options:\n * - `override: boolean`\n * If true, existing functions will be overwritten. False by default.\n * - `silent: boolean`\n * If true, the function will not throw errors on duplicates or invalid\n * types. False by default.\n * - `wrap: boolean`\n * If true, the functions will be wrapped in a wrapper function\n * which converts data types like Matrix to primitive data types like Array.\n * The wrapper is needed when extending math.js with libraries which do not\n * support these data type. False by default.\n *\n * Examples:\n *\n * import { create, all } from 'mathjs'\n * import * as numbers from 'numbers'\n *\n * // create a mathjs instance\n * const math = create(all)\n *\n * // define new functions and variables\n * math.import({\n * myvalue: 42,\n * hello: function (name) {\n * return 'hello, ' + name + '!'\n * }\n * })\n *\n * // use the imported function and variable\n * math.myvalue * 2 // 84\n * math.hello('user') // 'hello, user!'\n *\n * // import the npm module 'numbers'\n * // (must be installed first with `npm install numbers`)\n * math.import(numbers, {wrap: true})\n *\n * math.fibonacci(7) // returns 13\n *\n * History:\n *\n * v0.2 Created\n * v0.7 Changed second parameter to an options object\n * v2 Dropped support for direct import of a module by name\n * v14.2 Add facility for specifying the former name of an import\n *\n * @param {Object | Array} functions Object with functions to be imported.\n * @param {Object} [options] Import options.\n */\n function mathImport(functions, options) {\n var num = arguments.length;\n if (num !== 1 && num !== 2) {\n throw new ArgumentsError('import', num, 1, 2);\n }\n if (!options) {\n options = {};\n }\n function flattenImports(flatValues, value, name) {\n if (Array.isArray(value)) {\n value.forEach(item => flattenImports(flatValues, item));\n } else if (isObject(value) || isModule(value)) {\n for (var _name in value) {\n if (hasOwnProperty(value, _name)) {\n flattenImports(flatValues, value[_name], _name);\n }\n }\n } else if (isFactory(value) || name !== undefined) {\n var flatName = isFactory(value) ? isTransformFunctionFactory(value) ? value.fn + '.transform' // TODO: this is ugly\n : value.fn : name;\n\n // we allow importing the same function twice if it points to the same implementation\n if (hasOwnProperty(flatValues, flatName) && flatValues[flatName] !== value && !options.silent) {\n throw new Error('Cannot import \"' + flatName + '\" twice');\n }\n flatValues[flatName] = value;\n } else {\n if (!options.silent) {\n throw new TypeError('Factory, Object, or Array expected');\n }\n }\n }\n var flatValues = {};\n flattenImports(flatValues, functions);\n for (var name in flatValues) {\n if (hasOwnProperty(flatValues, name)) {\n // console.log('import', name)\n var value = flatValues[name];\n if (isFactory(value)) {\n // we ignore name here and enforce the name of the factory\n // maybe at some point we do want to allow overriding it\n // in that case we can implement an option overrideFactoryNames: true\n _importFactory(value, options);\n } else if (isSupportedType(value)) {\n _import(name, value, options);\n } else {\n if (!options.silent) {\n throw new TypeError('Factory, Object, or Array expected');\n }\n }\n }\n }\n }\n\n /**\n * Add a property to the math namespace\n * @param {string} name\n * @param {*} value\n * @param {Object} options See import for a description of the options\n * @private\n */\n function _import(name, value, options) {\n var _math$Unit;\n // TODO: refactor this function, it's to complicated and contains duplicate code\n if (options.wrap && typeof value === 'function') {\n // create a wrapper around the function\n value = _wrap(value);\n }\n\n // turn a plain function with a typed-function signature into a typed-function\n if (hasTypedFunctionSignature(value)) {\n value = typed(name, {\n [value.signature]: value\n });\n }\n if (typed.isTypedFunction(math[name]) && typed.isTypedFunction(value)) {\n if (options.override) {\n // give the typed function the right name\n value = typed(name, value.signatures);\n } else {\n // merge the existing and typed function\n value = typed(math[name], value);\n }\n math[name] = value;\n delete importedFactories[name];\n _importTransform(name, value);\n math.emit('import', name, function resolver() {\n return value;\n });\n return;\n }\n var isDefined = math[name] !== undefined;\n var isValuelessUnit = (_math$Unit = math.Unit) === null || _math$Unit === void 0 ? void 0 : _math$Unit.isValuelessUnit(name);\n if (!isDefined && !isValuelessUnit || options.override) {\n math[name] = value;\n delete importedFactories[name];\n _importTransform(name, value);\n math.emit('import', name, function resolver() {\n return value;\n });\n return;\n }\n if (!options.silent) {\n throw new Error('Cannot import \"' + name + '\": already exists');\n }\n }\n function _importTransform(name, value) {\n if (value && typeof value.transform === 'function') {\n math.expression.transform[name] = value.transform;\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = value.transform;\n }\n } else {\n // remove existing transform\n delete math.expression.transform[name];\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = value;\n }\n }\n }\n function _deleteTransform(name) {\n delete math.expression.transform[name];\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = math[name];\n } else {\n delete math.expression.mathWithTransform[name];\n }\n }\n\n /**\n * Create a wrapper a round an function which converts the arguments\n * to their primitive values (like convert a Matrix to Array)\n * @param {Function} fn\n * @return {Function} Returns the wrapped function\n * @private\n */\n function _wrap(fn) {\n var wrapper = function wrapper() {\n var args = [];\n for (var i = 0, len = arguments.length; i < len; i++) {\n var arg = arguments[i];\n args[i] = arg && arg.valueOf();\n }\n return fn.apply(math, args);\n };\n if (fn.transform) {\n wrapper.transform = fn.transform;\n }\n return wrapper;\n }\n\n /**\n * Import an instance of a factory into math.js\n * @param {function(scope: object)} factory\n * @param {Object} options See import for a description of the options\n * @param {string} [name=factory.name] Optional custom name\n * @private\n */\n function _importFactory(factory, options) {\n var _factory$meta$formerl, _factory$meta;\n var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : factory.fn;\n if (name.includes('.')) {\n throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));\n }\n var namespace = isTransformFunctionFactory(factory) ? math.expression.transform : math;\n var existingTransform = name in math.expression.transform;\n var existing = hasOwnProperty(namespace, name) ? namespace[name] : undefined;\n var resolver = function resolver() {\n // collect all dependencies, handle finding both functions and classes and other special cases\n var dependencies = {};\n factory.dependencies.map(stripOptionalNotation).forEach(dependency => {\n if (dependency.includes('.')) {\n throw new Error('Factory dependency should not contain a nested path. ' + 'Name: ' + JSON.stringify(dependency));\n }\n if (dependency === 'math') {\n dependencies.math = math;\n } else if (dependency === 'mathWithTransform') {\n dependencies.mathWithTransform = math.expression.mathWithTransform;\n } else if (dependency === 'classes') {\n // special case for json reviver\n dependencies.classes = math;\n } else {\n dependencies[dependency] = math[dependency];\n }\n });\n var instance = /* #__PURE__ */factory(dependencies);\n if (instance && typeof instance.transform === 'function') {\n throw new Error('Transforms cannot be attached to factory functions. ' + 'Please create a separate function for it with export const path = \"expression.transform\"');\n }\n if (existing === undefined || options.override) {\n return instance;\n }\n if (typed.isTypedFunction(existing) && typed.isTypedFunction(instance)) {\n // merge the existing and new typed function\n return typed(existing, instance);\n }\n if (options.silent) {\n // keep existing, ignore imported function\n return existing;\n } else {\n throw new Error('Cannot import \"' + name + '\": already exists');\n }\n };\n var former = (_factory$meta$formerl = (_factory$meta = factory.meta) === null || _factory$meta === void 0 ? void 0 : _factory$meta.formerly) !== null && _factory$meta$formerl !== void 0 ? _factory$meta$formerl : '';\n var needsTransform = isTransformFunctionFactory(factory) || factoryAllowedInExpressions(factory);\n var withTransform = math.expression.mathWithTransform;\n\n // TODO: add unit test with non-lazy factory\n if (!factory.meta || factory.meta.lazy !== false) {\n lazy(namespace, name, resolver);\n if (former) lazy(namespace, former, resolver);\n\n // FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)\n if (existing && existingTransform) {\n _deleteTransform(name);\n if (former) _deleteTransform(former);\n } else {\n if (needsTransform) {\n lazy(withTransform, name, () => namespace[name]);\n if (former) lazy(withTransform, former, () => namespace[name]);\n }\n }\n } else {\n namespace[name] = resolver();\n if (former) namespace[former] = namespace[name];\n\n // FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)\n if (existing && existingTransform) {\n _deleteTransform(name);\n if (former) _deleteTransform(former);\n } else {\n if (needsTransform) {\n lazy(withTransform, name, () => namespace[name]);\n if (former) lazy(withTransform, former, () => namespace[name]);\n }\n }\n }\n\n // TODO: improve factories, store a list with imports instead which can be re-played\n importedFactories[name] = factory;\n math.emit('import', name, resolver);\n }\n\n /**\n * Check whether given object is a type which can be imported\n * @param {Function | number | string | boolean | null | Unit | Complex} object\n * @return {boolean}\n * @private\n */\n function isSupportedType(object) {\n return typeof object === 'function' || typeof object === 'number' || typeof object === 'string' || typeof object === 'boolean' || object === null || isUnit(object) || isComplex(object) || isBigNumber(object) || isFraction(object) || isMatrix(object) || Array.isArray(object);\n }\n function isModule(object) {\n return typeof object === 'object' && object[Symbol.toStringTag] === 'Module';\n }\n function hasTypedFunctionSignature(fn) {\n return typeof fn === 'function' && typeof fn.signature === 'string';\n }\n function allowedInExpressions(name) {\n return !hasOwnProperty(unsafe, name);\n }\n function factoryAllowedInExpressions(factory) {\n return !factory.fn.includes('.') &&\n // FIXME: make checking on path redundant, check on meta data instead\n !hasOwnProperty(unsafe, factory.fn) && (!factory.meta || !factory.meta.isClass);\n }\n function isTransformFunctionFactory(factory) {\n return factory !== undefined && factory.meta !== undefined && factory.meta.isTransformFunction === true || false;\n }\n\n // namespaces and functions not available in the parser for safety reasons\n var unsafe = {\n expression: true,\n type: true,\n docs: true,\n error: true,\n json: true,\n chain: true // chain method not supported. Note that there is a unit chain too.\n };\n return mathImport;\n}","import _extends from \"@babel/runtime/helpers/extends\";\nimport typedFunction from 'typed-function';\nimport { ArgumentsError } from '../error/ArgumentsError.js';\nimport { DimensionError } from '../error/DimensionError.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { factory, isFactory } from '../utils/factory.js';\nimport { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigInt, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMap, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isObjectWrappingMap, isOperatorNode, isParenthesisNode, isPartitionedMap, isRange, isRangeNode, isRegExp, isRelationalNode, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../utils/is.js';\nimport { deepFlatten, isLegacyFactory } from '../utils/object.js';\nimport * as emitter from './../utils/emitter.js';\nimport { DEFAULT_CONFIG } from './config.js';\nimport { configFactory } from './function/config.js';\nimport { importFactory } from './function/import.js';\n\n/**\n * Create a mathjs instance from given factory functions and optionally config\n *\n * Usage:\n *\n * const mathjs1 = create({ createAdd, createMultiply, ...})\n * const config = { number: 'BigNumber' }\n * const mathjs2 = create(all, config)\n *\n * @param {Object} [factories] An object with factory functions\n * The object can contain nested objects,\n * all nested objects will be flattened.\n * @param {Object} [config] Available options:\n * {number} relTol\n * Minimum relative difference between two\n * compared values, used by all comparison functions.\n * {number} absTol\n * Minimum absolute difference between two\n * compared values, used by all comparison functions.\n * {string} matrix\n * A string 'Matrix' (default) or 'Array'.\n * {string} number\n * A string 'number' (default), 'BigNumber', or 'Fraction'\n * {number} precision\n * The number of significant digits for BigNumbers.\n * Not applicable for Numbers.\n * {boolean} predictable\n * Predictable output type of functions. When true,\n * output type depends only on the input types. When\n * false (default), output type can vary depending\n * on input values. For example `math.sqrt(-4)`\n * returns `complex('2i')` when predictable is false, and\n * returns `NaN` when true.\n * {string} randomSeed\n * Random seed for seeded pseudo random number generator.\n * Set to null to randomly seed.\n * @returns {Object} Returns a bare-bone math.js instance containing\n * functions:\n * - `import` to add new functions\n * - `config` to change configuration\n * - `on`, `off`, `once`, `emit` for events\n */\nexport function create(factories, config) {\n var configInternal = _extends({}, DEFAULT_CONFIG, config);\n\n // simple test for ES5 support\n if (typeof Object.create !== 'function') {\n throw new Error('ES5 not supported by this JavaScript engine. ' + 'Please load the es5-shim and es5-sham library for compatibility.');\n }\n\n // create the mathjs instance\n var math = emitter.mixin({\n // only here for backward compatibility for legacy factory functions\n isNumber,\n isComplex,\n isBigNumber,\n isBigInt,\n isFraction,\n isUnit,\n isString,\n isArray,\n isMatrix,\n isCollection,\n isDenseMatrix,\n isSparseMatrix,\n isRange,\n isIndex,\n isBoolean,\n isResultSet,\n isHelp,\n isFunction,\n isDate,\n isRegExp,\n isObject,\n isMap,\n isPartitionedMap,\n isObjectWrappingMap,\n isNull,\n isUndefined,\n isAccessorNode,\n isArrayNode,\n isAssignmentNode,\n isBlockNode,\n isConditionalNode,\n isConstantNode,\n isFunctionAssignmentNode,\n isFunctionNode,\n isIndexNode,\n isNode,\n isObjectNode,\n isOperatorNode,\n isParenthesisNode,\n isRangeNode,\n isRelationalNode,\n isSymbolNode,\n isChain\n });\n\n // load config function and apply provided config\n math.config = configFactory(configInternal, math.emit);\n math.expression = {\n transform: {},\n mathWithTransform: {\n config: math.config\n }\n };\n\n // cached factories and instances used by function load\n var legacyFactories = [];\n var legacyInstances = [];\n\n /**\n * Load a function or data type from a factory.\n * If the function or data type already exists, the existing instance is\n * returned.\n * @param {Function} factory\n * @returns {*}\n */\n function load(factory) {\n if (isFactory(factory)) {\n return factory(math);\n }\n var firstProperty = factory[Object.keys(factory)[0]];\n if (isFactory(firstProperty)) {\n return firstProperty(math);\n }\n if (!isLegacyFactory(factory)) {\n console.warn('Factory object with properties `type`, `name`, and `factory` expected', factory);\n throw new Error('Factory object with properties `type`, `name`, and `factory` expected');\n }\n var index = legacyFactories.indexOf(factory);\n var instance;\n if (index === -1) {\n // doesn't yet exist\n if (factory.math === true) {\n // pass with math namespace\n instance = factory.factory(math.type, configInternal, load, math.typed, math);\n } else {\n instance = factory.factory(math.type, configInternal, load, math.typed);\n }\n\n // append to the cache\n legacyFactories.push(factory);\n legacyInstances.push(instance);\n } else {\n // already existing function, return the cached instance\n instance = legacyInstances[index];\n }\n return instance;\n }\n var importedFactories = {};\n\n // load the import function\n function lazyTyped() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return math.typed.apply(math.typed, args);\n }\n lazyTyped.isTypedFunction = typedFunction.isTypedFunction;\n var internalImport = importFactory(lazyTyped, load, math, importedFactories);\n math.import = internalImport;\n\n // listen for changes in config, import all functions again when changed\n // TODO: move this listener into the import function?\n math.on('config', () => {\n Object.values(importedFactories).forEach(factory => {\n if (factory && factory.meta && factory.meta.recreateOnConfigChange) {\n // FIXME: only re-create when the current instance is the same as was initially created\n // FIXME: delete the functions/constants before importing them again?\n internalImport(factory, {\n override: true\n });\n }\n });\n });\n\n // the create function exposed on the mathjs instance is bound to\n // the factory functions passed before\n math.create = create.bind(null, factories);\n\n // export factory function\n math.factory = factory;\n\n // import the factory functions like createAdd as an array instead of object,\n // else they will get a different naming (`createAdd` instead of `add`).\n math.import(Object.values(deepFlatten(factories)));\n math.ArgumentsError = ArgumentsError;\n math.DimensionError = DimensionError;\n math.IndexError = IndexError;\n return math;\n}","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { getElement } from \"./getElement.ts\";\n\nexport const appendAnswerElement = (element: HTMLElement | string | number): void => {\n const results = getElement(\"results\");\n\n // ./searx/templates/elements/answers.html\n let answers = getElement(\"answers\", { assert: false });\n if (!answers) {\n // what is this?\n const answersTitle = document.createElement(\"h4\");\n answersTitle.setAttribute(\"class\", \"title\");\n answersTitle.setAttribute(\"id\", \"answers-title\");\n answersTitle.textContent = \"Answers : \";\n\n answers = document.createElement(\"div\");\n answers.setAttribute(\"id\", \"answers\");\n answers.setAttribute(\"role\", \"complementary\");\n answers.setAttribute(\"aria-labelledby\", \"answers-title\");\n answers.appendChild(answersTitle);\n }\n\n if (!(element instanceof HTMLElement)) {\n const span = document.createElement(\"span\");\n span.innerHTML = element.toString();\n // biome-ignore lint/style/noParameterAssign: TODO\n element = span;\n }\n\n answers.appendChild(element);\n\n results.insertAdjacentElement(\"afterbegin\", answers);\n};\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport {\n absDependencies,\n addDependencies,\n create,\n divideDependencies,\n eDependencies,\n evaluateDependencies,\n expDependencies,\n factorialDependencies,\n gcdDependencies,\n lcmDependencies,\n log1pDependencies,\n log2Dependencies,\n log10Dependencies,\n logDependencies,\n modDependencies,\n multiplyDependencies,\n nthRootDependencies,\n piDependencies,\n powDependencies,\n roundDependencies,\n signDependencies,\n sqrtDependencies,\n subtractDependencies\n} from \"mathjs/number\";\nimport { Plugin } from \"../Plugin.ts\";\nimport { appendAnswerElement } from \"../util/appendAnswerElement.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\n/**\n * Parses and solves mathematical expressions. Can do basic arithmetic and\n * evaluate some functions.\n *\n * @example\n * \"(3 + 5) / 2\" = \"4\"\n * \"e ^ 2 + pi\" = \"10.530648752520442\"\n * \"gcd(48, 18) + lcm(4, 5)\" = \"26\"\n *\n * @remarks\n * Depends on `mathjs` library.\n */\nexport default class Calculator extends Plugin {\n public constructor() {\n super(\"calculator\");\n }\n\n /**\n * @remarks\n * Compare bundle size after adding or removing features.\n */\n private static readonly math = create({\n ...absDependencies,\n ...addDependencies,\n ...divideDependencies,\n ...eDependencies,\n ...evaluateDependencies,\n ...expDependencies,\n ...factorialDependencies,\n ...gcdDependencies,\n ...lcmDependencies,\n ...log10Dependencies,\n ...log1pDependencies,\n ...log2Dependencies,\n ...logDependencies,\n ...modDependencies,\n ...multiplyDependencies,\n ...nthRootDependencies,\n ...piDependencies,\n ...powDependencies,\n ...roundDependencies,\n ...signDependencies,\n ...sqrtDependencies,\n ...subtractDependencies\n });\n\n protected async run(): Promise {\n const searchInput = getElement(\"q\");\n const node = Calculator.math.parse(searchInput.value);\n\n try {\n return `${node.toString()} = ${node.evaluate()}`;\n } catch {\n // not a compatible math expression\n return;\n }\n }\n\n protected async post(result: string): Promise {\n appendAnswerElement(result);\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,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,KAAK,EAAE,CAC5zgB,CAAE,CACD,KAAM,SACN,KAAM,EACP,CAAE,CACD,KAAM,QACN,KAAM,GACP,CAAE,CACD,KAAM,QACN,KAAM,EACP,CAAE,CACD,KAAM,SACN,KAAM,EACP,CAAE,CACD,KAAM,cACN,KAAM,EACP,CAAE,CACD,KAAM,eACN,KAAM,GACP,CAAE,CACD,KAAM,QACN,KAAM,GACP,CAAE,CACD,KAAM,QACN,KAAM,EACP,CAAE,CACD,KAAM,UACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,GACP,CAAE,CACD,KAAM,WACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,GACP,CAAE,CACD,KAAM,SACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,EACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,iBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,kBACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,EACP,CAAE,CACD,KAAM,eACN,KAAM,GACP,CAAE,CACD,KAAM,yBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,EACP,CAAE,CACD,KAAM,OACN,KAAM,EACP,CAAE,CACD,KAAM,aACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,GACP,CAAE,CACD,KAAM,kBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,iBACN,KAAM,GACP,CAAE,CACD,KAAM,aACN,KAAM,EACP,CAAE,CACD,KAAM,MACN,KAAM,EACP,CAAE,CACD,KAAM,SACN,KAAM,EACP,CACA,CAAC,CACF,EAAM,eAAe,CAAC,CACpB,KAAM,SACN,GAAI,YACJ,QAAS,SAAiB,EAAG,CAM3B,GALK,GACH,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,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACJ,CAAC,CAEF,MAAgB,KAAmC,CACjD,IAAM,EAAc,EAA6B,IAAI,CAC/C,EAAO,EAAW,KAAK,MAAM,EAAY,MAAM,CAErD,GAAI,CACF,MAAO,GAAG,EAAK,UAAU,CAAC,KAAK,EAAK,UAAU,QACxC,CAEN,QAIJ,MAAgB,KAAK,EAA+B,CAClD,GAAoB,EAAO"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BFSBs3g1.min.js b/searx/static/themes/simple/chunk/BFSBs3g1.min.js new file mode 100644 index 000000000..f8dadd59b --- /dev/null +++ b/searx/static/themes/simple/chunk/BFSBs3g1.min.js @@ -0,0 +1,2 @@ +import{i as e,r as t,s as n}from"./Cs5Jkbkf.min.js";import{t as r}from"./DXl78Wnf.min.js";var i=async(i,a)=>{try{let o;o=n.method===`GET`?await t(`GET`,`./autocompleter?q=${a}`):await t(`POST`,`./autocompleter`,{body:new URLSearchParams({q:a})});let s=await o.json(),c=document.querySelector(`.autocomplete`);r(c);let l=document.querySelector(`.autocomplete ul`);if(r(l),c.classList.add(`open`),l.replaceChildren(),s?.[1]?.length===0){let e=Object.assign(document.createElement(`li`),{className:`no-item-found`,textContent:n.translations?.no_item_found??`No results found`});l.append(e);return}let u=new DocumentFragment;for(let t of s[1]){let n=Object.assign(document.createElement(`li`),{textContent:t});e(`mousedown`,n,()=>{i.value=t,document.querySelector(`#search`)?.submit()}),u.append(n)}l.append(u)}catch(e){console.error(`Error fetching autocomplete results:`,e)}},a=document.getElementById(`q`);r(a);var o;e(`input`,a,()=>{clearTimeout(o);let e=a.value,t=n.autocomplete_min??2;e.length{e===a.value&&await i(a,e)},300))});var s=document.querySelector(`.autocomplete`),c=document.querySelector(`.autocomplete ul`);c&&(e(`keydown`,a,e=>{e.key===`Escape`&&s?.classList.remove(`open`)}),e(`keyup`,a,e=>{let t=[...c.children],n=t.findIndex(e=>e.classList.contains(`active`)),r=-1;switch(e.key){case`ArrowUp`:{let e=t[n];e&&n>=0&&e.classList.remove(`active`),r=(n-1+t.length)%t.length;break}case`ArrowDown`:{let e=t[n];e&&n>=0&&e.classList.remove(`active`),r=(n+1)%t.length;break}case`Enter`:s&&s.classList.remove(`open`);break;default:break}if(r!==-1){let e=t[r];if(e&&(e.classList.add(`active`),!e.classList.contains(`no-item-found`))){let t=document.getElementById(`q`);t&&(t.value=e.textContent??``)}}}),e(`blur`,a,()=>{s?.classList.remove(`open`)}),e(`focus`,a,()=>{s?.classList.add(`open`)})); +//# sourceMappingURL=BFSBs3g1.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/CQ8vfMdp.min.js.map b/searx/static/themes/simple/chunk/BFSBs3g1.min.js.map similarity index 98% rename from searx/static/themes/simple/chunk/CQ8vfMdp.min.js.map rename to searx/static/themes/simple/chunk/BFSBs3g1.min.js.map index 1dbcc1572..3339dce60 100644 --- a/searx/static/themes/simple/chunk/CQ8vfMdp.min.js.map +++ b/searx/static/themes/simple/chunk/BFSBs3g1.min.js.map @@ -1 +1 @@ -{"version":3,"file":"CQ8vfMdp.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/autocomplete.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { http, listen, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\n\nconst fetchResults = async (qInput: HTMLInputElement, query: string): Promise => {\n try {\n let res: Response;\n\n if (settings.method === \"GET\") {\n res = await http(\"GET\", `./autocompleter?q=${query}`);\n } else {\n res = await http(\"POST\", \"./autocompleter\", { body: new URLSearchParams({ q: query }) });\n }\n\n const results = await res.json();\n\n const autocomplete = document.querySelector(\".autocomplete\");\n assertElement(autocomplete);\n\n const autocompleteList = document.querySelector(\".autocomplete ul\");\n assertElement(autocompleteList);\n\n autocomplete.classList.add(\"open\");\n autocompleteList.replaceChildren();\n\n // show an error message that no result was found\n if (results?.[1]?.length === 0) {\n const noItemFoundMessage = Object.assign(document.createElement(\"li\"), {\n className: \"no-item-found\",\n textContent: settings.translations?.no_item_found ?? \"No results found\"\n });\n autocompleteList.append(noItemFoundMessage);\n return;\n }\n\n const fragment = new DocumentFragment();\n\n for (const result of results[1]) {\n const li = Object.assign(document.createElement(\"li\"), { textContent: result });\n\n listen(\"mousedown\", li, () => {\n qInput.value = result;\n\n const form = document.querySelector(\"#search\");\n form?.submit();\n });\n\n fragment.append(li);\n }\n\n autocompleteList.append(fragment);\n } catch (error) {\n console.error(\"Error fetching autocomplete results:\", error);\n }\n};\n\nconst qInput = document.getElementById(\"q\") as HTMLInputElement | null;\nassertElement(qInput);\n\nlet timeoutId: number;\n\nlisten(\"input\", qInput, () => {\n clearTimeout(timeoutId);\n\n const query = qInput.value;\n const minLength = settings.autocomplete_min ?? 2;\n\n if (query.length < minLength) return;\n\n timeoutId = window.setTimeout(async () => {\n if (query === qInput.value) {\n await fetchResults(qInput, query);\n }\n }, 300);\n});\n\nconst autocomplete: HTMLElement | null = document.querySelector(\".autocomplete\");\nconst autocompleteList: HTMLUListElement | null = document.querySelector(\".autocomplete ul\");\nif (autocompleteList) {\n listen(\"keydown\", qInput, (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n autocomplete?.classList.remove(\"open\");\n }\n });\n listen(\"keyup\", qInput, (event: KeyboardEvent) => {\n const listItems = [...autocompleteList.children] as HTMLElement[];\n\n const currentIndex = listItems.findIndex((item) => item.classList.contains(\"active\"));\n let newCurrentIndex = -1;\n\n switch (event.key) {\n case \"ArrowUp\": {\n const currentItem = listItems[currentIndex];\n if (currentItem && currentIndex >= 0) {\n currentItem.classList.remove(\"active\");\n }\n // we need to add listItems.length to the index calculation here because the JavaScript modulos\n // operator doesn't work with negative numbers\n newCurrentIndex = (currentIndex - 1 + listItems.length) % listItems.length;\n break;\n }\n case \"ArrowDown\": {\n const currentItem = listItems[currentIndex];\n if (currentItem && currentIndex >= 0) {\n currentItem.classList.remove(\"active\");\n }\n newCurrentIndex = (currentIndex + 1) % listItems.length;\n break;\n }\n case \"Enter\":\n if (autocomplete) {\n autocomplete.classList.remove(\"open\");\n }\n break;\n default:\n break;\n }\n\n if (newCurrentIndex !== -1) {\n const selectedItem = listItems[newCurrentIndex];\n if (selectedItem) {\n selectedItem.classList.add(\"active\");\n\n if (!selectedItem.classList.contains(\"no-item-found\")) {\n const qInput = document.getElementById(\"q\") as HTMLInputElement | null;\n if (qInput) {\n qInput.value = selectedItem.textContent ?? \"\";\n }\n }\n }\n }\n });\n\n listen(\"blur\", qInput, () => {\n autocomplete?.classList.remove(\"open\");\n });\n\n listen(\"focus\", qInput, () => {\n autocomplete?.classList.add(\"open\");\n });\n}\n"],"mappings":"4FAKA,IAAM,EAAe,MAAO,EAA0B,IAAiC,CACrF,GAAI,CACF,IAAI,EAEJ,AAGE,EAHE,EAAS,SAAW,MAChB,MAAM,EAAK,MAAO,qBAAqB,IAAQ,CAE/C,MAAM,EAAK,OAAQ,kBAAmB,CAAE,KAAM,IAAI,gBAAgB,CAAE,EAAG,EAAO,CAAC,CAAE,CAAC,CAG1F,IAAM,EAAU,MAAM,EAAI,MAAM,CAE1B,EAAe,SAAS,cAA2B,gBAAgB,CACzE,EAAc,EAAa,CAE3B,IAAM,EAAmB,SAAS,cAAgC,mBAAmB,CAOrF,GANA,EAAc,EAAiB,CAE/B,EAAa,UAAU,IAAI,OAAO,CAClC,EAAiB,iBAAiB,CAG9B,IAAU,IAAI,SAAW,EAAG,CAC9B,IAAM,EAAqB,OAAO,OAAO,SAAS,cAAc,KAAK,CAAE,CACrE,UAAW,gBACX,YAAa,EAAS,cAAc,eAAiB,mBACtD,CAAC,CACF,EAAiB,OAAO,EAAmB,CAC3C,OAGF,IAAM,EAAW,IAAI,iBAErB,IAAK,IAAM,KAAU,EAAQ,GAAI,CAC/B,IAAM,EAAK,OAAO,OAAO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e,EAAU,GAC/B,GAAI,IACF,EAAa,UAAU,IAAI,SAAS,CAEhC,CAAC,EAAa,UAAU,SAAS,gBAAgB,EAAE,CACrD,IAAM,EAAS,SAAS,eAAe,IAAI,CACvC,IACF,EAAO,MAAQ,EAAa,aAAe,OAKnD,CAEF,EAAO,OAAQ,MAAc,CAC3B,GAAc,UAAU,OAAO,OAAO,EACtC,CAEF,EAAO,QAAS,MAAc,CAC5B,GAAc,UAAU,IAAI,OAAO,EACnC"} \ No newline at end of file +{"version":3,"file":"BFSBs3g1.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/autocomplete.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { http, listen, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\n\nconst fetchResults = async (qInput: HTMLInputElement, query: string): Promise => {\n try {\n let res: Response;\n\n if (settings.method === \"GET\") {\n res = await http(\"GET\", `./autocompleter?q=${query}`);\n } else {\n res = await http(\"POST\", \"./autocompleter\", { body: new URLSearchParams({ q: query }) });\n }\n\n const results = await res.json();\n\n const autocomplete = document.querySelector(\".autocomplete\");\n assertElement(autocomplete);\n\n const autocompleteList = document.querySelector(\".autocomplete ul\");\n assertElement(autocompleteList);\n\n autocomplete.classList.add(\"open\");\n autocompleteList.replaceChildren();\n\n // show an error message that no result was found\n if (results?.[1]?.length === 0) {\n const noItemFoundMessage = Object.assign(document.createElement(\"li\"), {\n className: \"no-item-found\",\n textContent: settings.translations?.no_item_found ?? \"No results found\"\n });\n autocompleteList.append(noItemFoundMessage);\n return;\n }\n\n const fragment = new DocumentFragment();\n\n for (const result of results[1]) {\n const li = Object.assign(document.createElement(\"li\"), { textContent: result });\n\n listen(\"mousedown\", li, () => {\n qInput.value = result;\n\n const form = document.querySelector(\"#search\");\n form?.submit();\n });\n\n fragment.append(li);\n }\n\n autocompleteList.append(fragment);\n } catch (error) {\n console.error(\"Error fetching autocomplete results:\", error);\n }\n};\n\nconst qInput = document.getElementById(\"q\") as HTMLInputElement | null;\nassertElement(qInput);\n\nlet timeoutId: number;\n\nlisten(\"input\", qInput, () => {\n clearTimeout(timeoutId);\n\n const query = qInput.value;\n const minLength = settings.autocomplete_min ?? 2;\n\n if (query.length < minLength) return;\n\n timeoutId = window.setTimeout(async () => {\n if (query === qInput.value) {\n await fetchResults(qInput, query);\n }\n }, 300);\n});\n\nconst autocomplete: HTMLElement | null = document.querySelector(\".autocomplete\");\nconst autocompleteList: HTMLUListElement | null = document.querySelector(\".autocomplete ul\");\nif (autocompleteList) {\n listen(\"keydown\", qInput, (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n autocomplete?.classList.remove(\"open\");\n }\n });\n listen(\"keyup\", qInput, (event: KeyboardEvent) => {\n const listItems = [...autocompleteList.children] as HTMLElement[];\n\n const currentIndex = listItems.findIndex((item) => item.classList.contains(\"active\"));\n let newCurrentIndex = -1;\n\n switch (event.key) {\n case \"ArrowUp\": {\n const currentItem = listItems[currentIndex];\n if (currentItem && currentIndex >= 0) {\n currentItem.classList.remove(\"active\");\n }\n // we need to add listItems.length to the index calculation here because the JavaScript modulos\n // operator doesn't work with negative numbers\n newCurrentIndex = (currentIndex - 1 + listItems.length) % listItems.length;\n break;\n }\n case \"ArrowDown\": {\n const currentItem = listItems[currentIndex];\n if (currentItem && currentIndex >= 0) {\n currentItem.classList.remove(\"active\");\n }\n newCurrentIndex = (currentIndex + 1) % listItems.length;\n break;\n }\n case \"Enter\":\n if (autocomplete) {\n autocomplete.classList.remove(\"open\");\n }\n break;\n default:\n break;\n }\n\n if (newCurrentIndex !== -1) {\n const selectedItem = listItems[newCurrentIndex];\n if (selectedItem) {\n selectedItem.classList.add(\"active\");\n\n if (!selectedItem.classList.contains(\"no-item-found\")) {\n const qInput = document.getElementById(\"q\") as HTMLInputElement | null;\n if (qInput) {\n qInput.value = selectedItem.textContent ?? \"\";\n }\n }\n }\n }\n });\n\n listen(\"blur\", qInput, () => {\n autocomplete?.classList.remove(\"open\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,IAAU,EAAO,OACnB,MAAM,EAAa,EAAQ,EAAM,EAElC,IAAI,GACP,CAEF,IAAM,EAAmC,SAAS,cAA2B,gBAAgB,CACvF,EAA4C,SAAS,cAAgC,mBAAmB,CAC1G,IACF,EAAO,UAAW,EAAS,GAAyB,CAC9C,EAAM,MAAQ,UAChB,GAAc,UAAU,OAAO,OAAO,EAExC,CACF,EAAO,QAAS,EAAS,GAAyB,CAChD,IAAM,EAAY,CAAC,GAAG,EAAiB,SAAS,CAE1C,EAAe,EAAU,UAAW,GAAS,EAAK,UAAU,SAAS,SAAS,CAAC,CACjF,EAAkB,GAEtB,OAAQ,EAAM,IAAd,CACE,IAAK,UAAW,CACd,IAAM,EAAc,EAAU,GAC1B,GAAe,GAAgB,GACjC,EAAY,UAAU,OAAO,SAAS,CAIxC,GAAmB,EAAe,EAAI,EAAU,QAAU,EAAU,OACpE,MAEF,IAAK,YAAa,CAChB,IAAM,EAAc,EAAU,GAC1B,GAAe,GAAgB,GACjC,EAAY,UAAU,OAAO,SAAS,CAExC,GAAmB,EAAe,GAAK,EAAU,OACjD,MAEF,IAAK,QACC,GACF,EAAa,UAAU,OAAO,OAAO,CAEvC,MACF,QACE,MAGJ,GAAI,IAAoB,GAAI,CAC1B,IAAM,EAAe,EAAU,GAC/B,GAAI,IACF,EAAa,UAAU,IAAI,SAAS,CAEhC,CAAC,EAAa,UAAU,SAAS,gBAAgB,EAAE,CACrD,IAAM,EAAS,SAAS,eAAe,IAAI,CACvC,IACF,EAAO,MAAQ,EAAa,aAAe,OAKnD,CAEF,EAAO,OAAQ,MAAc,CAC3B,GAAc,UAAU,OAAO,OAAO,EACtC,CAEF,EAAO,QAAS,MAAc,CAC5B,GAAc,UAAU,IAAI,OAAO,EACnC"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BG44gnGf.min.js b/searx/static/themes/simple/chunk/BG44gnGf.min.js new file mode 100644 index 000000000..6bf7ad0f5 --- /dev/null +++ b/searx/static/themes/simple/chunk/BG44gnGf.min.js @@ -0,0 +1,2 @@ +import{i as e}from"./Cs5Jkbkf.min.js";import{t}from"./vehLS1_D.min.js";var n=t(`search`),r=t(`q`),i=t(`clear_search`),a=window.matchMedia(`(max-width: 50em)`).matches,o=document.querySelector(`main`)?.id===`main_results`,s=Array.from(document.querySelectorAll(`#categories_container button.category`));r.value.length===0&&i.classList.add(`empty`),a||o||r.focus(),a&&e(`focus`,r,()=>{requestAnimationFrame(()=>{let e=r.value.length;r.setSelectionRange(e,e),r.scrollLeft=r.scrollWidth})}),e(`input`,r,()=>{i.classList.toggle(`empty`,r.value.length===0)}),e(`click`,i,e=>{e.preventDefault(),r.value=``,r.focus(),i.classList.add(`empty`)});for(let t of s)e(`click`,t,e=>{if(e.shiftKey){e.preventDefault(),t.classList.toggle(`selected`);return}for(let e of s)e.classList.toggle(`selected`,e===t)});if(document.querySelector(`div.search_filters`)){let t=document.getElementById(`safesearch`);t&&e(`change`,t,()=>n.submit());let r=document.getElementById(`time_range`);r&&e(`change`,r,()=>n.submit());let i=document.getElementById(`language`);i&&e(`change`,i,()=>n.submit())}e(`submit`,n,e=>{if(e.preventDefault(),s.length>0){let e=t(`selected-categories`);e.value=s.filter(e=>e.classList.contains(`selected`)).map(e=>e.name.replace(`category_`,``)).join(`,`)}n.submit()}); +//# sourceMappingURL=BG44gnGf.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BnP4vIuG.min.js.map b/searx/static/themes/simple/chunk/BG44gnGf.min.js.map similarity index 97% rename from searx/static/themes/simple/chunk/BnP4vIuG.min.js.map rename to searx/static/themes/simple/chunk/BG44gnGf.min.js.map index a01722a38..6e1e477a2 100644 --- a/searx/static/themes/simple/chunk/BnP4vIuG.min.js.map +++ b/searx/static/themes/simple/chunk/BG44gnGf.min.js.map @@ -1 +1 @@ -{"version":3,"file":"BnP4vIuG.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/search.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { listen } from \"../toolkit.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\nconst searchForm: HTMLFormElement = getElement(\"search\");\nconst searchInput: HTMLInputElement = getElement(\"q\");\nconst searchReset: HTMLButtonElement = getElement(\"clear_search\");\n\nconst isMobile: boolean = window.matchMedia(\"(max-width: 50em)\").matches;\nconst isResultsPage: boolean = document.querySelector(\"main\")?.id === \"main_results\";\n\nconst categoryButtons: HTMLButtonElement[] = Array.from(\n document.querySelectorAll(\"#categories_container button.category\")\n);\n\nif (searchInput.value.length === 0) {\n searchReset.classList.add(\"empty\");\n}\n\n// focus search input on large screens\nif (!(isMobile || isResultsPage)) {\n searchInput.focus();\n}\n\n// On mobile, move cursor to the end of the input on focus\nif (isMobile) {\n listen(\"focus\", searchInput, () => {\n // Defer cursor move until the next frame to prevent a visual jump\n requestAnimationFrame(() => {\n const end = searchInput.value.length;\n searchInput.setSelectionRange(end, end);\n searchInput.scrollLeft = searchInput.scrollWidth;\n });\n });\n}\n\nlisten(\"input\", searchInput, () => {\n searchReset.classList.toggle(\"empty\", searchInput.value.length === 0);\n});\n\nlisten(\"click\", searchReset, (event: MouseEvent) => {\n event.preventDefault();\n searchInput.value = \"\";\n searchInput.focus();\n searchReset.classList.add(\"empty\");\n});\n\nfor (const button of categoryButtons) {\n listen(\"click\", button, (event: MouseEvent) => {\n if (event.shiftKey) {\n event.preventDefault();\n button.classList.toggle(\"selected\");\n return;\n }\n\n // deselect all other categories\n for (const categoryButton of categoryButtons) {\n categoryButton.classList.toggle(\"selected\", categoryButton === button);\n }\n });\n}\n\nif (document.querySelector(\"div.search_filters\")) {\n const safesearchElement = document.getElementById(\"safesearch\");\n if (safesearchElement) {\n listen(\"change\", safesearchElement, () => searchForm.submit());\n }\n\n const timeRangeElement = document.getElementById(\"time_range\");\n if (timeRangeElement) {\n listen(\"change\", timeRangeElement, () => searchForm.submit());\n }\n\n const languageElement = document.getElementById(\"language\");\n if (languageElement) {\n listen(\"change\", languageElement, () => searchForm.submit());\n }\n}\n\n// override searchForm submit event\nlisten(\"submit\", searchForm, (event: Event) => {\n event.preventDefault();\n\n if (categoryButtons.length > 0) {\n const searchCategories = getElement(\"selected-categories\");\n searchCategories.value = categoryButtons\n .filter((button) => button.classList.contains(\"selected\"))\n .map((button) => button.name.replace(\"category_\", \"\"))\n .join(\",\");\n }\n\n searchForm.submit();\n});\n"],"mappings":"yEAKA,IAAM,EAA8B,EAA4B,SAAS,CACnE,EAAgC,EAA6B,IAAI,CACjE,EAAiC,EAA8B,eAAe,CAE9E,EAAoB,OAAO,WAAW,oBAAoB,CAAC,QAC3D,EAAyB,SAAS,cAAc,OAAO,EAAE,KAAO,eAEhE,EAAuC,MAAM,KACjD,SAAS,iBAAoC,wCAAwC,CACtF,CAEG,EAAY,MAAM,SAAW,GAC/B,EAAY,UAAU,IAAI,QAAQ,CAI9B,GAAY,GAChB,EAAY,OAAO,CAIjB,GACF,EAAO,QAAS,MAAmB,CAEjC,0BAA4B,CAC1B,IAAM,EAAM,EAAY,MAAM,OAC9B,EAAY,kBAAkB,EAAK,EAAI,CACvC,EAAY,WAAa,EAAY,aACrC,EACF,CAGJ,EAAO,QAAS,MAAmB,CACjC,EAAY,UAAU,OAAO,QAAS,EAAY,MAAM,SAAW,EAAE,EACrE,CAEF,EAAO,QAAS,EAAc,GAAsB,CAClD,EAAM,gBAAgB,CACtB,EAAY,MAAQ,GACpB,EAAY,OAAO,CACnB,EAAY,UAAU,IAAI,QAAQ,EAClC,CAEF,IAAK,IAAM,KAAU,EACnB,EAAO,QAAS,EAAS,GAAsB,CAC7C,GAAI,EAAM,SAAU,CAClB,EAAM,gBAAgB,CACtB,EAAO,UAAU,OAAO,WAAW,CACnC,OAIF,IAAK,IAAM,KAAkB,EAC3B,EAAe,UAAU,OAAO,WAAY,IAAmB,EAAO,EAExE,CAGJ,GAAI,SAAS,cAAc,qBAAqB,CAAE,CAChD,IAAM,EAAoB,SAAS,eAAe,aAAa,CAC3D,GACF,EAAO,SAAU,MAAyB,EAAW,QAAQ,CAAC,CAGhE,IAAM,EAAmB,SAAS,eAAe,aAAa,CAC1D,GACF,EAAO,SAAU,MAAwB,EAAW,QAAQ,CAAC,CAG/D,IAAM,EAAkB,SAAS,eAAe,WAAW,CACvD,GACF,EAAO,SAAU,MAAuB,EAAW,QAAQ,CAAC,CAKhE,EAAO,SAAU,EAAa,GAAiB,CAG7C,GAFA,EAAM,gBAAgB,CAElB,EAAgB,OAAS,EAAG,CAC9B,IAAM,EAAmB,EAA6B,sBAAsB,CAC5E,EAAiB,MAAQ,EACtB,OAAQ,GAAW,EAAO,UAAU,SAAS,WAAW,CAAC,CACzD,IAAK,GAAW,EAAO,KAAK,QAAQ,YAAa,GAAG,CAAC,CACrD,KAAK,IAAI,CAGd,EAAW,QAAQ,EACnB"} \ No newline at end of file +{"version":3,"file":"BG44gnGf.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/search.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { listen } from \"../toolkit.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\nconst searchForm: HTMLFormElement = getElement(\"search\");\nconst searchInput: HTMLInputElement = getElement(\"q\");\nconst searchReset: HTMLButtonElement = getElement(\"clear_search\");\n\nconst isMobile: boolean = window.matchMedia(\"(max-width: 50em)\").matches;\nconst isResultsPage: boolean = document.querySelector(\"main\")?.id === \"main_results\";\n\nconst categoryButtons: HTMLButtonElement[] = Array.from(\n document.querySelectorAll(\"#categories_container button.category\")\n);\n\nif (searchInput.value.length === 0) {\n searchReset.classList.add(\"empty\");\n}\n\n// focus search input on large screens\nif (!(isMobile || isResultsPage)) {\n searchInput.focus();\n}\n\n// On mobile, move cursor to the end of the input on focus\nif (isMobile) {\n listen(\"focus\", searchInput, () => {\n // Defer cursor move until the next frame to prevent a visual jump\n requestAnimationFrame(() => {\n const end = searchInput.value.length;\n searchInput.setSelectionRange(end, end);\n searchInput.scrollLeft = searchInput.scrollWidth;\n });\n });\n}\n\nlisten(\"input\", searchInput, () => {\n searchReset.classList.toggle(\"empty\", searchInput.value.length === 0);\n});\n\nlisten(\"click\", searchReset, (event: MouseEvent) => {\n event.preventDefault();\n searchInput.value = \"\";\n searchInput.focus();\n searchReset.classList.add(\"empty\");\n});\n\nfor (const button of categoryButtons) {\n listen(\"click\", button, (event: MouseEvent) => {\n if (event.shiftKey) {\n event.preventDefault();\n button.classList.toggle(\"selected\");\n return;\n }\n\n // deselect all other categories\n for (const categoryButton of categoryButtons) {\n categoryButton.classList.toggle(\"selected\", categoryButton === button);\n }\n });\n}\n\nif (document.querySelector(\"div.search_filters\")) {\n const safesearchElement = document.getElementById(\"safesearch\");\n if (safesearchElement) {\n listen(\"change\", safesearchElement, () => searchForm.submit());\n }\n\n const timeRangeElement = document.getElementById(\"time_range\");\n if (timeRangeElement) {\n listen(\"change\", timeRangeElement, () => searchForm.submit());\n }\n\n const languageElement = document.getElementById(\"language\");\n if (languageElement) {\n listen(\"change\", languageElement, () => searchForm.submit());\n }\n}\n\n// override searchForm submit event\nlisten(\"submit\", searchForm, (event: Event) => {\n event.preventDefault();\n\n if (categoryButtons.length > 0) {\n const searchCategories = getElement(\"selected-categories\");\n searchCategories.value = categoryButtons\n .filter((button) => button.classList.contains(\"selected\"))\n .map((button) => button.name.replace(\"category_\", \"\"))\n .join(\",\");\n }\n\n searchForm.submit();\n});\n"],"mappings":"uEAKA,IAAM,EAA8B,EAA4B,SAAS,CACnE,EAAgC,EAA6B,IAAI,CACjE,EAAiC,EAA8B,eAAe,CAE9E,EAAoB,OAAO,WAAW,oBAAoB,CAAC,QAC3D,EAAyB,SAAS,cAAc,OAAO,EAAE,KAAO,eAEhE,EAAuC,MAAM,KACjD,SAAS,iBAAoC,wCAAwC,CACtF,CAEG,EAAY,MAAM,SAAW,GAC/B,EAAY,UAAU,IAAI,QAAQ,CAI9B,GAAY,GAChB,EAAY,OAAO,CAIjB,GACF,EAAO,QAAS,MAAmB,CAEjC,0BAA4B,CAC1B,IAAM,EAAM,EAAY,MAAM,OAC9B,EAAY,kBAAkB,EAAK,EAAI,CACvC,EAAY,WAAa,EAAY,aACrC,EACF,CAGJ,EAAO,QAAS,MAAmB,CACjC,EAAY,UAAU,OAAO,QAAS,EAAY,MAAM,SAAW,EAAE,EACrE,CAEF,EAAO,QAAS,EAAc,GAAsB,CAClD,EAAM,gBAAgB,CACtB,EAAY,MAAQ,GACpB,EAAY,OAAO,CACnB,EAAY,UAAU,IAAI,QAAQ,EAClC,CAEF,IAAK,IAAM,KAAU,EACnB,EAAO,QAAS,EAAS,GAAsB,CAC7C,GAAI,EAAM,SAAU,CAClB,EAAM,gBAAgB,CACtB,EAAO,UAAU,OAAO,WAAW,CACnC,OAIF,IAAK,IAAM,KAAkB,EAC3B,EAAe,UAAU,OAAO,WAAY,IAAmB,EAAO,EAExE,CAGJ,GAAI,SAAS,cAAc,qBAAqB,CAAE,CAChD,IAAM,EAAoB,SAAS,eAAe,aAAa,CAC3D,GACF,EAAO,SAAU,MAAyB,EAAW,QAAQ,CAAC,CAGhE,IAAM,EAAmB,SAAS,eAAe,aAAa,CAC1D,GACF,EAAO,SAAU,MAAwB,EAAW,QAAQ,CAAC,CAG/D,IAAM,EAAkB,SAAS,eAAe,WAAW,CACvD,GACF,EAAO,SAAU,MAAuB,EAAW,QAAQ,CAAC,CAKhE,EAAO,SAAU,EAAa,GAAiB,CAG7C,GAFA,EAAM,gBAAgB,CAElB,EAAgB,OAAS,EAAG,CAC9B,IAAM,EAAmB,EAA6B,sBAAsB,CAC5E,EAAiB,MAAQ,EACtB,OAAQ,GAAW,EAAO,UAAU,SAAS,WAAW,CAAC,CACzD,IAAK,GAAW,EAAO,KAAK,QAAQ,YAAa,GAAG,CAAC,CACrD,KAAK,IAAI,CAGd,EAAW,QAAQ,EACnB"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BSJ3HQQa.min.js b/searx/static/themes/simple/chunk/BSJ3HQQa.min.js deleted file mode 100644 index 28e4e53e8..000000000 --- a/searx/static/themes/simple/chunk/BSJ3HQQa.min.js +++ /dev/null @@ -1,15 +0,0 @@ -import{a as e}from"../sxng-core.min.js";import{t}from"./chlzpS6K.min.js";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;tthis.has(e)).values()}get(e){return p(this.wrappedObject,e)}set(e,t){return m(this.wrappedObject,e,t),this}has(e){return h(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return ee(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){h(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},S=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return ee(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function ee(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function te(){return new Map}function ne(e){if(!e)return te();if(P(e))return e;if(fe(e))return new x(e);throw Error(`createMap can create maps from objects or Maps`)}function C(e){return typeof e==`number`}function w(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function re(e){return typeof e==`bigint`}function T(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function E(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function D(e){return e&&e.constructor.prototype.isUnit===!0||!1}function O(e){return typeof e==`string`}var k=Array.isArray;function A(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function j(e){return Array.isArray(e)||A(e)}function ie(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function M(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function ae(e){return e&&e.constructor.prototype.isRange===!0||!1}function oe(e){return e&&e.constructor.prototype.isIndex===!0||!1}function N(e){return typeof e==`boolean`}function se(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function ce(e){return e&&e.constructor.prototype.isHelp===!0||!1}function le(e){return typeof e==`function`}function ue(e){return e instanceof Date}function de(e){return e instanceof RegExp}function fe(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!T(e)&&!E(e))}function P(e){return e?e instanceof Map||e instanceof x||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function pe(e){return P(e)&&P(e.a)&&P(e.b)}function me(e){return P(e)&&fe(e.wrappedObject)}function F(e){return e===null}function he(e){return e===void 0}function I(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function ge(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function _e(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ve(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function ye(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function L(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function be(e){return L(e)||we(e)&&e.args.length===1&&L(e.args[0])&&`-+~`.includes(e.op)}function xe(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Se(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function R(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function z(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ce(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function we(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Te(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ee(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function De(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function B(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Oe(e){return e&&e.constructor.prototype.isChain===!0||!1}function ke(e){var t=typeof e;return t===`object`?e===null?`null`:w(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function Ae(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return Ae(e)});if(e instanceof Date)return new Date(e.valueOf());if(w(e))return e;if(fe(e))return je(e,Ae);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function je(e,t){var n={};for(var r in e)V(e,r)&&(n[r]=t(e[r]));return n}function Me(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(V(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?Me(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function Ne(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function Ve(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}function U(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function He(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var Ue=Math.sign||function(e){return e>0?1:e<0?-1:0},We=Math.log2||function(e){return Math.log(e)/Math.LN2},Ge=Math.log10||function(e){return Math.log(e)/Math.LN10},Ke=Math.log1p||function(e){return Math.log(e+1)},qe=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},Je=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Ye(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!U(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!U(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function Xe(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=Ze(t);switch(n){case`fixed`:return et(e,r);case`exponential`:return tt(e,r);case`engineering`:return $e(e,r);case`bin`:return Ye(e,2,i);case`oct`:return Ye(e,8,i);case`hex`:return Ye(e,16,i);case`auto`:return nt(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function Ze(e){var t=`auto`,n,r;if(e!==void 0)if(C(e))n=e;else if(w(e))n=e.toNumber();else if(fe(e))e.precision!==void 0&&(n=ot(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=ot(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function Qe(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function $e(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=rt(Qe(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(C(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s0;)l++,c--;var u=i.slice(l).join(``),d=C(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function et(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Qe(e),r=typeof t==`number`?rt(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function nt(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=st(n?.lowerExp,-3),i=st(n?.upperExp,5),a=Qe(e),o=t?rt(a,t):a;if(o.exponent=i)return tt(e,t);var s=o.coefficients,c=o.exponent;s.length0?c:0;return lt&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function it(e){for(var t=[],n=0;n1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)throw Error(`Root must be non-zero`);if(e<0&&Math.abs(t)%2!=1)throw Error(`Root must be odd when a is negative.`);if(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.abs(e)**(1/t);return r=e<0?-r:r,n?1/r:r}function Ot(e){return Ue(e)}Ot.signature=W;function kt(e){return Math.sqrt(e)}kt.signature=W;function At(e){return e*e}At.signature=W;function jt(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!U(e)||!U(t))throw Error(`Parameters in function xgcd must be integer numbers`);for(;t;)r=Math.floor(e/t),i=e-r*t,n=a,a=o-r*a,o=n,n=s,s=c-r*s,c=n,e=t,t=i;return e<0?[-e,-o,-c]:[e,e?o:0,c]}jt.signature=ct;function Mt(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}Mt.signature=ct;function Nt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!U(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(et(e,t))}function Pt(e){return Math.abs(e)}Pt.signature=W;function Ft(e,t){if(t>1;return Ft(e,n)*Ft(n+1,t)}function It(e,t){if(!U(e)||e<0||!U(t)||t<0)throw TypeError(`Positive integer value expected in function combinations`);if(t>e)throw TypeError(`k must be less than or equal to n`);for(var n=e-t,r=1,i=t171?1/0:Ft(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*zt(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,a=i*e;return Math.sqrt(2*Math.PI/e)*(e/Math.E)**+e*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=Vt[0];for(var o=1;o=1;r--)n+=Ut[r]/(e+r);return Ht+(e+.5)*Math.log(t)-t+Math.log(n)}Wt.signature=`number`;function G(e,t,n,r){function i(r){var i=H(r,t.map(Jt));return Kt(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function Gt(e){return typeof e==`function`&&typeof e.fn==`string`&&Array.isArray(e.dependencies)}function Kt(e,t,n){if(!t.filter(e=>!qt(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function qt(e){return e&&e[0]===`?`}function Jt(e){return e&&e[0]===`?`?e.slice(1):e}function Yt(){throw Error(`No "bignumber" implementation available`)}function Xt(){throw Error(`No "fraction" implementation available`)}function Zt(){throw Error(`No "matrix" implementation available`)}function Qt(){throw Error(`No "matrix" implementation available`)}var $t=u(c(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=ne(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,i+=e.name+`|`,{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function ee(e){let t=ae(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function te(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function ne(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=w(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=w(e[0]),r=w(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(w),function(e){for(let n=0;n{let r=E(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function k(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s{let r=w(T(n.params,s));(s0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return C(e.params)?1/0:e.params.length});if(t.lengthl)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e0)return .001;let r=j(e),i=j(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function M(e,t){let n=e.params,r=t.params,i=F(n),a=F(r),o=C(n),s=C(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;ee.hasConversion)){let i=C(e),a=e.map(N);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;te.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return ge(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function ce(e,t){let n=Math.max(e.length,t.length);for(let r=0;r=r:o?r>=i:r===i}function le(e){return e.map(e=>be(e)?ye(e.referToSelf.callback):L(e)?ve(e.referTo.references,e.referTo.callback):e)}function ue(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function de(e,t,n){let r=le(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function P(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&fe(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=ne(c);if(!e)continue;i.forEach(function(t){if(ce(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(ee),l;for(l of se(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(M);let l=de(a,o,z),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!C(f[0].params),h=f[1]&&f[1].params.length<=2&&!C(f[1].params),g=f[2]&&f[2].params.length<=2&&!C(f[2].params),_=f[3]&&f[3].params.length<=2&&!C(f[3].params),v=f[4]&&f[4].params.length<=2&&!C(f[4].params),y=f[5]&&f[5].params.length<=2&&!C(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;ee.test),Se=f.map(e=>e.implementation),R=function(){for(let e=L;ex(ne(e))),t=F(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return ve(e,t)}function ve(e,t){return{referTo:{references:e,callback:t}}}function ye(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function L(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function be(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function xe(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function Se(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=xe(t,e[n].name));return t}function R(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let z=d;d=function(e){let t=typeof e==`string`,n=t?1:0,r=t?e:``,i={};for(let e=n;e1&&arguments[1]!==void 0?arguments[1]:{override:!1};Ce(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){Ce(e);let t=f(e.to),n=I(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;eO&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971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u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD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F90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\u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-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:O},{name:`Chain`,test:Oe},{name:`Array`,test:k},{name:`Matrix`,test:A},{name:`DenseMatrix`,test:ie},{name:`SparseMatrix`,test:M},{name:`Range`,test:ae},{name:`Index`,test:oe},{name:`boolean`,test:N},{name:`ResultSet`,test:se},{name:`Help`,test:ce},{name:`function`,test:le},{name:`Date`,test:ue},{name:`RegExp`,test:de},{name:`null`,test:F},{name:`undefined`,test:he},{name:`AccessorNode`,test:I},{name:`ArrayNode`,test:ge},{name:`AssignmentNode`,test:_e},{name:`BlockNode`,test:ve},{name:`ConditionalNode`,test:ye},{name:`ConstantNode`,test:L},{name:`FunctionNode`,test:Se},{name:`FunctionAssignmentNode`,test:xe},{name:`IndexNode`,test:R},{name:`Node`,test:z},{name:`ObjectNode`,test:Ce},{name:`OperatorNode`,test:we},{name:`ParenthesisNode`,test:Te},{name:`RangeNode`,test:Ee},{name:`RelationalNode`,test:De},{name:`SymbolNode`,test:B},{name:`Map`,test:P},{name:`Object`,test:fe}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||nn(e),at(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||rn(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||rn(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw TypeError(`Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: `+e+`)`);return Number(e)}},{from:`bigint`,to:`BigNumber`,convert:function(e){return t||nn(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||on(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw TypeError(`Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.`)}},{from:`Fraction`,to:`Complex`,convert:function(e){return n||rn(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||on(e);var t=new i(e);if(t.valueOf()!==e)throw TypeError(`Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: `+e+`). Use function fraction(x) to convert to Fraction.`);return t}},{from:`string`,to:`number`,convert:function(e){var t=Number(e);if(isNaN(t))throw Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||nn(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||on(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||rn(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||nn(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||on(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||an(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&j(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&j(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function nn(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function rn(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function an(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function on(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var sn=G(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0});function cn(e,t,n){var r=e.constructor,i=new r(2),a=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!U(n))throw Error(`size must be an integer`);if(e.greaterThan(i.pow(n-1).sub(1))||e.lessThan(i.pow(n-1).mul(-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!e.isInteger())throw Error(`Value must be an integer`);e.lessThan(0)&&(e=e.add(i.pow(n))),a=`i${n}`}switch(t){case 2:return`${e.toBinary()}${a}`;case 8:return`${e.toOctal()}${a}`;case 16:return`${e.toHexadecimal()}${a}`;default:throw Error(`Base ${t} not supported `)}}function ln(e,t){if(typeof t==`function`)return t(e);if(!e.isFinite())return e.isNaN()?`NaN`:e.gt(0)?`Infinity`:`-Infinity`;var{notation:n,precision:r,wordSize:i}=Ze(t);switch(n){case`fixed`:return fn(e,r);case`exponential`:return dn(e,r);case`engineering`:return un(e,r);case`bin`:return cn(e,2,i);case`oct`:return cn(e,8,i);case`hex`:return cn(e,16,i);case`auto`:var a=pn(t?.lowerExp,-3),o=pn(t?.upperExp,5);if(e.isZero())return`0`;var s,c=e.toSignificantDigits(r),l=c.e;return s=l>=a&&l=0?`+`:``)+r.toString()}function dn(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function fn(e,t){return e.toFixed(t)}function pn(e,t){return C(e)?e:w(e)?e.toNumber():t}function mn(e,t){var n=hn(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function hn(e,t){return typeof e==`number`?Xe(e,t):w(e)?ln(e,t):yn(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?vn(e,t):O(e)?gn(e):typeof e==`function`?e.syntax?String(e.syntax):`function`:e&&typeof e==`object`?typeof e.format==`function`?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):`{`+Object.keys(e).map(n=>gn(n)+`: `+mn(e[n],t)).join(`, `)+`}`:String(e)}function gn(e){for(var t=String(e),n=``,r=0;r/g,`>`),t}function vn(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;i`,associativity:`left`,associativeWith:[]},"OperatorNode:smallerEq":{op:`<=`,associativity:`left`,associativeWith:[]},"OperatorNode:largerEq":{op:`>=`,associativity:`left`,associativeWith:[]},RelationalNode:{associativity:`left`,associativeWith:[]}},{"OperatorNode:leftShift":{op:`<<`,associativity:`left`,associativeWith:[]},"OperatorNode:rightArithShift":{op:`>>`,associativity:`left`,associativeWith:[]},"OperatorNode:rightLogShift":{op:`>>>`,associativity:`left`,associativeWith:[]}},{"OperatorNode:to":{op:`to`,associativity:`left`,associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:`+`,associativity:`left`,associativeWith:[`OperatorNode:add`,`OperatorNode:subtract`]},"OperatorNode:subtract":{op:`-`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{op:`*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]},"OperatorNode:divide":{op:`/`,associativity:`left`,associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:`.*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`OperatorNode:dotMultiply`,`OperatorNode:doDivide`]},"OperatorNode:dotDivide":{op:`./`,associativity:`left`,associativeWith:[]},"OperatorNode:mod":{op:`mod`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]}},{"OperatorNode:unaryPlus":{op:`+`,associativity:`right`},"OperatorNode:unaryMinus":{op:`-`,associativity:`right`},"OperatorNode:bitNot":{op:`~`,associativity:`right`},"OperatorNode:not":{op:`not`,associativity:`right`}},{"OperatorNode:pow":{op:`^`,associativity:`right`,associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:`.^`,associativity:`right`,associativeWith:[]}},{"OperatorNode:nullish":{op:`??`,associativity:`left`,associativeWith:[]}},{"OperatorNode:factorial":{op:`!`,associativity:`left`}},{"OperatorNode:ctranspose":{op:`'`,associativity:`left`}}];function Cn(e,t){if(!t||t!==`auto`)return e;for(var n=e;Te(n);)n=n.content;return n}function Y(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s=this.max?this.message=`Index out of range (`+this.index+` > `+(this.max-1)+`)`:this.message=`Index out of range (`+this.index+`)`,this.stack=Error().stack}En.prototype=RangeError(),En.prototype.constructor=RangeError,En.prototype.name=`IndexError`,En.prototype.isIndexError=!0;function Dn(e,t,n){if(!(this instanceof Dn))throw SyntaxError(`Constructor must be called with the new operator`);this.actual=e,this.expected=t,this.relation=n,this.message=`Dimension mismatch (`+(Array.isArray(e)?`[`+e.join(`, `)+`]`:e)+` `+(this.relation||`!=`)+` `+(Array.isArray(t)?`[`+t.join(`, `)+`]`:t)+`)`,this.stack=Error().stack}Dn.prototype=RangeError(),Dn.prototype.constructor=RangeError,Dn.prototype.name=`DimensionError`,Dn.prototype.isDimensionError=!0;function On(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function kn(e,t){return Array.prototype.map.call(e,t)}function An(e,t){Array.prototype.forEach.call(e,t)}function jn(e,t){return Array.prototype.join.call(e,t)}function Mn(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(n)return a(e);var r=[];return i(e,0);function i(n,a){if(Array.isArray(n)){for(var o=n.length,s=Array(o),c=0;ct(e),!1,!0):Mn(e,t,!0);var r=e=>e===0?e:t(e);return A(e)?e.map(e=>r(e),!1,!0):Mn(e,r,!0)}function Pn(e){var t=0,n=1,r=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete r[o],delete i[e],--t,n===o)){if(!t){a=0,n=1;return}for(;!Object.prototype.hasOwnProperty.call(r,++n););}};return e=Math.abs(e),{hit:function(s){var c=i[s],l=++a;if(r[l]=s,i[s]=l,!c)return++t,t<=e?void 0:(s=r[n],o(s),s);if(delete r[c],n===c)for(;!Object.prototype.hasOwnProperty.call(r,++n););},delete:o,clear:function(){t=a=0,n=1,r=Object.create(null),i=Object.create(null)}}}function Fn(e){var{hasher:t,limit:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n??=1/0,t??=JSON.stringify,function r(){typeof r.cache!=`object`&&(r.cache={values:new Map,lru:Pn(n||1/0)});var i=[...arguments],a=t(i);if(r.cache.values.has(a))return r.cache.lru.hit(a),r.cache.values.get(a);var o=e.apply(e,i);return r.cache.values.set(a,o),r.cache.values.delete(r.cache.lru.hit(a)),o}}var In=Fn(function(e){return new e(1).exp()},{hasher:Rn});Fn(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:Rn});var Ln=Fn(function(e){return e.acos(-1)},{hasher:Rn});Fn(function(e){return Ln(e).times(2)},{hasher:Rn});function Rn(e){return e[0].precision}var zn=Vn(`pi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Ln(n):Lt}),Bn=Vn(`e`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?In(n):Rt});function Vn(e,t,n){return G(e,t,n,{recreateOnConfigChange:!0})}var Hn=`number`,Un=[`typed`];function Wn(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}function Gn(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r{var{typed:t}=e,n=t(`number`,{"":function(){return 0},number:function(e){return e},string:function(e){if(e===`NaN`)return NaN;var t=Wn(e);if(t)return Gn(t);var n=0,r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);r&&(n=Number(r[2]),e=r[1]);var i=Number(e);if(isNaN(i))throw SyntaxError(`String "`+e+`" is not a valid number`);if(r){if(i>2**n-1)throw SyntaxError(`String "${e}" is out of range`);i>=2**(n-1)&&(i-=2**n)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(e=>t=>Nn(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),qn=new Set([`end`]),Jn=G(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...qn])if(e.has(t))throw Error(`Scope contains an illegal symbol, "`+t+`" is a reserved keyword`)}class r{get type(){return`Node`}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={},i=null;function a(t){var a=ne(t);return n(a),e(a,r,i)}return{evaluate:a}}_compile(e,t){throw Error(`Method _compile must be implemented by type `+this.type)}forEach(e){throw Error(`Cannot run forEach on a Node interface`)}map(e){throw Error(`Cannot run map on a Node interface`)}_ifNode(e){if(!z(e))throw TypeError(`Callback function must return a Node`);return e}traverse(e){e(this,null,null);function t(e,n){e.forEach(function(e,r,i){n(e,r,i),t(e,n)})}t(this,e)}transform(e){function t(n,r,i){var a=e(n,r,i);return a===n?n.map(t):a}return t(this,null,null)}filter(e){var t=[];return this.traverse(function(n,r,i){e(n,r,i)&&t.push(n)}),t}clone(){throw Error(`Cannot clone a Node interface`)}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return e?this.type===e.type&&Ne(this,e):!1}toString(e){var t=this._getCustomString(e);return t===void 0?this._toString(e):t}_toString(){throw Error(`_toString not implemented for `+this.type)}toJSON(){throw Error(`Cannot serialize object: toJSON not implemented by `+this.type)}toHTML(e){var t=this._getCustomString(e);return t===void 0?this._toHTML(e):t}_toHTML(){throw Error(`_toHTML not implemented for `+this.type)}toTex(e){var t=this._getCustomString(e);return t===void 0?this._toTex(e):t}_toTex(e){throw Error(`_toTex not implemented for `+this.type)}_getCustomString(e){if(e&&typeof e==`object`)switch(typeof e.handler){case`object`:case`undefined`:return;case`function`:return e.handler(this,e);default:throw TypeError(`Object or function expected as callback`)}}getIdentifier(){return this.type}getContent(){return this}}return r},{isClass:!0,isNode:!0});function Yn(e){return e&&e.isIndexError?new En(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function Xn(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&typeof e.subset==`function`)return e.subset(n);if(typeof e==`string`)return t(e,n);if(typeof e==`object`){if(!n.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return p(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Yn(e)}}}var Zn=`AccessorNode`,Qn=G(Zn,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=Xn({subset:t});function i(e){return!(I(e)||ge(e)||L(e)||Se(e)||Ce(e)||Te(e)||B(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!z(e))throw TypeError(`Node expected for parameter "object"`);if(!R(t))throw TypeError(`IndexNode expected for parameter "index"`);this.object=e,this.index=t,this.optionalChaining=n}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return Zn}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=I(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,t,r){var i=r||{},c=n(e,t,i);if(a&&c==null){i.optionalShortCircuit=!0;return}if(!(o&&i!=null&&i.optionalShortCircuit))return p(c,s)}}else return function(e,t,s){var c=s||{},l=n(e,t,c);if(a&&l==null){c.optionalShortCircuit=!0;return}if(!(o&&c!=null&&c.optionalShortCircuit))return r(l,i(e,t,l))}}forEach(e){e(this.object,`object`,this),e(this.index,`index`,this)}map(e){return new a(this._ifNode(e(this.object,`object`,this)),this._ifNode(e(this.index,`index`,this)),this.optionalChaining)}clone(){return new a(this.object,this.index,this.optionalChaining)}_toString(e){var t=this.object.toString(e);i(this.object)&&(t=`(`+t+`)`);var n=this.optionalChaining?this.index.dotNotation?`?`:`?.`:``;return t+n+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t=`(`+t+`)`),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t=`\\left(' + object + '\\right)`),t+this.index.toTex(e)}toJSON(){return{mathjs:Zn,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return q(a,`name`,Zn),a},{isClass:!0,isNode:!0}),$n=`ArrayNode`,er=G($n,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(z))throw TypeError(`Array containing Nodes expected`)}get type(){return $n}get isArrayNode(){return!0}_compile(e,t){var n=kn(this.items,function(n){return n._compile(e,t)});if(e.config.matrix!==`Array`){var r=e.matrix;return function(e,t,i){return r(kn(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return kn(n,function(n){return n(e,t,r)})}}forEach(e){for(var t=0;t[`+this.items.map(function(t){return t.toHTML(e)}).join(`,`)+`]`}_toTex(e){function t(n,r){var i=n.some(ge)&&!n.every(ge),a=r||i,o=a?`&`:`\\\\`,s=n.map(function(n){return n.items?t(n.items,!r):n.toTex(e)}).join(o);return i||!a||a&&!r?`\\begin{bmatrix}`+s+`\\end{bmatrix}`:s}return t(this.items,!1)}}return q(n,`name`,$n),n},{isClass:!0,isNode:!0});function tr(e){var{subset:t,matrix:n}=e;return function(e,r,i){try{if(Array.isArray(e))return n(e).subset(r,i).valueOf().forEach((t,n)=>{e[n]=t}),e;if(e&&typeof e.subset==`function`)return e.subset(r,i);if(typeof e==`string`)return t(e,r,i);if(typeof e==`object`){if(!r.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return m(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Yn(e)}}}var nr=`AssignmentNode`,rr=G(nr,[`subset`,`?matrix`,`Node`],e=>{var{subset:t,matrix:n,Node:r}=e,i=Xn({subset:t}),a=tr({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=Y(e,t,n),i=Y(e.value,t,n);return t===`all`||i!==null&&i<=r}class s extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!B(e)&&!I(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(B(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!R(this.index))throw TypeError(`IndexNode expected as "index"`);if(!z(this.value))throw TypeError(`Node expected as "value"`)}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return nr}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(!this.index){if(!B(this.object))throw TypeError(`SymbolNode expected as object`);return function(e,t,n){var r=o(e,t,n);return e.set(s,r),r}}else if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(e,t,r){var i=n(e,t,r),a=o(e,t,r);return m(i,c,a),a}}else if(B(this.object))return function(e,t,i){var c=n(e,t,i),l=o(e,t,i),u=r(e,t,c);return e.set(s,a(c,u,l)),l};else{var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var u=this.object.index.getObjectProperty();return function(e,t,n){var i=l(e,t,n),s=p(i,u),c=r(e,t,s),d=o(e,t,n);return m(i,u,a(s,c,d)),d}}else{var d=this.object.index._compile(e,t);return function(e,t,n){var s=l(e,t,n),c=d(e,t,s),u=i(s,c),f=r(e,t,u),p=o(e,t,n);return a(s,c,a(u,f,p)),p}}}}forEach(e){e(this.object,`object`,this),this.index&&e(this.index,`index`,this),e(this.value,`value`,this)}map(e){return new s(this._ifNode(e(this.object,`object`,this)),this.index?this._ifNode(e(this.index,`index`,this)):null,this._ifNode(e(this.value,`value`,this)))}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):``,r=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+` = `+r}toJSON(){return{mathjs:nr,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):``,r=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+`=`+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):``,r=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`\\left(${r}\\right)`),t+n+`=`+r}}return q(s,`name`,nr),s},{isClass:!0,isNode:!0}),ir=`BlockNode`,ar=G(ir,[`ResultSet`,`Node`],e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw Error(`Array expected`);this.blocks=e.map(function(e){var t=e&&e.node,n=e&&e.visible!==void 0?e.visible:!0;if(!z(t))throw TypeError(`Property "node" must be a Node`);if(typeof n!=`boolean`)throw TypeError(`Property "visible" must be a boolean`);return{node:t,visible:n}})}get type(){return ir}get isBlockNode(){return!0}_compile(e,n){var r=kn(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return An(r,function(t){var r=t.evaluate(e,n,i);t.visible&&a.push(r)}),new t(a)}}forEach(e){for(var t=0;t;`)}).join(`
`)}_toTex(e){return this.blocks.map(function(t){return t.node.toTex(e)+(t.visible?``:`;`)}).join(`\\;\\; -`)}}return q(r,`name`,ir),r},{isClass:!0,isNode:!0}),or=`ConditionalNode`,sr=G(or,[`Node`],e=>{var{Node:t}=e;function n(e){if(typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return!!e;if(e){if(w(e))return!e.isZero();if(T(e))return!!(e.re||e.im);if(D(e))return!!e.value}if(e==null)return!1;throw TypeError(`Unsupported type of condition "`+ke(e)+`"`)}class r extends t{constructor(e,t,n){if(super(),!z(e))throw TypeError(`Parameter condition must be a Node`);if(!z(t))throw TypeError(`Parameter trueExpr must be a Node`);if(!z(n))throw TypeError(`Parameter falseExpr must be a Node`);this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return or}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,o){return n(r(e,t,o))?i(e,t,o):a(e,t,o)}}forEach(e){e(this.condition,`condition`,this),e(this.trueExpr,`trueExpr`,this),e(this.falseExpr,`falseExpr`,this)}map(e){return new r(this._ifNode(e(this.condition,`condition`,this)),this._ifNode(e(this.trueExpr,`trueExpr`,this)),this._ifNode(e(this.falseExpr,`falseExpr`,this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.condition.toString(e),i=Y(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toString(e),o=Y(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toString(e),c=Y(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+` ? `+a+` : `+s}toJSON(){return{mathjs:or,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.condition.toHTML(e),i=Y(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toHTML(e),o=Y(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toHTML(e),c=Y(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+`?`+a+`:`+s}_toTex(e){return`\\begin{cases} {`+this.trueExpr.toTex(e)+`}, &\\quad{\\text{if }\\;`+this.condition.toTex(e)+`}\\\\{`+this.falseExpr.toTex(e)+`}, &\\quad{\\text{otherwise}}\\end{cases}`}}return q(r,`name`,or),r},{isClass:!0,isNode:!0}),cr=u(c(((e,t)=>{var n=Object.assign||function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{},o=t.preserveFormatting,s=o===void 0?!1:o,c=t.escapeMapFn,l=c===void 0?a:c,u=String(e),d=``,f=l(n({},r),s?n({},i):{}),p=Object.keys(f),m=function(){var e=!1;p.forEach(function(t,n){e||u.length>=t.length&&u.slice(0,t.length)===t&&(d+=f[p[n]],u=u.slice(t.length,u.length),e=!0)}),e||(d+=u.slice(0,1),u=u.slice(1,u.length))};u;)m();return d}}))(),1),lr={Alpha:`A`,alpha:`\\alpha`,Beta:`B`,beta:`\\beta`,Gamma:`\\Gamma`,gamma:`\\gamma`,Delta:`\\Delta`,delta:`\\delta`,Epsilon:`E`,epsilon:`\\epsilon`,varepsilon:`\\varepsilon`,Zeta:`Z`,zeta:`\\zeta`,Eta:`H`,eta:`\\eta`,Theta:`\\Theta`,theta:`\\theta`,vartheta:`\\vartheta`,Iota:`I`,iota:`\\iota`,Kappa:`K`,kappa:`\\kappa`,varkappa:`\\varkappa`,Lambda:`\\Lambda`,lambda:`\\lambda`,Mu:`M`,mu:`\\mu`,Nu:`N`,nu:`\\nu`,Xi:`\\Xi`,xi:`\\xi`,Omicron:`O`,omicron:`o`,Pi:`\\Pi`,pi:`\\pi`,varpi:`\\varpi`,Rho:`P`,rho:`\\rho`,varrho:`\\varrho`,Sigma:`\\Sigma`,sigma:`\\sigma`,varsigma:`\\varsigma`,Tau:`T`,tau:`\\tau`,Upsilon:`\\Upsilon`,upsilon:`\\upsilon`,Phi:`\\Phi`,phi:`\\phi`,varphi:`\\varphi`,Chi:`X`,chi:`\\chi`,Psi:`\\Psi`,psi:`\\psi`,Omega:`\\Omega`,omega:`\\omega`,true:`\\mathrm{True}`,false:`\\mathrm{False}`,i:`i`,inf:`\\infty`,Inf:`\\infty`,infinity:`\\infty`,Infinity:`\\infty`,oo:`\\infty`,lim:`\\lim`,undefined:`\\mathbf{?}`},X={transpose:`^\\top`,ctranspose:`^H`,factorial:`!`,pow:`^`,dotPow:`.^\\wedge`,unaryPlus:`+`,unaryMinus:`-`,bitNot:`\\~`,not:`\\neg`,multiply:`\\cdot`,divide:`\\frac`,dotMultiply:`.\\cdot`,dotDivide:`.:`,mod:`\\mod`,add:`+`,subtract:`-`,to:`\\rightarrow`,leftShift:`<<`,rightArithShift:`>>`,rightLogShift:`>>>`,equal:`=`,unequal:`\\neq`,smaller:`<`,larger:`>`,smallerEq:`\\leq`,largerEq:`\\geq`,bitAnd:`\\&`,bitXor:`\\underline{|}`,bitOr:`|`,and:`\\wedge`,xor:`\\veebar`,or:`\\vee`},ur={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${X.add}\${args[1]}\\right)`},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:`\\left(\${args[0]}${X.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${X.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${X.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${X.pow}{\${args[0]}}-1\\right)`,fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:`\\left(\${args[0]}${X.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${X.multiply}\${args[1]}\\right)`},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : y^${args[1]} = {${args[0]}}\\}"},pow:{2:`\\left(\${args[0]}\\right)${X.pow}{\${args[1]}}`},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:`\\left(\${args[0]}${X.subtract}\${args[1]}\\right)`},unaryMinus:{1:`${X.unaryMinus}\\left(\${args[0]}\\right)`},unaryPlus:{1:`${X.unaryPlus}\\left(\${args[0]}\\right)`},bitAnd:{2:`\\left(\${args[0]}${X.bitAnd}\${args[1]}\\right)`},bitNot:{1:X.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${X.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${X.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${X.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${X.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${X.rightLogShift}\${args[1]}\\right)`},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:`\\left(\${args[0]}${X.and}\${args[1]}\\right)`},not:{1:X.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${X.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${X.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:`\\left(\${args[0]}\\right)${X.ctranspose}`},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:`{\${args[0]}}${X.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:`\\left(\${args[0]}\\right)${X.transpose}`},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:`\\left(\${args[0]}\\right)${X.factorial}`},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${X.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${X.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${X.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${X.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${X.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${X.unequal}\${args[1]}\\right)`},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:`\\left(\${args[0]}${X.to}\${args[1]}\\right)`},numeric:function(e,t){return e.args[0].toTex()},number:{0:`0`,1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:`\\mathtt{""}`,1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:`0`,1:"\\left(${args[0]}\\right)"},bigint:{0:`0`,1:"\\left(${args[0]}\\right)"},complex:{0:`0`,1:"\\left(${args[0]}\\right)",2:`\\left(\\left(\${args[0]}\\right)+${lr.i}\\cdot\\left(\${args[1]}\\right)\\right)`},matrix:{0:`\\begin{bmatrix}\\end{bmatrix}`,1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:`\\begin{bsparse}\\end{bsparse}`,1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},dr="\\mathrm{${name}}\\left(${args}\\right)",fr={deg:`^\\circ`};function pr(e){return(0,cr.default)(e,{preserveFormatting:!0})}function mr(e,t){return t=t===void 0?!1:t,t?V(fr,e)?fr[e]:`\\mathrm{`+pr(e)+`}`:V(lr,e)?lr[e]:pr(e)}var hr=`ConstantNode`,gr=G(hr,[`Node`,`isBounded`],e=>{var{Node:t,isBounded:n}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return hr}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return mn(this.value,e)}_toHTML(e){var t=this._toString(e);switch(ke(this.value)){case`number`:case`bigint`:case`BigNumber`:case`Fraction`:return``+t+``;case`string`:return``+t+``;case`boolean`:return``+t+``;case`null`:return``+t+``;case`undefined`:return``+t+``;default:return``+t+``}}toJSON(){return{mathjs:hr,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e);switch(ke(this.value)){case`string`:return`\\mathtt{`+pr(t)+`}`;case`number`:case`BigNumber`:if(!n(this.value))return this.value.valueOf()<0?`-\\infty`:`\\infty`;var r=t.toLowerCase().indexOf(`e`);return r===-1?t:t.substring(0,r)+`\\cdot10^{`+t.substring(r+1)+`}`;case`bigint`:return t.toString();case`Fraction`:return this.value.toLatex();default:return t}}}return q(r,`name`,hr),r},{isClass:!0,isNode:!0}),_r=`FunctionAssignmentNode`,vr=G(_r,[`typed`,`Node`],e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=Y(e,t,n),i=Y(e.expr,t,n);return t===`all`||i!==null&&i<=r}class i extends n{constructor(e,t,n){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);if(!Array.isArray(t))throw TypeError(`Array containing strings or objects expected for parameter "params"`);if(!z(n))throw TypeError(`Node expected for parameter "expr"`);if(qn.has(e))throw Error(`Illegal function name, "`+e+`" is a reserved keyword`);var r=new Set;for(var i of t){var a=typeof i==`string`?i:i.name;if(r.has(a))throw Error(`Duplicate parameter name "${a}"`);r.add(a)}this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||`any`}),this.expr=n}get type(){return _r}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);An(this.params,function(e){r[e]=!0});var i=this.expr,a=i._compile(e,r),o=this.name,s=this.params,c=jn(this.types,`,`),l=o+`(`+jn(this.params,`, `)+`)`;return function(e,n,r){var u={};u[c]=function(){for(var t=Object.create(n),i=0;i`+K(this.params[i])+``);var a=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(a=`(`+a+`)`),``+K(this.name)+`(`+n.join(`,`)+`)=`+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n=`\\left(${n}\\right)`),`\\mathrm{`+this.name+`}\\left(`+this.params.map(mr).join(`,`)+`\\right)=`+n}}return q(i,`name`,_r),i},{isClass:!0,isNode:!0}),yr=`IndexNode`,br=G(yr,[`Node`,`size`],e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(z))throw TypeError(`Array containing Nodes expected for parameter "dimensions"`);if(this.dotNotation&&!this.isObjectProperty())throw Error(`dotNotation only applicable for object properties`)}get type(){return yr}get isIndexNode(){return!0}_compile(e,t){var r=kn(this.dimensions,function(r,i){if(r.filter(e=>e.isSymbolNode&&e.name===`end`).length>0){var a=Object.create(t);a.end=!0;var o=r._compile(e,a);return function(e,t,r){if(!A(r)&&!k(r)&&!O(r))throw TypeError(`Cannot resolve "end": context must be a Matrix, Array, or string but is `+ke(r));var a=n(r),s=Object.create(t);return s.end=a[i],o(e,s,r)}}else return r._compile(e,t)}),i=p(e,`index`);return function(e,t,n){return i(...kn(r,function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t.`+K(this.getObjectProperty())+``:`[`+t.join(`,`)+`]`}_toTex(e){var t=this.dimensions.map(function(t){return t.toTex(e)});return this.dotNotation?`.`+this.getObjectProperty():`_{`+t.join(`,`)+`}`}}return q(r,`name`,yr),r},{isClass:!0,isNode:!0}),xr=`ObjectNode`,Sr=G(xr,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&(typeof e!=`object`||!Object.keys(e).every(function(t){return z(e[t])})))throw TypeError(`Object containing Nodes expected`)}get type(){return xr}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(V(this.properties,r)){var i=gn(r),a=JSON.parse(i);n[a]=p(this.properties,r)._compile(e,t)}return function(e,t,r){var i={};for(var a in n)V(n,a)&&(i[a]=n[a](e,t,r));return i}}forEach(e){for(var t in this.properties)V(this.properties,t)&&e(this.properties[t],`properties[`+gn(t)+`]`,this)}map(e){var t={};for(var r in this.properties)V(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],`properties[`+gn(r)+`]`,this)));return new n(t)}clone(){var e={};for(var t in this.properties)V(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)V(this.properties,n)&&t.push(gn(n)+`: `+this.properties[n].toString(e));return`{`+t.join(`, `)+`}`}toJSON(){return{mathjs:xr,properties:this.properties}}static fromJSON(e){return new n(e.properties)}_toHTML(e){var t=[];for(var n in this.properties)V(this.properties,n)&&t.push(``+K(n)+`:`+this.properties[n].toHTML(e));return`{`+t.join(`,`)+`}`}_toTex(e){var t=[];for(var n in this.properties)V(this.properties,n)&&t.push(`\\mathbf{`+n+`:} & `+this.properties[n].toTex(e)+`\\\\`);return`\\left\\{\\begin{array}{ll}`+t.join(` -`)+`\\end{array}\\right\\}`}}return q(n,`name`,xr),n},{isClass:!0,isNode:!0});function Cr(e,t){return new S(e,new x(t),new Set(Object.keys(t)))}var wr=`OperatorNode`,Tr=G(wr,[`Node`],e=>{var{Node:t}=e;function n(e,t){var r=e;if(t===`auto`)for(;Te(r);)r=r.content;return L(r)?!0:we(r)?n(r.args[0],t):!1}function r(e,t,r,i,a){var o=Y(e,t,r),s=wn(e,t);if(t===`all`||i.length>2&&e.getIdentifier()!==`OperatorNode:add`&&e.getIdentifier()!==`OperatorNode:multiply`)return i.map(function(e){switch(e.getContent().type){case`ArrayNode`:case`ConstantNode`:case`SymbolNode`:case`ParenthesisNode`:return!1;default:return!0}});var c;switch(i.length){case 0:c=[];break;case 1:var l=Y(i[0],t,r,e);if(a&&l!==null){var u,d;if(t===`keep`?(u=i[0].getIdentifier(),d=e.getIdentifier()):(u=i[0].getContent().getIdentifier(),d=e.getContent().getIdentifier()),J[o][d].latexLeftParens===!1){c=[!1];break}if(J[l][u].latexParens===!1){c=[!1];break}}if(l===null){c=[!1];break}if(l<=o){c=[!0];break}c=[!1];break;case 2:var f,p=Y(i[0],t,r,e),m=Tn(e,i[0],t);f=p===null?!1:p===o&&s===`right`&&!m?!0:p=2&&e.getIdentifier()===`OperatorNode:multiply`&&e.implicit&&t!==`all`&&r===`hide`)for(var x=1;x2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var d=i.map(function(t,n){return t=t.toString(e),a[n]&&(t=`(`+t+`)`),t});return this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?d.join(` `):d.join(` `+this.op+` `)}else return this.fn+`(`+this.args.join(`, `)+`)`}toJSON(){return{mathjs:wr,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=wn(this,t),s=i[0].toHTML(e);return a[0]&&(s=`(`+s+`)`),o===`right`?``+K(this.op)+``+s:s+``+K(this.op)+``}else if(i.length===2){var c=i[0].toHTML(e),l=i[1].toHTML(e);return a[0]&&(c=`(`+c+`)`),a[1]&&(l=`(`+l+`)`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?c+``+l:c+``+K(this.op)+``+l}else{var u=i.map(function(t,n){return t=t.toHTML(e),a[n]&&(t=`(`+t+`)`),t});return i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)?this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?u.join(``):u.join(``+K(this.op)+``):``+K(this.fn)+`(`+u.join(`,`)+`)`}}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!0),o=X[this.fn];if(o=o===void 0?this.op:o,i.length===1){var s=wn(this,t),c=i[0].toTex(e);return a[0]&&(c=`\\left(${c}\\right)`),s===`right`?o+c:c+o}else if(i.length===2){var l=i[0],u=l.toTex(e);a[0]&&(u=`\\left(${u}\\right)`);var d=i[1].toTex(e);a[1]&&(d=`\\left(${d}\\right)`);var f=t===`keep`?l.getIdentifier():l.getContent().getIdentifier();switch(this.getIdentifier()){case`OperatorNode:divide`:return o+`{`+u+`}{`+d+`}`;case`OperatorNode:pow`:switch(u=`{`+u+`}`,d=`{`+d+`}`,f){case`ConditionalNode`:case`OperatorNode:divide`:u=`\\left(${u}\\right)`}break;case`OperatorNode:multiply`:if(this.implicit&&n===`hide`)return u+`~`+d}return u+o+d}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var p=i.map(function(t,n){return t=t.toTex(e),a[n]&&(t=`\\left(${t}\\right)`),t});return this.getIdentifier()===`OperatorNode:multiply`&&this.implicit&&n===`hide`?p.join(`~`):p.join(o)}else return`\\mathrm{`+this.fn+`}\\left(`+i.map(function(t){return t.toTex(e)}).join(`,`)+`\\right)`}getIdentifier(){return this.type+`:`+this.fn}}return q(i,`name`,wr),i},{isClass:!0,isNode:!0}),Er=`ParenthesisNode`,Dr=G(Er,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!z(e))throw TypeError(`Node expected for parameter "content"`);this.content=e}get type(){return Er}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,`content`,this)}map(e){return new n(e(this.content,`content`,this))}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toString(e)+`)`:this.content.toString(e)}toJSON(){return{mathjs:Er,content:this.content}}static fromJSON(e){return new n(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toHTML(e)+`)`:this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return q(n,`name`,Er),n},{isClass:!0,isNode:!0}),Or=`RangeNode`,kr=G(Or,[`Node`],e=>{var{Node:t}=e;function n(e,t,n){var r=Y(e,t,n),i={},a=Y(e.start,t,n);if(i.start=a!==null&&a<=r||t===`all`,e.step){var o=Y(e.step,t,n);i.step=o!==null&&o<=r||t===`all`}var s=Y(e.end,t,n);return i.end=s!==null&&s<=r||t===`all`,i}class r extends t{constructor(e,t,n){if(super(),!z(e)||!z(t)||n&&!z(n))throw TypeError(`Node expected`);if(arguments.length>3)throw Error(`Too many arguments`);this.start=e,this.end=t,this.step=n||null}get type(){return Or}get isRangeNode(){return!0}needsEnd(){return this.filter(function(e){return B(e)&&e.name===`end`}).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return n(r(e,t,o),i(e,t,o),a(e,t,o))}}else return function(e,t,a){return n(r(e,t,a),i(e,t,a))}}forEach(e){e(this.start,`start`,this),e(this.end,`end`,this),this.step&&e(this.step,`step`,this)}map(e){return new r(this._ifNode(e(this.start,`start`,this)),this._ifNode(e(this.end,`end`,this)),this.step&&this._ifNode(e(this.step,`step`,this)))}clone(){return new r(this.start,this.end,this.step&&this.step)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toString(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toString(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toString(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}toJSON(){return{mathjs:Or,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toHTML(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toHTML(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toHTML(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i=this.start.toTex(e);if(r.start&&(i=`\\left(${i}\\right)`),this.step){var a=this.step.toTex(e);r.step&&(a=`\\left(${a}\\right)`),i+=`:`+a}var o=this.end.toTex(e);return r.end&&(o=`\\left(${o}\\right)`),i+=`:`+o,i}}return q(r,`name`,Or),r},{isClass:!0,isNode:!0}),Ar=`RelationalNode`,jr=G(Ar,[`Node`],e=>{var{Node:t}=e,n={equal:`==`,unequal:`!=`,smaller:`<`,larger:`>`,smallerEq:`<=`,largerEq:`>=`};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw TypeError(`Parameter conditionals must be an array`);if(!Array.isArray(t))throw TypeError(`Parameter params must be an array`);if(e.length!==t.length-1)throw TypeError(`Parameter params must contain exactly one more element than parameter conditionals`);this.conditionals=e,this.params=t}get type(){return Ar}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map(n=>n._compile(e,t));return function(t,i,a){for(var o,s=r[0](t,i,a),c=0;ce(t,`params[`+n+`]`,this),this)}map(e){return new r(this.conditionals.slice(),this.params.map((t,n)=>this._ifNode(e(t,`params[`+n+`]`,this)),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=Y(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=Y(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`(`+n.toString(e)+`)`:n.toString(e)}),a=i[0],o=0;o(`+n.toHTML(e)+`)`:n.toHTML(e)}),a=i[0],o=0;o`+K(n[this.conditionals[o]])+``+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=Y(this,t,e&&e.implicit),r=this.params.map(function(r,i){var a=Y(r,t,e&&e.implicit);return t===`all`||a!==null&&a<=n?`\\left(`+r.toTex(e)+`\right)`:r.toTex(e)}),i=r[0],a=0;a{var{math:t,Unit:n,Node:r}=e;function i(e){return n?n.isValuelessUnit(e):!1}class a extends r{constructor(e){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);this.name=e}get type(){return`SymbolNode`}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(t[r]===!0)return function(e,t,n){return p(t,r)};if(r in e)return function(t,n,i){return t.has(r)?t.get(r):p(e,r)};var o=i(r);return function(e,t,i){return e.has(r)?e.get(r):o?new n(null,r):a.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error(`Undefined symbol `+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=K(this.name);return t===`true`||t===`false`?``+t+``:t===`i`?``+t+``:t===`Infinity`?``+t+``:t===`NaN`?``+t+``:t===`null`?``+t+``:t===`undefined`?``+t+``:``+t+``}toJSON(){return{mathjs:`SymbolNode`,name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var n=!1;t[this.name]===void 0&&i(this.name)&&(n=!0);var r=mr(this.name,n);return r[0]===`\\`?r:` `+r}}return a},{isClass:!0,isNode:!0}),Nr=`FunctionNode`,Pr=G(Nr,[`math`,`Node`,`SymbolNode`],e=>{var t,{math:n,Node:r,SymbolNode:i}=e,a=e=>mn(e,{truncate:78});function o(e,t,n){for(var r=``,i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,a=0,o;(o=i.exec(e))!==null;)if(r+=e.substring(a,o.index),a=o.index,o[0]===`$$`)r+=`$`,a++;else{a+=o[0].length;var s=t[o[1]];if(!s)throw ReferenceError(`Template: Property `+o[1]+` does not exist.`);if(o[2]===void 0)switch(typeof s){case`string`:r+=s;break;case`object`:if(z(s))r+=s.toTex(n);else if(Array.isArray(s))r+=s.map(function(e,t){if(z(e))return e.toTex(n);throw TypeError(`Template: `+o[1]+`[`+t+`] is not a Node.`)}).join(`,`);else throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`);break;default:throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`)}else if(z(s[o[2]]&&s[o[2]]))r+=s[o[2]].toTex(n);else throw TypeError(`Template: `+o[1]+`[`+o[2]+`] is not a Node.`)}return r+=e.slice(a),r}class s extends r{constructor(e,t,n){if(super(),typeof e==`string`&&(e=new i(e)),!z(e))throw TypeError(`Node expected as parameter "fn"`);if(!Array.isArray(t)||!t.every(z))throw TypeError(`Array containing Nodes expected for parameter "args"`);var r=typeof n;if(!(r===`undefined`||r===`boolean`))throw TypeError(`optional flag, if specified, must be boolean`);this.fn=e,this.args=t||[],this.optional=!!n}get name(){return this.fn.name||``}get type(){return Nr}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map(n=>n._compile(e,t)),r=this.optional||I(this.fn)&&this.fn.optionalChaining;if(B(this.fn)){var i=this.fn.name;if(t[i]){var o=this.args;return function(t,s,c){var l=p(s,i);if(!(r&&l===void 0)){if(typeof l!=`function`)throw TypeError(`Argument '${i}' was not a function; received: ${a(l)}`);if(l.rawArgs)return l(o,e,Cr(t,s));var u=n.map(e=>e(t,s,c));return l.apply(l,u)}}}else{var c=i in e?p(e,i):void 0,l=typeof c==`function`&&c.rawArgs===!0,u=t=>{var n;if(t.has(i))n=t.get(i);else if(i in e)n=p(e,i);else if(r)n=void 0;else return s.onUndefinedFunction(i);if(typeof n==`function`||r&&n===void 0)return n;throw TypeError(`'${i}' is not a function; its value is: - ${a(n)}`)};if(l){var d=this.args;return function(t,r,i){var a=u(t);return a.rawArgs===!0?a(d,e,Cr(t,r)):a(...n.map(e=>e(t,r,i)))}}else switch(n.length){case 0:return function(e,t,n){var i=u(e);if(!(r&&i===void 0))return i()};case 1:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0];return a(o(e,t,i))}};case 2:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0],s=n[1];return a(o(e,t,i),s(e,t,i))}};default:return function(e,t,i){var a=u(e);if(!(r&&a===void 0))return a(...n.map(n=>n(e,t,i)))}}}}else if(I(this.fn)&&R(this.fn.index)&&this.fn.index.isObjectProperty()){var f=this.fn.object._compile(e,t),m=this.fn.index.getObjectProperty(),h=this.args;return function(t,i,a){var o=f(t,i,a);if(!(r&&(o==null||o[m]===void 0))){var s=g(o,m);if(s!=null&&s.rawArgs)return s(h,e,Cr(t,i));var c=n.map(e=>e(t,i,a));return s.apply(o,c)}}}else{var _=this.fn.toString(),v=this.fn._compile(e,t),y=this.args;return function(t,i,o){var s=v(t,i,o);if(!(r&&s===void 0)){if(typeof s!=`function`)throw TypeError(`Expression '${_}' did not evaluate to a function; value is: - ${a(s)}`);if(s.rawArgs)return s(y,e,Cr(t,i));var c=n.map(e=>e(t,i,o));return s.apply(s,c)}}}}forEach(e){e(this.fn,`fn`,this);for(var t=0;t`+K(this.fn)+`(`+t.join(`,`)+`)`}toTex(e){var t;return e&&typeof e.handler==`object`&&V(e.handler,this.name)&&(t=e.handler[this.name](this,e)),t===void 0?super.toTex(e):t}_toTex(e){var t=this.args.map(function(t){return t.toTex(e)}),r;ur[this.name]&&(r=ur[this.name]),n[this.name]&&(typeof n[this.name].toTex==`function`||typeof n[this.name].toTex==`object`||typeof n[this.name].toTex==`string`)&&(r=n[this.name].toTex);var i;switch(typeof r){case`function`:i=r(this,e);break;case`string`:i=o(r,this,e);break;case`object`:switch(typeof r[t.length]){case`function`:i=r[t.length](this,e);break;case`string`:i=o(r[t.length],this,e);break}}return i===void 0?o(dr,this,e):i}getIdentifier(){return this.type+`:`+this.name}}return t=s,q(s,`name`,Nr),q(s,`onUndefinedFunction`,function(e){throw Error(`Undefined function `+e)}),q(s,`fromJSON`,function(e){return new t(e.fn,e.args)}),s},{isClass:!0,isNode:!0}),Fr=`parse`,Ir=G(Fr,[`typed`,`numeric`,`config`,`AccessorNode`,`ArrayNode`,`AssignmentNode`,`BlockNode`,`ConditionalNode`,`ConstantNode`,`FunctionAssignmentNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`RangeNode`,`RelationalNode`,`SymbolNode`],e=>{var{typed:t,numeric:n,config:r,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:u,FunctionNode:f,IndexNode:p,ObjectNode:m,OperatorNode:h,ParenthesisNode:g,RangeNode:_,RelationalNode:v,SymbolNode:y}=e,b=t(Fr,{string:function(e){return ae(e,{})},"Array | Matrix":function(e){return x(e,{})},"string, Object":function(e,t){return ae(e,t.nodes===void 0?{}:t.nodes)},"Array | Matrix, Object":x});function x(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.nodes===void 0?{}:t.nodes;return Nn(e,function(e){if(typeof e!=`string`)throw TypeError(`String expected`);return ae(e,n)})}var S={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},ee={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"?.":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},te={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},ne={true:!0,false:!1,null:null,undefined:void 0},C=[`NaN`,`Infinity`],w={'"':`"`,"'":`'`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:` -`,r:`\r`,t:` `};function re(){return{extraNodes:{},expression:``,comment:``,index:0,token:``,tokenType:S.NULL,nestingLevel:0,conditionalLevel:null}}function T(e,t){return e.expression.substr(e.index,t)}function E(e){return T(e,1)}function D(e){e.index++}function O(e){return e.expression.charAt(e.index-1)}function k(e){return e.expression.charAt(e.index+1)}function A(e){for(e.tokenType=S.NULL,e.token=``,e.comment=``;;){if(E(e)===`#`)for(;E(e)!==` -`&&E(e)!==``;)e.comment+=E(e),D(e);if(b.isWhitespace(E(e),e.nestingLevel))D(e);else break}if(E(e)===``){e.tokenType=S.DELIMITER;return}if(E(e)===` -`&&!e.nestingLevel){e.tokenType=S.DELIMITER,e.token=E(e),D(e);return}var t=E(e),n=T(e,2),r=T(e,3);if(r.length===3&&ee[r]){e.tokenType=S.DELIMITER,e.token=r,D(e),D(e),D(e);return}if(n.length===2&&ee[n]&&(n!==`?.`||!b.isDigit(e.expression.charAt(e.index+2)))){e.tokenType=S.DELIMITER,e.token=n,D(e),D(e);return}if(ee[t]){e.tokenType=S.DELIMITER,e.token=t,D(e);return}if(b.isDigitDot(t)){e.tokenType=S.NUMBER;var i=T(e,2);if(i===`0b`||i===`0o`||i===`0x`){for(e.token+=E(e),D(e),e.token+=E(e),D(e);b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);if(E(e)===`.`)for(e.token+=`.`,D(e);b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);else if(E(e)===`i`)for(e.token+=`i`,D(e);b.isDigit(E(e));)e.token+=E(e),D(e);return}if(E(e)===`.`){if(e.token+=E(e),D(e),!b.isDigit(E(e))){e.tokenType=S.DELIMITER;return}}else{for(;b.isDigit(E(e));)e.token+=E(e),D(e);b.isDecimalMark(E(e),k(e))&&(e.token+=E(e),D(e))}for(;b.isDigit(E(e));)e.token+=E(e),D(e);if(E(e)===`E`||E(e)===`e`){if(b.isDigit(k(e))||k(e)===`-`||k(e)===`+`){if(e.token+=E(e),D(e),(E(e)===`+`||E(e)===`-`)&&(e.token+=E(e),D(e)),!b.isDigit(E(e)))throw H(e,`Digit expected, got "`+E(e)+`"`);for(;b.isDigit(E(e));)e.token+=E(e),D(e);if(b.isDecimalMark(E(e),k(e)))throw H(e,`Digit expected, got "`+E(e)+`"`)}else if(b.isDecimalMark(k(e),e.expression.charAt(e.index+2)))throw D(e),H(e,`Digit expected, got "`+E(e)+`"`)}return}if(b.isAlpha(E(e),O(e),k(e))){for(;b.isAlpha(E(e),O(e),k(e))||b.isDigit(E(e));)e.token+=E(e),D(e);V(te,e.token)?e.tokenType=S.DELIMITER:e.tokenType=S.SYMBOL;return}for(e.tokenType=S.UNKNOWN;E(e)!==``;)e.token+=E(e),D(e);throw H(e,`Syntax error in part "`+e.token+`"`)}function j(e){do A(e);while(e.token===` -`)}function ie(e){e.nestingLevel++}function M(e){e.nestingLevel--}b.isAlpha=function(e,t,n){return b.isValidLatinOrGreek(e)||b.isValidMathSymbol(e,n)||b.isValidMathSymbol(t,e)},b.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},b.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},b.isWhitespace=function(e,t){return e===` `||e===` `||e===`\xA0`||e===` -`&&t>0},b.isDecimalMark=function(e,t){return e===`.`&&t!==`/`&&t!==`*`&&t!==`^`},b.isDigitDot=function(e){return e>=`0`&&e<=`9`||e===`.`},b.isDigit=function(e){return e>=`0`&&e<=`9`};function ae(e,t){var n=re();d(n,{expression:e,extraNodes:t}),A(n);var r=oe(n);if(n.token!==``)throw n.tokenType===S.DELIMITER?Re(n,`Unexpected operator `+n.token):H(n,`Unexpected part "`+n.token+`"`);return r}function oe(e){var t,n=[],r;for(e.token!==``&&e.token!==` -`&&e.token!==`;`&&(t=N(e),e.comment&&(t.comment=e.comment));e.token===` -`||e.token===`;`;)n.length===0&&t&&(r=e.token!==`;`,n.push({node:t,visible:r})),A(e),e.token!==` -`&&e.token!==`;`&&e.token!==``&&(t=N(e),e.comment&&(t.comment=e.comment),r=e.token!==`;`,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}function N(e){var t,n,r,i,a=se(e);if(e.token===`=`){if(B(a))return t=a.name,j(e),r=N(e),new o(new y(t),r);if(I(a)){if(a.optionalChaining)throw H(e,`Cannot assign to optional chain`);return j(e),r=N(e),new o(a.object,a.index,r)}else if(Se(a)&&B(a.fn)&&(i=!0,n=[],t=a.name,a.args.forEach(function(e,t){B(e)?n[t]=e.name:i=!1}),i))return j(e),r=N(e),new u(t,n,r);throw H(e,`Invalid left hand side of assignment operator =`)}return a}function se(e){for(var t=ce(e);e.token===`?`;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,j(e);var r=t,i=N(e);if(e.token!==`:`)throw H(e,`False part of conditional expression expected`);e.conditionalLevel=null,j(e),t=new c(r,i,N(e)),e.conditionalLevel=n}return t}function ce(e){for(var t=le(e);e.token===`or`;)j(e),t=new h(`or`,`or`,[t,le(e)]);return t}function le(e){for(var t=ue(e);e.token===`xor`;)j(e),t=new h(`xor`,`xor`,[t,ue(e)]);return t}function ue(e){for(var t=de(e);e.token===`and`;)j(e),t=new h(`and`,`and`,[t,de(e)]);return t}function de(e){for(var t=fe(e);e.token===`|`;)j(e),t=new h(`|`,`bitOr`,[t,fe(e)]);return t}function fe(e){for(var t=P(e);e.token===`^|`;)j(e),t=new h(`^|`,`bitXor`,[t,P(e)]);return t}function P(e){for(var t=pe(e);e.token===`&`;)j(e),t=new h(`&`,`bitAnd`,[t,pe(e)]);return t}function pe(e){for(var t=[me(e)],n=[],r={"==":`equal`,"!=":`unequal`,"<":`smaller`,">":`larger`,"<=":`smallerEq`,">=":`largerEq`};V(r,e.token);){var i={name:e.token,fn:r[e.token]};n.push(i),j(e),t.push(me(e))}return t.length===1?t[0]:t.length===2?new h(n[0].name,n[0].fn,t):new v(n.map(e=>e.fn),t)}function me(e){for(var t=F(e),n,r,i,a={"<<":`leftShift`,">>":`rightArithShift`,">>>":`rightLogShift`};V(a,e.token);)n=e.token,r=a[n],j(e),i=[t,F(e)],t=new h(n,r,i);return t}function F(e){for(var t=he(e),n,r,i,a={to:`to`,in:`to`};V(a,e.token);)n=e.token,r=a[n],j(e),n===`in`&&`])},;`.includes(e.token)?t=new h(`*`,`multiply`,[t,new y(`in`)],!0):(i=[t,he(e)],t=new h(n,r,i));return t}function he(e){var t,n=[];if(e.token===`:`){if(e.conditionalLevel===e.nestingLevel)throw H(e,`The true-expression of a conditional operator may not be empty`);t=new l(1)}else t=ge(e);if(e.token===`:`&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);e.token===`:`&&n.length<3;)j(e),e.token===`)`||e.token===`]`||e.token===`,`||e.token===``?n.push(new y(`end`)):n.push(ge(e));t=n.length===3?new _(n[0],n[2],n[1]):new _(n[0],n[1])}return t}function ge(e){for(var t=_e(e),n,r,i,a={"+":`add`,"-":`subtract`};V(a,e.token);){n=e.token,r=a[n],j(e);var o=_e(e);i=o.isPercentage?[t,new h(`*`,`multiply`,[t,o])]:[t,o],t=new h(n,r,i)}return t}function _e(e){for(var t=ve(e),n=t,r,i,a={"*":`multiply`,".*":`dotMultiply`,"/":`divide`,"./":`dotDivide`,"%":`mod`,mod:`mod`};V(a,e.token);)r=e.token,i=a[r],j(e),n=ve(e),t=new h(r,i,[t,n]);return t}function ve(e){for(var t=ye(e),n=t;e.tokenType===S.SYMBOL||e.token===`in`&&L(t)||e.token===`in`&&we(t)&&t.fn===`unaryMinus`&&L(t.args[0])||e.tokenType===S.NUMBER&&!L(n)&&(!we(n)||n.op===`!`)||e.token===`(`;)n=ye(e),t=new h(`*`,`multiply`,[t,n],!0);return t}function ye(e){for(var t=xe(e),n=t,r=[];e.token===`/`&&be(n);)if(r.push(d({},e)),j(e),e.tokenType===S.NUMBER)if(r.push(d({},e)),j(e),e.tokenType===S.SYMBOL||e.token===`(`||e.token===`in`)d(e,r.pop()),r.pop(),n=xe(e),t=new h(`/`,`divide`,[t,n]);else{r.pop(),d(e,r.pop());break}else{d(e,r.pop());break}return t}function xe(e){var t=R(e);if(e.token===`%`){var n=d({},e);j(e);try{R(e),d(e,n)}catch{t=new h(`/`,`divide`,[t,new l(100)],!1,!0)}}return t}function R(e){var t,n,r,i={"-":`unaryMinus`,"+":`unaryPlus`,"~":`bitNot`,not:`not`};return V(i,e.token)?(r=i[e.token],t=e.token,j(e),n=[R(e)],new h(t,r,n)):z(e)}function z(e){var t=Ce(e),n,r,i;return(e.token===`^`||e.token===`.^`)&&(n=e.token,r=n===`^`?`pow`:`dotPow`,j(e),i=[t,R(e)],t=new h(n,r,i)),t}function Ce(e){for(var t=Te(e);e.token===`??`;)j(e),t=new h(`??`,`nullish`,[t,Te(e)]);return t}function Te(e){for(var t=Ee(e),n,r,i,a={"!":`factorial`,"'":`ctranspose`};V(a,e.token);)n=e.token,r=a[n],A(e),i=[t],t=new h(n,r,i),t=Oe(e,t);return t}function Ee(e){var t=[];if(e.tokenType===S.SYMBOL&&V(e.extraNodes,e.token)){var n=e.extraNodes[e.token];if(A(e),e.token===`(`){if(t=[],ie(e),A(e),e.token!==`)`)for(t.push(N(e));e.token===`,`;)A(e),t.push(N(e));if(e.token!==`)`)throw H(e,`Parenthesis ) expected`);M(e),A(e)}return new n(t)}return De(e)}function De(e){var t,r;return e.tokenType===S.SYMBOL||e.tokenType===S.DELIMITER&&e.token in te?(r=e.token,A(e),t=V(ne,r)?new l(ne[r]):C.includes(r)?new l(n(r,`number`)):new y(r),t=Oe(e,t),t):ke(e)}function Oe(e,t,n){for(var r;;){var a=!1;e.token===`?.`&&(a=!0,A(e));var o=(e.token===`(`||e.token===`[`||e.token===`.`)&&(!n||n.includes(e.token));if(!(a||o))break;if(r=[],e.token===`(`)if(a||B(t)||I(t)){if(ie(e),A(e),e.token!==`)`)for(r.push(N(e));e.token===`,`;)A(e),r.push(N(e));if(e.token!==`)`)throw H(e,`Parenthesis ) expected`);M(e),A(e),t=new f(t,r,a)}else return t;else if(e.token===`[`){if(ie(e),A(e),e.token!==`]`)for(r.push(N(e));e.token===`,`;)A(e),r.push(N(e));if(e.token!==`]`)throw H(e,`Parenthesis ] expected`);M(e),A(e),t=new i(t,new p(r),a)}else{if(a||A(e),!(e.tokenType===S.SYMBOL||e.tokenType===S.DELIMITER&&e.token in te)){var s=`Property name expected after `;throw s+=a?`optional chain`:`dot`,H(e,s)}r.push(new l(e.token)),A(e),t=new i(t,new p(r,!0),a)}}return t}function ke(e){var t,n;return e.token===`"`||e.token===`'`?(n=Ae(e,e.token),t=new l(n),t=Oe(e,t),t):je(e)}function Ae(e,t){for(var n=``;E(e)!==``&&E(e)!==t;)if(E(e)===`\\`){D(e);var r=E(e),i=w[r];if(i!==void 0)n+=i,e.index+=1;else if(r===`u`){var a=e.expression.slice(e.index+1,e.index+5);if(/^[0-9A-Fa-f]{4}$/.test(a))n+=String.fromCharCode(parseInt(a,16)),e.index+=5;else throw H(e,`Invalid unicode character \\u${a}`)}else throw H(e,`Bad escape character \\${r}`)}else n+=E(e),D(e);if(A(e),e.token!==t)throw H(e,`End of string ${t} expected`);return A(e),n}function je(e){var t,n,r,i;if(e.token===`[`){if(ie(e),A(e),e.token!==`]`){var o=Me(e);if(e.token===`;`){for(r=1,n=[o];e.token===`;`;)A(e),e.token!==`]`&&(n[r]=Me(e),r++);if(e.token!==`]`)throw H(e,`End of matrix ] expected`);M(e),A(e),i=n[0].items.length;for(var s=1;s{var{typed:t,parse:n}=e;return t(Lr,{string:function(e){var t=te();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=te();return Nn(e,function(e){return n(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return Nn(e,function(e){return n(e).compile().evaluate(t)})}})}),zr=`size`,Br=G(zr,[`typed`],e=>{var{typed:t}=e;return t(zr,{Matrix:e=>e.size(),Array:On,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),Vr=`factorial`,Hr=G(Vr,[`typed`,`gamma`],e=>{var{typed:t,gamma:n}=e;return t(Vr,{number:function(e){if(e<0)throw Error(`Value must be non-negative`);return n(e+1)},BigNumber:function(e){if(e.isNegative())throw Error(`Value must be non-negative`);return n(e.plus(1))},"Array | Matrix":t.referToSelf(e=>t=>Nn(t,e))})}),Ur=`isBounded`,Wr=G(Ur,[`typed`],e=>{var{typed:t}=e;return t(Ur,{number:e=>Number.isFinite(e),"BigNumber | Complex":e=>e.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:t.referToSelf(e=>t=>e(t.value)),"Array | Matrix":t.referToSelf(e=>t=>(Array.isArray(t)||(t=t.valueOf()),t.every(t=>e(t))))})}),Gr=G(`numeric`,[`number`,`?bignumber`,`?fraction`],e=>{var{number:t,bignumber:n,fraction:r}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:n?e=>n(e):Yt,bigint:e=>BigInt(e),Fraction:r?e=>r(e):Xt};return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`number`;if((arguments.length>2?arguments[2]:void 0)!==void 0)throw SyntaxError(`numeric() takes one or two arguments`);var n=ke(e);if(!(n in i))throw TypeError(`Cannot convert `+e+` of type "`+n+`"; valid input types are `+Object.keys(i).join(`, `));if(!(t in a))throw TypeError(`Cannot convert `+e+` to type "`+t+`"; valid output types are `+Object.keys(a).join(`, `));return t===n?e:a[t](e)}}),Kr=Z(`abs`,lt),qr=Z(`exp`,vt),Jr=Z(`gcd`,bt),Yr=Z(`lcm`,xt),Xr=Z(`log10`,Ct),Zr=Z(`log2`,wt),Qr=Z(`mod`,Et),$r=Z(`multiply`,ft),ei=pi(`nthRoot`,Dt),ti=Z(`sign`,Ot),ni=Z(`sqrt`,kt),ri=Z(`subtract`,dt),ii=Z(`pow`,Mt),ai=pi(`round`,Nt),oi=pi(`log`,St),si=Z(`log1p`,Tt),ci=Z(`add`,ut),li=Z(`divide`,pt),ui=G(`matrix`,[],()=>Zt),di=G(`subset`,[],()=>Qt);Z(`combinations`,It);var fi=Z(`gamma`,zt);Z(`lgamma`,Wt);function Z(e,t){return G(e,[`typed`],e=>{var{typed:n}=e;return n(t)})}function pi(e,t){return G(e,[`typed`],e=>{var{typed:n}=e;return n({number:t,"number,number":t})})}function mi(e,t,n,r){if(!(this instanceof mi))throw SyntaxError(`Constructor must be called with the new operator`);this.fn=e,this.count=t,this.min=n,this.max=r,this.message=`Wrong number of arguments in function `+e+` (`+t+` provided, `+n+(r==null?``:`-`+r)+` expected)`,this.stack=Error().stack}mi.prototype=Error(),mi.prototype.constructor=Error,mi.prototype.name=`ArgumentsError`,mi.prototype.isArgumentsError=!0;var Q={createTyped:tn},hi={typedDependencies:Q,createAbs:Kr},$={createNode:Jn},gi={createSubset:di},_i={NodeDependencies:$,subsetDependencies:gi,createAccessorNode:Qn},vi={typedDependencies:Q,createAdd:ci},yi={NodeDependencies:$,createArrayNode:er},bi={matrixDependencies:{createMatrix:ui},NodeDependencies:$,subsetDependencies:gi,createAssignmentNode:rr},xi={gammaDependencies:{typedDependencies:Q,createGamma:fi},typedDependencies:Q,createFactorial:Hr},Si={typedDependencies:Q,createNumber:Kn},Ci={typedDependencies:Q,createPow:ii},wi={NodeDependencies:$,ResultSetDependencies:{createResultSet:sn},createBlockNode:ar},Ti={typedDependencies:Q,createRound:ai},Ei={NodeDependencies:$,createConditionalNode:sr},Di={NodeDependencies:$,isBoundedDependencies:{typedDependencies:Q,createIsBounded:Wr},createConstantNode:gr},Oi={NodeDependencies:$,typedDependencies:Q,createFunctionAssignmentNode:vr},ki={NodeDependencies:$,createSymbolNode:Mr},Ai={AccessorNodeDependencies:_i,ArrayNodeDependencies:yi,AssignmentNodeDependencies:bi,BlockNodeDependencies:wi,ConditionalNodeDependencies:Ei,ConstantNodeDependencies:Di,FunctionAssignmentNodeDependencies:Oi,FunctionNodeDependencies:{NodeDependencies:$,SymbolNodeDependencies:ki,createFunctionNode:Pr},IndexNodeDependencies:{NodeDependencies:$,sizeDependencies:{typedDependencies:Q,createSize:Br},createIndexNode:br},ObjectNodeDependencies:{NodeDependencies:$,createObjectNode:Sr},OperatorNodeDependencies:{NodeDependencies:$,createOperatorNode:Tr},ParenthesisNodeDependencies:{NodeDependencies:$,createParenthesisNode:Dr},RangeNodeDependencies:{NodeDependencies:$,createRangeNode:kr},RelationalNodeDependencies:{NodeDependencies:$,createRelationalNode:jr},SymbolNodeDependencies:ki,numericDependencies:{numberDependencies:Si,createNumeric:Gr},typedDependencies:Q,createParse:Ir},ji={typedDependencies:Q,createDivide:li},Mi={typedDependencies:Q,createMultiply:$r},Ni={typedDependencies:Q,createSqrt:ni},Pi={typedDependencies:Q,createSubtract:ri},Fi={createE:Bn},Ii={parseDependencies:Ai,typedDependencies:Q,createEvaluate:Rr},Li={typedDependencies:Q,createExp:qr},Ri={typedDependencies:Q,createGcd:Jr},zi={typedDependencies:Q,createLcm:Yr},Bi={typedDependencies:Q,createLog:oi},Vi={typedDependencies:Q,createLog10:Xr},Hi={typedDependencies:Q,createLog1p:si},Ui={typedDependencies:Q,createLog2:Zr},Wi={typedDependencies:Q,createMod:Qr},Gi={typedDependencies:Q,createNthRoot:ei},Ki={createPi:zn},qi={typedDependencies:Q,createSign:ti},Ji=u(c(((e,t)=>{function n(){}n.prototype={on:function(e,t,n){var r=this.e||={};return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||={})[e]||[]).slice(),r=0,i=n.length;rr(e,t));else if(fe(n)||d(n))for(var a in n)V(n,a)&&r(e,n[a],a);else if(Gt(n)||i!==void 0){var o=Gt(n)?h(n)?n.fn+`.transform`:n.fn:i;if(V(e,o)&&e[o]!==n&&!t.silent)throw Error(`Cannot import "`+o+`" twice`);e[o]=n}else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}var i={};for(var o in r(i,e),i)if(V(i,o)){var s=i[o];if(Gt(s))l(s,t);else if(u(s))a(o,s,t);else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}}function a(t,i,a){if(a.wrap&&typeof i==`function`&&(i=c(i)),f(i)&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(n[t])&&e.isTypedFunction(i)){i=a.override?e(t,i.signatures):e(n[t],i),n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}var s=n[t]!==void 0,l=n.Unit?.isValuelessUnit(t);if(!s&&!l||a.override){n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}if(!a.silent)throw Error(`Cannot import "`+t+`": already exists`)}function o(e,t){t&&typeof t.transform==`function`?(n.expression.transform[e]=t.transform,p(e)&&(n.expression.mathWithTransform[e]=t.transform)):(delete n.expression.transform[e],p(e)&&(n.expression.mathWithTransform[e]=t))}function s(e){delete n.expression.transform[e],p(e)?n.expression.mathWithTransform[e]=n[e]:delete n.expression.mathWithTransform[e]}function c(e){var t=function(){for(var t=[],r=0,i=arguments.length;r2&&arguments[2]!==void 0?arguments[2]:t.fn;if(a.includes(`.`))throw Error(`Factory name should not contain a nested path. Name: `+JSON.stringify(a));var o=h(t)?n.expression.transform:n,c=a in n.expression.transform,l=V(o,a)?o[a]:void 0,u=function(){var r={};t.dependencies.map(Jt).forEach(e=>{if(e.includes(`.`))throw Error(`Factory dependency should not contain a nested path. Name: `+JSON.stringify(e));e===`math`?r.math=n:e===`mathWithTransform`?r.mathWithTransform=n.expression.mathWithTransform:e===`classes`?r.classes=n:r[e]=n[e]});var o=t(r);if(o&&typeof o.transform==`function`)throw Error(`Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"`);if(l===void 0||i.override)return o;if(e.isTypedFunction(l)&&e.isTypedFunction(o))return e(l,o);if(i.silent)return l;throw Error(`Cannot import "`+a+`": already exists`)},d=t.meta?.formerly??``,f=h(t)||m(t),p=n.expression.mathWithTransform;!t.meta||t.meta.lazy!==!1?(Ie(o,a,u),d&&Ie(o,d,u),l&&c?(s(a),d&&s(d)):f&&(Ie(p,a,()=>o[a]),d&&Ie(p,d,()=>o[a]))):(o[a]=u(),d&&(o[d]=o[a]),l&&c?(s(a),d&&s(d)):f&&(Ie(p,a,()=>o[a]),d&&Ie(p,d,()=>o[a]))),r[a]=t,n.emit(`import`,a,u)}function u(e){return typeof e==`function`||typeof e==`number`||typeof e==`string`||typeof e==`boolean`||e===null||D(e)||T(e)||w(e)||E(e)||A(e)||Array.isArray(e)}function d(e){return typeof e==`object`&&e[Symbol.toStringTag]===`Module`}function f(e){return typeof e==`function`&&typeof e.signature==`string`}function p(e){return!V(g,e)}function m(e){return!e.fn.includes(`.`)&&!V(g,e.fn)&&(!e.meta||!e.meta.isClass)}function h(e){return e!==void 0&&e.meta!==void 0&&e.meta.isTransformFunction===!0||!1}var g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return i}function Zi(e,t){var n=d({},f,t);if(typeof Object.create!=`function`)throw Error(`ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.`);var r=Yi({isNumber:C,isComplex:T,isBigNumber:w,isBigInt:re,isFraction:E,isUnit:D,isString:O,isArray:k,isMatrix:A,isCollection:j,isDenseMatrix:ie,isSparseMatrix:M,isRange:ae,isIndex:oe,isBoolean:N,isResultSet:se,isHelp:ce,isFunction:le,isDate:ue,isRegExp:de,isObject:fe,isMap:P,isPartitionedMap:pe,isObjectWrappingMap:me,isNull:F,isUndefined:he,isAccessorNode:I,isArrayNode:ge,isAssignmentNode:_e,isBlockNode:ve,isConditionalNode:ye,isConstantNode:L,isFunctionAssignmentNode:xe,isFunctionNode:Se,isIndexNode:R,isNode:z,isObjectNode:Ce,isOperatorNode:we,isParenthesisNode:Te,isRangeNode:Ee,isRelationalNode:De,isSymbolNode:B,isChain:Oe});r.config=Be(n,r.emit),r.expression={transform:{},mathWithTransform:{config:r.config}};var i=[],a=[];function o(e){if(Gt(e))return e(r);var t=e[Object.keys(e)[0]];if(Gt(t))return t(r);if(!Le(e))throw console.warn("Factory object with properties `type`, `name`, and `factory` expected",e),Error("Factory object with properties `type`, `name`, and `factory` expected");var s=i.indexOf(e),c;return s===-1?(c=e.math===!0?e.factory(r.type,n,o,r.typed,r):e.factory(r.type,n,o,r.typed),i.push(e),a.push(c)):c=a[s],c}var s={};function c(){var e=[...arguments];return r.typed.apply(r.typed,e)}c.isTypedFunction=$t.default.isTypedFunction;var l=Xi(c,o,r,s);return r.import=l,r.on(`config`,()=>{Object.values(s).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&l(e,{override:!0})})}),r.create=Zi.bind(null,e),r.factory=G,r.import(Object.values(Pe(e))),r.ArgumentsError=mi,r.DimensionError=Dn,r.IndexError=En,r}var Qi=e=>{let n=t(`results`),r=t(`answers`,{assert:!1});if(!r){let e=document.createElement(`h4`);e.setAttribute(`class`,`title`),e.setAttribute(`id`,`answers-title`),e.textContent=`Answers : `,r=document.createElement(`div`),r.setAttribute(`id`,`answers`),r.setAttribute(`role`,`complementary`),r.setAttribute(`aria-labelledby`,`answers-title`),r.appendChild(e)}if(!(e instanceof HTMLElement)){let t=document.createElement(`span`);t.innerHTML=e.toString(),e=t}r.appendChild(e),n.insertAdjacentElement(`afterbegin`,r)},$i=class n extends e{constructor(){super(`calculator`)}static math=Zi({...hi,...vi,...ji,...Fi,...Ii,...Li,...xi,...Ri,...zi,...Vi,...Hi,...Ui,...Bi,...Wi,...Mi,...Gi,...Ki,...Ci,...Ti,...qi,...Ni,...Pi});async run(){let e=t(`q`),r=n.math.parse(e.value);try{return`${r.toString()} = ${r.evaluate()}`}catch{return}}async post(e){Qi(e)}};export{$i as default}; -//# sourceMappingURL=BSJ3HQQa.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BSJ3HQQa.min.js.map b/searx/static/themes/simple/chunk/BSJ3HQQa.min.js.map deleted file mode 100644 index 92939d450..000000000 --- a/searx/static/themes/simple/chunk/BSJ3HQQa.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"BSJ3HQQa.min.js","names":["format","toFixed","toExponential","toEngineering","_toNumberOrDefault","toFixed","typedFunction","dependencies","name","dependencies","format","formatNumber","formatBigNumber","deepMap","arrayDeepMap","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","name","dependencies","Emitter","emitter.mixin","typedFunction"],"sources":["../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/extends.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/config.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/customs.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/map.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/is.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/object.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/config.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/number.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/arithmetic.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/product.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/combinations.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/plain/number/probability.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/factory.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/noop.js","../../../../../client/simple/node_modules/typed-function/lib/umd/typed-function.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/typed.js","../../../../../client/simple/node_modules/mathjs/lib/esm/type/resultset/ResultSet.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/bignumber/formatter.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/string.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../../../../../client/simple/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/operators.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/IndexError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/DimensionError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/array.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/collection.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/lruQueue.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/function.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/bignumber/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/constants.js","../../../../../client/simple/node_modules/mathjs/lib/esm/type/number.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/keywords.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/Node.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/transform/utils/errorTransform.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/utils/access.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/AccessorNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ArrayNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/utils/assign.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/AssignmentNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/BlockNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ConditionalNode.js","../../../../../client/simple/node_modules/escape-latex/dist/index.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/latex.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ConstantNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/FunctionAssignmentNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/IndexNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ObjectNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/scope.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/OperatorNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/ParenthesisNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/RangeNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/RelationalNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/SymbolNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/node/FunctionNode.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/parse.js","../../../../../client/simple/node_modules/mathjs/lib/esm/expression/function/evaluate.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/matrix/size.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/probability/factorial.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/utils/isBounded.js","../../../../../client/simple/node_modules/mathjs/lib/esm/function/utils/numeric.js","../../../../../client/simple/node_modules/mathjs/lib/esm/factoriesNumber.js","../../../../../client/simple/node_modules/mathjs/lib/esm/error/ArgumentsError.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesTyped.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAbs.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSubset.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAccessorNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAdd.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesArrayNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMatrix.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesAssignmentNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesGamma.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFactorial.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNumber.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesPow.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesResultSet.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesBlockNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRound.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesConditionalNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesIsBounded.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesConstantNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFunctionAssignmentNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSymbolNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesFunctionNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSize.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesIndexNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesObjectNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesOperatorNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesParenthesisNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRangeNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesRelationalNode.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNumeric.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesParse.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesDivide.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMultiply.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSqrt.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSubtract.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesE.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesEvaluate.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesExp.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesGcd.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLcm.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog10.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog1p.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesLog2.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesMod.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesNthRoot.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesPi.generated.js","../../../../../client/simple/node_modules/mathjs/lib/esm/entry/dependenciesNumber/dependenciesSign.generated.js","../../../../../client/simple/node_modules/tiny-emitter/index.js","../../../../../client/simple/node_modules/mathjs/lib/esm/utils/emitter.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/function/import.js","../../../../../client/simple/node_modules/mathjs/lib/esm/core/create.js","../../../../../client/simple/src/js/util/appendAnswerElement.ts","../../../../../client/simple/src/js/plugin/Calculator.ts"],"sourcesContent":["function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","export var DEFAULT_CONFIG = {\n // minimum relative difference between two compared values,\n // used by all comparison functions\n relTol: 1e-12,\n // minimum absolute difference between two compared values,\n // used by all comparison functions\n absTol: 1e-15,\n // type of default matrix output. Choose 'matrix' (default) or 'array'\n matrix: 'Matrix',\n // type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'\n number: 'number',\n // type of fallback used for config { number: 'bigint' } when a value cannot be represented\n // in the configured numeric type. Choose 'number' (default) or 'BigNumber'.\n numberFallback: 'number',\n // number of significant digits in BigNumbers\n precision: 64,\n // predictable output type of functions. When true, output type depends only\n // on the input types. When false (default), output type can vary depending\n // on input values. For example `math.sqrt(-4)` returns `complex('2i')` when\n // predictable is false, and returns `NaN` when true.\n predictable: false,\n // random seed for seeded pseudo random number generation\n // null = randomly seed\n randomSeed: null,\n // legacy behavior for matrix subset. When true, the subset function\n // returns a matrix or array with the same size as the index (except for scalars).\n // When false, it returns a matrix or array with a size depending on the type of index.\n legacySubset: false\n};","import { hasOwnProperty } from './object.js';\n\n/**\n * Get a property of a plain object\n * Throws an error in case the object is not a plain object or the\n * property is not defined on the object itself\n * @param {Object} object\n * @param {string} prop\n * @return {*} Returns the property value when safe\n */\nfunction getSafeProperty(object, prop) {\n // only allow getting safe properties of a plain object\n if (isSafeProperty(object, prop)) {\n return object[prop];\n }\n if (typeof object[prop] === 'function' && isSafeMethod(object, prop)) {\n throw new Error('Cannot access method \"' + prop + '\" as a property');\n }\n throw new Error('No access to property \"' + prop + '\"');\n}\n\n/**\n * Set a property on a plain object.\n * Throws an error in case the object is not a plain object or the\n * property would override an inherited property like .constructor or .toString\n * @param {Object} object\n * @param {string} prop\n * @param {*} value\n * @return {*} Returns the value\n */\n// TODO: merge this function into access.js?\nfunction setSafeProperty(object, prop, value) {\n // only allow setting safe properties of a plain object\n if (isSafeProperty(object, prop)) {\n object[prop] = value;\n return value;\n }\n throw new Error('No access to property \"' + prop + '\"');\n}\n\n/**\n * Test whether a property is safe to use on an object or Array.\n * For example .toString and .constructor are not safe\n * @param {Object | Array} object\n * @param {string} prop\n * @return {boolean} Returns true when safe\n */\nfunction isSafeProperty(object, prop) {\n if (!isPlainObject(object) && !Array.isArray(object)) {\n return false;\n }\n // SAFE: whitelisted\n // e.g length\n if (hasOwnProperty(safeNativeProperties, prop)) {\n return true;\n }\n // UNSAFE: inherited from Object prototype\n // e.g constructor\n if (prop in Object.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Object.prototype is a root object\n return false;\n }\n // UNSAFE: inherited from Function prototype\n // e.g call, apply\n if (prop in Function.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Function.prototype is a root object\n return false;\n }\n return true;\n}\n\n/**\n * Validate whether a method is safe.\n * Throws an error when that's not the case.\n * @param {Object} object\n * @param {string} method\n * @return {function} Returns the method when valid\n */\nfunction getSafeMethod(object, method) {\n if (!isSafeMethod(object, method)) {\n throw new Error('No access to method \"' + method + '\"');\n }\n return object[method];\n}\n\n/**\n * Check whether a method is safe.\n * Throws an error when that's not the case (for example for `constructor`).\n * @param {Object} object\n * @param {string} method\n * @return {boolean} Returns true when safe, false otherwise\n */\nfunction isSafeMethod(object, method) {\n if (object === null || object === undefined || typeof object[method] !== 'function') {\n return false;\n }\n // UNSAFE: ghosted\n // e.g overridden toString\n // Note that IE10 doesn't support __proto__ and we can't do this check there.\n if (hasOwnProperty(object, method) && Object.getPrototypeOf && method in Object.getPrototypeOf(object)) {\n return false;\n }\n // SAFE: whitelisted\n // e.g toString\n if (hasOwnProperty(safeNativeMethods, method)) {\n return true;\n }\n // UNSAFE: inherited from Object prototype\n // e.g constructor\n if (method in Object.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Object.prototype is a root object\n return false;\n }\n // UNSAFE: inherited from Function prototype\n // e.g call, apply\n if (method in Function.prototype) {\n // 'in' is used instead of hasOwnProperty for nodejs v0.10\n // which is inconsistent on root prototypes. It is safe\n // here because Function.prototype is a root object\n return false;\n }\n return true;\n}\nfunction isPlainObject(object) {\n return typeof object === 'object' && object && object.constructor === Object;\n}\nvar safeNativeProperties = {\n length: true,\n name: true\n};\nvar safeNativeMethods = {\n toString: true,\n valueOf: true,\n toLocaleString: true\n};\nexport { getSafeProperty };\nexport { setSafeProperty };\nexport { isSafeProperty };\nexport { getSafeMethod };\nexport { isSafeMethod };\nexport { isPlainObject };","import { getSafeProperty, isSafeProperty, setSafeProperty } from './customs.js';\nimport { isMap, isObject } from './is.js';\n\n/**\n * A map facade on a bare object.\n *\n * The small number of methods needed to implement a scope,\n * forwarding on to the SafeProperty functions. Over time, the codebase\n * will stop using this method, as all objects will be Maps, rather than\n * more security prone objects.\n */\nexport class ObjectWrappingMap {\n constructor(object) {\n this.wrappedObject = object;\n this[Symbol.iterator] = this.entries;\n }\n keys() {\n return Object.keys(this.wrappedObject).filter(key => this.has(key)).values();\n }\n get(key) {\n return getSafeProperty(this.wrappedObject, key);\n }\n set(key, value) {\n setSafeProperty(this.wrappedObject, key, value);\n return this;\n }\n has(key) {\n return isSafeProperty(this.wrappedObject, key) && key in this.wrappedObject;\n }\n entries() {\n return mapIterator(this.keys(), key => [key, this.get(key)]);\n }\n forEach(callback) {\n for (var key of this.keys()) {\n callback(this.get(key), key, this);\n }\n }\n delete(key) {\n if (isSafeProperty(this.wrappedObject, key)) {\n delete this.wrappedObject[key];\n }\n }\n clear() {\n for (var key of this.keys()) {\n this.delete(key);\n }\n }\n get size() {\n return Object.keys(this.wrappedObject).length;\n }\n}\n\n/**\n * Create a map with two partitions: a and b.\n * The set with bKeys determines which keys/values are read/written to map b,\n * all other values are read/written to map a\n *\n * For example:\n *\n * const a = new Map()\n * const b = new Map()\n * const p = new PartitionedMap(a, b, new Set(['x', 'y']))\n *\n * In this case, values `x` and `y` are read/written to map `b`,\n * all other values are read/written to map `a`.\n */\nexport class PartitionedMap {\n /**\n * @param {Map} a\n * @param {Map} b\n * @param {Set} bKeys\n */\n constructor(a, b, bKeys) {\n this.a = a;\n this.b = b;\n this.bKeys = bKeys;\n this[Symbol.iterator] = this.entries;\n }\n get(key) {\n return this.bKeys.has(key) ? this.b.get(key) : this.a.get(key);\n }\n set(key, value) {\n if (this.bKeys.has(key)) {\n this.b.set(key, value);\n } else {\n this.a.set(key, value);\n }\n return this;\n }\n has(key) {\n return this.b.has(key) || this.a.has(key);\n }\n keys() {\n return new Set([...this.a.keys(), ...this.b.keys()])[Symbol.iterator]();\n }\n entries() {\n return mapIterator(this.keys(), key => [key, this.get(key)]);\n }\n forEach(callback) {\n for (var key of this.keys()) {\n callback(this.get(key), key, this);\n }\n }\n delete(key) {\n return this.bKeys.has(key) ? this.b.delete(key) : this.a.delete(key);\n }\n clear() {\n this.a.clear();\n this.b.clear();\n }\n get size() {\n return [...this.keys()].length;\n }\n}\n\n/**\n * Create a new iterator that maps over the provided iterator, applying a mapping function to each item\n */\nfunction mapIterator(it, callback) {\n return {\n next: () => {\n var n = it.next();\n return n.done ? n : {\n value: callback(n.value),\n done: false\n };\n }\n };\n}\n\n/**\n * Creates an empty map, or whatever your platform's polyfill is.\n *\n * @returns an empty Map or Map like object.\n */\nexport function createEmptyMap() {\n return new Map();\n}\n\n/**\n * Creates a Map from the given object.\n *\n * @param { Map | { [key: string]: unknown } | undefined } mapOrObject\n * @returns\n */\nexport function createMap(mapOrObject) {\n if (!mapOrObject) {\n return createEmptyMap();\n }\n if (isMap(mapOrObject)) {\n return mapOrObject;\n }\n if (isObject(mapOrObject)) {\n return new ObjectWrappingMap(mapOrObject);\n }\n throw new Error('createMap can create maps from objects or Maps');\n}\n\n/**\n * Unwraps a map into an object.\n *\n * @param {Map} map\n * @returns { [key: string]: unknown }\n */\nexport function toObject(map) {\n if (map instanceof ObjectWrappingMap) {\n return map.wrappedObject;\n }\n var object = {};\n for (var key of map.keys()) {\n var value = map.get(key);\n setSafeProperty(object, key, value);\n }\n return object;\n}\n\n/**\n * Copies the contents of key-value pairs from each `objects` in to `map`.\n *\n * Object is `objects` can be a `Map` or object.\n *\n * This is the `Map` analog to `Object.assign`.\n */\nexport function assign(map) {\n for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n objects[_key - 1] = arguments[_key];\n }\n for (var args of objects) {\n if (!args) {\n continue;\n }\n if (isMap(args)) {\n for (var key of args.keys()) {\n map.set(key, args.get(key));\n }\n } else if (isObject(args)) {\n for (var _key2 of Object.keys(args)) {\n map.set(_key2, args[_key2]);\n }\n }\n }\n return map;\n}","// type checks for all known types\n//\n// note that:\n//\n// - check by duck-typing on a property like `isUnit`, instead of checking instanceof.\n// instanceof cannot be used because that would not allow to pass data from\n// one instance of math.js to another since each has it's own instance of Unit.\n// - check the `isUnit` property via the constructor, so there will be no\n// matches for \"fake\" instances like plain objects with a property `isUnit`.\n// That is important for security reasons.\n// - It must not be possible to override the type checks used internally,\n// for security reasons, so these functions are not exposed in the expression\n// parser.\n\nimport { ObjectWrappingMap } from './map.js';\nexport function isNumber(x) {\n return typeof x === 'number';\n}\nexport function isBigNumber(x) {\n if (!x || typeof x !== 'object' || typeof x.constructor !== 'function') {\n return false;\n }\n if (x.isBigNumber === true && typeof x.constructor.prototype === 'object' && x.constructor.prototype.isBigNumber === true) {\n return true;\n }\n if (typeof x.constructor.isDecimal === 'function' && x.constructor.isDecimal(x) === true) {\n return true;\n }\n return false;\n}\nexport function isBigInt(x) {\n return typeof x === 'bigint';\n}\nexport function isComplex(x) {\n return x && typeof x === 'object' && Object.getPrototypeOf(x).isComplex === true || false;\n}\nexport function isFraction(x) {\n return x && typeof x === 'object' && Object.getPrototypeOf(x).isFraction === true || false;\n}\nexport function isUnit(x) {\n return x && x.constructor.prototype.isUnit === true || false;\n}\nexport function isString(x) {\n return typeof x === 'string';\n}\nexport var isArray = Array.isArray;\nexport function isMatrix(x) {\n return x && x.constructor.prototype.isMatrix === true || false;\n}\n\n/**\n * Test whether a value is a collection: an Array or Matrix\n * @param {*} x\n * @returns {boolean} isCollection\n */\nexport function isCollection(x) {\n return Array.isArray(x) || isMatrix(x);\n}\nexport function isDenseMatrix(x) {\n return x && x.isDenseMatrix && x.constructor.prototype.isMatrix === true || false;\n}\nexport function isSparseMatrix(x) {\n return x && x.isSparseMatrix && x.constructor.prototype.isMatrix === true || false;\n}\nexport function isRange(x) {\n return x && x.constructor.prototype.isRange === true || false;\n}\nexport function isIndex(x) {\n return x && x.constructor.prototype.isIndex === true || false;\n}\nexport function isBoolean(x) {\n return typeof x === 'boolean';\n}\nexport function isResultSet(x) {\n return x && x.constructor.prototype.isResultSet === true || false;\n}\nexport function isHelp(x) {\n return x && x.constructor.prototype.isHelp === true || false;\n}\nexport function isFunction(x) {\n return typeof x === 'function';\n}\nexport function isDate(x) {\n return x instanceof Date;\n}\nexport function isRegExp(x) {\n return x instanceof RegExp;\n}\nexport function isObject(x) {\n return !!(x && typeof x === 'object' && x.constructor === Object && !isComplex(x) && !isFraction(x));\n}\n\n/**\n * Returns `true` if the passed object appears to be a Map (i.e. duck typing).\n *\n * Methods looked for are `get`, `set`, `keys` and `has`.\n *\n * @param {Map | object} object\n * @returns\n */\nexport function isMap(object) {\n // We can use the fast instanceof, or a slower duck typing check.\n // The duck typing method needs to cover enough methods to not be confused with DenseMatrix.\n if (!object) {\n return false;\n }\n return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === 'function' && typeof object.get === 'function' && typeof object.keys === 'function' && typeof object.has === 'function';\n}\nexport function isPartitionedMap(object) {\n return isMap(object) && isMap(object.a) && isMap(object.b);\n}\nexport function isObjectWrappingMap(object) {\n return isMap(object) && isObject(object.wrappedObject);\n}\nexport function isNull(x) {\n return x === null;\n}\nexport function isUndefined(x) {\n return x === undefined;\n}\nexport function isAccessorNode(x) {\n return x && x.isAccessorNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isArrayNode(x) {\n return x && x.isArrayNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isAssignmentNode(x) {\n return x && x.isAssignmentNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isBlockNode(x) {\n return x && x.isBlockNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isConditionalNode(x) {\n return x && x.isConditionalNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isConstantNode(x) {\n return x && x.isConstantNode === true && x.constructor.prototype.isNode === true || false;\n}\n\n/* Very specialized: returns true for those nodes which in the numerator of\n a fraction means that the division in that fraction has precedence over implicit\n multiplication, e.g. -2/3 x parses as (-2/3) x and 3/4 x parses as (3/4) x but\n 6!/8 x parses as 6! / (8x). It is located here because it is shared between\n parse.js and OperatorNode.js (for parsing and printing, respectively).\n\n This should *not* be exported from mathjs, unlike most of the tests here.\n Its name does not start with 'is' to prevent utils/snapshot.js from thinking\n it should be exported.\n*/\nexport function rule2Node(node) {\n return isConstantNode(node) || isOperatorNode(node) && node.args.length === 1 && isConstantNode(node.args[0]) && '-+~'.includes(node.op);\n}\nexport function isFunctionAssignmentNode(x) {\n return x && x.isFunctionAssignmentNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isFunctionNode(x) {\n return x && x.isFunctionNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isIndexNode(x) {\n return x && x.isIndexNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isNode(x) {\n return x && x.isNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isObjectNode(x) {\n return x && x.isObjectNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isOperatorNode(x) {\n return x && x.isOperatorNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isParenthesisNode(x) {\n return x && x.isParenthesisNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isRangeNode(x) {\n return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isRelationalNode(x) {\n return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isSymbolNode(x) {\n return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;\n}\nexport function isChain(x) {\n return x && x.constructor.prototype.isChain === true || false;\n}\nexport function typeOf(x) {\n var t = typeof x;\n if (t === 'object') {\n if (x === null) return 'null';\n if (isBigNumber(x)) return 'BigNumber'; // Special: weird mashup with Decimal\n if (x.constructor && x.constructor.name) return x.constructor.name;\n return 'Object'; // just in case\n }\n return t; // can be 'string', 'number', 'boolean', 'function', 'bigint', ...\n}","import { isBigNumber, isObject } from './is.js';\n\n/**\n * Clone an object\n *\n * clone(x)\n *\n * Can clone any primitive type, array, and object.\n * If x has a function clone, this function will be invoked to clone the object.\n *\n * @param {*} x\n * @return {*} clone\n */\nexport function clone(x) {\n var type = typeof x;\n\n // immutable primitive types\n if (type === 'number' || type === 'bigint' || type === 'string' || type === 'boolean' || x === null || x === undefined) {\n return x;\n }\n\n // use clone function of the object when available\n if (typeof x.clone === 'function') {\n return x.clone();\n }\n\n // array\n if (Array.isArray(x)) {\n return x.map(function (value) {\n return clone(value);\n });\n }\n if (x instanceof Date) return new Date(x.valueOf());\n if (isBigNumber(x)) return x; // bignumbers are immutable\n\n // object\n if (isObject(x)) {\n return mapObject(x, clone);\n }\n if (type === 'function') {\n // we assume that the function is immutable\n return x;\n }\n throw new TypeError(\"Cannot clone: unknown type of value (value: \".concat(x, \")\"));\n}\n\n/**\n * Apply map to all properties of an object\n * @param {Object} object\n * @param {function} callback\n * @return {Object} Returns a copy of the object with mapped properties\n */\nexport function mapObject(object, callback) {\n var clone = {};\n for (var key in object) {\n if (hasOwnProperty(object, key)) {\n clone[key] = callback(object[key]);\n }\n }\n return clone;\n}\n\n/**\n * Extend object a with the properties of object b\n * @param {Object} a\n * @param {Object} b\n * @return {Object} a\n */\nexport function extend(a, b) {\n for (var prop in b) {\n if (hasOwnProperty(b, prop)) {\n a[prop] = b[prop];\n }\n }\n return a;\n}\n\n/**\n * Deep extend an object a with the properties of object b\n * @param {Object} a\n * @param {Object} b\n * @returns {Object}\n */\nexport function deepExtend(a, b) {\n // TODO: add support for Arrays to deepExtend\n if (Array.isArray(b)) {\n throw new TypeError('Arrays are not supported by deepExtend');\n }\n for (var prop in b) {\n // We check against prop not being in Object.prototype or Function.prototype\n // to prevent polluting for example Object.__proto__.\n if (hasOwnProperty(b, prop) && !(prop in Object.prototype) && !(prop in Function.prototype)) {\n if (b[prop] && b[prop].constructor === Object) {\n if (a[prop] === undefined) {\n a[prop] = {};\n }\n if (a[prop] && a[prop].constructor === Object) {\n deepExtend(a[prop], b[prop]);\n } else {\n a[prop] = b[prop];\n }\n } else if (Array.isArray(b[prop])) {\n throw new TypeError('Arrays are not supported by deepExtend');\n } else {\n a[prop] = b[prop];\n }\n }\n }\n return a;\n}\n\n/**\n * Deep test equality of all fields in two pairs of arrays or objects.\n * Compares values and functions strictly (ie. 2 is not the same as '2').\n * @param {Array | Object} a\n * @param {Array | Object} b\n * @returns {boolean}\n */\nexport function deepStrictEqual(a, b) {\n var prop, i, len;\n if (Array.isArray(a)) {\n if (!Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (i = 0, len = a.length; i < len; i++) {\n if (!deepStrictEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n } else if (typeof a === 'function') {\n return a === b;\n } else if (a instanceof Object) {\n if (Array.isArray(b) || !(b instanceof Object)) {\n return false;\n }\n for (prop in a) {\n // noinspection JSUnfilteredForInLoop\n if (!(prop in b) || !deepStrictEqual(a[prop], b[prop])) {\n return false;\n }\n }\n for (prop in b) {\n // noinspection JSUnfilteredForInLoop\n if (!(prop in a)) {\n return false;\n }\n }\n return true;\n } else {\n return a === b;\n }\n}\n\n/**\n * Recursively flatten a nested object.\n * @param {Object} nestedObject\n * @return {Object} Returns the flattened object\n */\nexport function deepFlatten(nestedObject) {\n var flattenedObject = {};\n _deepFlatten(nestedObject, flattenedObject);\n return flattenedObject;\n}\n\n// helper function used by deepFlatten\nfunction _deepFlatten(nestedObject, flattenedObject) {\n for (var prop in nestedObject) {\n if (hasOwnProperty(nestedObject, prop)) {\n var value = nestedObject[prop];\n if (typeof value === 'object' && value !== null) {\n _deepFlatten(value, flattenedObject);\n } else {\n flattenedObject[prop] = value;\n }\n }\n }\n}\n\n/**\n * Test whether the current JavaScript engine supports Object.defineProperty\n * @returns {boolean} returns true if supported\n */\nexport function canDefineProperty() {\n // test needed for broken IE8 implementation\n try {\n if (Object.defineProperty) {\n Object.defineProperty({}, 'x', {\n get: function get() {\n return null;\n }\n });\n return true;\n }\n } catch (e) {}\n return false;\n}\n\n/**\n * Attach a lazy loading property to a constant.\n * The given function `fn` is called once when the property is first requested.\n *\n * @param {Object} object Object where to add the property\n * @param {string} prop Property name\n * @param {Function} valueResolver Function returning the property value. Called\n * without arguments.\n */\nexport function lazy(object, prop, valueResolver) {\n var _uninitialized = true;\n var _value;\n Object.defineProperty(object, prop, {\n get: function get() {\n if (_uninitialized) {\n _value = valueResolver();\n _uninitialized = false;\n }\n return _value;\n },\n set: function set(value) {\n _value = value;\n _uninitialized = false;\n },\n configurable: true,\n enumerable: true\n });\n}\n\n/**\n * Traverse a path into an object.\n * When a namespace is missing, it will be created\n * @param {Object} object\n * @param {string | string[]} path A dot separated string like 'name.space'\n * @return {Object} Returns the object at the end of the path\n */\nexport function traverse(object, path) {\n if (path && typeof path === 'string') {\n return traverse(object, path.split('.'));\n }\n var obj = object;\n if (path) {\n for (var i = 0; i < path.length; i++) {\n var key = path[i];\n if (!(key in obj)) {\n obj[key] = {};\n }\n obj = obj[key];\n }\n }\n return obj;\n}\n\n/**\n * A safe hasOwnProperty\n * @param {Object} object\n * @param {string} property\n */\nexport function hasOwnProperty(object, property) {\n return object && Object.hasOwnProperty.call(object, property);\n}\n\n/**\n * Test whether an object is a factory. a factory has fields:\n *\n * - factory: function (type: Object, config: Object, load: function, typed: function [, math: Object]) (required)\n * - name: string (optional)\n * - path: string A dot separated path (optional)\n * - math: boolean If true (false by default), the math namespace is passed\n * as fifth argument of the factory function\n *\n * @param {*} object\n * @returns {boolean}\n */\nexport function isLegacyFactory(object) {\n return object && typeof object.factory === 'function';\n}\n\n/**\n * Get a nested property from an object\n * @param {Object} object\n * @param {string | string[]} path\n * @returns {Object}\n */\nexport function get(object, path) {\n if (typeof path === 'string') {\n if (isPath(path)) {\n return get(object, path.split('.'));\n } else {\n return object[path];\n }\n }\n var child = object;\n for (var i = 0; i < path.length; i++) {\n var key = path[i];\n child = child ? child[key] : undefined;\n }\n return child;\n}\n\n/**\n * Set a nested property in an object\n * Mutates the object itself\n * If the path doesn't exist, it will be created\n * @param {Object} object\n * @param {string | string[]} path\n * @param {*} value\n * @returns {Object}\n */\nexport function set(object, path, value) {\n if (typeof path === 'string') {\n if (isPath(path)) {\n return set(object, path.split('.'), value);\n } else {\n object[path] = value;\n return object;\n }\n }\n var child = object;\n for (var i = 0; i < path.length - 1; i++) {\n var key = path[i];\n if (child[key] === undefined) {\n child[key] = {};\n }\n child = child[key];\n }\n if (path.length > 0) {\n var lastKey = path[path.length - 1];\n child[lastKey] = value;\n }\n return object;\n}\n\n/**\n * Create an object composed of the picked object properties\n * @param {Object} object\n * @param {string[]} properties\n * @param {function} [transform] Optional value to transform a value when picking it\n * @return {Object}\n */\nexport function pick(object, properties, transform) {\n var copy = {};\n for (var i = 0; i < properties.length; i++) {\n var key = properties[i];\n var value = get(object, key);\n if (value !== undefined) {\n set(copy, key, transform ? transform(value, key) : value);\n }\n }\n return copy;\n}\n\n/**\n * Shallow version of pick, creating an object composed of the picked object properties\n * but not for nested properties\n * @param {Object} object\n * @param {string[]} properties\n * @return {Object}\n */\nexport function pickShallow(object, properties) {\n var copy = {};\n for (var i = 0; i < properties.length; i++) {\n var key = properties[i];\n var value = object[key];\n if (value !== undefined) {\n copy[key] = value;\n }\n }\n return copy;\n}\n\n// helper function to test whether a string contains a path like 'user.name'\nfunction isPath(str) {\n return str.includes('.');\n}","import { clone, deepExtend } from '../../utils/object.js';\nimport { DEFAULT_CONFIG } from '../config.js';\nexport var MATRIX_OPTIONS = ['Matrix', 'Array']; // valid values for option matrix\nexport var NUMBER_OPTIONS = ['number', 'BigNumber', 'bigint', 'Fraction']; // valid values for option number\n\nexport function configFactory(config, emit) {\n /**\n * Set configuration options for math.js, and get current options.\n * Will emit a 'config' event, with arguments (curr, prev, changes).\n *\n * This function is only available on a mathjs instance created using `create`.\n *\n * Syntax:\n *\n * math.config(config: Object): Object\n *\n * Examples:\n *\n * import { create, all } from 'mathjs'\n *\n * // create a mathjs instance\n * const math = create(all)\n *\n * math.config().number // outputs 'number'\n * math.evaluate('0.4') // outputs number 0.4\n * math.config({number: 'Fraction'})\n * math.evaluate('0.4') // outputs Fraction 2/5\n *\n * @param {Object} [options] Available options:\n * {number} relTol\n * Minimum relative difference between two\n * compared values, used by all comparison functions.\n * {number} absTol\n * Minimum absolute difference between two\n * compared values, used by all comparison functions.\n * {string} matrix\n * A string 'Matrix' (default) or 'Array'.\n * {string} number\n * A string 'number' (default), 'BigNumber', 'bigint', or 'Fraction'\n * {number} precision\n * The number of significant digits for BigNumbers.\n * Not applicable for Numbers.\n * {string} parenthesis\n * How to display parentheses in LaTeX and string\n * output.\n * {string} randomSeed\n * Random seed for seeded pseudo random number generator.\n * Set to null to randomly seed.\n * @return {Object} Returns the current configuration\n */\n function _config(options) {\n if (options) {\n if (options.epsilon !== undefined) {\n // this if is only for backwards compatibility, it can be removed in the future.\n console.warn('Warning: The configuration option \"epsilon\" is deprecated. Use \"relTol\" and \"absTol\" instead.');\n var optionsFix = clone(options);\n optionsFix.relTol = options.epsilon;\n optionsFix.absTol = options.epsilon * 1e-3;\n delete optionsFix.epsilon;\n return _config(optionsFix);\n }\n if (options.legacySubset === true) {\n // this if is only for backwards compatibility, it can be removed in the future.\n console.warn('Warning: The configuration option \"legacySubset\" is for compatibility only and might be deprecated in the future.');\n }\n var prev = clone(config);\n\n // validate some of the options\n validateOption(options, 'matrix', MATRIX_OPTIONS);\n validateOption(options, 'number', NUMBER_OPTIONS);\n\n // merge options\n deepExtend(config, options);\n var curr = clone(config);\n var changes = clone(options);\n\n // emit 'config' event\n emit('config', curr, prev, changes);\n return curr;\n } else {\n return clone(config);\n }\n }\n\n // attach the valid options to the function so they can be extended\n _config.MATRIX_OPTIONS = MATRIX_OPTIONS;\n _config.NUMBER_OPTIONS = NUMBER_OPTIONS;\n\n // attach the config properties as readonly properties to the config function\n Object.keys(DEFAULT_CONFIG).forEach(key => {\n Object.defineProperty(_config, key, {\n get: () => config[key],\n enumerable: true,\n configurable: true\n });\n });\n return _config;\n}\n\n/**\n * Validate an option\n * @param {Object} options Object with options\n * @param {string} name Name of the option to validate\n * @param {Array.} values Array with valid values for this option\n */\nfunction validateOption(options, name, values) {\n if (options[name] !== undefined && !values.includes(options[name])) {\n // unknown value\n console.warn('Warning: Unknown value \"' + options[name] + '\" for configuration option \"' + name + '\". ' + 'Available options: ' + values.map(value => JSON.stringify(value)).join(', ') + '.');\n }\n}","import { isBigNumber, isNumber, isObject } from './is.js';\n\n/**\n * @typedef {{sign: '+' | '-' | '', coefficients: number[], exponent: number}} SplitValue\n */\n\n/**\n * Check if a number is integer\n * @param {number | boolean} value\n * @return {boolean} isInteger\n */\nexport function isInteger(value) {\n if (typeof value === 'boolean') {\n return true;\n }\n return Number.isFinite(value) ? value === Math.round(value) : false;\n}\n\n/**\n * Ensure the number type is compatible with the provided value.\n * If not, return 'number' instead.\n *\n * For example:\n *\n * safeNumberType('2.3', { number: 'bigint', numberFallback: 'number' })\n *\n * will return 'number' and not 'bigint' because trying to create a bigint with\n * value 2.3 would throw an exception.\n *\n * @param {string} numberStr\n * @param {{\n * number: 'number' | 'BigNumber' | 'bigint' | 'Fraction'\n * numberFallback: 'number' | 'BigNumber'\n * }} config\n * @returns {'number' | 'BigNumber' | 'bigint' | 'Fraction'}\n */\nexport function safeNumberType(numberStr, config) {\n if (config.number === 'bigint') {\n try {\n BigInt(numberStr);\n } catch (_unused) {\n return config.numberFallback;\n }\n }\n return config.number;\n}\n\n/**\n * Calculate the sign of a number\n * @param {number} x\n * @returns {number}\n */\nexport var sign = Math.sign || function (x) {\n if (x > 0) {\n return 1;\n } else if (x < 0) {\n return -1;\n } else {\n return 0;\n }\n};\n\n/**\n * Calculate the base-2 logarithm of a number\n * @param {number} x\n * @returns {number}\n */\nexport var log2 = Math.log2 || function log2(x) {\n return Math.log(x) / Math.LN2;\n};\n\n/**\n * Calculate the base-10 logarithm of a number\n * @param {number} x\n * @returns {number}\n */\nexport var log10 = Math.log10 || function log10(x) {\n return Math.log(x) / Math.LN10;\n};\n\n/**\n * Calculate the natural logarithm of a number + 1\n * @param {number} x\n * @returns {number}\n */\nexport var log1p = Math.log1p || function (x) {\n return Math.log(x + 1);\n};\n\n/**\n * Calculate cubic root for a number\n *\n * Code from es6-shim.js:\n * https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1564-L1577\n *\n * @param {number} x\n * @returns {number} Returns the cubic root of x\n */\nexport var cbrt = Math.cbrt || function cbrt(x) {\n if (x === 0) {\n return x;\n }\n var negate = x < 0;\n var result;\n if (negate) {\n x = -x;\n }\n if (Number.isFinite(x)) {\n result = Math.exp(Math.log(x) / 3);\n // from https://en.wikipedia.org/wiki/Cube_root#Numerical_methods\n result = (x / (result * result) + 2 * result) / 3;\n } else {\n result = x;\n }\n return negate ? -result : result;\n};\n\n/**\n * Calculates exponentiation minus 1\n * @param {number} x\n * @return {number} res\n */\nexport var expm1 = Math.expm1 || function expm1(x) {\n return x >= 2e-4 || x <= -2e-4 ? Math.exp(x) - 1 : x + x * x / 2 + x * x * x / 6;\n};\n\n/**\n * Formats a number in a given base\n * @param {number} n\n * @param {number} base\n * @param {number} size\n * @returns {string}\n */\nfunction formatNumberToBase(n, base, size) {\n var prefixes = {\n 2: '0b',\n 8: '0o',\n 16: '0x'\n };\n var prefix = prefixes[base];\n var suffix = '';\n if (size) {\n if (size < 1) {\n throw new Error('size must be in greater than 0');\n }\n if (!isInteger(size)) {\n throw new Error('size must be an integer');\n }\n if (n > 2 ** (size - 1) - 1 || n < -(2 ** (size - 1))) {\n throw new Error(\"Value must be in range [-2^\".concat(size - 1, \", 2^\").concat(size - 1, \"-1]\"));\n }\n if (!isInteger(n)) {\n throw new Error('Value must be an integer');\n }\n if (n < 0) {\n n = n + 2 ** size;\n }\n suffix = \"i\".concat(size);\n }\n var sign = '';\n if (n < 0) {\n n = -n;\n sign = '-';\n }\n return \"\".concat(sign).concat(prefix).concat(n.toString(base)).concat(suffix);\n}\n\n/**\n * Convert a number to a formatted string representation.\n *\n * Syntax:\n *\n * format(value)\n * format(value, options)\n * format(value, precision)\n * format(value, fn)\n *\n * Where:\n *\n * {number} value The value to be formatted\n * {Object} options An object with formatting options. Available options:\n * {string} notation\n * Number notation. Choose from:\n * 'fixed' Always use regular number notation.\n * For example '123.40' and '14000000'\n * 'exponential' Always use exponential notation.\n * For example '1.234e+2' and '1.4e+7'\n * 'engineering' Always use engineering notation.\n * For example '123.4e+0' and '14.0e+6'\n * 'auto' (default) Regular number notation for numbers\n * having an absolute value between\n * `lowerExp` and `upperExp` bounds, and\n * uses exponential notation elsewhere.\n * Lower bound is included, upper bound\n * is excluded.\n * For example '123.4' and '1.4e7'.\n * 'bin', 'oct, or\n * 'hex' Format the number using binary, octal,\n * or hexadecimal notation.\n * For example '0b1101' and '0x10fe'.\n * {number} wordSize The word size in bits to use for formatting\n * in binary, octal, or hexadecimal notation.\n * To be used only with 'bin', 'oct', or 'hex'\n * values for 'notation' option. When this option\n * is defined the value is formatted as a signed\n * twos complement integer of the given word size\n * and the size suffix is appended to the output.\n * For example\n * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.\n * Default value is undefined.\n * {number} precision A number between 0 and 16 to round\n * the digits of the number.\n * In case of notations 'exponential',\n * 'engineering', and 'auto',\n * `precision` defines the total\n * number of significant digits returned.\n * In case of notation 'fixed',\n * `precision` defines the number of\n * significant digits after the decimal\n * point.\n * `precision` is undefined by default,\n * not rounding any digits.\n * {number} lowerExp Exponent determining the lower boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `-3`.\n * {number} upperExp Exponent determining the upper boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `5`.\n * {Function} fn A custom formatting function. Can be used to override the\n * built-in notations. Function `fn` is called with `value` as\n * parameter and must return a string. Is useful for example to\n * format all values inside a matrix in a particular way.\n *\n * Examples:\n *\n * format(6.4) // '6.4'\n * format(1240000) // '1.24e6'\n * format(1/3) // '0.3333333333333333'\n * format(1/3, 3) // '0.333'\n * format(21385, 2) // '21000'\n * format(12.071, {notation: 'fixed'}) // '12'\n * format(2.3, {notation: 'fixed', precision: 2}) // '2.30'\n * format(52.8, {notation: 'exponential'}) // '5.28e+1'\n * format(12345678, {notation: 'engineering'}) // '12.345678e+6'\n *\n * @param {number} value\n * @param {Object | Function | number} [options]\n * @return {string} str The formatted value\n */\nexport function format(value, options) {\n if (typeof options === 'function') {\n // handle format(value, fn)\n return options(value);\n }\n\n // handle special cases\n if (value === Infinity) {\n return 'Infinity';\n } else if (value === -Infinity) {\n return '-Infinity';\n } else if (isNaN(value)) {\n return 'NaN';\n }\n var {\n notation,\n precision,\n wordSize\n } = normalizeFormatOptions(options);\n\n // handle the various notations\n switch (notation) {\n case 'fixed':\n return toFixed(value, precision);\n case 'exponential':\n return toExponential(value, precision);\n case 'engineering':\n return toEngineering(value, precision);\n case 'bin':\n return formatNumberToBase(value, 2, wordSize);\n case 'oct':\n return formatNumberToBase(value, 8, wordSize);\n case 'hex':\n return formatNumberToBase(value, 16, wordSize);\n case 'auto':\n // remove trailing zeros after the decimal point\n return toPrecision(value, precision, options).replace(/((\\.\\d*?)(0+))($|e)/, function () {\n var digits = arguments[2];\n var e = arguments[4];\n return digits !== '.' ? digits + e : e;\n });\n default:\n throw new Error('Unknown notation \"' + notation + '\". ' + 'Choose \"auto\", \"exponential\", \"fixed\", \"bin\", \"oct\", or \"hex.');\n }\n}\n\n/**\n * Normalize format options into an object:\n * {\n * notation: string,\n * precision: number | undefined,\n * wordSize: number | undefined\n * }\n */\nexport function normalizeFormatOptions(options) {\n // default values for options\n var notation = 'auto';\n var precision;\n var wordSize;\n if (options !== undefined) {\n if (isNumber(options)) {\n precision = options;\n } else if (isBigNumber(options)) {\n precision = options.toNumber();\n } else if (isObject(options)) {\n if (options.precision !== undefined) {\n precision = _toNumberOrThrow(options.precision, () => {\n throw new Error('Option \"precision\" must be a number or BigNumber');\n });\n }\n if (options.wordSize !== undefined) {\n wordSize = _toNumberOrThrow(options.wordSize, () => {\n throw new Error('Option \"wordSize\" must be a number or BigNumber');\n });\n }\n if (options.notation) {\n notation = options.notation;\n }\n } else {\n throw new Error('Unsupported type of options, number, BigNumber, or object expected');\n }\n }\n return {\n notation,\n precision,\n wordSize\n };\n}\n\n/**\n * Split a number into sign, coefficients, and exponent\n * @param {number | string} value\n * @return {SplitValue}\n * Returns an object containing sign, coefficients, and exponent\n */\nexport function splitNumber(value) {\n // parse the input value\n var match = String(value).toLowerCase().match(/^(-?)(\\d+\\.?\\d*)(e([+-]?\\d+))?$/);\n if (!match) {\n throw new SyntaxError('Invalid number ' + value);\n }\n var sign = match[1];\n var digits = match[2];\n var exponent = parseFloat(match[4] || '0');\n var dot = digits.indexOf('.');\n exponent += dot !== -1 ? dot - 1 : digits.length - 1;\n var coefficients = digits.replace('.', '') // remove the dot (must be removed before removing leading zeros)\n .replace(/^0*/, function (zeros) {\n // remove leading zeros, add their count to the exponent\n exponent -= zeros.length;\n return '';\n }).replace(/0*$/, '') // remove trailing zeros\n .split('').map(function (d) {\n return parseInt(d);\n });\n if (coefficients.length === 0) {\n coefficients.push(0);\n exponent++;\n }\n return {\n sign,\n coefficients,\n exponent\n };\n}\n\n/**\n * Format a number in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'\n * @param {number | string} value\n * @param {number} [precision] Optional number of significant figures to return.\n */\nexport function toEngineering(value, precision) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n var split = splitNumber(value);\n var rounded = roundDigits(split, precision);\n var e = rounded.exponent;\n var c = rounded.coefficients;\n\n // find nearest lower multiple of 3 for exponent\n var newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;\n if (isNumber(precision)) {\n // add zeroes to give correct sig figs\n while (precision > c.length || e - newExp + 1 > c.length) {\n c.push(0);\n }\n } else {\n // concatenate coefficients with necessary zeros\n // add zeros if necessary (for example: 1e+8 -> 100e+6)\n var missingZeros = Math.abs(e - newExp) - (c.length - 1);\n for (var i = 0; i < missingZeros; i++) {\n c.push(0);\n }\n }\n\n // find difference in exponents\n var expDiff = Math.abs(e - newExp);\n var decimalIdx = 1;\n\n // push decimal index over by expDiff times\n while (expDiff > 0) {\n decimalIdx++;\n expDiff--;\n }\n\n // if all coefficient values are zero after the decimal point and precision is unset, don't add a decimal value.\n // otherwise concat with the rest of the coefficients\n var decimals = c.slice(decimalIdx).join('');\n var decimalVal = isNumber(precision) && decimals.length || decimals.match(/[1-9]/) ? '.' + decimals : '';\n var str = c.slice(0, decimalIdx).join('') + decimalVal + 'e' + (e >= 0 ? '+' : '') + newExp.toString();\n return rounded.sign + str;\n}\n\n/**\n * Format a number with fixed notation.\n * @param {number | string} value\n * @param {number} [precision=undefined] Optional number of decimals after the\n * decimal point. null by default.\n */\nexport function toFixed(value, precision) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n var splitValue = splitNumber(value);\n var rounded = typeof precision === 'number' ? roundDigits(splitValue, splitValue.exponent + 1 + precision) : splitValue;\n var c = rounded.coefficients;\n var p = rounded.exponent + 1; // exponent may have changed\n\n // append zeros if needed\n var pp = p + (precision || 0);\n if (c.length < pp) {\n c = c.concat(zeros(pp - c.length));\n }\n\n // prepend zeros if needed\n if (p < 0) {\n c = zeros(-p + 1).concat(c);\n p = 1;\n }\n\n // insert a dot if needed\n if (p < c.length) {\n c.splice(p, 0, p === 0 ? '0.' : '.');\n }\n return rounded.sign + c.join('');\n}\n\n/**\n * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'\n * @param {number | string} value\n * @param {number} [precision] Number of digits in formatted output.\n * If not provided, the maximum available digits\n * is used.\n */\nexport function toExponential(value, precision) {\n if (isNaN(value) || !Number.isFinite(Number(value))) {\n return String(value);\n }\n\n // round if needed, else create a clone\n var split = splitNumber(value);\n var rounded = precision ? roundDigits(split, precision) : split;\n var c = rounded.coefficients;\n var e = rounded.exponent;\n\n // append zeros if needed\n if (c.length < precision) {\n c = c.concat(zeros(precision - c.length));\n }\n\n // format as `C.CCCe+EEE` or `C.CCCe-EEE`\n var first = c.shift();\n return rounded.sign + first + (c.length > 0 ? '.' + c.join('') : '') + 'e' + (e >= 0 ? '+' : '') + e;\n}\n\n/**\n * Format a number with a certain precision\n * @param {number | string} value\n * @param {number} [precision=undefined] Optional number of digits.\n * @param {{lowerExp: number | undefined, upperExp: number | undefined}} [options]\n * By default:\n * lowerExp = -3 (incl)\n * upper = +5 (excl)\n * @return {string}\n */\nexport function toPrecision(value, precision, options) {\n if (isNaN(value) || !Number.isFinite(value)) {\n return String(value);\n }\n\n // determine lower and upper bound for exponential notation.\n var lowerExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.lowerExp, -3);\n var upperExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.upperExp, 5);\n var split = splitNumber(value);\n var rounded = precision ? roundDigits(split, precision) : split;\n if (rounded.exponent < lowerExp || rounded.exponent >= upperExp) {\n // exponential notation\n return toExponential(value, precision);\n } else {\n var c = rounded.coefficients;\n var e = rounded.exponent;\n\n // append trailing zeros\n if (c.length < precision) {\n c = c.concat(zeros(precision - c.length));\n }\n\n // append trailing zeros\n // TODO: simplify the next statement\n c = c.concat(zeros(e - c.length + 1 + (c.length < precision ? precision - c.length : 0)));\n\n // prepend zeros\n c = zeros(-e).concat(c);\n var dot = e > 0 ? e : 0;\n if (dot < c.length - 1) {\n c.splice(dot + 1, 0, '.');\n }\n return rounded.sign + c.join('');\n }\n}\n\n/**\n * Round the number of digits of a number *\n * @param {SplitValue} split A value split with .splitNumber(value)\n * @param {number} precision A positive integer\n * @return {SplitValue}\n * Returns an object containing sign, coefficients, and exponent\n * with rounded digits\n */\nexport function roundDigits(split, precision) {\n // create a clone\n var rounded = {\n sign: split.sign,\n coefficients: split.coefficients,\n exponent: split.exponent\n };\n var c = rounded.coefficients;\n\n // prepend zeros if needed\n while (precision <= 0) {\n c.unshift(0);\n rounded.exponent++;\n precision++;\n }\n if (c.length > precision) {\n var removed = c.splice(precision, c.length - precision);\n if (removed[0] >= 5) {\n var i = precision - 1;\n c[i]++;\n while (c[i] === 10) {\n c.pop();\n if (i === 0) {\n c.unshift(0);\n rounded.exponent++;\n i++;\n }\n i--;\n c[i]++;\n }\n }\n }\n return rounded;\n}\n\n/**\n * Create an array filled with zeros.\n * @param {number} length\n * @return {Array}\n */\nfunction zeros(length) {\n var arr = [];\n for (var i = 0; i < length; i++) {\n arr.push(0);\n }\n return arr;\n}\n\n/**\n * Count the number of significant digits of a number.\n *\n * For example:\n * 2.34 returns 3\n * 0.0034 returns 2\n * 120.5e+30 returns 4\n *\n * @param {number} value\n * @return {number} digits Number of significant digits\n */\nexport function digits(value) {\n return value.toExponential().replace(/e.*$/, '') // remove exponential notation\n .replace(/^0\\.?0*|\\./, '') // remove decimal point and leading zeros\n .length;\n}\n\n/**\n * Compares two floating point numbers.\n * @param {number} a - First value to compare\n * @param {number} b - Second value to compare\n * @param {number} [relTol=1e-09] - The relative tolerance, indicating the maximum allowed difference relative to the larger absolute value. Must be greater than 0.\n * @param {number} [absTol=1e-12] - The minimum absolute tolerance, useful for comparisons near zero. Must be at least 0.\n * @return {boolean} whether the two numbers are nearly equal\n *\n * @throws {Error} If `relTol` is less than or equal to 0.\n * @throws {Error} If `absTol` is less than 0.\n *\n * @example\n * nearlyEqual(1.000000001, 1.0, 1e-8); // true\n * nearlyEqual(1.000000002, 1.0, 0); // false\n * nearlyEqual(1.0, 1.009, undefined, 0.01); // true\n * nearlyEqual(0.000000001, 0.0, undefined, 1e-8); // true\n */\nexport function nearlyEqual(a, b) {\n var relTol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1e-8;\n var absTol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n if (relTol <= 0) {\n throw new Error('Relative tolerance must be greater than 0');\n }\n if (absTol < 0) {\n throw new Error('Absolute tolerance must be at least 0');\n }\n\n // NaN\n if (isNaN(a) || isNaN(b)) {\n return false;\n }\n if (!Number.isFinite(a) || !Number.isFinite(b)) {\n return a === b;\n }\n if (a === b) {\n return true;\n }\n\n // abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)\n return Math.abs(a - b) <= Math.max(relTol * Math.max(Math.abs(a), Math.abs(b)), absTol);\n}\n\n/**\n * Calculate the hyperbolic arccos of a number\n * @param {number} x\n * @return {number}\n */\nexport var acosh = Math.acosh || function (x) {\n return Math.log(Math.sqrt(x * x - 1) + x);\n};\nexport var asinh = Math.asinh || function (x) {\n return Math.log(Math.sqrt(x * x + 1) + x);\n};\n\n/**\n * Calculate the hyperbolic arctangent of a number\n * @param {number} x\n * @return {number}\n */\nexport var atanh = Math.atanh || function (x) {\n return Math.log((1 + x) / (1 - x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic cosine of a number\n * @param {number} x\n * @returns {number}\n */\nexport var cosh = Math.cosh || function (x) {\n return (Math.exp(x) + Math.exp(-x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic sine of a number\n * @param {number} x\n * @returns {number}\n */\nexport var sinh = Math.sinh || function (x) {\n return (Math.exp(x) - Math.exp(-x)) / 2;\n};\n\n/**\n * Calculate the hyperbolic tangent of a number\n * @param {number} x\n * @returns {number}\n */\nexport var tanh = Math.tanh || function (x) {\n var e = Math.exp(2 * x);\n return (e - 1) / (e + 1);\n};\n\n/**\n * Returns a value with the magnitude of x and the sign of y.\n * @param {number} x\n * @param {number} y\n * @returns {number}\n */\nexport function copysign(x, y) {\n var signx = x > 0 ? true : x < 0 ? false : 1 / x === Infinity;\n var signy = y > 0 ? true : y < 0 ? false : 1 / y === Infinity;\n return signx ^ signy ? -x : x;\n}\nfunction _toNumberOrThrow(value, onError) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n onError();\n }\n}\nfunction _toNumberOrDefault(value, defaultValue) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n return defaultValue;\n }\n}","import { cbrt, expm1, isInteger, log10, log1p, log2, sign, toFixed } from '../../utils/number.js';\nvar n1 = 'number';\nvar n2 = 'number, number';\nexport function absNumber(a) {\n return Math.abs(a);\n}\nabsNumber.signature = n1;\nexport function addNumber(a, b) {\n return a + b;\n}\naddNumber.signature = n2;\nexport function subtractNumber(a, b) {\n return a - b;\n}\nsubtractNumber.signature = n2;\nexport function multiplyNumber(a, b) {\n return a * b;\n}\nmultiplyNumber.signature = n2;\nexport function divideNumber(a, b) {\n return a / b;\n}\ndivideNumber.signature = n2;\nexport function unaryMinusNumber(x) {\n return -x;\n}\nunaryMinusNumber.signature = n1;\nexport function unaryPlusNumber(x) {\n return x;\n}\nunaryPlusNumber.signature = n1;\nexport function cbrtNumber(x) {\n return cbrt(x);\n}\ncbrtNumber.signature = n1;\nexport function cubeNumber(x) {\n return x * x * x;\n}\ncubeNumber.signature = n1;\nexport function expNumber(x) {\n return Math.exp(x);\n}\nexpNumber.signature = n1;\nexport function expm1Number(x) {\n return expm1(x);\n}\nexpm1Number.signature = n1;\n\n/**\n * Calculate gcd for numbers\n * @param {number} a\n * @param {number} b\n * @returns {number} Returns the greatest common denominator of a and b\n */\nexport function gcdNumber(a, b) {\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function gcd must be integer numbers');\n }\n\n // https://en.wikipedia.org/wiki/Euclidean_algorithm\n var r;\n while (b !== 0) {\n r = a % b;\n a = b;\n b = r;\n }\n return a < 0 ? -a : a;\n}\ngcdNumber.signature = n2;\n\n/**\n * Calculate lcm for two numbers\n * @param {number} a\n * @param {number} b\n * @returns {number} Returns the least common multiple of a and b\n */\nexport function lcmNumber(a, b) {\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function lcm must be integer numbers');\n }\n if (a === 0 || b === 0) {\n return 0;\n }\n\n // https://en.wikipedia.org/wiki/Euclidean_algorithm\n // evaluate lcm here inline to reduce overhead\n var t;\n var prod = a * b;\n while (b !== 0) {\n t = b;\n b = a % t;\n a = t;\n }\n return Math.abs(prod / a);\n}\nlcmNumber.signature = n2;\n\n/**\n * Calculate the logarithm of a value, optionally to a given base.\n * @param {number} x\n * @param {number | null | undefined} base\n * @return {number}\n */\nexport function logNumber(x, y) {\n if (y) {\n return Math.log(x) / Math.log(y);\n }\n return Math.log(x);\n}\n\n/**\n * Calculate the 10-base logarithm of a number\n * @param {number} x\n * @return {number}\n */\nexport function log10Number(x) {\n return log10(x);\n}\nlog10Number.signature = n1;\n\n/**\n * Calculate the 2-base logarithm of a number\n * @param {number} x\n * @return {number}\n */\nexport function log2Number(x) {\n return log2(x);\n}\nlog2Number.signature = n1;\n\n/**\n * Calculate the natural logarithm of a `number+1`\n * @param {number} x\n * @returns {number}\n */\nexport function log1pNumber(x) {\n return log1p(x);\n}\nlog1pNumber.signature = n1;\n\n/**\n * Calculate the modulus of two numbers\n * @param {number} x\n * @param {number} y\n * @returns {number} res\n * @private\n */\nexport function modNumber(x, y) {\n // We don't use JavaScript's % operator here as this doesn't work\n // correctly for x < 0 and x === 0\n // see https://en.wikipedia.org/wiki/Modulo_operation\n return y === 0 ? x : x - y * Math.floor(x / y);\n}\nmodNumber.signature = n2;\n\n/**\n * Calculate the nth root of a, solve x^root == a\n * http://rosettacode.org/wiki/Nth_root#JavaScript\n * @param {number} a\n * @param {number} [2] root\n * @private\n */\nexport function nthRootNumber(a) {\n var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n var inv = root < 0;\n if (inv) {\n root = -root;\n }\n if (root === 0) {\n throw new Error('Root must be non-zero');\n }\n if (a < 0 && Math.abs(root) % 2 !== 1) {\n throw new Error('Root must be odd when a is negative.');\n }\n\n // edge cases zero and infinity\n if (a === 0) {\n return inv ? Infinity : 0;\n }\n if (!isFinite(a)) {\n return inv ? 0 : a;\n }\n var x = Math.pow(Math.abs(a), 1 / root);\n // If a < 0, we require that root is an odd integer,\n // so (-1) ^ (1/root) = -1\n x = a < 0 ? -x : x;\n return inv ? 1 / x : x;\n\n // Very nice algorithm, but fails with nthRoot(-2, 3).\n // Newton's method has some well-known problems at times:\n // https://en.wikipedia.org/wiki/Newton%27s_method#Failure_analysis\n /*\n let x = 1 // Initial guess\n let xPrev = 1\n let i = 0\n const iMax = 10000\n do {\n const delta = (a / Math.pow(x, root - 1) - x) / root\n xPrev = x\n x = x + delta\n i++\n }\n while (xPrev !== x && i < iMax)\n if (xPrev !== x) {\n throw new Error('Function nthRoot failed to converge')\n }\n return inv ? 1 / x : x\n */\n}\nexport function signNumber(x) {\n return sign(x);\n}\nsignNumber.signature = n1;\nexport function sqrtNumber(x) {\n return Math.sqrt(x);\n}\nsqrtNumber.signature = n1;\nexport function squareNumber(x) {\n return x * x;\n}\nsquareNumber.signature = n1;\n\n/**\n * Calculate xgcd for two numbers\n * @param {number} a\n * @param {number} b\n * @return {number} result\n * @private\n */\nexport function xgcdNumber(a, b) {\n // source: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm\n var t; // used to swap two variables\n var q; // quotient\n var r; // remainder\n var x = 0;\n var lastx = 1;\n var y = 1;\n var lasty = 0;\n if (!isInteger(a) || !isInteger(b)) {\n throw new Error('Parameters in function xgcd must be integer numbers');\n }\n while (b) {\n q = Math.floor(a / b);\n r = a - q * b;\n t = x;\n x = lastx - q * x;\n lastx = t;\n t = y;\n y = lasty - q * y;\n lasty = t;\n a = b;\n b = r;\n }\n var res;\n if (a < 0) {\n res = [-a, -lastx, -lasty];\n } else {\n res = [a, a ? lastx : 0, lasty];\n }\n return res;\n}\nxgcdNumber.signature = n2;\n\n/**\n * Calculates the power of x to y, x^y, for two numbers.\n * @param {number} x\n * @param {number} y\n * @return {number} res\n */\nexport function powNumber(x, y) {\n // x^Infinity === 0 if -1 < x < 1\n // A real number 0 is returned instead of complex(0)\n if (x * x < 1 && y === Infinity || x * x > 1 && y === -Infinity) {\n return 0;\n }\n return Math.pow(x, y);\n}\npowNumber.signature = n2;\n\n/**\n * round a number to the given number of decimals, or to zero if decimals is\n * not provided\n * @param {number} value\n * @param {number} decimals number of decimals, between 0 and 15 (0 by default)\n * @return {number} roundedValue\n */\nexport function roundNumber(value) {\n var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n if (!isInteger(decimals) || decimals < 0 || decimals > 15) {\n throw new Error('Number of decimals in function round must be an integer from 0 to 15 inclusive');\n }\n return parseFloat(toFixed(value, decimals));\n}\n\n/**\n * Calculate the norm of a number, the absolute value.\n * @param {number} x\n * @return {number}\n */\nexport function normNumber(x) {\n return Math.abs(x);\n}\nnormNumber.signature = n1;","/** @param {number} i\n * @param {number} n\n * @returns {number} product of i to n\n */\nexport function product(i, n) {\n if (n < i) {\n return 1;\n }\n if (n === i) {\n return n;\n }\n var half = n + i >> 1; // divide (n + i) by 2 and truncate to integer\n return product(i, half) * product(half + 1, n);\n}","import { isInteger } from '../../utils/number.js';\nimport { product } from '../../utils/product.js';\nexport function combinationsNumber(n, k) {\n if (!isInteger(n) || n < 0) {\n throw new TypeError('Positive integer value expected in function combinations');\n }\n if (!isInteger(k) || k < 0) {\n throw new TypeError('Positive integer value expected in function combinations');\n }\n if (k > n) {\n throw new TypeError('k must be less than or equal to n');\n }\n var nMinusk = n - k;\n var answer = 1;\n var firstnumerator = k < nMinusk ? nMinusk + 1 : k + 1;\n var nextdivisor = 2;\n var lastdivisor = k < nMinusk ? k : nMinusk;\n // balance multiplications and divisions to try to keep intermediate values\n // in exact-integer range as long as possible\n for (var nextnumerator = firstnumerator; nextnumerator <= n; ++nextnumerator) {\n answer *= nextnumerator;\n while (nextdivisor <= lastdivisor && answer % nextdivisor === 0) {\n answer /= nextdivisor;\n ++nextdivisor;\n }\n }\n // for big n, k, floating point may have caused weirdness in remainder\n if (nextdivisor <= lastdivisor) {\n answer /= product(nextdivisor, lastdivisor);\n }\n return answer;\n}\ncombinationsNumber.signature = 'number, number';","export var pi = Math.PI;\nexport var tau = 2 * Math.PI;\nexport var e = Math.E;\nexport var phi = 1.6180339887498948; // eslint-disable-line no-loss-of-precision","/* eslint-disable no-loss-of-precision */\n\nimport { isInteger } from '../../utils/number.js';\nimport { product } from '../../utils/product.js';\nexport function gammaNumber(n) {\n var x;\n if (isInteger(n)) {\n if (n <= 0) {\n return Number.isFinite(n) ? Infinity : NaN;\n }\n if (n > 171) {\n return Infinity; // Will overflow\n }\n return product(1, n - 1);\n }\n if (n < 0.5) {\n return Math.PI / (Math.sin(Math.PI * n) * gammaNumber(1 - n));\n }\n if (n >= 171.35) {\n return Infinity; // will overflow\n }\n if (n > 85.0) {\n // Extended Stirling Approx\n var twoN = n * n;\n var threeN = twoN * n;\n var fourN = threeN * n;\n var fiveN = fourN * n;\n return Math.sqrt(2 * Math.PI / n) * Math.pow(n / Math.E, n) * (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + 5246819 / (75246796800 * fiveN * n));\n }\n --n;\n x = gammaP[0];\n for (var i = 1; i < gammaP.length; ++i) {\n x += gammaP[i] / (n + i);\n }\n var t = n + gammaG + 0.5;\n return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x;\n}\ngammaNumber.signature = 'number';\n\n// TODO: comment on the variables g and p\n\nexport var gammaG = 4.7421875;\nexport var gammaP = [0.99999999999999709182, 57.156235665862923517, -59.597960355475491248, 14.136097974741747174, -0.49191381609762019978, 0.33994649984811888699e-4, 0.46523628927048575665e-4, -0.98374475304879564677e-4, 0.15808870322491248884e-3, -0.21026444172410488319e-3, 0.21743961811521264320e-3, -0.16431810653676389022e-3, 0.84418223983852743293e-4, -0.26190838401581408670e-4, 0.36899182659531622704e-5];\n\n// lgamma implementation ref: https://mrob.com/pub/ries/lanczos-gamma.html#code\n\n// log(2 * pi) / 2\nexport var lnSqrt2PI = 0.91893853320467274178;\nexport var lgammaG = 5; // Lanczos parameter \"g\"\nexport var lgammaN = 7; // Range of coefficients \"n\"\n\nexport var lgammaSeries = [1.000000000190015, 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5];\nexport function lgammaNumber(n) {\n if (n < 0) return NaN;\n if (n === 0) return Infinity;\n if (!Number.isFinite(n)) return n;\n if (n < 0.5) {\n // Use Euler's reflection formula:\n // gamma(z) = PI / (sin(PI * z) * gamma(1 - z))\n return Math.log(Math.PI / Math.sin(Math.PI * n)) - lgammaNumber(1 - n);\n }\n\n // Compute the logarithm of the Gamma function using the Lanczos method\n\n n = n - 1;\n var base = n + lgammaG + 0.5; // Base of the Lanczos exponential\n var sum = lgammaSeries[0];\n\n // We start with the terms that have the smallest coefficients and largest denominator\n for (var i = lgammaN - 1; i >= 1; i--) {\n sum += lgammaSeries[i] / (n + i);\n }\n return lnSqrt2PI + (n + 0.5) * Math.log(base) - base + Math.log(sum);\n}\nlgammaNumber.signature = 'number';","import { pickShallow } from './object.js';\n\n/**\n * Create a factory function, which can be used to inject dependencies.\n *\n * The created functions are memoized, a consecutive call of the factory\n * with the exact same inputs will return the same function instance.\n * The memoized cache is exposed on `factory.cache` and can be cleared\n * if needed.\n *\n * Example:\n *\n * const name = 'log'\n * const dependencies = ['config', 'typed', 'divideScalar', 'Complex']\n *\n * export const createLog = factory(name, dependencies, ({ typed, config, divideScalar, Complex }) => {\n * // ... create the function log here and return it\n * }\n *\n * @param {string} name Name of the function to be created\n * @param {string[]} dependencies The names of all required dependencies\n * @param {function} create Callback function called with an object with all dependencies\n * @param {Object} [meta]\n * Optional object with meta information that will be attached\n * to the created factory function as property `meta`. For explanation\n * of what meta properties can be specified and what they mean, see\n * docs/core/extension.md.\n * @returns {function}\n */\nexport function factory(name, dependencies, create, meta) {\n function assertAndCreate(scope) {\n // we only pass the requested dependencies to the factory function\n // to prevent functions to rely on dependencies that are not explicitly\n // requested.\n var deps = pickShallow(scope, dependencies.map(stripOptionalNotation));\n assertDependencies(name, dependencies, scope);\n return create(deps);\n }\n assertAndCreate.isFactory = true;\n assertAndCreate.fn = name;\n assertAndCreate.dependencies = dependencies.slice().sort();\n if (meta) {\n assertAndCreate.meta = meta;\n }\n return assertAndCreate;\n}\n\n/**\n * Sort all factories such that when loading in order, the dependencies are resolved.\n *\n * @param {Array} factories\n * @returns {Array} Returns a new array with the sorted factories.\n */\nexport function sortFactories(factories) {\n var factoriesByName = {};\n factories.forEach(factory => {\n factoriesByName[factory.fn] = factory;\n });\n function containsDependency(factory, dependency) {\n // TODO: detect circular references\n if (isFactory(factory)) {\n if (factory.dependencies.includes(dependency.fn || dependency.name)) {\n return true;\n }\n if (factory.dependencies.some(d => containsDependency(factoriesByName[d], dependency))) {\n return true;\n }\n }\n return false;\n }\n var sorted = [];\n function addFactory(factory) {\n var index = 0;\n while (index < sorted.length && !containsDependency(sorted[index], factory)) {\n index++;\n }\n sorted.splice(index, 0, factory);\n }\n\n // sort regular factory functions\n factories.filter(isFactory).forEach(addFactory);\n\n // sort legacy factory functions AFTER the regular factory functions\n factories.filter(factory => !isFactory(factory)).forEach(addFactory);\n return sorted;\n}\n\n// TODO: comment or cleanup if unused in the end\nexport function create(factories) {\n var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n sortFactories(factories).forEach(factory => factory(scope));\n return scope;\n}\n\n/**\n * Test whether an object is a factory. This is the case when it has\n * properties name, dependencies, and a function create.\n * @param {*} obj\n * @returns {boolean}\n */\nexport function isFactory(obj) {\n return typeof obj === 'function' && typeof obj.fn === 'string' && Array.isArray(obj.dependencies);\n}\n\n/**\n * Assert that all dependencies of a list with dependencies are available in the provided scope.\n *\n * Will throw an exception when there are dependencies missing.\n *\n * @param {string} name Name for the function to be created. Used to generate a useful error message\n * @param {string[]} dependencies\n * @param {Object} scope\n */\nexport function assertDependencies(name, dependencies, scope) {\n var allDefined = dependencies.filter(dependency => !isOptionalDependency(dependency)) // filter optionals\n .every(dependency => scope[dependency] !== undefined);\n if (!allDefined) {\n var missingDependencies = dependencies.filter(dependency => scope[dependency] === undefined);\n\n // TODO: create a custom error class for this, a MathjsError or something like that\n throw new Error(\"Cannot create function \\\"\".concat(name, \"\\\", \") + \"some dependencies are missing: \".concat(missingDependencies.map(d => \"\\\"\".concat(d, \"\\\"\")).join(', '), \".\"));\n }\n}\nexport function isOptionalDependency(dependency) {\n return dependency && dependency[0] === '?';\n}\nexport function stripOptionalNotation(dependency) {\n return dependency && dependency[0] === '?' ? dependency.slice(1) : dependency;\n}","export function noBignumber() {\n throw new Error('No \"bignumber\" implementation available');\n}\nexport function noFraction() {\n throw new Error('No \"fraction\" implementation available');\n}\nexport function noMatrix() {\n throw new Error('No \"matrix\" implementation available');\n}\nexport function noIndex() {\n throw new Error('No \"index\" implementation available');\n}\nexport function noSubset() {\n throw new Error('No \"matrix\" implementation available');\n}","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.typed = factory());\n})(this, (function () { 'use strict';\n\n function ok() {\n return true;\n }\n function notOk() {\n return false;\n }\n function undef() {\n return undefined;\n }\n const NOT_TYPED_FUNCTION = 'Argument is not a typed-function.';\n\n /**\n * @typedef {{\n * params: Param[],\n * fn: function,\n * test: function,\n * implementation: function\n * }} Signature\n *\n * @typedef {{\n * types: Type[],\n * hasAny: boolean,\n * hasConversion: boolean,\n * restParam: boolean\n * }} Param\n *\n * @typedef {{\n * name: string,\n * typeIndex: number,\n * test: function,\n * isAny: boolean,\n * conversion?: ConversionDef,\n * conversionIndex: number,\n * }} Type\n *\n * @typedef {{\n * from: string,\n * to: string,\n * convert: function (*) : *\n * }} ConversionDef\n *\n * @typedef {{\n * name: string,\n * test: function(*) : boolean,\n * isAny?: boolean\n * }} TypeDef\n */\n\n /**\n * @returns {() => function}\n */\n function create() {\n // data type tests\n\n /**\n * Returns true if the argument is a non-null \"plain\" object\n */\n function isPlainObject(x) {\n return typeof x === 'object' && x !== null && x.constructor === Object;\n }\n const _types = [{\n name: 'number',\n test: function (x) {\n return typeof x === 'number';\n }\n }, {\n name: 'string',\n test: function (x) {\n return typeof x === 'string';\n }\n }, {\n name: 'boolean',\n test: function (x) {\n return typeof x === 'boolean';\n }\n }, {\n name: 'Function',\n test: function (x) {\n return typeof x === 'function';\n }\n }, {\n name: 'Array',\n test: Array.isArray\n }, {\n name: 'Date',\n test: function (x) {\n return x instanceof Date;\n }\n }, {\n name: 'RegExp',\n test: function (x) {\n return x instanceof RegExp;\n }\n }, {\n name: 'Object',\n test: isPlainObject\n }, {\n name: 'null',\n test: function (x) {\n return x === null;\n }\n }, {\n name: 'undefined',\n test: function (x) {\n return x === undefined;\n }\n }];\n const anyType = {\n name: 'any',\n test: ok,\n isAny: true\n };\n\n // Data structures to track the types. As these are local variables in\n // create(), each typed universe will get its own copy, but the variables\n // will only be accessible through the (closures of the) functions supplied\n // as properties of the typed object, not directly.\n // These will be initialized in clear() below\n let typeMap; // primary store of all types\n let typeList; // Array of just type names, for the sake of ordering\n\n // And similar data structures for the type conversions:\n let nConversions = 0;\n // the actual conversions are stored on a property of the destination types\n\n // This is a temporary object, will be replaced with a function at the end\n let typed = {\n createCount: 0\n };\n\n /**\n * Takes a type name and returns the corresponding official type object\n * for that type.\n *\n * @param {string} typeName\n * @returns {TypeDef} type\n */\n function findType(typeName) {\n const type = typeMap.get(typeName);\n if (type) {\n return type;\n }\n // Remainder is error handling\n let message = 'Unknown type \"' + typeName + '\"';\n const name = typeName.toLowerCase();\n let otherName;\n for (otherName of typeList) {\n if (otherName.toLowerCase() === name) {\n message += '. Did you mean \"' + otherName + '\" ?';\n break;\n }\n }\n throw new TypeError(message);\n }\n\n /**\n * Adds an array `types` of type definitions to this typed instance.\n * Each type definition should be an object with properties:\n * 'name' - a string giving the name of the type; 'test' - function\n * returning a boolean that tests membership in the type; and optionally\n * 'isAny' - true only for the 'any' type.\n *\n * The second optional argument, `before`, gives the name of a type that\n * these types should be added before. The new types are added in the\n * order specified.\n * @param {TypeDef[]} types\n * @param {string | boolean} [beforeSpec='any'] before\n */\n function addTypes(types) {\n let beforeSpec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any';\n const beforeIndex = beforeSpec ? findType(beforeSpec).index : typeList.length;\n const newTypes = [];\n for (let i = 0; i < types.length; ++i) {\n if (!types[i] || typeof types[i].name !== 'string' || typeof types[i].test !== 'function') {\n throw new TypeError('Object with properties {name: string, test: function} expected');\n }\n const typeName = types[i].name;\n if (typeMap.has(typeName)) {\n throw new TypeError('Duplicate type name \"' + typeName + '\"');\n }\n newTypes.push(typeName);\n typeMap.set(typeName, {\n name: typeName,\n test: types[i].test,\n isAny: types[i].isAny,\n index: beforeIndex + i,\n conversionsTo: [] // Newly added type can't have any conversions to it\n });\n }\n // update the typeList\n const affectedTypes = typeList.slice(beforeIndex);\n typeList = typeList.slice(0, beforeIndex).concat(newTypes).concat(affectedTypes);\n // Fix the indices\n for (let i = beforeIndex + newTypes.length; i < typeList.length; ++i) {\n typeMap.get(typeList[i]).index = i;\n }\n }\n\n /**\n * Removes all types and conversions from this typed instance.\n * May cause previously constructed typed-functions to throw\n * strange errors when they are called with types that do not\n * match any of their signatures.\n */\n function clear() {\n typeMap = new Map();\n typeList = [];\n nConversions = 0;\n addTypes([anyType], false);\n }\n\n // initialize the types to the default list\n clear();\n addTypes(_types);\n\n /**\n * Removes all conversions, leaving the types alone.\n */\n function clearConversions() {\n let typeName;\n for (typeName of typeList) {\n typeMap.get(typeName).conversionsTo = [];\n }\n nConversions = 0;\n }\n\n /**\n * Find the type names that match a value.\n * @param {*} value\n * @return {string[]} Array of names of types for which\n * the type test matches the value.\n */\n function findTypeNames(value) {\n const matches = typeList.filter(name => {\n const type = typeMap.get(name);\n return !type.isAny && type.test(value);\n });\n if (matches.length) {\n return matches;\n }\n return ['any'];\n }\n\n /**\n * Check if an entity is a typed function created by any instance\n * @param {any} entity\n * @returns {boolean}\n */\n function isTypedFunction(entity) {\n return entity && typeof entity === 'function' && '_typedFunctionData' in entity;\n }\n\n /**\n * Find a specific signature from a (composed) typed function, for example:\n *\n * typed.findSignature(fn, ['number', 'string'])\n * typed.findSignature(fn, 'number, string')\n * typed.findSignature(fn, 'number,string', {exact: true})\n *\n * This function findSignature will by default return the best match to\n * the given signature, possibly employing type conversions.\n *\n * The (optional) third argument is a plain object giving options\n * controlling the signature search. Currently the only implemented\n * option is `exact`: if specified as true (default is false), only\n * exact matches will be returned (i.e. signatures for which `fn` was\n * directly defined). Note that a (possibly different) type matching\n * `any`, or one or more instances of TYPE matching `...TYPE` are\n * considered exact matches in this regard, as no conversions are used.\n *\n * This function returns a \"signature\" object, as does `typed.resolve()`,\n * which is a plain object with four keys: `params` (the array of parameters\n * for this signature), `fn` (the originally supplied function for this\n * signature), `test` (a generated function that determines if an argument\n * list matches this signature, and `implementation` (the function to call\n * on a matching argument list, that performs conversions if necessary and\n * then calls the originally supplied function).\n *\n * @param {Function} fn A typed-function\n * @param {string | string[]} signature\n * Signature to be found, can be an array or a comma separated string.\n * @param {object} options Controls the signature search as documented\n * @return {{ params: Param[], fn: function, test: function, implementation: function }}\n * Returns the matching signature, or throws an error when no signature\n * is found.\n */\n function findSignature(fn, signature, options) {\n if (!isTypedFunction(fn)) {\n throw new TypeError(NOT_TYPED_FUNCTION);\n }\n\n // Canonicalize input\n const exact = options && options.exact;\n const stringSignature = Array.isArray(signature) ? signature.join(',') : signature;\n const params = parseSignature(stringSignature);\n const canonicalSignature = stringifyParams(params);\n\n // First hope we get lucky and exactly match a signature\n if (!exact || canonicalSignature in fn.signatures) {\n // OK, we can check the internal signatures\n const match = fn._typedFunctionData.signatureMap.get(canonicalSignature);\n if (match) {\n return match;\n }\n }\n\n // Oh well, we did not; so we have to go back and check the parameters\n // one by one, in order to catch things like `any` and rest params.\n // Note here we can assume there is at least one parameter, because\n // the empty signature would have matched successfully above.\n const nParams = params.length;\n let remainingSignatures;\n if (exact) {\n remainingSignatures = [];\n let name;\n for (name in fn.signatures) {\n remainingSignatures.push(fn._typedFunctionData.signatureMap.get(name));\n }\n } else {\n remainingSignatures = fn._typedFunctionData.signatures;\n }\n for (let i = 0; i < nParams; ++i) {\n const want = params[i];\n const filteredSignatures = [];\n let possibility;\n for (possibility of remainingSignatures) {\n const have = getParamAtIndex(possibility.params, i);\n if (!have || want.restParam && !have.restParam) {\n continue;\n }\n if (!have.hasAny) {\n // have to check all of the wanted types are available\n const haveTypes = paramTypeSet(have);\n if (want.types.some(wtype => !haveTypes.has(wtype.name))) {\n continue;\n }\n }\n // OK, this looks good\n filteredSignatures.push(possibility);\n }\n remainingSignatures = filteredSignatures;\n if (remainingSignatures.length === 0) break;\n }\n // Return the first remaining signature that was totally matched:\n let candidate;\n for (candidate of remainingSignatures) {\n if (candidate.params.length <= nParams) {\n return candidate;\n }\n }\n throw new TypeError('Signature not found (signature: ' + (fn.name || 'unnamed') + '(' + stringifyParams(params, ', ') + '))');\n }\n\n /**\n * Find the proper function to call for a specific signature from\n * a (composed) typed function, for example:\n *\n * typed.find(fn, ['number', 'string'])\n * typed.find(fn, 'number, string')\n * typed.find(fn, 'number,string', {exact: true})\n *\n * This function find will by default return the best match to\n * the given signature, possibly employing type conversions (and returning\n * a function that will perform those conversions as needed). The\n * (optional) third argument is a plain object giving options contolling\n * the signature search. Currently only the option `exact` is implemented,\n * which defaults to \"false\". If `exact` is specified as true, then only\n * exact matches will be returned (i.e. signatures for which `fn` was\n * directly defined). Uses of `any` and `...TYPE` are considered exact if\n * no conversions are necessary to apply the corresponding function.\n *\n * @param {Function} fn A typed-function\n * @param {string | string[]} signature\n * Signature to be found, can be an array or a comma separated string.\n * @param {object} options Controls the signature match as documented\n * @return {function}\n * Returns the function to call for the given signature, or throws an\n * error if no match is found.\n */\n function find(fn, signature, options) {\n return findSignature(fn, signature, options).implementation;\n }\n\n /**\n * Convert a given value to another data type, specified by type name.\n *\n * @param {*} value\n * @param {string} typeName\n */\n function convert(value, typeName) {\n // check conversion is needed\n const type = findType(typeName);\n if (type.test(value)) {\n return value;\n }\n const conversions = type.conversionsTo;\n if (conversions.length === 0) {\n throw new Error('There are no conversions to ' + typeName + ' defined.');\n }\n for (let i = 0; i < conversions.length; i++) {\n const fromType = findType(conversions[i].from);\n if (fromType.test(value)) {\n return conversions[i].convert(value);\n }\n }\n throw new Error('Cannot convert ' + value + ' to ' + typeName);\n }\n\n /**\n * Stringify parameters in a normalized way\n * @param {Param[]} params\n * @param {string} [','] separator\n * @return {string}\n */\n function stringifyParams(params) {\n let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';\n return params.map(p => p.name).join(separator);\n }\n\n /**\n * Parse a parameter, like \"...number | boolean\"\n * @param {string} param\n * @return {Param} param\n */\n function parseParam(param) {\n const restParam = param.indexOf('...') === 0;\n const types = !restParam ? param : param.length > 3 ? param.slice(3) : 'any';\n const typeDefs = types.split('|').map(s => findType(s.trim()));\n let hasAny = false;\n let paramName = restParam ? '...' : '';\n const exactTypes = typeDefs.map(function (type) {\n hasAny = type.isAny || hasAny;\n paramName += type.name + '|';\n return {\n name: type.name,\n typeIndex: type.index,\n test: type.test,\n isAny: type.isAny,\n conversion: null,\n conversionIndex: -1\n };\n });\n return {\n types: exactTypes,\n name: paramName.slice(0, -1),\n // remove trailing '|' from above\n hasAny,\n hasConversion: false,\n restParam\n };\n }\n\n /**\n * Expands a parsed parameter with the types available from currently\n * defined conversions.\n * @param {Param} param\n * @return {Param} param\n */\n function expandParam(param) {\n const typeNames = param.types.map(t => t.name);\n const matchingConversions = availableConversions(typeNames);\n let hasAny = param.hasAny;\n let newName = param.name;\n const convertibleTypes = matchingConversions.map(function (conversion) {\n const type = findType(conversion.from);\n hasAny = type.isAny || hasAny;\n newName += '|' + conversion.from;\n return {\n name: conversion.from,\n typeIndex: type.index,\n test: type.test,\n isAny: type.isAny,\n conversion,\n conversionIndex: conversion.index\n };\n });\n return {\n types: param.types.concat(convertibleTypes),\n name: newName,\n hasAny,\n hasConversion: convertibleTypes.length > 0,\n restParam: param.restParam\n };\n }\n\n /**\n * Return the set of type names in a parameter.\n * Caches the result for efficiency\n *\n * @param {Param} param\n * @return {Set} typenames\n */\n function paramTypeSet(param) {\n if (!param.typeSet) {\n param.typeSet = new Set();\n param.types.forEach(type => param.typeSet.add(type.name));\n }\n return param.typeSet;\n }\n\n /**\n * Parse a signature with comma separated parameters,\n * like \"number | boolean, ...string\"\n *\n * @param {string} signature\n * @return {Param[]} params\n */\n function parseSignature(rawSignature) {\n const params = [];\n if (typeof rawSignature !== 'string') {\n throw new TypeError('Signatures must be strings');\n }\n const signature = rawSignature.trim();\n if (signature === '') {\n return params;\n }\n const rawParams = signature.split(',');\n for (let i = 0; i < rawParams.length; ++i) {\n const parsedParam = parseParam(rawParams[i].trim());\n if (parsedParam.restParam && i !== rawParams.length - 1) {\n throw new SyntaxError('Unexpected rest parameter \"' + rawParams[i] + '\": ' + 'only allowed for the last parameter');\n }\n // if invalid, short-circuit (all the types may have been filtered)\n if (parsedParam.types.length === 0) {\n return null;\n }\n params.push(parsedParam);\n }\n return params;\n }\n\n /**\n * Test whether a set of params contains a restParam\n * @param {Param[]} params\n * @return {boolean} Returns true when the last parameter is a restParam\n */\n function hasRestParam(params) {\n const param = last(params);\n return param ? param.restParam : false;\n }\n\n /**\n * Create a type test for a single parameter, which can have one or multiple\n * types.\n * @param {Param} param\n * @return {function(x: *) : boolean} Returns a test function\n */\n function compileTest(param) {\n if (!param || param.types.length === 0) {\n // nothing to do\n return ok;\n } else if (param.types.length === 1) {\n return findType(param.types[0].name).test;\n } else if (param.types.length === 2) {\n const test0 = findType(param.types[0].name).test;\n const test1 = findType(param.types[1].name).test;\n return function or(x) {\n return test0(x) || test1(x);\n };\n } else {\n // param.types.length > 2\n const tests = param.types.map(function (type) {\n return findType(type.name).test;\n });\n return function or(x) {\n for (let i = 0; i < tests.length; i++) {\n if (tests[i](x)) {\n return true;\n }\n }\n return false;\n };\n }\n }\n\n /**\n * Create a test for all parameters of a signature\n * @param {Param[]} params\n * @return {function(args: Array<*>) : boolean}\n */\n function compileTests(params) {\n let tests, test0, test1;\n if (hasRestParam(params)) {\n // variable arguments like '...number'\n tests = initial(params).map(compileTest);\n const varIndex = tests.length;\n const lastTest = compileTest(last(params));\n const testRestParam = function (args) {\n for (let i = varIndex; i < args.length; i++) {\n if (!lastTest(args[i])) {\n return false;\n }\n }\n return true;\n };\n return function testArgs(args) {\n for (let i = 0; i < tests.length; i++) {\n if (!tests[i](args[i])) {\n return false;\n }\n }\n return testRestParam(args) && args.length >= varIndex + 1;\n };\n } else {\n // no variable arguments\n if (params.length === 0) {\n return function testArgs(args) {\n return args.length === 0;\n };\n } else if (params.length === 1) {\n test0 = compileTest(params[0]);\n return function testArgs(args) {\n return test0(args[0]) && args.length === 1;\n };\n } else if (params.length === 2) {\n test0 = compileTest(params[0]);\n test1 = compileTest(params[1]);\n return function testArgs(args) {\n return test0(args[0]) && test1(args[1]) && args.length === 2;\n };\n } else {\n // arguments.length > 2\n tests = params.map(compileTest);\n return function testArgs(args) {\n for (let i = 0; i < tests.length; i++) {\n if (!tests[i](args[i])) {\n return false;\n }\n }\n return args.length === tests.length;\n };\n }\n }\n }\n\n /**\n * Find the parameter at a specific index of a Params list.\n * Handles rest parameters.\n * @param {Param[]} params\n * @param {number} index\n * @return {Param | null} Returns the matching parameter when found,\n * null otherwise.\n */\n function getParamAtIndex(params, index) {\n return index < params.length ? params[index] : hasRestParam(params) ? last(params) : null;\n }\n\n /**\n * Get all type names of a parameter\n * @param {Params[]} params\n * @param {number} index\n * @return {string[]} Returns an array with type names\n */\n function getTypeSetAtIndex(params, index) {\n const param = getParamAtIndex(params, index);\n if (!param) {\n return new Set();\n }\n return paramTypeSet(param);\n }\n\n /**\n * Test whether a type is an exact type or conversion\n * @param {Type} type\n * @return {boolean} Returns true when\n */\n function isExactType(type) {\n return type.conversion === null || type.conversion === undefined;\n }\n\n /**\n * Helper function for creating error messages: create an array with\n * all available types on a specific argument index.\n * @param {Signature[]} signatures\n * @param {number} index\n * @return {string[]} Returns an array with available types\n */\n function mergeExpectedParams(signatures, index) {\n const typeSet = new Set();\n signatures.forEach(signature => {\n const paramSet = getTypeSetAtIndex(signature.params, index);\n let name;\n for (name of paramSet) {\n typeSet.add(name);\n }\n });\n return typeSet.has('any') ? ['any'] : Array.from(typeSet);\n }\n\n /**\n * Create\n * @param {string} name The name of the function\n * @param {array.<*>} args The actual arguments passed to the function\n * @param {Signature[]} signatures A list with available signatures\n * @return {TypeError} Returns a type error with additional data\n * attached to it in the property `data`\n */\n function createError(name, args, signatures) {\n let err, expected;\n const _name = name || 'unnamed';\n\n // test for wrong type at some index\n let matchingSignatures = signatures;\n let index;\n for (index = 0; index < args.length; index++) {\n const nextMatchingDefs = [];\n matchingSignatures.forEach(signature => {\n const param = getParamAtIndex(signature.params, index);\n const test = compileTest(param);\n if ((index < signature.params.length || hasRestParam(signature.params)) && test(args[index])) {\n nextMatchingDefs.push(signature);\n }\n });\n if (nextMatchingDefs.length === 0) {\n // no matching signatures anymore, throw error \"wrong type\"\n expected = mergeExpectedParams(matchingSignatures, index);\n if (expected.length > 0) {\n const actualTypes = findTypeNames(args[index]);\n err = new TypeError('Unexpected type of argument in function ' + _name + ' (expected: ' + expected.join(' or ') + ', actual: ' + actualTypes.join(' | ') + ', index: ' + index + ')');\n err.data = {\n category: 'wrongType',\n fn: _name,\n index,\n actual: actualTypes,\n expected\n };\n return err;\n }\n } else {\n matchingSignatures = nextMatchingDefs;\n }\n }\n\n // test for too few arguments\n const lengths = matchingSignatures.map(function (signature) {\n return hasRestParam(signature.params) ? Infinity : signature.params.length;\n });\n if (args.length < Math.min.apply(null, lengths)) {\n expected = mergeExpectedParams(matchingSignatures, index);\n err = new TypeError('Too few arguments in function ' + _name + ' (expected: ' + expected.join(' or ') + ', index: ' + args.length + ')');\n err.data = {\n category: 'tooFewArgs',\n fn: _name,\n index: args.length,\n expected\n };\n return err;\n }\n\n // test for too many arguments\n const maxLength = Math.max.apply(null, lengths);\n if (args.length > maxLength) {\n err = new TypeError('Too many arguments in function ' + _name + ' (expected: ' + maxLength + ', actual: ' + args.length + ')');\n err.data = {\n category: 'tooManyArgs',\n fn: _name,\n index: args.length,\n expectedLength: maxLength\n };\n return err;\n }\n\n // Generic error\n const argTypes = [];\n for (let i = 0; i < args.length; ++i) {\n argTypes.push(findTypeNames(args[i]).join('|'));\n }\n err = new TypeError('Arguments of type \"' + argTypes.join(', ') + '\" do not match any of the defined signatures of function ' + _name + '.');\n err.data = {\n category: 'mismatch',\n actual: argTypes\n };\n return err;\n }\n\n /**\n * Find the lowest index of all types of a parameter\n * @param {Param} param\n * @return {number} Returns the index of the lowest type in typed.types\n */\n function getLowestTypeIndex(param) {\n let min = typeList.length + 1;\n for (let i = 0; i < param.types.length; i++) {\n min = Math.min(min, param.types[i].typeIndex);\n }\n return min;\n }\n\n /**\n * Find the lowest index of the conversion of all types of the parameter\n * having a conversion\n * @param {Param} param\n * @return {number} Returns the lowest index of the conversions of this type\n */\n function getLowestConversionIndex(param) {\n let min = nConversions + 1;\n for (let i = 0; i < param.types.length; i++) {\n if (!isExactType(param.types[i])) {\n min = Math.min(min, param.types[i].conversionIndex);\n }\n }\n return min;\n }\n\n /**\n * Compare two params. The return value is a number that is\n * negative when param1 should be considered first, positive\n * when param2 should be considered first, and zero when the\n * params are indistinguishable. Primarily as a debugging aid,\n * the value is always less than one in absolute value, and\n * a smaller absolute value indicates a less important distinction\n * between the parameters.\n * @param {Param} param1\n * @param {Param} param2\n * @return {number} negative, positive, or zero depending on whether\n * param1 should be ordered before, after, or equivalently\n * to param2\n */\n function compareParams(param1, param2) {\n // We compare a number of metrics on a param in turn:\n // 1) 'any' parameters are the least preferred\n if (param1.hasAny) {\n if (!param2.hasAny) {\n return 0.1;\n }\n } else if (param2.hasAny) {\n return -0.1;\n }\n\n // 2) Prefer non-rest to rest parameters\n if (param1.restParam) {\n if (!param2.restParam) {\n return 0.01;\n }\n } else if (param2.restParam) {\n return -0.01;\n }\n\n // 3) Prefer lower type index:\n const typeDiff = getLowestTypeIndex(param1) - getLowestTypeIndex(param2);\n if (typeDiff < 0) {\n return -1e-3;\n }\n if (typeDiff > 0) {\n return 0.001;\n }\n\n // 4) Prefer exact type match to conversions, with a strength that\n // grows with the conversion index\n const conv1 = getLowestConversionIndex(param1);\n const conv2 = getLowestConversionIndex(param2);\n if (param1.hasConversion) {\n if (!param2.hasConversion) {\n return (1 + conv1) * 0.000001;\n }\n } else if (param2.hasConversion) {\n return -(1 + conv2) * 0.000001;\n }\n\n // 5) Prefer lower conversion index\n const convDiff = conv1 - conv2;\n if (convDiff < 0) {\n return -1e-7;\n }\n if (convDiff > 0) {\n return 0.0000001;\n }\n\n // Don't have a basis for preference\n return 0;\n }\n\n /**\n * Compare two signatures. The result is a number that is negative\n * when the first signature should be preferred to the second, positive\n * when the second signature should be preferred, and zero in case the\n * two signatures are essentially equivalent. Primarily as a debugging\n * aid, a larger absolute value indicates a more \"important\" difference.\n *\n * @param {Signature} signature1\n * @param {Signature} signature2\n * @return {number} returns a negative number when signature1 must get a\n * lower index than signature2, a positive number when the\n * opposite holds, or zero when both are equivalent.\n */\n function compareSignatures(signature1, signature2) {\n const pars1 = signature1.params;\n const pars2 = signature2.params;\n const last1 = last(pars1);\n const last2 = last(pars2);\n const hasRest1 = hasRestParam(pars1);\n const hasRest2 = hasRestParam(pars2);\n // We compare a number of metrics on signatures in turn:\n // 1) An \"any rest param\" is least preferred\n if (hasRest1 && last1.hasAny) {\n if (!hasRest2 || !last2.hasAny) {\n return 10000000;\n }\n } else if (hasRest2 && last2.hasAny) {\n return -1e7;\n }\n\n // 2) Minimize the number of 'any' parameters\n let any1 = 0;\n let conv1 = 0;\n let par;\n for (par of pars1) {\n if (par.hasAny) ++any1;\n if (par.hasConversion) ++conv1;\n }\n let any2 = 0;\n let conv2 = 0;\n for (par of pars2) {\n if (par.hasAny) ++any2;\n if (par.hasConversion) ++conv2;\n }\n if (any1 !== any2) {\n return (any1 - any2) * 1000000;\n }\n\n // 3) A conversion rest param is less preferred\n if (hasRest1 && last1.hasConversion) {\n if (!hasRest2 || !last2.hasConversion) {\n return 100000;\n }\n } else if (hasRest2 && last2.hasConversion) {\n return -1e5;\n }\n\n // 4) Minimize the number of conversions\n if (conv1 !== conv2) {\n return (conv1 - conv2) * 10000;\n }\n\n // 5) Prefer no rest param\n if (hasRest1) {\n if (!hasRest2) {\n return 1000;\n }\n } else if (hasRest2) {\n return -1e3;\n }\n\n // 6) Prefer shorter with rest param, longer without\n const lengthCriterion = (pars1.length - pars2.length) * (hasRest1 ? -100 : 100);\n if (lengthCriterion !== 0) {\n return lengthCriterion;\n }\n\n // Signatures are identical in each of the above metrics.\n // In particular, they are the same length.\n // We can therefore compare the parameters one by one.\n // First we count which signature has more preferred parameters.\n const comparisons = [];\n let tc = 0;\n for (let i = 0; i < pars1.length; ++i) {\n const thisComparison = compareParams(pars1[i], pars2[i]);\n comparisons.push(thisComparison);\n tc += thisComparison;\n }\n if (tc !== 0) {\n return (tc < 0 ? -10 : 10) + tc;\n }\n\n // They have the same number of preferred parameters, so go by the\n // earliest parameter in which we have a preference.\n // In other words, dispatch is driven somewhat more by earlier\n // parameters than later ones.\n let c;\n let bonus = 9;\n const decrement = bonus / (comparisons.length + 1);\n for (c of comparisons) {\n if (c !== 0) {\n return (c < 0 ? -bonus : bonus) + c;\n }\n bonus -= decrement;\n }\n\n // It's a tossup:\n return 0;\n }\n\n /**\n * Produce a list of all conversions from distinct types to one of\n * the given types.\n *\n * @param {string[]} typeNames\n * @return {ConversionDef[]} Returns the conversions that are available\n * resulting in any given type (if any)\n */\n function availableConversions(typeNames) {\n if (typeNames.length === 0) {\n return [];\n }\n const types = typeNames.map(findType);\n if (typeNames.length === 1) return types[0].conversionsTo;\n\n // Here, for each type that occurs as the from-type of any conversion\n // to any of the types found, we must select the conversion of\n // lowest index from that type. So first collect the types.\n const knownTypes = new Set(typeNames);\n const convertibleTypes = new Set();\n for (let i = 0; i < types.length; ++i) {\n for (const match of types[i].conversionsTo) {\n if (!knownTypes.has(match.from)) convertibleTypes.add(match.from);\n }\n }\n\n // Now get the lowest-index conversion for each type\n const matches = [];\n for (const typeName of convertibleTypes) {\n let bestIndex = nConversions + 1;\n let bestConversion = null;\n for (let i = 0; i < types.length; ++i) {\n for (const match of types[i].conversionsTo) {\n if (match.from === typeName && match.index < bestIndex) {\n bestIndex = match.index;\n bestConversion = match;\n }\n }\n }\n matches.push(bestConversion);\n }\n return matches;\n }\n\n /**\n * Preprocess arguments before calling the original function:\n * - if needed convert the parameters\n * - in case of rest parameters, move the rest parameters into an Array\n * @param {Param[]} params\n * @param {function} fn\n * @return {function} Returns fn or a wrapped function if needed. If it\n * has conversions, the function will be named to indicate\n * what conversions are occurring.\n */\n function compileArgsPreprocessing(params, fn) {\n let fnConvert = fn;\n\n // TODO: can we make this wrapper function smarter/simpler?\n\n let name = '';\n if (params.some(p => p.hasConversion)) {\n const restParam = hasRestParam(params);\n const compiledConversions = params.map(compileArgConversion);\n name = compiledConversions.map(conv => conv.name).join(';');\n fnConvert = function convertArgs() {\n const args = [];\n const last = restParam ? arguments.length - 1 : arguments.length;\n for (let i = 0; i < last; i++) {\n args[i] = compiledConversions[i](arguments[i]);\n }\n if (restParam) {\n args[last] = arguments[last].map(compiledConversions[last]);\n }\n return fn.apply(this, args);\n };\n }\n let fnPreprocess = fnConvert;\n if (hasRestParam(params)) {\n const offset = params.length - 1;\n fnPreprocess = function preprocessRestParams() {\n return fnConvert.apply(this, slice(arguments, 0, offset).concat([slice(arguments, offset)]));\n };\n }\n if (name) Object.defineProperty(fnPreprocess, 'name', {\n value: name\n });\n return fnPreprocess;\n }\n\n /**\n * Compile conversion for a parameter to the right type\n * @param {Param} param\n * @return {function} Returns the wrapped function that will convert arguments\n *\n */\n function compileArgConversion(param) {\n let test0, test1, conversion0, conversion1;\n const tests = [];\n const conversions = [];\n let name = '';\n param.types.forEach(function (type) {\n if (type.conversion) {\n name += type.conversion.from + '~>' + type.conversion.to + ',';\n tests.push(findType(type.conversion.from).test);\n conversions.push(type.conversion.convert);\n }\n });\n if (name) name = name.slice(0, -1);else name = 'pass';\n\n // create optimized conversion functions depending on the number of conversions\n let convertor = arg => arg;\n switch (conversions.length) {\n case 0:\n break;\n case 1:\n test0 = tests[0];\n conversion0 = conversions[0];\n convertor = function convertArg(arg) {\n if (test0(arg)) {\n return conversion0(arg);\n }\n return arg;\n };\n break;\n case 2:\n test0 = tests[0];\n test1 = tests[1];\n conversion0 = conversions[0];\n conversion1 = conversions[1];\n convertor = function convertArg(arg) {\n if (test0(arg)) {\n return conversion0(arg);\n }\n if (test1(arg)) {\n return conversion1(arg);\n }\n return arg;\n };\n break;\n default:\n convertor = function convertArg(arg) {\n for (let i = 0; i < conversions.length; i++) {\n if (tests[i](arg)) {\n return conversions[i](arg);\n }\n }\n return arg;\n };\n }\n Object.defineProperty(convertor, 'name', {\n value: name\n });\n return convertor;\n }\n\n /**\n * Split params with union types in to separate params.\n *\n * For example:\n *\n * splitParams([['Array', 'Object'], ['string', 'RegExp'])\n * // returns:\n * // [\n * // ['Array', 'string'],\n * // ['Array', 'RegExp'],\n * // ['Object', 'string'],\n * // ['Object', 'RegExp']\n * // ]\n *\n * @param {Param[]} params\n * @return {Param[]}\n */\n function splitParams(params) {\n function _splitParams(params, index, paramsSoFar) {\n if (index < params.length) {\n const param = params[index];\n let resultingParams = [];\n if (param.restParam) {\n // split the types of a rest parameter in two:\n // one with only exact types, and one with exact types and conversions\n const exactTypes = param.types.filter(isExactType);\n if (exactTypes.length < param.types.length) {\n resultingParams.push({\n types: exactTypes,\n name: '...' + exactTypes.map(t => t.name).join('|'),\n hasAny: exactTypes.some(t => t.isAny),\n hasConversion: false,\n restParam: true\n });\n }\n resultingParams.push(param);\n } else {\n // split all the types of a regular parameter into one type per param\n resultingParams = param.types.map(function (type) {\n return {\n types: [type],\n name: type.name,\n hasAny: type.isAny,\n hasConversion: type.conversion,\n restParam: false\n };\n });\n }\n\n // recurse over the groups with types\n return flatMap(resultingParams, function (nextParam) {\n return _splitParams(params, index + 1, paramsSoFar.concat([nextParam]));\n });\n } else {\n // we've reached the end of the parameters.\n return [paramsSoFar];\n }\n }\n return _splitParams(params, 0, []);\n }\n\n /**\n * Test whether two param lists represent conflicting signatures\n * @param {Param[]} params1\n * @param {Param[]} params2\n * @return {boolean} Returns true when the signatures conflict, false otherwise.\n */\n function conflicting(params1, params2) {\n const ii = Math.max(params1.length, params2.length);\n for (let i = 0; i < ii; i++) {\n const typeSet1 = getTypeSetAtIndex(params1, i);\n const typeSet2 = getTypeSetAtIndex(params2, i);\n let overlap = false;\n let name;\n for (name of typeSet2) {\n if (typeSet1.has(name)) {\n overlap = true;\n break;\n }\n }\n if (!overlap) {\n return false;\n }\n }\n const len1 = params1.length;\n const len2 = params2.length;\n const restParam1 = hasRestParam(params1);\n const restParam2 = hasRestParam(params2);\n return restParam1 ? restParam2 ? len1 === len2 : len2 >= len1 : restParam2 ? len1 >= len2 : len1 === len2;\n }\n\n /**\n * Helper function for `resolveReferences` that returns a copy of\n * functionList wihe any prior resolutions cleared out, in case we are\n * recycling signatures from a prior typed function construction.\n *\n * @param {Array.} functionList\n * @return {Array.}\n */\n function clearResolutions(functionList) {\n return functionList.map(fn => {\n if (isReferToSelf(fn)) {\n return referToSelf(fn.referToSelf.callback);\n }\n if (isReferTo(fn)) {\n return makeReferTo(fn.referTo.references, fn.referTo.callback);\n }\n return fn;\n });\n }\n\n /**\n * Take a list of references, a list of functions functionList, and a\n * signatureMap indexing signatures into functionList, and return\n * the list of resolutions, or a false-y value if they don't all\n * resolve in a valid way (yet).\n *\n * @param {string[]} references\n * @param {Array} signatureMap\n * @return {function[] | false} resolutions\n */\n function collectResolutions(references, functionList, signatureMap) {\n const resolvedReferences = [];\n let reference;\n for (reference of references) {\n let resolution = signatureMap[reference];\n if (typeof resolution !== 'number') {\n throw new TypeError('No definition for referenced signature \"' + reference + '\"');\n }\n resolution = functionList[resolution];\n if (typeof resolution !== 'function') {\n return false;\n }\n resolvedReferences.push(resolution);\n }\n return resolvedReferences;\n }\n\n /**\n * Resolve any references in the functionList for the typed function\n * itself. The signatureMap tells which index in the functionList a\n * given signature should be mapped to (for use in resolving typed.referTo)\n * and self provides the destions of a typed.referToSelf.\n *\n * @param {Array} functionList\n * @param {Object.} signatureMap\n * @param {function} self The typed-function itself\n * @return {Array} The list of resolved functions\n */\n function resolveReferences(functionList, signatureMap, self) {\n const resolvedFunctions = clearResolutions(functionList);\n const isResolved = new Array(resolvedFunctions.length).fill(false);\n let leftUnresolved = true;\n while (leftUnresolved) {\n leftUnresolved = false;\n let nothingResolved = true;\n for (let i = 0; i < resolvedFunctions.length; ++i) {\n if (isResolved[i]) continue;\n const fn = resolvedFunctions[i];\n if (isReferToSelf(fn)) {\n resolvedFunctions[i] = fn.referToSelf.callback(self);\n // Preserve reference in case signature is reused someday:\n resolvedFunctions[i].referToSelf = fn.referToSelf;\n isResolved[i] = true;\n nothingResolved = false;\n } else if (isReferTo(fn)) {\n const resolvedReferences = collectResolutions(fn.referTo.references, resolvedFunctions, signatureMap);\n if (resolvedReferences) {\n resolvedFunctions[i] = fn.referTo.callback.apply(this, resolvedReferences);\n // Preserve reference in case signature is reused someday:\n resolvedFunctions[i].referTo = fn.referTo;\n isResolved[i] = true;\n nothingResolved = false;\n } else {\n leftUnresolved = true;\n }\n }\n }\n if (nothingResolved && leftUnresolved) {\n throw new SyntaxError('Circular reference detected in resolving typed.referTo');\n }\n }\n return resolvedFunctions;\n }\n\n /**\n * Validate whether any of the function bodies contains a self-reference\n * usage like `this(...)` or `this.signatures`. This self-referencing is\n * deprecated since typed-function v3. It has been replaced with\n * the functions typed.referTo and typed.referToSelf.\n * @param {Object.} signaturesMap\n */\n function validateDeprecatedThis(signaturesMap) {\n // TODO: remove this deprecation warning logic some day (it's introduced in v3)\n\n // match occurrences like 'this(' and 'this.signatures'\n const deprecatedThisRegex = /\\bthis(\\(|\\.signatures\\b)/;\n Object.keys(signaturesMap).forEach(signature => {\n const fn = signaturesMap[signature];\n if (deprecatedThisRegex.test(fn.toString())) {\n throw new SyntaxError('Using `this` to self-reference a function ' + 'is deprecated since typed-function@3. ' + 'Use typed.referTo and typed.referToSelf instead.');\n }\n });\n }\n\n /**\n * Create a typed function\n * @param {String} name The name for the typed function\n * @param {Object.} rawSignaturesMap\n * An object with one or\n * multiple signatures as key, and the\n * function corresponding to the\n * signature as value.\n * @return {function} Returns the created typed function.\n */\n function createTypedFunction(name, rawSignaturesMap) {\n typed.createCount++;\n if (Object.keys(rawSignaturesMap).length === 0) {\n throw new SyntaxError('No signatures provided');\n }\n if (typed.warnAgainstDeprecatedThis) {\n validateDeprecatedThis(rawSignaturesMap);\n }\n\n // Main processing loop for signatures\n const parsedParams = [];\n const originalFunctions = [];\n const signaturesMap = {};\n const preliminarySignatures = []; // may have duplicates from conversions\n let signature;\n for (signature in rawSignaturesMap) {\n // A) Protect against polluted Object prototype:\n if (!Object.prototype.hasOwnProperty.call(rawSignaturesMap, signature)) {\n continue;\n }\n // B) Parse the signature\n const params = parseSignature(signature);\n if (!params) continue;\n // C) Check for conflicts\n parsedParams.forEach(function (pp) {\n if (conflicting(pp, params)) {\n throw new TypeError('Conflicting signatures \"' + stringifyParams(pp) + '\" and \"' + stringifyParams(params) + '\".');\n }\n });\n parsedParams.push(params);\n // D) Store the provided function and add conversions\n const functionIndex = originalFunctions.length;\n originalFunctions.push(rawSignaturesMap[signature]);\n const conversionParams = params.map(expandParam);\n // E) Split the signatures and collect them up\n let sp;\n for (sp of splitParams(conversionParams)) {\n const spName = stringifyParams(sp);\n preliminarySignatures.push({\n params: sp,\n name: spName,\n fn: functionIndex\n });\n if (sp.every(p => !p.hasConversion)) {\n signaturesMap[spName] = functionIndex;\n }\n }\n }\n preliminarySignatures.sort(compareSignatures);\n\n // Note the forward reference to theTypedFn\n const resolvedFunctions = resolveReferences(originalFunctions, signaturesMap, theTypedFn);\n\n // Fill in the proper function for each signature\n let s;\n for (s in signaturesMap) {\n if (Object.prototype.hasOwnProperty.call(signaturesMap, s)) {\n signaturesMap[s] = resolvedFunctions[signaturesMap[s]];\n }\n }\n const signatures = [];\n const internalSignatureMap = new Map(); // benchmarks faster than object\n for (s of preliminarySignatures) {\n // Note it's only safe to eliminate duplicates like this\n // _after_ the signature sorting step above; otherwise we might\n // remove the wrong one.\n if (!internalSignatureMap.has(s.name)) {\n s.fn = resolvedFunctions[s.fn];\n signatures.push(s);\n internalSignatureMap.set(s.name, s);\n }\n }\n\n // we create a highly optimized checks for the first couple of signatures with max 2 arguments\n const ok0 = signatures[0] && signatures[0].params.length <= 2 && !hasRestParam(signatures[0].params);\n const ok1 = signatures[1] && signatures[1].params.length <= 2 && !hasRestParam(signatures[1].params);\n const ok2 = signatures[2] && signatures[2].params.length <= 2 && !hasRestParam(signatures[2].params);\n const ok3 = signatures[3] && signatures[3].params.length <= 2 && !hasRestParam(signatures[3].params);\n const ok4 = signatures[4] && signatures[4].params.length <= 2 && !hasRestParam(signatures[4].params);\n const ok5 = signatures[5] && signatures[5].params.length <= 2 && !hasRestParam(signatures[5].params);\n const allOk = ok0 && ok1 && ok2 && ok3 && ok4 && ok5;\n\n // compile the tests\n for (let i = 0; i < signatures.length; ++i) {\n signatures[i].test = compileTests(signatures[i].params);\n }\n const test00 = ok0 ? compileTest(signatures[0].params[0]) : notOk;\n const test10 = ok1 ? compileTest(signatures[1].params[0]) : notOk;\n const test20 = ok2 ? compileTest(signatures[2].params[0]) : notOk;\n const test30 = ok3 ? compileTest(signatures[3].params[0]) : notOk;\n const test40 = ok4 ? compileTest(signatures[4].params[0]) : notOk;\n const test50 = ok5 ? compileTest(signatures[5].params[0]) : notOk;\n const test01 = ok0 ? compileTest(signatures[0].params[1]) : notOk;\n const test11 = ok1 ? compileTest(signatures[1].params[1]) : notOk;\n const test21 = ok2 ? compileTest(signatures[2].params[1]) : notOk;\n const test31 = ok3 ? compileTest(signatures[3].params[1]) : notOk;\n const test41 = ok4 ? compileTest(signatures[4].params[1]) : notOk;\n const test51 = ok5 ? compileTest(signatures[5].params[1]) : notOk;\n\n // compile the functions\n for (let i = 0; i < signatures.length; ++i) {\n signatures[i].implementation = compileArgsPreprocessing(signatures[i].params, signatures[i].fn);\n }\n const fn0 = ok0 ? signatures[0].implementation : undef;\n const fn1 = ok1 ? signatures[1].implementation : undef;\n const fn2 = ok2 ? signatures[2].implementation : undef;\n const fn3 = ok3 ? signatures[3].implementation : undef;\n const fn4 = ok4 ? signatures[4].implementation : undef;\n const fn5 = ok5 ? signatures[5].implementation : undef;\n const len0 = ok0 ? signatures[0].params.length : -1;\n const len1 = ok1 ? signatures[1].params.length : -1;\n const len2 = ok2 ? signatures[2].params.length : -1;\n const len3 = ok3 ? signatures[3].params.length : -1;\n const len4 = ok4 ? signatures[4].params.length : -1;\n const len5 = ok5 ? signatures[5].params.length : -1;\n\n // simple and generic, but also slow\n const iStart = allOk ? 6 : 0;\n const iEnd = signatures.length;\n // de-reference ahead for execution speed:\n const tests = signatures.map(s => s.test);\n const fns = signatures.map(s => s.implementation);\n const generic = function generic() {\n\n for (let i = iStart; i < iEnd; i++) {\n if (tests[i](arguments)) {\n return fns[i].apply(this, arguments);\n }\n }\n return typed.onMismatch(name, arguments, signatures);\n };\n\n // create the typed function\n // fast, specialized version. Falls back to the slower, generic one if needed\n function theTypedFn(arg0, arg1) {\n\n if (arguments.length === len0 && test00(arg0) && test01(arg1)) {\n return fn0.apply(this, arguments);\n }\n if (arguments.length === len1 && test10(arg0) && test11(arg1)) {\n return fn1.apply(this, arguments);\n }\n if (arguments.length === len2 && test20(arg0) && test21(arg1)) {\n return fn2.apply(this, arguments);\n }\n if (arguments.length === len3 && test30(arg0) && test31(arg1)) {\n return fn3.apply(this, arguments);\n }\n if (arguments.length === len4 && test40(arg0) && test41(arg1)) {\n return fn4.apply(this, arguments);\n }\n if (arguments.length === len5 && test50(arg0) && test51(arg1)) {\n return fn5.apply(this, arguments);\n }\n return generic.apply(this, arguments);\n }\n\n // attach name the typed function\n try {\n Object.defineProperty(theTypedFn, 'name', {\n value: name\n });\n } catch (err) {\n // old browsers do not support Object.defineProperty and some don't support setting the name property\n // the function name is not essential for the functioning, it's mostly useful for debugging,\n // so it's fine to have unnamed functions.\n }\n\n // attach signatures to the function.\n // This property is close to the original collection of signatures\n // used to create the typed-function, just with unions split:\n theTypedFn.signatures = signaturesMap;\n\n // Store internal data for functions like resolve, find, etc.\n // Also serves as the flag that this is a typed-function\n theTypedFn._typedFunctionData = {\n signatures,\n signatureMap: internalSignatureMap\n };\n return theTypedFn;\n }\n\n /**\n * Action to take on mismatch\n * @param {string} name Name of function that was attempted to be called\n * @param {Array} args Actual arguments to the call\n * @param {Array} signatures Known signatures of the named typed-function\n */\n function _onMismatch(name, args, signatures) {\n throw createError(name, args, signatures);\n }\n\n /**\n * Return all but the last items of an array or function Arguments\n * @param {Array | Arguments} arr\n * @return {Array}\n */\n function initial(arr) {\n return slice(arr, 0, arr.length - 1);\n }\n\n /**\n * return the last item of an array or function Arguments\n * @param {Array | Arguments} arr\n * @return {*}\n */\n function last(arr) {\n return arr[arr.length - 1];\n }\n\n /**\n * Slice an array or function Arguments\n * @param {Array | Arguments | IArguments} arr\n * @param {number} start\n * @param {number} [end]\n * @return {Array}\n */\n function slice(arr, start, end) {\n return Array.prototype.slice.call(arr, start, end);\n }\n\n /**\n * Return the first item from an array for which test(arr[i]) returns true\n * @param {Array} arr\n * @param {function} test\n * @return {* | undefined} Returns the first matching item\n * or undefined when there is no match\n */\n function findInArray(arr, test) {\n for (let i = 0; i < arr.length; i++) {\n if (test(arr[i])) {\n return arr[i];\n }\n }\n return undefined;\n }\n\n /**\n * Flat map the result invoking a callback for every item in an array.\n * https://gist.github.com/samgiles/762ee337dff48623e729\n * @param {Array} arr\n * @param {function} callback\n * @return {Array}\n */\n function flatMap(arr, callback) {\n return Array.prototype.concat.apply([], arr.map(callback));\n }\n\n /**\n * Create a reference callback to one or multiple signatures\n *\n * Syntax:\n *\n * typed.referTo(signature1, signature2, ..., function callback(fn1, fn2, ...) {\n * // ...\n * })\n *\n * @returns {{referTo: {references: string[], callback}}}\n */\n function referTo() {\n const references = initial(arguments).map(s => stringifyParams(parseSignature(s)));\n const callback = last(arguments);\n if (typeof callback !== 'function') {\n throw new TypeError('Callback function expected as last argument');\n }\n return makeReferTo(references, callback);\n }\n function makeReferTo(references, callback) {\n return {\n referTo: {\n references,\n callback\n }\n };\n }\n\n /**\n * Create a reference callback to the typed-function itself\n *\n * @param {(self: function) => function} callback\n * @returns {{referToSelf: { callback: function }}}\n */\n function referToSelf(callback) {\n if (typeof callback !== 'function') {\n throw new TypeError('Callback function expected as first argument');\n }\n return {\n referToSelf: {\n callback\n }\n };\n }\n\n /**\n * Test whether something is a referTo object, holding a list with reference\n * signatures and a callback.\n *\n * @param {Object | function} objectOrFn\n * @returns {boolean}\n */\n function isReferTo(objectOrFn) {\n return objectOrFn && typeof objectOrFn.referTo === 'object' && Array.isArray(objectOrFn.referTo.references) && typeof objectOrFn.referTo.callback === 'function';\n }\n\n /**\n * Test whether something is a referToSelf object, holding a callback where\n * to pass `self`.\n *\n * @param {Object | function} objectOrFn\n * @returns {boolean}\n */\n function isReferToSelf(objectOrFn) {\n return objectOrFn && typeof objectOrFn.referToSelf === 'object' && typeof objectOrFn.referToSelf.callback === 'function';\n }\n\n /**\n * Check if name is (A) new, (B) a match, or (C) a mismatch; and throw\n * an error in case (C).\n *\n * @param { string | undefined } nameSoFar\n * @param { string | undefined } newName\n * @returns { string } updated name\n */\n function checkName(nameSoFar, newName) {\n if (!nameSoFar) {\n return newName;\n }\n if (newName && newName !== nameSoFar) {\n const err = new Error('Function names do not match (expected: ' + nameSoFar + ', actual: ' + newName + ')');\n err.data = {\n actual: newName,\n expected: nameSoFar\n };\n throw err;\n }\n return nameSoFar;\n }\n\n /**\n * Retrieve the implied name from an object with signature keys\n * and function values, checking whether all value names match\n *\n * @param { {string: function} } obj\n */\n function getObjectName(obj) {\n let name;\n for (const key in obj) {\n // Only pay attention to own properties, and only if their values\n // are typed functions or functions with a signature property\n if (Object.prototype.hasOwnProperty.call(obj, key) && (isTypedFunction(obj[key]) || typeof obj[key].signature === 'string')) {\n name = checkName(name, obj[key].name);\n }\n }\n return name;\n }\n\n /**\n * Copy all of the signatures from the second argument into the first,\n * which is modified by side effect, checking for conflicts\n *\n * @param {Object.} dest\n * @param {Object.} source\n */\n function mergeSignatures(dest, source) {\n let key;\n for (key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n if (key in dest) {\n if (source[key] !== dest[key]) {\n const err = new Error('Signature \"' + key + '\" is defined twice');\n err.data = {\n signature: key,\n sourceFunction: source[key],\n destFunction: dest[key]\n };\n throw err;\n }\n // else: both signatures point to the same function, that's fine\n }\n dest[key] = source[key];\n }\n }\n }\n const saveTyped = typed;\n\n /**\n * Originally the main function was a typed function itself, but then\n * it might not be able to generate error messages if the client\n * replaced the type system with different names.\n *\n * Main entry: typed([name], functions/objects with signatures...)\n *\n * Assembles and returns a new typed-function from the given items\n * that provide signatures and implementations, each of which may be\n * * a plain object mapping (string) signatures to implementing functions,\n * * a previously constructed typed function, or\n * * any other single function with a string-valued property `signature`.\n * The name of the resulting typed-function will be given by the\n * string-valued name argument if present, or if not, by the name\n * of any of the arguments that have one, as long as any that do are\n * consistent with each other. If no name is specified, the name will be\n * an empty string.\n *\n * @param {string} maybeName [optional]\n * @param {(function|object)[]} signature providers\n * @returns {typed-function}\n */\n typed = function (maybeName) {\n const named = typeof maybeName === 'string';\n const start = named ? 1 : 0;\n let name = named ? maybeName : '';\n const allSignatures = {};\n for (let i = start; i < arguments.length; ++i) {\n const item = arguments[i];\n let theseSignatures = {};\n let thisName;\n if (typeof item === 'function') {\n thisName = item.name;\n if (typeof item.signature === 'string') {\n // Case 1: Ordinary function with a string 'signature' property\n theseSignatures[item.signature] = item;\n } else if (isTypedFunction(item)) {\n // Case 2: Existing typed function\n theseSignatures = item.signatures;\n }\n } else if (isPlainObject(item)) {\n // Case 3: Plain object, assume keys = signatures, values = functions\n theseSignatures = item;\n if (!named) {\n thisName = getObjectName(item);\n }\n }\n if (Object.keys(theseSignatures).length === 0) {\n const err = new TypeError('Argument to \\'typed\\' at index ' + i + ' is not a (typed) function, ' + 'nor an object with signatures as keys and functions as values.');\n err.data = {\n index: i,\n argument: item\n };\n throw err;\n }\n if (!named) {\n name = checkName(name, thisName);\n }\n mergeSignatures(allSignatures, theseSignatures);\n }\n return createTypedFunction(name || '', allSignatures);\n };\n typed.create = create;\n typed.createCount = saveTyped.createCount;\n typed.onMismatch = _onMismatch;\n typed.throwMismatchError = _onMismatch;\n typed.createError = createError;\n typed.clear = clear;\n typed.clearConversions = clearConversions;\n typed.addTypes = addTypes;\n typed._findType = findType; // For unit testing only\n typed.referTo = referTo;\n typed.referToSelf = referToSelf;\n typed.convert = convert;\n typed.findSignature = findSignature;\n typed.find = find;\n typed.isTypedFunction = isTypedFunction;\n typed.warnAgainstDeprecatedThis = true;\n\n /**\n * add a type (convenience wrapper for typed.addTypes)\n * @param {{name: string, test: function}} type\n * @param {boolean} [beforeObjectTest=true]\n * If true, the new test will be inserted before\n * the test with name 'Object' (if any), since\n * tests for Object match Array and classes too.\n */\n typed.addType = function (type, beforeObjectTest) {\n let before = 'any';\n if (beforeObjectTest !== false && typeMap.has('Object')) {\n before = 'Object';\n }\n typed.addTypes([type], before);\n };\n\n /**\n * Verify that the ConversionDef conversion has a valid format.\n *\n * @param {conversionDef} conversion\n * @return {void}\n * @throws {TypeError|SyntaxError}\n */\n function _validateConversion(conversion) {\n if (!conversion || typeof conversion.from !== 'string' || typeof conversion.to !== 'string' || typeof conversion.convert !== 'function') {\n throw new TypeError('Object with properties {from: string, to: string, convert: function} expected');\n }\n if (conversion.to === conversion.from) {\n throw new SyntaxError('Illegal to define conversion from \"' + conversion.from + '\" to itself.');\n }\n }\n\n /**\n * Add a conversion\n *\n * @param {ConversionDef} conversion\n * @param {{override: boolean}} [options]\n * @returns {void}\n * @throws {TypeError}\n */\n typed.addConversion = function (conversion) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n override: false\n };\n _validateConversion(conversion);\n const to = findType(conversion.to);\n const existing = to.conversionsTo.find(other => other.from === conversion.from);\n if (existing) {\n if (options && options.override) {\n typed.removeConversion({\n from: existing.from,\n to: conversion.to,\n convert: existing.convert\n });\n } else {\n throw new Error('There is already a conversion from \"' + conversion.from + '\" to \"' + to.name + '\"');\n }\n }\n to.conversionsTo.push({\n from: conversion.from,\n to: to.name,\n convert: conversion.convert,\n index: nConversions++\n });\n };\n\n /**\n * Convenience wrapper to call addConversion on each conversion in a list.\n *\n * @param {ConversionDef[]} conversions\n * @param {{override: boolean}} [options]\n * @returns {void}\n * @throws {TypeError}\n */\n typed.addConversions = function (conversions, options) {\n conversions.forEach(conversion => typed.addConversion(conversion, options));\n };\n\n /**\n * Remove the specified conversion. The format is the same as for\n * addConversion, and the convert function must match or an error\n * is thrown.\n *\n * @param {{from: string, to: string, convert: function}} conversion\n * @returns {void}\n * @throws {TypeError|SyntaxError|Error}\n */\n typed.removeConversion = function (conversion) {\n _validateConversion(conversion);\n const to = findType(conversion.to);\n const existingConversion = findInArray(to.conversionsTo, c => c.from === conversion.from);\n if (!existingConversion) {\n throw new Error('Attempt to remove nonexistent conversion from ' + conversion.from + ' to ' + conversion.to);\n }\n if (existingConversion.convert !== conversion.convert) {\n throw new Error('Conversion to remove does not match existing conversion');\n }\n const index = to.conversionsTo.indexOf(existingConversion);\n to.conversionsTo.splice(index, 1);\n };\n\n /**\n * Produce the specific signature that a typed function\n * will execute on the given arguments. Here, a \"signature\" is an\n * object with properties 'params', 'test', 'fn', and 'implementation'.\n * This last property is a function that converts params as necessary\n * and then calls 'fn'. Returns null if there is no matching signature.\n * @param {typed-function} tf\n * @param {any[]} argList\n * @returns {{params: string, test: function, fn: function, implementation: function}}\n */\n typed.resolve = function (tf, argList) {\n if (!isTypedFunction(tf)) {\n throw new TypeError(NOT_TYPED_FUNCTION);\n }\n const sigs = tf._typedFunctionData.signatures;\n for (let i = 0; i < sigs.length; ++i) {\n if (sigs[i].test(argList)) {\n return sigs[i];\n }\n }\n return null;\n };\n return typed;\n }\n var typedFunction = create();\n\n return typedFunction;\n\n}));\n//# sourceMappingURL=typed-function.js.map\n","/**\n * Create a typed-function which checks the types of the arguments and\n * can match them against multiple provided signatures. The typed-function\n * automatically converts inputs in order to find a matching signature.\n * Typed functions throw informative errors in case of wrong input arguments.\n *\n * See the library [typed-function](https://github.com/josdejong/typed-function)\n * for detailed documentation.\n *\n * Syntax:\n *\n * math.typed(name, signatures) : function\n * math.typed(signatures) : function\n *\n * Examples:\n *\n * // create a typed function with multiple types per argument (type union)\n * const fn2 = typed({\n * 'number | boolean': function (b) {\n * return 'b is a number or boolean'\n * },\n * 'string, number | boolean': function (a, b) {\n * return 'a is a string, b is a number or boolean'\n * }\n * })\n *\n * // create a typed function with an any type argument\n * const log = typed({\n * 'string, any': function (event, data) {\n * console.log('event: ' + event + ', data: ' + JSON.stringify(data))\n * }\n * })\n *\n * @param {string} [name] Optional name for the typed-function\n * @param {Object} signatures Object with one or multiple function signatures\n * @returns {function} The created typed-function.\n */\n\nimport typedFunction from 'typed-function';\nimport { factory } from '../../utils/factory.js';\nimport { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigInt, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMap, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isRelationalNode, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';\nimport { digits } from '../../utils/number.js';\n\n// returns a new instance of typed-function\nvar _createTyped2 = function _createTyped() {\n // initially, return the original instance of typed-function\n // consecutively, return a new instance from typed.create.\n _createTyped2 = typedFunction.create;\n return typedFunction;\n};\nvar dependencies = ['?BigNumber', '?Complex', '?DenseMatrix', '?Fraction'];\n\n/**\n * Factory function for creating a new typed instance\n * @param {Object} dependencies Object with data types like Complex and BigNumber\n * @returns {Function}\n */\nexport var createTyped = /* #__PURE__ */factory('typed', dependencies, function createTyped(_ref) {\n var {\n BigNumber,\n Complex,\n DenseMatrix,\n Fraction\n } = _ref;\n // TODO: typed-function must be able to silently ignore signatures with unknown data types\n\n // get a new instance of typed-function\n var typed = _createTyped2();\n\n // define all types. The order of the types determines in which order function\n // arguments are type-checked (so for performance it's important to put the\n // most used types first).\n typed.clear();\n typed.addTypes([{\n name: 'number',\n test: isNumber\n }, {\n name: 'Complex',\n test: isComplex\n }, {\n name: 'BigNumber',\n test: isBigNumber\n }, {\n name: 'bigint',\n test: isBigInt\n }, {\n name: 'Fraction',\n test: isFraction\n }, {\n name: 'Unit',\n test: isUnit\n },\n // The following type matches a valid variable name, i.e., an alphanumeric\n // string starting with an alphabetic character. It is used (at least)\n // in the definition of the derivative() function, as the argument telling\n // what to differentiate over must (currently) be a variable.\n // TODO: deprecate the identifier type (it's not used anymore, see https://github.com/josdejong/mathjs/issues/3253)\n {\n name: 'identifier',\n test: s => isString && /^(?:[A-Za-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C\\u0C5D\\u0C60\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-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?:[0-9A-Za-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088F\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5C\\u0C5D\\u0C60\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDC-\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C8A\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7DC\\uA7F1-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\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uDD41\\uDDA0-\\uDDA7\\uDDAA-\\uDDD0\\uDDE1\\uDDE3\\uDE00\\uDE0B-\\uDE32\\uDE3A\\uDE50\\uDE5C-\\uDE89\\uDE9D\\uDEB0-\\uDEF8\\uDFC0-\\uDFE0]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDDB0-\\uDDDB\\uDEE0-\\uDEF2\\uDF02\\uDF04-\\uDF10\\uDF12-\\uDF33\\uDFB0]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC80-\\uDD43]|\\uD80B[\\uDF90-\\uDFF0]|[\\uD80C\\uD80E\\uD80F\\uD81C-\\uD822\\uD840-\\uD868\\uD86A-\\uD86D\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883\\uD885-\\uD88C][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2F\\uDC41-\\uDC46\\uDC60-\\uDFFF]|\\uD810[\\uDC00-\\uDFFA]|\\uD811[\\uDC00-\\uDE46]|\\uD818[\\uDD00-\\uDD1D]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDE70-\\uDEBE\\uDED0-\\uDEED\\uDF00-\\uDF2F\\uDF40-\\uDF43\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDD40-\\uDD6C\\uDE40-\\uDE7F\\uDEA0-\\uDEB8\\uDEBB-\\uDED3\\uDF00-\\uDF4A\\uDF50\\uDF93-\\uDF9F\\uDFE0\\uDFE1\\uDFE3\\uDFF2\\uDFF3]|\\uD823[\\uDC00-\\uDCD5\\uDCFF-\\uDD1E\\uDD80-\\uDDF2]|\\uD82B[\\uDFF0-\\uDFF3\\uDFF5-\\uDFFB\\uDFFD\\uDFFE]|\\uD82C[\\uDC00-\\uDD22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E51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDEDF\\uDF00-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEAD\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0\\uDFF0-\\uDFFF]|\\uD87B[\\uDC00-\\uDE5D]|\\uD87E[\\uDC00-\\uDE1D]|\\uD884[\\uDC00-\\uDF4A\\uDF50-\\uDFFF]|\\uD88D[\\uDC00-\\uDC79])*$/.test(s)\n }, {\n name: 'string',\n test: isString\n }, {\n name: 'Chain',\n test: isChain\n }, {\n name: 'Array',\n test: isArray\n }, {\n name: 'Matrix',\n test: isMatrix\n }, {\n name: 'DenseMatrix',\n test: isDenseMatrix\n }, {\n name: 'SparseMatrix',\n test: isSparseMatrix\n }, {\n name: 'Range',\n test: isRange\n }, {\n name: 'Index',\n test: isIndex\n }, {\n name: 'boolean',\n test: isBoolean\n }, {\n name: 'ResultSet',\n test: isResultSet\n }, {\n name: 'Help',\n test: isHelp\n }, {\n name: 'function',\n test: isFunction\n }, {\n name: 'Date',\n test: isDate\n }, {\n name: 'RegExp',\n test: isRegExp\n }, {\n name: 'null',\n test: isNull\n }, {\n name: 'undefined',\n test: isUndefined\n }, {\n name: 'AccessorNode',\n test: isAccessorNode\n }, {\n name: 'ArrayNode',\n test: isArrayNode\n }, {\n name: 'AssignmentNode',\n test: isAssignmentNode\n }, {\n name: 'BlockNode',\n test: isBlockNode\n }, {\n name: 'ConditionalNode',\n test: isConditionalNode\n }, {\n name: 'ConstantNode',\n test: isConstantNode\n }, {\n name: 'FunctionNode',\n test: isFunctionNode\n }, {\n name: 'FunctionAssignmentNode',\n test: isFunctionAssignmentNode\n }, {\n name: 'IndexNode',\n test: isIndexNode\n }, {\n name: 'Node',\n test: isNode\n }, {\n name: 'ObjectNode',\n test: isObjectNode\n }, {\n name: 'OperatorNode',\n test: isOperatorNode\n }, {\n name: 'ParenthesisNode',\n test: isParenthesisNode\n }, {\n name: 'RangeNode',\n test: isRangeNode\n }, {\n name: 'RelationalNode',\n test: isRelationalNode\n }, {\n name: 'SymbolNode',\n test: isSymbolNode\n }, {\n name: 'Map',\n test: isMap\n }, {\n name: 'Object',\n test: isObject\n } // order 'Object' last, it matches on other classes too\n ]);\n typed.addConversions([{\n from: 'number',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n\n // note: conversion from number to BigNumber can fail if x has >15 digits\n if (digits(x) > 15) {\n throw new TypeError('Cannot implicitly convert a number with >15 significant digits to BigNumber ' + '(value: ' + x + '). ' + 'Use function bignumber(x) to convert to BigNumber.');\n }\n return new BigNumber(x);\n }\n }, {\n from: 'number',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x, 0);\n }\n }, {\n from: 'BigNumber',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x.toNumber(), 0);\n }\n }, {\n from: 'bigint',\n to: 'number',\n convert: function convert(x) {\n if (x > Number.MAX_SAFE_INTEGER) {\n throw new TypeError('Cannot implicitly convert bigint to number: ' + 'value exceeds the max safe integer value (value: ' + x + ')');\n }\n return Number(x);\n }\n }, {\n from: 'bigint',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n return new BigNumber(x.toString());\n }\n }, {\n from: 'bigint',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n return new Fraction(x);\n }\n }, {\n from: 'Fraction',\n to: 'BigNumber',\n convert: function convert(x) {\n throw new TypeError('Cannot implicitly convert a Fraction to BigNumber or vice versa. ' + 'Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.');\n }\n }, {\n from: 'Fraction',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n return new Complex(x.valueOf(), 0);\n }\n }, {\n from: 'number',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n var f = new Fraction(x);\n if (f.valueOf() !== x) {\n throw new TypeError('Cannot implicitly convert a number to a Fraction when there will be a loss of precision ' + '(value: ' + x + '). ' + 'Use function fraction(x) to convert to Fraction.');\n }\n return f;\n }\n }, {\n // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))`\n // from: 'Fraction',\n // to: 'number',\n // convert: function (x) {\n // return x.valueOf()\n // }\n // }, {\n from: 'string',\n to: 'number',\n convert: function convert(x) {\n var n = Number(x);\n if (isNaN(n)) {\n throw new Error('Cannot convert \"' + x + '\" to a number');\n }\n return n;\n }\n }, {\n from: 'string',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n try {\n return new BigNumber(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to BigNumber');\n }\n }\n }, {\n from: 'string',\n to: 'bigint',\n convert: function convert(x) {\n try {\n return BigInt(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to BigInt');\n }\n }\n }, {\n from: 'string',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n try {\n return new Fraction(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to Fraction');\n }\n }\n }, {\n from: 'string',\n to: 'Complex',\n convert: function convert(x) {\n if (!Complex) {\n throwNoComplex(x);\n }\n try {\n return new Complex(x);\n } catch (err) {\n throw new Error('Cannot convert \"' + x + '\" to Complex');\n }\n }\n }, {\n from: 'boolean',\n to: 'number',\n convert: function convert(x) {\n return +x;\n }\n }, {\n from: 'boolean',\n to: 'BigNumber',\n convert: function convert(x) {\n if (!BigNumber) {\n throwNoBignumber(x);\n }\n return new BigNumber(+x);\n }\n }, {\n from: 'boolean',\n to: 'bigint',\n convert: function convert(x) {\n return BigInt(+x);\n }\n }, {\n from: 'boolean',\n to: 'Fraction',\n convert: function convert(x) {\n if (!Fraction) {\n throwNoFraction(x);\n }\n return new Fraction(+x);\n }\n }, {\n from: 'boolean',\n to: 'string',\n convert: function convert(x) {\n return String(x);\n }\n }, {\n from: 'Array',\n to: 'Matrix',\n convert: function convert(array) {\n if (!DenseMatrix) {\n throwNoMatrix();\n }\n return new DenseMatrix(array);\n }\n }, {\n from: 'Matrix',\n to: 'Array',\n convert: function convert(matrix) {\n return matrix.valueOf();\n }\n }]);\n\n // Provide a suggestion on how to call a function elementwise\n // This was added primarily as guidance for the v10 -> v11 transition,\n // and could potentially be removed in the future if it no longer seems\n // to be helpful.\n typed.onMismatch = (name, args, signatures) => {\n var usualError = typed.createError(name, args, signatures);\n if (['wrongType', 'mismatch'].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) &&\n // check if the function can be unary:\n signatures.some(sig => !sig.params.includes(','))) {\n var err = new TypeError(\"Function '\".concat(name, \"' doesn't apply to matrices. To call it \") + \"elementwise on a matrix 'M', try 'map(M, \".concat(name, \")'.\"));\n err.data = usualError.data;\n throw err;\n }\n throw usualError;\n };\n\n // Provide a suggestion on how to call a function elementwise\n // This was added primarily as guidance for the v10 -> v11 transition,\n // and could potentially be removed in the future if it no longer seems\n // to be helpful.\n typed.onMismatch = (name, args, signatures) => {\n var usualError = typed.createError(name, args, signatures);\n if (['wrongType', 'mismatch'].includes(usualError.data.category) && args.length === 1 && isCollection(args[0]) &&\n // check if the function can be unary:\n signatures.some(sig => !sig.params.includes(','))) {\n var err = new TypeError(\"Function '\".concat(name, \"' doesn't apply to matrices. To call it \") + \"elementwise on a matrix 'M', try 'map(M, \".concat(name, \")'.\"));\n err.data = usualError.data;\n throw err;\n }\n throw usualError;\n };\n return typed;\n});\nfunction throwNoBignumber(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a BigNumber: no class 'BigNumber' provided\"));\n}\nfunction throwNoComplex(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a Complex number: no class 'Complex' provided\"));\n}\nfunction throwNoMatrix() {\n throw new Error('Cannot convert array into a Matrix: no class \\'DenseMatrix\\' provided');\n}\nfunction throwNoFraction(x) {\n throw new Error(\"Cannot convert value \".concat(x, \" into a Fraction, no class 'Fraction' provided.\"));\n}","import { factory } from '../../utils/factory.js';\nvar name = 'ResultSet';\nvar dependencies = [];\nexport var createResultSet = /* #__PURE__ */factory(name, dependencies, () => {\n /**\n * A ResultSet contains a list or results\n * @class ResultSet\n * @param {Array} entries\n * @constructor ResultSet\n */\n function ResultSet(entries) {\n if (!(this instanceof ResultSet)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.entries = entries || [];\n }\n\n /**\n * Attach type information\n */\n ResultSet.prototype.type = 'ResultSet';\n ResultSet.prototype.isResultSet = true;\n\n /**\n * Returns the array with results hold by this ResultSet\n * @memberof ResultSet\n * @returns {Array} entries\n */\n ResultSet.prototype.valueOf = function () {\n return this.entries;\n };\n\n /**\n * Returns the stringified results of the ResultSet\n * @memberof ResultSet\n * @returns {string} string\n */\n ResultSet.prototype.toString = function () {\n return '[' + this.entries.map(String).join(', ') + ']';\n };\n\n /**\n * Get a JSON representation of the ResultSet\n * @memberof ResultSet\n * @returns {Object} Returns a JSON object structured as:\n * `{\"mathjs\": \"ResultSet\", \"entries\": [...]}`\n */\n ResultSet.prototype.toJSON = function () {\n return {\n mathjs: 'ResultSet',\n entries: this.entries\n };\n };\n\n /**\n * Instantiate a ResultSet from a JSON object\n * @memberof ResultSet\n * @param {Object} json A JSON object structured as:\n * `{\"mathjs\": \"ResultSet\", \"entries\": [...]}`\n * @return {ResultSet}\n */\n ResultSet.fromJSON = function (json) {\n return new ResultSet(json.entries);\n };\n return ResultSet;\n}, {\n isClass: true\n});","import { isBigNumber, isNumber } from '../is.js';\nimport { isInteger, normalizeFormatOptions } from '../number.js';\n\n/**\n * Formats a BigNumber in a given base\n * @param {BigNumber} n\n * @param {number} base\n * @param {number} size\n * @returns {string}\n */\nfunction formatBigNumberToBase(n, base, size) {\n var BigNumberCtor = n.constructor;\n var big2 = new BigNumberCtor(2);\n var suffix = '';\n if (size) {\n if (size < 1) {\n throw new Error('size must be in greater than 0');\n }\n if (!isInteger(size)) {\n throw new Error('size must be an integer');\n }\n if (n.greaterThan(big2.pow(size - 1).sub(1)) || n.lessThan(big2.pow(size - 1).mul(-1))) {\n throw new Error(\"Value must be in range [-2^\".concat(size - 1, \", 2^\").concat(size - 1, \"-1]\"));\n }\n if (!n.isInteger()) {\n throw new Error('Value must be an integer');\n }\n if (n.lessThan(0)) {\n n = n.add(big2.pow(size));\n }\n suffix = \"i\".concat(size);\n }\n switch (base) {\n case 2:\n return \"\".concat(n.toBinary()).concat(suffix);\n case 8:\n return \"\".concat(n.toOctal()).concat(suffix);\n case 16:\n return \"\".concat(n.toHexadecimal()).concat(suffix);\n default:\n throw new Error(\"Base \".concat(base, \" not supported \"));\n }\n}\n\n/**\n * Convert a BigNumber to a formatted string representation.\n *\n * Syntax:\n *\n * format(value)\n * format(value, options)\n * format(value, precision)\n * format(value, fn)\n *\n * Where:\n *\n * {number} value The value to be formatted\n * {Object} options An object with formatting options. Available options:\n * {string} notation\n * Number notation. Choose from:\n * 'fixed' Always use regular number notation.\n * For example '123.40' and '14000000'\n * 'exponential' Always use exponential notation.\n * For example '1.234e+2' and '1.4e+7'\n * 'auto' (default) Regular number notation for numbers\n * having an absolute value between\n * `lower` and `upper` bounds, and uses\n * exponential notation elsewhere.\n * Lower bound is included, upper bound\n * is excluded.\n * For example '123.4' and '1.4e7'.\n * 'bin', 'oct, or\n * 'hex' Format the number using binary, octal,\n * or hexadecimal notation.\n * For example '0b1101' and '0x10fe'.\n * {number} wordSize The word size in bits to use for formatting\n * in binary, octal, or hexadecimal notation.\n * To be used only with 'bin', 'oct', or 'hex'\n * values for 'notation' option. When this option\n * is defined the value is formatted as a signed\n * twos complement integer of the given word size\n * and the size suffix is appended to the output.\n * For example\n * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.\n * Default value is undefined.\n * {number} precision A number between 0 and 16 to round\n * the digits of the number.\n * In case of notations 'exponential',\n * 'engineering', and 'auto',\n * `precision` defines the total\n * number of significant digits returned.\n * In case of notation 'fixed',\n * `precision` defines the number of\n * significant digits after the decimal\n * point.\n * `precision` is undefined by default.\n * {number} lowerExp Exponent determining the lower boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `-3`.\n * {number} upperExp Exponent determining the upper boundary\n * for formatting a value with an exponent\n * when `notation='auto`.\n * Default value is `5`.\n * {Function} fn A custom formatting function. Can be used to override the\n * built-in notations. Function `fn` is called with `value` as\n * parameter and must return a string. Is useful for example to\n * format all values inside a matrix in a particular way.\n *\n * Examples:\n *\n * format(6.4) // '6.4'\n * format(1240000) // '1.24e6'\n * format(1/3) // '0.3333333333333333'\n * format(1/3, 3) // '0.333'\n * format(21385, 2) // '21000'\n * format(12e8, {notation: 'fixed'}) // returns '1200000000'\n * format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'\n * format(52.8, {notation: 'exponential'}) // returns '5.28e+1'\n * format(12400, {notation: 'engineering'}) // returns '12.400e+3'\n *\n * @param {BigNumber} value\n * @param {Object | Function | number | BigNumber} [options]\n * @return {string} str The formatted value\n */\nexport function format(value, options) {\n if (typeof options === 'function') {\n // handle format(value, fn)\n return options(value);\n }\n\n // handle special cases\n if (!value.isFinite()) {\n return value.isNaN() ? 'NaN' : value.gt(0) ? 'Infinity' : '-Infinity';\n }\n var {\n notation,\n precision,\n wordSize\n } = normalizeFormatOptions(options);\n\n // handle the various notations\n switch (notation) {\n case 'fixed':\n return toFixed(value, precision);\n case 'exponential':\n return toExponential(value, precision);\n case 'engineering':\n return toEngineering(value, precision);\n case 'bin':\n return formatBigNumberToBase(value, 2, wordSize);\n case 'oct':\n return formatBigNumberToBase(value, 8, wordSize);\n case 'hex':\n return formatBigNumberToBase(value, 16, wordSize);\n case 'auto':\n {\n // determine lower and upper bound for exponential notation.\n // TODO: implement support for upper and lower to be BigNumbers themselves\n var lowerExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.lowerExp, -3);\n var upperExp = _toNumberOrDefault(options === null || options === void 0 ? void 0 : options.upperExp, 5);\n\n // handle special case zero\n if (value.isZero()) return '0';\n\n // determine whether or not to output exponential notation\n var str;\n var rounded = value.toSignificantDigits(precision);\n var exp = rounded.e;\n if (exp >= lowerExp && exp < upperExp) {\n // normal number notation\n str = rounded.toFixed();\n } else {\n // exponential notation\n str = toExponential(value, precision);\n }\n\n // remove trailing zeros after the decimal point\n return str.replace(/((\\.\\d*?)(0+))($|e)/, function () {\n var digits = arguments[2];\n var e = arguments[4];\n return digits !== '.' ? digits + e : e;\n });\n }\n default:\n throw new Error('Unknown notation \"' + notation + '\". ' + 'Choose \"auto\", \"exponential\", \"fixed\", \"bin\", \"oct\", or \"hex.');\n }\n}\n\n/**\n * Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'\n * @param {BigNumber} value\n * @param {number} [precision] Optional number of significant figures to return.\n */\nexport function toEngineering(value, precision) {\n // find nearest lower multiple of 3 for exponent\n var e = value.e;\n var newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;\n\n // find difference in exponents, and calculate the value without exponent\n var valueWithoutExp = value.mul(Math.pow(10, -newExp));\n var valueStr = valueWithoutExp.toPrecision(precision);\n if (valueStr.includes('e')) {\n var BigNumber = value.constructor;\n valueStr = new BigNumber(valueStr).toFixed();\n }\n return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();\n}\n\n/**\n * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'\n * @param {BigNumber} value\n * @param {number} [precision] Number of digits in formatted output.\n * If not provided, the maximum available digits\n * is used.\n * @returns {string} str\n */\nexport function toExponential(value, precision) {\n if (precision !== undefined) {\n return value.toExponential(precision - 1); // Note the offset of one\n } else {\n return value.toExponential();\n }\n}\n\n/**\n * Format a number with fixed notation.\n * @param {BigNumber} value\n * @param {number} [precision=undefined] Optional number of decimals after the\n * decimal point. Undefined by default.\n */\nexport function toFixed(value, precision) {\n return value.toFixed(precision);\n}\nfunction _toNumberOrDefault(value, defaultValue) {\n if (isNumber(value)) {\n return value;\n } else if (isBigNumber(value)) {\n return value.toNumber();\n } else {\n return defaultValue;\n }\n}","import { isBigNumber, isString, typeOf } from './is.js';\nimport { format as formatNumber } from './number.js';\nimport { format as formatBigNumber } from './bignumber/formatter.js';\n\n/**\n * Check if a text ends with a certain string.\n * @param {string} text\n * @param {string} search\n */\nexport function endsWith(text, search) {\n var start = text.length - search.length;\n var end = text.length;\n return text.substring(start, end) === search;\n}\n\n/**\n * Format a value of any type into a string.\n *\n * Usage:\n * math.format(value)\n * math.format(value, precision)\n * math.format(value, options)\n *\n * When value is a function:\n *\n * - When the function has a property `syntax`, it returns this\n * syntax description.\n * - In other cases, a string `'function'` is returned.\n *\n * When `value` is an Object:\n *\n * - When the object contains a property `format` being a function, this\n * function is invoked as `value.format(options)` and the result is returned.\n * - When the object has its own `toString` method, this method is invoked\n * and the result is returned.\n * - In other cases the function will loop over all object properties and\n * return JSON object notation like '{\"a\": 2, \"b\": 3}'.\n *\n * Example usage:\n * math.format(2/7) // '0.2857142857142857'\n * math.format(math.pi, 3) // '3.14'\n * math.format(new Complex(2, 3)) // '2 + 3i'\n * math.format('hello') // '\"hello\"'\n *\n * @param {*} value Value to be stringified\n * @param {Object | number | Function} [options]\n * Formatting options. See src/utils/number.js:format for a\n * description of the available options controlling number output.\n * This generic \"format\" also supports the option property `truncate: NN`\n * giving the maximum number NN of characters to return (if there would\n * have been more, they are deleted and replaced by an ellipsis).\n * @return {string} str\n */\nexport function format(value, options) {\n var result = _format(value, options);\n if (options && typeof options === 'object' && 'truncate' in options && result.length > options.truncate) {\n return result.substring(0, options.truncate - 3) + '...';\n }\n return result;\n}\nfunction _format(value, options) {\n if (typeof value === 'number') {\n return formatNumber(value, options);\n }\n if (isBigNumber(value)) {\n return formatBigNumber(value, options);\n }\n\n // note: we use unsafe duck-typing here to check for Fractions, this is\n // ok here since we're only invoking toString or concatenating its values\n if (looksLikeFraction(value)) {\n if (!options || options.fraction !== 'decimal') {\n // output as ratio, like '1/3'\n return \"\".concat(value.s * value.n, \"/\").concat(value.d);\n } else {\n // output as decimal, like '0.(3)'\n return value.toString();\n }\n }\n if (Array.isArray(value)) {\n return formatArray(value, options);\n }\n if (isString(value)) {\n return stringify(value);\n }\n if (typeof value === 'function') {\n return value.syntax ? String(value.syntax) : 'function';\n }\n if (value && typeof value === 'object') {\n if (typeof value.format === 'function') {\n return value.format(options);\n } else if (value && value.toString(options) !== {}.toString()) {\n // this object has a non-native toString method, use that one\n return value.toString(options);\n } else {\n var entries = Object.keys(value).map(key => {\n return stringify(key) + ': ' + format(value[key], options);\n });\n return '{' + entries.join(', ') + '}';\n }\n }\n return String(value);\n}\n\n/**\n * Stringify a value into a string enclosed in double quotes.\n * Unescaped double quotes and backslashes inside the value are escaped.\n * @param {*} value\n * @return {string}\n */\nexport function stringify(value) {\n var text = String(value);\n var escaped = '';\n var i = 0;\n while (i < text.length) {\n var c = text.charAt(i);\n escaped += c in controlCharacters ? controlCharacters[c] : c;\n i++;\n }\n return '\"' + escaped + '\"';\n}\nvar controlCharacters = {\n '\"': '\\\\\"',\n '\\\\': '\\\\\\\\',\n '\\b': '\\\\b',\n '\\f': '\\\\f',\n '\\n': '\\\\n',\n '\\r': '\\\\r',\n '\\t': '\\\\t'\n};\n\n/**\n * Escape special HTML characters\n * @param {*} value\n * @return {string}\n */\nexport function escape(value) {\n var text = String(value);\n text = text.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(//g, '>');\n return text;\n}\n\n/**\n * Recursively format an n-dimensional matrix\n * Example output: \"[[1, 2], [3, 4]]\"\n * @param {Array} array\n * @param {Object | number | Function} [options] Formatting options. See\n * lib/utils/number:format for a\n * description of the available\n * options.\n * @returns {string} str\n */\nfunction formatArray(array, options) {\n if (Array.isArray(array)) {\n var str = '[';\n var len = array.length;\n for (var i = 0; i < len; i++) {\n if (i !== 0) {\n str += ', ';\n }\n str += formatArray(array[i], options);\n }\n str += ']';\n return str;\n } else {\n return format(array, options);\n }\n}\n\n/**\n * Check whether a value looks like a Fraction (unsafe duck-type check)\n * @param {*} value\n * @return {boolean}\n */\nfunction looksLikeFraction(value) {\n return value && typeof value === 'object' && typeof value.s === 'bigint' && typeof value.n === 'bigint' && typeof value.d === 'bigint' || false;\n}\n\n/**\n * Compare two strings\n * @param {string} x\n * @param {string} y\n * @returns {number}\n */\nexport function compareText(x, y) {\n // we don't want to convert numbers to string, only accept string input\n if (!isString(x)) {\n throw new TypeError('Unexpected type of argument in function compareText ' + '(expected: string or Array or Matrix, actual: ' + typeOf(x) + ', index: 0)');\n }\n if (!isString(y)) {\n throw new TypeError('Unexpected type of argument in function compareText ' + '(expected: string or Array or Matrix, actual: ' + typeOf(y) + ', index: 1)');\n }\n return x === y ? 0 : x > y ? 1 : -1;\n}","function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}\nexport { _typeof as default };","import _typeof from \"./typeof.js\";\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nexport { toPrimitive as default };","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nexport { toPropertyKey as default };","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nexport { _defineProperty as default };","// list of identifiers of nodes in order of their precedence\n// also contains information about left/right associativity\n// and which other operator the operator is associative with\n// Example:\n// addition is associative with addition and subtraction, because:\n// (a+b)+c=a+(b+c)\n// (a+b)-c=a+(b-c)\n//\n// postfix operators are left associative, prefix operators\n// are right associative\n//\n// It's also possible to set the following properties:\n// latexParens: if set to false, this node doesn't need to be enclosed\n// in parentheses when using LaTeX\n// latexLeftParens: if set to false, this !OperatorNode's!\n// left argument doesn't need to be enclosed\n// in parentheses\n// latexRightParens: the same for the right argument\nimport { hasOwnProperty } from '../utils/object.js';\nimport { isConstantNode, isParenthesisNode, rule2Node } from '../utils/is.js';\nexport var properties = [{\n // assignment\n AssignmentNode: {},\n FunctionAssignmentNode: {}\n}, {\n // conditional expression\n ConditionalNode: {\n latexLeftParens: false,\n latexRightParens: false,\n latexParens: false\n // conditionals don't need parentheses in LaTeX because\n // they are 2 dimensional\n }\n}, {\n // logical or\n 'OperatorNode:or': {\n op: 'or',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // logical xor\n 'OperatorNode:xor': {\n op: 'xor',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // logical and\n 'OperatorNode:and': {\n op: 'and',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise or\n 'OperatorNode:bitOr': {\n op: '|',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise xor\n 'OperatorNode:bitXor': {\n op: '^|',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitwise and\n 'OperatorNode:bitAnd': {\n op: '&',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // relational operators\n 'OperatorNode:equal': {\n op: '==',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:unequal': {\n op: '!=',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:smaller': {\n op: '<',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:larger': {\n op: '>',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:smallerEq': {\n op: '<=',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:largerEq': {\n op: '>=',\n associativity: 'left',\n associativeWith: []\n },\n RelationalNode: {\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // bitshift operators\n 'OperatorNode:leftShift': {\n op: '<<',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:rightArithShift': {\n op: '>>',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:rightLogShift': {\n op: '>>>',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // unit conversion\n 'OperatorNode:to': {\n op: 'to',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // range\n RangeNode: {}\n}, {\n // addition, subtraction\n 'OperatorNode:add': {\n op: '+',\n associativity: 'left',\n associativeWith: ['OperatorNode:add', 'OperatorNode:subtract']\n },\n 'OperatorNode:subtract': {\n op: '-',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // multiply, divide, modulus\n 'OperatorNode:multiply': {\n op: '*',\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']\n },\n 'OperatorNode:divide': {\n op: '/',\n associativity: 'left',\n associativeWith: [],\n latexLeftParens: false,\n latexRightParens: false,\n latexParens: false\n // fractions don't require parentheses because\n // they're 2 dimensional, so parens aren't needed\n // in LaTeX\n },\n 'OperatorNode:dotMultiply': {\n op: '.*',\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'OperatorNode:dotMultiply', 'OperatorNode:doDivide']\n },\n 'OperatorNode:dotDivide': {\n op: './',\n associativity: 'left',\n associativeWith: []\n },\n 'OperatorNode:mod': {\n op: 'mod',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // Repeat multiplication for implicit multiplication\n 'OperatorNode:multiply': {\n associativity: 'left',\n associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']\n }\n}, {\n // unary prefix operators\n 'OperatorNode:unaryPlus': {\n op: '+',\n associativity: 'right'\n },\n 'OperatorNode:unaryMinus': {\n op: '-',\n associativity: 'right'\n },\n 'OperatorNode:bitNot': {\n op: '~',\n associativity: 'right'\n },\n 'OperatorNode:not': {\n op: 'not',\n associativity: 'right'\n }\n}, {\n // exponentiation\n 'OperatorNode:pow': {\n op: '^',\n associativity: 'right',\n associativeWith: [],\n latexRightParens: false\n // the exponent doesn't need parentheses in\n // LaTeX because it's 2 dimensional\n // (it's on top)\n },\n 'OperatorNode:dotPow': {\n op: '.^',\n associativity: 'right',\n associativeWith: []\n }\n}, {\n // nullish coalescing\n 'OperatorNode:nullish': {\n op: '??',\n associativity: 'left',\n associativeWith: []\n }\n}, {\n // factorial\n 'OperatorNode:factorial': {\n op: '!',\n associativity: 'left'\n }\n}, {\n // matrix transpose\n 'OperatorNode:ctranspose': {\n op: \"'\",\n associativity: 'left'\n }\n}];\n\n/**\n * Returns the first non-parenthesis internal node, but only\n * when the 'parenthesis' option is unset or auto.\n * @param {Node} _node\n * @param {string} parenthesis\n * @return {Node}\n */\nfunction unwrapParen(_node, parenthesis) {\n if (!parenthesis || parenthesis !== 'auto') return _node;\n var node = _node;\n while (isParenthesisNode(node)) node = node.content;\n return node;\n}\n\n/**\n * Get the precedence of a Node.\n * Higher number for higher precedence, starting with 0.\n * Returns null if the precedence is undefined.\n *\n * @param {Node} _node\n * @param {string} parenthesis\n * @param {string} implicit\n * @param {Node} parent (for determining context for implicit multiplication)\n * @return {number | null}\n */\nexport function getPrecedence(_node, parenthesis, implicit, parent) {\n var node = _node;\n if (parenthesis !== 'keep') {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n node = _node.getContent();\n }\n var identifier = node.getIdentifier();\n var precedence = null;\n for (var i = 0; i < properties.length; i++) {\n if (identifier in properties[i]) {\n precedence = i;\n break;\n }\n }\n // Bump up precedence of implicit multiplication, except when preceded\n // by a \"Rule 2\" fraction ( [unaryOp]constant / constant )\n if (identifier === 'OperatorNode:multiply' && node.implicit && implicit !== 'show') {\n var leftArg = unwrapParen(node.args[0], parenthesis);\n if (!(isConstantNode(leftArg) && parent && parent.getIdentifier() === 'OperatorNode:divide' && rule2Node(unwrapParen(parent.args[0], parenthesis))) && !(leftArg.getIdentifier() === 'OperatorNode:divide' && rule2Node(unwrapParen(leftArg.args[0], parenthesis)) && isConstantNode(unwrapParen(leftArg.args[1])))) {\n precedence += 1;\n }\n }\n return precedence;\n}\n\n/**\n * Get the associativity of an operator (left or right).\n * Returns a string containing 'left' or 'right' or null if\n * the associativity is not defined.\n *\n * @param {Node} _node\n * @param {string} parenthesis\n * @return {string|null}\n * @throws {Error}\n */\nexport function getAssociativity(_node, parenthesis) {\n var node = _node;\n if (parenthesis !== 'keep') {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n node = _node.getContent();\n }\n var identifier = node.getIdentifier();\n var index = getPrecedence(node, parenthesis);\n if (index === null) {\n // node isn't in the list\n return null;\n }\n var property = properties[index][identifier];\n if (hasOwnProperty(property, 'associativity')) {\n if (property.associativity === 'left') {\n return 'left';\n }\n if (property.associativity === 'right') {\n return 'right';\n }\n // associativity is invalid\n throw Error('\\'' + identifier + '\\' has the invalid associativity \\'' + property.associativity + '\\'.');\n }\n\n // associativity is undefined\n return null;\n}\n\n/**\n * Check if an operator is associative with another operator.\n * Returns either true or false or null if not defined.\n *\n * @param {Node} nodeA\n * @param {Node} nodeB\n * @param {string} parenthesis\n * @return {boolean | null}\n */\nexport function isAssociativeWith(nodeA, nodeB, parenthesis) {\n // ParenthesisNodes are only ignored when not in 'keep' mode\n var a = parenthesis !== 'keep' ? nodeA.getContent() : nodeA;\n var b = parenthesis !== 'keep' ? nodeA.getContent() : nodeB;\n var identifierA = a.getIdentifier();\n var identifierB = b.getIdentifier();\n var index = getPrecedence(a, parenthesis);\n if (index === null) {\n // node isn't in the list\n return null;\n }\n var property = properties[index][identifierA];\n if (hasOwnProperty(property, 'associativeWith') && property.associativeWith instanceof Array) {\n for (var i = 0; i < property.associativeWith.length; i++) {\n if (property.associativeWith[i] === identifierB) {\n return true;\n }\n }\n return false;\n }\n\n // associativeWith is not defined\n return null;\n}\n\n/**\n * Get the operator associated with a function name.\n * Returns a string with the operator symbol, or null if the\n * input is not the name of a function associated with an\n * operator.\n *\n * @param {string} Function name\n * @return {string | null} Associated operator symbol, if any\n */\nexport function getOperator(fn) {\n var identifier = 'OperatorNode:' + fn;\n for (var group of properties) {\n if (identifier in group) {\n return group[identifier].op;\n }\n }\n return null;\n}","/**\n * Create a range error with the message:\n * 'Index out of range (index < min)'\n * 'Index out of range (index < max)'\n *\n * @param {number} index The actual index\n * @param {number} [min=0] Minimum index (included)\n * @param {number} [max] Maximum index (excluded)\n * @extends RangeError\n */\nexport function IndexError(index, min, max) {\n if (!(this instanceof IndexError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.index = index;\n if (arguments.length < 3) {\n this.min = 0;\n this.max = min;\n } else {\n this.min = min;\n this.max = max;\n }\n if (this.min !== undefined && this.index < this.min) {\n this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')';\n } else if (this.max !== undefined && this.index >= this.max) {\n this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')';\n } else {\n this.message = 'Index out of range (' + this.index + ')';\n }\n this.stack = new Error().stack;\n}\nIndexError.prototype = new RangeError();\nIndexError.prototype.constructor = RangeError;\nIndexError.prototype.name = 'IndexError';\nIndexError.prototype.isIndexError = true;","/**\n * Create a range error with the message:\n * 'Dimension mismatch ( != )'\n * @param {number | number[]} actual The actual size\n * @param {number | number[]} expected The expected size\n * @param {string} [relation='!='] Optional relation between actual\n * and expected size: '!=', '<', etc.\n * @extends RangeError\n */\nexport function DimensionError(actual, expected, relation) {\n if (!(this instanceof DimensionError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.actual = actual;\n this.expected = expected;\n this.relation = relation;\n this.message = 'Dimension mismatch (' + (Array.isArray(actual) ? '[' + actual.join(', ') + ']' : actual) + ' ' + (this.relation || '!=') + ' ' + (Array.isArray(expected) ? '[' + expected.join(', ') + ']' : expected) + ')';\n this.stack = new Error().stack;\n}\nDimensionError.prototype = new RangeError();\nDimensionError.prototype.constructor = RangeError;\nDimensionError.prototype.name = 'DimensionError';\nDimensionError.prototype.isDimensionError = true;","import _extends from \"@babel/runtime/helpers/extends\";\nimport { isInteger } from './number.js';\nimport { isNumber, isBigNumber, isArray, isString } from './is.js';\nimport { format } from './string.js';\nimport { DimensionError } from '../error/DimensionError.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { deepStrictEqual } from './object.js';\n\n/**\n * Calculate the size of a multi dimensional array.\n * This function checks the size of the first entry, it does not validate\n * whether all dimensions match. (use function `validate` for that)\n * @param {Array} x\n * @return {number[]} size\n */\nexport function arraySize(x) {\n var s = [];\n while (Array.isArray(x)) {\n s.push(x.length);\n x = x[0];\n }\n return s;\n}\n\n/**\n * Recursively validate whether each element in a multi dimensional array\n * has a size corresponding to the provided size array.\n * @param {Array} array Array to be validated\n * @param {number[]} size Array with the size of each dimension\n * @param {number} dim Current dimension\n * @throws DimensionError\n * @private\n */\nfunction _validate(array, size, dim) {\n var i;\n var len = array.length;\n if (len !== size[dim]) {\n throw new DimensionError(len, size[dim]);\n }\n if (dim < size.length - 1) {\n // recursively validate each child array\n var dimNext = dim + 1;\n for (i = 0; i < len; i++) {\n var child = array[i];\n if (!Array.isArray(child)) {\n throw new DimensionError(size.length - 1, size.length, '<');\n }\n _validate(array[i], size, dimNext);\n }\n } else {\n // last dimension. none of the children may be an array\n for (i = 0; i < len; i++) {\n if (Array.isArray(array[i])) {\n throw new DimensionError(size.length + 1, size.length, '>');\n }\n }\n }\n}\n\n/**\n * Validate whether each element in a multi dimensional array has\n * a size corresponding to the provided size array.\n * @param {Array} array Array to be validated\n * @param {number[]} size Array with the size of each dimension\n * @throws DimensionError\n */\nexport function validate(array, size) {\n var isScalar = size.length === 0;\n if (isScalar) {\n // scalar\n if (Array.isArray(array)) {\n throw new DimensionError(array.length, 0);\n }\n } else {\n // array\n _validate(array, size, 0);\n }\n}\n\n/**\n * Validate whether the source of the index matches the size of the Array\n * @param {Array | Matrix} value Array to be validated\n * @param {Index} index Index with the source information to validate\n * @throws DimensionError\n */\nexport function validateIndexSourceSize(value, index) {\n var valueSize = value.isMatrix ? value._size : arraySize(value);\n var sourceSize = index._sourceSize;\n // checks if the source size is not null and matches the valueSize\n sourceSize.forEach((sourceDim, i) => {\n if (sourceDim !== null && sourceDim !== valueSize[i]) {\n throw new DimensionError(sourceDim, valueSize[i]);\n }\n });\n}\n\n/**\n * Test whether index is an integer number with index >= 0 and index < length\n * when length is provided\n * @param {number} index Zero-based index\n * @param {number} [length] Length of the array\n */\nexport function validateIndex(index, length) {\n if (index !== undefined) {\n if (!isNumber(index) || !isInteger(index)) {\n throw new TypeError('Index must be an integer (value: ' + index + ')');\n }\n if (index < 0 || typeof length === 'number' && index >= length) {\n throw new IndexError(index, length);\n }\n }\n}\n\n/**\n * Test if an index has empty values\n * @param {Index} index Zero-based index\n */\nexport function isEmptyIndex(index) {\n for (var i = 0; i < index._dimensions.length; ++i) {\n var dimension = index._dimensions[i];\n if (dimension._data && isArray(dimension._data)) {\n if (dimension._size[0] === 0) {\n return true;\n }\n } else if (dimension.isRange) {\n if (dimension.start === dimension.end) {\n return true;\n }\n } else if (isString(dimension)) {\n if (dimension.length === 0) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Resize a multi dimensional array. The resized array is returned.\n * @param {Array | number} array Array to be resized\n * @param {number[]} size Array with the size of each dimension\n * @param {*} [defaultValue=0] Value to be filled in new entries,\n * zero by default. Specify for example `null`,\n * to clearly see entries that are not explicitly\n * set.\n * @return {Array} array The resized array\n */\nexport function resize(array, size, defaultValue) {\n // check the type of the arguments\n if (!Array.isArray(size)) {\n throw new TypeError('Array expected');\n }\n if (size.length === 0) {\n throw new Error('Resizing to scalar is not supported');\n }\n\n // check whether size contains positive integers\n size.forEach(function (value) {\n if (!isNumber(value) || !isInteger(value) || value < 0) {\n throw new TypeError('Invalid size, must contain positive integers ' + '(size: ' + format(size) + ')');\n }\n });\n\n // convert number to an array\n if (isNumber(array) || isBigNumber(array)) {\n array = [array];\n }\n\n // recursively resize the array\n var _defaultValue = defaultValue !== undefined ? defaultValue : 0;\n _resize(array, size, 0, _defaultValue);\n return array;\n}\n\n/**\n * Recursively resize a multi dimensional array\n * @param {Array} array Array to be resized\n * @param {number[]} size Array with the size of each dimension\n * @param {number} dim Current dimension\n * @param {*} [defaultValue] Value to be filled in new entries,\n * undefined by default.\n * @private\n */\nfunction _resize(array, size, dim, defaultValue) {\n var i;\n var elem;\n var oldLen = array.length;\n var newLen = size[dim];\n var minLen = Math.min(oldLen, newLen);\n\n // apply new length\n array.length = newLen;\n if (dim < size.length - 1) {\n // non-last dimension\n var dimNext = dim + 1;\n\n // resize existing child arrays\n for (i = 0; i < minLen; i++) {\n // resize child array\n elem = array[i];\n if (!Array.isArray(elem)) {\n elem = [elem]; // add a dimension\n array[i] = elem;\n }\n _resize(elem, size, dimNext, defaultValue);\n }\n\n // create new child arrays\n for (i = minLen; i < newLen; i++) {\n // get child array\n elem = [];\n array[i] = elem;\n\n // resize new child array\n _resize(elem, size, dimNext, defaultValue);\n }\n } else {\n // last dimension\n\n // remove dimensions of existing values\n for (i = 0; i < minLen; i++) {\n while (Array.isArray(array[i])) {\n array[i] = array[i][0];\n }\n }\n\n // fill new elements with the default value\n for (i = minLen; i < newLen; i++) {\n array[i] = defaultValue;\n }\n }\n}\n\n/**\n * Re-shape a multi dimensional array to fit the specified dimensions\n * @param {Array} array Array to be reshaped\n * @param {number[]} sizes List of sizes for each dimension\n * @returns {Array} Array whose data has been formatted to fit the\n * specified dimensions\n *\n * @throws {DimensionError} If the product of the new dimension sizes does\n * not equal that of the old ones\n */\nexport function reshape(array, sizes) {\n var flatArray = flatten(array, true); // since it has rectangular\n var currentLength = flatArray.length;\n if (!Array.isArray(array) || !Array.isArray(sizes)) {\n throw new TypeError('Array expected');\n }\n if (sizes.length === 0) {\n throw new DimensionError(0, currentLength, '!=');\n }\n sizes = processSizesWildcard(sizes, currentLength);\n var newLength = product(sizes);\n if (currentLength !== newLength) {\n throw new DimensionError(newLength, currentLength, '!=');\n }\n try {\n return _reshape(flatArray, sizes);\n } catch (e) {\n if (e instanceof DimensionError) {\n throw new DimensionError(newLength, currentLength, '!=');\n }\n throw e;\n }\n}\n\n/**\n * Replaces the wildcard -1 in the sizes array.\n * @param {number[]} sizes List of sizes for each dimension. At most one wildcard.\n * @param {number} currentLength Number of elements in the array.\n * @throws {Error} If more than one wildcard or unable to replace it.\n * @returns {number[]} The sizes array with wildcard replaced.\n */\nexport function processSizesWildcard(sizes, currentLength) {\n var newLength = product(sizes);\n var processedSizes = sizes.slice();\n var WILDCARD = -1;\n var wildCardIndex = sizes.indexOf(WILDCARD);\n var isMoreThanOneWildcard = sizes.indexOf(WILDCARD, wildCardIndex + 1) >= 0;\n if (isMoreThanOneWildcard) {\n throw new Error('More than one wildcard in sizes');\n }\n var hasWildcard = wildCardIndex >= 0;\n var canReplaceWildcard = currentLength % newLength === 0;\n if (hasWildcard) {\n if (canReplaceWildcard) {\n processedSizes[wildCardIndex] = -currentLength / newLength;\n } else {\n throw new Error('Could not replace wildcard, since ' + currentLength + ' is no multiple of ' + -newLength);\n }\n }\n return processedSizes;\n}\n\n/**\n * Computes the product of all array elements.\n * @param {number[]} array Array of factors\n * @returns {number} Product of all elements\n */\nfunction product(array) {\n return array.reduce((prev, curr) => prev * curr, 1);\n}\n\n/**\n * Iteratively re-shape a multi dimensional array to fit the specified dimensions\n * @param {Array} array Array to be reshaped\n * @param {number[]} sizes List of sizes for each dimension\n * @returns {Array} Array whose data has been formatted to fit the\n * specified dimensions\n */\n\nfunction _reshape(array, sizes) {\n // testing if there are enough elements for the requested shape\n var tmpArray = array;\n var tmpArray2;\n // for each dimension starting by the last one and ignoring the first one\n for (var sizeIndex = sizes.length - 1; sizeIndex > 0; sizeIndex--) {\n var size = sizes[sizeIndex];\n tmpArray2 = [];\n\n // aggregate the elements of the current tmpArray in elements of the requested size\n var length = tmpArray.length / size;\n for (var i = 0; i < length; i++) {\n tmpArray2.push(tmpArray.slice(i * size, (i + 1) * size));\n }\n // set it as the new tmpArray for the next loop turn or for return\n tmpArray = tmpArray2;\n }\n return tmpArray;\n}\n\n/**\n * Squeeze a multi dimensional array\n * @param {Array} array\n * @param {Array} [size]\n * @returns {Array} returns the array itself\n */\nexport function squeeze(array, size) {\n var s = size || arraySize(array);\n\n // squeeze outer dimensions\n while (Array.isArray(array) && array.length === 1) {\n array = array[0];\n s.shift();\n }\n\n // find the first dimension to be squeezed\n var dims = s.length;\n while (s[dims - 1] === 1) {\n dims--;\n }\n\n // squeeze inner dimensions\n if (dims < s.length) {\n array = _squeeze(array, dims, 0);\n s.length = dims;\n }\n return array;\n}\n\n/**\n * Recursively squeeze a multi dimensional array\n * @param {Array} array\n * @param {number} dims Required number of dimensions\n * @param {number} dim Current dimension\n * @returns {Array | *} Returns the squeezed array\n * @private\n */\nfunction _squeeze(array, dims, dim) {\n var i, ii;\n if (dim < dims) {\n var next = dim + 1;\n for (i = 0, ii = array.length; i < ii; i++) {\n array[i] = _squeeze(array[i], dims, next);\n }\n } else {\n while (Array.isArray(array)) {\n array = array[0];\n }\n }\n return array;\n}\n\n/**\n * Unsqueeze a multi dimensional array: add dimensions when missing\n *\n * Parameter `size` will be mutated to match the new, unsqueezed matrix size.\n *\n * @param {Array} array\n * @param {number} dims Desired number of dimensions of the array\n * @param {number} [outer] Number of outer dimensions to be added\n * @param {Array} [size] Current size of array.\n * @returns {Array} returns the array itself\n * @private\n */\nexport function unsqueeze(array, dims, outer, size) {\n var s = size || arraySize(array);\n\n // unsqueeze outer dimensions\n if (outer) {\n for (var i = 0; i < outer; i++) {\n array = [array];\n s.unshift(1);\n }\n }\n\n // unsqueeze inner dimensions\n array = _unsqueeze(array, dims, 0);\n while (s.length < dims) {\n s.push(1);\n }\n return array;\n}\n\n/**\n * Recursively unsqueeze a multi dimensional array\n * @param {Array} array\n * @param {number} dims Required number of dimensions\n * @param {number} dim Current dimension\n * @returns {Array | *} Returns the unsqueezed array\n * @private\n */\nfunction _unsqueeze(array, dims, dim) {\n var i, ii;\n if (Array.isArray(array)) {\n var next = dim + 1;\n for (i = 0, ii = array.length; i < ii; i++) {\n array[i] = _unsqueeze(array[i], dims, next);\n }\n } else {\n for (var d = dim; d < dims; d++) {\n array = [array];\n }\n }\n return array;\n}\n/**\n * Flatten a multi dimensional array, put all elements in a one dimensional\n * array\n * @param {Array} array A multi dimensional array\n * @param {boolean} isRectangular Optional. If the array is rectangular (not jagged)\n * @return {Array} The flattened array (1 dimensional)\n */\nexport function flatten(array) {\n var isRectangular = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!Array.isArray(array)) {\n // if not an array, return as is\n return array;\n }\n if (typeof isRectangular !== 'boolean') {\n throw new TypeError('Boolean expected for second argument of flatten');\n }\n var flat = [];\n if (isRectangular) {\n _flattenRectangular(array);\n } else {\n _flatten(array);\n }\n return flat;\n function _flatten(array) {\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n if (Array.isArray(item)) {\n _flatten(item);\n } else {\n flat.push(item);\n }\n }\n }\n function _flattenRectangular(array) {\n if (Array.isArray(array[0])) {\n for (var i = 0; i < array.length; i++) {\n _flattenRectangular(array[i]);\n }\n } else {\n for (var _i = 0; _i < array.length; _i++) {\n flat.push(array[_i]);\n }\n }\n }\n}\n\n/**\n * A safe map\n * @param {Array} array\n * @param {function} callback\n */\nexport function map(array, callback) {\n return Array.prototype.map.call(array, callback);\n}\n\n/**\n * A safe forEach\n * @param {Array} array\n * @param {function} callback\n */\nexport function forEach(array, callback) {\n Array.prototype.forEach.call(array, callback);\n}\n\n/**\n * A safe filter\n * @param {Array} array\n * @param {function} callback\n */\nexport function filter(array, callback) {\n if (arraySize(array).length !== 1) {\n throw new Error('Only one dimensional matrices supported');\n }\n return Array.prototype.filter.call(array, callback);\n}\n\n/**\n * Filter values in an array given a regular expression\n * @param {Array} array\n * @param {RegExp} regexp\n * @return {Array} Returns the filtered array\n * @private\n */\nexport function filterRegExp(array, regexp) {\n if (arraySize(array).length !== 1) {\n throw new Error('Only one dimensional matrices supported');\n }\n return Array.prototype.filter.call(array, entry => regexp.test(entry));\n}\n\n/**\n * A safe join\n * @param {Array} array\n * @param {string} separator\n */\nexport function join(array, separator) {\n return Array.prototype.join.call(array, separator);\n}\n\n/**\n * Assign a numeric identifier to every element of a sorted array\n * @param {Array} a An array\n * @return {Array} An array of objects containing the original value and its identifier\n */\nexport function identify(a) {\n if (!Array.isArray(a)) {\n throw new TypeError('Array input expected');\n }\n if (a.length === 0) {\n return a;\n }\n var b = [];\n var count = 0;\n b[0] = {\n value: a[0],\n identifier: 0\n };\n for (var i = 1; i < a.length; i++) {\n if (a[i] === a[i - 1]) {\n count++;\n } else {\n count = 0;\n }\n b.push({\n value: a[i],\n identifier: count\n });\n }\n return b;\n}\n\n/**\n * Remove the numeric identifier from the elements\n * @param {array} a An array\n * @return {array} An array of values without identifiers\n */\nexport function generalize(a) {\n if (!Array.isArray(a)) {\n throw new TypeError('Array input expected');\n }\n if (a.length === 0) {\n return a;\n }\n var b = [];\n for (var i = 0; i < a.length; i++) {\n b.push(a[i].value);\n }\n return b;\n}\n\n/**\n * Check the datatype of a given object\n * This is a low level implementation that should only be used by\n * parent Matrix classes such as SparseMatrix or DenseMatrix\n * This method does not validate Array Matrix shape\n * @param {Array} array\n * @param {function} typeOf Callback function to use to determine the type of a value\n * @return {string}\n */\nexport function getArrayDataType(array, typeOf) {\n var type; // to hold type info\n var length = 0; // to hold length value to ensure it has consistent sizes\n\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n var _isArray = Array.isArray(item);\n\n // Saving the target matrix row size\n if (i === 0 && _isArray) {\n length = item.length;\n }\n\n // If the current item is an array but the length does not equal the targetVectorSize\n if (_isArray && item.length !== length) {\n return undefined;\n }\n var itemType = _isArray ? getArrayDataType(item, typeOf) // recurse into a nested array\n : typeOf(item);\n if (type === undefined) {\n type = itemType; // first item\n } else if (type !== itemType) {\n return 'mixed';\n } else {\n // we're good, everything has the same type so far\n }\n }\n return type;\n}\n\n/**\n * Return the last item from an array\n * @param {Array} array\n * @returns {*}\n */\nexport function last(array) {\n return array[array.length - 1];\n}\n\n/**\n * Get all but the last element of array.\n * @param {Array} array\n * @returns {Array}\n */\nexport function initial(array) {\n return array.slice(0, array.length - 1);\n}\n\n/**\n * Recursively concatenate two matrices.\n * The contents of the matrices are not cloned.\n * @param {Array} a Multi dimensional array\n * @param {Array} b Multi dimensional array\n * @param {number} concatDim The dimension on which to concatenate (zero-based)\n * @param {number} dim The current dim (zero-based)\n * @return {Array} c The concatenated matrix\n * @private\n */\nfunction concatRecursive(a, b, concatDim, dim) {\n if (dim < concatDim) {\n // recurse into next dimension\n if (a.length !== b.length) {\n throw new DimensionError(a.length, b.length);\n }\n var c = [];\n for (var i = 0; i < a.length; i++) {\n c[i] = concatRecursive(a[i], b[i], concatDim, dim + 1);\n }\n return c;\n } else {\n // concatenate this dimension\n return a.concat(b);\n }\n}\n\n/**\n * Concatenates many arrays in the specified direction\n * @param {...Array} arrays All the arrays to concatenate\n * @param {number} concatDim The dimension on which to concatenate (zero-based)\n * @returns {Array}\n */\nexport function concat() {\n var arrays = Array.prototype.slice.call(arguments, 0, -1);\n var concatDim = Array.prototype.slice.call(arguments, -1);\n if (arrays.length === 1) {\n return arrays[0];\n }\n if (arrays.length > 1) {\n return arrays.slice(1).reduce(function (A, B) {\n return concatRecursive(A, B, concatDim, 0);\n }, arrays[0]);\n } else {\n throw new Error('Wrong number of arguments in function concat');\n }\n}\n\n/**\n * Receives two or more sizes and gets the broadcasted size for both.\n * @param {...number[]} sizes Sizes to broadcast together\n * @returns {number[]} The broadcasted size\n */\nexport function broadcastSizes() {\n for (var _len = arguments.length, sizes = new Array(_len), _key = 0; _key < _len; _key++) {\n sizes[_key] = arguments[_key];\n }\n var dimensions = sizes.map(s => s.length);\n var N = Math.max(...dimensions);\n var sizeMax = new Array(N).fill(null);\n // check for every size\n for (var i = 0; i < sizes.length; i++) {\n var size = sizes[i];\n var dim = dimensions[i];\n for (var j = 0; j < dim; j++) {\n var n = N - dim + j;\n if (size[j] > sizeMax[n]) {\n sizeMax[n] = size[j];\n }\n }\n }\n for (var _i2 = 0; _i2 < sizes.length; _i2++) {\n checkBroadcastingRules(sizes[_i2], sizeMax);\n }\n return sizeMax;\n}\n\n/**\n * Checks if it's possible to broadcast a size to another size\n * @param {number[]} size The size of the array to check\n * @param {number[]} toSize The size of the array to validate if it can be broadcasted to\n */\nexport function checkBroadcastingRules(size, toSize) {\n var N = toSize.length;\n var dim = size.length;\n for (var j = 0; j < dim; j++) {\n var n = N - dim + j;\n if (size[j] < toSize[n] && size[j] > 1 || size[j] > toSize[n]) {\n throw new Error(\"shape mismatch: mismatch is found in arg with shape (\".concat(size, \") not possible to broadcast dimension \").concat(dim, \" with size \").concat(size[j], \" to size \").concat(toSize[n]));\n }\n }\n}\n\n/**\n * Broadcasts a single array to a certain size\n * @param {Array} array Array to be broadcasted\n * @param {number[]} toSize Size to broadcast the array\n * @returns {Array} The broadcasted array\n */\nexport function broadcastTo(array, toSize) {\n var Asize = arraySize(array);\n if (deepStrictEqual(Asize, toSize)) {\n return array;\n }\n checkBroadcastingRules(Asize, toSize);\n var broadcastedSize = broadcastSizes(Asize, toSize);\n var N = broadcastedSize.length;\n var paddedSize = [...Array(N - Asize.length).fill(1), ...Asize];\n var A = clone(array);\n // reshape A if needed to make it ready for concat\n if (Asize.length < N) {\n A = reshape(A, paddedSize);\n Asize = arraySize(A);\n }\n\n // stretches the array on each dimension to make it the same size as index\n for (var dim = 0; dim < N; dim++) {\n if (Asize[dim] < broadcastedSize[dim]) {\n A = stretch(A, broadcastedSize[dim], dim);\n Asize = arraySize(A);\n }\n }\n return A;\n}\n\n/**\n * Broadcasts arrays and returns the broadcasted arrays in an array\n * @param {...Array | any} arrays\n * @returns {Array[]} The broadcasted arrays\n */\nexport function broadcastArrays() {\n for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n arrays[_key2] = arguments[_key2];\n }\n if (arrays.length === 0) {\n throw new Error('Insufficient number of arguments in function broadcastArrays');\n }\n if (arrays.length === 1) {\n return arrays[0];\n }\n var sizes = arrays.map(function (array) {\n return arraySize(array);\n });\n var broadcastedSize = broadcastSizes(...sizes);\n var broadcastedArrays = [];\n arrays.forEach(function (array) {\n broadcastedArrays.push(broadcastTo(array, broadcastedSize));\n });\n return broadcastedArrays;\n}\n\n/**\n * Stretches a matrix up to a certain size in a certain dimension\n * @param {Array} arrayToStretch\n * @param {number[]} sizeToStretch\n * @param {number} dimToStretch\n * @returns {Array} The stretched array\n */\nexport function stretch(arrayToStretch, sizeToStretch, dimToStretch) {\n return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);\n}\n\n/**\n* Retrieves a single element from an array given an index.\n*\n* @param {Array} array - The array from which to retrieve the value.\n* @param {Array} index - An array of indices specifying the position of the desired element in each dimension.\n* @returns {*} - The value at the specified position in the array.\n*\n* @example\n* const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];\n* const index = [1, 0, 1];\n* console.log(get(arr, index)); // 6\n*/\nexport function get(array, index) {\n if (!Array.isArray(array)) {\n throw new Error('Array expected');\n }\n var size = arraySize(array);\n if (index.length !== size.length) {\n throw new DimensionError(index.length, size.length);\n }\n for (var x = 0; x < index.length; x++) {\n validateIndex(index[x], size[x]);\n }\n return index.reduce((acc, curr) => acc[curr], array);\n}\n\n/**\n * Recursively maps over each element of nested array using a provided callback function.\n *\n * @param {Array} array - The array to be mapped.\n * @param {Function} callback - The function to execute on each element, taking three arguments:\n * - `value` (any): The current element being processed in the array.\n * - `index` (Array): The index of the current element being processed in the array.\n * - `array` (Array): The array `deepMap` was called upon.\n * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.\n * @returns {Array} A new array with each element being the result of the callback function.\n */\nexport function deepMap(array, callback) {\n var skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n if (array.length === 0) {\n return [];\n }\n if (skipIndex) {\n return recursiveMap(array);\n }\n var index = [];\n return recursiveMapWithIndex(array, 0);\n function recursiveMapWithIndex(value, depth) {\n if (Array.isArray(value)) {\n var N = value.length;\n var result = Array(N);\n for (var i = 0; i < N; i++) {\n index[depth] = i;\n result[i] = recursiveMapWithIndex(value[i], depth + 1);\n }\n return result;\n } else {\n return callback(value, index.slice(0, depth), array);\n }\n }\n function recursiveMap(value) {\n if (Array.isArray(value)) {\n var N = value.length;\n var result = Array(N);\n for (var i = 0; i < N; i++) {\n result[i] = recursiveMap(value[i]);\n }\n return result;\n } else {\n return callback(value);\n }\n }\n}\n\n/**\n * Recursively iterates over each element in a multi-dimensional array and applies a callback function.\n *\n * @param {Array} array - The multi-dimensional array to iterate over.\n * @param {Function} callback - The function to execute for each element. It receives three arguments:\n * - {any} value: The current element being processed in the array.\n * - {Array} index: The index of the current element in each dimension.\n * - {Array} array: The original array being processed.\n * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.\n */\nexport function deepForEach(array, callback) {\n var skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n if (array.length === 0) {\n return;\n }\n if (skipIndex) {\n recursiveForEach(array);\n return;\n }\n var index = [];\n recursiveForEachWithIndex(array, 0);\n function recursiveForEachWithIndex(value, depth) {\n if (Array.isArray(value)) {\n var N = value.length;\n for (var i = 0; i < N; i++) {\n index[depth] = i;\n recursiveForEachWithIndex(value[i], depth + 1);\n }\n } else {\n callback(value, index.slice(0, depth), array);\n }\n }\n function recursiveForEach(value) {\n if (Array.isArray(value)) {\n var N = value.length;\n for (var i = 0; i < N; i++) {\n recursiveForEach(value[i]);\n }\n } else {\n callback(value);\n }\n }\n}\n\n/**\n * Deep clones a multidimensional array\n * @param {Array} array\n * @returns {Array} cloned array\n */\nexport function clone(array) {\n return _extends([], array);\n}","import { isCollection, isMatrix } from './is.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { arraySize, deepMap as arrayDeepMap, deepForEach as arrayDeepForEach } from './array.js';\nimport { _switch } from './switch.js';\n\n/**\n * Test whether an array contains collections\n * @param {Array} array\n * @returns {boolean} Returns true when the array contains one or multiple\n * collections (Arrays or Matrices). Returns false otherwise.\n */\nexport function containsCollections(array) {\n for (var i = 0; i < array.length; i++) {\n if (isCollection(array[i])) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Recursively loop over all elements in a given multi dimensional array\n * and invoke the callback on each of the elements.\n * @param {Array | Matrix} array\n * @param {Function} callback The callback method is invoked with one\n * parameter: the current element in the array\n */\nexport function deepForEach(array, callback) {\n if (isMatrix(array)) {\n array.forEach(x => callback(x), false, true);\n } else {\n arrayDeepForEach(array, callback, true);\n }\n}\n\n/**\n * Execute the callback function element wise for each element in array and any\n * nested array\n * Returns an array with the results\n * @param {Array | Matrix} array\n * @param {Function} callback The callback is called with two parameters:\n * value1 and value2, which contain the current\n * element of both arrays.\n * @param {boolean} [skipZeros] Invoke callback function for non-zero values only.\n *\n * @return {Array | Matrix} res\n */\nexport function deepMap(array, callback, skipZeros) {\n if (!skipZeros) {\n if (isMatrix(array)) {\n return array.map(x => callback(x), false, true);\n } else {\n return arrayDeepMap(array, callback, true);\n }\n }\n var skipZerosCallback = x => x === 0 ? x : callback(x);\n if (isMatrix(array)) {\n return array.map(x => skipZerosCallback(x), false, true);\n } else {\n return arrayDeepMap(array, skipZerosCallback, true);\n }\n}\n\n/**\n * Reduce a given matrix or array to a new matrix or\n * array with one less dimension, applying the given\n * callback in the selected dimension.\n * @param {Array | Matrix} mat\n * @param {number} dim\n * @param {Function} callback\n * @return {Array | Matrix} res\n */\nexport function reduce(mat, dim, callback) {\n var size = Array.isArray(mat) ? arraySize(mat) : mat.size();\n if (dim < 0 || dim >= size.length) {\n // TODO: would be more clear when throwing a DimensionError here\n throw new IndexError(dim, size.length);\n }\n if (isMatrix(mat)) {\n return mat.create(_reduce(mat.valueOf(), dim, callback), mat.datatype());\n } else {\n return _reduce(mat, dim, callback);\n }\n}\n\n/**\n * Recursively reduce a matrix\n * @param {Array} mat\n * @param {number} dim\n * @param {Function} callback\n * @returns {Array} ret\n * @private\n */\nfunction _reduce(mat, dim, callback) {\n var i, ret, val, tran;\n if (dim <= 0) {\n if (!Array.isArray(mat[0])) {\n val = mat[0];\n for (i = 1; i < mat.length; i++) {\n val = callback(val, mat[i]);\n }\n return val;\n } else {\n tran = _switch(mat);\n ret = [];\n for (i = 0; i < tran.length; i++) {\n ret[i] = _reduce(tran[i], dim - 1, callback);\n }\n return ret;\n }\n } else {\n ret = [];\n for (i = 0; i < mat.length; i++) {\n ret[i] = _reduce(mat[i], dim - 1, callback);\n }\n return ret;\n }\n}\n\n// TODO: document function scatter\nexport function scatter(a, j, w, x, u, mark, cindex, f, inverse, update, value) {\n // a arrays\n var avalues = a._values;\n var aindex = a._index;\n var aptr = a._ptr;\n\n // vars\n var k, k0, k1, i;\n\n // check we need to process values (pattern matrix)\n if (x) {\n // values in j\n for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {\n // row\n i = aindex[k];\n // check value exists in current j\n if (w[i] !== mark) {\n // i is new entry in j\n w[i] = mark;\n // add i to pattern of C\n cindex.push(i);\n // x(i) = A, check we need to call function this time\n if (update) {\n // copy value to workspace calling callback function\n x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]);\n // function was called on current row\n u[i] = mark;\n } else {\n // copy value to workspace\n x[i] = avalues[k];\n }\n } else {\n // i exists in C already\n x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]);\n // function was called on current row\n u[i] = mark;\n }\n }\n } else {\n // values in j\n for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {\n // row\n i = aindex[k];\n // check value exists in current j\n if (w[i] !== mark) {\n // i is new entry in j\n w[i] = mark;\n // add i to pattern of C\n cindex.push(i);\n } else {\n // indicate function was called on current row\n u[i] = mark;\n }\n }\n }\n}","// (c) 2018, Mariusz Nowak\n// SPDX-License-Identifier: ISC\n// Derived from https://github.com/medikoo/lru-queue\nexport function lruQueue(limit) {\n var size = 0;\n var base = 1;\n var queue = Object.create(null);\n var map = Object.create(null);\n var index = 0;\n var del = function del(id) {\n var oldIndex = map[id];\n if (!oldIndex) return;\n delete queue[oldIndex];\n delete map[id];\n --size;\n if (base !== oldIndex) return;\n if (!size) {\n index = 0;\n base = 1;\n return;\n }\n while (!Object.prototype.hasOwnProperty.call(queue, ++base)) {/* empty */}\n };\n limit = Math.abs(limit);\n return {\n hit: function hit(id) {\n var oldIndex = map[id];\n var nuIndex = ++index;\n queue[nuIndex] = id;\n map[id] = nuIndex;\n if (!oldIndex) {\n ++size;\n if (size <= limit) return undefined;\n id = queue[base];\n del(id);\n return id;\n }\n delete queue[oldIndex];\n if (base !== oldIndex) return undefined;\n while (!Object.prototype.hasOwnProperty.call(queue, ++base)) {/* empty */}\n return undefined;\n },\n delete: del,\n clear: function clear() {\n size = index = 0;\n base = 1;\n queue = Object.create(null);\n map = Object.create(null);\n }\n };\n}","// function utils\n\nimport { lruQueue } from './lruQueue.js';\n\n/**\n * Memoize a given function by caching the computed result.\n * The cache of a memoized function can be cleared by deleting the `cache`\n * property of the function.\n *\n * @param {function} fn The function to be memoized.\n * Must be a pure function.\n * @param {Object} [options]\n * @param {function(args: Array): string} [options.hasher]\n * A custom hash builder. Is JSON.stringify by default.\n * @param {number | undefined} [options.limit]\n * Maximum number of values that may be cached. Undefined indicates\n * unlimited (default)\n * @return {function} Returns the memoized function\n */\nexport function memoize(fn) {\n var {\n hasher,\n limit\n } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n limit = limit == null ? Number.POSITIVE_INFINITY : limit;\n hasher = hasher == null ? JSON.stringify : hasher;\n return function memoize() {\n if (typeof memoize.cache !== 'object') {\n memoize.cache = {\n values: new Map(),\n lru: lruQueue(limit || Number.POSITIVE_INFINITY)\n };\n }\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args[i] = arguments[i];\n }\n var hash = hasher(args);\n if (memoize.cache.values.has(hash)) {\n memoize.cache.lru.hit(hash);\n return memoize.cache.values.get(hash);\n }\n var newVal = fn.apply(fn, args);\n memoize.cache.values.set(hash, newVal);\n memoize.cache.values.delete(memoize.cache.lru.hit(hash));\n return newVal;\n };\n}\n\n/**\n * Memoize a given function by caching all results and the arguments,\n * and comparing against the arguments of previous results before\n * executing again.\n * This is less performant than `memoize` which calculates a hash,\n * which is very fast to compare. Use `memoizeCompare` only when it is\n * not possible to create a unique serializable hash from the function\n * arguments.\n * The isEqual function must compare two sets of arguments\n * and return true when equal (can be a deep equality check for example).\n * @param {function} fn\n * @param {function(a: *, b: *) : boolean} isEqual\n * @returns {function}\n */\nexport function memoizeCompare(fn, isEqual) {\n var memoize = function memoize() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args[i] = arguments[i];\n }\n for (var c = 0; c < memoize.cache.length; c++) {\n var cached = memoize.cache[c];\n if (isEqual(args, cached.args)) {\n // TODO: move this cache entry to the top so recently used entries move up?\n return cached.res;\n }\n }\n var res = fn.apply(fn, args);\n memoize.cache.unshift({\n args,\n res\n });\n return res;\n };\n memoize.cache = [];\n return memoize;\n}","import { memoize } from '../function.js';\n\n/**\n * Calculate BigNumber e\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns e\n */\nexport var createBigNumberE = memoize(function (BigNumber) {\n return new BigNumber(1).exp();\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber golden ratio, phi = (1+sqrt(5))/2\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns phi\n */\nexport var createBigNumberPhi = memoize(function (BigNumber) {\n return new BigNumber(1).plus(new BigNumber(5).sqrt()).div(2);\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber pi.\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns pi\n */\nexport var createBigNumberPi = memoize(function (BigNumber) {\n return BigNumber.acos(-1);\n}, {\n hasher\n});\n\n/**\n * Calculate BigNumber tau, tau = 2 * pi\n * @param {function} BigNumber BigNumber constructor\n * @returns {BigNumber} Returns tau\n */\nexport var createBigNumberTau = memoize(function (BigNumber) {\n return createBigNumberPi(BigNumber).times(2);\n}, {\n hasher\n});\n\n/**\n * Create a hash for a BigNumber constructor function. The created has is\n * the configured precision\n * @param {Array} args Supposed to contain a single entry with\n * a BigNumber constructor\n * @return {number} precision\n * @private\n */\nfunction hasher(args) {\n return args[0].precision;\n}","import { factory } from './utils/factory.js';\nimport { version } from './version.js';\nimport { createBigNumberE, createBigNumberPhi, createBigNumberPi, createBigNumberTau } from './utils/bignumber/constants.js';\nimport { pi, tau, e, phi } from './plain/number/index.js';\nexport var createTrue = /* #__PURE__ */factory('true', [], () => true);\nexport var createFalse = /* #__PURE__ */factory('false', [], () => false);\nexport var createNull = /* #__PURE__ */factory('null', [], () => null);\nexport var createInfinity = /* #__PURE__ */recreateFactory('Infinity', ['config', '?BigNumber'], _ref => {\n var {\n config,\n BigNumber\n } = _ref;\n return config.number === 'BigNumber' ? new BigNumber(Infinity) : Infinity;\n});\nexport var createNaN = /* #__PURE__ */recreateFactory('NaN', ['config', '?BigNumber'], _ref2 => {\n var {\n config,\n BigNumber\n } = _ref2;\n return config.number === 'BigNumber' ? new BigNumber(NaN) : NaN;\n});\nexport var createPi = /* #__PURE__ */recreateFactory('pi', ['config', '?BigNumber'], _ref3 => {\n var {\n config,\n BigNumber\n } = _ref3;\n return config.number === 'BigNumber' ? createBigNumberPi(BigNumber) : pi;\n});\nexport var createTau = /* #__PURE__ */recreateFactory('tau', ['config', '?BigNumber'], _ref4 => {\n var {\n config,\n BigNumber\n } = _ref4;\n return config.number === 'BigNumber' ? createBigNumberTau(BigNumber) : tau;\n});\nexport var createE = /* #__PURE__ */recreateFactory('e', ['config', '?BigNumber'], _ref5 => {\n var {\n config,\n BigNumber\n } = _ref5;\n return config.number === 'BigNumber' ? createBigNumberE(BigNumber) : e;\n});\n\n// golden ratio, (1+sqrt(5))/2\nexport var createPhi = /* #__PURE__ */recreateFactory('phi', ['config', '?BigNumber'], _ref6 => {\n var {\n config,\n BigNumber\n } = _ref6;\n return config.number === 'BigNumber' ? createBigNumberPhi(BigNumber) : phi;\n});\nexport var createLN2 = /* #__PURE__ */recreateFactory('LN2', ['config', '?BigNumber'], _ref7 => {\n var {\n config,\n BigNumber\n } = _ref7;\n return config.number === 'BigNumber' ? new BigNumber(2).ln() : Math.LN2;\n});\nexport var createLN10 = /* #__PURE__ */recreateFactory('LN10', ['config', '?BigNumber'], _ref8 => {\n var {\n config,\n BigNumber\n } = _ref8;\n return config.number === 'BigNumber' ? new BigNumber(10).ln() : Math.LN10;\n});\nexport var createLOG2E = /* #__PURE__ */recreateFactory('LOG2E', ['config', '?BigNumber'], _ref9 => {\n var {\n config,\n BigNumber\n } = _ref9;\n return config.number === 'BigNumber' ? new BigNumber(1).div(new BigNumber(2).ln()) : Math.LOG2E;\n});\nexport var createLOG10E = /* #__PURE__ */recreateFactory('LOG10E', ['config', '?BigNumber'], _ref0 => {\n var {\n config,\n BigNumber\n } = _ref0;\n return config.number === 'BigNumber' ? new BigNumber(1).div(new BigNumber(10).ln()) : Math.LOG10E;\n});\nexport var createSQRT1_2 = /* #__PURE__ */recreateFactory(\n// eslint-disable-line camelcase\n'SQRT1_2', ['config', '?BigNumber'], _ref1 => {\n var {\n config,\n BigNumber\n } = _ref1;\n return config.number === 'BigNumber' ? new BigNumber('0.5').sqrt() : Math.SQRT1_2;\n});\nexport var createSQRT2 = /* #__PURE__ */recreateFactory('SQRT2', ['config', '?BigNumber'], _ref10 => {\n var {\n config,\n BigNumber\n } = _ref10;\n return config.number === 'BigNumber' ? new BigNumber(2).sqrt() : Math.SQRT2;\n});\nexport var createI = /* #__PURE__ */recreateFactory('i', ['Complex'], _ref11 => {\n var {\n Complex\n } = _ref11;\n return Complex.I;\n});\n\n// for backward compatibility with v5\nexport var createUppercasePi = /* #__PURE__ */factory('PI', ['pi'], _ref12 => {\n var {\n pi\n } = _ref12;\n return pi;\n});\nexport var createUppercaseE = /* #__PURE__ */factory('E', ['e'], _ref13 => {\n var {\n e\n } = _ref13;\n return e;\n});\nexport var createVersion = /* #__PURE__ */factory('version', [], () => version);\n\n// helper function to create a factory with a flag recreateOnConfigChange\n// idea: allow passing optional properties to be attached to the factory function as 4th argument?\nfunction recreateFactory(name, dependencies, create) {\n return factory(name, dependencies, create, {\n recreateOnConfigChange: true\n });\n}","import { factory } from '../utils/factory.js';\nimport { deepMap } from '../utils/collection.js';\nvar name = 'number';\nvar dependencies = ['typed'];\n\n/**\n * Separates the radix, integer part, and fractional part of a non decimal number string\n * @param {string} input string to parse\n * @returns {object} the parts of the string or null if not a valid input\n */\nfunction getNonDecimalNumberParts(input) {\n var nonDecimalWithRadixMatch = input.match(/(0[box])([0-9a-fA-F]*)\\.([0-9a-fA-F]*)/);\n if (nonDecimalWithRadixMatch) {\n var radix = {\n '0b': 2,\n '0o': 8,\n '0x': 16\n }[nonDecimalWithRadixMatch[1]];\n var integerPart = nonDecimalWithRadixMatch[2];\n var fractionalPart = nonDecimalWithRadixMatch[3];\n return {\n input,\n radix,\n integerPart,\n fractionalPart\n };\n } else {\n return null;\n }\n}\n\n/**\n * Makes a number from a radix, and integer part, and a fractional part\n * @param {parts} [x] parts of the number string (from getNonDecimalNumberParts)\n * @returns {number} the number\n */\nfunction makeNumberFromNonDecimalParts(parts) {\n var n = parseInt(parts.integerPart, parts.radix);\n var f = 0;\n for (var i = 0; i < parts.fractionalPart.length; i++) {\n var digitValue = parseInt(parts.fractionalPart[i], parts.radix);\n f += digitValue / Math.pow(parts.radix, i + 1);\n }\n var result = n + f;\n if (isNaN(result)) {\n throw new SyntaxError('String \"' + parts.input + '\" is not a valid number');\n }\n return result;\n}\nexport var createNumber = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Create a number or convert a string, boolean, or unit to a number.\n * When value is a matrix, all elements will be converted to number.\n *\n * Syntax:\n *\n * math.number(value)\n * math.number(unit, valuelessUnit)\n *\n * Examples:\n *\n * math.number(2) // returns number 2\n * math.number('7.2') // returns number 7.2\n * math.number(true) // returns number 1\n * math.number([true, false, true, true]) // returns [1, 0, 1, 1]\n * math.number(math.unit('52cm'), 'm') // returns 0.52\n *\n * See also:\n *\n * bignumber, bigint, boolean, numeric, complex, index, matrix, string, unit\n *\n * @param {string | number | BigNumber | Fraction | boolean | Array | Matrix | Unit | null} [value] Value to be converted\n * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number\n * @return {number | Array | Matrix} The created number\n */\n var number = typed('number', {\n '': function _() {\n return 0;\n },\n number: function number(x) {\n return x;\n },\n string: function string(x) {\n if (x === 'NaN') return NaN;\n var nonDecimalNumberParts = getNonDecimalNumberParts(x);\n if (nonDecimalNumberParts) {\n return makeNumberFromNonDecimalParts(nonDecimalNumberParts);\n }\n var size = 0;\n var wordSizeSuffixMatch = x.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);\n if (wordSizeSuffixMatch) {\n // x includes a size suffix like 0xffffi32, so we extract\n // the suffix and remove it from x\n size = Number(wordSizeSuffixMatch[2]);\n x = wordSizeSuffixMatch[1];\n }\n var num = Number(x);\n if (isNaN(num)) {\n throw new SyntaxError('String \"' + x + '\" is not a valid number');\n }\n if (wordSizeSuffixMatch) {\n // x is a signed bin, oct, or hex literal\n // num is the value of string x if x is interpreted as unsigned\n if (num > 2 ** size - 1) {\n // literal is too large for size suffix\n throw new SyntaxError(\"String \\\"\".concat(x, \"\\\" is out of range\"));\n }\n // check if the bit at index size - 1 is set and if so do the twos complement\n if (num >= 2 ** (size - 1)) {\n num = num - 2 ** size;\n }\n }\n return num;\n },\n BigNumber: function BigNumber(x) {\n return x.toNumber();\n },\n bigint: function bigint(x) {\n return Number(x);\n },\n Fraction: function Fraction(x) {\n return x.valueOf();\n },\n Unit: typed.referToSelf(self => x => {\n var clone = x.clone();\n clone.value = self(x.value);\n return clone;\n }),\n null: function _null(x) {\n return 0;\n },\n 'Unit, string | Unit': function Unit_string__Unit(unit, valuelessUnit) {\n return unit.toNumber(valuelessUnit);\n },\n 'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))\n });\n\n // reviver function to parse a JSON object like:\n //\n // {\"mathjs\":\"number\",\"value\":\"2.3\"}\n //\n // into a number 2.3\n number.fromJSON = function (json) {\n return parseFloat(json.value);\n };\n return number;\n});","// Reserved keywords not allowed to use in the parser\nexport var keywords = new Set(['end']);","import { isNode } from '../../utils/is.js';\nimport { keywords } from '../keywords.js';\nimport { deepStrictEqual } from '../../utils/object.js';\nimport { factory } from '../../utils/factory.js';\nimport { createMap } from '../../utils/map.js';\nvar name = 'Node';\nvar dependencies = ['mathWithTransform'];\nexport var createNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n mathWithTransform\n } = _ref;\n /**\n * Validate the symbol names of a scope.\n * Throws an error when the scope contains an illegal symbol.\n * @param {Object} scope\n */\n function _validateScope(scope) {\n for (var symbol of [...keywords]) {\n if (scope.has(symbol)) {\n throw new Error('Scope contains an illegal symbol, \"' + symbol + '\" is a reserved keyword');\n }\n }\n }\n class Node {\n get type() {\n return 'Node';\n }\n get isNode() {\n return true;\n }\n\n /**\n * Evaluate the node\n * @param {Object} [scope] Scope to read/write variables\n * @return {*} Returns the result\n */\n evaluate(scope) {\n return this.compile().evaluate(scope);\n }\n\n /**\n * Compile the node into an optimized, evauatable JavaScript function\n * @return {{evaluate: function([Object])}} object\n * Returns an object with a function 'evaluate',\n * which can be invoked as expr.evaluate([scope: Object]),\n * where scope is an optional object with\n * variables.\n */\n compile() {\n var expr = this._compile(mathWithTransform, {});\n var args = {};\n var context = null;\n function evaluate(scope) {\n var s = createMap(scope);\n _validateScope(s);\n return expr(s, args, context);\n }\n return {\n evaluate\n };\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n throw new Error('Method _compile must be implemented by type ' + this.type);\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot run forEach on a Node interface');\n }\n\n /**\n * Create a new Node whose children are the results of calling the\n * provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {OperatorNode} Returns a transformed copy of the node\n */\n map(callback) {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot run map on a Node interface');\n }\n\n /**\n * Validate whether an object is a Node, for use with map\n * @param {Node} node\n * @returns {Node} Returns the input if it's a node, else throws an Error\n * @protected\n */\n _ifNode(node) {\n if (!isNode(node)) {\n throw new TypeError('Callback function must return a Node');\n }\n return node;\n }\n\n /**\n * Recursively traverse all nodes in a node tree. Executes given callback for\n * this node and each of its child nodes.\n * @param {function(node: Node, path: string, parent: Node)} callback\n * A callback called for every node in the node tree.\n */\n traverse(callback) {\n // execute callback for itself\n // eslint-disable-next-line\n callback(this, null, null);\n\n // recursively traverse over all children of a node\n function _traverse(node, callback) {\n node.forEach(function (child, path, parent) {\n callback(child, path, parent);\n _traverse(child, callback);\n });\n }\n _traverse(this, callback);\n }\n\n /**\n * Recursively transform a node tree via a transform function.\n *\n * For example, to replace all nodes of type SymbolNode having name 'x' with\n * a ConstantNode with value 2:\n *\n * const res = Node.transform(function (node, path, parent) {\n * if (node && node.isSymbolNode) && (node.name === 'x')) {\n * return new ConstantNode(2)\n * }\n * else {\n * return node\n * }\n * })\n *\n * @param {function(node: Node, path: string, parent: Node) : Node} callback\n * A mapping function accepting a node, and returning\n * a replacement for the node or the original node. The \"signature\"\n * of the callback must be:\n * callback(node: Node, index: string, parent: Node) : Node\n * @return {Node} Returns the original node or its replacement\n */\n transform(callback) {\n function _transform(child, path, parent) {\n var replacement = callback(child, path, parent);\n if (replacement !== child) {\n // stop iterating when the node is replaced\n return replacement;\n }\n return child.map(_transform);\n }\n return _transform(this, null, null);\n }\n\n /**\n * Find any node in the node tree matching given filter function. For\n * example, to find all nodes of type SymbolNode having name 'x':\n *\n * const results = Node.filter(function (node) {\n * return (node && node.isSymbolNode) && (node.name === 'x')\n * })\n *\n * @param {function(node: Node, path: string, parent: Node) : Node} callback\n * A test function returning true when a node matches, and false\n * otherwise. Function signature:\n * callback(node: Node, index: string, parent: Node) : boolean\n * @return {Node[]} nodes\n * An array with nodes matching given filter criteria\n */\n filter(callback) {\n var nodes = [];\n this.traverse(function (node, path, parent) {\n if (callback(node, path, parent)) {\n nodes.push(node);\n }\n });\n return nodes;\n }\n\n /**\n * Create a shallow clone of this node\n * @return {Node}\n */\n clone() {\n // must be implemented by each of the Node implementations\n throw new Error('Cannot clone a Node interface');\n }\n\n /**\n * Create a deep clone of this node\n * @return {Node}\n */\n cloneDeep() {\n return this.map(function (node) {\n return node.cloneDeep();\n });\n }\n\n /**\n * Deep compare this node with another node.\n * @param {Node} other\n * @return {boolean} Returns true when both nodes are of the same type and\n * contain the same values (as do their childs)\n */\n equals(other) {\n return other ? this.type === other.type && deepStrictEqual(this, other) : false;\n }\n\n /**\n * Get string representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\"or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toString(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toString(options);\n }\n\n /**\n * Internal function to generate the string output.\n * This has to be implemented by every Node\n *\n * @throws {Error}\n */\n _toString() {\n // must be implemented by each of the Node implementations\n throw new Error('_toString not implemented for ' + this.type);\n }\n\n /**\n * Get a JSON representation of the node\n * Both .toJSON() and the static .fromJSON(json) should be implemented by all\n * implementations of Node\n * @returns {Object}\n */\n toJSON() {\n throw new Error('Cannot serialize object: toJSON not implemented by ' + this.type);\n }\n\n /**\n * Get HTML representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\" or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toHTML(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toHTML(options);\n }\n\n /**\n * Internal function to generate the HTML output.\n * This has to be implemented by every Node\n *\n * @throws {Error}\n */\n _toHTML() {\n // must be implemented by each of the Node implementations\n throw new Error('_toHTML not implemented for ' + this.type);\n }\n\n /**\n * Get LaTeX representation. (wrapper function)\n *\n * This function can get an object of the following form:\n * {\n * handler: //This can be a callback function of the form\n * // \"function callback(node, options)\"or\n * // a map that maps function names (used in FunctionNodes)\n * // to callbacks\n * parenthesis: \"keep\" //the parenthesis option (This is optional)\n * }\n *\n * @param {Object} [options]\n * @return {string}\n */\n toTex(options) {\n var customString = this._getCustomString(options);\n if (typeof customString !== 'undefined') {\n return customString;\n }\n return this._toTex(options);\n }\n\n /**\n * Internal function to generate the LaTeX output.\n * This has to be implemented by every Node\n *\n * @param {Object} [options]\n * @throws {Error}\n */\n _toTex(options) {\n // must be implemented by each of the Node implementations\n throw new Error('_toTex not implemented for ' + this.type);\n }\n\n /**\n * Helper used by `to...` functions.\n */\n _getCustomString(options) {\n if (options && typeof options === 'object') {\n switch (typeof options.handler) {\n case 'object':\n case 'undefined':\n return;\n case 'function':\n return options.handler(this, options);\n default:\n throw new TypeError('Object or function expected as callback');\n }\n }\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type;\n }\n\n /**\n * Get the content of the current Node.\n * @return {Node} node\n **/\n getContent() {\n return this;\n }\n }\n return Node;\n}, {\n isClass: true,\n isNode: true\n});","import { IndexError } from '../../../error/IndexError.js';\n\n/**\n * Transform zero-based indices to one-based indices in errors\n * @param {Error} err\n * @returns {Error | IndexError} Returns the transformed error\n */\nexport function errorTransform(err) {\n if (err && err.isIndexError) {\n return new IndexError(err.index + 1, err.min + 1, err.max !== undefined ? err.max + 1 : undefined);\n }\n return err;\n}","import { errorTransform } from '../../transform/utils/errorTransform.js';\nimport { getSafeProperty } from '../../../utils/customs.js';\nexport function accessFactory(_ref) {\n var {\n subset\n } = _ref;\n /**\n * Retrieve part of an object:\n *\n * - Retrieve a property from an object\n * - Retrieve a part of a string\n * - Retrieve a matrix subset\n *\n * @param {Object | Array | Matrix | string} object\n * @param {Index} index\n * @return {Object | Array | Matrix | string} Returns the subset\n */\n return function access(object, index) {\n try {\n if (Array.isArray(object)) {\n return subset(object, index);\n } else if (object && typeof object.subset === 'function') {\n // Matrix\n return object.subset(index);\n } else if (typeof object === 'string') {\n // TODO: move getStringSubset into a separate util file, use that\n return subset(object, index);\n } else if (typeof object === 'object') {\n if (!index.isObjectProperty()) {\n throw new TypeError('Cannot apply a numeric index as object property');\n }\n return getSafeProperty(object, index.getObjectProperty());\n } else {\n throw new TypeError('Cannot apply index: unsupported type of object');\n }\n } catch (err) {\n throw errorTransform(err);\n }\n };\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isArrayNode, isConstantNode, isFunctionNode, isIndexNode, isNode, isObjectNode, isParenthesisNode, isSymbolNode } from '../../utils/is.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { accessFactory } from './utils/access.js';\nvar name = 'AccessorNode';\nvar dependencies = ['subset', 'Node'];\nexport var createAccessorNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n subset,\n Node\n } = _ref;\n var access = accessFactory({\n subset\n });\n\n /**\n * Are parenthesis needed?\n * @private\n */\n function needParenthesis(node) {\n // TODO: maybe make a method on the nodes which tells whether they need parenthesis?\n return !(isAccessorNode(node) || isArrayNode(node) || isConstantNode(node) || isFunctionNode(node) || isObjectNode(node) || isParenthesisNode(node) || isSymbolNode(node));\n }\n class AccessorNode extends Node {\n /**\n * @constructor AccessorNode\n * @extends {Node}\n * Access an object property or get a matrix subset\n *\n * @param {Node} object The object from which to retrieve\n * a property or subset.\n * @param {IndexNode} index IndexNode containing ranges\n * @param {boolean} [optionalChaining=false]\n * Optional property, if the accessor was written as optional-chaining\n * using `a?.b`, or `a?.[\"b\"] with bracket notation.\n * Forces evaluate to undefined if the given object is undefined or null.\n */\n constructor(object, index) {\n var optionalChaining = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n super();\n if (!isNode(object)) {\n throw new TypeError('Node expected for parameter \"object\"');\n }\n if (!isIndexNode(index)) {\n throw new TypeError('IndexNode expected for parameter \"index\"');\n }\n this.object = object;\n this.index = index;\n this.optionalChaining = optionalChaining;\n }\n\n // readonly property name\n get name() {\n if (this.index) {\n return this.index.isObjectProperty() ? this.index.getObjectProperty() : '';\n } else {\n return this.object.name || '';\n }\n }\n get type() {\n return name;\n }\n get isAccessorNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalObject = this.object._compile(math, argNames);\n var evalIndex = this.index._compile(math, argNames);\n var optionalChaining = this.optionalChaining;\n var prevOptionalChaining = isAccessorNode(this.object) && this.object.optionalChaining;\n if (this.index.isObjectProperty()) {\n var prop = this.index.getObjectProperty();\n return function evalAccessorNode(scope, args, context) {\n var ctx = context || {};\n var object = evalObject(scope, args, ctx);\n if (optionalChaining && object == null) {\n ctx.optionalShortCircuit = true;\n return undefined;\n }\n if (prevOptionalChaining && ctx !== null && ctx !== void 0 && ctx.optionalShortCircuit) {\n return undefined;\n }\n\n // get a property from an object evaluated using the scope.\n return getSafeProperty(object, prop);\n };\n } else {\n return function evalAccessorNode(scope, args, context) {\n var ctx = context || {};\n var object = evalObject(scope, args, ctx);\n if (optionalChaining && object == null) {\n ctx.optionalShortCircuit = true;\n return undefined;\n }\n if (prevOptionalChaining && ctx !== null && ctx !== void 0 && ctx.optionalShortCircuit) {\n return undefined;\n }\n\n // we pass just object here instead of context:\n var index = evalIndex(scope, args, object);\n return access(object, index);\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.object, 'object', this);\n callback(this.index, 'index', this);\n }\n\n /**\n * Create a new AccessorNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {AccessorNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new AccessorNode(this._ifNode(callback(this.object, 'object', this)), this._ifNode(callback(this.index, 'index', this)), this.optionalChaining);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {AccessorNode}\n */\n clone() {\n return new AccessorNode(this.object, this.index, this.optionalChaining);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string}\n */\n _toString(options) {\n var object = this.object.toString(options);\n if (needParenthesis(this.object)) {\n object = '(' + object + ')';\n }\n var optionalChaining = this.optionalChaining ? this.index.dotNotation ? '?' : '?.' : '';\n return object + optionalChaining + this.index.toString(options);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string}\n */\n _toHTML(options) {\n var object = this.object.toHTML(options);\n if (needParenthesis(this.object)) {\n object = '(' + object + ')';\n }\n return object + this.index.toHTML(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string}\n */\n _toTex(options) {\n var object = this.object.toTex(options);\n if (needParenthesis(this.object)) {\n object = '\\\\left(\\' + object + \\'\\\\right)';\n }\n return object + this.index.toTex(options);\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n object: this.object,\n index: this.index,\n optionalChaining: this.optionalChaining\n };\n }\n\n /**\n * Instantiate an AccessorNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"AccessorNode\", object: ..., index: ...}`,\n * where mathjs is optional\n * @returns {AccessorNode}\n */\n static fromJSON(json) {\n return new AccessorNode(json.object, json.index, json.optionalChaining);\n }\n }\n _defineProperty(AccessorNode, \"name\", name);\n return AccessorNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isArrayNode, isNode } from '../../utils/is.js';\nimport { map } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ArrayNode';\nvar dependencies = ['Node'];\nexport var createArrayNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ArrayNode extends Node {\n /**\n * @constructor ArrayNode\n * @extends {Node}\n * Holds an 1-dimensional array with items\n * @param {Node[]} [items] 1 dimensional array with items\n */\n constructor(items) {\n super();\n this.items = items || [];\n\n // validate input\n if (!Array.isArray(this.items) || !this.items.every(isNode)) {\n throw new TypeError('Array containing Nodes expected');\n }\n }\n get type() {\n return name;\n }\n get isArrayNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalItems = map(this.items, function (item) {\n return item._compile(math, argNames);\n });\n var asMatrix = math.config.matrix !== 'Array';\n if (asMatrix) {\n var matrix = math.matrix;\n return function evalArrayNode(scope, args, context) {\n return matrix(map(evalItems, function (evalItem) {\n return evalItem(scope, args, context);\n }));\n };\n } else {\n return function evalArrayNode(scope, args, context) {\n return map(evalItems, function (evalItem) {\n return evalItem(scope, args, context);\n });\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.items.length; i++) {\n var node = this.items[i];\n callback(node, 'items[' + i + ']', this);\n }\n }\n\n /**\n * Create a new ArrayNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ArrayNode} Returns a transformed copy of the node\n */\n map(callback) {\n var items = [];\n for (var i = 0; i < this.items.length; i++) {\n items[i] = this._ifNode(callback(this.items[i], 'items[' + i + ']', this));\n }\n return new ArrayNode(items);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ArrayNode}\n */\n clone() {\n return new ArrayNode(this.items.slice(0));\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n var items = this.items.map(function (node) {\n return node.toString(options);\n });\n return '[' + items.join(', ') + ']';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n items: this.items\n };\n }\n\n /**\n * Instantiate an ArrayNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ArrayNode\", items: [...]}`,\n * where mathjs is optional\n * @returns {ArrayNode}\n */\n static fromJSON(json) {\n return new ArrayNode(json.items);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var items = this.items.map(function (node) {\n return node.toHTML(options);\n });\n return '[' + items.join(',') + ']';\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n function itemsToTex(items, nested) {\n var mixedItems = items.some(isArrayNode) && !items.every(isArrayNode);\n var itemsFormRow = nested || mixedItems;\n var itemSep = itemsFormRow ? '&' : '\\\\\\\\';\n var itemsTex = items.map(function (node) {\n if (node.items) {\n return itemsToTex(node.items, !nested);\n } else {\n return node.toTex(options);\n }\n }).join(itemSep);\n return mixedItems || !itemsFormRow || itemsFormRow && !nested ? '\\\\begin{bmatrix}' + itemsTex + '\\\\end{bmatrix}' : itemsTex;\n }\n return itemsToTex(this.items, false);\n }\n }\n _defineProperty(ArrayNode, \"name\", name);\n return ArrayNode;\n}, {\n isClass: true,\n isNode: true\n});","import { errorTransform } from '../../transform/utils/errorTransform.js';\nimport { setSafeProperty } from '../../../utils/customs.js';\nexport function assignFactory(_ref) {\n var {\n subset,\n matrix\n } = _ref;\n /**\n * Replace part of an object:\n *\n * - Assign a property to an object\n * - Replace a part of a string\n * - Replace a matrix subset\n *\n * @param {Object | Array | Matrix | string} object\n * @param {Index} index\n * @param {*} value\n * @return {Object | Array | Matrix | string} Returns the original object\n * except in case of a string\n */\n // TODO: change assign to return the value instead of the object\n return function assign(object, index, value) {\n try {\n if (Array.isArray(object)) {\n var result = matrix(object).subset(index, value).valueOf();\n\n // shallow copy all (updated) items into the original array\n result.forEach((item, index) => {\n object[index] = item;\n });\n return object;\n } else if (object && typeof object.subset === 'function') {\n // Matrix\n return object.subset(index, value);\n } else if (typeof object === 'string') {\n // TODO: move setStringSubset into a separate util file, use that\n return subset(object, index, value);\n } else if (typeof object === 'object') {\n if (!index.isObjectProperty()) {\n throw TypeError('Cannot apply a numeric index as object property');\n }\n setSafeProperty(object, index.getObjectProperty(), value);\n return object;\n } else {\n throw new TypeError('Cannot apply index: unsupported type of object');\n }\n } catch (err) {\n throw errorTransform(err);\n }\n };\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';\nimport { getSafeProperty, setSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { accessFactory } from './utils/access.js';\nimport { assignFactory } from './utils/assign.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'AssignmentNode';\nvar dependencies = ['subset', '?matrix',\n// FIXME: should not be needed at all, should be handled by subset\n'Node'];\nexport var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n subset,\n matrix,\n Node\n } = _ref;\n var access = accessFactory({\n subset\n });\n var assign = assignFactory({\n subset,\n matrix\n });\n\n /*\n * Is parenthesis needed?\n * @param {node} node\n * @param {string} [parenthesis='keep']\n * @param {string} implicit\n * @private\n */\n function needParenthesis(node, parenthesis, implicit) {\n if (!parenthesis) {\n parenthesis = 'keep';\n }\n var precedence = getPrecedence(node, parenthesis, implicit);\n var exprPrecedence = getPrecedence(node.value, parenthesis, implicit);\n return parenthesis === 'all' || exprPrecedence !== null && exprPrecedence <= precedence;\n }\n class AssignmentNode extends Node {\n /**\n * @constructor AssignmentNode\n * @extends {Node}\n *\n * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or\n * replace a subset of a matrix like `A[2,2]=42`.\n *\n * Syntax:\n *\n * new AssignmentNode(symbol, value)\n * new AssignmentNode(object, index, value)\n *\n * Usage:\n *\n * new AssignmentNode(new SymbolNode('a'), new ConstantNode(2)) // a=2\n * new AssignmentNode(new SymbolNode('a'),\n * new IndexNode('b'),\n * new ConstantNode(2)) // a.b=2\n * new AssignmentNode(new SymbolNode('a'),\n * new IndexNode(1, 2),\n * new ConstantNode(3)) // a[1,2]=3\n *\n * @param {SymbolNode | AccessorNode} object\n * Object on which to assign a value\n * @param {IndexNode} [index=null]\n * Index, property name or matrix index. Optional. If not provided\n * and `object` is a SymbolNode, the property is assigned to the\n * global scope.\n * @param {Node} value\n * The value to be assigned\n */\n constructor(object, index, value) {\n super();\n this.object = object;\n this.index = value ? index : null;\n this.value = value || index;\n\n // validate input\n if (!isSymbolNode(object) && !isAccessorNode(object)) {\n throw new TypeError('SymbolNode or AccessorNode expected as \"object\"');\n }\n if (isSymbolNode(object) && object.name === 'end') {\n throw new Error('Cannot assign to symbol \"end\"');\n }\n if (this.index && !isIndexNode(this.index)) {\n // index is optional\n throw new TypeError('IndexNode expected as \"index\"');\n }\n if (!isNode(this.value)) {\n throw new TypeError('Node expected as \"value\"');\n }\n }\n\n // class name for typing purposes:\n\n // readonly property name\n get name() {\n if (this.index) {\n return this.index.isObjectProperty() ? this.index.getObjectProperty() : '';\n } else {\n return this.object.name || '';\n }\n }\n get type() {\n return name;\n }\n get isAssignmentNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalObject = this.object._compile(math, argNames);\n var evalIndex = this.index ? this.index._compile(math, argNames) : null;\n var evalValue = this.value._compile(math, argNames);\n var name = this.object.name;\n if (!this.index) {\n // apply a variable to the scope, for example `a=2`\n if (!isSymbolNode(this.object)) {\n throw new TypeError('SymbolNode expected as object');\n }\n return function evalAssignmentNode(scope, args, context) {\n var value = evalValue(scope, args, context);\n scope.set(name, value);\n return value;\n };\n } else if (this.index.isObjectProperty()) {\n // apply an object property for example `a.b=2`\n var prop = this.index.getObjectProperty();\n return function evalAssignmentNode(scope, args, context) {\n var object = evalObject(scope, args, context);\n var value = evalValue(scope, args, context);\n setSafeProperty(object, prop, value);\n return value;\n };\n } else if (isSymbolNode(this.object)) {\n // update a matrix subset, for example `a[2]=3`\n return function evalAssignmentNode(scope, args, context) {\n var childObject = evalObject(scope, args, context);\n var value = evalValue(scope, args, context);\n // Important: we pass childObject instead of context:\n var index = evalIndex(scope, args, childObject);\n scope.set(name, assign(childObject, index, value));\n return value;\n };\n } else {\n // isAccessorNode(node.object) === true\n // update a matrix subset, for example `a.b[2]=3`\n\n // we will not use the compile function of the AccessorNode, but\n // compile it ourselves here as we need the parent object of the\n // AccessorNode:\n // wee need to apply the updated object to parent object\n var evalParentObject = this.object.object._compile(math, argNames);\n if (this.object.index.isObjectProperty()) {\n var parentProp = this.object.index.getObjectProperty();\n return function evalAssignmentNode(scope, args, context) {\n var parent = evalParentObject(scope, args, context);\n var childObject = getSafeProperty(parent, parentProp);\n // Important: we pass childObject instead of context:\n var index = evalIndex(scope, args, childObject);\n var value = evalValue(scope, args, context);\n setSafeProperty(parent, parentProp, assign(childObject, index, value));\n return value;\n };\n } else {\n // if some parameters use the 'end' parameter, we need to calculate\n // the size\n var evalParentIndex = this.object.index._compile(math, argNames);\n return function evalAssignmentNode(scope, args, context) {\n var parent = evalParentObject(scope, args, context);\n // Important: we pass parent instead of context:\n var parentIndex = evalParentIndex(scope, args, parent);\n var childObject = access(parent, parentIndex);\n // Important: we pass childObject instead of context\n var index = evalIndex(scope, args, childObject);\n var value = evalValue(scope, args, context);\n assign(parent, parentIndex, assign(childObject, index, value));\n return value;\n };\n }\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.object, 'object', this);\n if (this.index) {\n callback(this.index, 'index', this);\n }\n callback(this.value, 'value', this);\n }\n\n /**\n * Create a new AssignmentNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {AssignmentNode} Returns a transformed copy of the node\n */\n map(callback) {\n var object = this._ifNode(callback(this.object, 'object', this));\n var index = this.index ? this._ifNode(callback(this.index, 'index', this)) : null;\n var value = this._ifNode(callback(this.value, 'value', this));\n return new AssignmentNode(object, index, value);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {AssignmentNode}\n */\n clone() {\n return new AssignmentNode(this.object, this.index, this.value);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string}\n */\n _toString(options) {\n var object = this.object.toString(options);\n var index = this.index ? this.index.toString(options) : '';\n var value = this.value.toString(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = '(' + value + ')';\n }\n return object + index + ' = ' + value;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n object: this.object,\n index: this.index,\n value: this.value\n };\n }\n\n /**\n * Instantiate an AssignmentNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"AssignmentNode\", object: ..., index: ..., value: ...}`,\n * where mathjs is optional\n * @returns {AssignmentNode}\n */\n static fromJSON(json) {\n return new AssignmentNode(json.object, json.index, json.value);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string}\n */\n _toHTML(options) {\n var object = this.object.toHTML(options);\n var index = this.index ? this.index.toHTML(options) : '';\n var value = this.value.toHTML(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = '(' + value + ')';\n }\n return object + index + '=' + value;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string}\n */\n _toTex(options) {\n var object = this.object.toTex(options);\n var index = this.index ? this.index.toTex(options) : '';\n var value = this.value.toTex(options);\n if (needParenthesis(this, options && options.parenthesis, options && options.implicit)) {\n value = \"\\\\left(\".concat(value, \"\\\\right)\");\n }\n return object + index + '=' + value;\n }\n }\n _defineProperty(AssignmentNode, \"name\", name);\n return AssignmentNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { forEach, map } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'BlockNode';\nvar dependencies = ['ResultSet', 'Node'];\nexport var createBlockNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n ResultSet,\n Node\n } = _ref;\n class BlockNode extends Node {\n /**\n * @constructor BlockNode\n * @extends {Node}\n * Holds a set with blocks\n * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks\n * An array with blocks, where a block is constructed as an\n * Object with properties block, which is a Node, and visible,\n * which is a boolean. The property visible is optional and\n * is true by default\n */\n constructor(blocks) {\n super();\n // validate input, copy blocks\n if (!Array.isArray(blocks)) throw new Error('Array expected');\n this.blocks = blocks.map(function (block) {\n var node = block && block.node;\n var visible = block && block.visible !== undefined ? block.visible : true;\n if (!isNode(node)) throw new TypeError('Property \"node\" must be a Node');\n if (typeof visible !== 'boolean') {\n throw new TypeError('Property \"visible\" must be a boolean');\n }\n return {\n node,\n visible\n };\n });\n }\n get type() {\n return name;\n }\n get isBlockNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalBlocks = map(this.blocks, function (block) {\n return {\n evaluate: block.node._compile(math, argNames),\n visible: block.visible\n };\n });\n return function evalBlockNodes(scope, args, context) {\n var results = [];\n forEach(evalBlocks, function evalBlockNode(block) {\n var result = block.evaluate(scope, args, context);\n if (block.visible) {\n results.push(result);\n }\n });\n return new ResultSet(results);\n };\n }\n\n /**\n * Execute a callback for each of the child blocks of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.blocks.length; i++) {\n callback(this.blocks[i].node, 'blocks[' + i + '].node', this);\n }\n }\n\n /**\n * Create a new BlockNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {BlockNode} Returns a transformed copy of the node\n */\n map(callback) {\n var blocks = [];\n for (var i = 0; i < this.blocks.length; i++) {\n var block = this.blocks[i];\n var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this));\n blocks[i] = {\n node,\n visible: block.visible\n };\n }\n return new BlockNode(blocks);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {BlockNode}\n */\n clone() {\n var blocks = this.blocks.map(function (block) {\n return {\n node: block.node,\n visible: block.visible\n };\n });\n return new BlockNode(blocks);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n return this.blocks.map(function (param) {\n return param.node.toString(options) + (param.visible ? '' : ';');\n }).join('\\n');\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n blocks: this.blocks\n };\n }\n\n /**\n * Instantiate an BlockNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"BlockNode\", blocks: [{node: ..., visible: false}, ...]}`,\n * where mathjs is optional\n * @returns {BlockNode}\n */\n static fromJSON(json) {\n return new BlockNode(json.blocks);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n return this.blocks.map(function (param) {\n return param.node.toHTML(options) + (param.visible ? '' : ';');\n }).join('
');\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n return this.blocks.map(function (param) {\n return param.node.toTex(options) + (param.visible ? '' : ';');\n }).join('\\\\;\\\\;\\n');\n }\n }\n _defineProperty(BlockNode, \"name\", name);\n return BlockNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isBigNumber, isComplex, isNode, isUnit, typeOf } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'ConditionalNode';\nvar dependencies = ['Node'];\nexport var createConditionalNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Test whether a condition is met\n * @param {*} condition\n * @returns {boolean} true if condition is true or non-zero, else false\n */\n function testCondition(condition) {\n if (typeof condition === 'number' || typeof condition === 'boolean' || typeof condition === 'string') {\n return !!condition;\n }\n if (condition) {\n if (isBigNumber(condition)) {\n return !condition.isZero();\n }\n if (isComplex(condition)) {\n return !!(condition.re || condition.im);\n }\n if (isUnit(condition)) {\n return !!condition.value;\n }\n }\n if (condition === null || condition === undefined) {\n return false;\n }\n throw new TypeError('Unsupported type of condition \"' + typeOf(condition) + '\"');\n }\n class ConditionalNode extends Node {\n /**\n * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr'\n *\n * @param {Node} condition Condition, must result in a boolean\n * @param {Node} trueExpr Expression evaluated when condition is true\n * @param {Node} falseExpr Expression evaluated when condition is true\n *\n * @constructor ConditionalNode\n * @extends {Node}\n */\n constructor(condition, trueExpr, falseExpr) {\n super();\n if (!isNode(condition)) {\n throw new TypeError('Parameter condition must be a Node');\n }\n if (!isNode(trueExpr)) {\n throw new TypeError('Parameter trueExpr must be a Node');\n }\n if (!isNode(falseExpr)) {\n throw new TypeError('Parameter falseExpr must be a Node');\n }\n this.condition = condition;\n this.trueExpr = trueExpr;\n this.falseExpr = falseExpr;\n }\n get type() {\n return name;\n }\n get isConditionalNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalCondition = this.condition._compile(math, argNames);\n var evalTrueExpr = this.trueExpr._compile(math, argNames);\n var evalFalseExpr = this.falseExpr._compile(math, argNames);\n return function evalConditionalNode(scope, args, context) {\n return testCondition(evalCondition(scope, args, context)) ? evalTrueExpr(scope, args, context) : evalFalseExpr(scope, args, context);\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.condition, 'condition', this);\n callback(this.trueExpr, 'trueExpr', this);\n callback(this.falseExpr, 'falseExpr', this);\n }\n\n /**\n * Create a new ConditionalNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ConditionalNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new ConditionalNode(this._ifNode(callback(this.condition, 'condition', this)), this._ifNode(callback(this.trueExpr, 'trueExpr', this)), this._ifNode(callback(this.falseExpr, 'falseExpr', this)));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ConditionalNode}\n */\n clone() {\n return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n\n // Enclose Arguments in parentheses if they are an OperatorNode\n // or have lower or equal precedence\n // NOTE: enclosing all OperatorNodes in parentheses is a decision\n // purely based on aesthetics and readability\n var condition = this.condition.toString(options);\n var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.condition.type === 'OperatorNode' || conditionPrecedence !== null && conditionPrecedence <= precedence) {\n condition = '(' + condition + ')';\n }\n var trueExpr = this.trueExpr.toString(options);\n var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.trueExpr.type === 'OperatorNode' || truePrecedence !== null && truePrecedence <= precedence) {\n trueExpr = '(' + trueExpr + ')';\n }\n var falseExpr = this.falseExpr.toString(options);\n var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.falseExpr.type === 'OperatorNode' || falsePrecedence !== null && falsePrecedence <= precedence) {\n falseExpr = '(' + falseExpr + ')';\n }\n return condition + ' ? ' + trueExpr + ' : ' + falseExpr;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n condition: this.condition,\n trueExpr: this.trueExpr,\n falseExpr: this.falseExpr\n };\n }\n\n /**\n * Instantiate an ConditionalNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"ConditionalNode\",\n * \"condition\": ...,\n * \"trueExpr\": ...,\n * \"falseExpr\": ...}\n * ```\n * where mathjs is optional\n * @returns {ConditionalNode}\n */\n static fromJSON(json) {\n return new ConditionalNode(json.condition, json.trueExpr, json.falseExpr);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n\n // Enclose Arguments in parentheses if they are an OperatorNode\n // or have lower or equal precedence\n // NOTE: enclosing all OperatorNodes in parentheses is a decision\n // purely based on aesthetics and readability\n var condition = this.condition.toHTML(options);\n var conditionPrecedence = getPrecedence(this.condition, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.condition.type === 'OperatorNode' || conditionPrecedence !== null && conditionPrecedence <= precedence) {\n condition = '(' + condition + ')';\n }\n var trueExpr = this.trueExpr.toHTML(options);\n var truePrecedence = getPrecedence(this.trueExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.trueExpr.type === 'OperatorNode' || truePrecedence !== null && truePrecedence <= precedence) {\n trueExpr = '(' + trueExpr + ')';\n }\n var falseExpr = this.falseExpr.toHTML(options);\n var falsePrecedence = getPrecedence(this.falseExpr, parenthesis, options && options.implicit);\n if (parenthesis === 'all' || this.falseExpr.type === 'OperatorNode' || falsePrecedence !== null && falsePrecedence <= precedence) {\n falseExpr = '(' + falseExpr + ')';\n }\n return condition + '?' + trueExpr + ':' + falseExpr;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n return '\\\\begin{cases} {' + this.trueExpr.toTex(options) + '}, &\\\\quad{\\\\text{if }\\\\;' + this.condition.toTex(options) + '}\\\\\\\\{' + this.falseExpr.toTex(options) + '}, &\\\\quad{\\\\text{otherwise}}\\\\end{cases}';\n }\n }\n _defineProperty(ConditionalNode, \"name\", name);\n return ConditionalNode;\n}, {\n isClass: true,\n isNode: true\n});","\"use strict\";\n\n// Map the characters to escape to their escaped values. The list is derived\n// from http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar defaultEscapes = {\n \"{\": \"\\\\{\",\n \"}\": \"\\\\}\",\n \"\\\\\": \"\\\\textbackslash{}\",\n \"#\": \"\\\\#\",\n $: \"\\\\$\",\n \"%\": \"\\\\%\",\n \"&\": \"\\\\&\",\n \"^\": \"\\\\textasciicircum{}\",\n _: \"\\\\_\",\n \"~\": \"\\\\textasciitilde{}\"\n};\nvar formatEscapes = {\n \"\\u2013\": \"\\\\--\",\n \"\\u2014\": \"\\\\---\",\n \" \": \"~\",\n \"\\t\": \"\\\\qquad{}\",\n \"\\r\\n\": \"\\\\newline{}\",\n \"\\n\": \"\\\\newline{}\"\n};\n\nvar defaultEscapeMapFn = function defaultEscapeMapFn(defaultEscapes, formatEscapes) {\n return _extends({}, defaultEscapes, formatEscapes);\n};\n\n/**\n * Escape a string to be used in LaTeX documents.\n * @param {string} str the string to be escaped.\n * @param {boolean} params.preserveFormatting whether formatting escapes should\n * be performed (default: false).\n * @param {function} params.escapeMapFn the function to modify the escape maps.\n * @return {string} the escaped string, ready to be used in LaTeX.\n */\nmodule.exports = function (str) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref$preserveFormatti = _ref.preserveFormatting,\n preserveFormatting = _ref$preserveFormatti === undefined ? false : _ref$preserveFormatti,\n _ref$escapeMapFn = _ref.escapeMapFn,\n escapeMapFn = _ref$escapeMapFn === undefined ? defaultEscapeMapFn : _ref$escapeMapFn;\n\n var runningStr = String(str);\n var result = \"\";\n\n var escapes = escapeMapFn(_extends({}, defaultEscapes), preserveFormatting ? _extends({}, formatEscapes) : {});\n var escapeKeys = Object.keys(escapes); // as it is reused later on\n\n // Algorithm: Go through the string character by character, if it matches\n // with one of the special characters then we'll replace it with the escaped\n // version.\n\n var _loop = function _loop() {\n var specialCharFound = false;\n escapeKeys.forEach(function (key, index) {\n if (specialCharFound) {\n return;\n }\n if (runningStr.length >= key.length && runningStr.slice(0, key.length) === key) {\n result += escapes[escapeKeys[index]];\n runningStr = runningStr.slice(key.length, runningStr.length);\n specialCharFound = true;\n }\n });\n if (!specialCharFound) {\n result += runningStr.slice(0, 1);\n runningStr = runningStr.slice(1, runningStr.length);\n }\n };\n\n while (runningStr) {\n _loop();\n }\n return result;\n};","/* eslint no-template-curly-in-string: \"off\" */\n\nimport escapeLatexLib from 'escape-latex';\nimport { hasOwnProperty } from './object.js';\nexport var latexSymbols = {\n // GREEK LETTERS\n Alpha: 'A',\n alpha: '\\\\alpha',\n Beta: 'B',\n beta: '\\\\beta',\n Gamma: '\\\\Gamma',\n gamma: '\\\\gamma',\n Delta: '\\\\Delta',\n delta: '\\\\delta',\n Epsilon: 'E',\n epsilon: '\\\\epsilon',\n varepsilon: '\\\\varepsilon',\n Zeta: 'Z',\n zeta: '\\\\zeta',\n Eta: 'H',\n eta: '\\\\eta',\n Theta: '\\\\Theta',\n theta: '\\\\theta',\n vartheta: '\\\\vartheta',\n Iota: 'I',\n iota: '\\\\iota',\n Kappa: 'K',\n kappa: '\\\\kappa',\n varkappa: '\\\\varkappa',\n Lambda: '\\\\Lambda',\n lambda: '\\\\lambda',\n Mu: 'M',\n mu: '\\\\mu',\n Nu: 'N',\n nu: '\\\\nu',\n Xi: '\\\\Xi',\n xi: '\\\\xi',\n Omicron: 'O',\n omicron: 'o',\n Pi: '\\\\Pi',\n pi: '\\\\pi',\n varpi: '\\\\varpi',\n Rho: 'P',\n rho: '\\\\rho',\n varrho: '\\\\varrho',\n Sigma: '\\\\Sigma',\n sigma: '\\\\sigma',\n varsigma: '\\\\varsigma',\n Tau: 'T',\n tau: '\\\\tau',\n Upsilon: '\\\\Upsilon',\n upsilon: '\\\\upsilon',\n Phi: '\\\\Phi',\n phi: '\\\\phi',\n varphi: '\\\\varphi',\n Chi: 'X',\n chi: '\\\\chi',\n Psi: '\\\\Psi',\n psi: '\\\\psi',\n Omega: '\\\\Omega',\n omega: '\\\\omega',\n // logic\n true: '\\\\mathrm{True}',\n false: '\\\\mathrm{False}',\n // other\n i: 'i',\n // TODO use \\i ??\n inf: '\\\\infty',\n Inf: '\\\\infty',\n infinity: '\\\\infty',\n Infinity: '\\\\infty',\n oo: '\\\\infty',\n lim: '\\\\lim',\n undefined: '\\\\mathbf{?}'\n};\nexport var latexOperators = {\n transpose: '^\\\\top',\n ctranspose: '^H',\n factorial: '!',\n pow: '^',\n dotPow: '.^\\\\wedge',\n // TODO find ideal solution\n unaryPlus: '+',\n unaryMinus: '-',\n bitNot: '\\\\~',\n // TODO find ideal solution\n not: '\\\\neg',\n multiply: '\\\\cdot',\n divide: '\\\\frac',\n // TODO how to handle that properly?\n dotMultiply: '.\\\\cdot',\n // TODO find ideal solution\n dotDivide: '.:',\n // TODO find ideal solution\n mod: '\\\\mod',\n add: '+',\n subtract: '-',\n to: '\\\\rightarrow',\n leftShift: '<<',\n rightArithShift: '>>',\n rightLogShift: '>>>',\n equal: '=',\n unequal: '\\\\neq',\n smaller: '<',\n larger: '>',\n smallerEq: '\\\\leq',\n largerEq: '\\\\geq',\n bitAnd: '\\\\&',\n bitXor: '\\\\underline{|}',\n bitOr: '|',\n and: '\\\\wedge',\n xor: '\\\\veebar',\n or: '\\\\vee'\n};\nexport var latexFunctions = {\n // arithmetic\n abs: {\n 1: '\\\\left|${args[0]}\\\\right|'\n },\n add: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.add, \"${args[1]}\\\\right)\")\n },\n cbrt: {\n 1: '\\\\sqrt[3]{${args[0]}}'\n },\n ceil: {\n 1: '\\\\left\\\\lceil${args[0]}\\\\right\\\\rceil'\n },\n cube: {\n 1: '\\\\left(${args[0]}\\\\right)^3'\n },\n divide: {\n 2: '\\\\frac{${args[0]}}{${args[1]}}'\n },\n dotDivide: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotDivide, \"${args[1]}\\\\right)\")\n },\n dotMultiply: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotMultiply, \"${args[1]}\\\\right)\")\n },\n dotPow: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.dotPow, \"${args[1]}\\\\right)\")\n },\n exp: {\n 1: '\\\\exp\\\\left(${args[0]}\\\\right)'\n },\n expm1: \"\\\\left(e\".concat(latexOperators.pow, \"{${args[0]}}-1\\\\right)\"),\n fix: {\n 1: '\\\\mathrm{${name}}\\\\left(${args[0]}\\\\right)'\n },\n floor: {\n 1: '\\\\left\\\\lfloor${args[0]}\\\\right\\\\rfloor'\n },\n fraction: {\n 2: '\\\\frac{${args[0]}}{${args[1]}}'\n },\n gcd: '\\\\gcd\\\\left(${args}\\\\right)',\n hypot: '\\\\hypot\\\\left(${args}\\\\right)',\n log: {\n 1: '\\\\ln\\\\left(${args[0]}\\\\right)',\n 2: '\\\\log_{${args[1]}}\\\\left(${args[0]}\\\\right)'\n },\n log10: {\n 1: '\\\\log_{10}\\\\left(${args[0]}\\\\right)'\n },\n log1p: {\n 1: '\\\\ln\\\\left(${args[0]}+1\\\\right)',\n 2: '\\\\log_{${args[1]}}\\\\left(${args[0]}+1\\\\right)'\n },\n log2: '\\\\log_{2}\\\\left(${args[0]}\\\\right)',\n mod: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.mod, \"${args[1]}\\\\right)\")\n },\n multiply: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.multiply, \"${args[1]}\\\\right)\")\n },\n norm: {\n 1: '\\\\left\\\\|${args[0]}\\\\right\\\\|',\n 2: undefined // use default template\n },\n nthRoot: {\n 2: '\\\\sqrt[${args[1]}]{${args[0]}}'\n },\n nthRoots: {\n 2: '\\\\{y : y^${args[1]} = {${args[0]}}\\\\}'\n },\n pow: {\n 2: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.pow, \"{${args[1]}}\")\n },\n round: {\n 1: '\\\\left\\\\lfloor${args[0]}\\\\right\\\\rceil',\n 2: undefined // use default template\n },\n sign: {\n 1: '\\\\mathrm{${name}}\\\\left(${args[0]}\\\\right)'\n },\n sqrt: {\n 1: '\\\\sqrt{${args[0]}}'\n },\n square: {\n 1: '\\\\left(${args[0]}\\\\right)^2'\n },\n subtract: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.subtract, \"${args[1]}\\\\right)\")\n },\n unaryMinus: {\n 1: \"\".concat(latexOperators.unaryMinus, \"\\\\left(${args[0]}\\\\right)\")\n },\n unaryPlus: {\n 1: \"\".concat(latexOperators.unaryPlus, \"\\\\left(${args[0]}\\\\right)\")\n },\n // bitwise\n bitAnd: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitAnd, \"${args[1]}\\\\right)\")\n },\n bitNot: {\n 1: latexOperators.bitNot + '\\\\left(${args[0]}\\\\right)'\n },\n bitOr: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitOr, \"${args[1]}\\\\right)\")\n },\n bitXor: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.bitXor, \"${args[1]}\\\\right)\")\n },\n leftShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.leftShift, \"${args[1]}\\\\right)\")\n },\n rightArithShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.rightArithShift, \"${args[1]}\\\\right)\")\n },\n rightLogShift: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.rightLogShift, \"${args[1]}\\\\right)\")\n },\n // combinatorics\n bellNumbers: {\n 1: '\\\\mathrm{B}_{${args[0]}}'\n },\n catalan: {\n 1: '\\\\mathrm{C}_{${args[0]}}'\n },\n stirlingS2: {\n 2: '\\\\mathrm{S}\\\\left(${args}\\\\right)'\n },\n // complex\n arg: {\n 1: '\\\\arg\\\\left(${args[0]}\\\\right)'\n },\n conj: {\n 1: '\\\\left(${args[0]}\\\\right)^*'\n },\n im: {\n 1: '\\\\Im\\\\left\\\\lbrace${args[0]}\\\\right\\\\rbrace'\n },\n re: {\n 1: '\\\\Re\\\\left\\\\lbrace${args[0]}\\\\right\\\\rbrace'\n },\n // logical\n and: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.and, \"${args[1]}\\\\right)\")\n },\n not: {\n 1: latexOperators.not + '\\\\left(${args[0]}\\\\right)'\n },\n or: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.or, \"${args[1]}\\\\right)\")\n },\n xor: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.xor, \"${args[1]}\\\\right)\")\n },\n // matrix\n cross: {\n 2: '\\\\left(${args[0]}\\\\right)\\\\times\\\\left(${args[1]}\\\\right)'\n },\n ctranspose: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.ctranspose)\n },\n det: {\n 1: '\\\\det\\\\left(${args[0]}\\\\right)'\n },\n dot: {\n 2: '\\\\left(${args[0]}\\\\cdot${args[1]}\\\\right)'\n },\n expm: {\n 1: '\\\\exp\\\\left(${args[0]}\\\\right)'\n },\n inv: {\n 1: '\\\\left(${args[0]}\\\\right)^{-1}'\n },\n pinv: {\n 1: '\\\\left(${args[0]}\\\\right)^{+}'\n },\n sqrtm: {\n 1: \"{${args[0]}}\".concat(latexOperators.pow, \"{\\\\frac{1}{2}}\")\n },\n trace: {\n 1: '\\\\mathrm{tr}\\\\left(${args[0]}\\\\right)'\n },\n transpose: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.transpose)\n },\n // probability\n combinations: {\n 2: '\\\\binom{${args[0]}}{${args[1]}}'\n },\n combinationsWithRep: {\n 2: '\\\\left(\\\\!\\\\!{\\\\binom{${args[0]}}{${args[1]}}}\\\\!\\\\!\\\\right)'\n },\n factorial: {\n 1: \"\\\\left(${args[0]}\\\\right)\".concat(latexOperators.factorial)\n },\n gamma: {\n 1: '\\\\Gamma\\\\left(${args[0]}\\\\right)'\n },\n lgamma: {\n 1: '\\\\ln\\\\Gamma\\\\left(${args[0]}\\\\right)'\n },\n // relational\n equal: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.equal, \"${args[1]}\\\\right)\")\n },\n larger: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.larger, \"${args[1]}\\\\right)\")\n },\n largerEq: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.largerEq, \"${args[1]}\\\\right)\")\n },\n smaller: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.smaller, \"${args[1]}\\\\right)\")\n },\n smallerEq: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.smallerEq, \"${args[1]}\\\\right)\")\n },\n unequal: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.unequal, \"${args[1]}\\\\right)\")\n },\n // special\n erf: {\n 1: 'erf\\\\left(${args[0]}\\\\right)'\n },\n // statistics\n max: '\\\\max\\\\left(${args}\\\\right)',\n min: '\\\\min\\\\left(${args}\\\\right)',\n variance: '\\\\mathrm{Var}\\\\left(${args}\\\\right)',\n // trigonometry\n acos: {\n 1: '\\\\cos^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acosh: {\n 1: '\\\\cosh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acot: {\n 1: '\\\\cot^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acoth: {\n 1: '\\\\coth^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acsc: {\n 1: '\\\\csc^{-1}\\\\left(${args[0]}\\\\right)'\n },\n acsch: {\n 1: '\\\\mathrm{csch}^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asec: {\n 1: '\\\\sec^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asech: {\n 1: '\\\\mathrm{sech}^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asin: {\n 1: '\\\\sin^{-1}\\\\left(${args[0]}\\\\right)'\n },\n asinh: {\n 1: '\\\\sinh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n atan: {\n 1: '\\\\tan^{-1}\\\\left(${args[0]}\\\\right)'\n },\n atan2: {\n 2: '\\\\mathrm{atan2}\\\\left(${args}\\\\right)'\n },\n atanh: {\n 1: '\\\\tanh^{-1}\\\\left(${args[0]}\\\\right)'\n },\n cos: {\n 1: '\\\\cos\\\\left(${args[0]}\\\\right)'\n },\n cosh: {\n 1: '\\\\cosh\\\\left(${args[0]}\\\\right)'\n },\n cot: {\n 1: '\\\\cot\\\\left(${args[0]}\\\\right)'\n },\n coth: {\n 1: '\\\\coth\\\\left(${args[0]}\\\\right)'\n },\n csc: {\n 1: '\\\\csc\\\\left(${args[0]}\\\\right)'\n },\n csch: {\n 1: '\\\\mathrm{csch}\\\\left(${args[0]}\\\\right)'\n },\n sec: {\n 1: '\\\\sec\\\\left(${args[0]}\\\\right)'\n },\n sech: {\n 1: '\\\\mathrm{sech}\\\\left(${args[0]}\\\\right)'\n },\n sin: {\n 1: '\\\\sin\\\\left(${args[0]}\\\\right)'\n },\n sinh: {\n 1: '\\\\sinh\\\\left(${args[0]}\\\\right)'\n },\n tan: {\n 1: '\\\\tan\\\\left(${args[0]}\\\\right)'\n },\n tanh: {\n 1: '\\\\tanh\\\\left(${args[0]}\\\\right)'\n },\n // unit\n to: {\n 2: \"\\\\left(${args[0]}\".concat(latexOperators.to, \"${args[1]}\\\\right)\")\n },\n // utils\n numeric: function numeric(node, options) {\n // Not sure if this is strictly right but should work correctly for the vast majority of use cases.\n return node.args[0].toTex();\n },\n // type\n number: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(\\\\left(${args[0]}\\\\right)${args[1]}\\\\right)'\n },\n string: {\n 0: '\\\\mathtt{\"\"}',\n 1: '\\\\mathrm{string}\\\\left(${args[0]}\\\\right)'\n },\n bignumber: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n bigint: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n complex: {\n 0: '0',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: \"\\\\left(\\\\left(${args[0]}\\\\right)+\".concat(latexSymbols.i, \"\\\\cdot\\\\left(${args[1]}\\\\right)\\\\right)\")\n },\n matrix: {\n 0: '\\\\begin{bmatrix}\\\\end{bmatrix}',\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(${args[0]}\\\\right)'\n },\n sparse: {\n 0: '\\\\begin{bsparse}\\\\end{bsparse}',\n 1: '\\\\left(${args[0]}\\\\right)'\n },\n unit: {\n 1: '\\\\left(${args[0]}\\\\right)',\n 2: '\\\\left(\\\\left(${args[0]}\\\\right)${args[1]}\\\\right)'\n }\n};\nexport var defaultTemplate = '\\\\mathrm{${name}}\\\\left(${args}\\\\right)';\nvar latexUnits = {\n deg: '^\\\\circ'\n};\nexport function escapeLatex(string) {\n return escapeLatexLib(string, {\n preserveFormatting: true\n });\n}\n\n// @param {string} name\n// @param {boolean} isUnit\nexport function toSymbol(name, isUnit) {\n isUnit = typeof isUnit === 'undefined' ? false : isUnit;\n if (isUnit) {\n if (hasOwnProperty(latexUnits, name)) {\n return latexUnits[name];\n }\n return '\\\\mathrm{' + escapeLatex(name) + '}';\n }\n if (hasOwnProperty(latexSymbols, name)) {\n return latexSymbols[name];\n }\n return escapeLatex(name);\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { format } from '../../utils/string.js';\nimport { typeOf } from '../../utils/is.js';\nimport { escapeLatex } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ConstantNode';\nvar dependencies = ['Node', 'isBounded'];\nexport var createConstantNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node,\n isBounded\n } = _ref;\n class ConstantNode extends Node {\n /**\n * A ConstantNode holds a constant value like a number or string.\n *\n * Usage:\n *\n * new ConstantNode(2.3)\n * new ConstantNode('hello')\n *\n * @param {*} value Value can be any type (number, BigNumber, bigint, string, ...)\n * @constructor ConstantNode\n * @extends {Node}\n */\n constructor(value) {\n super();\n this.value = value;\n }\n get type() {\n return name;\n }\n get isConstantNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var value = this.value;\n return function evalConstantNode() {\n return value;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // nothing to do, we don't have any children\n }\n\n /**\n * Create a new ConstantNode with children produced by the given callback.\n * Trivial because there are no children.\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {ConstantNode} Returns a clone of the node\n */\n map(callback) {\n return this.clone();\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ConstantNode}\n */\n clone() {\n return new ConstantNode(this.value);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n return format(this.value, options);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var value = this._toString(options);\n switch (typeOf(this.value)) {\n case 'number':\n case 'bigint':\n case 'BigNumber':\n case 'Fraction':\n return '' + value + '';\n case 'string':\n return '' + value + '';\n case 'boolean':\n return '' + value + '';\n case 'null':\n return '' + value + '';\n case 'undefined':\n return '' + value + '';\n default:\n return '' + value + '';\n }\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n value: this.value\n };\n }\n\n /**\n * Instantiate a ConstantNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"SymbolNode\", value: 2.3}`,\n * where mathjs is optional\n * @returns {ConstantNode}\n */\n static fromJSON(json) {\n return new ConstantNode(json.value);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var value = this._toString(options);\n var type = typeOf(this.value);\n switch (type) {\n case 'string':\n return '\\\\mathtt{' + escapeLatex(value) + '}';\n case 'number':\n case 'BigNumber':\n {\n if (!isBounded(this.value)) {\n return this.value.valueOf() < 0 ? '-\\\\infty' : '\\\\infty';\n }\n var index = value.toLowerCase().indexOf('e');\n if (index !== -1) {\n return value.substring(0, index) + '\\\\cdot10^{' + value.substring(index + 1) + '}';\n }\n return value;\n }\n case 'bigint':\n {\n return value.toString();\n }\n case 'Fraction':\n return this.value.toLatex();\n default:\n return value;\n }\n }\n }\n _defineProperty(ConstantNode, \"name\", name);\n return ConstantNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { keywords } from '../keywords.js';\nimport { escape } from '../../utils/string.js';\nimport { forEach, join } from '../../utils/array.js';\nimport { toSymbol } from '../../utils/latex.js';\nimport { getPrecedence } from '../operators.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'FunctionAssignmentNode';\nvar dependencies = ['typed', 'Node'];\nexport var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n Node\n } = _ref;\n /**\n * Is parenthesis needed?\n * @param {Node} node\n * @param {Object} parenthesis\n * @param {string} implicit\n * @private\n */\n function needParenthesis(node, parenthesis, implicit) {\n var precedence = getPrecedence(node, parenthesis, implicit);\n var exprPrecedence = getPrecedence(node.expr, parenthesis, implicit);\n return parenthesis === 'all' || exprPrecedence !== null && exprPrecedence <= precedence;\n }\n class FunctionAssignmentNode extends Node {\n /**\n * @constructor FunctionAssignmentNode\n * @extends {Node}\n * Function assignment\n *\n * @param {string} name Function name\n * @param {string[] | Array.<{name: string, type: string}>} params\n * Array with function parameter names, or an\n * array with objects containing the name\n * and type of the parameter\n * @param {Node} expr The function expression\n */\n constructor(name, params, expr) {\n super();\n // validate input\n if (typeof name !== 'string') {\n throw new TypeError('String expected for parameter \"name\"');\n }\n if (!Array.isArray(params)) {\n throw new TypeError('Array containing strings or objects expected for parameter \"params\"');\n }\n if (!isNode(expr)) {\n throw new TypeError('Node expected for parameter \"expr\"');\n }\n if (keywords.has(name)) {\n throw new Error('Illegal function name, \"' + name + '\" is a reserved keyword');\n }\n var paramNames = new Set();\n for (var param of params) {\n var _name = typeof param === 'string' ? param : param.name;\n if (paramNames.has(_name)) {\n throw new Error(\"Duplicate parameter name \\\"\".concat(_name, \"\\\"\"));\n } else {\n paramNames.add(_name);\n }\n }\n this.name = name;\n this.params = params.map(function (param) {\n return param && param.name || param;\n });\n this.types = params.map(function (param) {\n return param && param.type || 'any';\n });\n this.expr = expr;\n }\n get type() {\n return name;\n }\n get isFunctionAssignmentNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var childArgNames = Object.create(argNames);\n forEach(this.params, function (param) {\n childArgNames[param] = true;\n });\n\n // compile the function expression with the child args\n var expr = this.expr;\n var evalExpr = expr._compile(math, childArgNames);\n var name = this.name;\n var params = this.params;\n var signature = join(this.types, ',');\n var syntax = name + '(' + join(this.params, ', ') + ')';\n return function evalFunctionAssignmentNode(scope, args, context) {\n var signatures = {};\n signatures[signature] = function () {\n var childArgs = Object.create(args);\n for (var i = 0; i < params.length; i++) {\n childArgs[params[i]] = arguments[i];\n }\n return evalExpr(scope, childArgs, context);\n };\n var fn = typed(name, signatures);\n fn.syntax = syntax;\n fn.expr = expr.toString();\n scope.set(name, fn);\n return fn;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.expr, 'expr', this);\n }\n\n /**\n * Create a new FunctionAssignmentNode whose children are the results of\n * calling the provided callback function for each child of the original\n * node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {FunctionAssignmentNode} Returns a transformed copy of the node\n */\n map(callback) {\n var expr = this._ifNode(callback(this.expr, 'expr', this));\n return new FunctionAssignmentNode(this.name, this.params.slice(0), expr);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {FunctionAssignmentNode}\n */\n clone() {\n return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr);\n }\n\n /**\n * get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var expr = this.expr.toString(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = '(' + expr + ')';\n }\n return this.name + '(' + this.params.join(', ') + ') = ' + expr;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n var types = this.types;\n return {\n mathjs: name,\n name: this.name,\n params: this.params.map(function (param, index) {\n return {\n name: param,\n type: types[index]\n };\n }),\n expr: this.expr\n };\n }\n\n /**\n * Instantiate an FunctionAssignmentNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"FunctionAssignmentNode\",\n * name: ..., params: ..., expr: ...}\n * ```\n * where mathjs is optional\n * @returns {FunctionAssignmentNode}\n */\n static fromJSON(json) {\n return new FunctionAssignmentNode(json.name, json.params, json.expr);\n }\n\n /**\n * get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var params = [];\n for (var i = 0; i < this.params.length; i++) {\n params.push('' + escape(this.params[i]) + '');\n }\n var expr = this.expr.toHTML(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = '(' + expr + ')';\n }\n return '' + escape(this.name) + '' + '(' + params.join(',') + ')' + '=' + expr;\n }\n\n /**\n * get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var expr = this.expr.toTex(options);\n if (needParenthesis(this, parenthesis, options && options.implicit)) {\n expr = \"\\\\left(\".concat(expr, \"\\\\right)\");\n }\n return '\\\\mathrm{' + this.name + '}\\\\left(' + this.params.map(toSymbol).join(',') + '\\\\right)=' + expr;\n }\n }\n _defineProperty(FunctionAssignmentNode, \"name\", name);\n return FunctionAssignmentNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { map } from '../../utils/array.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { isArray, isConstantNode, isMatrix, isNode, isString, typeOf } from '../../utils/is.js';\nimport { escape } from '../../utils/string.js';\nvar name = 'IndexNode';\nvar dependencies = ['Node', 'size'];\nexport var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node,\n size\n } = _ref;\n class IndexNode extends Node {\n /**\n * @constructor IndexNode\n * @extends Node\n *\n * Describes a subset of a matrix or an object property.\n * Cannot be used on its own, needs to be used within an AccessorNode or\n * AssignmentNode.\n *\n * @param {Node[]} dimensions\n * @param {boolean} [dotNotation=false]\n * Optional property describing whether this index was written using dot\n * notation like `a.b`, or using bracket notation like `a[\"b\"]`\n * (which is the default). This property is used for string conversion.\n */\n constructor(dimensions, dotNotation) {\n super();\n this.dimensions = dimensions;\n this.dotNotation = dotNotation || false;\n\n // validate input\n if (!Array.isArray(dimensions) || !dimensions.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"dimensions\"');\n }\n if (this.dotNotation && !this.isObjectProperty()) {\n throw new Error('dotNotation only applicable for object properties');\n }\n }\n get type() {\n return name;\n }\n get isIndexNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // TODO: implement support for bignumber (currently bignumbers are silently\n // reduced to numbers when changing the value to zero-based)\n\n // TODO: Optimization: when the range values are ConstantNodes,\n // we can beforehand resolve the zero-based value\n\n // optimization for a simple object property\n var evalDimensions = map(this.dimensions, function (dimension, i) {\n var needsEnd = dimension.filter(node => node.isSymbolNode && node.name === 'end').length > 0;\n if (needsEnd) {\n // SymbolNode 'end' is used inside the index,\n // like in `A[end]` or `A[end - 2]`\n var childArgNames = Object.create(argNames);\n childArgNames.end = true;\n var _evalDimension = dimension._compile(math, childArgNames);\n return function evalDimension(scope, args, context) {\n if (!isMatrix(context) && !isArray(context) && !isString(context)) {\n throw new TypeError('Cannot resolve \"end\": ' + 'context must be a Matrix, Array, or string but is ' + typeOf(context));\n }\n var s = size(context);\n var childArgs = Object.create(args);\n childArgs.end = s[i];\n return _evalDimension(scope, childArgs, context);\n };\n } else {\n // SymbolNode `end` not used\n return dimension._compile(math, argNames);\n }\n });\n var index = getSafeProperty(math, 'index');\n return function evalIndexNode(scope, args, context) {\n var dimensions = map(evalDimensions, function (evalDimension) {\n return evalDimension(scope, args, context);\n });\n return index(...dimensions);\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.dimensions.length; i++) {\n callback(this.dimensions[i], 'dimensions[' + i + ']', this);\n }\n }\n\n /**\n * Create a new IndexNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {IndexNode} Returns a transformed copy of the node\n */\n map(callback) {\n var dimensions = [];\n for (var i = 0; i < this.dimensions.length; i++) {\n dimensions[i] = this._ifNode(callback(this.dimensions[i], 'dimensions[' + i + ']', this));\n }\n return new IndexNode(dimensions, this.dotNotation);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {IndexNode}\n */\n clone() {\n return new IndexNode(this.dimensions.slice(0), this.dotNotation);\n }\n\n /**\n * Test whether this IndexNode contains a single property name\n * @return {boolean}\n */\n isObjectProperty() {\n return this.dimensions.length === 1 && isConstantNode(this.dimensions[0]) && typeof this.dimensions[0].value === 'string';\n }\n\n /**\n * Returns the property name if IndexNode contains a property.\n * If not, returns null.\n * @return {string | null}\n */\n getObjectProperty() {\n return this.isObjectProperty() ? this.dimensions[0].value : null;\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n // format the parameters like \"[1, 0:5]\"\n return this.dotNotation ? '.' + this.getObjectProperty() : '[' + this.dimensions.join(', ') + ']';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n dimensions: this.dimensions,\n dotNotation: this.dotNotation\n };\n }\n\n /**\n * Instantiate an IndexNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"IndexNode\", dimensions: [...], dotNotation: false}`,\n * where mathjs is optional\n * @returns {IndexNode}\n */\n static fromJSON(json) {\n return new IndexNode(json.dimensions, json.dotNotation);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n // format the parameters like \"[1, 0:5]\"\n var dimensions = [];\n for (var i = 0; i < this.dimensions.length; i++) {\n dimensions[i] = this.dimensions[i].toHTML();\n }\n if (this.dotNotation) {\n return '.' + '' + escape(this.getObjectProperty()) + '';\n } else {\n return '[' + dimensions.join(',') + ']';\n }\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var dimensions = this.dimensions.map(function (range) {\n return range.toTex(options);\n });\n return this.dotNotation ? '.' + this.getObjectProperty() + '' : '_{' + dimensions.join(',') + '}';\n }\n }\n _defineProperty(IndexNode, \"name\", name);\n return IndexNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { isNode } from '../../utils/is.js';\nimport { hasOwnProperty } from '../../utils/object.js';\nimport { escape, stringify } from '../../utils/string.js';\nvar name = 'ObjectNode';\nvar dependencies = ['Node'];\nexport var createObjectNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ObjectNode extends Node {\n /**\n * @constructor ObjectNode\n * @extends {Node}\n * Holds an object with keys/values\n * @param {Object.} [properties] object with key/value pairs\n */\n constructor(properties) {\n super();\n this.properties = properties || {};\n\n // validate input\n if (properties) {\n if (!(typeof properties === 'object') || !Object.keys(properties).every(function (key) {\n return isNode(properties[key]);\n })) {\n throw new TypeError('Object containing Nodes expected');\n }\n }\n }\n get type() {\n return name;\n }\n get isObjectNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var evalEntries = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n // we stringify/parse the key here to resolve unicode characters,\n // so you cannot create a key like {\"co\\\\u006Estructor\": null}\n var stringifiedKey = stringify(key);\n var parsedKey = JSON.parse(stringifiedKey);\n var prop = getSafeProperty(this.properties, key);\n evalEntries[parsedKey] = prop._compile(math, argNames);\n }\n }\n return function evalObjectNode(scope, args, context) {\n var obj = {};\n for (var _key in evalEntries) {\n if (hasOwnProperty(evalEntries, _key)) {\n obj[_key] = evalEntries[_key](scope, args, context);\n }\n }\n return obj;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n callback(this.properties[key], 'properties[' + stringify(key) + ']', this);\n }\n }\n }\n\n /**\n * Create a new ObjectNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {ObjectNode} Returns a transformed copy of the node\n */\n map(callback) {\n var properties = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n properties[key] = this._ifNode(callback(this.properties[key], 'properties[' + stringify(key) + ']', this));\n }\n }\n return new ObjectNode(properties);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ObjectNode}\n */\n clone() {\n var properties = {};\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n properties[key] = this.properties[key];\n }\n }\n return new ObjectNode(properties);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push(stringify(key) + ': ' + this.properties[key].toString(options));\n }\n }\n return '{' + entries.join(', ') + '}';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n properties: this.properties\n };\n }\n\n /**\n * Instantiate an OperatorNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ObjectNode\", \"properties\": {...}}`,\n * where mathjs is optional\n * @returns {ObjectNode}\n */\n static fromJSON(json) {\n return new ObjectNode(json.properties);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push('' + escape(key) + '' + '' + ':' + this.properties[key].toHTML(options));\n }\n }\n return '{' + entries.join(',') + '}';\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var entries = [];\n for (var key in this.properties) {\n if (hasOwnProperty(this.properties, key)) {\n entries.push('\\\\mathbf{' + key + ':} & ' + this.properties[key].toTex(options) + '\\\\\\\\');\n }\n }\n var tex = '\\\\left\\\\{\\\\begin{array}{ll}' + entries.join('\\n') + '\\\\end{array}\\\\right\\\\}';\n return tex;\n }\n }\n _defineProperty(ObjectNode, \"name\", name);\n return ObjectNode;\n}, {\n isClass: true,\n isNode: true\n});","import { ObjectWrappingMap, PartitionedMap } from './map.js';\n\n/**\n * Create a new scope which can access the parent scope,\n * but does not affect it when written. This is suitable for variable definitions\n * within a block node, or function definition.\n *\n * If parent scope has a createSubScope method, it delegates to that. Otherwise,\n * creates an empty map, and copies the parent scope to it, adding in\n * the remaining `args`.\n *\n * @param {Map} parentScope\n * @param {Object} args\n * @returns {PartitionedMap}\n */\nexport function createSubScope(parentScope, args) {\n return new PartitionedMap(parentScope, new ObjectWrappingMap(args), new Set(Object.keys(args)));\n}","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode, isConstantNode, isOperatorNode, isParenthesisNode } from '../../utils/is.js';\nimport { map } from '../../utils/array.js';\nimport { createSubScope } from '../../utils/scope.js';\nimport { escape } from '../../utils/string.js';\nimport { getSafeProperty, isSafeMethod } from '../../utils/customs.js';\nimport { getAssociativity, getPrecedence, isAssociativeWith, properties } from '../operators.js';\nimport { latexOperators } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'OperatorNode';\nvar dependencies = ['Node'];\nexport var createOperatorNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Returns true if the expression starts with a constant, under\n * the current parenthesization:\n * @param {Node} expression\n * @param {string} parenthesis\n * @return {boolean}\n */\n function startsWithConstant(expr, parenthesis) {\n var curNode = expr;\n if (parenthesis === 'auto') {\n while (isParenthesisNode(curNode)) curNode = curNode.content;\n }\n if (isConstantNode(curNode)) return true;\n if (isOperatorNode(curNode)) {\n return startsWithConstant(curNode.args[0], parenthesis);\n }\n return false;\n }\n\n /**\n * Calculate which parentheses are necessary. Gets an OperatorNode\n * (which is the root of the tree) and an Array of Nodes\n * (this.args) and returns an array where 'true' means that an argument\n * has to be enclosed in parentheses whereas 'false' means the opposite.\n *\n * @param {OperatorNode} root\n * @param {string} parenthesis\n * @param {Node[]} args\n * @param {boolean} latex\n * @return {boolean[]}\n * @private\n */\n function calculateNecessaryParentheses(root, parenthesis, implicit, args, latex) {\n // precedence of the root OperatorNode\n var precedence = getPrecedence(root, parenthesis, implicit);\n var associativity = getAssociativity(root, parenthesis);\n if (parenthesis === 'all' || args.length > 2 && root.getIdentifier() !== 'OperatorNode:add' && root.getIdentifier() !== 'OperatorNode:multiply') {\n return args.map(function (arg) {\n switch (arg.getContent().type) {\n // Nodes that don't need extra parentheses\n case 'ArrayNode':\n case 'ConstantNode':\n case 'SymbolNode':\n case 'ParenthesisNode':\n return false;\n default:\n return true;\n }\n });\n }\n var result;\n switch (args.length) {\n case 0:\n result = [];\n break;\n case 1:\n // unary operators\n {\n // precedence of the operand\n var operandPrecedence = getPrecedence(args[0], parenthesis, implicit, root);\n\n // handle special cases for LaTeX, where some of the parentheses aren't needed\n if (latex && operandPrecedence !== null) {\n var operandIdentifier;\n var rootIdentifier;\n if (parenthesis === 'keep') {\n operandIdentifier = args[0].getIdentifier();\n rootIdentifier = root.getIdentifier();\n } else {\n // Ignore Parenthesis Nodes when not in 'keep' mode\n operandIdentifier = args[0].getContent().getIdentifier();\n rootIdentifier = root.getContent().getIdentifier();\n }\n if (properties[precedence][rootIdentifier].latexLeftParens === false) {\n result = [false];\n break;\n }\n if (properties[operandPrecedence][operandIdentifier].latexParens === false) {\n result = [false];\n break;\n }\n }\n if (operandPrecedence === null) {\n // if the operand has no defined precedence, no parens are needed\n result = [false];\n break;\n }\n if (operandPrecedence <= precedence) {\n // if the operands precedence is lower, parens are needed\n result = [true];\n break;\n }\n\n // otherwise, no parens needed\n result = [false];\n }\n break;\n case 2:\n // binary operators\n {\n var lhsParens; // left hand side needs parenthesis?\n // precedence of the left hand side\n var lhsPrecedence = getPrecedence(args[0], parenthesis, implicit, root);\n // is the root node associative with the left hand side\n var assocWithLhs = isAssociativeWith(root, args[0], parenthesis);\n if (lhsPrecedence === null) {\n // if the left hand side has no defined precedence, no parens are needed\n // FunctionNode for example\n lhsParens = false;\n } else if (lhsPrecedence === precedence && associativity === 'right' && !assocWithLhs) {\n // In case of equal precedence, if the root node is left associative\n // parens are **never** necessary for the left hand side.\n // If it is right associative however, parens are necessary\n // if the root node isn't associative with the left hand side\n lhsParens = true;\n } else if (lhsPrecedence < precedence) {\n lhsParens = true;\n } else {\n lhsParens = false;\n }\n var rhsParens; // right hand side needs parenthesis?\n // precedence of the right hand side\n var rhsPrecedence = getPrecedence(args[1], parenthesis, implicit, root);\n // is the root node associative with the right hand side?\n var assocWithRhs = isAssociativeWith(root, args[1], parenthesis);\n if (rhsPrecedence === null) {\n // if the right hand side has no defined precedence, no parens are needed\n // FunctionNode for example\n rhsParens = false;\n } else if (rhsPrecedence === precedence && associativity === 'left' && !assocWithRhs) {\n // In case of equal precedence, if the root node is right associative\n // parens are **never** necessary for the right hand side.\n // If it is left associative however, parens are necessary\n // if the root node isn't associative with the right hand side\n rhsParens = true;\n } else if (rhsPrecedence < precedence) {\n rhsParens = true;\n } else {\n rhsParens = false;\n }\n\n // handle special cases for LaTeX, where some of the parentheses aren't needed\n if (latex) {\n var _rootIdentifier;\n var lhsIdentifier;\n var rhsIdentifier;\n if (parenthesis === 'keep') {\n _rootIdentifier = root.getIdentifier();\n lhsIdentifier = root.args[0].getIdentifier();\n rhsIdentifier = root.args[1].getIdentifier();\n } else {\n // Ignore ParenthesisNodes when not in 'keep' mode\n _rootIdentifier = root.getContent().getIdentifier();\n lhsIdentifier = root.args[0].getContent().getIdentifier();\n rhsIdentifier = root.args[1].getContent().getIdentifier();\n }\n if (lhsPrecedence !== null) {\n if (properties[precedence][_rootIdentifier].latexLeftParens === false) {\n lhsParens = false;\n }\n if (properties[lhsPrecedence][lhsIdentifier].latexParens === false) {\n lhsParens = false;\n }\n }\n if (rhsPrecedence !== null) {\n if (properties[precedence][_rootIdentifier].latexRightParens === false) {\n rhsParens = false;\n }\n if (properties[rhsPrecedence][rhsIdentifier].latexParens === false) {\n rhsParens = false;\n }\n }\n }\n result = [lhsParens, rhsParens];\n }\n break;\n default:\n if (root.getIdentifier() === 'OperatorNode:add' || root.getIdentifier() === 'OperatorNode:multiply') {\n result = args.map(function (arg) {\n var argPrecedence = getPrecedence(arg, parenthesis, implicit, root);\n var assocWithArg = isAssociativeWith(root, arg, parenthesis);\n var argAssociativity = getAssociativity(arg, parenthesis);\n if (argPrecedence === null) {\n // if the argument has no defined precedence, no parens are needed\n return false;\n } else if (precedence === argPrecedence && associativity === argAssociativity && !assocWithArg) {\n return true;\n } else if (argPrecedence < precedence) {\n return true;\n }\n return false;\n });\n }\n break;\n }\n\n // Handles an edge case of parentheses with implicit multiplication\n // of ConstantNode.\n // In that case, parenthesize ConstantNodes that follow an unparenthesized\n // expression, even though they normally wouldn't be printed.\n if (args.length >= 2 && root.getIdentifier() === 'OperatorNode:multiply' && root.implicit && parenthesis !== 'all' && implicit === 'hide') {\n for (var i = 1; i < result.length; ++i) {\n if (startsWithConstant(args[i], parenthesis) && !result[i - 1] && (parenthesis !== 'keep' || !isParenthesisNode(args[i - 1]))) {\n result[i] = true;\n }\n }\n }\n return result;\n }\n class OperatorNode extends Node {\n /**\n * @constructor OperatorNode\n * @extends {Node}\n * An operator with two arguments, like 2+3\n *\n * @param {string} op Operator name, for example '+'\n * @param {string} fn Function name, for example 'add'\n * @param {Node[]} args Operator arguments\n * @param {boolean} [implicit] Is this an implicit multiplication?\n * @param {boolean} [isPercentage] Is this an percentage Operation?\n */\n constructor(op, fn, args, implicit, isPercentage) {\n super();\n // validate input\n if (typeof op !== 'string') {\n throw new TypeError('string expected for parameter \"op\"');\n }\n if (typeof fn !== 'string') {\n throw new TypeError('string expected for parameter \"fn\"');\n }\n if (!Array.isArray(args) || !args.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"args\"');\n }\n this.implicit = implicit === true;\n this.isPercentage = isPercentage === true;\n this.op = op;\n this.fn = fn;\n this.args = args || [];\n }\n get type() {\n return name;\n }\n get isOperatorNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // validate fn\n if (typeof this.fn !== 'string' || !isSafeMethod(math, this.fn)) {\n if (!math[this.fn]) {\n throw new Error('Function ' + this.fn + ' missing in provided namespace \"math\"');\n } else {\n throw new Error('No access to function \"' + this.fn + '\"');\n }\n }\n var fn = getSafeProperty(math, this.fn);\n var evalArgs = map(this.args, function (arg) {\n return arg._compile(math, argNames);\n });\n if (typeof fn === 'function' && fn.rawArgs === true) {\n // pass unevaluated parameters (nodes) to the function\n // \"raw\" evaluation\n var rawArgs = this.args;\n return function evalOperatorNode(scope, args, context) {\n return fn(rawArgs, math, createSubScope(scope, args));\n };\n } else if (evalArgs.length === 1) {\n var evalArg0 = evalArgs[0];\n return function evalOperatorNode(scope, args, context) {\n return fn(evalArg0(scope, args, context));\n };\n } else if (evalArgs.length === 2) {\n var _evalArg = evalArgs[0];\n var evalArg1 = evalArgs[1];\n return function evalOperatorNode(scope, args, context) {\n return fn(_evalArg(scope, args, context), evalArg1(scope, args, context));\n };\n } else {\n return function evalOperatorNode(scope, args, context) {\n return fn.apply(null, map(evalArgs, function (evalArg) {\n return evalArg(scope, args, context);\n }));\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n for (var i = 0; i < this.args.length; i++) {\n callback(this.args[i], 'args[' + i + ']', this);\n }\n }\n\n /**\n * Create a new OperatorNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {OperatorNode} Returns a transformed copy of the node\n */\n map(callback) {\n var args = [];\n for (var i = 0; i < this.args.length; i++) {\n args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this));\n }\n return new OperatorNode(this.op, this.fn, args, this.implicit, this.isPercentage);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {OperatorNode}\n */\n clone() {\n return new OperatorNode(this.op, this.fn, this.args.slice(0), this.implicit, this.isPercentage);\n }\n\n /**\n * Check whether this is an unary OperatorNode:\n * has exactly one argument, like `-a`.\n * @return {boolean}\n * Returns true when an unary operator node, false otherwise.\n */\n isUnary() {\n return this.args.length === 1;\n }\n\n /**\n * Check whether this is a binary OperatorNode:\n * has exactly two arguments, like `a + b`.\n * @return {boolean}\n * Returns true when a binary operator node, false otherwise.\n */\n isBinary() {\n return this.args.length === 2;\n }\n\n /**\n * Get string representation.\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toString(options);\n if (parens[0]) {\n operand = '(' + operand + ')';\n }\n\n // for example for \"not\", we want a space between operand and argument\n var opIsNamed = /[a-zA-Z]+/.test(this.op);\n if (assoc === 'right') {\n // prefix operator\n return this.op + (opIsNamed ? ' ' : '') + operand;\n } else if (assoc === 'left') {\n // postfix\n return operand + (opIsNamed ? ' ' : '') + this.op;\n }\n\n // fall back to postfix\n return operand + this.op;\n } else if (args.length === 2) {\n var lhs = args[0].toString(options); // left hand side\n var rhs = args[1].toString(options); // right hand side\n if (parens[0]) {\n // left hand side in parenthesis?\n lhs = '(' + lhs + ')';\n }\n if (parens[1]) {\n // right hand side in parenthesis?\n rhs = '(' + rhs + ')';\n }\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return lhs + ' ' + rhs;\n }\n return lhs + ' ' + this.op + ' ' + rhs;\n } else if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n var stringifiedArgs = args.map(function (arg, index) {\n arg = arg.toString(options);\n if (parens[index]) {\n // put in parenthesis?\n arg = '(' + arg + ')';\n }\n return arg;\n });\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return stringifiedArgs.join(' ');\n }\n return stringifiedArgs.join(' ' + this.op + ' ');\n } else {\n // fallback to formatting as a function call\n return this.fn + '(' + this.args.join(', ') + ')';\n }\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n op: this.op,\n fn: this.fn,\n args: this.args,\n implicit: this.implicit,\n isPercentage: this.isPercentage\n };\n }\n\n /**\n * Instantiate an OperatorNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * ```\n * {\"mathjs\": \"OperatorNode\",\n * \"op\": \"+\", \"fn\": \"add\", \"args\": [...],\n * \"implicit\": false,\n * \"isPercentage\":false}\n * ```\n * where mathjs is optional\n * @returns {OperatorNode}\n */\n static fromJSON(json) {\n return new OperatorNode(json.op, json.fn, json.args, json.implicit, json.isPercentage);\n }\n\n /**\n * Get HTML representation.\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, false);\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toHTML(options);\n if (parens[0]) {\n operand = '(' + operand + ')';\n }\n if (assoc === 'right') {\n // prefix operator\n return '' + escape(this.op) + '' + operand;\n } else {\n // postfix when assoc === 'left' or undefined\n return operand + '' + escape(this.op) + '';\n }\n } else if (args.length === 2) {\n // binary operatoes\n var lhs = args[0].toHTML(options); // left hand side\n var rhs = args[1].toHTML(options); // right hand side\n if (parens[0]) {\n // left hand side in parenthesis?\n lhs = '(' + lhs + ')';\n }\n if (parens[1]) {\n // right hand side in parenthesis?\n rhs = '(' + rhs + ')';\n }\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return lhs + '' + rhs;\n }\n return lhs + '' + escape(this.op) + '' + rhs;\n } else {\n var stringifiedArgs = args.map(function (arg, index) {\n arg = arg.toHTML(options);\n if (parens[index]) {\n // put in parenthesis?\n arg = '(' + arg + ')';\n }\n return arg;\n });\n if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n if (this.implicit && this.getIdentifier() === 'OperatorNode:multiply' && implicit === 'hide') {\n return stringifiedArgs.join('');\n }\n return stringifiedArgs.join('' + escape(this.op) + '');\n } else {\n // fallback to formatting as a function call\n return '' + escape(this.fn) + '' + '(' + stringifiedArgs.join(',') + ')';\n }\n }\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var implicit = options && options.implicit ? options.implicit : 'hide';\n var args = this.args;\n var parens = calculateNecessaryParentheses(this, parenthesis, implicit, args, true);\n var op = latexOperators[this.fn];\n op = typeof op === 'undefined' ? this.op : op; // fall back to using this.op\n\n if (args.length === 1) {\n // unary operators\n var assoc = getAssociativity(this, parenthesis);\n var operand = args[0].toTex(options);\n if (parens[0]) {\n operand = \"\\\\left(\".concat(operand, \"\\\\right)\");\n }\n if (assoc === 'right') {\n // prefix operator\n return op + operand;\n } else if (assoc === 'left') {\n // postfix operator\n return operand + op;\n }\n\n // fall back to postfix\n return operand + op;\n } else if (args.length === 2) {\n // binary operators\n var lhs = args[0]; // left hand side\n var lhsTex = lhs.toTex(options);\n if (parens[0]) {\n lhsTex = \"\\\\left(\".concat(lhsTex, \"\\\\right)\");\n }\n var rhs = args[1]; // right hand side\n var rhsTex = rhs.toTex(options);\n if (parens[1]) {\n rhsTex = \"\\\\left(\".concat(rhsTex, \"\\\\right)\");\n }\n\n // handle some exceptions (due to the way LaTeX works)\n var lhsIdentifier;\n if (parenthesis === 'keep') {\n lhsIdentifier = lhs.getIdentifier();\n } else {\n // Ignore ParenthesisNodes if in 'keep' mode\n lhsIdentifier = lhs.getContent().getIdentifier();\n }\n switch (this.getIdentifier()) {\n case 'OperatorNode:divide':\n // op contains '\\\\frac' at this point\n return op + '{' + lhsTex + '}' + '{' + rhsTex + '}';\n case 'OperatorNode:pow':\n lhsTex = '{' + lhsTex + '}';\n rhsTex = '{' + rhsTex + '}';\n switch (lhsIdentifier) {\n case 'ConditionalNode': //\n case 'OperatorNode:divide':\n lhsTex = \"\\\\left(\".concat(lhsTex, \"\\\\right)\");\n }\n break;\n case 'OperatorNode:multiply':\n if (this.implicit && implicit === 'hide') {\n return lhsTex + '~' + rhsTex;\n }\n }\n return lhsTex + op + rhsTex;\n } else if (args.length > 2 && (this.getIdentifier() === 'OperatorNode:add' || this.getIdentifier() === 'OperatorNode:multiply')) {\n var texifiedArgs = args.map(function (arg, index) {\n arg = arg.toTex(options);\n if (parens[index]) {\n arg = \"\\\\left(\".concat(arg, \"\\\\right)\");\n }\n return arg;\n });\n if (this.getIdentifier() === 'OperatorNode:multiply' && this.implicit && implicit === 'hide') {\n return texifiedArgs.join('~');\n }\n return texifiedArgs.join(op);\n } else {\n // fall back to formatting as a function call\n // as this is a fallback, it doesn't use\n // fancy function names\n return '\\\\mathrm{' + this.fn + '}\\\\left(' + args.map(function (arg) {\n return arg.toTex(options);\n }).join(',') + '\\\\right)';\n }\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type + ':' + this.fn;\n }\n }\n _defineProperty(OperatorNode, \"name\", name);\n return OperatorNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'ParenthesisNode';\nvar dependencies = ['Node'];\nexport var createParenthesisNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n class ParenthesisNode extends Node {\n /**\n * @constructor ParenthesisNode\n * @extends {Node}\n * A parenthesis node describes manual parenthesis from the user input\n * @param {Node} content\n * @extends {Node}\n */\n constructor(content) {\n super();\n // validate input\n if (!isNode(content)) {\n throw new TypeError('Node expected for parameter \"content\"');\n }\n this.content = content;\n }\n get type() {\n return name;\n }\n get isParenthesisNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n return this.content._compile(math, argNames);\n }\n\n /**\n * Get the content of the current Node.\n * @return {Node} content\n * @override\n **/\n getContent() {\n return this.content.getContent();\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.content, 'content', this);\n }\n\n /**\n * Create a new ParenthesisNode whose child is the result of calling\n * the provided callback function on the child of this node.\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {ParenthesisNode} Returns a clone of the node\n */\n map(callback) {\n var content = callback(this.content, 'content', this);\n return new ParenthesisNode(content);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {ParenthesisNode}\n */\n clone() {\n return new ParenthesisNode(this.content);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return '(' + this.content.toString(options) + ')';\n }\n return this.content.toString(options);\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n content: this.content\n };\n }\n\n /**\n * Instantiate an ParenthesisNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"ParenthesisNode\", \"content\": ...}`,\n * where mathjs is optional\n * @returns {ParenthesisNode}\n */\n static fromJSON(json) {\n return new ParenthesisNode(json.content);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return '(' + this.content.toHTML(options) + ')';\n }\n return this.content.toHTML(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toTex(options) {\n if (!options || options && !options.parenthesis || options && options.parenthesis === 'keep') {\n return \"\\\\left(\".concat(this.content.toTex(options), \"\\\\right)\");\n }\n return this.content.toTex(options);\n }\n }\n _defineProperty(ParenthesisNode, \"name\", name);\n return ParenthesisNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isNode, isSymbolNode } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { getPrecedence } from '../operators.js';\nvar name = 'RangeNode';\nvar dependencies = ['Node'];\nexport var createRangeNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n /**\n * Calculate the necessary parentheses\n * @param {Node} node\n * @param {string} parenthesis\n * @param {string} implicit\n * @return {Object} parentheses\n * @private\n */\n function calculateNecessaryParentheses(node, parenthesis, implicit) {\n var precedence = getPrecedence(node, parenthesis, implicit);\n var parens = {};\n var startPrecedence = getPrecedence(node.start, parenthesis, implicit);\n parens.start = startPrecedence !== null && startPrecedence <= precedence || parenthesis === 'all';\n if (node.step) {\n var stepPrecedence = getPrecedence(node.step, parenthesis, implicit);\n parens.step = stepPrecedence !== null && stepPrecedence <= precedence || parenthesis === 'all';\n }\n var endPrecedence = getPrecedence(node.end, parenthesis, implicit);\n parens.end = endPrecedence !== null && endPrecedence <= precedence || parenthesis === 'all';\n return parens;\n }\n class RangeNode extends Node {\n /**\n * @constructor RangeNode\n * @extends {Node}\n * create a range\n * @param {Node} start included lower-bound\n * @param {Node} end included upper-bound\n * @param {Node} [step] optional step\n */\n constructor(start, end, step) {\n super();\n // validate inputs\n if (!isNode(start)) throw new TypeError('Node expected');\n if (!isNode(end)) throw new TypeError('Node expected');\n if (step && !isNode(step)) throw new TypeError('Node expected');\n if (arguments.length > 3) throw new Error('Too many arguments');\n this.start = start; // included lower-bound\n this.end = end; // included upper-bound\n this.step = step || null; // optional step\n }\n get type() {\n return name;\n }\n get isRangeNode() {\n return true;\n }\n\n /**\n * Check whether the RangeNode needs the `end` symbol to be defined.\n * This end is the size of the Matrix in current dimension.\n * @return {boolean}\n */\n needsEnd() {\n // find all `end` symbols in this RangeNode\n var endSymbols = this.filter(function (node) {\n return isSymbolNode(node) && node.name === 'end';\n });\n return endSymbols.length > 0;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var range = math.range;\n var evalStart = this.start._compile(math, argNames);\n var evalEnd = this.end._compile(math, argNames);\n if (this.step) {\n var evalStep = this.step._compile(math, argNames);\n return function evalRangeNode(scope, args, context) {\n return range(evalStart(scope, args, context), evalEnd(scope, args, context), evalStep(scope, args, context));\n };\n } else {\n return function evalRangeNode(scope, args, context) {\n return range(evalStart(scope, args, context), evalEnd(scope, args, context));\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.start, 'start', this);\n callback(this.end, 'end', this);\n if (this.step) {\n callback(this.step, 'step', this);\n }\n }\n\n /**\n * Create a new RangeNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {RangeNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new RangeNode(this._ifNode(callback(this.start, 'start', this)), this._ifNode(callback(this.end, 'end', this)), this.step && this._ifNode(callback(this.step, 'step', this)));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {RangeNode}\n */\n clone() {\n return new RangeNode(this.start, this.end, this.step && this.step);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n\n // format string as start:step:stop\n var str;\n var start = this.start.toString(options);\n if (parens.start) {\n start = '(' + start + ')';\n }\n str = start;\n if (this.step) {\n var step = this.step.toString(options);\n if (parens.step) {\n step = '(' + step + ')';\n }\n str += ':' + step;\n }\n var end = this.end.toString(options);\n if (parens.end) {\n end = '(' + end + ')';\n }\n str += ':' + end;\n return str;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n start: this.start,\n end: this.end,\n step: this.step\n };\n }\n\n /**\n * Instantiate an RangeNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"RangeNode\", \"start\": ..., \"end\": ..., \"step\": ...}`,\n * where mathjs is optional\n * @returns {RangeNode}\n */\n static fromJSON(json) {\n return new RangeNode(json.start, json.end, json.step);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n\n // format string as start:step:stop\n var str;\n var start = this.start.toHTML(options);\n if (parens.start) {\n start = '(' + start + ')';\n }\n str = start;\n if (this.step) {\n var step = this.step.toHTML(options);\n if (parens.step) {\n step = '(' + step + ')';\n }\n str += ':' + step;\n }\n var end = this.end.toHTML(options);\n if (parens.end) {\n end = '(' + end + ')';\n }\n str += ':' + end;\n return str;\n }\n\n /**\n * Get LaTeX representation\n * @params {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var parens = calculateNecessaryParentheses(this, parenthesis, options && options.implicit);\n var str = this.start.toTex(options);\n if (parens.start) {\n str = \"\\\\left(\".concat(str, \"\\\\right)\");\n }\n if (this.step) {\n var step = this.step.toTex(options);\n if (parens.step) {\n step = \"\\\\left(\".concat(step, \"\\\\right)\");\n }\n str += ':' + step;\n }\n var end = this.end.toTex(options);\n if (parens.end) {\n end = \"\\\\left(\".concat(end, \"\\\\right)\");\n }\n str += ':' + end;\n return str;\n }\n }\n _defineProperty(RangeNode, \"name\", name);\n return RangeNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { getPrecedence } from '../operators.js';\nimport { escape } from '../../utils/string.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { latexOperators } from '../../utils/latex.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'RelationalNode';\nvar dependencies = ['Node'];\nexport var createRelationalNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n Node\n } = _ref;\n var operatorMap = {\n equal: '==',\n unequal: '!=',\n smaller: '<',\n larger: '>',\n smallerEq: '<=',\n largerEq: '>='\n };\n class RelationalNode extends Node {\n /**\n * A node representing a chained conditional expression, such as 'x > y > z'\n *\n * @param {String[]} conditionals\n * An array of conditional operators used to compare the parameters\n * @param {Node[]} params\n * The parameters that will be compared\n *\n * @constructor RelationalNode\n * @extends {Node}\n */\n constructor(conditionals, params) {\n super();\n if (!Array.isArray(conditionals)) {\n throw new TypeError('Parameter conditionals must be an array');\n }\n if (!Array.isArray(params)) {\n throw new TypeError('Parameter params must be an array');\n }\n if (conditionals.length !== params.length - 1) {\n throw new TypeError('Parameter params must contain exactly one more element ' + 'than parameter conditionals');\n }\n this.conditionals = conditionals;\n this.params = params;\n }\n get type() {\n return name;\n }\n get isRelationalNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var self = this;\n var compiled = this.params.map(p => p._compile(math, argNames));\n return function evalRelationalNode(scope, args, context) {\n var evalLhs;\n var evalRhs = compiled[0](scope, args, context);\n for (var i = 0; i < self.conditionals.length; i++) {\n evalLhs = evalRhs;\n evalRhs = compiled[i + 1](scope, args, context);\n var condFn = getSafeProperty(math, self.conditionals[i]);\n if (!condFn(evalLhs, evalRhs)) {\n return false;\n }\n }\n return true;\n };\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n this.params.forEach((n, i) => callback(n, 'params[' + i + ']', this), this);\n }\n\n /**\n * Create a new RelationalNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {RelationalNode} Returns a transformed copy of the node\n */\n map(callback) {\n return new RelationalNode(this.conditionals.slice(), this.params.map((n, i) => this._ifNode(callback(n, 'params[' + i + ']', this)), this));\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {RelationalNode}\n */\n clone() {\n return new RelationalNode(this.conditionals, this.params);\n }\n\n /**\n * Get string representation.\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '(' + p.toString(options) + ')' : p.toString(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += ' ' + operatorMap[this.conditionals[i]];\n ret += ' ' + paramStrings[i + 1];\n }\n return ret;\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n conditionals: this.conditionals,\n params: this.params\n };\n }\n\n /**\n * Instantiate a RelationalNode from its JSON representation\n * @param {Object} json\n * An object structured like\n * `{\"mathjs\": \"RelationalNode\", \"conditionals\": ..., \"params\": ...}`,\n * where mathjs is optional\n * @returns {RelationalNode}\n */\n static fromJSON(json) {\n return new RelationalNode(json.conditionals, json.params);\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '(' + p.toHTML(options) + ')' : p.toHTML(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += '' + escape(operatorMap[this.conditionals[i]]) + '' + paramStrings[i + 1];\n }\n return ret;\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var parenthesis = options && options.parenthesis ? options.parenthesis : 'keep';\n var precedence = getPrecedence(this, parenthesis, options && options.implicit);\n var paramStrings = this.params.map(function (p, index) {\n var paramPrecedence = getPrecedence(p, parenthesis, options && options.implicit);\n return parenthesis === 'all' || paramPrecedence !== null && paramPrecedence <= precedence ? '\\\\left(' + p.toTex(options) + '\\right)' : p.toTex(options);\n });\n var ret = paramStrings[0];\n for (var i = 0; i < this.conditionals.length; i++) {\n ret += latexOperators[this.conditionals[i]] + paramStrings[i + 1];\n }\n return ret;\n }\n }\n _defineProperty(RelationalNode, \"name\", name);\n return RelationalNode;\n}, {\n isClass: true,\n isNode: true\n});","import { escape } from '../../utils/string.js';\nimport { getSafeProperty } from '../../utils/customs.js';\nimport { factory } from '../../utils/factory.js';\nimport { toSymbol } from '../../utils/latex.js';\nvar name = 'SymbolNode';\nvar dependencies = ['math', '?Unit', 'Node'];\nexport var createSymbolNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n math,\n Unit,\n Node\n } = _ref;\n /**\n * Check whether some name is a valueless unit like \"inch\".\n * @param {string} name\n * @return {boolean}\n */\n function isValuelessUnit(name) {\n return Unit ? Unit.isValuelessUnit(name) : false;\n }\n class SymbolNode extends Node {\n /**\n * @constructor SymbolNode\n * @extends {Node}\n * A symbol node can hold and resolve a symbol\n * @param {string} name\n * @extends {Node}\n */\n constructor(name) {\n super();\n // validate input\n if (typeof name !== 'string') {\n throw new TypeError('String expected for parameter \"name\"');\n }\n this.name = name;\n }\n get type() {\n return 'SymbolNode';\n }\n get isSymbolNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n var name = this.name;\n if (argNames[name] === true) {\n // this is a FunctionAssignment argument\n // (like an x when inside the expression of a function\n // assignment `f(x) = ...`)\n return function (scope, args, context) {\n return getSafeProperty(args, name);\n };\n } else if (name in math) {\n return function (scope, args, context) {\n return scope.has(name) ? scope.get(name) : getSafeProperty(math, name);\n };\n } else {\n var isUnit = isValuelessUnit(name);\n return function (scope, args, context) {\n return scope.has(name) ? scope.get(name) : isUnit ? new Unit(null, name) : SymbolNode.onUndefinedSymbol(name);\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n // nothing to do, we don't have any children\n }\n\n /**\n * Create a new SymbolNode with children produced by the given callback.\n * Trivial since a SymbolNode has no children\n * @param {function(child: Node, path: string, parent: Node) : Node} callback\n * @returns {SymbolNode} Returns a clone of the node\n */\n map(callback) {\n return this.clone();\n }\n\n /**\n * Throws an error 'Undefined symbol {name}'\n * @param {string} name\n */\n static onUndefinedSymbol(name) {\n throw new Error('Undefined symbol ' + name);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {SymbolNode}\n */\n clone() {\n return new SymbolNode(this.name);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toString(options) {\n return this.name;\n }\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toHTML(options) {\n var name = escape(this.name);\n if (name === 'true' || name === 'false') {\n return '' + name + '';\n } else if (name === 'i') {\n return '' + name + '';\n } else if (name === 'Infinity') {\n return '' + name + '';\n } else if (name === 'NaN') {\n return '' + name + '';\n } else if (name === 'null') {\n return '' + name + '';\n } else if (name === 'undefined') {\n return '' + name + '';\n }\n return '' + name + '';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: 'SymbolNode',\n name: this.name\n };\n }\n\n /**\n * Instantiate a SymbolNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"SymbolNode\", name: \"x\"}`,\n * where mathjs is optional\n * @returns {SymbolNode}\n */\n static fromJSON(json) {\n return new SymbolNode(json.name);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n * @override\n */\n _toTex(options) {\n var isUnit = false;\n if (typeof math[this.name] === 'undefined' && isValuelessUnit(this.name)) {\n isUnit = true;\n }\n var symbol = toSymbol(this.name, isUnit);\n if (symbol[0] === '\\\\') {\n // no space needed if the symbol starts with '\\'\n return symbol;\n }\n // the space prevents symbols from breaking stuff like '\\cdot'\n // if it's written right before the symbol\n return ' ' + symbol;\n }\n }\n return SymbolNode;\n}, {\n isClass: true,\n isNode: true\n});","import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport { isAccessorNode, isFunctionAssignmentNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';\nimport { escape, format } from '../../utils/string.js';\nimport { hasOwnProperty } from '../../utils/object.js';\nimport { getSafeProperty, getSafeMethod } from '../../utils/customs.js';\nimport { createSubScope } from '../../utils/scope.js';\nimport { factory } from '../../utils/factory.js';\nimport { defaultTemplate, latexFunctions } from '../../utils/latex.js';\nvar name = 'FunctionNode';\nvar dependencies = ['math', 'Node', 'SymbolNode'];\nexport var createFunctionNode = /* #__PURE__ */factory(name, dependencies, _ref => {\n var _FunctionNode;\n var {\n math,\n Node,\n SymbolNode\n } = _ref;\n /* format to fixed length */\n var strin = entity => format(entity, {\n truncate: 78\n });\n\n /*\n * Expand a LaTeX template\n *\n * @param {string} template\n * @param {Node} node\n * @param {Object} options\n * @private\n **/\n function expandTemplate(template, node, options) {\n var latex = '';\n\n // Match everything of the form ${identifier} or ${identifier[2]} or $$\n // while submatching identifier and 2 (in the second case)\n var regex = /\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)/gi;\n var inputPos = 0; // position in the input string\n var match;\n while ((match = regex.exec(template)) !== null) {\n // go through all matches\n // add everything in front of the match to the LaTeX string\n latex += template.substring(inputPos, match.index);\n inputPos = match.index;\n if (match[0] === '$$') {\n // escaped dollar sign\n latex += '$';\n inputPos++;\n } else {\n // template parameter\n inputPos += match[0].length;\n var property = node[match[1]];\n if (!property) {\n throw new ReferenceError('Template: Property ' + match[1] + ' does not exist.');\n }\n if (match[2] === undefined) {\n // no square brackets\n switch (typeof property) {\n case 'string':\n latex += property;\n break;\n case 'object':\n if (isNode(property)) {\n latex += property.toTex(options);\n } else if (Array.isArray(property)) {\n // make array of Nodes into comma separated list\n latex += property.map(function (arg, index) {\n if (isNode(arg)) {\n return arg.toTex(options);\n }\n throw new TypeError('Template: ' + match[1] + '[' + index + '] is not a Node.');\n }).join(',');\n } else {\n throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes');\n }\n break;\n default:\n throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes');\n }\n } else {\n // with square brackets\n if (isNode(property[match[2]] && property[match[2]])) {\n latex += property[match[2]].toTex(options);\n } else {\n throw new TypeError('Template: ' + match[1] + '[' + match[2] + '] is not a Node.');\n }\n }\n }\n }\n latex += template.slice(inputPos); // append rest of the template\n\n return latex;\n }\n class FunctionNode extends Node {\n /**\n * @constructor FunctionNode\n * @extends {./Node}\n * invoke a list with arguments on a node\n * @param {./Node | string} fn\n * Item resolving to a function on which to invoke\n * the arguments, typically a SymbolNode or AccessorNode\n * @param {./Node[]} args\n */\n constructor(fn, args, optional) {\n super();\n if (typeof fn === 'string') {\n fn = new SymbolNode(fn);\n }\n\n // validate input\n if (!isNode(fn)) throw new TypeError('Node expected as parameter \"fn\"');\n if (!Array.isArray(args) || !args.every(isNode)) {\n throw new TypeError('Array containing Nodes expected for parameter \"args\"');\n }\n var optionalType = typeof optional;\n if (!(optionalType === 'undefined' || optionalType === 'boolean')) {\n throw new TypeError('optional flag, if specified, must be boolean');\n }\n this.fn = fn;\n this.args = args || [];\n this.optional = !!optional;\n }\n\n // readonly property name\n get name() {\n return this.fn.name || '';\n }\n get type() {\n return name;\n }\n get isFunctionNode() {\n return true;\n }\n\n /**\n * Compile a node into a JavaScript function.\n * This basically pre-calculates as much as possible and only leaves open\n * calculations which depend on a dynamic scope with variables.\n * @param {Object} math Math.js namespace with functions and constants.\n * @param {Object} argNames An object with argument names as key and `true`\n * as value. Used in the SymbolNode to optimize\n * for arguments from user assigned functions\n * (see FunctionAssignmentNode) or special symbols\n * like `end` (see IndexNode).\n * @return {function} Returns a function which can be called like:\n * evalNode(scope: Object, args: Object, context: *)\n */\n _compile(math, argNames) {\n // compile arguments\n var evalArgs = this.args.map(arg => arg._compile(math, argNames));\n var fromOptionalChaining = this.optional || isAccessorNode(this.fn) && this.fn.optionalChaining;\n if (isSymbolNode(this.fn)) {\n var _name = this.fn.name;\n if (!argNames[_name]) {\n // we can statically determine whether the function\n // has the rawArgs property\n var fn = _name in math ? getSafeProperty(math, _name) : undefined;\n var isRaw = typeof fn === 'function' && fn.rawArgs === true;\n var resolveFn = scope => {\n var value;\n if (scope.has(_name)) {\n value = scope.get(_name);\n } else if (_name in math) {\n value = getSafeProperty(math, _name);\n } else if (fromOptionalChaining) value = undefined;else return FunctionNode.onUndefinedFunction(_name);\n if (typeof value === 'function' || fromOptionalChaining && value === undefined) {\n return value;\n }\n throw new TypeError(\"'\".concat(_name, \"' is not a function; its value is:\\n \").concat(strin(value)));\n };\n if (isRaw) {\n // pass unevaluated parameters (nodes) to the function\n // \"raw\" evaluation\n var rawArgs = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n\n // the original function can be overwritten in the scope with a non-rawArgs function\n if (fn.rawArgs === true) {\n return fn(rawArgs, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn(...values);\n }\n };\n } else {\n // \"regular\" evaluation\n switch (evalArgs.length) {\n case 0:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n return fn();\n };\n case 1:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var evalArg0 = evalArgs[0];\n return fn(evalArg0(scope, args, context));\n };\n case 2:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var evalArg0 = evalArgs[0];\n var evalArg1 = evalArgs[1];\n return fn(evalArg0(scope, args, context), evalArg1(scope, args, context));\n };\n default:\n return function evalFunctionNode(scope, args, context) {\n var fn = resolveFn(scope);\n if (fromOptionalChaining && fn === undefined) return undefined;\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn(...values);\n };\n }\n }\n } else {\n // the function symbol is an argName\n var _rawArgs = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = getSafeProperty(args, _name);\n if (fromOptionalChaining && fn === undefined) return undefined;\n if (typeof fn !== 'function') {\n throw new TypeError(\"Argument '\".concat(_name, \"' was not a function; received: \").concat(strin(fn)));\n }\n if (fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs, math, createSubScope(scope, args));\n } else {\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(fn, values);\n }\n };\n }\n } else if (isAccessorNode(this.fn) && isIndexNode(this.fn.index) && this.fn.index.isObjectProperty()) {\n // execute the function with the right context:\n // the object of the AccessorNode\n\n var evalObject = this.fn.object._compile(math, argNames);\n var prop = this.fn.index.getObjectProperty();\n var _rawArgs2 = this.args;\n return function evalFunctionNode(scope, args, context) {\n var object = evalObject(scope, args, context);\n\n // Optional chaining: if the base object is nullish, short-circuit to undefined\n if (fromOptionalChaining && (object == null || object[prop] === undefined)) {\n return undefined;\n }\n var fn = getSafeMethod(object, prop);\n if (fn !== null && fn !== void 0 && fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs2, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(object, values);\n }\n };\n } else {\n // node.fn.isAccessorNode && !node.fn.index.isObjectProperty()\n // we have to dynamically determine whether the function has the\n // rawArgs property\n var fnExpr = this.fn.toString();\n var evalFn = this.fn._compile(math, argNames);\n var _rawArgs3 = this.args;\n return function evalFunctionNode(scope, args, context) {\n var fn = evalFn(scope, args, context);\n if (fromOptionalChaining && fn === undefined) return undefined;\n if (typeof fn !== 'function') {\n throw new TypeError(\"Expression '\".concat(fnExpr, \"' did not evaluate to a function; value is:\") + \"\\n \".concat(strin(fn)));\n }\n if (fn.rawArgs) {\n // \"Raw\" evaluation\n return fn(_rawArgs3, math, createSubScope(scope, args));\n } else {\n // \"regular\" evaluation\n var values = evalArgs.map(evalArg => evalArg(scope, args, context));\n return fn.apply(fn, values);\n }\n };\n }\n }\n\n /**\n * Execute a callback for each of the child nodes of this node\n * @param {function(child: Node, path: string, parent: Node)} callback\n */\n forEach(callback) {\n callback(this.fn, 'fn', this);\n for (var i = 0; i < this.args.length; i++) {\n callback(this.args[i], 'args[' + i + ']', this);\n }\n }\n\n /**\n * Create a new FunctionNode whose children are the results of calling\n * the provided callback function for each child of the original node.\n * @param {function(child: Node, path: string, parent: Node): Node} callback\n * @returns {FunctionNode} Returns a transformed copy of the node\n */\n map(callback) {\n var fn = this._ifNode(callback(this.fn, 'fn', this));\n var args = [];\n for (var i = 0; i < this.args.length; i++) {\n args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this));\n }\n return new FunctionNode(fn, args);\n }\n\n /**\n * Create a clone of this node, a shallow copy\n * @return {FunctionNode}\n */\n clone() {\n return new FunctionNode(this.fn, this.args.slice(0));\n }\n\n /**\n * Throws an error 'Undefined function {name}'\n * @param {string} name\n */\n\n /**\n * Get string representation. (wrapper function)\n * This overrides parts of Node's toString function.\n * If callback is an object containing callbacks, it\n * calls the correct callback for the current node,\n * otherwise it falls back to calling Node's toString\n * function.\n *\n * @param {Object} options\n * @return {string} str\n * @override\n */\n toString(options) {\n var customString;\n var name = this.fn.toString(options);\n if (options && typeof options.handler === 'object' && hasOwnProperty(options.handler, name)) {\n // callback is a map of callback functions\n customString = options.handler[name](this, options);\n }\n if (typeof customString !== 'undefined') {\n return customString;\n }\n\n // fall back to Node's toString\n return super.toString(options);\n }\n\n /**\n * Get string representation\n * @param {Object} options\n * @return {string} str\n */\n _toString(options) {\n var args = this.args.map(function (arg) {\n return arg.toString(options);\n });\n var fn = isFunctionAssignmentNode(this.fn) ? '(' + this.fn.toString(options) + ')' : this.fn.toString(options);\n\n // format the arguments like \"add(2, 4.2)\"\n return fn + '(' + args.join(', ') + ')';\n }\n\n /**\n * Get a JSON representation of the node\n * @returns {Object}\n */\n toJSON() {\n return {\n mathjs: name,\n fn: this.fn,\n args: this.args\n };\n }\n\n /**\n * Instantiate an AssignmentNode from its JSON representation\n * @param {Object} json An object structured like\n * `{\"mathjs\": \"FunctionNode\", fn: ..., args: ...}`,\n * where mathjs is optional\n * @returns {FunctionNode}\n */\n\n /**\n * Get HTML representation\n * @param {Object} options\n * @return {string} str\n */\n _toHTML(options) {\n var args = this.args.map(function (arg) {\n return arg.toHTML(options);\n });\n\n // format the arguments like \"add(2, 4.2)\"\n return '' + escape(this.fn) + '(' + args.join(',') + ')';\n }\n\n /**\n * Get LaTeX representation. (wrapper function)\n * This overrides parts of Node's toTex function.\n * If callback is an object containing callbacks, it\n * calls the correct callback for the current node,\n * otherwise it falls back to calling Node's toTex\n * function.\n *\n * @param {Object} options\n * @return {string}\n */\n toTex(options) {\n var customTex;\n if (options && typeof options.handler === 'object' && hasOwnProperty(options.handler, this.name)) {\n // callback is a map of callback functions\n customTex = options.handler[this.name](this, options);\n }\n if (typeof customTex !== 'undefined') {\n return customTex;\n }\n\n // fall back to Node's toTex\n return super.toTex(options);\n }\n\n /**\n * Get LaTeX representation\n * @param {Object} options\n * @return {string} str\n */\n _toTex(options) {\n var args = this.args.map(function (arg) {\n // get LaTeX of the arguments\n return arg.toTex(options);\n });\n var latexConverter;\n if (latexFunctions[this.name]) {\n latexConverter = latexFunctions[this.name];\n }\n\n // toTex property on the function itself\n if (math[this.name] && (typeof math[this.name].toTex === 'function' || typeof math[this.name].toTex === 'object' || typeof math[this.name].toTex === 'string')) {\n // .toTex is a callback function\n latexConverter = math[this.name].toTex;\n }\n var customToTex;\n switch (typeof latexConverter) {\n case 'function':\n // a callback function\n customToTex = latexConverter(this, options);\n break;\n case 'string':\n // a template string\n customToTex = expandTemplate(latexConverter, this, options);\n break;\n case 'object':\n // an object with different \"converters\" for different\n // numbers of arguments\n switch (typeof latexConverter[args.length]) {\n case 'function':\n customToTex = latexConverter[args.length](this, options);\n break;\n case 'string':\n customToTex = expandTemplate(latexConverter[args.length], this, options);\n break;\n }\n }\n if (typeof customToTex !== 'undefined') {\n return customToTex;\n }\n return expandTemplate(defaultTemplate, this, options);\n }\n\n /**\n * Get identifier.\n * @return {string}\n */\n getIdentifier() {\n return this.type + ':' + this.name;\n }\n }\n _FunctionNode = FunctionNode;\n _defineProperty(FunctionNode, \"name\", name);\n _defineProperty(FunctionNode, \"onUndefinedFunction\", function (name) {\n throw new Error('Undefined function ' + name);\n });\n _defineProperty(FunctionNode, \"fromJSON\", function (json) {\n return new _FunctionNode(json.fn, json.args);\n });\n return FunctionNode;\n}, {\n isClass: true,\n isNode: true\n});","import _extends from \"@babel/runtime/helpers/extends\";\nimport { factory } from '../utils/factory.js';\nimport { isAccessorNode, isConstantNode, isFunctionNode, isOperatorNode, isSymbolNode, rule2Node } from '../utils/is.js';\nimport { deepMap } from '../utils/collection.js';\nimport { safeNumberType } from '../utils/number.js';\nimport { hasOwnProperty } from '../utils/object.js';\nvar name = 'parse';\nvar dependencies = ['typed', 'numeric', 'config', 'AccessorNode', 'ArrayNode', 'AssignmentNode', 'BlockNode', 'ConditionalNode', 'ConstantNode', 'FunctionAssignmentNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'RangeNode', 'RelationalNode', 'SymbolNode'];\nexport var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n numeric,\n config,\n AccessorNode,\n ArrayNode,\n AssignmentNode,\n BlockNode,\n ConditionalNode,\n ConstantNode,\n FunctionAssignmentNode,\n FunctionNode,\n IndexNode,\n ObjectNode,\n OperatorNode,\n ParenthesisNode,\n RangeNode,\n RelationalNode,\n SymbolNode\n } = _ref;\n /**\n * Parse an expression. Returns a node tree, which can be evaluated by\n * invoking node.evaluate() or transformed into a functional object via node.compile().\n *\n * Note the evaluating arbitrary expressions may involve security risks,\n * see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.\n *\n * Syntax:\n *\n * math.parse(expr)\n * math.parse(expr, options)\n * math.parse([expr1, expr2, expr3, ...])\n * math.parse([expr1, expr2, expr3, ...], options)\n *\n * Example:\n *\n * const node1 = math.parse('sqrt(3^2 + 4^2)')\n * node1.compile().evaluate() // 5\n *\n * let scope = {a:3, b:4}\n * const node2 = math.parse('a * b')\n * node2.evaluate(scope) // 12\n * const code2 = node2.compile()\n * code2.evaluate(scope) // 12\n * scope.a = 5\n * code2.evaluate(scope) // 20\n *\n * const nodes = math.parse(['a = 3', 'b = 4', 'a * b'])\n * nodes[2].compile().evaluate() // 12\n *\n * See also:\n *\n * evaluate, compile\n *\n * History:\n *\n * v0.9 Created\n * v0.13 Switched to one-based indices\n * v0.14 Added `[1,2;3,4]` notation for matrices\n * v0.18 Dropped the `function` keyword\n * v0.20 Added ternary conditional\n * v0.27 Allow multi-line expressions; allow functions that receive\n * unevaluated parameters (`rawArgs`)\n * v3 Add object notation; allow assignments internal to other\n * expressions\n * v7.3 Supported binary, octal, and hexadecimal notation\n * v9.5 Support for calculations with percentages\n * v12.4 Allow trailing commas in matrices\n * v14.8 Add nullish coalescing operator\n * v15.1 Add optional chaining operator\n *\n * @param {string | string[] | Matrix} expr Expression to be parsed\n * @param {{nodes: Object}} [options] Available options:\n * - `nodes` a set of custom nodes\n * @return {Node | Node[]} node\n * @throws {Error}\n */\n var parse = typed(name, {\n string: function string(expression) {\n return parseStart(expression, {});\n },\n 'Array | Matrix': function Array__Matrix(expressions) {\n return parseMultiple(expressions, {});\n },\n 'string, Object': function string_Object(expression, options) {\n var extraNodes = options.nodes !== undefined ? options.nodes : {};\n return parseStart(expression, extraNodes);\n },\n 'Array | Matrix, Object': parseMultiple\n });\n function parseMultiple(expressions) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var extraNodes = options.nodes !== undefined ? options.nodes : {};\n\n // parse an array or matrix with expressions\n return deepMap(expressions, function (elem) {\n if (typeof elem !== 'string') throw new TypeError('String expected');\n return parseStart(elem, extraNodes);\n });\n }\n\n // token types enumeration\n var TOKENTYPE = {\n NULL: 0,\n DELIMITER: 1,\n NUMBER: 2,\n SYMBOL: 3,\n UNKNOWN: 4\n };\n\n // map with all delimiters\n var DELIMITERS = {\n ',': true,\n '(': true,\n ')': true,\n '[': true,\n ']': true,\n '{': true,\n '}': true,\n '\"': true,\n '\\'': true,\n ';': true,\n '+': true,\n '-': true,\n '*': true,\n '.*': true,\n '/': true,\n './': true,\n '%': true,\n '^': true,\n '.^': true,\n '~': true,\n '!': true,\n '&': true,\n '|': true,\n '^|': true,\n '=': true,\n ':': true,\n '?': true,\n '?.': true,\n '??': true,\n '==': true,\n '!=': true,\n '<': true,\n '>': true,\n '<=': true,\n '>=': true,\n '<<': true,\n '>>': true,\n '>>>': true\n };\n\n // map with all named delimiters\n var NAMED_DELIMITERS = {\n mod: true,\n to: true,\n in: true,\n and: true,\n xor: true,\n or: true,\n not: true\n };\n var CONSTANTS = {\n true: true,\n false: false,\n null: null,\n undefined\n };\n var NUMERIC_CONSTANTS = ['NaN', 'Infinity'];\n var ESCAPE_CHARACTERS = {\n '\"': '\"',\n \"'\": \"'\",\n '\\\\': '\\\\',\n '/': '/',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t'\n // note that \\u is handled separately in parseStringToken()\n };\n function initialState() {\n return {\n extraNodes: {},\n // current extra nodes, must be careful not to mutate\n expression: '',\n // current expression\n comment: '',\n // last parsed comment\n index: 0,\n // current index in expr\n token: '',\n // current token\n tokenType: TOKENTYPE.NULL,\n // type of the token\n nestingLevel: 0,\n // level of nesting inside parameters, used to ignore newline characters\n conditionalLevel: null // when a conditional is being parsed, the level of the conditional is stored here\n };\n }\n\n /**\n * View upto `length` characters of the expression starting at the current character.\n *\n * @param {Object} state\n * @param {number} [length=1] Number of characters to view\n * @returns {string}\n * @private\n */\n function currentString(state, length) {\n return state.expression.substr(state.index, length);\n }\n\n /**\n * View the current character. Returns '' if end of expression is reached.\n *\n * @param {Object} state\n * @returns {string}\n * @private\n */\n function currentCharacter(state) {\n return currentString(state, 1);\n }\n\n /**\n * Get the next character from the expression.\n * The character is stored into the char c. If the end of the expression is\n * reached, the function puts an empty string in c.\n * @private\n */\n function next(state) {\n state.index++;\n }\n\n /**\n * Preview the previous character from the expression.\n * @return {string} cNext\n * @private\n */\n function prevCharacter(state) {\n return state.expression.charAt(state.index - 1);\n }\n\n /**\n * Preview the next character from the expression.\n * @return {string} cNext\n * @private\n */\n function nextCharacter(state) {\n return state.expression.charAt(state.index + 1);\n }\n\n /**\n * Get next token in the current string expr.\n * The token and token type are available as token and tokenType\n * @private\n */\n function getToken(state) {\n state.tokenType = TOKENTYPE.NULL;\n state.token = '';\n state.comment = '';\n\n // skip over ignored characters:\n while (true) {\n // comments:\n if (currentCharacter(state) === '#') {\n while (currentCharacter(state) !== '\\n' && currentCharacter(state) !== '') {\n state.comment += currentCharacter(state);\n next(state);\n }\n }\n // whitespace: space, tab, and newline when inside parameters\n if (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {\n next(state);\n } else {\n break;\n }\n }\n\n // check for end of expression\n if (currentCharacter(state) === '') {\n // token is still empty\n state.tokenType = TOKENTYPE.DELIMITER;\n return;\n }\n\n // check for new line character\n if (currentCharacter(state) === '\\n' && !state.nestingLevel) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = currentCharacter(state);\n next(state);\n return;\n }\n var c1 = currentCharacter(state);\n var c2 = currentString(state, 2);\n var c3 = currentString(state, 3);\n if (c3.length === 3 && DELIMITERS[c3]) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c3;\n next(state);\n next(state);\n next(state);\n return;\n }\n\n // check for delimiters consisting of 2 characters\n // Special case: the check for '?.' is to prevent a case like 'a?.3:.7' from being interpreted as optional chaining\n // TODO: refactor the tokenization into some better way to deal with cases like 'a?.3:.7', see https://github.com/josdejong/mathjs/pull/3584\n if (c2.length === 2 && DELIMITERS[c2] && (c2 !== '?.' || !parse.isDigit(state.expression.charAt(state.index + 2)))) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c2;\n next(state);\n next(state);\n return;\n }\n\n // check for delimiters consisting of 1 character\n if (DELIMITERS[c1]) {\n state.tokenType = TOKENTYPE.DELIMITER;\n state.token = c1;\n next(state);\n return;\n }\n\n // check for a number\n if (parse.isDigitDot(c1)) {\n state.tokenType = TOKENTYPE.NUMBER;\n\n // check for binary, octal, or hex\n var _c = currentString(state, 2);\n if (_c === '0b' || _c === '0o' || _c === '0x') {\n state.token += currentCharacter(state);\n next(state);\n state.token += currentCharacter(state);\n next(state);\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (currentCharacter(state) === '.') {\n // this number has a radix point\n state.token += '.';\n next(state);\n // get the digits after the radix\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n } else if (currentCharacter(state) === 'i') {\n // this number has a word size suffix\n state.token += 'i';\n next(state);\n // get the word size\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n }\n return;\n }\n\n // get number, can have a single dot\n if (currentCharacter(state) === '.') {\n state.token += currentCharacter(state);\n next(state);\n if (!parse.isDigit(currentCharacter(state))) {\n // this is no number, it is just a dot (can be dot notation)\n state.tokenType = TOKENTYPE.DELIMITER;\n return;\n }\n } else {\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (parse.isDecimalMark(currentCharacter(state), nextCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n }\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n // check for exponential notation like \"2.3e-4\", \"1.23e50\" or \"2e+4\"\n if (currentCharacter(state) === 'E' || currentCharacter(state) === 'e') {\n if (parse.isDigit(nextCharacter(state)) || nextCharacter(state) === '-' || nextCharacter(state) === '+') {\n state.token += currentCharacter(state);\n next(state);\n if (currentCharacter(state) === '+' || currentCharacter(state) === '-') {\n state.token += currentCharacter(state);\n next(state);\n }\n // Scientific notation MUST be followed by an exponent\n if (!parse.isDigit(currentCharacter(state))) {\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n while (parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (parse.isDecimalMark(currentCharacter(state), nextCharacter(state))) {\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n } else if (parse.isDecimalMark(nextCharacter(state), state.expression.charAt(state.index + 2))) {\n next(state);\n throw createSyntaxError(state, 'Digit expected, got \"' + currentCharacter(state) + '\"');\n }\n }\n return;\n }\n\n // check for variables, functions, named operators\n if (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state))) {\n while (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state)) || parse.isDigit(currentCharacter(state))) {\n state.token += currentCharacter(state);\n next(state);\n }\n if (hasOwnProperty(NAMED_DELIMITERS, state.token)) {\n state.tokenType = TOKENTYPE.DELIMITER;\n } else {\n state.tokenType = TOKENTYPE.SYMBOL;\n }\n return;\n }\n\n // something unknown is found, wrong characters -> a syntax error\n state.tokenType = TOKENTYPE.UNKNOWN;\n while (currentCharacter(state) !== '') {\n state.token += currentCharacter(state);\n next(state);\n }\n throw createSyntaxError(state, 'Syntax error in part \"' + state.token + '\"');\n }\n\n /**\n * Get next token and skip newline tokens\n */\n function getTokenSkipNewline(state) {\n do {\n getToken(state);\n } while (state.token === '\\n'); // eslint-disable-line no-unmodified-loop-condition\n }\n\n /**\n * Open parameters.\n * New line characters will be ignored until closeParams(state) is called\n */\n function openParams(state) {\n state.nestingLevel++;\n }\n\n /**\n * Close parameters.\n * New line characters will no longer be ignored\n */\n function closeParams(state) {\n state.nestingLevel--;\n }\n\n /**\n * Checks whether the current character `c` is a valid alpha character:\n *\n * - A latin letter (upper or lower case) Ascii: a-z, A-Z\n * - An underscore Ascii: _\n * - A dollar sign Ascii: $\n * - A latin letter with accents Unicode: \\u00C0 - \\u02AF\n * - A greek letter Unicode: \\u0370 - \\u03FF\n * - A mathematical alphanumeric symbol Unicode: \\u{1D400} - \\u{1D7FF} excluding invalid code points\n *\n * The previous and next characters are needed to determine whether\n * this character is part of a unicode surrogate pair.\n *\n * @param {string} c Current character in the expression\n * @param {string} cPrev Previous character\n * @param {string} cNext Next character\n * @return {boolean}\n */\n parse.isAlpha = function isAlpha(c, cPrev, cNext) {\n return parse.isValidLatinOrGreek(c) || parse.isValidMathSymbol(c, cNext) || parse.isValidMathSymbol(cPrev, c);\n };\n\n /**\n * Test whether a character is a valid latin, greek, or letter-like character\n * @param {string} c\n * @return {boolean}\n */\n parse.isValidLatinOrGreek = function isValidLatinOrGreek(c) {\n return /^[a-zA-Z_$\\u00C0-\\u02AF\\u0370-\\u03FF\\u2100-\\u214F]$/.test(c);\n };\n\n /**\n * Test whether two given 16 bit characters form a surrogate pair of a\n * unicode math symbol.\n *\n * https://unicode-table.com/en/\n * https://www.wikiwand.com/en/Mathematical_operators_and_symbols_in_Unicode\n *\n * Note: In ES6 will be unicode aware:\n * https://stackoverflow.com/questions/280712/javascript-unicode-regexes\n * https://mathiasbynens.be/notes/es6-unicode-regex\n *\n * @param {string} high\n * @param {string} low\n * @return {boolean}\n */\n parse.isValidMathSymbol = function isValidMathSymbol(high, low) {\n return /^[\\uD835]$/.test(high) && /^[\\uDC00-\\uDFFF]$/.test(low) && /^[^\\uDC55\\uDC9D\\uDCA0\\uDCA1\\uDCA3\\uDCA4\\uDCA7\\uDCA8\\uDCAD\\uDCBA\\uDCBC\\uDCC4\\uDD06\\uDD0B\\uDD0C\\uDD15\\uDD1D\\uDD3A\\uDD3F\\uDD45\\uDD47-\\uDD49\\uDD51\\uDEA6\\uDEA7\\uDFCC\\uDFCD]$/.test(low);\n };\n\n /**\n * Check whether given character c is a white space character: space, tab, or enter\n * @param {string} c\n * @param {number} nestingLevel\n * @return {boolean}\n */\n parse.isWhitespace = function isWhitespace(c, nestingLevel) {\n // TODO: also take '\\r' carriage return as newline? Or does that give problems on mac?\n return c === ' ' || c === '\\t' || c === '\\u00A0' || c === '\\n' && nestingLevel > 0;\n };\n\n /**\n * Test whether the character c is a decimal mark (dot).\n * This is the case when it's not the start of a delimiter '.*', './', or '.^'\n * @param {string} c\n * @param {string} cNext\n * @return {boolean}\n */\n parse.isDecimalMark = function isDecimalMark(c, cNext) {\n return c === '.' && cNext !== '/' && cNext !== '*' && cNext !== '^';\n };\n\n /**\n * checks if the given char c is a digit or dot\n * @param {string} c a string with one character\n * @return {boolean}\n */\n parse.isDigitDot = function isDigitDot(c) {\n return c >= '0' && c <= '9' || c === '.';\n };\n\n /**\n * checks if the given char c is a digit\n * @param {string} c a string with one character\n * @return {boolean}\n */\n parse.isDigit = function isDigit(c) {\n return c >= '0' && c <= '9';\n };\n\n /**\n * Start of the parse levels below, in order of precedence\n * @return {Node} node\n * @private\n */\n function parseStart(expression, extraNodes) {\n var state = initialState();\n _extends(state, {\n expression,\n extraNodes\n });\n getToken(state);\n var node = parseBlock(state);\n\n // check for garbage at the end of the expression\n // an expression ends with a empty character '' and tokenType DELIMITER\n if (state.token !== '') {\n if (state.tokenType === TOKENTYPE.DELIMITER) {\n // user entered a not existing operator like \"//\"\n\n // TODO: give hints for aliases, for example with \"<>\" give as hint \" did you mean !== ?\"\n throw createError(state, 'Unexpected operator ' + state.token);\n } else {\n throw createSyntaxError(state, 'Unexpected part \"' + state.token + '\"');\n }\n }\n return node;\n }\n\n /**\n * Parse a block with expressions. Expressions can be separated by a newline\n * character '\\n', or by a semicolon ';'. In case of a semicolon, no output\n * of the preceding line is returned.\n * @return {Node} node\n * @private\n */\n function parseBlock(state) {\n var node;\n var blocks = [];\n var visible;\n if (state.token !== '' && state.token !== '\\n' && state.token !== ';') {\n node = parseAssignment(state);\n if (state.comment) {\n node.comment = state.comment;\n }\n }\n\n // TODO: simplify this loop\n while (state.token === '\\n' || state.token === ';') {\n // eslint-disable-line no-unmodified-loop-condition\n if (blocks.length === 0 && node) {\n visible = state.token !== ';';\n blocks.push({\n node,\n visible\n });\n }\n getToken(state);\n if (state.token !== '\\n' && state.token !== ';' && state.token !== '') {\n node = parseAssignment(state);\n if (state.comment) {\n node.comment = state.comment;\n }\n visible = state.token !== ';';\n blocks.push({\n node,\n visible\n });\n }\n }\n if (blocks.length > 0) {\n return new BlockNode(blocks);\n } else {\n if (!node) {\n node = new ConstantNode(undefined);\n if (state.comment) {\n node.comment = state.comment;\n }\n }\n return node;\n }\n }\n\n /**\n * Assignment of a function or variable,\n * - can be a variable like 'a=2.3'\n * - or a updating an existing variable like 'matrix(2,3:5)=[6,7,8]'\n * - defining a function like 'f(x) = x^2'\n * @return {Node} node\n * @private\n */\n function parseAssignment(state) {\n var name, args, value, valid;\n var node = parseConditional(state);\n if (state.token === '=') {\n if (isSymbolNode(node)) {\n // parse a variable assignment like 'a = 2/3'\n name = node.name;\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new AssignmentNode(new SymbolNode(name), value);\n } else if (isAccessorNode(node)) {\n // parse a matrix subset assignment like 'A[1,2] = 4'\n if (node.optionalChaining) {\n throw createSyntaxError(state, 'Cannot assign to optional chain');\n }\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new AssignmentNode(node.object, node.index, value);\n } else if (isFunctionNode(node) && isSymbolNode(node.fn)) {\n // parse function assignment like 'f(x) = x^2'\n valid = true;\n args = [];\n name = node.name;\n node.args.forEach(function (arg, index) {\n if (isSymbolNode(arg)) {\n args[index] = arg.name;\n } else {\n valid = false;\n }\n });\n if (valid) {\n getTokenSkipNewline(state);\n value = parseAssignment(state);\n return new FunctionAssignmentNode(name, args, value);\n }\n }\n throw createSyntaxError(state, 'Invalid left hand side of assignment operator =');\n }\n return node;\n }\n\n /**\n * conditional operation\n *\n * condition ? truePart : falsePart\n *\n * Note: conditional operator is right-associative\n *\n * @return {Node} node\n * @private\n */\n function parseConditional(state) {\n var node = parseLogicalOr(state);\n while (state.token === '?') {\n // eslint-disable-line no-unmodified-loop-condition\n // set a conditional level, the range operator will be ignored as long\n // as conditionalLevel === state.nestingLevel.\n var prev = state.conditionalLevel;\n state.conditionalLevel = state.nestingLevel;\n getTokenSkipNewline(state);\n var condition = node;\n var trueExpr = parseAssignment(state);\n if (state.token !== ':') throw createSyntaxError(state, 'False part of conditional expression expected');\n state.conditionalLevel = null;\n getTokenSkipNewline(state);\n var falseExpr = parseAssignment(state); // Note: check for conditional operator again, right associativity\n\n node = new ConditionalNode(condition, trueExpr, falseExpr);\n\n // restore the previous conditional level\n state.conditionalLevel = prev;\n }\n return node;\n }\n\n /**\n * logical or, 'x or y'\n * @return {Node} node\n * @private\n */\n function parseLogicalOr(state) {\n var node = parseLogicalXor(state);\n while (state.token === 'or') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('or', 'or', [node, parseLogicalXor(state)]);\n }\n return node;\n }\n\n /**\n * logical exclusive or, 'x xor y'\n * @return {Node} node\n * @private\n */\n function parseLogicalXor(state) {\n var node = parseLogicalAnd(state);\n while (state.token === 'xor') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd(state)]);\n }\n return node;\n }\n\n /**\n * logical and, 'x and y'\n * @return {Node} node\n * @private\n */\n function parseLogicalAnd(state) {\n var node = parseBitwiseOr(state);\n while (state.token === 'and') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('and', 'and', [node, parseBitwiseOr(state)]);\n }\n return node;\n }\n\n /**\n * bitwise or, 'x | y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseOr(state) {\n var node = parseBitwiseXor(state);\n while (state.token === '|') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor(state)]);\n }\n return node;\n }\n\n /**\n * bitwise exclusive or (xor), 'x ^| y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseXor(state) {\n var node = parseBitwiseAnd(state);\n while (state.token === '^|') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd(state)]);\n }\n return node;\n }\n\n /**\n * bitwise and, 'x & y'\n * @return {Node} node\n * @private\n */\n function parseBitwiseAnd(state) {\n var node = parseRelational(state);\n while (state.token === '&') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('&', 'bitAnd', [node, parseRelational(state)]);\n }\n return node;\n }\n\n /**\n * Parse a chained conditional, like 'a > b >= c'\n * @return {Node} node\n */\n function parseRelational(state) {\n var params = [parseShift(state)];\n var conditionals = [];\n var operators = {\n '==': 'equal',\n '!=': 'unequal',\n '<': 'smaller',\n '>': 'larger',\n '<=': 'smallerEq',\n '>=': 'largerEq'\n };\n while (hasOwnProperty(operators, state.token)) {\n // eslint-disable-line no-unmodified-loop-condition\n var cond = {\n name: state.token,\n fn: operators[state.token]\n };\n conditionals.push(cond);\n getTokenSkipNewline(state);\n params.push(parseShift(state));\n }\n if (params.length === 1) {\n return params[0];\n } else if (params.length === 2) {\n return new OperatorNode(conditionals[0].name, conditionals[0].fn, params);\n } else {\n return new RelationalNode(conditionals.map(c => c.fn), params);\n }\n }\n\n /**\n * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift\n * @return {Node} node\n * @private\n */\n function parseShift(state) {\n var node, name, fn, params;\n node = parseConversion(state);\n var operators = {\n '<<': 'leftShift',\n '>>': 'rightArithShift',\n '>>>': 'rightLogShift'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n params = [node, parseConversion(state)];\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * conversion operators 'to' and 'in'\n * @return {Node} node\n * @private\n */\n function parseConversion(state) {\n var node, name, fn, params;\n node = parseRange(state);\n var operators = {\n to: 'to',\n in: 'to' // alias of 'to'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n if (name === 'in' && '])},;'.includes(state.token)) {\n // end of expression -> this is the unit 'in' ('inch')\n node = new OperatorNode('*', 'multiply', [node, new SymbolNode('in')], true);\n } else {\n // operator 'a to b' or 'a in b'\n params = [node, parseRange(state)];\n node = new OperatorNode(name, fn, params);\n }\n }\n return node;\n }\n\n /**\n * parse range, \"start:end\", \"start:step:end\", \":\", \"start:\", \":end\", etc\n * @return {Node} node\n * @private\n */\n function parseRange(state) {\n var node;\n var params = [];\n if (state.token === ':') {\n if (state.conditionalLevel === state.nestingLevel) {\n // we are in the midst of parsing a conditional operator, so not\n // a range, but rather an empty true-expr, which is considered a\n // syntax error\n throw createSyntaxError(state, 'The true-expression of a conditional operator may not be empty');\n } else {\n // implicit start of range = 1 (one-based)\n node = new ConstantNode(1);\n }\n } else {\n // explicit start\n node = parseAddSubtract(state);\n }\n if (state.token === ':' && state.conditionalLevel !== state.nestingLevel) {\n // we ignore the range operator when a conditional operator is being processed on the same level\n params.push(node);\n\n // parse step and end\n while (state.token === ':' && params.length < 3) {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n if (state.token === ')' || state.token === ']' || state.token === ',' || state.token === '') {\n // implicit end\n params.push(new SymbolNode('end'));\n } else {\n // explicit end\n params.push(parseAddSubtract(state));\n }\n }\n if (params.length === 3) {\n // params = [start, step, end]\n node = new RangeNode(params[0], params[2], params[1]); // start, end, step\n } else {\n // length === 2\n // params = [start, end]\n node = new RangeNode(params[0], params[1]); // start, end\n }\n }\n return node;\n }\n\n /**\n * add or subtract\n * @return {Node} node\n * @private\n */\n function parseAddSubtract(state) {\n var node, name, fn, params;\n node = parseMultiplyDivideModulus(state);\n var operators = {\n '+': 'add',\n '-': 'subtract'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n var rightNode = parseMultiplyDivideModulus(state);\n if (rightNode.isPercentage) {\n params = [node, new OperatorNode('*', 'multiply', [node, rightNode])];\n } else {\n params = [node, rightNode];\n }\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * multiply, divide, modulus\n * @return {Node} node\n * @private\n */\n function parseMultiplyDivideModulus(state) {\n var node, last, name, fn;\n node = parseImplicitMultiplication(state);\n last = node;\n var operators = {\n '*': 'multiply',\n '.*': 'dotMultiply',\n '/': 'divide',\n './': 'dotDivide',\n '%': 'mod',\n mod: 'mod'\n };\n while (true) {\n if (hasOwnProperty(operators, state.token)) {\n // explicit operators\n name = state.token;\n fn = operators[name];\n getTokenSkipNewline(state);\n last = parseImplicitMultiplication(state);\n node = new OperatorNode(name, fn, [node, last]);\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * implicit multiplication\n * @return {Node} node\n * @private\n */\n function parseImplicitMultiplication(state) {\n var node, last;\n node = parseRule2(state);\n last = node;\n while (true) {\n if (state.tokenType === TOKENTYPE.SYMBOL || state.token === 'in' && isConstantNode(node) || state.token === 'in' && isOperatorNode(node) && node.fn === 'unaryMinus' && isConstantNode(node.args[0]) || state.tokenType === TOKENTYPE.NUMBER && !isConstantNode(last) && (!isOperatorNode(last) || last.op === '!') || state.token === '(') {\n // parse implicit multiplication\n //\n // symbol: implicit multiplication like '2a', '(2+3)a', 'a b'\n // number: implicit multiplication like '(2+3)2'\n // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)'\n last = parseRule2(state);\n node = new OperatorNode('*', 'multiply', [node, last], true /* implicit */);\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * Infamous \"rule 2\" as described in https://github.com/josdejong/mathjs/issues/792#issuecomment-361065370\n * And as amended in https://github.com/josdejong/mathjs/issues/2370#issuecomment-1054052164\n * Explicit division gets higher precedence than implicit multiplication\n * when the division matches this pattern:\n * [unaryPrefixOp]?[number] / [number] [symbol]\n * @return {Node} node\n * @private\n */\n function parseRule2(state) {\n var node = parseUnaryPercentage(state);\n var last = node;\n var tokenStates = [];\n while (true) {\n // Match the \"number /\" part of the pattern \"number / number symbol\"\n if (state.token === '/' && rule2Node(last)) {\n // Look ahead to see if the next token is a number\n tokenStates.push(_extends({}, state));\n getTokenSkipNewline(state);\n\n // Match the \"number / number\" part of the pattern\n if (state.tokenType === TOKENTYPE.NUMBER) {\n // Look ahead again\n tokenStates.push(_extends({}, state));\n getTokenSkipNewline(state);\n\n // Match the \"symbol\" part of the pattern, or a left parenthesis\n if (state.tokenType === TOKENTYPE.SYMBOL || state.token === '(' || state.token === 'in') {\n // We've matched the pattern \"number / number symbol\".\n // Rewind once and build the \"number / number\" node; the symbol will be consumed later\n _extends(state, tokenStates.pop());\n tokenStates.pop();\n last = parseUnaryPercentage(state);\n node = new OperatorNode('/', 'divide', [node, last]);\n } else {\n // Not a match, so rewind\n tokenStates.pop();\n _extends(state, tokenStates.pop());\n break;\n }\n } else {\n // Not a match, so rewind\n _extends(state, tokenStates.pop());\n break;\n }\n } else {\n break;\n }\n }\n return node;\n }\n\n /**\n * Unary percentage operator (treated as `value / 100`)\n * @return {Node} node\n * @private\n */\n function parseUnaryPercentage(state) {\n var node = parseUnary(state);\n if (state.token === '%') {\n var previousState = _extends({}, state);\n getTokenSkipNewline(state);\n // We need to decide if this is a unary percentage % or binary modulo %\n // So we attempt to parse a unary expression at this point.\n // If it fails, then the only possibility is that this is a unary percentage.\n // If it succeeds, then we presume that this must be binary modulo, since the\n // only things that parseUnary can handle are _higher_ precedence than unary %.\n try {\n parseUnary(state);\n // Not sure if we could somehow use the result of that parseUnary? Without\n // further analysis/testing, safer just to discard and let the parse proceed\n _extends(state, previousState);\n } catch (_unused) {\n // Not seeing a term at this point, so was a unary %\n node = new OperatorNode('/', 'divide', [node, new ConstantNode(100)], false, true);\n }\n }\n return node;\n }\n\n /**\n * Unary plus and minus, and logical and bitwise not\n * @return {Node} node\n * @private\n */\n function parseUnary(state) {\n var name, params, fn;\n var operators = {\n '-': 'unaryMinus',\n '+': 'unaryPlus',\n '~': 'bitNot',\n not: 'not'\n };\n if (hasOwnProperty(operators, state.token)) {\n fn = operators[state.token];\n name = state.token;\n getTokenSkipNewline(state);\n params = [parseUnary(state)];\n return new OperatorNode(name, fn, params);\n }\n return parsePow(state);\n }\n\n /**\n * power\n * Note: power operator is right associative\n * @return {Node} node\n * @private\n */\n function parsePow(state) {\n var node, name, fn, params;\n node = parseNullishCoalescing(state);\n if (state.token === '^' || state.token === '.^') {\n name = state.token;\n fn = name === '^' ? 'pow' : 'dotPow';\n getTokenSkipNewline(state);\n params = [node, parseUnary(state)]; // Go back to unary, we can have '2^-3'\n node = new OperatorNode(name, fn, params);\n }\n return node;\n }\n\n /**\n * nullish coalescing operator\n * @return {Node} node\n * @private\n */\n function parseNullishCoalescing(state) {\n var node = parseLeftHandOperators(state);\n while (state.token === '??') {\n // eslint-disable-line no-unmodified-loop-condition\n getTokenSkipNewline(state);\n node = new OperatorNode('??', 'nullish', [node, parseLeftHandOperators(state)]);\n }\n return node;\n }\n\n /**\n * Left hand operators: factorial x!, ctranspose x'\n * @return {Node} node\n * @private\n */\n function parseLeftHandOperators(state) {\n var node, name, fn, params;\n node = parseCustomNodes(state);\n var operators = {\n '!': 'factorial',\n '\\'': 'ctranspose'\n };\n while (hasOwnProperty(operators, state.token)) {\n name = state.token;\n fn = operators[name];\n getToken(state);\n params = [node];\n node = new OperatorNode(name, fn, params);\n node = parseAccessors(state, node);\n }\n return node;\n }\n\n /**\n * Parse a custom node handler. A node handler can be used to process\n * nodes in a custom way, for example for handling a plot.\n *\n * A handler must be passed as second argument of the parse function.\n * - must extend math.Node\n * - must contain a function _compile(defs: Object) : string\n * - must contain a function find(filter: Object) : Node[]\n * - must contain a function toString() : string\n * - the constructor is called with a single argument containing all parameters\n *\n * For example:\n *\n * nodes = {\n * 'plot': PlotHandler\n * }\n *\n * The constructor of the handler is called as:\n *\n * node = new PlotHandler(params)\n *\n * The handler will be invoked when evaluating an expression like:\n *\n * node = math.parse('plot(sin(x), x)', nodes)\n *\n * @return {Node} node\n * @private\n */\n function parseCustomNodes(state) {\n var params = [];\n if (state.tokenType === TOKENTYPE.SYMBOL && hasOwnProperty(state.extraNodes, state.token)) {\n var CustomNode = state.extraNodes[state.token];\n getToken(state);\n\n // parse parameters\n if (state.token === '(') {\n params = [];\n openParams(state);\n getToken(state);\n if (state.token !== ')') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n }\n\n // create a new custom node\n // noinspection JSValidateTypes\n return new CustomNode(params);\n }\n return parseSymbol(state);\n }\n\n /**\n * parse symbols: functions, variables, constants, units\n * @return {Node} node\n * @private\n */\n function parseSymbol(state) {\n var node, name;\n if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {\n name = state.token;\n getToken(state);\n if (hasOwnProperty(CONSTANTS, name)) {\n // true, false, null, ...\n node = new ConstantNode(CONSTANTS[name]);\n } else if (NUMERIC_CONSTANTS.includes(name)) {\n // NaN, Infinity\n node = new ConstantNode(numeric(name, 'number'));\n } else {\n node = new SymbolNode(name);\n }\n\n // parse function parameters and matrix index\n node = parseAccessors(state, node);\n return node;\n }\n return parseString(state);\n }\n\n /**\n * parse accessors:\n * - function invocation in round brackets (...), for example sqrt(2) or sqrt?.(2) with optional chaining\n * - index enclosed in square brackets [...], for example A[2,3] or A?.[2,3] with optional chaining\n * - dot notation for properties, like foo.bar or foo?.bar with optional chaining\n * @param {Object} state\n * @param {Node} node Node on which to apply the parameters. If there\n * are no parameters in the expression, the node\n * itself is returned\n * @param {string[]} [types] Filter the types of notations\n * can be ['(', '[', '.']\n * @return {Node} node\n * @private\n */\n function parseAccessors(state, node, types) {\n var params;\n\n // Iterate and handle chained accessors, including repeated optional chaining\n while (true) {\n // eslint-disable-line no-unmodified-loop-condition\n // Track whether an optional chaining operator precedes the next accessor\n var optional = false;\n\n // Consume an optional chaining operator if present\n if (state.token === '?.') {\n optional = true;\n // consume the '?.' token\n getToken(state);\n }\n var hasNextAccessor = (state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.includes(state.token));\n if (!(optional || hasNextAccessor)) {\n break;\n }\n params = [];\n if (state.token === '(') {\n if (optional || isSymbolNode(node) || isAccessorNode(node)) {\n // function invocation: fn(2, 3) or obj.fn(2, 3) or (anything)?.(2, 3)\n openParams(state);\n getToken(state);\n if (state.token !== ')') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n node = new FunctionNode(node, params, optional);\n } else {\n // implicit multiplication like (2+3)(4+5) or sqrt(2)(1+2)\n // don't parse it here but let it be handled by parseImplicitMultiplication\n // with correct precedence\n return node;\n }\n } else if (state.token === '[') {\n // index notation like variable[2, 3]\n openParams(state);\n getToken(state);\n if (state.token !== ']') {\n params.push(parseAssignment(state));\n\n // parse a list with parameters\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n params.push(parseAssignment(state));\n }\n }\n if (state.token !== ']') {\n throw createSyntaxError(state, 'Parenthesis ] expected');\n }\n closeParams(state);\n getToken(state);\n node = new AccessorNode(node, new IndexNode(params), optional);\n } else {\n // dot notation like variable.prop\n // consume the `.` (if it was ?., already consumed):\n if (!optional) getToken(state);\n var isPropertyName = state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS;\n if (!isPropertyName) {\n var message = 'Property name expected after ';\n message += optional ? 'optional chain' : 'dot';\n throw createSyntaxError(state, message);\n }\n params.push(new ConstantNode(state.token));\n getToken(state);\n var dotNotation = true;\n node = new AccessorNode(node, new IndexNode(params, dotNotation), optional);\n }\n }\n return node;\n }\n\n /**\n * Parse a single or double quoted string.\n * @return {Node} node\n * @private\n */\n function parseString(state) {\n var node, str;\n if (state.token === '\"' || state.token === \"'\") {\n str = parseStringToken(state, state.token);\n\n // create constant\n node = new ConstantNode(str);\n\n // parse index parameters\n node = parseAccessors(state, node);\n return node;\n }\n return parseMatrix(state);\n }\n\n /**\n * Parse a string surrounded by single or double quotes\n * @param {Object} state\n * @param {\"'\" | \"\\\"\"} quote\n * @return {string}\n */\n function parseStringToken(state, quote) {\n var str = '';\n while (currentCharacter(state) !== '' && currentCharacter(state) !== quote) {\n if (currentCharacter(state) === '\\\\') {\n next(state);\n var char = currentCharacter(state);\n var escapeChar = ESCAPE_CHARACTERS[char];\n if (escapeChar !== undefined) {\n // an escaped control character like \\\" or \\n\n str += escapeChar;\n state.index += 1;\n } else if (char === 'u') {\n // escaped unicode character\n var unicode = state.expression.slice(state.index + 1, state.index + 5);\n if (/^[0-9A-Fa-f]{4}$/.test(unicode)) {\n // test whether the string holds four hexadecimal values\n str += String.fromCharCode(parseInt(unicode, 16));\n state.index += 5;\n } else {\n throw createSyntaxError(state, \"Invalid unicode character \\\\u\".concat(unicode));\n }\n } else {\n throw createSyntaxError(state, \"Bad escape character \\\\\".concat(char));\n }\n } else {\n // any regular character\n str += currentCharacter(state);\n next(state);\n }\n }\n getToken(state);\n if (state.token !== quote) {\n throw createSyntaxError(state, \"End of string \".concat(quote, \" expected\"));\n }\n getToken(state);\n return str;\n }\n\n /**\n * parse the matrix\n * @return {Node} node\n * @private\n */\n function parseMatrix(state) {\n var array, params, rows, cols;\n if (state.token === '[') {\n // matrix [...]\n openParams(state);\n getToken(state);\n if (state.token !== ']') {\n // this is a non-empty matrix\n var row = parseRow(state);\n if (state.token === ';') {\n // 2 dimensional array\n rows = 1;\n params = [row];\n\n // the rows of the matrix are separated by dot-comma's\n while (state.token === ';') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n if (state.token !== ']') {\n params[rows] = parseRow(state);\n rows++;\n }\n }\n if (state.token !== ']') {\n throw createSyntaxError(state, 'End of matrix ] expected');\n }\n closeParams(state);\n getToken(state);\n\n // check if the number of columns matches in all rows\n cols = params[0].items.length;\n for (var r = 1; r < rows; r++) {\n if (params[r].items.length !== cols) {\n throw createError(state, 'Column dimensions mismatch ' + '(' + params[r].items.length + ' !== ' + cols + ')');\n }\n }\n array = new ArrayNode(params);\n } else {\n // 1 dimensional vector\n if (state.token !== ']') {\n throw createSyntaxError(state, 'End of matrix ] expected');\n }\n closeParams(state);\n getToken(state);\n array = row;\n }\n } else {\n // this is an empty matrix \"[ ]\"\n closeParams(state);\n getToken(state);\n array = new ArrayNode([]);\n }\n return parseAccessors(state, array);\n }\n return parseObject(state);\n }\n\n /**\n * Parse a single comma-separated row from a matrix, like 'a, b, c'\n * @return {ArrayNode} node\n */\n function parseRow(state) {\n var params = [parseAssignment(state)];\n var len = 1;\n while (state.token === ',') {\n // eslint-disable-line no-unmodified-loop-condition\n getToken(state);\n\n // parse expression\n if (state.token !== ']' && state.token !== ';') {\n params[len] = parseAssignment(state);\n len++;\n }\n }\n return new ArrayNode(params);\n }\n\n /**\n * parse an object, enclosed in angle brackets{...}, for example {value: 2}\n * @return {Node} node\n * @private\n */\n function parseObject(state) {\n if (state.token === '{') {\n openParams(state);\n var key;\n var properties = {};\n do {\n getToken(state);\n if (state.token !== '}') {\n // parse key\n if (state.token === '\"' || state.token === \"'\") {\n key = parseStringToken(state, state.token);\n } else if (state.tokenType === TOKENTYPE.SYMBOL || state.tokenType === TOKENTYPE.DELIMITER && state.token in NAMED_DELIMITERS) {\n key = state.token;\n getToken(state);\n } else {\n throw createSyntaxError(state, 'Symbol or string expected as object key');\n }\n\n // parse key/value separator\n if (state.token !== ':') {\n throw createSyntaxError(state, 'Colon : expected after object key');\n }\n getToken(state);\n\n // parse key\n properties[key] = parseAssignment(state);\n }\n } while (state.token === ','); // eslint-disable-line no-unmodified-loop-condition\n\n if (state.token !== '}') {\n throw createSyntaxError(state, 'Comma , or bracket } expected after object value');\n }\n closeParams(state);\n getToken(state);\n var node = new ObjectNode(properties);\n\n // parse index parameters\n node = parseAccessors(state, node);\n return node;\n }\n return parseNumber(state);\n }\n\n /**\n * parse a number\n * @return {Node} node\n * @private\n */\n function parseNumber(state) {\n var numberStr;\n if (state.tokenType === TOKENTYPE.NUMBER) {\n // this is a number\n numberStr = state.token;\n getToken(state);\n var numericType = safeNumberType(numberStr, config);\n var value = numeric(numberStr, numericType);\n return new ConstantNode(value);\n }\n return parseParentheses(state);\n }\n\n /**\n * parentheses\n * @return {Node} node\n * @private\n */\n function parseParentheses(state) {\n var node;\n\n // check if it is a parenthesized expression\n if (state.token === '(') {\n // parentheses (...)\n openParams(state);\n getToken(state);\n node = parseAssignment(state); // start again\n\n if (state.token !== ')') {\n throw createSyntaxError(state, 'Parenthesis ) expected');\n }\n closeParams(state);\n getToken(state);\n node = new ParenthesisNode(node);\n node = parseAccessors(state, node);\n return node;\n }\n return parseEnd(state);\n }\n\n /**\n * Evaluated when the expression is not yet ended but expected to end\n * @return {Node} res\n * @private\n */\n function parseEnd(state) {\n if (state.token === '') {\n // syntax error or unexpected end of expression\n throw createSyntaxError(state, 'Unexpected end of expression');\n } else {\n throw createSyntaxError(state, 'Value expected');\n }\n }\n\n /**\n * Shortcut for getting the current row value (one based)\n * Returns the line of the currently handled expression\n * @private\n */\n /* TODO: implement keeping track on the row number\n function row () {\n return null\n }\n */\n\n /**\n * Shortcut for getting the current col value (one based)\n * Returns the column (position) where the last state.token starts\n * @private\n */\n function col(state) {\n return state.index - state.token.length + 1;\n }\n\n /**\n * Create an error\n * @param {Object} state\n * @param {string} message\n * @return {SyntaxError} instantiated error\n * @private\n */\n function createSyntaxError(state, message) {\n var c = col(state);\n var error = new SyntaxError(message + ' (char ' + c + ')');\n error.char = c;\n return error;\n }\n\n /**\n * Create an error\n * @param {Object} state\n * @param {string} message\n * @return {Error} instantiated error\n * @private\n */\n function createError(state, message) {\n var c = col(state);\n var error = new SyntaxError(message + ' (char ' + c + ')');\n error.char = c;\n return error;\n }\n\n // Now that we can parse, automatically convert strings to Nodes by parsing\n typed.addConversion({\n from: 'string',\n to: 'Node',\n convert: parse\n });\n return parse;\n});","import { deepMap } from '../../utils/collection.js';\nimport { factory } from '../../utils/factory.js';\nimport { createEmptyMap } from '../../utils/map.js';\nvar name = 'evaluate';\nvar dependencies = ['typed', 'parse'];\nexport var createEvaluate = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n parse\n } = _ref;\n /**\n * Evaluate an expression.\n *\n * The expression parser does not use JavaScript. Its syntax is close\n * to JavaScript but more suited for mathematical expressions.\n * See [https://mathjs.org/docs/expressions/syntax.html](https://mathjs.org/docs/expressions/syntax.html) to learn\n * the syntax and get an overview of the exact differences from JavaScript.\n *\n * Note the evaluating arbitrary expressions may involve security risks,\n * see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.\n *\n * Syntax:\n *\n * math.evaluate(expr)\n * math.evaluate(expr, scope)\n * math.evaluate([expr1, expr2, expr3, ...])\n * math.evaluate([expr1, expr2, expr3, ...], scope)\n *\n * Example:\n *\n * math.evaluate('(2+3)/4') // 1.25\n * math.evaluate('sqrt(3^2 + 4^2)') // 5\n * math.evaluate('sqrt(-4)') // 2i\n * math.evaluate(['a=3', 'b=4', 'a*b']) // [3, 4, 12]\n *\n * let scope = {a:3, b:4}\n * math.evaluate('a * b', scope) // 12\n *\n * See also:\n *\n * parse, compile\n *\n * @param {string | string[] | Matrix} expr The expression to be evaluated\n * @param {Object} [scope] Scope to read/write variables\n * @return {*} The result of the expression\n * @throws {Error}\n */\n return typed(name, {\n string: function string(expr) {\n var scope = createEmptyMap();\n return parse(expr).compile().evaluate(scope);\n },\n 'string, Map | Object': function string_Map__Object(expr, scope) {\n return parse(expr).compile().evaluate(scope);\n },\n 'Array | Matrix': function Array__Matrix(expr) {\n var scope = createEmptyMap();\n return deepMap(expr, function (entry) {\n return parse(entry).compile().evaluate(scope);\n });\n },\n 'Array | Matrix, Map | Object': function Array__Matrix_Map__Object(expr, scope) {\n return deepMap(expr, function (entry) {\n return parse(entry).compile().evaluate(scope);\n });\n }\n });\n});","import { arraySize } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'size';\nvar dependencies = ['typed'];\nexport var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Calculate the size of a matrix or scalar. Always returns an Array containing numbers.\n *\n * Note that in mathjs v14 and older, function size could return a Matrix depending on\n * the input type and configuration.\n *\n * Syntax:\n *\n * math.size(x)\n *\n * Examples:\n *\n * math.size(2.3) // returns []\n * math.size('hello world') // returns [11]\n *\n * const A = [[1, 2, 3], [4, 5, 6]]\n * math.size(A) // returns [2, 3]\n * math.size(math.range(1,6).toArray()) // returns [5]\n *\n * See also:\n *\n * count, resize, squeeze, subset\n *\n * @param {boolean | number | Complex | Unit | string | Array | Matrix} x A matrix\n * @return {Array} A vector with size of `x`.\n */\n return typed(name, {\n Matrix: x => x.size(),\n Array: arraySize,\n string: x => [x.length],\n // scalar\n 'number | Complex | BigNumber | Unit | boolean | null': _x => []\n });\n});","import { deepMap } from '../../utils/collection.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'factorial';\nvar dependencies = ['typed', 'gamma'];\nexport var createFactorial = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed,\n gamma\n } = _ref;\n /**\n * Compute the factorial of a value\n *\n * Factorial only supports an integer value as argument.\n * For matrices, the function is evaluated element wise.\n *\n * Syntax:\n *\n * math.factorial(n)\n *\n * Examples:\n *\n * math.factorial(5) // returns 120\n * math.factorial(3) // returns 6\n *\n * See also:\n *\n * combinations, combinationsWithRep, gamma, permutations\n *\n * @param {number | BigNumber | Array | Matrix} n An integer number\n * @return {number | BigNumber | Array | Matrix} The factorial of `n`\n */\n return typed(name, {\n number: function number(n) {\n if (n < 0) {\n throw new Error('Value must be non-negative');\n }\n return gamma(n + 1);\n },\n BigNumber: function BigNumber(n) {\n if (n.isNegative()) {\n throw new Error('Value must be non-negative');\n }\n return gamma(n.plus(1));\n },\n 'Array | Matrix': typed.referToSelf(self => n => deepMap(n, self))\n });\n});","import { factory } from '../../utils/factory.js';\nvar name = 'isBounded';\nvar dependencies = ['typed'];\nexport var createIsBounded = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n typed\n } = _ref;\n /**\n * Test whether a value is bounded. For scalars, this test is equivalent\n * to the isFinite finiteness test. On the other hand, a Matrix or Array\n * is defined to be bounded if every entry is finite.\n *\n * Syntax:\n *\n * math.isBounded(x)\n *\n * Examples:\n *\n * math.isBounded(0) // returns true\n * math.isBounded(NaN) // returns false\n * math.isBounded(math.bignumber(Infinity)) // returns false\n * math.isBounded(math.fraction(1,3)) // returns true\n * math.isBounded(math.complex('2 - 4i')) // returns true\n * math.isBounded(-10000000000000000n) // returns true\n * math.isBounded(undefined) // returns false\n * math.isBounded(null) // returns false\n * math.isBounded([0.001, -3n, 0]) // returns true\n * math.isBounded([2, -Infinity, -3]) // returns false\n *\n * See also:\n *\n * isFinite, isNumeric, isPositive, isNegative, isNaN\n *\n * @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested\n * @return {boolean} Returns true when `x` is bounded.\n */\n return typed(name, {\n number: n => Number.isFinite(n),\n 'BigNumber | Complex': x => x.isFinite(),\n 'bigint | Fraction': () => true,\n 'null | undefined': () => false,\n Unit: typed.referToSelf(self => x => self(x.value)),\n 'Array | Matrix': typed.referToSelf(self => A => {\n if (!Array.isArray(A)) A = A.valueOf();\n return A.every(entry => self(entry));\n })\n });\n});","import { typeOf } from '../../utils/is.js';\nimport { factory } from '../../utils/factory.js';\nimport { noBignumber, noFraction } from '../../utils/noop.js';\nvar name = 'numeric';\nvar dependencies = ['number', '?bignumber', '?fraction'];\nexport var createNumeric = /* #__PURE__ */factory(name, dependencies, _ref => {\n var {\n number: _number,\n bignumber,\n fraction\n } = _ref;\n var validInputTypes = {\n string: true,\n number: true,\n BigNumber: true,\n Fraction: true\n };\n\n // Load the conversion functions for each output type\n var validOutputTypes = {\n number: x => _number(x),\n BigNumber: bignumber ? x => bignumber(x) : noBignumber,\n bigint: x => BigInt(x),\n Fraction: fraction ? x => fraction(x) : noFraction\n };\n\n /**\n * Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.\n *\n * Syntax:\n *\n * math.numeric(x)\n * math.numeric(value, outputType)\n *\n * Examples:\n *\n * math.numeric('4') // returns 4\n * math.numeric('4', 'number') // returns 4\n * math.numeric('4', 'bigint') // returns 4n\n * math.numeric('4', 'BigNumber') // returns BigNumber 4\n * math.numeric('4', 'Fraction') // returns Fraction 4\n * math.numeric(4, 'Fraction') // returns Fraction 4\n * math.numeric(math.fraction(2, 5), 'number') // returns 0.4\n *\n * See also:\n *\n * number, fraction, bignumber, bigint, string, format\n *\n * History:\n *\n * v6 Created\n * v13 Added `bigint` support\n * v14.2.1 Prefer mathjs `bigint()` to built-in `BigInt()`\n *\n * @param {string | number | BigNumber | bigint | Fraction } value\n * A numeric value or a string containing a numeric value\n * @param {string} outputType\n * Desired numeric output type.\n * Available values: 'number', 'BigNumber', or 'Fraction'\n * @return {number | BigNumber | bigint | Fraction}\n * Returns an instance of the numeric in the requested type\n */\n return function numeric(value) {\n var outputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'number';\n var check = arguments.length > 2 ? arguments[2] : undefined;\n if (check !== undefined) {\n throw new SyntaxError('numeric() takes one or two arguments');\n }\n var inputType = typeOf(value);\n if (!(inputType in validInputTypes)) {\n throw new TypeError('Cannot convert ' + value + ' of type \"' + inputType + '\"; valid input types are ' + Object.keys(validInputTypes).join(', '));\n }\n if (!(outputType in validOutputTypes)) {\n throw new TypeError('Cannot convert ' + value + ' to type \"' + outputType + '\"; valid output types are ' + Object.keys(validOutputTypes).join(', '));\n }\n if (outputType === inputType) {\n return value;\n } else {\n return validOutputTypes[outputType](value);\n }\n };\n});","import { absNumber, acoshNumber, acosNumber, acothNumber, acotNumber, acschNumber, acscNumber, addNumber, andNumber, asechNumber, asecNumber, asinhNumber, asinNumber, atan2Number, atanhNumber, atanNumber, bitAndNumber, bitNotNumber, bitOrNumber, bitXorNumber, cbrtNumber, combinationsNumber, coshNumber, cosNumber, cothNumber, cotNumber, cschNumber, cscNumber, cubeNumber, divideNumber, expm1Number, expNumber, gammaNumber, gcdNumber, isIntegerNumber, isNaNNumber, isNegativeNumber, isPositiveNumber, isZeroNumber, lcmNumber, leftShiftNumber, lgammaNumber, log10Number, log1pNumber, log2Number, logNumber, modNumber, multiplyNumber, normNumber, notNumber, nthRootNumber, orNumber, powNumber, rightArithShiftNumber, rightLogShiftNumber, roundNumber, sechNumber, secNumber, signNumber, sinhNumber, sinNumber, sqrtNumber, squareNumber, subtractNumber, tanhNumber, tanNumber, unaryMinusNumber, unaryPlusNumber, xgcdNumber, xorNumber } from './plain/number/index.js';\nimport { factory } from './utils/factory.js';\nimport { noIndex, noMatrix, noSubset } from './utils/noop.js';\n\n// ----------------------------------------------------------------------------\n// classes and functions\n\n// core\nexport { createTyped } from './core/function/typed.js';\n\n// classes\nexport { createResultSet } from './type/resultset/ResultSet.js';\nexport { createRangeClass } from './type/matrix/Range.js';\nexport { createHelpClass } from './expression/Help.js';\nexport { createChainClass } from './type/chain/Chain.js';\nexport { createHelp } from './expression/function/help.js';\nexport { createChain } from './type/chain/function/chain.js';\n\n// algebra\nexport { createResolve } from './function/algebra/resolve.js';\nexport { createSimplify } from './function/algebra/simplify.js';\nexport { createSimplifyConstant } from './function/algebra/simplifyConstant.js';\nexport { createSimplifyCore } from './function/algebra/simplifyCore.js';\nexport { createDerivative } from './function/algebra/derivative.js';\nexport { createRationalize } from './function/algebra/rationalize.js';\n\n// arithmetic\nexport var createUnaryMinus = /* #__PURE__ */createNumberFactory('unaryMinus', unaryMinusNumber);\nexport var createUnaryPlus = /* #__PURE__ */createNumberFactory('unaryPlus', unaryPlusNumber);\nexport var createAbs = /* #__PURE__ */createNumberFactory('abs', absNumber);\nexport var createAddScalar = /* #__PURE__ */createNumberFactory('addScalar', addNumber);\nexport var createSubtractScalar = /* #__PURE__ */createNumberFactory('subtractScalar', subtractNumber);\nexport var createCbrt = /* #__PURE__ */createNumberFactory('cbrt', cbrtNumber);\nexport { createCeilNumber as createCeil } from './function/arithmetic/ceil.js';\nexport var createCube = /* #__PURE__ */createNumberFactory('cube', cubeNumber);\nexport var createExp = /* #__PURE__ */createNumberFactory('exp', expNumber);\nexport var createExpm1 = /* #__PURE__ */createNumberFactory('expm1', expm1Number);\nexport { createFixNumber as createFix } from './function/arithmetic/fix.js';\nexport { createFloorNumber as createFloor } from './function/arithmetic/floor.js';\nexport var createGcd = /* #__PURE__ */createNumberFactory('gcd', gcdNumber);\nexport var createLcm = /* #__PURE__ */createNumberFactory('lcm', lcmNumber);\nexport var createLog10 = /* #__PURE__ */createNumberFactory('log10', log10Number);\nexport var createLog2 = /* #__PURE__ */createNumberFactory('log2', log2Number);\nexport var createMod = /* #__PURE__ */createNumberFactory('mod', modNumber);\nexport var createMultiplyScalar = /* #__PURE__ */createNumberFactory('multiplyScalar', multiplyNumber);\nexport var createMultiply = /* #__PURE__ */createNumberFactory('multiply', multiplyNumber);\nexport var createNthRoot = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('nthRoot', nthRootNumber);\nexport var createSign = /* #__PURE__ */createNumberFactory('sign', signNumber);\nexport var createSqrt = /* #__PURE__ */createNumberFactory('sqrt', sqrtNumber);\nexport var createSquare = /* #__PURE__ */createNumberFactory('square', squareNumber);\nexport var createSubtract = /* #__PURE__ */createNumberFactory('subtract', subtractNumber);\nexport var createXgcd = /* #__PURE__ */createNumberFactory('xgcd', xgcdNumber);\nexport var createDivideScalar = /* #__PURE__ */createNumberFactory('divideScalar', divideNumber);\nexport var createPow = /* #__PURE__ */createNumberFactory('pow', powNumber);\nexport var createRound = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('round', roundNumber);\nexport var createLog = /* #__PURE__ */\ncreateNumberOptionalSecondArgFactory('log', logNumber);\nexport var createLog1p = /* #__PURE__ */createNumberFactory('log1p', log1pNumber);\nexport var createAdd = /* #__PURE__ */createNumberFactory('add', addNumber);\nexport { createHypot } from './function/arithmetic/hypot.js';\nexport var createNorm = /* #__PURE__ */createNumberFactory('norm', normNumber);\nexport var createDivide = /* #__PURE__ */createNumberFactory('divide', divideNumber);\n\n// bitwise\nexport var createBitAnd = /* #__PURE__ */createNumberFactory('bitAnd', bitAndNumber);\nexport var createBitNot = /* #__PURE__ */createNumberFactory('bitNot', bitNotNumber);\nexport var createBitOr = /* #__PURE__ */createNumberFactory('bitOr', bitOrNumber);\nexport var createBitXor = /* #__PURE__ */createNumberFactory('bitXor', bitXorNumber);\nexport var createLeftShift = /* #__PURE__ */createNumberFactory('leftShift', leftShiftNumber);\nexport var createRightArithShift = /* #__PURE__ */createNumberFactory('rightArithShift', rightArithShiftNumber);\nexport var createRightLogShift = /* #__PURE__ */createNumberFactory('rightLogShift', rightLogShiftNumber);\n\n// combinatorics\nexport { createStirlingS2 } from './function/combinatorics/stirlingS2.js';\nexport { createBellNumbers } from './function/combinatorics/bellNumbers.js';\nexport { createCatalan } from './function/combinatorics/catalan.js';\nexport { createComposition } from './function/combinatorics/composition.js';\n\n// constants\nexport { createE, createUppercaseE, createFalse,\n// createI,\ncreateInfinity, createLN10, createLN2, createLOG10E, createLOG2E, createNaN, createNull, createPhi, createPi, createUppercasePi, createSQRT1_2,\n// eslint-disable-line camelcase\ncreateSQRT2, createTau, createTrue, createVersion } from './constants.js';\n\n// create\nexport { createNumber } from './type/number.js';\nexport { createBigint } from './type/bigint.js';\nexport { createString } from './type/string.js';\nexport { createBoolean } from './type/boolean.js';\nexport { createParser } from './expression/function/parser.js';\n\n// expression\nexport { createNode } from './expression/node/Node.js';\nexport { createAccessorNode } from './expression/node/AccessorNode.js';\nexport { createArrayNode } from './expression/node/ArrayNode.js';\nexport { createAssignmentNode } from './expression/node/AssignmentNode.js';\nexport { createBlockNode } from './expression/node/BlockNode.js';\nexport { createConditionalNode } from './expression/node/ConditionalNode.js';\nexport { createConstantNode } from './expression/node/ConstantNode.js';\nexport { createFunctionAssignmentNode } from './expression/node/FunctionAssignmentNode.js';\nexport { createIndexNode } from './expression/node/IndexNode.js';\nexport { createObjectNode } from './expression/node/ObjectNode.js';\nexport { createOperatorNode } from './expression/node/OperatorNode.js';\nexport { createParenthesisNode } from './expression/node/ParenthesisNode.js';\nexport { createRangeNode } from './expression/node/RangeNode.js';\nexport { createRelationalNode } from './expression/node/RelationalNode.js';\nexport { createSymbolNode } from './expression/node/SymbolNode.js';\nexport { createFunctionNode } from './expression/node/FunctionNode.js';\nexport { createParse } from './expression/parse.js';\nexport { createCompile } from './expression/function/compile.js';\nexport { createEvaluate } from './expression/function/evaluate.js';\nexport { createParserClass } from './expression/Parser.js';\n\n// logical\nexport var createAnd = /* #__PURE__ */createNumberFactory('and', andNumber);\nexport var createNot = /* #__PURE__ */createNumberFactory('not', notNumber);\nexport var createOr = /* #__PURE__ */createNumberFactory('or', orNumber);\nexport var createXor = /* #__PURE__ */createNumberFactory('xor', xorNumber);\n\n// matrix\nexport { createMapSlices } from './function/matrix/mapSlices.js';\nexport { createFilter } from './function/matrix/filter.js';\nexport { createForEach } from './function/matrix/forEach.js';\nexport { createMap } from './function/matrix/map.js';\nexport { createRange } from './function/matrix/range.js';\nexport { createSize } from './function/matrix/size.js';\n// FIXME: create a lightweight \"number\" implementation of subset only supporting plain objects/arrays\nexport var createIndex = /* #__PURE__ */factory('index', [], () => noIndex);\nexport var createMatrix = /* #__PURE__ */factory('matrix', [], () => noMatrix); // FIXME: needed now because subset transform needs it. Remove the need for it in subset\nexport var createSubset = /* #__PURE__ */factory('subset', [], () => noSubset);\n// TODO: provide number+array implementations for map, filter, forEach, zeros, ...?\n// TODO: create range implementation for range?\nexport { createPartitionSelect } from './function/matrix/partitionSelect.js';\n\n// probability\nexport { createBernoulli } from './function/probability/bernoulli.js';\nexport var createCombinations = createNumberFactory('combinations', combinationsNumber);\nexport var createGamma = createNumberFactory('gamma', gammaNumber);\nexport var createLgamma = createNumberFactory('lgamma', lgammaNumber);\nexport { createCombinationsWithRep } from './function/probability/combinationsWithRep.js';\nexport { createFactorial } from './function/probability/factorial.js';\nexport { createMultinomial } from './function/probability/multinomial.js';\nexport { createPermutations } from './function/probability/permutations.js';\nexport { createPickRandom } from './function/probability/pickRandom.js';\nexport { createRandomNumber as createRandom } from './function/probability/random.js';\nexport { createRandomInt } from './function/probability/randomInt.js';\n\n// relational\nexport { createEqualScalarNumber as createEqualScalar } from './function/relational/equalScalar.js';\nexport { createCompareNumber as createCompare } from './function/relational/compare.js';\nexport { createCompareNatural } from './function/relational/compareNatural.js';\nexport { createCompareTextNumber as createCompareText } from './function/relational/compareText.js';\nexport { createEqualNumber as createEqual } from './function/relational/equal.js';\nexport { createEqualText } from './function/relational/equalText.js';\nexport { createSmallerNumber as createSmaller } from './function/relational/smaller.js';\nexport { createSmallerEqNumber as createSmallerEq } from './function/relational/smallerEq.js';\nexport { createLargerNumber as createLarger } from './function/relational/larger.js';\nexport { createLargerEqNumber as createLargerEq } from './function/relational/largerEq.js';\nexport { createDeepEqual } from './function/relational/deepEqual.js';\nexport { createUnequalNumber as createUnequal } from './function/relational/unequal.js';\n\n// special\nexport { createErf } from './function/special/erf.js';\nexport { createZeta } from './function/special/zeta.js';\n// statistics\nexport { createMode } from './function/statistics/mode.js';\nexport { createProd } from './function/statistics/prod.js';\nexport { createMax } from './function/statistics/max.js';\nexport { createMin } from './function/statistics/min.js';\nexport { createSum } from './function/statistics/sum.js';\nexport { createCumSum } from './function/statistics/cumsum.js';\nexport { createMean } from './function/statistics/mean.js';\nexport { createMedian } from './function/statistics/median.js';\nexport { createMad } from './function/statistics/mad.js';\nexport { createVariance } from './function/statistics/variance.js';\nexport { createQuantileSeq } from './function/statistics/quantileSeq.js';\nexport { createStd } from './function/statistics/std.js';\nexport { createCorr } from './function/statistics/corr.js';\n\n// string\nexport { createFormat } from './function/string/format.js';\nexport { createPrint } from './function/string/print.js';\n\n// trigonometry\nexport var createAcos = /* #__PURE__ */createNumberFactory('acos', acosNumber);\nexport var createAcosh = /* #__PURE__ */createNumberFactory('acosh', acoshNumber);\nexport var createAcot = /* #__PURE__ */createNumberFactory('acot', acotNumber);\nexport var createAcoth = /* #__PURE__ */createNumberFactory('acoth', acothNumber);\nexport var createAcsc = /* #__PURE__ */createNumberFactory('acsc', acscNumber);\nexport var createAcsch = /* #__PURE__ */createNumberFactory('acsch', acschNumber);\nexport var createAsec = /* #__PURE__ */createNumberFactory('asec', asecNumber);\nexport var createAsech = /* #__PURE__ */createNumberFactory('asech', asechNumber);\nexport var createAsin = /* #__PURE__ */createNumberFactory('asin', asinNumber);\nexport var createAsinh = /* #__PURE__ */createNumberFactory('asinh', asinhNumber);\nexport var createAtan = /* #__PURE__ */createNumberFactory('atan', atanNumber);\nexport var createAtan2 = /* #__PURE__ */createNumberFactory('atan2', atan2Number);\nexport var createAtanh = /* #__PURE__ */createNumberFactory('atanh', atanhNumber);\nexport var createCos = /* #__PURE__ */createNumberFactory('cos', cosNumber);\nexport var createCosh = /* #__PURE__ */createNumberFactory('cosh', coshNumber);\nexport var createCot = /* #__PURE__ */createNumberFactory('cot', cotNumber);\nexport var createCoth = /* #__PURE__ */createNumberFactory('coth', cothNumber);\nexport var createCsc = /* #__PURE__ */createNumberFactory('csc', cscNumber);\nexport var createCsch = /* #__PURE__ */createNumberFactory('csch', cschNumber);\nexport var createSec = /* #__PURE__ */createNumberFactory('sec', secNumber);\nexport var createSech = /* #__PURE__ */createNumberFactory('sech', sechNumber);\nexport var createSin = /* #__PURE__ */createNumberFactory('sin', sinNumber);\nexport var createSinh = /* #__PURE__ */createNumberFactory('sinh', sinhNumber);\nexport var createTan = /* #__PURE__ */createNumberFactory('tan', tanNumber);\nexport var createTanh = /* #__PURE__ */createNumberFactory('tanh', tanhNumber);\n\n// transforms\nexport { createMapSlicesTransform } from './expression/transform/mapSlices.transform.js';\nexport { createFilterTransform } from './expression/transform/filter.transform.js';\nexport { createForEachTransform } from './expression/transform/forEach.transform.js';\nexport { createMapTransform } from './expression/transform/map.transform.js';\nexport { createMaxTransform } from './expression/transform/max.transform.js';\nexport { createMeanTransform } from './expression/transform/mean.transform.js';\nexport { createMinTransform } from './expression/transform/min.transform.js';\nexport { createRangeTransform } from './expression/transform/range.transform.js';\nexport var createSubsetTransform = /* #__PURE__ */factory('subset', [], () => noSubset, {\n isTransformFunction: true\n});\nexport { createStdTransform } from './expression/transform/std.transform.js';\nexport { createSumTransform } from './expression/transform/sum.transform.js';\nexport { createCumSumTransform } from './expression/transform/cumsum.transform.js';\nexport { createVarianceTransform } from './expression/transform/variance.transform.js';\n\n// utils\nexport { createClone } from './function/utils/clone.js';\nexport var createIsInteger = /* #__PURE__ */createNumberFactory('isInteger', isIntegerNumber);\nexport var createIsNegative = /* #__PURE__ */createNumberFactory('isNegative', isNegativeNumber);\nexport { createIsNumeric } from './function/utils/isNumeric.js';\nexport { createHasNumericValue } from './function/utils/hasNumericValue.js';\nexport var createIsPositive = /* #__PURE__ */createNumberFactory('isPositive', isPositiveNumber);\nexport var createIsZero = /* #__PURE__ */createNumberFactory('isZero', isZeroNumber);\nexport var createIsNaN = /* #__PURE__ */createNumberFactory('isNaN', isNaNNumber);\nexport { createIsBounded } from './function/utils/isBounded.js';\nexport { createIsFinite } from './function/utils/isFinite.js';\nexport { createTypeOf } from './function/utils/typeOf.js';\nexport { createIsPrime } from './function/utils/isPrime.js';\nexport { createNumeric } from './function/utils/numeric.js';\n\n// json\nexport { createReviver } from './json/reviver.js';\nexport { createReplacer } from './json/replacer.js';\n\n// helper functions to create a factory function for a function which only needs typed-function\nfunction createNumberFactory(name, fn) {\n return factory(name, ['typed'], _ref => {\n var {\n typed\n } = _ref;\n return typed(fn);\n });\n}\nfunction createNumberOptionalSecondArgFactory(name, fn) {\n return factory(name, ['typed'], _ref2 => {\n var {\n typed\n } = _ref2;\n return typed({\n number: fn,\n 'number,number': fn\n });\n });\n}","/**\n * Create a syntax error with the message:\n * 'Wrong number of arguments in function ( provided, - expected)'\n * @param {string} fn Function name\n * @param {number} count Actual argument count\n * @param {number} min Minimum required argument count\n * @param {number} [max] Maximum required argument count\n * @extends Error\n */\nexport function ArgumentsError(fn, count, min, max) {\n if (!(this instanceof ArgumentsError)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n this.fn = fn;\n this.count = count;\n this.min = min;\n this.max = max;\n this.message = 'Wrong number of arguments in function ' + fn + ' (' + count + ' provided, ' + min + (max !== undefined && max !== null ? '-' + max : '') + ' expected)';\n this.stack = new Error().stack;\n}\nArgumentsError.prototype = new Error();\nArgumentsError.prototype.constructor = Error;\nArgumentsError.prototype.name = 'ArgumentsError';\nArgumentsError.prototype.isArgumentsError = true;","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createTyped } from '../../factoriesNumber.js';\nexport var typedDependencies = {\n createTyped\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createAbs } from '../../factoriesNumber.js';\nexport var absDependencies = {\n typedDependencies,\n createAbs\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createNode } from '../../factoriesNumber.js';\nexport var NodeDependencies = {\n createNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createSubset } from '../../factoriesNumber.js';\nexport var subsetDependencies = {\n createSubset\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { subsetDependencies } from './dependenciesSubset.generated.js';\nimport { createAccessorNode } from '../../factoriesNumber.js';\nexport var AccessorNodeDependencies = {\n NodeDependencies,\n subsetDependencies,\n createAccessorNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createAdd } from '../../factoriesNumber.js';\nexport var addDependencies = {\n typedDependencies,\n createAdd\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createArrayNode } from '../../factoriesNumber.js';\nexport var ArrayNodeDependencies = {\n NodeDependencies,\n createArrayNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createMatrix } from '../../factoriesNumber.js';\nexport var matrixDependencies = {\n createMatrix\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { matrixDependencies } from './dependenciesMatrix.generated.js';\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { subsetDependencies } from './dependenciesSubset.generated.js';\nimport { createAssignmentNode } from '../../factoriesNumber.js';\nexport var AssignmentNodeDependencies = {\n matrixDependencies,\n NodeDependencies,\n subsetDependencies,\n createAssignmentNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createGamma } from '../../factoriesNumber.js';\nexport var gammaDependencies = {\n typedDependencies,\n createGamma\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { gammaDependencies } from './dependenciesGamma.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createFactorial } from '../../factoriesNumber.js';\nexport var factorialDependencies = {\n gammaDependencies,\n typedDependencies,\n createFactorial\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createNumber } from '../../factoriesNumber.js';\nexport var numberDependencies = {\n typedDependencies,\n createNumber\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createPow } from '../../factoriesNumber.js';\nexport var powDependencies = {\n typedDependencies,\n createPow\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createResultSet } from '../../factoriesNumber.js';\nexport var ResultSetDependencies = {\n createResultSet\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { ResultSetDependencies } from './dependenciesResultSet.generated.js';\nimport { createBlockNode } from '../../factoriesNumber.js';\nexport var BlockNodeDependencies = {\n NodeDependencies,\n ResultSetDependencies,\n createBlockNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createRound } from '../../factoriesNumber.js';\nexport var roundDependencies = {\n typedDependencies,\n createRound\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createConditionalNode } from '../../factoriesNumber.js';\nexport var ConditionalNodeDependencies = {\n NodeDependencies,\n createConditionalNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createIsBounded } from '../../factoriesNumber.js';\nexport var isBoundedDependencies = {\n typedDependencies,\n createIsBounded\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { isBoundedDependencies } from './dependenciesIsBounded.generated.js';\nimport { createConstantNode } from '../../factoriesNumber.js';\nexport var ConstantNodeDependencies = {\n NodeDependencies,\n isBoundedDependencies,\n createConstantNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createFunctionAssignmentNode } from '../../factoriesNumber.js';\nexport var FunctionAssignmentNodeDependencies = {\n NodeDependencies,\n typedDependencies,\n createFunctionAssignmentNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createSymbolNode } from '../../factoriesNumber.js';\nexport var SymbolNodeDependencies = {\n NodeDependencies,\n createSymbolNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { SymbolNodeDependencies } from './dependenciesSymbolNode.generated.js';\nimport { createFunctionNode } from '../../factoriesNumber.js';\nexport var FunctionNodeDependencies = {\n NodeDependencies,\n SymbolNodeDependencies,\n createFunctionNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSize } from '../../factoriesNumber.js';\nexport var sizeDependencies = {\n typedDependencies,\n createSize\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { sizeDependencies } from './dependenciesSize.generated.js';\nimport { createIndexNode } from '../../factoriesNumber.js';\nexport var IndexNodeDependencies = {\n NodeDependencies,\n sizeDependencies,\n createIndexNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createObjectNode } from '../../factoriesNumber.js';\nexport var ObjectNodeDependencies = {\n NodeDependencies,\n createObjectNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createOperatorNode } from '../../factoriesNumber.js';\nexport var OperatorNodeDependencies = {\n NodeDependencies,\n createOperatorNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createParenthesisNode } from '../../factoriesNumber.js';\nexport var ParenthesisNodeDependencies = {\n NodeDependencies,\n createParenthesisNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createRangeNode } from '../../factoriesNumber.js';\nexport var RangeNodeDependencies = {\n NodeDependencies,\n createRangeNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { NodeDependencies } from './dependenciesNode.generated.js';\nimport { createRelationalNode } from '../../factoriesNumber.js';\nexport var RelationalNodeDependencies = {\n NodeDependencies,\n createRelationalNode\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { numberDependencies } from './dependenciesNumber.generated.js';\nimport { createNumeric } from '../../factoriesNumber.js';\nexport var numericDependencies = {\n numberDependencies,\n createNumeric\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { AccessorNodeDependencies } from './dependenciesAccessorNode.generated.js';\nimport { ArrayNodeDependencies } from './dependenciesArrayNode.generated.js';\nimport { AssignmentNodeDependencies } from './dependenciesAssignmentNode.generated.js';\nimport { BlockNodeDependencies } from './dependenciesBlockNode.generated.js';\nimport { ConditionalNodeDependencies } from './dependenciesConditionalNode.generated.js';\nimport { ConstantNodeDependencies } from './dependenciesConstantNode.generated.js';\nimport { FunctionAssignmentNodeDependencies } from './dependenciesFunctionAssignmentNode.generated.js';\nimport { FunctionNodeDependencies } from './dependenciesFunctionNode.generated.js';\nimport { IndexNodeDependencies } from './dependenciesIndexNode.generated.js';\nimport { ObjectNodeDependencies } from './dependenciesObjectNode.generated.js';\nimport { OperatorNodeDependencies } from './dependenciesOperatorNode.generated.js';\nimport { ParenthesisNodeDependencies } from './dependenciesParenthesisNode.generated.js';\nimport { RangeNodeDependencies } from './dependenciesRangeNode.generated.js';\nimport { RelationalNodeDependencies } from './dependenciesRelationalNode.generated.js';\nimport { SymbolNodeDependencies } from './dependenciesSymbolNode.generated.js';\nimport { numericDependencies } from './dependenciesNumeric.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createParse } from '../../factoriesNumber.js';\nexport var parseDependencies = {\n AccessorNodeDependencies,\n ArrayNodeDependencies,\n AssignmentNodeDependencies,\n BlockNodeDependencies,\n ConditionalNodeDependencies,\n ConstantNodeDependencies,\n FunctionAssignmentNodeDependencies,\n FunctionNodeDependencies,\n IndexNodeDependencies,\n ObjectNodeDependencies,\n OperatorNodeDependencies,\n ParenthesisNodeDependencies,\n RangeNodeDependencies,\n RelationalNodeDependencies,\n SymbolNodeDependencies,\n numericDependencies,\n typedDependencies,\n createParse\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createDivide } from '../../factoriesNumber.js';\nexport var divideDependencies = {\n typedDependencies,\n createDivide\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createMultiply } from '../../factoriesNumber.js';\nexport var multiplyDependencies = {\n typedDependencies,\n createMultiply\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSqrt } from '../../factoriesNumber.js';\nexport var sqrtDependencies = {\n typedDependencies,\n createSqrt\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSubtract } from '../../factoriesNumber.js';\nexport var subtractDependencies = {\n typedDependencies,\n createSubtract\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createE } from '../../factoriesNumber.js';\nexport var eDependencies = {\n createE\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { parseDependencies } from './dependenciesParse.generated.js';\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createEvaluate } from '../../factoriesNumber.js';\nexport var evaluateDependencies = {\n parseDependencies,\n typedDependencies,\n createEvaluate\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createExp } from '../../factoriesNumber.js';\nexport var expDependencies = {\n typedDependencies,\n createExp\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createGcd } from '../../factoriesNumber.js';\nexport var gcdDependencies = {\n typedDependencies,\n createGcd\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLcm } from '../../factoriesNumber.js';\nexport var lcmDependencies = {\n typedDependencies,\n createLcm\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog } from '../../factoriesNumber.js';\nexport var logDependencies = {\n typedDependencies,\n createLog\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog10 } from '../../factoriesNumber.js';\nexport var log10Dependencies = {\n typedDependencies,\n createLog10\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog1p } from '../../factoriesNumber.js';\nexport var log1pDependencies = {\n typedDependencies,\n createLog1p\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createLog2 } from '../../factoriesNumber.js';\nexport var log2Dependencies = {\n typedDependencies,\n createLog2\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createMod } from '../../factoriesNumber.js';\nexport var modDependencies = {\n typedDependencies,\n createMod\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createNthRoot } from '../../factoriesNumber.js';\nexport var nthRootDependencies = {\n typedDependencies,\n createNthRoot\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { createPi } from '../../factoriesNumber.js';\nexport var piDependencies = {\n createPi\n};","/**\n * THIS FILE IS AUTO-GENERATED\n * DON'T MAKE CHANGES HERE\n */\nimport { typedDependencies } from './dependenciesTyped.generated.js';\nimport { createSign } from '../../factoriesNumber.js';\nexport var signDependencies = {\n typedDependencies,\n createSign\n};","function E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n","import Emitter from 'tiny-emitter';\n\n/**\n * Extend given object with emitter functions `on`, `off`, `once`, `emit`\n * @param {Object} obj\n * @return {Object} obj\n */\nexport function mixin(obj) {\n // create event emitter\n var emitter = new Emitter();\n\n // bind methods to obj (we don't want to expose the emitter.e Array...)\n obj.on = emitter.on.bind(emitter);\n obj.off = emitter.off.bind(emitter);\n obj.once = emitter.once.bind(emitter);\n obj.emit = emitter.emit.bind(emitter);\n return obj;\n}","import { isBigNumber, isComplex, isFraction, isMatrix, isObject, isUnit } from '../../utils/is.js';\nimport { isFactory, stripOptionalNotation } from '../../utils/factory.js';\nimport { hasOwnProperty, lazy } from '../../utils/object.js';\nimport { ArgumentsError } from '../../error/ArgumentsError.js';\nexport function importFactory(typed, load, math, importedFactories) {\n /**\n * Import functions from an object or a module.\n *\n * This function is only available on a mathjs instance created using `create`.\n *\n * Syntax:\n *\n * math.import(functions)\n * math.import(functions, options)\n *\n * Where:\n *\n * - `functions: Object`\n * An object with functions or factories to be imported.\n * - `options: Object` An object with import options. Available options:\n * - `override: boolean`\n * If true, existing functions will be overwritten. False by default.\n * - `silent: boolean`\n * If true, the function will not throw errors on duplicates or invalid\n * types. False by default.\n * - `wrap: boolean`\n * If true, the functions will be wrapped in a wrapper function\n * which converts data types like Matrix to primitive data types like Array.\n * The wrapper is needed when extending math.js with libraries which do not\n * support these data type. False by default.\n *\n * Examples:\n *\n * import { create, all } from 'mathjs'\n * import * as numbers from 'numbers'\n *\n * // create a mathjs instance\n * const math = create(all)\n *\n * // define new functions and variables\n * math.import({\n * myvalue: 42,\n * hello: function (name) {\n * return 'hello, ' + name + '!'\n * }\n * })\n *\n * // use the imported function and variable\n * math.myvalue * 2 // 84\n * math.hello('user') // 'hello, user!'\n *\n * // import the npm module 'numbers'\n * // (must be installed first with `npm install numbers`)\n * math.import(numbers, {wrap: true})\n *\n * math.fibonacci(7) // returns 13\n *\n * History:\n *\n * v0.2 Created\n * v0.7 Changed second parameter to an options object\n * v2 Dropped support for direct import of a module by name\n * v14.2 Add facility for specifying the former name of an import\n *\n * @param {Object | Array} functions Object with functions to be imported.\n * @param {Object} [options] Import options.\n */\n function mathImport(functions, options) {\n var num = arguments.length;\n if (num !== 1 && num !== 2) {\n throw new ArgumentsError('import', num, 1, 2);\n }\n if (!options) {\n options = {};\n }\n function flattenImports(flatValues, value, name) {\n if (Array.isArray(value)) {\n value.forEach(item => flattenImports(flatValues, item));\n } else if (isObject(value) || isModule(value)) {\n for (var _name in value) {\n if (hasOwnProperty(value, _name)) {\n flattenImports(flatValues, value[_name], _name);\n }\n }\n } else if (isFactory(value) || name !== undefined) {\n var flatName = isFactory(value) ? isTransformFunctionFactory(value) ? value.fn + '.transform' // TODO: this is ugly\n : value.fn : name;\n\n // we allow importing the same function twice if it points to the same implementation\n if (hasOwnProperty(flatValues, flatName) && flatValues[flatName] !== value && !options.silent) {\n throw new Error('Cannot import \"' + flatName + '\" twice');\n }\n flatValues[flatName] = value;\n } else {\n if (!options.silent) {\n throw new TypeError('Factory, Object, or Array expected');\n }\n }\n }\n var flatValues = {};\n flattenImports(flatValues, functions);\n for (var name in flatValues) {\n if (hasOwnProperty(flatValues, name)) {\n // console.log('import', name)\n var value = flatValues[name];\n if (isFactory(value)) {\n // we ignore name here and enforce the name of the factory\n // maybe at some point we do want to allow overriding it\n // in that case we can implement an option overrideFactoryNames: true\n _importFactory(value, options);\n } else if (isSupportedType(value)) {\n _import(name, value, options);\n } else {\n if (!options.silent) {\n throw new TypeError('Factory, Object, or Array expected');\n }\n }\n }\n }\n }\n\n /**\n * Add a property to the math namespace\n * @param {string} name\n * @param {*} value\n * @param {Object} options See import for a description of the options\n * @private\n */\n function _import(name, value, options) {\n var _math$Unit;\n // TODO: refactor this function, it's to complicated and contains duplicate code\n if (options.wrap && typeof value === 'function') {\n // create a wrapper around the function\n value = _wrap(value);\n }\n\n // turn a plain function with a typed-function signature into a typed-function\n if (hasTypedFunctionSignature(value)) {\n value = typed(name, {\n [value.signature]: value\n });\n }\n if (typed.isTypedFunction(math[name]) && typed.isTypedFunction(value)) {\n if (options.override) {\n // give the typed function the right name\n value = typed(name, value.signatures);\n } else {\n // merge the existing and typed function\n value = typed(math[name], value);\n }\n math[name] = value;\n delete importedFactories[name];\n _importTransform(name, value);\n math.emit('import', name, function resolver() {\n return value;\n });\n return;\n }\n var isDefined = math[name] !== undefined;\n var isValuelessUnit = (_math$Unit = math.Unit) === null || _math$Unit === void 0 ? void 0 : _math$Unit.isValuelessUnit(name);\n if (!isDefined && !isValuelessUnit || options.override) {\n math[name] = value;\n delete importedFactories[name];\n _importTransform(name, value);\n math.emit('import', name, function resolver() {\n return value;\n });\n return;\n }\n if (!options.silent) {\n throw new Error('Cannot import \"' + name + '\": already exists');\n }\n }\n function _importTransform(name, value) {\n if (value && typeof value.transform === 'function') {\n math.expression.transform[name] = value.transform;\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = value.transform;\n }\n } else {\n // remove existing transform\n delete math.expression.transform[name];\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = value;\n }\n }\n }\n function _deleteTransform(name) {\n delete math.expression.transform[name];\n if (allowedInExpressions(name)) {\n math.expression.mathWithTransform[name] = math[name];\n } else {\n delete math.expression.mathWithTransform[name];\n }\n }\n\n /**\n * Create a wrapper a round an function which converts the arguments\n * to their primitive values (like convert a Matrix to Array)\n * @param {Function} fn\n * @return {Function} Returns the wrapped function\n * @private\n */\n function _wrap(fn) {\n var wrapper = function wrapper() {\n var args = [];\n for (var i = 0, len = arguments.length; i < len; i++) {\n var arg = arguments[i];\n args[i] = arg && arg.valueOf();\n }\n return fn.apply(math, args);\n };\n if (fn.transform) {\n wrapper.transform = fn.transform;\n }\n return wrapper;\n }\n\n /**\n * Import an instance of a factory into math.js\n * @param {function(scope: object)} factory\n * @param {Object} options See import for a description of the options\n * @param {string} [name=factory.name] Optional custom name\n * @private\n */\n function _importFactory(factory, options) {\n var _factory$meta$formerl, _factory$meta;\n var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : factory.fn;\n if (name.includes('.')) {\n throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));\n }\n var namespace = isTransformFunctionFactory(factory) ? math.expression.transform : math;\n var existingTransform = name in math.expression.transform;\n var existing = hasOwnProperty(namespace, name) ? namespace[name] : undefined;\n var resolver = function resolver() {\n // collect all dependencies, handle finding both functions and classes and other special cases\n var dependencies = {};\n factory.dependencies.map(stripOptionalNotation).forEach(dependency => {\n if (dependency.includes('.')) {\n throw new Error('Factory dependency should not contain a nested path. ' + 'Name: ' + JSON.stringify(dependency));\n }\n if (dependency === 'math') {\n dependencies.math = math;\n } else if (dependency === 'mathWithTransform') {\n dependencies.mathWithTransform = math.expression.mathWithTransform;\n } else if (dependency === 'classes') {\n // special case for json reviver\n dependencies.classes = math;\n } else {\n dependencies[dependency] = math[dependency];\n }\n });\n var instance = /* #__PURE__ */factory(dependencies);\n if (instance && typeof instance.transform === 'function') {\n throw new Error('Transforms cannot be attached to factory functions. ' + 'Please create a separate function for it with export const path = \"expression.transform\"');\n }\n if (existing === undefined || options.override) {\n return instance;\n }\n if (typed.isTypedFunction(existing) && typed.isTypedFunction(instance)) {\n // merge the existing and new typed function\n return typed(existing, instance);\n }\n if (options.silent) {\n // keep existing, ignore imported function\n return existing;\n } else {\n throw new Error('Cannot import \"' + name + '\": already exists');\n }\n };\n var former = (_factory$meta$formerl = (_factory$meta = factory.meta) === null || _factory$meta === void 0 ? void 0 : _factory$meta.formerly) !== null && _factory$meta$formerl !== void 0 ? _factory$meta$formerl : '';\n var needsTransform = isTransformFunctionFactory(factory) || factoryAllowedInExpressions(factory);\n var withTransform = math.expression.mathWithTransform;\n\n // TODO: add unit test with non-lazy factory\n if (!factory.meta || factory.meta.lazy !== false) {\n lazy(namespace, name, resolver);\n if (former) lazy(namespace, former, resolver);\n\n // FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)\n if (existing && existingTransform) {\n _deleteTransform(name);\n if (former) _deleteTransform(former);\n } else {\n if (needsTransform) {\n lazy(withTransform, name, () => namespace[name]);\n if (former) lazy(withTransform, former, () => namespace[name]);\n }\n }\n } else {\n namespace[name] = resolver();\n if (former) namespace[former] = namespace[name];\n\n // FIXME: remove the `if (existing &&` condition again. Can we make sure subset is loaded before subset.transform? (Name collision, and no dependencies between the two)\n if (existing && existingTransform) {\n _deleteTransform(name);\n if (former) _deleteTransform(former);\n } else {\n if (needsTransform) {\n lazy(withTransform, name, () => namespace[name]);\n if (former) lazy(withTransform, former, () => namespace[name]);\n }\n }\n }\n\n // TODO: improve factories, store a list with imports instead which can be re-played\n importedFactories[name] = factory;\n math.emit('import', name, resolver);\n }\n\n /**\n * Check whether given object is a type which can be imported\n * @param {Function | number | string | boolean | null | Unit | Complex} object\n * @return {boolean}\n * @private\n */\n function isSupportedType(object) {\n return typeof object === 'function' || typeof object === 'number' || typeof object === 'string' || typeof object === 'boolean' || object === null || isUnit(object) || isComplex(object) || isBigNumber(object) || isFraction(object) || isMatrix(object) || Array.isArray(object);\n }\n function isModule(object) {\n return typeof object === 'object' && object[Symbol.toStringTag] === 'Module';\n }\n function hasTypedFunctionSignature(fn) {\n return typeof fn === 'function' && typeof fn.signature === 'string';\n }\n function allowedInExpressions(name) {\n return !hasOwnProperty(unsafe, name);\n }\n function factoryAllowedInExpressions(factory) {\n return !factory.fn.includes('.') &&\n // FIXME: make checking on path redundant, check on meta data instead\n !hasOwnProperty(unsafe, factory.fn) && (!factory.meta || !factory.meta.isClass);\n }\n function isTransformFunctionFactory(factory) {\n return factory !== undefined && factory.meta !== undefined && factory.meta.isTransformFunction === true || false;\n }\n\n // namespaces and functions not available in the parser for safety reasons\n var unsafe = {\n expression: true,\n type: true,\n docs: true,\n error: true,\n json: true,\n chain: true // chain method not supported. Note that there is a unit chain too.\n };\n return mathImport;\n}","import _extends from \"@babel/runtime/helpers/extends\";\nimport typedFunction from 'typed-function';\nimport { ArgumentsError } from '../error/ArgumentsError.js';\nimport { DimensionError } from '../error/DimensionError.js';\nimport { IndexError } from '../error/IndexError.js';\nimport { factory, isFactory } from '../utils/factory.js';\nimport { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigInt, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMap, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isObjectWrappingMap, isOperatorNode, isParenthesisNode, isPartitionedMap, isRange, isRangeNode, isRegExp, isRelationalNode, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../utils/is.js';\nimport { deepFlatten, isLegacyFactory } from '../utils/object.js';\nimport * as emitter from './../utils/emitter.js';\nimport { DEFAULT_CONFIG } from './config.js';\nimport { configFactory } from './function/config.js';\nimport { importFactory } from './function/import.js';\n\n/**\n * Create a mathjs instance from given factory functions and optionally config\n *\n * Usage:\n *\n * const mathjs1 = create({ createAdd, createMultiply, ...})\n * const config = { number: 'BigNumber' }\n * const mathjs2 = create(all, config)\n *\n * @param {Object} [factories] An object with factory functions\n * The object can contain nested objects,\n * all nested objects will be flattened.\n * @param {Object} [config] Available options:\n * {number} relTol\n * Minimum relative difference between two\n * compared values, used by all comparison functions.\n * {number} absTol\n * Minimum absolute difference between two\n * compared values, used by all comparison functions.\n * {string} matrix\n * A string 'Matrix' (default) or 'Array'.\n * {string} number\n * A string 'number' (default), 'BigNumber', or 'Fraction'\n * {number} precision\n * The number of significant digits for BigNumbers.\n * Not applicable for Numbers.\n * {boolean} predictable\n * Predictable output type of functions. When true,\n * output type depends only on the input types. When\n * false (default), output type can vary depending\n * on input values. For example `math.sqrt(-4)`\n * returns `complex('2i')` when predictable is false, and\n * returns `NaN` when true.\n * {string} randomSeed\n * Random seed for seeded pseudo random number generator.\n * Set to null to randomly seed.\n * @returns {Object} Returns a bare-bone math.js instance containing\n * functions:\n * - `import` to add new functions\n * - `config` to change configuration\n * - `on`, `off`, `once`, `emit` for events\n */\nexport function create(factories, config) {\n var configInternal = _extends({}, DEFAULT_CONFIG, config);\n\n // simple test for ES5 support\n if (typeof Object.create !== 'function') {\n throw new Error('ES5 not supported by this JavaScript engine. ' + 'Please load the es5-shim and es5-sham library for compatibility.');\n }\n\n // create the mathjs instance\n var math = emitter.mixin({\n // only here for backward compatibility for legacy factory functions\n isNumber,\n isComplex,\n isBigNumber,\n isBigInt,\n isFraction,\n isUnit,\n isString,\n isArray,\n isMatrix,\n isCollection,\n isDenseMatrix,\n isSparseMatrix,\n isRange,\n isIndex,\n isBoolean,\n isResultSet,\n isHelp,\n isFunction,\n isDate,\n isRegExp,\n isObject,\n isMap,\n isPartitionedMap,\n isObjectWrappingMap,\n isNull,\n isUndefined,\n isAccessorNode,\n isArrayNode,\n isAssignmentNode,\n isBlockNode,\n isConditionalNode,\n isConstantNode,\n isFunctionAssignmentNode,\n isFunctionNode,\n isIndexNode,\n isNode,\n isObjectNode,\n isOperatorNode,\n isParenthesisNode,\n isRangeNode,\n isRelationalNode,\n isSymbolNode,\n isChain\n });\n\n // load config function and apply provided config\n math.config = configFactory(configInternal, math.emit);\n math.expression = {\n transform: {},\n mathWithTransform: {\n config: math.config\n }\n };\n\n // cached factories and instances used by function load\n var legacyFactories = [];\n var legacyInstances = [];\n\n /**\n * Load a function or data type from a factory.\n * If the function or data type already exists, the existing instance is\n * returned.\n * @param {Function} factory\n * @returns {*}\n */\n function load(factory) {\n if (isFactory(factory)) {\n return factory(math);\n }\n var firstProperty = factory[Object.keys(factory)[0]];\n if (isFactory(firstProperty)) {\n return firstProperty(math);\n }\n if (!isLegacyFactory(factory)) {\n console.warn('Factory object with properties `type`, `name`, and `factory` expected', factory);\n throw new Error('Factory object with properties `type`, `name`, and `factory` expected');\n }\n var index = legacyFactories.indexOf(factory);\n var instance;\n if (index === -1) {\n // doesn't yet exist\n if (factory.math === true) {\n // pass with math namespace\n instance = factory.factory(math.type, configInternal, load, math.typed, math);\n } else {\n instance = factory.factory(math.type, configInternal, load, math.typed);\n }\n\n // append to the cache\n legacyFactories.push(factory);\n legacyInstances.push(instance);\n } else {\n // already existing function, return the cached instance\n instance = legacyInstances[index];\n }\n return instance;\n }\n var importedFactories = {};\n\n // load the import function\n function lazyTyped() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return math.typed.apply(math.typed, args);\n }\n lazyTyped.isTypedFunction = typedFunction.isTypedFunction;\n var internalImport = importFactory(lazyTyped, load, math, importedFactories);\n math.import = internalImport;\n\n // listen for changes in config, import all functions again when changed\n // TODO: move this listener into the import function?\n math.on('config', () => {\n Object.values(importedFactories).forEach(factory => {\n if (factory && factory.meta && factory.meta.recreateOnConfigChange) {\n // FIXME: only re-create when the current instance is the same as was initially created\n // FIXME: delete the functions/constants before importing them again?\n internalImport(factory, {\n override: true\n });\n }\n });\n });\n\n // the create function exposed on the mathjs instance is bound to\n // the factory functions passed before\n math.create = create.bind(null, factories);\n\n // export factory function\n math.factory = factory;\n\n // import the factory functions like createAdd as an array instead of object,\n // else they will get a different naming (`createAdd` instead of `add`).\n math.import(Object.values(deepFlatten(factories)));\n math.ArgumentsError = ArgumentsError;\n math.DimensionError = DimensionError;\n math.IndexError = IndexError;\n return math;\n}","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { getElement } from \"./getElement.ts\";\n\nexport const appendAnswerElement = (element: HTMLElement | string | number): void => {\n const results = getElement(\"results\");\n\n // ./searx/templates/elements/answers.html\n let answers = getElement(\"answers\", { assert: false });\n if (!answers) {\n // what is this?\n const answersTitle = document.createElement(\"h4\");\n answersTitle.setAttribute(\"class\", \"title\");\n answersTitle.setAttribute(\"id\", \"answers-title\");\n answersTitle.textContent = \"Answers : \";\n\n answers = document.createElement(\"div\");\n answers.setAttribute(\"id\", \"answers\");\n answers.setAttribute(\"role\", \"complementary\");\n answers.setAttribute(\"aria-labelledby\", \"answers-title\");\n answers.appendChild(answersTitle);\n }\n\n if (!(element instanceof HTMLElement)) {\n const span = document.createElement(\"span\");\n span.innerHTML = element.toString();\n // biome-ignore lint/style/noParameterAssign: TODO\n element = span;\n }\n\n answers.appendChild(element);\n\n results.insertAdjacentElement(\"afterbegin\", answers);\n};\n","// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport {\n absDependencies,\n addDependencies,\n create,\n divideDependencies,\n eDependencies,\n evaluateDependencies,\n expDependencies,\n factorialDependencies,\n gcdDependencies,\n lcmDependencies,\n log1pDependencies,\n log2Dependencies,\n log10Dependencies,\n logDependencies,\n modDependencies,\n multiplyDependencies,\n nthRootDependencies,\n piDependencies,\n powDependencies,\n roundDependencies,\n signDependencies,\n sqrtDependencies,\n subtractDependencies\n} from \"mathjs/number\";\nimport { Plugin } from \"../Plugin.ts\";\nimport { appendAnswerElement } from \"../util/appendAnswerElement.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\n/**\n * Parses and solves mathematical expressions. Can do basic arithmetic and\n * evaluate some functions.\n *\n * @example\n * \"(3 + 5) / 2\" = \"4\"\n * \"e ^ 2 + pi\" = \"10.530648752520442\"\n * \"gcd(48, 18) + lcm(4, 5)\" = \"26\"\n *\n * @remarks\n * Depends on `mathjs` library.\n */\nexport default class Calculator extends Plugin {\n public constructor() {\n super(\"calculator\");\n }\n\n /**\n * @remarks\n * Compare bundle size after adding or removing features.\n */\n private static readonly math = create({\n ...absDependencies,\n ...addDependencies,\n ...divideDependencies,\n ...eDependencies,\n ...evaluateDependencies,\n ...expDependencies,\n ...factorialDependencies,\n ...gcdDependencies,\n ...lcmDependencies,\n ...log10Dependencies,\n ...log1pDependencies,\n ...log2Dependencies,\n ...logDependencies,\n ...modDependencies,\n ...multiplyDependencies,\n ...nthRootDependencies,\n ...piDependencies,\n ...powDependencies,\n ...roundDependencies,\n ...signDependencies,\n ...sqrtDependencies,\n ...subtractDependencies\n });\n\n protected async run(): Promise {\n const searchInput = getElement(\"q\");\n const node = Calculator.math.parse(searchInput.value);\n\n try {\n return `${node.toString()} = ${node.evaluate()}`;\n } catch {\n // not a compatible math expression\n return;\n }\n }\n\n protected async post(result: string): Promise {\n appendAnswerElement(result);\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42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KAAM,SACN,KAAM,EACP,CAAE,CACD,KAAM,QACN,KAAM,GACP,CAAE,CACD,KAAM,QACN,KAAM,EACP,CAAE,CACD,KAAM,SACN,KAAM,EACP,CAAE,CACD,KAAM,cACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,EACP,CAAE,CACD,KAAM,QACN,KAAM,GACP,CAAE,CACD,KAAM,QACN,KAAM,GACP,CAAE,CACD,KAAM,UACN,KAAM,EACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,GACP,CAAE,CACD,KAAM,WACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,GACP,CAAE,CACD,KAAM,SACN,KAAM,GACP,CAAE,CACD,KAAM,OACN,KAAM,EACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,EACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,iBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,kBACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,EACP,CAAE,CACD,KAAM,eACN,KAAM,GACP,CAAE,CACD,KAAM,yBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,EACP,CAAE,CACD,KAAM,OACN,KAAM,EACP,CAAE,CACD,KAAM,aACN,KAAM,GACP,CAAE,CACD,KAAM,eACN,KAAM,GACP,CAAE,CACD,KAAM,kBACN,KAAM,GACP,CAAE,CACD,KAAM,YACN,KAAM,GACP,CAAE,CACD,KAAM,iBACN,KAAM,GACP,CAAE,CACD,KAAM,aACN,KAAM,EACP,CAAE,CACD,KAAM,MACN,KAAM,EACP,CAAE,CACD,KAAM,SACN,KAAM,GACP,CACA,CAAC,CACF,EAAM,eAAe,CAAC,CACpB,KAAM,SACN,GAAI,YACJ,QAAS,SAAiB,EAAG,CAM3B,GALK,GACH,GAAiB,EAAE,CAIjB,GAAO,EAAE,C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GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACJ,CAAC,CAEF,MAAgB,KAAmC,CACjD,IAAM,EAAc,EAA6B,IAAI,CAC/C,EAAO,EAAW,KAAK,MAAM,EAAY,MAAM,CAErD,GAAI,CACF,MAAO,GAAG,EAAK,UAAU,CAAC,KAAK,EAAK,UAAU,QACxC,CAEN,QAIJ,MAAgB,KAAK,EAA+B,CAClD,GAAoB,EAAO"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/BnP4vIuG.min.js b/searx/static/themes/simple/chunk/BnP4vIuG.min.js deleted file mode 100644 index f63d8c7a2..000000000 --- a/searx/static/themes/simple/chunk/BnP4vIuG.min.js +++ /dev/null @@ -1,2 +0,0 @@ -import{n as e}from"../sxng-core.min.js";import{t}from"./chlzpS6K.min.js";var n=t(`search`),r=t(`q`),i=t(`clear_search`),a=window.matchMedia(`(max-width: 50em)`).matches,o=document.querySelector(`main`)?.id===`main_results`,s=Array.from(document.querySelectorAll(`#categories_container button.category`));r.value.length===0&&i.classList.add(`empty`),a||o||r.focus(),a&&e(`focus`,r,()=>{requestAnimationFrame(()=>{let e=r.value.length;r.setSelectionRange(e,e),r.scrollLeft=r.scrollWidth})}),e(`input`,r,()=>{i.classList.toggle(`empty`,r.value.length===0)}),e(`click`,i,e=>{e.preventDefault(),r.value=``,r.focus(),i.classList.add(`empty`)});for(let t of s)e(`click`,t,e=>{if(e.shiftKey){e.preventDefault(),t.classList.toggle(`selected`);return}for(let e of s)e.classList.toggle(`selected`,e===t)});if(document.querySelector(`div.search_filters`)){let t=document.getElementById(`safesearch`);t&&e(`change`,t,()=>n.submit());let r=document.getElementById(`time_range`);r&&e(`change`,r,()=>n.submit());let i=document.getElementById(`language`);i&&e(`change`,i,()=>n.submit())}e(`submit`,n,e=>{if(e.preventDefault(),s.length>0){let e=t(`selected-categories`);e.value=s.filter(e=>e.classList.contains(`selected`)).map(e=>e.name.replace(`category_`,``)).join(`,`)}n.submit()}); -//# sourceMappingURL=BnP4vIuG.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/CAKNRGBu.min.js b/searx/static/themes/simple/chunk/CAKNRGBu.min.js new file mode 100644 index 000000000..a642da376 --- /dev/null +++ b/searx/static/themes/simple/chunk/CAKNRGBu.min.js @@ -0,0 +1,2 @@ +import{t as e}from"./Cq566EWy.min.js";import{r as t,s as n}from"./Cs5Jkbkf.min.js";import{t as r}from"./DXl78Wnf.min.js";import{t as i}from"./vehLS1_D.min.js";var a=class extends e{constructor(){super(`infiniteScroll`)}async run(){let e=i(`results`).classList.contains(`only_template_images`),a=`article.result:last-child`,o=document.createElement(`div`);o.className=`loader`;let s=async i=>{let a=document.querySelector(`#search`);r(a);let s=document.querySelector(`#pagination form.next_page`);r(s);let c=a.getAttribute(`action`);if(!c)throw Error(`Form action not defined`);let l=document.querySelector(`#pagination`);r(l),l.replaceChildren(o);try{let n=await(await t(`POST`,c,{body:new FormData(s)})).text();if(!n)return;let r=new DOMParser().parseFromString(n,`text/html`),a=r.querySelectorAll(`#urls article`),o=r.querySelector(`#pagination`);document.querySelector(`#pagination`)?.remove();let l=document.querySelector(`#urls`);if(!l)throw Error(`URLs element not found`);a.length>0&&!e&&l.appendChild(document.createElement(`hr`)),l.append(...a),o&&(document.querySelector(`#results`)?.appendChild(o),i())}catch(e){console.error(`Error loading next page:`,e);let t=Object.assign(document.createElement(`div`),{textContent:n.translations?.error_loading_next_page??`Error loading next page`,className:`dialog-error`});t.setAttribute(`role`,`alert`),document.querySelector(`#pagination`)?.replaceChildren(t)}},c=new IntersectionObserver(async e=>{let[t]=e;t?.isIntersecting&&(c.unobserve(t.target),await s(()=>{let e=document.querySelector(a);e&&c.observe(e)}))},{rootMargin:`320px`}),l=document.querySelector(a);l&&c.observe(l)}async post(){}};export{a as default}; +//# sourceMappingURL=CAKNRGBu.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/Cx4rGXMm.min.js.map b/searx/static/themes/simple/chunk/CAKNRGBu.min.js.map similarity index 97% rename from searx/static/themes/simple/chunk/Cx4rGXMm.min.js.map rename to searx/static/themes/simple/chunk/CAKNRGBu.min.js.map index 7d329723b..2dd822960 100644 --- a/searx/static/themes/simple/chunk/Cx4rGXMm.min.js.map +++ b/searx/static/themes/simple/chunk/CAKNRGBu.min.js.map @@ -1 +1 @@ -{"version":3,"file":"Cx4rGXMm.min.js","names":[],"sources":["../../../../../client/simple/src/js/plugin/InfiniteScroll.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { Plugin } from \"../Plugin.ts\";\nimport { http, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\n/**\n * Automatically loads the next page when scrolling to bottom of the current page.\n */\nexport default class InfiniteScroll extends Plugin {\n public constructor() {\n super(\"infiniteScroll\");\n }\n\n protected async run(): Promise {\n const resultsElement = getElement(\"results\");\n\n const onlyImages: boolean = resultsElement.classList.contains(\"only_template_images\");\n const observedSelector = \"article.result:last-child\";\n\n const spinnerElement = document.createElement(\"div\");\n spinnerElement.className = \"loader\";\n\n const loadNextPage = async (callback: () => void): Promise => {\n const searchForm = document.querySelector(\"#search\");\n assertElement(searchForm);\n\n const form = document.querySelector(\"#pagination form.next_page\");\n assertElement(form);\n\n const action = searchForm.getAttribute(\"action\");\n if (!action) {\n throw new Error(\"Form action not defined\");\n }\n\n const paginationElement = document.querySelector(\"#pagination\");\n assertElement(paginationElement);\n\n paginationElement.replaceChildren(spinnerElement);\n\n try {\n const res = await http(\"POST\", action, { body: new FormData(form) });\n const nextPage = await res.text();\n if (!nextPage) return;\n\n const nextPageDoc = new DOMParser().parseFromString(nextPage, \"text/html\");\n const articleList = nextPageDoc.querySelectorAll(\"#urls article\");\n const nextPaginationElement = nextPageDoc.querySelector(\"#pagination\");\n\n document.querySelector(\"#pagination\")?.remove();\n\n const urlsElement = document.querySelector(\"#urls\");\n if (!urlsElement) {\n throw new Error(\"URLs element not found\");\n }\n\n if (articleList.length > 0 && !onlyImages) {\n // do not add
element when there are only images\n urlsElement.appendChild(document.createElement(\"hr\"));\n }\n\n urlsElement.append(...articleList);\n\n if (nextPaginationElement) {\n const results = document.querySelector(\"#results\");\n results?.appendChild(nextPaginationElement);\n callback();\n }\n } catch (error) {\n console.error(\"Error loading next page:\", error);\n\n const errorElement = Object.assign(document.createElement(\"div\"), {\n textContent: settings.translations?.error_loading_next_page ?? \"Error loading next page\",\n className: \"dialog-error\"\n });\n errorElement.setAttribute(\"role\", \"alert\");\n document.querySelector(\"#pagination\")?.replaceChildren(errorElement);\n }\n };\n\n const intersectionObserveOptions: IntersectionObserverInit = {\n rootMargin: \"320px\"\n };\n\n const observer: IntersectionObserver = new IntersectionObserver(async (entries: IntersectionObserverEntry[]) => {\n const [paginationEntry] = entries;\n\n if (paginationEntry?.isIntersecting) {\n observer.unobserve(paginationEntry.target);\n\n await loadNextPage(() => {\n const nextObservedElement = document.querySelector(observedSelector);\n if (nextObservedElement) {\n observer.observe(nextObservedElement);\n }\n });\n }\n }, intersectionObserveOptions);\n\n const initialObservedElement: HTMLElement | null = document.querySelector(observedSelector);\n if (initialObservedElement) {\n observer.observe(initialObservedElement);\n }\n }\n\n protected async post(): Promise {\n // noop\n }\n}\n"],"mappings":"kIAUA,IAAqB,EAArB,cAA4C,CAAO,CACjD,aAAqB,CACnB,MAAM,iBAAiB,CAGzB,MAAgB,KAAqB,CAGnC,IAAM,EAFiB,EAAwB,UAAU,CAEd,UAAU,SAAS,uBAAuB,CAC/E,EAAmB,4BAEnB,EAAiB,SAAS,cAAc,MAAM,CACpD,EAAe,UAAY,SAE3B,IAAM,EAAe,KAAO,IAAwC,CAClE,IAAM,EAAa,SAAS,cAA+B,UAAU,CACrE,EAAc,EAAW,CAEzB,IAAM,EAAO,SAAS,cAA+B,6BAA6B,CAClF,EAAc,EAAK,CAEnB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AiB,CACpG,GACF,EAAS,QAAQ,EAAuB,CAI5C,MAAgB,MAAsB"} \ No newline at end of file +{"version":3,"file":"CAKNRGBu.min.js","names":[],"sources":["../../../../../client/simple/src/js/plugin/InfiniteScroll.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { Plugin } from \"../Plugin.ts\";\nimport { http, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\nimport { getElement } from \"../util/getElement.ts\";\n\n/**\n * Automatically loads the next page when scrolling to bottom of the current page.\n */\nexport default class InfiniteScroll extends Plugin {\n public constructor() {\n super(\"infiniteScroll\");\n }\n\n protected async run(): Promise {\n const resultsElement = getElement(\"results\");\n\n const onlyImages: boolean = resultsElement.classList.contains(\"only_template_images\");\n const observedSelector = \"article.result:last-child\";\n\n const spinnerElement = document.createElement(\"div\");\n spinnerElement.className = \"loader\";\n\n const loadNextPage = async (callback: () => void): Promise => {\n const searchForm = document.querySelector(\"#search\");\n assertElement(searchForm);\n\n const form = document.querySelector(\"#pagination form.next_page\");\n assertElement(form);\n\n const action = searchForm.getAttribute(\"action\");\n if (!action) {\n throw new Error(\"Form action not defined\");\n }\n\n const paginationElement = document.querySelector(\"#pagination\");\n assertElement(paginationElement);\n\n paginationElement.replaceChildren(spinnerElement);\n\n try {\n const res = await http(\"POST\", action, { body: new FormData(form) });\n const nextPage = await res.text();\n if (!nextPage) return;\n\n const nextPageDoc = new DOMParser().parseFromString(nextPage, \"text/html\");\n const articleList = nextPageDoc.querySelectorAll(\"#urls article\");\n const nextPaginationElement = nextPageDoc.querySelector(\"#pagination\");\n\n document.querySelector(\"#pagination\")?.remove();\n\n const urlsElement = document.querySelector(\"#urls\");\n if (!urlsElement) {\n throw new Error(\"URLs element not found\");\n }\n\n if (articleList.length > 0 && !onlyImages) {\n // do not add
element when there are only images\n urlsElement.appendChild(document.createElement(\"hr\"));\n }\n\n urlsElement.append(...articleList);\n\n if (nextPaginationElement) {\n const results = document.querySelector(\"#results\");\n results?.appendChild(nextPaginationElement);\n callback();\n }\n } catch (error) {\n console.error(\"Error loading next page:\", error);\n\n const errorElement = Object.assign(document.createElement(\"div\"), {\n textContent: settings.translations?.error_loading_next_page ?? \"Error loading next page\",\n className: \"dialog-error\"\n });\n errorElement.setAttribute(\"role\", \"alert\");\n document.querySelector(\"#pagination\")?.replaceChildren(errorElement);\n }\n };\n\n const intersectionObserveOptions: IntersectionObserverInit = {\n rootMargin: \"320px\"\n };\n\n const observer: IntersectionObserver = new IntersectionObserver(async (entries: IntersectionObserverEntry[]) => {\n const [paginationEntry] = entries;\n\n if (paginationEntry?.isIntersecting) {\n observer.unobserve(paginationEntry.target);\n\n await loadNextPage(() => {\n const nextObservedElement = document.querySelector(observedSelector);\n if (nextObservedElement) {\n observer.observe(nextObservedElement);\n }\n });\n }\n }, intersectionObserveOptions);\n\n const initialObservedElement: HTMLElement | null = document.querySelector(observedSelector);\n if (initialObservedElement) {\n observer.observe(initialObservedElement);\n }\n }\n\n protected async post(): Promise {\n // noop\n }\n}\n"],"mappings":"+JAUA,IAAqB,EAArB,cAA4C,CAAO,CACjD,aAAqB,CACnB,MAAM,iBAAiB,CAGzB,MAAgB,KAAqB,CAGnC,IAAM,EAFiB,EAAwB,UAAU,CAEd,UAAU,SAAS,uBAAuB,CAC/E,EAAmB,4BAEnB,EAAiB,SAAS,cAAc,MAAM,CACpD,EAAe,UAAY,SAE3B,IAAM,EAAe,KAAO,IAAwC,CAClE,IAAM,EAAa,SAAS,cAA+B,UAAU,CACrE,EAAc,EAAW,CAEzB,IAAM,EAAO,SAAS,cAA+B,6BAA6B,CAClF,EAAc,EAAK,CAEnB,IAAM,EAAS,EAAW,aAAa,SAAS,CAChD,GAAI,CAAC,EACH,MAAU,MAAM,0BAA0B,CAG5C,IAAM,EAAoB,SAAS,cAA2B,cAAc,CAC5E,EAAc,EAAkB,CAEhC,EAAkB,gBAAgB,EAAe,CAEjD,GAAI,CAEF,IAAM,EAAW,MADL,MAAM,EAAK,OAAQ,EAAQ,CAAE,KAAM,IAAI,SAAS,EAAK,CAAE,CAAC,EACzC,MAAM,CACjC,GAAI,CAAC,EAAU,OAEf,IAAM,EAAc,IAAI,WAAW,CAAC,gBAAgB,EAAU,YAAY,CACpE,EAAc,EAAY,iBAA8B,gBAAgB,CACxE,EAAwB,EAAY,cAA2B,cAAc,CAEnF,SAAS,cAAc,cAAc,EAAE,QAAQ,CAE/C,IAAM,EAAc,SAAS,cAA2B,QAAQ,CAChE,GAAI,CAAC,EACH,MAAU,MAAM,yBAAyB,CAGvC,EAAY,OAAS,GAAK,CAAC,GAE7B,EAAY,YAAY,SAAS,cAAc,KAAK,CAAC,CAGvD,EAAY,OAAO,GAAG,EAAY,CAE9B,IACc,SAAS,cAA2B,WAAW,EACtD,YAAY,EAAsB,CAC3C,GAAU,QAEL,EAAO,CACd,QAAQ,MAAM,2BAA4B,EAAM,CAEhD,IAAM,EAAe,OAAO,OAAO,SAAS,cAAc,MAAM,CAAE,CAChE,YAAa,EAAS,cAAc,yBAA2B,0BAC/D,UAAW,eACZ,CAAC,CACF,EAAa,aAAa,OAAQ,QAAQ,CAC1C,SAAS,cAAc,cAAc,EAAE,gBAAgB,EAAa,GAQlE,EAAiC,IAAI,qBAAqB,KAAO,IAAyC,CAC9G,GAAM,CAAC,GAAmB,EAEtB,GAAiB,iBACnB,EAAS,UAAU,EAAgB,OAAO,CAE1C,MAAM,MAAmB,CACvB,IAAM,EAAsB,SAAS,cAA2B,EAAiB,CAC7E,GACF,EAAS,QAAQ,EAAoB,EAEvC,GAfuD,CAC3D,WAAY,QACb,CAe6B,CAExB,EAA6C,SAAS,cAA2B,EAAiB,CACpG,GACF,EAAS,QAAQ,EAAuB,CAI5C,MAAgB,MAAsB"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/CCrWrjxi.min.js b/searx/static/themes/simple/chunk/CCrWrjxi.min.js new file mode 100644 index 000000000..1cec51257 --- /dev/null +++ b/searx/static/themes/simple/chunk/CCrWrjxi.min.js @@ -0,0 +1,2 @@ +import{a as e,i as t,s as n}from"./Cs5Jkbkf.min.js";import{t as r}from"./DXl78Wnf.min.js";var i={Escape:{key:`ESC`,fun:e=>f(e),des:`remove focus from the focused input`,cat:`Control`},c:{key:`c`,fun:()=>S(),des:`copy url of the selected result to the clipboard`,cat:`Results`},h:{key:`h`,fun:()=>x(o),des:`toggle help window`,cat:`Other`},i:{key:`i`,fun:()=>v(),des:`focus on the search input`,cat:`Control`},n:{key:`n`,fun:()=>m(),des:`go to next page`,cat:`Results`},o:{key:`o`,fun:()=>y(!1),des:`open search result`,cat:`Results`},p:{key:`p`,fun:()=>h(),des:`go to previous page`,cat:`Results`},r:{key:`r`,fun:()=>d(),des:`reload page from the server`,cat:`Control`},t:{key:`t`,fun:()=>y(!0),des:`open the result in a new tab`,cat:`Results`}},a={default:{ArrowLeft:{key:`←`,fun:()=>u(`up`)(),des:`select previous search result`,cat:`Results`},ArrowRight:{key:`→`,fun:()=>u(`down`)(),des:`select next search result`,cat:`Results`},...i},vim:{b:{key:`b`,fun:()=>g(-window.innerHeight),des:`scroll one page up`,cat:`Navigation`},d:{key:`d`,fun:()=>g(window.innerHeight/2),des:`scroll half a page down`,cat:`Navigation`},f:{key:`f`,fun:()=>g(window.innerHeight),des:`scroll one page down`,cat:`Navigation`},g:{key:`g`,fun:()=>_(-document.body.scrollHeight,`top`),des:`scroll to the top of the page`,cat:`Navigation`},j:{key:`j`,fun:()=>u(`down`)(),des:`select next search result`,cat:`Results`},k:{key:`k`,fun:()=>u(`up`)(),des:`select previous search result`,cat:`Results`},u:{key:`u`,fun:()=>g(-window.innerHeight/2),des:`scroll half a page up`,cat:`Navigation`},v:{key:`v`,fun:()=>_(document.body.scrollHeight,`bottom`),des:`scroll to the bottom of the page`,cat:`Navigation`},y:{key:`y`,fun:()=>S(),des:`copy url of the selected result to the clipboard`,cat:`Results`},...i}},o=n.hotkeys&&n.hotkeys in a?a[n.hotkeys]:a.default,s=e=>(e?.closest(`.detail, .result`))?.classList.contains(`detail`)??!1,c=e=>e?.closest(`.result`)??void 0,l=e=>e?.classList.contains(`result-images`)??!1,u=t=>(n,r)=>{let i=t,a=document.querySelector(`.result[data-vim-selected]`);if(!a){if(a=document.querySelector(`.result`),!a)return;(t===`down`||t===`up`)&&(i=a)}let o=Array.from(document.querySelectorAll(`.result`)),s;if(typeof i==`string`)switch(i){case`visible`:{let e=document.documentElement.scrollTop||document.body.scrollTop,t=e+document.documentElement.clientHeight;for(let n of o){let r=n.offsetTop;if(r+n.clientHeight<=t&&r>e){s=n;break}}break}case`down`:s=o[o.indexOf(a)+1]||a;break;case`up`:s=o[o.indexOf(a)-1]||a;break;case`bottom`:s=o.at(-1);break;default:[s]=o}else s=i;s&&(a.removeAttribute(`data-vim-selected`),s.setAttribute(`data-vim-selected`,`true`),r||(s.querySelector(`h3 a`)||s.querySelector(`a`))?.focus(),n||e.scrollPageToSelected?.())},d=()=>{document.location.reload()},f=t=>{let n=t.target?.tagName?.toLowerCase();document.activeElement&&(n===`input`||n===`select`||n===`textarea`)?document.activeElement.blur():e.closeDetail?.()},p=e=>{let t=document.querySelector(e);t&&t.click()},m=()=>{p(`nav#pagination .next_page button[type="submit"]`)},h=()=>{p(`nav#pagination .previous_page button[type="submit"]`)};e.scrollPageToSelected=()=>{let e=document.querySelector(`.result[data-vim-selected]`);if(!e)return;let t=document.documentElement.scrollTop||document.body.scrollTop,n=document.documentElement.clientHeight,r=e.offsetTop,i=r+e.clientHeight;if(!e.previousElementSibling&&ir-120?window.scroll(window.scrollX,r-120):t+n{window.scrollBy(0,e),u(`visible`)()},_=(e,t)=>{window.scrollTo(0,e),u(t)()},v=()=>{window.scrollTo(0,0);let e=document.querySelector(`#q`);if(e&&(e.focus(),e.setSelectionRange)){let t=e.value.length;e.setSelectionRange(t,t)}},y=e=>{let t=document.querySelector(`.result[data-vim-selected] h3 a`);if(t||=document.querySelector(`.result[data-vim-selected] > a`),!t)return;let n=t.getAttribute(`href`);n&&(e?window.open(n):window.location.href=n)},b=(e,t)=>{let n={};for(let e of Object.values(t)){let{cat:t}=e;n[t]??=[],n[t].push(e)}let r=Object.keys(n).sort((e,t)=>(n[t]?.length??0)-(n[e]?.length??0)),i=`×`;i+=`

How to navigate SearXNG with hotkeys

`,i+=``;for(let[e,t]of r.entries()){let a=n[t];if(!a||a.length===0)continue;let o=e%2==0,s=e===r.length-1;o&&(i+=``),i+=``,(!o||s)&&(i+=``)}i+=`
`,i+=`

${t}

`,i+=`
    `;for(let e of a)i+=`
  • ${e.key} ${e.des}
  • `;i+=`
`,i+=`
`,e.innerHTML=i},x=e=>{let t=document.querySelector(`#vim-hotkeys-help`);if(t)t.classList.toggle(`invisible`);else{t=Object.assign(document.createElement(`div`),{id:`vim-hotkeys-help`,className:`dialog-modal`}),b(t,e);let[n]=document.getElementsByTagName(`body`);n&&n.appendChild(t)}},S=async()=>{let e=document.querySelector(`.result[data-vim-selected]`);if(!e)return;let t=e.querySelector(`a`);r(t);let n=t.getAttribute(`href`);if(n)if(window.isSecureContext)await navigator.clipboard.writeText(n);else{let e=window.getSelection();if(e){let r=document.createElement(`span`);r.textContent=n,t.appendChild(r);let i=document.createRange();i.selectNodeContents(r),e.removeAllRanges(),e.addRange(i),document.execCommand(`copy`),r.remove()}}};t(`click`,`.result`,function(t){if(!s(t.target)){u(this)(!0,!0);let n=c(t.target);n&&l(n)&&(t.preventDefault(),e.selectImage?.(n))}}),t(`focus`,`.result a`,t=>{if(!s(t.target)){let n=c(t.target);n&&!n.hasAttribute(`data-vim-selected`)&&u(n)(!0),n&&l(n)&&(t.preventDefault(),e.selectImage?.(n))}},{capture:!0}),t(`keydown`,document,e=>{if(Object.hasOwn(o,e.key)&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey){let t=e.target?.tagName?.toLowerCase();e.key===`Escape`?o[e.key]?.fun(e):(e.target===document.body||t===`a`||t===`button`)&&(e.preventDefault(),o[e.key]?.fun(e))}}),e.selectNext=u(`down`),e.selectPrevious=u(`up`); +//# sourceMappingURL=CCrWrjxi.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/aUw47Wy0.min.js.map b/searx/static/themes/simple/chunk/CCrWrjxi.min.js.map similarity index 99% rename from searx/static/themes/simple/chunk/aUw47Wy0.min.js.map rename to searx/static/themes/simple/chunk/CCrWrjxi.min.js.map index 5d0f86ddf..d29238ee8 100644 --- a/searx/static/themes/simple/chunk/aUw47Wy0.min.js.map +++ b/searx/static/themes/simple/chunk/CCrWrjxi.min.js.map @@ -1 +1 @@ -{"version":3,"file":"aUw47Wy0.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/keyboard.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { listen, mutable, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\n\nexport type KeyBindingLayout = \"default\" | \"vim\";\n\ntype KeyBinding = {\n key: string;\n fun: (event: KeyboardEvent) => void;\n des: string;\n cat: string;\n};\n\ntype HighlightResultElement = \"down\" | \"up\" | \"visible\" | \"bottom\" | \"top\";\n\n/* common base for layouts */\nconst baseKeyBinding: Record = {\n Escape: {\n key: \"ESC\",\n fun: (event: KeyboardEvent) => removeFocus(event),\n des: \"remove focus from the focused input\",\n cat: \"Control\"\n },\n c: {\n key: \"c\",\n fun: () => copyURLToClipboard(),\n des: \"copy url of the selected result to the clipboard\",\n cat: \"Results\"\n },\n h: {\n key: \"h\",\n fun: () => toggleHelp(keyBindings),\n des: \"toggle help window\",\n cat: \"Other\"\n },\n i: {\n key: \"i\",\n fun: () => searchInputFocus(),\n des: \"focus on the search input\",\n cat: \"Control\"\n },\n n: {\n key: \"n\",\n fun: () => GoToNextPage(),\n des: \"go to next page\",\n cat: \"Results\"\n },\n o: {\n key: \"o\",\n fun: () => openResult(false),\n des: \"open search result\",\n cat: \"Results\"\n },\n p: {\n key: \"p\",\n fun: () => GoToPreviousPage(),\n des: \"go to previous page\",\n cat: \"Results\"\n },\n r: {\n key: \"r\",\n fun: () => reloadPage(),\n des: \"reload page from the server\",\n cat: \"Control\"\n },\n t: {\n key: \"t\",\n fun: () => openResult(true),\n des: \"open the result in a new tab\",\n cat: \"Results\"\n }\n};\n\nconst keyBindingLayouts: Record> = {\n // SearXNG layout\n default: {\n ArrowLeft: {\n key: \"←\",\n fun: () => highlightResult(\"up\")(),\n des: \"select previous search result\",\n cat: \"Results\"\n },\n ArrowRight: {\n key: \"→\",\n fun: () => highlightResult(\"down\")(),\n des: \"select next search result\",\n cat: \"Results\"\n },\n ...baseKeyBinding\n },\n\n // Vim-like keyboard layout\n vim: {\n b: {\n key: \"b\",\n fun: () => scrollPage(-window.innerHeight),\n des: \"scroll one page up\",\n cat: \"Navigation\"\n },\n d: {\n key: \"d\",\n fun: () => scrollPage(window.innerHeight / 2),\n des: \"scroll half a page down\",\n cat: \"Navigation\"\n },\n f: {\n key: \"f\",\n fun: () => scrollPage(window.innerHeight),\n des: \"scroll one page down\",\n cat: \"Navigation\"\n },\n g: {\n key: \"g\",\n fun: () => scrollPageTo(-document.body.scrollHeight, \"top\"),\n des: \"scroll to the top of the page\",\n cat: \"Navigation\"\n },\n j: {\n key: \"j\",\n fun: () => highlightResult(\"down\")(),\n des: \"select next search result\",\n cat: \"Results\"\n },\n k: {\n key: \"k\",\n fun: () => highlightResult(\"up\")(),\n des: \"select previous search result\",\n cat: \"Results\"\n },\n u: {\n key: \"u\",\n fun: () => scrollPage(-window.innerHeight / 2),\n des: \"scroll half a page up\",\n cat: \"Navigation\"\n },\n v: {\n key: \"v\",\n fun: () => scrollPageTo(document.body.scrollHeight, \"bottom\"),\n des: \"scroll to the bottom of the page\",\n cat: \"Navigation\"\n },\n y: {\n key: \"y\",\n fun: () => copyURLToClipboard(),\n des: \"copy url of the selected result to the clipboard\",\n cat: \"Results\"\n },\n ...baseKeyBinding\n }\n};\n\nconst keyBindings: Record =\n settings.hotkeys && settings.hotkeys in keyBindingLayouts\n ? keyBindingLayouts[settings.hotkeys]\n : keyBindingLayouts.default;\n\nconst isElementInDetail = (element?: HTMLElement): boolean => {\n const ancestor = element?.closest(\".detail, .result\");\n return ancestor?.classList.contains(\"detail\") ?? false;\n};\n\nconst getResultElement = (element?: HTMLElement): HTMLElement | undefined => {\n return element?.closest(\".result\") ?? undefined;\n};\n\nconst isImageResult = (resultElement?: HTMLElement): boolean => {\n return resultElement?.classList.contains(\"result-images\") ?? false;\n};\n\nconst highlightResult =\n (which: HighlightResultElement | HTMLElement) =>\n (noScroll?: boolean, keepFocus?: boolean): void => {\n let effectiveWhich = which;\n let current = document.querySelector(\".result[data-vim-selected]\");\n if (!current) {\n // no selection : choose the first one\n current = document.querySelector(\".result\");\n if (!current) {\n // no first one : there are no results\n return;\n }\n // replace up/down actions by selecting first one\n if (which === \"down\" || which === \"up\") {\n effectiveWhich = current;\n }\n }\n\n const results = Array.from(document.querySelectorAll(\".result\"));\n\n let next: HTMLElement | undefined;\n\n if (typeof effectiveWhich === \"string\") {\n switch (effectiveWhich) {\n case \"visible\": {\n const top = document.documentElement.scrollTop || document.body.scrollTop;\n const bot = top + document.documentElement.clientHeight;\n\n for (const element of results) {\n const etop = element.offsetTop;\n const ebot = etop + element.clientHeight;\n if (ebot <= bot && etop > top) {\n next = element;\n break;\n }\n }\n break;\n }\n case \"down\":\n next = results[results.indexOf(current) + 1] || current;\n break;\n case \"up\":\n next = results[results.indexOf(current) - 1] || current;\n break;\n case \"bottom\":\n next = results.at(-1);\n break;\n // biome-ignore lint/complexity/noUselessSwitchCase: fallthrough is intended\n case \"top\":\n default:\n [next] = results;\n }\n } else {\n next = effectiveWhich;\n }\n\n if (next) {\n current.removeAttribute(\"data-vim-selected\");\n next.setAttribute(\"data-vim-selected\", \"true\");\n\n if (!keepFocus) {\n const link = next.querySelector(\"h3 a\") || next.querySelector(\"a\");\n link?.focus();\n }\n\n if (!noScroll) {\n mutable.scrollPageToSelected?.();\n }\n }\n };\n\nconst reloadPage = (): void => {\n document.location.reload();\n};\n\nconst removeFocus = (event: KeyboardEvent): void => {\n const target = event.target as HTMLElement;\n const tagName = target?.tagName?.toLowerCase();\n\n if (document.activeElement && (tagName === \"input\" || tagName === \"select\" || tagName === \"textarea\")) {\n (document.activeElement as HTMLElement).blur();\n } else {\n mutable.closeDetail?.();\n }\n};\n\nconst pageButtonClick = (css_selector: string): void => {\n const button = document.querySelector(css_selector);\n if (button) {\n button.click();\n }\n};\n\nconst GoToNextPage = (): void => {\n pageButtonClick('nav#pagination .next_page button[type=\"submit\"]');\n};\n\nconst GoToPreviousPage = (): void => {\n pageButtonClick('nav#pagination .previous_page button[type=\"submit\"]');\n};\n\nmutable.scrollPageToSelected = (): void => {\n const sel = document.querySelector(\".result[data-vim-selected]\");\n if (!sel) return;\n\n const wtop = document.documentElement.scrollTop || document.body.scrollTop;\n const height = document.documentElement.clientHeight;\n const etop = sel.offsetTop;\n const ebot = etop + sel.clientHeight;\n const offset = 120;\n\n // first element ?\n if (!sel.previousElementSibling && ebot < height) {\n // set to the top of page if the first element\n // is fully included in the viewport\n window.scroll(window.scrollX, 0);\n return;\n }\n\n if (wtop > etop - offset) {\n window.scroll(window.scrollX, etop - offset);\n } else {\n const wbot = wtop + height;\n if (wbot < ebot + offset) {\n window.scroll(window.scrollX, ebot - height + offset);\n }\n }\n};\n\nconst scrollPage = (amount: number): void => {\n window.scrollBy(0, amount);\n highlightResult(\"visible\")();\n};\n\nconst scrollPageTo = (position: number, nav: HighlightResultElement): void => {\n window.scrollTo(0, position);\n highlightResult(nav)();\n};\n\nconst searchInputFocus = (): void => {\n window.scrollTo(0, 0);\n\n const q = document.querySelector(\"#q\");\n if (q) {\n q.focus();\n\n if (q.setSelectionRange) {\n const len = q.value.length;\n\n q.setSelectionRange(len, len);\n }\n }\n};\n\nconst openResult = (newTab: boolean): void => {\n let link = document.querySelector(\".result[data-vim-selected] h3 a\");\n if (!link) {\n link = document.querySelector(\".result[data-vim-selected] > a\");\n }\n if (!link) return;\n\n const url = link.getAttribute(\"href\");\n if (url) {\n if (newTab) {\n window.open(url);\n } else {\n window.location.href = url;\n }\n }\n};\n\nconst initHelpContent = (divElement: HTMLElement, keyBindings: typeof baseKeyBinding): void => {\n const categories: Record = {};\n\n for (const binding of Object.values(keyBindings)) {\n const { cat } = binding;\n categories[cat] ??= [];\n categories[cat].push(binding);\n }\n\n const sortedCategoryKeys = Object.keys(categories).sort(\n (a, b) => (categories[b]?.length ?? 0) - (categories[a]?.length ?? 0)\n );\n\n let html = '×';\n html += \"

How to navigate SearXNG with hotkeys

\";\n html += \"\";\n\n for (const [i, categoryKey] of sortedCategoryKeys.entries()) {\n const bindings = categories[categoryKey];\n if (!bindings || bindings.length === 0) continue;\n\n const isFirst = i % 2 === 0;\n const isLast = i === sortedCategoryKeys.length - 1;\n\n if (isFirst) {\n html += \"\";\n }\n\n html += \"\";\n\n if (!isFirst || isLast) {\n html += \"\";\n }\n }\n\n html += \"
\";\n html += `

${categoryKey}

`;\n html += '
    ';\n\n for (const binding of bindings) {\n html += `
  • ${binding.key} ${binding.des}
  • `;\n }\n\n html += \"
\";\n html += \"
\";\n\n divElement.innerHTML = html;\n};\n\nconst toggleHelp = (keyBindings: typeof baseKeyBinding): void => {\n let helpPanel = document.querySelector(\"#vim-hotkeys-help\");\n if (helpPanel) {\n // toggle hidden\n helpPanel.classList.toggle(\"invisible\");\n } else {\n // first call\n helpPanel = Object.assign(document.createElement(\"div\"), {\n id: \"vim-hotkeys-help\",\n className: \"dialog-modal\"\n });\n initHelpContent(helpPanel, keyBindings);\n const [body] = document.getElementsByTagName(\"body\");\n if (body) {\n body.appendChild(helpPanel);\n }\n }\n};\n\nconst copyURLToClipboard = async (): Promise => {\n const selectedResult = document.querySelector(\".result[data-vim-selected]\");\n if (!selectedResult) return;\n\n const resultAnchor = selectedResult.querySelector(\"a\");\n assertElement(resultAnchor);\n\n const url = resultAnchor.getAttribute(\"href\");\n if (url) {\n if (window.isSecureContext) {\n await navigator.clipboard.writeText(url);\n } else {\n const selection = window.getSelection();\n if (selection) {\n const node = document.createElement(\"span\");\n node.textContent = url;\n resultAnchor.appendChild(node);\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n document.execCommand(\"copy\");\n node.remove();\n }\n }\n }\n};\n\nlisten(\"click\", \".result\", function (this: HTMLElement, event: PointerEvent) {\n if (!isElementInDetail(event.target as HTMLElement)) {\n highlightResult(this)(true, true);\n\n const resultElement = getResultElement(event.target as HTMLElement);\n\n if (resultElement && isImageResult(resultElement)) {\n event.preventDefault();\n mutable.selectImage?.(resultElement);\n }\n }\n});\n\n// FIXME: Focus might also trigger Pointer event ^^^\nlisten(\n \"focus\",\n \".result a\",\n (event: FocusEvent) => {\n if (!isElementInDetail(event.target as HTMLElement)) {\n const resultElement = getResultElement(event.target as HTMLElement);\n\n if (resultElement && !resultElement.hasAttribute(\"data-vim-selected\")) {\n highlightResult(resultElement)(true);\n }\n\n if (resultElement && isImageResult(resultElement)) {\n event.preventDefault();\n mutable.selectImage?.(resultElement);\n }\n }\n },\n { capture: true }\n);\n\nlisten(\"keydown\", document, (event: KeyboardEvent) => {\n // check for modifiers so we don't break browser's hotkeys\n if (Object.hasOwn(keyBindings, event.key) && !event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {\n const tagName = (event.target as HTMLElement)?.tagName?.toLowerCase();\n\n if (event.key === \"Escape\") {\n keyBindings[event.key]?.fun(event);\n } else if (event.target === document.body || tagName === \"a\" || tagName === \"button\") {\n event.preventDefault();\n keyBindings[event.key]?.fun(event);\n }\n }\n});\n\nmutable.selectNext = highlightResult(\"down\");\nmutable.selectPrevious = highlightResult(\"up\");\n"],"mappings":"4FAiBA,IAAM,EAA6C,CACjD,OAAQ,CACN,IAAK,MACL,IAAM,GAAyB,EAAY,EAAM,CACjD,IAAK,sCACL,IAAK,UACN,CACD,EAAG,CACD,IAAK,IACL,QAAW,GAAoB,CAC/B,IAAK,mDACL,IAAK,UACN,CACD,EAAG,CACD,IAAK,IACL,Q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yB,CAEpD,GAAI,OAAO,OAAO,EAAa,EAAM,IAAI,EAAI,CAAC,EAAM,SAAW,CAAC,EAAM,QAAU,CAAC,EAAM,UAAY,CAAC,EAAM,QAAS,CACjH,IAAM,EAAW,EAAM,QAAwB,SAAS,aAAa,CAEjE,EAAM,MAAQ,SAChB,EAAY,EAAM,MAAM,IAAI,EAAM,EACzB,EAAM,SAAW,SAAS,MAAQ,IAAY,KAAO,IAAY,YAC1E,EAAM,gBAAgB,CACtB,EAAY,EAAM,MAAM,IAAI,EAAM,IAGtC,CAEF,EAAQ,WAAa,EAAgB,OAAO,CAC5C,EAAQ,eAAiB,EAAgB,KAAK"} \ No newline at end of file +{"version":3,"file":"CCrWrjxi.min.js","names":[],"sources":["../../../../../client/simple/src/js/main/keyboard.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport { listen, mutable, settings } from \"../toolkit.ts\";\nimport { assertElement } from \"../util/assertElement.ts\";\n\nexport type KeyBindingLayout = \"default\" | \"vim\";\n\ntype KeyBinding = {\n key: string;\n fun: (event: KeyboardEvent) => void;\n des: string;\n cat: string;\n};\n\ntype HighlightResultElement = \"down\" | \"up\" | \"visible\" | \"bottom\" | \"top\";\n\n/* common base for layouts */\nconst baseKeyBinding: Record = {\n Escape: {\n key: \"ESC\",\n fun: (event: KeyboardEvent) => removeFocus(event),\n des: \"remove focus from the focused input\",\n cat: \"Control\"\n },\n c: {\n key: \"c\",\n fun: () => copyURLToClipboard(),\n des: \"copy url of the selected result to the clipboard\",\n cat: \"Results\"\n },\n h: {\n key: \"h\",\n fun: () => toggleHelp(keyBindings),\n des: \"toggle help window\",\n cat: \"Other\"\n },\n i: {\n key: \"i\",\n fun: () => searchInputFocus(),\n des: \"focus on the search input\",\n cat: \"Control\"\n },\n n: {\n key: \"n\",\n fun: () => GoToNextPage(),\n des: \"go to next page\",\n cat: \"Results\"\n },\n o: {\n key: \"o\",\n fun: () => openResult(false),\n des: \"open search result\",\n cat: \"Results\"\n },\n p: {\n key: \"p\",\n fun: () => GoToPreviousPage(),\n des: \"go to previous page\",\n cat: \"Results\"\n },\n r: {\n key: \"r\",\n fun: () => reloadPage(),\n des: \"reload page from the server\",\n cat: \"Control\"\n },\n t: {\n key: \"t\",\n fun: () => openResult(true),\n des: \"open the result in a new tab\",\n cat: \"Results\"\n }\n};\n\nconst keyBindingLayouts: Record> = {\n // SearXNG layout\n default: {\n ArrowLeft: {\n key: \"←\",\n fun: () => highlightResult(\"up\")(),\n des: \"select previous search result\",\n cat: \"Results\"\n },\n ArrowRight: {\n key: \"→\",\n fun: () => highlightResult(\"down\")(),\n des: \"select next search result\",\n cat: \"Results\"\n },\n ...baseKeyBinding\n },\n\n // Vim-like keyboard layout\n vim: {\n b: {\n key: \"b\",\n fun: () => scrollPage(-window.innerHeight),\n des: \"scroll one page up\",\n cat: \"Navigation\"\n },\n d: {\n key: \"d\",\n fun: () => scrollPage(window.innerHeight / 2),\n des: \"scroll half a page down\",\n cat: \"Navigation\"\n },\n f: {\n key: \"f\",\n fun: () => scrollPage(window.innerHeight),\n des: \"scroll one page down\",\n cat: \"Navigation\"\n },\n g: {\n key: \"g\",\n fun: () => scrollPageTo(-document.body.scrollHeight, \"top\"),\n des: \"scroll to the top of the page\",\n cat: \"Navigation\"\n },\n j: {\n key: \"j\",\n fun: () => highlightResult(\"down\")(),\n des: \"select next search result\",\n cat: \"Results\"\n },\n k: {\n key: \"k\",\n fun: () => highlightResult(\"up\")(),\n des: \"select previous search result\",\n cat: \"Results\"\n },\n u: {\n key: \"u\",\n fun: () => scrollPage(-window.innerHeight / 2),\n des: \"scroll half a page up\",\n cat: \"Navigation\"\n },\n v: {\n key: \"v\",\n fun: () => scrollPageTo(document.body.scrollHeight, \"bottom\"),\n des: \"scroll to the bottom of the page\",\n cat: \"Navigation\"\n },\n y: {\n key: \"y\",\n fun: () => copyURLToClipboard(),\n des: \"copy url of the selected result to the clipboard\",\n cat: \"Results\"\n },\n ...baseKeyBinding\n }\n};\n\nconst keyBindings: Record =\n settings.hotkeys && settings.hotkeys in keyBindingLayouts\n ? keyBindingLayouts[settings.hotkeys]\n : keyBindingLayouts.default;\n\nconst isElementInDetail = (element?: HTMLElement): boolean => {\n const ancestor = element?.closest(\".detail, .result\");\n return ancestor?.classList.contains(\"detail\") ?? false;\n};\n\nconst getResultElement = (element?: HTMLElement): HTMLElement | undefined => {\n return element?.closest(\".result\") ?? undefined;\n};\n\nconst isImageResult = (resultElement?: HTMLElement): boolean => {\n return resultElement?.classList.contains(\"result-images\") ?? false;\n};\n\nconst highlightResult =\n (which: HighlightResultElement | HTMLElement) =>\n (noScroll?: boolean, keepFocus?: boolean): void => {\n let effectiveWhich = which;\n let current = document.querySelector(\".result[data-vim-selected]\");\n if (!current) {\n // no selection : choose the first one\n current = document.querySelector(\".result\");\n if (!current) {\n // no first one : there are no results\n return;\n }\n // replace up/down actions by selecting first one\n if (which === \"down\" || which === \"up\") {\n effectiveWhich = current;\n }\n }\n\n const results = Array.from(document.querySelectorAll(\".result\"));\n\n let next: HTMLElement | undefined;\n\n if (typeof effectiveWhich === \"string\") {\n switch (effectiveWhich) {\n case \"visible\": {\n const top = document.documentElement.scrollTop || document.body.scrollTop;\n const bot = top + document.documentElement.clientHeight;\n\n for (const element of results) {\n const etop = element.offsetTop;\n const ebot = etop + element.clientHeight;\n if (ebot <= bot && etop > top) {\n next = element;\n break;\n }\n }\n break;\n }\n case \"down\":\n next = results[results.indexOf(current) + 1] || current;\n break;\n case \"up\":\n next = results[results.indexOf(current) - 1] || current;\n break;\n case \"bottom\":\n next = results.at(-1);\n break;\n // biome-ignore lint/complexity/noUselessSwitchCase: fallthrough is intended\n case \"top\":\n default:\n [next] = results;\n }\n } else {\n next = effectiveWhich;\n }\n\n if (next) {\n current.removeAttribute(\"data-vim-selected\");\n next.setAttribute(\"data-vim-selected\", \"true\");\n\n if (!keepFocus) {\n const link = next.querySelector(\"h3 a\") || next.querySelector(\"a\");\n link?.focus();\n }\n\n if (!noScroll) {\n mutable.scrollPageToSelected?.();\n }\n }\n };\n\nconst reloadPage = (): void => {\n document.location.reload();\n};\n\nconst removeFocus = (event: KeyboardEvent): void => {\n const target = event.target as HTMLElement;\n const tagName = target?.tagName?.toLowerCase();\n\n if (document.activeElement && (tagName === \"input\" || tagName === \"select\" || tagName === \"textarea\")) {\n (document.activeElement as HTMLElement).blur();\n } else {\n mutable.closeDetail?.();\n }\n};\n\nconst pageButtonClick = (css_selector: string): void => {\n const button = document.querySelector(css_selector);\n if (button) {\n button.click();\n }\n};\n\nconst GoToNextPage = (): void => {\n pageButtonClick('nav#pagination .next_page button[type=\"submit\"]');\n};\n\nconst GoToPreviousPage = (): void => {\n pageButtonClick('nav#pagination .previous_page button[type=\"submit\"]');\n};\n\nmutable.scrollPageToSelected = (): void => {\n const sel = document.querySelector(\".result[data-vim-selected]\");\n if (!sel) return;\n\n const wtop = document.documentElement.scrollTop || document.body.scrollTop;\n const height = document.documentElement.clientHeight;\n const etop = sel.offsetTop;\n const ebot = etop + sel.clientHeight;\n const offset = 120;\n\n // first element ?\n if (!sel.previousElementSibling && ebot < height) {\n // set to the top of page if the first element\n // is fully included in the viewport\n window.scroll(window.scrollX, 0);\n return;\n }\n\n if (wtop > etop - offset) {\n window.scroll(window.scrollX, etop - offset);\n } else {\n const wbot = wtop + height;\n if (wbot < ebot + offset) {\n window.scroll(window.scrollX, ebot - height + offset);\n }\n }\n};\n\nconst scrollPage = (amount: number): void => {\n window.scrollBy(0, amount);\n highlightResult(\"visible\")();\n};\n\nconst scrollPageTo = (position: number, nav: HighlightResultElement): void => {\n window.scrollTo(0, position);\n highlightResult(nav)();\n};\n\nconst searchInputFocus = (): void => {\n window.scrollTo(0, 0);\n\n const q = document.querySelector(\"#q\");\n if (q) {\n q.focus();\n\n if (q.setSelectionRange) {\n const len = q.value.length;\n\n q.setSelectionRange(len, len);\n }\n }\n};\n\nconst openResult = (newTab: boolean): void => {\n let link = document.querySelector(\".result[data-vim-selected] h3 a\");\n if (!link) {\n link = document.querySelector(\".result[data-vim-selected] > a\");\n }\n if (!link) return;\n\n const url = link.getAttribute(\"href\");\n if (url) {\n if (newTab) {\n window.open(url);\n } else {\n window.location.href = url;\n }\n }\n};\n\nconst initHelpContent = (divElement: HTMLElement, keyBindings: typeof baseKeyBinding): void => {\n const categories: Record = {};\n\n for (const binding of Object.values(keyBindings)) {\n const { cat } = binding;\n categories[cat] ??= [];\n categories[cat].push(binding);\n }\n\n const sortedCategoryKeys = Object.keys(categories).sort(\n (a, b) => (categories[b]?.length ?? 0) - (categories[a]?.length ?? 0)\n );\n\n let html = '×';\n html += \"

How to navigate SearXNG with hotkeys

\";\n html += \"\";\n\n for (const [i, categoryKey] of sortedCategoryKeys.entries()) {\n const bindings = categories[categoryKey];\n if (!bindings || bindings.length === 0) continue;\n\n const isFirst = i % 2 === 0;\n const isLast = i === sortedCategoryKeys.length - 1;\n\n if (isFirst) {\n html += \"\";\n }\n\n html += \"\";\n\n if (!isFirst || isLast) {\n html += \"\";\n }\n }\n\n html += \"
\";\n html += `

${categoryKey}

`;\n html += '
    ';\n\n for (const binding of bindings) {\n html += `
  • ${binding.key} ${binding.des}
  • `;\n }\n\n html += \"
\";\n html += \"
\";\n\n divElement.innerHTML = html;\n};\n\nconst toggleHelp = (keyBindings: typeof baseKeyBinding): void => {\n let helpPanel = document.querySelector(\"#vim-hotkeys-help\");\n if (helpPanel) {\n // toggle hidden\n helpPanel.classList.toggle(\"invisible\");\n } else {\n // first call\n helpPanel = Object.assign(document.createElement(\"div\"), {\n id: \"vim-hotkeys-help\",\n className: \"dialog-modal\"\n });\n initHelpContent(helpPanel, keyBindings);\n const [body] = document.getElementsByTagName(\"body\");\n if (body) {\n body.appendChild(helpPanel);\n }\n }\n};\n\nconst copyURLToClipboard = async (): Promise => {\n const selectedResult = document.querySelector(\".result[data-vim-selected]\");\n if (!selectedResult) return;\n\n const resultAnchor = selectedResult.querySelector(\"a\");\n assertElement(resultAnchor);\n\n const url = resultAnchor.getAttribute(\"href\");\n if (url) {\n if (window.isSecureContext) {\n await navigator.clipboard.writeText(url);\n } else {\n const selection = window.getSelection();\n if (selection) {\n const node = document.createElement(\"span\");\n node.textContent = url;\n resultAnchor.appendChild(node);\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n document.execCommand(\"copy\");\n node.remove();\n }\n }\n }\n};\n\nlisten(\"click\", \".result\", function (this: HTMLElement, event: PointerEvent) {\n if (!isElementInDetail(event.target as HTMLElement)) {\n highlightResult(this)(true, true);\n\n const resultElement = getResultElement(event.target as HTMLElement);\n\n if (resultElement && isImageResult(resultElement)) {\n event.preventDefault();\n mutable.selectImage?.(resultElement);\n }\n }\n});\n\n// FIXME: Focus might also trigger Pointer event ^^^\nlisten(\n \"focus\",\n \".result a\",\n (event: FocusEvent) => {\n if (!isElementInDetail(event.target as HTMLElement)) {\n const resultElement = getResultElement(event.target as HTMLElement);\n\n if (resultElement && !resultElement.hasAttribute(\"data-vim-selected\")) {\n highlightResult(resultElement)(true);\n }\n\n if (resultElement && isImageResult(resultElement)) {\n event.preventDefault();\n mutable.selectImage?.(resultElement);\n }\n }\n },\n { capture: true }\n);\n\nlisten(\"keydown\", document, (event: KeyboardEvent) => {\n // check for modifiers so we don't break browser's hotkeys\n if (Object.hasOwn(keyBindings, event.key) && !event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {\n const tagName = (event.target as HTMLElement)?.tagName?.toLowerCase();\n\n if (event.key === \"Escape\") {\n keyBindings[event.key]?.fun(event);\n } else if (event.target === document.body || tagName === \"a\" || tagName === \"button\") {\n event.preventDefault();\n keyBindings[event.key]?.fun(event);\n }\n }\n});\n\nmutable.selectNext = highlightResult(\"down\");\nmutable.selectPrevious = highlightResult(\"up\");\n"],"mappings":"0FAiBA,IAAM,EAA6C,CACjD,OAAQ,CACN,IAAK,MACL,IAAM,GAAyB,EAAY,EAAM,CACjD,IAAK,sCACL,IAAK,UACN,CACD,EAAG,CACD,IAA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,EAAQ,cAAc,EAAc,IAI1C,CAAE,QAAS,GAAM,CAClB,CAED,EAAO,UAAW,SAAW,GAAyB,CAEpD,GAAI,OAAO,OAAO,EAAa,EAAM,IAAI,EAAI,CAAC,EAAM,SAAW,CAAC,EAAM,QAAU,CAAC,EAAM,UAAY,CAAC,EAAM,QAAS,CACjH,IAAM,EAAW,EAAM,QAAwB,SAAS,aAAa,CAEjE,EAAM,MAAQ,SAChB,EAAY,EAAM,MAAM,IAAI,EAAM,EACzB,EAAM,SAAW,SAAS,MAAQ,IAAY,KAAO,IAAY,YAC1E,EAAM,gBAAgB,CACtB,EAAY,EAAM,MAAM,IAAI,EAAM,IAGtC,CAEF,EAAQ,WAAa,EAAgB,OAAO,CAC5C,EAAQ,eAAiB,EAAgB,KAAK"} \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/CQ8vfMdp.min.js b/searx/static/themes/simple/chunk/CQ8vfMdp.min.js deleted file mode 100644 index 515ef36f7..000000000 --- a/searx/static/themes/simple/chunk/CQ8vfMdp.min.js +++ /dev/null @@ -1,2 +0,0 @@ -import{i as e,n as t,t as n}from"../sxng-core.min.js";import{t as r}from"./DH1EQbEY.min.js";var i=async(i,a)=>{try{let o;o=e.method===`GET`?await n(`GET`,`./autocompleter?q=${a}`):await n(`POST`,`./autocompleter`,{body:new URLSearchParams({q:a})});let s=await o.json(),c=document.querySelector(`.autocomplete`);r(c);let l=document.querySelector(`.autocomplete ul`);if(r(l),c.classList.add(`open`),l.replaceChildren(),s?.[1]?.length===0){let t=Object.assign(document.createElement(`li`),{className:`no-item-found`,textContent:e.translations?.no_item_found??`No results found`});l.append(t);return}let u=new DocumentFragment;for(let e of s[1]){let n=Object.assign(document.createElement(`li`),{textContent:e});t(`mousedown`,n,()=>{i.value=e,document.querySelector(`#search`)?.submit()}),u.append(n)}l.append(u)}catch(e){console.error(`Error fetching autocomplete results:`,e)}},a=document.getElementById(`q`);r(a);var o;t(`input`,a,()=>{clearTimeout(o);let t=a.value,n=e.autocomplete_min??2;t.length{t===a.value&&await i(a,t)},300))});var s=document.querySelector(`.autocomplete`),c=document.querySelector(`.autocomplete ul`);c&&(t(`keydown`,a,e=>{e.key===`Escape`&&s?.classList.remove(`open`)}),t(`keyup`,a,e=>{let t=[...c.children],n=t.findIndex(e=>e.classList.contains(`active`)),r=-1;switch(e.key){case`ArrowUp`:{let e=t[n];e&&n>=0&&e.classList.remove(`active`),r=(n-1+t.length)%t.length;break}case`ArrowDown`:{let e=t[n];e&&n>=0&&e.classList.remove(`active`),r=(n+1)%t.length;break}case`Enter`:s&&s.classList.remove(`open`);break;default:break}if(r!==-1){let e=t[r];if(e&&(e.classList.add(`active`),!e.classList.contains(`no-item-found`))){let t=document.getElementById(`q`);t&&(t.value=e.textContent??``)}}}),t(`blur`,a,()=>{s?.classList.remove(`open`)}),t(`focus`,a,()=>{s?.classList.add(`open`)})); -//# sourceMappingURL=CQ8vfMdp.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/Cj4jNiaB.min.js b/searx/static/themes/simple/chunk/Cj4jNiaB.min.js new file mode 100644 index 000000000..033741b96 --- /dev/null +++ b/searx/static/themes/simple/chunk/Cj4jNiaB.min.js @@ -0,0 +1,8 @@ +import{t as e}from"./Cq566EWy.min.js";var t={ADD:`add`,REMOVE:`remove`},n={PROPERTYCHANGE:`propertychange`};function r(e){for(let t in e)delete e[t]}function i(e){let t;for(t in e)return!1;return!t}function a(e,t,n,r,i){if(i){let i=n;n=function(a){return e.removeEventListener(t,n),i.call(r??this,a)}}else r&&r!==e&&(n=n.bind(r));let a={target:e,type:t,listener:n};return e.addEventListener(t,n),a}function o(e,t,n,r){return a(e,t,n,r,!0)}function s(e){e&&e.target&&(e.target.removeEventListener(e.type,e.listener),r(e))}var c={CHANGE:`change`,ERROR:`error`,BLUR:`blur`,CLEAR:`clear`,CONTEXTMENU:`contextmenu`,CLICK:`click`,DBLCLICK:`dblclick`,DRAGENTER:`dragenter`,DRAGOVER:`dragover`,DROP:`drop`,FOCUS:`focus`,KEYDOWN:`keydown`,KEYPRESS:`keypress`,LOAD:`load`,RESIZE:`resize`,TOUCHMOVE:`touchmove`,WHEEL:`wheel`},l=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function u(e,t,n){let r,i;n||=d;let a=0,o=e.length,s=!1;for(;a>1),i=+n(e[r],t),i<0?a=r+1:(o=r,s=!i);return s?a:~a}function d(e,t){return e>t?1:et?-1:0}function p(e,t,n){if(e[0]<=t)return 0;let r=e.length;if(t<=e[r-1])return r-1;if(typeof n==`function`){for(let i=1;i0?i-1:i}return r-1}if(n>0){for(let n=1;n0||n&&a===0)})}function v(){return!0}function y(){return!1}function b(){}function x(e){let t,n,r;return function(){let i=Array.prototype.slice.call(arguments);return(!n||this!==r||!g(i,n))&&(r=this,n=i,t=e.apply(this,arguments)),t}}function S(e){function t(){let t;try{t=e()}catch(e){return Promise.reject(e)}return t instanceof Promise?t:Promise.resolve(t)}return t()}var C=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},w=class extends l{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;let n=this.listeners_||={},r=n[e]||(n[e]=[]);r.includes(t)||r.push(t)}dispatchEvent(e){let t=typeof e==`string`,n=t?e:e.type,r=this.listeners_&&this.listeners_[n];if(!r)return;let i=t?new C(e):e;i.target||=this.eventTarget_||this;let a=this.dispatching_||={},o=this.pendingRemovals_||={};n in a||(a[n]=0,o[n]=0),++a[n];let s;for(let e=0,t=r.length;e0:!1}removeEventListener(e,t){if(!this.listeners_)return;let n=this.listeners_[e];if(!n)return;let r=n.indexOf(t);r!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(n[r]=b,++this.pendingRemovals_[e]):(n.splice(r,1),n.length===0&&delete this.listeners_[e]))}},T=class extends w{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(c.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){let n=e.length,r=Array(n);for(let i=0;i0;)this.pop()}extend(e){for(let t=0,n=e.length;tthis.getLength())throw Error(`Index out of bounds: `+e);this.unique_&&this.assertUnique_(n),this.array_.splice(e,0,n),this.updateLength_(),this.dispatchEvent(new te(t.ADD,n,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){let t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){let t=this.array_;for(let n=0,r=t.length;n=this.getLength())return;let n=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new te(t.REMOVE,n,e)),n}setAt(e,n){if(e>=this.getLength()){this.insertAt(e,n);return}if(e<0)throw Error(`Index out of bounds: `+e);this.unique_&&this.assertUnique_(n,e);let r=this.array_[e];this.array_[e]=n,this.dispatchEvent(new te(t.REMOVE,r,e)),this.dispatchEvent(new te(t.ADD,n,e))}updateLength_(){this.set(ee.LENGTH,this.array_.length)}assertUnique_(e,t){let n=this.array_;for(let r=0,i=n.length;ri&&(c|=N.RIGHT),sa&&(c|=N.ABOVE),c===N.UNKNOWN&&(c=N.INTERSECTING),c}function me(){return[1/0,1/0,-1/0,-1/0]}function he(e,t,n,r,i){return i?(i[0]=e,i[1]=t,i[2]=n,i[3]=r,i):[e,t,n,r]}function ge(e){return he(1/0,1/0,-1/0,-1/0,e)}function _e(e,t){let n=e[0],r=e[1];return he(n,r,n,r,t)}function ve(e,t,n,r,i){return Se(ge(i),e,t,n,r)}function ye(e,t){return e[0]==t[0]&&e[2]==t[2]&&e[1]==t[1]&&e[3]==t[3]}function be(e,t){return t[0]e[2]&&(e[2]=t[2]),t[1]e[3]&&(e[3]=t[3]),e}function xe(e,t){t[0]e[2]&&(e[2]=t[0]),t[1]e[3]&&(e[3]=t[1])}function Se(e,t,n,r,i){for(;nt[0]?r[0]=e[0]:r[0]=t[0],e[1]>t[1]?r[1]=e[1]:r[1]=t[1],e[2]=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function Ie(e){return e[2]=o&&h<=c),!r&&a&N.RIGHT&&!(i&N.RIGHT)&&(g=p-(f-c)*m,r=g>=s&&g<=l),!r&&a&N.BELOW&&!(i&N.BELOW)&&(h=f-(p-s)/m,r=h>=o&&h<=c),!r&&a&N.LEFT&&!(i&N.LEFT)&&(g=p-(f-o)*m,r=g>=s&&g<=l)}return r}function ze(e,t,n,r){if(Ie(e))return ge(n);let i=[];if(r>1){let t=e[2]-e[0],n=e[3]-e[1];for(let a=0;a=n[2])){let t=F(n),i=Math.floor((r[0]-n[0])/t)*t;e[0]-=i,e[2]-=i}return e}function Ve(e,t,n){if(t.canWrapX()){let r=t.getExtent();if(!isFinite(e[0])||!isFinite(e[2]))return[[r[0],e[1],r[2],e[3]]];Be(e,t);let i=F(r);if(F(e)>i&&!n)return[[r[0],e[1],r[2],e[3]]];if(e[0]r[2])return[[e[0],e[1],r[2],e[3]],[r[0],e[1],e[2]-i,e[3]]]}return[e]}function I(e,t,n){return Math.min(Math.max(e,t),n)}function He(e,t,n,r,i,a){let o=i-n,s=a-r;if(o!==0||s!==0){let c=((e-n)*o+(t-r)*s)/(o*o+s*s);c>1?(n=i,r=a):c>0&&(n+=o*c,r+=s*c)}return Ue(e,t,n,r)}function Ue(e,t,n,r){let i=n-e,a=r-t;return i*i+a*a}function We(e){let t=e.length;for(let n=0;ni&&(i=t,r=a)}if(i===0)return null;let a=e[r];e[r]=e[n],e[n]=a;for(let r=n+1;r=0;r--){n[r]=e[r][t]/e[r][r];for(let i=r-1;i>=0;i--)e[i][t]-=e[i][r]*n[r]}return n}function Ge(e){return e*180/Math.PI}function Ke(e){return e*Math.PI/180}function qe(e,t){let n=e%t;return n*t<0?n+t:n}function Je(e,t,n){return e+n*(t-e)}function Ye(e,t){let n=10**t;return Math.round(e*n)/n}function Xe(e,t){return Math.floor(Ye(e,t))}function Ze(e,t){return Math.ceil(Ye(e,t))}function Qe(e,t,n){if(e>=t&&eet.warn||console.warn(...e)}function rt(e,t){return e[0]+=+t[0],e[1]+=+t[1],e}function it(e,t){let n=!0;for(let r=e.length-1;r>=0;--r)if(e[r]!=t[r]){n=!1;break}return n}function at(e,t){let n=Math.cos(t),r=Math.sin(t),i=e[0]*n-e[1]*r,a=e[1]*n+e[0]*r;return e[0]=i,e[1]=a,e}function ot(e,t){return e[0]*=t,e[1]*=t,e}function st(e,t){if(t.canWrapX()){let n=F(t.getExtent()),r=ct(e,t,n);r&&(e[0]-=r*n)}return e}function ct(e,t,n){let r=t.getExtent(),i=0;return t.canWrapX()&&(e[0]r[2])&&(n||=F(r),i=Math.floor((e[0]-r[0])/n)),i}function lt(e,t,n){let r=Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])),i=[(t[0]-e[0])/r,(t[1]-e[1])/r],a=[-i[1],i[0]],o=Math.sqrt((n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1])),s=[(n[0]-e[0])/o,(n[1]-e[1])/o],c=r===0||o===0?0:Math.acos(I(s[0]*i[0]+s[1]*i[1],-1,1));return c=Math.max(c,1e-5),s[0]*a[0]+s[1]*a[1]>0?c:Math.PI*2-c}var ut={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},dt=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent===void 0?null:e.extent,this.worldExtent_=e.worldExtent===void 0?null:e.worldExtent,this.axisOrientation_=e.axisOrientation===void 0?`enu`:e.axisOrientation,this.global_=e.global===void 0?!1:e.global,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ut[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},ft=6378137,pt=Math.PI*ft,mt=[-pt,-pt,pt,pt],ht=[-180,-85,180,85],gt=ft*Math.log(Math.tan(Math.PI/2)),_t=class extends dt{constructor(e){super({code:e,units:`m`,extent:mt,global:!0,worldExtent:ht,getPointResolution:function(e,t){return e/Math.cosh(t[1]/ft)}})}},vt=[new _t(`EPSG:3857`),new _t(`EPSG:102100`),new _t(`EPSG:102113`),new _t(`EPSG:900913`),new _t(`http://www.opengis.net/def/crs/EPSG/0/3857`),new _t(`http://www.opengis.net/gml/srs/epsg.xml#3857`)];function yt(e,t,n,r){let i=e.length;n=n>1?n:2,r??=n,t===void 0&&(t=n>2?e.slice():Array(i));for(let n=0;ngt?r=gt:r<-gt&&(r=-gt),t[n+1]=r}return t}function bt(e,t,n,r){let i=e.length;n=n>1?n:2,r??=n,t===void 0&&(t=n>2?e.slice():Array(i));for(let n=0;nen&&(t=en);let r=Ke(t),i=Math.sin(r),a=Math.cos(r),o=i/a,s=o*o,c=s*s,l=Ke(e),u=Ke(an(n.number)),d=Zt/Math.sqrt(1-Nt*i**2),f=It*a**2,p=a*Qe(l-u,-Math.PI,Math.PI),m=p*p,h=m*p,g=h*p,_=g*p,v=_*p,y=Zt*(Ut*r-Wt*Math.sin(2*r)+Gt*Math.sin(4*r)-Kt*Math.sin(6*r)),b=Mt*d*(p+h/6*(1-s+f)+_/120*(5-18*s+c+72*f-58*It))+5e5,x=Mt*(y+d*o*(m/2+g/24*(5-s+9*f+4*f**2)+v/720*(61-58*s+c+600*f-330*It)));return n.north||(x+=1e7),[b,x]}function an(e){return(e-1)*6-180+3}var on=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function sn(e){let t=0;for(let n of on){let r=e.match(n);if(r){t=parseInt(r[1]);break}}if(!t)return null;let n=0,r=!1;return t>32700&&t<32761?n=t-32700:t>32600&&t<32661&&(r=!0,n=t-32600),n?{number:n,north:r}:null}function cn(e,t){return function(n,r,i,a){let o=n.length;i=i>1?i:2,a??=i,r||=i>2?n.slice():Array(o);for(let i=0;i=s?t[o+e]:a[e]}return n})}function Cn(e,t){return mn(),On(e,`EPSG:4326`,t===void 0?`EPSG:3857`:t)}function wn(e,t){if(e===t)return!0;let n=e.getUnits()===t.getUnits();return(e.getCode()===t.getCode()||Tn(e,t)===hn)&&n}function Tn(e,t){let n=e.getCode(),r=t.getCode(),i=jt(n,r);if(i)return i;let a=null,o=null;for(let n of dn)a||=n(e),o||=n(t);if(!a&&!o)return null;let s=`EPSG:4326`;if(!o){let e=jt(s,r);e&&(i=En(a.inverse,e))}else if(a)i=En(a.inverse,o.forward);else{let e=jt(n,s);e&&(i=En(e,o.forward))}return i&&(gn(e),gn(t),At(e,t,i)),i}function En(e,t){return function(n,r,i,a){return r=e(n,r,i,a),t(r,r,i,a)}}function Dn(e,t){return Tn(L(e),L(t))}function On(e,t,n){let r=Dn(t,n);if(!r){let e=L(t).getCode(),r=L(n).getCode();throw Error(`No transform available between ${e} and ${r}`)}return r(e,void 0,e.length)}function kn(e,t,n,r){return ze(e,Dn(t,n),void 0,r)}var An=null;function jn(){return An}function Mn(e,t){return An?On(e,t,An):e}function Nn(e,t){return An?On(e,An,t):(pn&&!it(e,[0,0])&&e[0]>=-180&&e[0]<=180&&e[1]>=-90&&e[1]<=90&&(pn=!1,nt(`Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.`)),e)}function Pn(e,t){return An?kn(e,t,An):e}function Fn(e,t){return An?kn(e,An,t):e}function In(e,t){if(!An)return e;let n=L(t).getMetersPerUnit(),r=An.getMetersPerUnit();return n&&r?e*n/r:e}function Ln(){yn(vt),yn(Tt),bn(Tt,vt,yt,bt)}Ln();function Rn(){return[1,0,0,1,0,0]}function zn(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function R(e,t){let n=t[0],r=t[1];return t[0]=e[0]*n+e[2]*r+e[4],t[1]=e[1]*n+e[3]*r+e[5],t}function Bn(e,t,n,r,i,a,o,s){let c=Math.sin(a),l=Math.cos(a);return e[0]=r*l,e[1]=i*c,e[2]=-r*c,e[3]=i*l,e[4]=o*r*l-s*r*c+t,e[5]=o*i*c+s*i*l+n,e}function Vn(e,t){let n=Hn(t);M(n!==0,`Transformation matrix cannot be inverted`);let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];return e[0]=o/n,e[1]=-i/n,e[2]=-a/n,e[3]=r/n,e[4]=(a*c-o*s)/n,e[5]=-(r*c-i*s)/n,e}function Hn(e){return e[0]*e[3]-e[1]*e[2]}var Un=[1e5,1e5,1e5,1e5,2,2];function Wn(e){return`matrix(`+e.join(`, `)+`)`}function Gn(e){return e.substring(7,e.length-1).split(`,`).map(parseFloat)}function Kn(e,t){let n=Gn(e),r=Gn(t);for(let e=0;e<6;++e)if(Math.round((n[e]-r[e])*Un[e])!==0)return!1;return!0}function qn(e,t,n,r,i,a,o){a||=[],o||=2;let s=0;for(let c=t;c{if(!n)return this.getSimplifiedGeometry(t);let r=this.clone();return r.applyTransform(n),r.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return D()}closestPointXY(e,t,n,r){return D()}containsXY(e,t){return this.closestPointXY(e,t,Qn,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t||=[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return D()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&ge(e),this.extentRevision_=this.getRevision()}return Le(this.extent_,e)}rotate(e,t){D()}scale(e,t,n){D()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return D()}getType(){return D()}applyTransform(e){D()}intersectsExtent(e){return D()}translate(e,t){D()}transform(e,t){let n=L(e),r=n.getUnits()==`tile-pixels`?function(e,r,i){let a=n.getExtent(),o=n.getWorldExtent(),s=P(o)/P(a);Bn(Zn,o[0],o[3],s,-s,0,0,0);let c=qn(e,0,e.length,i,Zn,r),l=Dn(n,t);return l?l(c,c,i):c}:Dn(n,t);return this.applyTransform(r),this}},er=class extends $n{constructor(){super(),this.layout=`XY`,this.stride=2,this.flatCoordinates}computeExtent(e){return ve(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return D()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length1)d=n;else if(f>0){for(let i=0;ii&&(i=s),a=n,o=r}return i}function lr(e,t,n,r,i){for(let a=0,o=n.length;a0;){let n=l.pop(),a=l.pop(),o=0,s=e[a],d=e[a+1],f=e[n],p=e[n+1];for(let t=a+r;to&&(u=t,o=i)}o>i&&(c[(u-t)/r]=1,a+r0&&m>f)&&(p<0&&h0&&h>p)){l=n,u=d;continue}a[o++]=l,a[o++]=u,s=l,c=u,l=n,u=d}return a[o++]=l,a[o++]=u,o}function Tr(e,t,n,r,i,a,o,s){for(let c=0,l=n.length;ca&&(n-s)*(a-c)-(i-s)*(r-c)>0&&o++:r<=a&&(n-s)*(a-c)-(i-s)*(r-c)<0&&o--,s=n,c=r}return o!==0}function jr(e,t,n,r,i,a){if(n.length===0||!Ar(e,t,n[0],r,i,a))return!1;for(let t=1,o=n.length;tv&&(l=(u+f)/2,jr(e,t,n,r,l,h)&&(_=l,v=i)),u=f}return isNaN(_)&&(_=i[a]),o?(o.push(_,h,v),o):[_,h,v]}function Pr(e,t,n,r,i){let a=[];for(let o=0,s=n.length;o=i[0]&&a[2]<=i[2]||a[1]>=i[1]&&a[3]<=i[3]?!0:Fr(e,t,n,r,function(e,t){return Re(i,e,t)}):!1}function Lr(e,t,n,r,i){for(let a=0,o=n.length;a0}function Ur(e,t,n,r,i){i=i===void 0?!1:i;for(let a=0,o=n.length;a{function i(){o(),n(e)}function a(){o(),r(Error(`Image load error`))}function o(){e.removeEventListener(`load`,i),e.removeEventListener(`error`,a)}e.addEventListener(`load`,i),e.addEventListener(`error`,a),t&&(e.src=t)})}function ai(e,t){return t&&(e.src=t),e.src&&ti?new Promise((t,n)=>e.decode().then(()=>t(e)).catch(r=>e.complete&&e.width?t(e):n(r))):ii(e)}var B={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function oi(e){return e**3}function si(e){return 1-oi(1-e)}function ci(e){return 3*e*e-2*e*e*e}function li(e){return e}var ui=class extends w{constructor(e,t,n){super(),n||={},this.tileCoord=e,this.state=t,this.key=``,this.transition_=n.transition===void 0?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(c.CHANGE)}release(){this.setState(B.EMPTY)}getKey(){return this.key+`/`+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==B.EMPTY){if(this.state!==B.ERROR&&this.state>e)throw Error(`Tile load sequence violation`);this.state=e,this.changed()}}load(){D()}getAlpha(e,t){if(!this.transition_)return 1;let n=this.transitionStarts_[e];if(!n)n=t,this.transitionStarts_[e]=n;else if(n===-1)return 1;let r=t-n+1e3/60;return r>=this.transition_?1:oi(r/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}};function V(e,t,n,r){let i;return i=n&&n.length?n.shift():ei?new class extends OffscreenCanvas{style={}}(e??300,t??150):document.createElement(`canvas`),e&&(i.width=e),t&&(i.height=t),i.getContext(`2d`,r)}var di;function fi(){return di||=V(1,1),di}function pi(e){let t=e.canvas;t.width=1,t.height=1,e.clearRect(0,0,1,1)}function mi(e,t){let n=t.parentNode;n&&n.replaceChild(e,t)}function hi(e){for(;e.lastChild;)e.lastChild.remove()}function gi(e,t){let n=e.childNodes;for(let r=0;;++r){let i=n[r],a=t[r];if(!i&&!a)break;if(i!==a){if(!i){e.appendChild(a);continue}if(!a){e.removeChild(i),--r;continue}e.insertBefore(a,i)}}}function _i(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){let t=this.childNodes.indexOf(e);if(t===-1)throw Error(`Node to remove was not found`);return this.childNodes.splice(t,1),e},insertBefore:function(e,t){let n=this.childNodes.indexOf(t);if(n===-1)throw Error(`Reference node not found`);return this.childNodes.splice(n,0,e),e},style:{}},{get(e,t,n){return t===`firstElementChild`?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,n)}})}function vi(e){return typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}var yi=class extends ui{constructor(e,t,n,r,i,a){super(e,t,a),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=n,this.key=n,this.image_,ei?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=i}getImage(){return this.image_}setImage(e){this.image_=e,this.state=B.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=B.ERROR,this.unlistenImage_(),this.image_=bi(),this.changed()}handleImageLoad_(){if(ei)this.state=B.LOADED;else{let e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=B.LOADED:this.state=B.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==B.ERROR&&(this.state=B.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==B.IDLE&&(this.state=B.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=ri(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&=(this.unlisten_(),null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function bi(){let e=V(1,1);return e.fillStyle=`rgba(0,0,0,0)`,e.fillRect(0,0,1,1),e.canvas}var xi=class{constructor(e,t,n){this.decay_=e,this.minVelocity_=t,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;let e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]0&&this.points_[n+2]>e;)n-=3;let r=this.points_[t+2]-this.points_[n+2];if(r<1e3/60)return!1;let i=this.points_[t]-this.points_[n],a=this.points_[t+1]-this.points_[n+1];return this.angle_=Math.atan2(a,i),this.initialVelocity_=Math.sqrt(i*i+a*a)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}};function Si(e,t,n,r,i,a,o){let s,c,l=(n-t)/r;if(l===1)s=t;else if(l===2)s=t,c=i;else if(l!==0){let a=e[t],o=e[t+1],l=0,d=[0];for(let i=t+r;i1?o:2,a||=Array(o);for(let t=0;t>1;i.0031308?e**(1/2.4)*269.025-14.025:e*3294.6}function Ui(e){return e>.2068965?e**3:(e-4/29)*(108/841)}function Wi(e){return e>10.314724?((e+14.025)/269.025)**2.4:e/3294.6}function Gi(e){return e>.0088564?e**(1/3):e/(108/841)+4/29}function Ki(e){let t=Wi(e[0]),n=Wi(e[1]),r=Wi(e[2]),i=Gi(t*.222488403+n*.716873169+r*.06060791),a=500*(Gi(t*.452247074+n*.399439023+r*.148375274)-i),o=200*(i-Gi(t*.016863605+n*.117638439+r*.865350722)),s=180/Math.PI*Math.atan2(o,a);return[116*i-16,Math.sqrt(a*a+o*o),s<0?s+360:s,e[3]]}function qi(e){let t=(e[0]+16)/116,n=e[1],r=e[2]*Math.PI/180,i=Ui(t),a=Ui(t+n/500*Math.cos(r)),o=Ui(t-n/200*Math.sin(r)),s=Hi(a*3.021973625-i*1.617392459-o*.404875592),c=Hi(a*-.943766287+i*1.916279586+o*.027607165),l=Hi(a*.069407491-i*.22898585+o*1.159737864);return[I(s+.5|0,0,255),I(c+.5|0,0,255),I(l+.5|0,0,255),e[3]]}function Ji(e){if(e===`none`)return Di;if(zi.hasOwnProperty(e))return zi[e];if(Bi>=Ri){let e=0;for(let t in zi)e++&3||(delete zi[t],--Bi)}let t=Ii(e);t.length!==4&&Fi(e);for(let n of t)isNaN(n)&&Fi(e);return zi[e]=t,++Bi,t}function Yi(e){return Array.isArray(e)?e:Ji(e)}function Xi(e){let t=e[0];t!=(t|0)&&(t=t+.5|0);let n=e[1];n!=(n|0)&&(n=n+.5|0);let r=e[2];r!=(r|0)&&(r=r+.5|0);let i=e[3]===void 0?1:Math.round(e[3]*1e3)/1e3;return`rgba(`+t+`,`+n+`,`+r+`,`+i+`)`}var Zi=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let t in this.cache_){let n=this.cache_[t];!(e++&3)&&!n.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t){let n=Qi(e,t);return n in this.cache_?this.cache_[n]:null}getPattern(e,t){let n=Qi(e,t);return n in this.patternCache_?this.patternCache_[n]:null}set(e,t,n,r){let i=Qi(e,t),a=i in this.cache_;this.cache_[i]=n,r&&(n.getImageState()===z.IDLE&&n.load(),n.getImageState()===z.LOADING?n.ready().then(()=>{this.patternCache_[i]=fi().createPattern(n.getImage(1),`repeat`)}):this.patternCache_[i]=fi().createPattern(n.getImage(1),`repeat`)),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function Qi(e,t){let n=t?Yi(t):`null`;return e+`:`+n}var $i=new Zi,ea=null,ta=class extends w{constructor(e,t,n,r,i){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=i,this.imageState_=r===void 0?z.IDLE:r,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===z.LOADED){ea||=V(1,1,void 0,{willReadFrequently:!0}),ea.drawImage(this.image_,0,0);try{ea.getImageData(0,0,1,1),this.tainted_=!1}catch{ea=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(c.CHANGE)}handleImageError_(){this.imageState_=z.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=z.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}setImage(e){this.image_=e}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],t=this.size_[1],n=V(e,t);n.fillRect(0,0,e,t),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===z.IDLE){this.image_||this.initializeImage_(),this.imageState_=z.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&ai(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==z.LOADED)return;let t=this.image_,n=V(Math.ceil(t.width*e),Math.ceil(t.height*e)),r=n.canvas;n.scale(e,e),n.drawImage(t,0,0),n.globalCompositeOperation=`multiply`,n.fillStyle=Li(this.color_),n.fillRect(0,0,r.width/e,r.height/e),n.globalCompositeOperation=`destination-in`,n.drawImage(t,0,0),this.canvas_[e]=r}ready(){return this.ready_||=new Promise(e=>{if(this.imageState_===z.LOADED||this.imageState_===z.ERROR)e();else{let t=()=>{(this.imageState_===z.LOADED||this.imageState_===z.ERROR)&&(this.removeEventListener(c.CHANGE,t),e())};this.addEventListener(c.CHANGE,t)}}),this.ready_}};function na(e,t,n,r,i,a){let o=t===void 0?void 0:$i.get(t,i);return o||(o=new ta(e,e&&`src`in e?e.src||void 0:t,n,r,i),$i.set(t,i,o,a)),a&&o&&!$i.getPattern(t,i)&&$i.set(t,i,o,a),o}function ra(e){return e?Array.isArray(e)?Xi(e):typeof e==`object`&&`src`in e?ia(e):e:null}function ia(e){if(!e.offset||!e.size)return $i.getPattern(e.src,e.color);let t=e.src+`:`+e.offset,n=$i.getPattern(t,e.color);if(n)return n;let r=$i.get(e.src,null);if(r.getImageState()!==z.LOADED)return null;let i=V(e.size[0],e.size[1]);return i.drawImage(r.getImage(1),e.offset[0],e.offset[1],e.size[0],e.size[1],0,0,e.size[0],e.size[1]),na(i.canvas,t,void 0,z.LOADED,e.color,!0),$i.getPattern(t,e.color)}function aa(e,t,n,r,i,a,o,s){o??=[],s??=r;let c=e[t+r],l=e[t+r+1],u=e[n-2*r],d=e[n-2*r+1],f,p,m,h,g,_,v,y,b=0;for(let x=t;x.998)return[e+u*o,t+d*o];let p=Math.cos(f/2),m=Math.sin(f/2),h=m*s+p*c,g=-p*s+m*c,_=1/m*h,v=1/m*g;return[e+_*o,t+v*o]}function sa(e,t){for(let n=0,r=e.length-2;nn+t;r-=t){let i=e[n],a=e[n+1],o=e[n+t],s=e[n+t+1],c=e[r],l=e[r+1],u=e[r+t],d=e[r+t+1],f=(d-l)*(o-i)-(u-c)*(s-a);if(f===0)continue;let p=((u-c)*(a-l)-(d-l)*(i-c))/f,m=((o-i)*(a-l)-(s-a)*(i-c))/f;if(p>0&&p<1&&m>0&&m<1){let c=i+p*(o-i),l=a+p*(s-a);e[n+t]=c,e[n+t+1]=l,e.splice(n+2*t,r-n-t);break}}return e}var ca=class{drawCustom(e,t,n,r,i){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,n){}drawFeature(e,t,n){}drawGeometryCollection(e,t,n){}drawLineString(e,t,n){}drawMultiLineString(e,t,n){}drawMultiPoint(e,t,n){}drawMultiPolygon(e,t,n){}drawPoint(e,t,n){}drawPolygon(e,t,n){}drawText(e,t,n){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}},la=`ol-hidden`,ua=`ol-unselectable`,da=`ol-control`,fa=`ol-collapsed`,pa=new RegExp([`^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)`,`(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)`,`(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)`,`(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?`,`(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))`,`(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))`,`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(``),`i`),ma=[`style`,`variant`,`weight`,`size`,`lineHeight`,`family`],ha={normal:400,bold:700},ga=function(e){let t=e.match(pa);if(!t)return null;let n={lineHeight:`normal`,size:`1.2em`,style:`normal`,weight:`400`,variant:`normal`};for(let e=0,r=ma.length;ee.trim().replace(/^['"]|['"]$/g,``)),n},_a=`10px sans-serif`,va=`#000`,ya=`round`,ba=[],xa=`round`,Sa=`#000`,Ca=`center`,wa=`middle`,Ta=[0,0,0,0],Ea=new j,Da=null,Oa,ka={},Aa=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`emoji`,`math`,`fangsong`]);function ja(e,t,n){return`${e} ${t} 16px "${n}"`}var Ma=(function(){let e,t;async function n(e){await t.ready;let n=await t.load(e);if(n.length===0)return!1;let r=ga(e),i=r.families[0].toLowerCase(),a=r.weight;return n.some(e=>{let t=e.family.replace(/^['"]|['"]$/g,``).toLowerCase(),n=ha[e.weight]||e.weight;return t===i&&e.style===r.style&&n==a})}async function i(){await t.ready;let a=!0,o=Ea.getProperties(),s=Object.keys(o).filter(e=>o[e]<100);for(let e=s.length-1;e>=0;--e){let t=s[e],i=o[t];i<100&&(await n(t)?(r(ka),Ea.set(t,100)):(i+=10,Ea.set(t,i,!0),i<100&&(a=!1)))}e=void 0,a||(e=setTimeout(i,100))}return async function(n){t||=ei?self.fonts:document.fonts;let r=ga(n);if(!r)return;let a=r.families,o=!1;for(let e of a){if(Aa.has(e))continue;let t=ja(r.style,r.weight,e);Ea.get(t)===void 0&&(Ea.set(t,0,!0),o=!0)}o&&(clearTimeout(e),e=setTimeout(i,100))}})(),Na=(function(){let e;return function(t){let n=ka[t];if(n==null){if(ei){let e=ga(t),r=Pa(t,`Žg`);n=(isNaN(Number(e.lineHeight))?1.2:Number(e.lineHeight))*(r.actualBoundingBoxAscent+r.actualBoundingBoxDescent)}else e||(e=document.createElement(`div`),e.innerHTML=`M`,e.style.minHeight=`0`,e.style.maxHeight=`none`,e.style.height=`auto`,e.style.padding=`0`,e.style.border=`none`,e.style.position=`absolute`,e.style.display=`block`,e.style.left=`-99999px`),e.style.font=t,document.body.appendChild(e),n=e.offsetHeight,document.body.removeChild(e);ka[t]=n}return n}})();function Pa(e,t){return Da||=V(1,1),e!=Oa&&(Da.font=e,Oa=Da.font),Da.measureText(t)}function Fa(e,t){return Pa(e,t).width}function Ia(e,t,n){if(t in n)return n[t];let r=t.split(` +`).reduce((t,n)=>Math.max(t,Fa(e,n)),0);return n[t]=r,r}function La(e,t){let n=[],r=[],i=[],a=0,o=0,s=0,c=0;for(let l=0,u=t.length;l<=u;l+=2){let d=t[l];if(d===` +`||l===u){a=Math.max(a,o),i.push(o),o=0,s+=c,c=0;continue}let f=t[l+1]||e.font,p=Fa(f,d);n.push(p),o+=p;let m=Na(f);r.push(m),c=Math.max(c,m)}return{width:a,height:s,widths:n,heights:r,lineWidths:i}}function Ra(e,t,n,r,i,a,o,s,c,l,u){e.save(),n!==1&&(e.globalAlpha===void 0?e.globalAlpha=e=>e.globalAlpha*=n:e.globalAlpha*=n),t&&e.transform.apply(e,t),r.contextInstructions?(e.translate(c,l),e.scale(u[0],u[1]),za(r,e)):u[0]<0||u[1]<0?(e.translate(c,l),e.scale(u[0],u[1]),e.drawImage(r,i,a,o,s,0,0,o,s)):e.drawImage(r,i,a,o,s,c,l,o*u[0],s*u[1]),e.restore()}function za(e,t){let n=e.contextInstructions;for(let e=0,r=n.length;e0&&(s=aa(s,0,s.length,2,a,i,s),sa(s,2)),o.moveTo(s[0],s[1]);let c=s.length;i&&(c-=2);for(let e=2;ee*this.pixelRatio_),lineDashOffset:(i||0)*this.pixelRatio_,lineJoin:a===void 0?xa:a,lineWidth:(o===void 0?1:o)*this.pixelRatio_,miterLimit:s===void 0?10:s,strokeStyle:ra(e||Sa),strokeOffset:(l??0)*this.pixelRatio_}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}let n=e.getPixelRatio(this.pixelRatio_),r=e.getAnchor(),i=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*n,this.imageAnchorY_=r[1]*n,this.imageHeight_=t[1]*n,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=i[0],this.imageOriginY_=i[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let a=e.getScaleArray();this.imageScale_=[a[0]*this.pixelRatio_/n,a[1]*this.pixelRatio_/n],this.imageWidth_=t[0]*n}setTextStyle(e){if(!e)this.text_=``;else{let t=e.getFill();t?this.textFillState_={fillStyle:ra(t.getColor()||va)}:this.textFillState_=null;let n=e.getStroke();if(!n)this.textStrokeState_=null;else{let e=n.getColor(),t=n.getLineCap(),r=n.getLineDash(),i=n.getLineDashOffset(),a=n.getLineJoin(),o=n.getWidth(),s=n.getMiterLimit();this.textStrokeState_={lineCap:t===void 0?ya:t,lineDash:r||ba,lineDashOffset:i||0,lineJoin:a===void 0?xa:a,lineWidth:o===void 0?1:o,miterLimit:s===void 0?10:s,strokeStyle:ra(e||Sa)}}let r=e.getFont(),i=e.getOffsetX(),a=e.getOffsetY(),o=e.getRotateWithView(),s=e.getRotation(),c=e.getScaleArray(),l=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:r===void 0?_a:r,textAlign:u===void 0?Ca:u,textBaseline:d===void 0?wa:d},this.text_=l===void 0?``:Array.isArray(l)?l.reduce((e,t,n)=>e+=n%2?` `:t,``):l,this.textOffsetX_=i===void 0?0:this.pixelRatio_*i,this.textOffsetY_=a===void 0?0:this.pixelRatio_*a,this.textRotateWithView_=o===void 0?!1:o,this.textRotation_=s===void 0?0:s,this.textScale_=[this.pixelRatio_*c[0],this.pixelRatio_*c[1]]}}},Va=.5,Ha={Point:eo,LineString:Za,Polygon:no,MultiPoint:to,MultiLineString:Qa,MultiPolygon:$a,GeometryCollection:Xa,Circle:Ka};function Ua(e,t){return parseInt(k(e),10)-parseInt(k(t),10)}function Wa(e,t){let n=Ga(e,t);return n*n}function Ga(e,t){return Va*e/t}function Ka(e,t,n,r,i){let a=n.getFill(),o=n.getStroke();if(a||o){let s=e.getBuilder(n.getZIndex(),`Circle`);s.setFillStrokeStyle(a,o),s.drawCircle(t,r,i)}let s=n.getText();if(s&&s.getText()){let a=e.getBuilder(n.getZIndex(),`Text`);a.setTextStyle(s),a.drawText(t,r,i)}}function qa(e,t,n,r,i,a,o,s){let c=[],l=n.getImage();if(l){let e=!0,t=l.getImageState();t==z.LOADED||t==z.ERROR?e=!1:t==z.IDLE&&l.load(),e&&c.push(l.ready())}let u=n.getFill();u&&u.loading()&&c.push(u.ready());let d=c.length>0;return d&&Promise.all(c).then(()=>i(null)),Ja(e,t,n,r,a,o,s),d}function Ja(e,t,n,r,i,a,o){let s=n.getGeometryFunction()(t);if(!s)return;let c=s.simplifyTransformed(r,i);if(n.getRenderer())Ya(e,c,n,t,o);else{let r=Ha[c.getType()];r(e,c,n,t,o,a)}}function Ya(e,t,n,r,i){if(t.getType()==`GeometryCollection`){let a=t.getGeometries();for(let t=0,o=a.length;t=200&&s.status<300){let e=t.getType();try{let r;e==`text`||e==`json`?r=s.responseText:e==`xml`?r=s.responseXML||s.responseText:e==`arraybuffer`&&(r=s.response),r?a(t.readFeatures(r,{extent:n,featureProjection:i}),t.readProjection(r)):o()}catch{o()}}else o()},s.onerror=o,s.send()}function oo(e,t){return function(n,r,i,a,o){ao(e,t,n,r,i,(e,t)=>{this.addFeatures(e),a!==void 0&&a(e)},()=>{this.changed(),o!==void 0&&o()})}}function so(e,t){return[[-1/0,-1/0,1/0,1/0]]}var co=class e extends er{constructor(e,t,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,t);else if(t!==void 0&&n)this.setFlatCoordinates(t,e),this.ends_=n;else{let t=e,n=[],r=[];for(let e=0,i=t.length;e{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),n&&this.simplifiedGeometry_.applyTransform(n);let r=this.simplifiedGeometry_.getFlatCoordinates(),i;switch(this.type_){case`LineString`:r.length=xr(r,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,r,0),i=[r.length];break;case`MultiLineString`:i=[],r.length=Sr(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,r,0,i);break;case`Polygon`:i=[],r.length=Tr(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),r,0,i);break;default:}return i&&(this.simplifiedGeometry_=new e(this.type_,r,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};mo.prototype.getFlatCoordinates=mo.prototype.getOrientedFlatCoordinates;function ho(e,t,n=0,r=e.length-1,i=_o){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);ho(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(go(e,n,t),i(e[r],a)>0&&go(e,n,r);o0;)s--}i(e[n],a)===0?go(e,n,s):(s++,go(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function go(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function _o(e,t){return et)}var vo=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!Ao(e,t))return n;let r=this.toBBox,i=[];for(;t;){for(let a=0;a=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)}_split(e,t){let n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);let a=this._chooseSplitIndex(n,i,r),o=jo(n.children.splice(a,n.children.length-a));o.height=n.height,o.leaf=n.leaf,bo(n,this.toBBox),bo(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)}_splitRoot(e,t){this.data=jo([e,t]),this.data.height=e.height+1,this.data.leaf=!1,bo(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,i=1/0,a=1/0;for(let o=t;o<=n-t;o++){let t=xo(e,0,o,this.toBBox),s=xo(e,o,n,this.toBBox),c=Oo(t,s),l=To(t)+To(s);c=t;r--){let t=e.children[r];So(o,e.leaf?i(t):t),s+=Eo(o)}return s}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)So(t[r],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():bo(e[t],this.toBBox)}};function yo(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r=e.minX&&t.maxY>=e.minY}function jo(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Mo(e,t,n,r,i){let a=[t,n];for(;a.length;){if(n=a.pop(),t=a.pop(),n-t<=r)continue;let o=t+Math.ceil((n-t)/r/2)*r;ho(e,o,t,n,i),a.push(t,o,o,n)}}var No=class{constructor(e){this.rbush_=new vo(e),this.items_={}}insert(e,t){let n={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(n),this.items_[k(t)]=n}load(e,t){let n=Array(t.length);for(let r=0,i=t.length;re):null}var Io={ADDFEATURE:`addfeature`,CHANGEFEATURE:`changefeature`,CLEAR:`clear`,REMOVEFEATURE:`removefeature`,FEATURESLOADSTART:`featuresloadstart`,FEATURESLOADEND:`featuresloadend`,FEATURESLOADERROR:`featuresloaderror`},Lo=class extends C{constructor(e,t,n){super(e),this.feature=t,this.features=n}},Ro=class extends Po{constructor(e){e||={},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:`ready`,wrapX:e.wrapX===void 0?!0:e.wrapX}),this.on,this.once,this.un,this.loader_=b,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader===void 0?this.url_!==void 0&&(M(this.format_,"`format` must be set when `url` is set"),this.loader_=oo(this.url_,this.format_)):this.loader_=e.loader,this.strategy_=e.strategy===void 0?so:e.strategy;let t=e.useSpatialIndex===void 0?!0:e.useSpatialIndex;this.featuresRtree_=t?new No:null,this.loadedExtentsRtree_=new No,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,r;Array.isArray(e.features)?r=e.features:e.features&&(n=e.features,r=n.getArray()),!t&&n===void 0&&(n=new ne(r)),r!==void 0&&this.addFeaturesInternal(r),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=k(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);let n=e.getGeometry();if(n){let t=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(t,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new Lo(Io.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof mo||(this.featureChangeKeys_[e]=[a(t,c.CHANGE,this.handleFeatureChange_,this),a(t,n.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let n=!0;if(t.getId()!==void 0){let e=String(t.getId());if(!(e in this.idIndex_))this.idIndex_[e]=t;else if(t instanceof mo){let r=this.idIndex_[e];r instanceof mo?Array.isArray(r)?r.push(t):this.idIndex_[e]=[r,t]:n=!1}else n=!1}return n&&(M(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),n}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let t=[],n=[],r=[];for(let t=0,r=e.length;t{n||=(n=!0,this.addFeature(e.element),!1)}),e.addEventListener(t.REMOVE,e=>{n||=(n=!0,this.removeFeature(e.element),!1)}),this.featuresCollection_=e}clear(e){if(e){for(let e in this.featureChangeKeys_)this.featureChangeKeys_[e].forEach(s);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(e=>{this.removeFeatureInternal(e)});for(let e in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[e])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let t=new Lo(Io.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){let n=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(n,function(n){let r=n.getGeometry();if(r instanceof mo||r.intersectsCoordinate(e))return t(n)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(n){let r=n.getGeometry();if(r instanceof mo||r.intersectsExtent(e)){let e=t(n);if(e)return e}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),i(this.nullGeometryFeatures_)||h(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let t=[];return this.forEachFeatureAtCoordinateDirect(e,function(e){t.push(e)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let n=Ve(e,t);return[].concat(...n.map(e=>this.featuresRtree_.getInExtent(e)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){let n=e[0],r=e[1],i=null,a=[NaN,NaN],o=1/0,s=[-1/0,-1/0,1/0,1/0];return t||=v,this.featuresRtree_.forEachInExtent(s,function(e){if(t(e)){let t=e.getGeometry(),c=o;if(o=t instanceof mo?0:t.closestPointXY(n,r,a,o),o{this.loading=Number(this.loading)-1,this.dispatchEvent(new Lo(Io.FEATURESLOADEND,void 0,e))},i=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new Lo(Io.FEATURESLOADERROR))},o=!1,s=this.loader_.call(this,a,t,n,t=>o||e(t),()=>o||i());s instanceof Promise?(o=!0,s.then(t=>{this.addFeatures(t),e(t)}).catch(i)):this.loader_.length<4&&(this.loading=!1),r.insert(a,{extent:a.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let t=this.loadedExtentsRtree_,n=t.forEachInExtent(e,function(t){if(ye(t.extent,e))return t});n&&t.remove(n)}removeFeatures(e){let t=!1;for(let n=0,r=e.length;n{this.patternImage_=null}),t.getImageState()===z.IDLE&&t.load(),t.getImageState()===z.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){let e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?k(e):typeof e==`object`&&`src`in e?e.src+`:`+e.offset:Yi(e).toString():``}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Bo=class e{constructor(e){e||={},this.color_=e.color===void 0?null:e.color,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash===void 0?null:e.lineDash,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.offset_=e.offset,this.width_=e.width}clone(){let t=this.getColor();return new e({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setOffset(e){this.offset_=e}setWidth(e){this.width_=e}};function Vo(e){return e[0]>0&&e[1]>0}function Ho(e,t,n){return n===void 0&&(n=[0,0]),n[0]=e[0]*t+.5|0,n[1]=e[1]*t+.5|0,n}function Uo(e,t){return Array.isArray(e)?e:(t===void 0?t=[e,e]:(t[0]=e,t[1]=e),t)}var Wo=class e{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Uo(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let t=this.getScale();return new e({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return D()}getImage(e){return D()}getHitDetectionImage(){return D()}getPixelRatio(e){return 1}getImageState(){return D()}getImageSize(){return D()}getOrigin(){return D()}getSize(){return D()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Uo(e)}listenImageChange(e){D()}load(){D()}unlistenImageChange(e){D()}ready(){return Promise.resolve()}},Go=class e extends Wo{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView===void 0?!1:e.rotateWithView,rotation:e.rotation===void 0?0:e.rotation,scale:e.scale===void 0?1:e.scale,displacement:e.displacement===void 0?[0,0]:e.displacement,declutterMode:e.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=e.fill===void 0?null:e.fill,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle===void 0?0:e.angle,this.stroke_=e.stroke===void 0?null:e.stroke,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?z.LOADING:z.LOADED,this.imageState_===z.LOADING&&this.ready().then(()=>this.imageState_=z.LOADED),this.render()}clone(){let t=this.getScale(),n=new e({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return n.setOpacity(this.getOpacity()),n}getAnchor(){let e=this.size_,t=this.getDisplacement(),n=this.getScaleArray();return[e[0]/2-t[0]/n[0],e[1]/2+t[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||=this.createHitDetectionCanvas_(this.renderOptions_),this.hitDetectionCanvas_}getImage(e){let t=this.fill_?.getKey(),n=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(`,`),r=$i.get(n,null)?.getImage(1);if(!r){let t=this.renderOptions_,i=Math.ceil(t.size*e),a=V(i,i);this.draw_(t,a,e),r=a.canvas;let o=new ta(r,void 0,null,z.LOADED,null);$i.set(n,null,o),createImageBitmap(r).then(e=>{o.setImage(e)})}return r}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(e){this.radius!==e&&(this.radius=e,this.render())}getRadius2(){return this.radius2_}setRadius2(e){this.radius2_!==e&&(this.radius2_=e,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,n){if(t===0||this.points_===1/0||e!==`bevel`&&e!==`miter`)return t;let r=this.radius,i=this.radius2_===void 0?r:this.radius2_;if(rs&&(this.instructions.push([U.CUSTOM,s,l,e,n,vr,i]),this.hitDetectionInstructions.push([U.CUSTOM,s,l,e,r||n,vr,i]));break;case`Point`:c=e.getFlatCoordinates(),this.coordinates.push(c[0],c[1]),l=this.coordinates.length,this.instructions.push([U.CUSTOM,s,l,e,n,void 0,i]),this.hitDetectionInstructions.push([U.CUSTOM,s,l,e,r||n,void 0,i]);break;default:}this.endGeometry(t)}beginGeometry(e,t,n){this.beginGeometryInstruction1_=[U.BEGIN_GEOMETRY,t,0,e,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[U.BEGIN_GEOMETRY,t,0,e,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let t,n=e.length,r,i,a=-1;for(t=0;tthis.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0,t.strokeOffset=void 0;return t}setFillStrokeStyle(e,t){let n=this.state;this.fillStyleToState(e,n),this.strokeStyleToState(t,n)}createFill(e){let t=e.fillStyle,n=[U.SET_FILL_STYLE,t];return typeof t!=`string`&&n.push(e.fillPatternScale),n}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[U.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){let n=e.fillStyle;(n!==void 0&&typeof n!=`string`||e.currentFillStyle!=n)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=n)}updateStrokeStyle(e,t){let n=e.strokeStyle,r=e.lineCap,i=e.lineDash,a=e.lineDashOffset,o=e.lineJoin,s=e.lineWidth,c=e.miterLimit,l=e.strokeOffset;(e.currentStrokeStyle!=n||e.currentLineCap!=r||i!=e.currentLineDash&&!g(e.currentLineDash,i)||e.currentLineDashOffset!=a||e.currentLineJoin!=o||e.currentLineWidth!=s||e.currentMiterLimit!=c||e.currentStrokeOffset!=l)&&(t.call(this,e),e.currentStrokeStyle=n,e.currentLineCap=r,e.currentLineDash=i,e.currentLineDashOffset=a,e.currentLineJoin=o,e.currentLineWidth=s,e.currentMiterLimit=c,e.currentStrokeOffset=l)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let t=[U.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=ce(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;se(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},as=class extends is{constructor(e,t,n,r){super(e,t,n,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,n){if(!this.image_||this.maxExtent&&!ue(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,n);let r=e.getFlatCoordinates(),i=e.getStride(),a=this.coordinates.length,o=this.appendFlatPointCoordinates(r,i);this.instructions.push([U.DRAW_IMAGE,a,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([U.DRAW_IMAGE,a,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,n){if(!this.image_)return;this.beginGeometry(e,t,n);let r=e.getFlatCoordinates(),i=[];for(let t=0,n=r.length;tthis.drawCircle(e,t,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_FILL_STYLE,va]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_STROKE_STYLE,Sa,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,ba,0]);let s=e.getFlatCoordinates(),c=e.getStride(),l=this.coordinates.length;this.appendFlatLineCoordinates(s,0,s.length,c,!1,!1);let u=[U.CIRCLE,l,o];this.instructions.push(ns,u),this.hitDetectionInstructions.push(ns,u),r.fillStyle!==void 0&&(this.instructions.push(es),this.hitDetectionInstructions.push(es)),r.strokeStyle!==void 0&&(this.instructions.push(ts),this.hitDetectionInstructions.push(ts)),this.endGeometry(t)}drawPolygon(e,t,n){let r=this.state,i=r.fillStyle,a=r.strokeStyle,o=r.strokeOffset;if(i===void 0&&a===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(e,t,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_FILL_STYLE,va]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_STROKE_STYLE,Sa,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,ba,0]);let s=e.getEnds(),c=e.getOrientedFlatCoordinates(),l=e.getStride();this.drawFlatCoordinatess_(c,0,s,l,o),this.endGeometry(t)}drawMultiPolygon(e,t,n){let r=this.state,i=r.fillStyle,a=r.strokeStyle,o=r.strokeOffset;if(i===void 0&&a===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(e,t,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_FILL_STYLE,va]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([U.SET_STROKE_STYLE,Sa,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,ba,0]);let s=e.getEndss(),c=e.getOrientedFlatCoordinates(),l=e.getStride(),u=0;for(let e=0,t=s.length;e0&&n!==void 0&&r!==void 0?(t.strokeStyle=void 0,t.strokeOffset=0,e(),t.fillStyle=void 0,t.strokeStyle=r,t.strokeOffset=i,e(),t.fillStyle=n,!0):!1}};function cs(e,t,n,r,i){let a=[],o=n,s=0,c=t.slice(n,2);for(;s=e){let t=(e-s+d)/d,f=Je(n,l,t),p=Je(r,u,t);c.push(f,p),a.push(c),c=[f,p],s==e&&(o+=i),s=0}else if(s0&&a.push(c),a}function ls(e,t,n,r,i){let a=n,o=n,s=0,c=0,l=n,u,d,f,p,m,h,g,_,v,y;for(d=n;de&&(c>s&&(s=c,a=l,o=d),c=0,l=d-i)),f=p,g=v,_=y),m=n,h=r}return c+=p,c>s?[l,d]:[a,o]}var us={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ds={Circle:ss,Default:is,Image:as,LineString:os,Polygon:ss,Text:class extends is{constructor(e,t,n,r){super(e,t,n,r),this.labels_=null,this.text_=``,this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[va]={fillStyle:va},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_=``,this.fillKey_=``,this.strokeKey_=``,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,n){let r=this.textFillState_,i=this.textStrokeState_,a=this.textState_;if(this.text_===``||!a||!r&&!i)return;let o=this.coordinates,s=o.length,c=e.getType(),l=null,u=e.getStride();if(a.placement===`line`&&(c==`LineString`||c==`MultiLineString`||c==`Polygon`||c==`MultiPolygon`)){if(!Fe(this.maxExtent,e.getExtent()))return;let r;if(l=e.getFlatCoordinates(),c==`LineString`)r=[l.length];else if(c==`MultiLineString`)r=e.getEnds();else if(c==`Polygon`)r=e.getEnds().slice(0,1);else if(c==`MultiPolygon`){let t=e.getEndss();r=[];for(let e=0,n=t.length;e{let r=o[(e+n)*2]===l[n*u]&&o[(e+n)*2+1]===l[n*u+1];return r||--e,r})}this.saveTextStates_();let d=a.backgroundFill?this.createFill(this.fillStyleToState(a.backgroundFill)):null,f=a.backgroundStroke?this.createStroke(this.strokeStyleToState(a.backgroundStroke)):null;this.beginGeometry(e,t,n);let p=a.padding;if(p!=Ta&&(a.scale[0]<0||a.scale[1]<0)){let e=a.padding[0],t=a.padding[1],n=a.padding[2],r=a.padding[3];a.scale[0]<0&&(t=-t,r=-r),a.scale[1]<0&&(e=-e,n=-n),p=[e,t,n,r]}let m=this.pixelRatio;this.instructions.push([U.DRAW_IMAGE,s,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==Ta?Ta:p.map(function(e){return e*m}),d,f,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]);let h=1/m,g=d?d.slice(0):null;g&&(g[1]=va),this.hitDetectionInstructions.push([U.DRAW_IMAGE,s,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[h,h],NaN,this.declutterMode_,this.declutterImageWithText_,p,g,f,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?va:this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]),this.endGeometry(t)}}saveTextStates_(){let e=this.textStrokeState_,t=this.textState_,n=this.textFillState_,r=this.strokeKey_;e&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let i=this.textKey_;i in this.textStates||(this.textStates[i]={font:t.font,textAlign:t.textAlign||`center`,justify:t.justify,textBaseline:t.textBaseline||`middle`,scale:t.scale});let a=this.fillKey_;n&&(a in this.fillStates||(this.fillStates[a]={fillStyle:n.fillStyle}))}drawChars_(e,t){let n=this.textStrokeState_,r=this.textState_,i=this.strokeKey_,a=this.textKey_,o=this.fillKey_;this.saveTextStates_();let s=this.pixelRatio,c=us[r.textBaseline],l=this.textOffsetY_*s,u=this.text_,d=n?n.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([U.DRAW_CHARS,e,t,c,r.overflow,o,r.maxAngle,s,l,i,d*s,u,a,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([U.DRAW_CHARS,e,t,c,r.overflow,o&&va,r.maxAngle,s,l,i,d*s,u,a,1/s,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let n,r,i;if(!e)this.text_=``;else{let t=e.getFill();t?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=ra(t.getColor()||`#000`)):(r=null,this.textFillState_=r);let a=e.getStroke();if(!a)i=null,this.textStrokeState_=i;else{i=this.textStrokeState_,i||(i={},this.textStrokeState_=i);let e=a.getLineDash(),t=a.getLineDashOffset(),n=a.getWidth(),r=a.getMiterLimit();i.lineCap=a.getLineCap()||`round`,i.lineDash=e?e.slice():ba,i.lineDashOffset=t===void 0?0:t,i.lineJoin=a.getLineJoin()||`round`,i.lineWidth=n===void 0?1:n,i.miterLimit=r===void 0?10:r,i.strokeStyle=ra(a.getColor()||`#000`)}n=this.textState_;let o=e.getFont()||`10px sans-serif`;Ma(o);let s=e.getScaleArray();n.overflow=e.getOverflow(),n.font=o,n.maxAngle=e.getMaxAngle(),n.placement=e.getPlacement(),n.textAlign=e.getTextAlign(),n.repeat=e.getRepeat(),n.justify=e.getJustify(),n.textBaseline=e.getTextBaseline()||`middle`,n.backgroundFill=e.getBackgroundFill(),n.backgroundStroke=e.getBackgroundStroke(),n.padding=e.getPadding()||Ta,n.scale=s===void 0?[1,1]:s;let c=e.getOffsetX(),l=e.getOffsetY(),u=e.getRotateWithView(),d=e.getKeepUpright(),f=e.getRotation();this.text_=e.getText()||``,this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=l===void 0?0:l,this.textRotateWithView_=u===void 0?!1:u,this.textKeepUpright_=d===void 0?!0:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=i?(typeof i.strokeStyle==`string`?i.strokeStyle:k(i.strokeStyle))+i.lineCap+i.lineDashOffset+`|`+i.lineWidth+i.lineJoin+i.miterLimit+`[`+i.lineDash.join()+`]`:``,this.textKey_=n.font+n.scale+(n.textAlign||`?`)+(n.repeat||`?`)+(n.justify||`?`)+(n.textBaseline||`?`),this.fillKey_=r&&r.fillStyle?typeof r.fillStyle==`string`?r.fillStyle:`|`+k(r.fillStyle):``}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}},fs=class{constructor(e,t,n,r){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=r,this.resolution_=n,this.buildersByZIndex_={}}finish(){let e={};for(let t in this.buildersByZIndex_){e[t]=e[t]||{};let n=this.buildersByZIndex_[t];for(let r in n){let i=n[r].finish();e[t][r]=i}}return e}getBuilder(e,t){let n=e===void 0?`0`:e.toString(),r=this.buildersByZIndex_[n];r===void 0&&(r={},this.buildersByZIndex_[n]=r);let i=r[t];if(i===void 0){let e=ds[t];i=new e(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[t]=i}return i}};function ps(e,t,n,r,i,a,o,s,c,l,u,d,f=!0){let p=e[t],m=e[t+1],h=0,g=0,_=0,v=0;function y(){h=p,g=m,t+=r,p=e[t],m=e[t+1],v+=_,_=Math.sqrt((p-h)*(p-h)+(m-g)*(m-g))}do y();while(te[2]}else O=x>E;let k=Math.PI,A=[],j=C+r===t;t=C,_=0,v=w,p=e[t],m=e[t+1];let ee;if(j)return y(),ee=Math.atan2(m-g,p-h),O&&(ee+=ee>0?-k:k),A[0]=[(E+x)/2,(D+S)/2,(T-a)/2,ee,i],A;i=i.replace(/\n/g,` `);for(let e=0,d=i.length;e0?-k:k),ee!==void 0){let e=f-ee;if(e+=e>k?-2*k:e<-k?2*k:0,Math.abs(e)>o)return null}ee=f;let x=e,S=0;for(;e{if(typeof fi()[t]==`function`)return this.push_(t),this.pushMethodArgs_},set:(e,t,n)=>(this.push_(t,n),!0)})}push_(...e){let t=this.instructions_,n=this.zIndex+this.offset_;t[n]||(t[n]=[]),t[n].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let n=0,r=t.length;n0&&e.push(` +`,``),e.push(t,``),e}function ws(e,t,n){return n%2==0&&(e+=t),e}var Ts=class{constructor(e,t,n,r,i){this.overlaps=n,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=Rn(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=i?new ms:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,n,r){let i=e+t+n+r;if(this.labels_[i])return this.labels_[i];let a=r?this.strokeStates[r]:null,o=n?this.fillStates[n]:null,s=this.textStates[t],c=this.pixelRatio,l=[s.scale[0]*c,s.scale[1]*c],u=s.justify?us[s.justify]:Ss(Array.isArray(e)?e[0]:e,s.textAlign||`center`),d=r&&a.lineWidth?a.lineWidth:0,f=Array.isArray(e)?e:String(e).split(` +`).reduce(Cs,[]),{width:p,height:m,widths:h,heights:g,lineWidths:_}=La(s,f),v=p+d,y=[],b=(v+2)*l[0],x=(m+d)*l[1],S={width:b<0?Math.floor(b):Math.ceil(b),height:x<0?Math.floor(x):Math.ceil(x),contextInstructions:y};(l[0]!=1||l[1]!=1)&&y.push(`scale`,l),r&&(y.push(`strokeStyle`,a.strokeStyle),y.push(`lineWidth`,d),y.push(`lineCap`,a.lineCap),y.push(`lineJoin`,a.lineJoin),y.push(`miterLimit`,a.miterLimit),y.push(`setLineDash`,[a.lineDash]),y.push(`lineDashOffset`,a.lineDashOffset)),n&&y.push(`fillStyle`,o.fillStyle),y.push(`textBaseline`,`middle`),y.push(`textAlign`,`center`);let C=.5-u,w=u*v+C*d,T=[],E=[],D=0,O=0,k=0,A=0,j;for(let e=0,t=f.length;ee?e-c:i,y=a+l>t?t-l:a,b=p[3]+v*d[0]+p[1],x=p[0]+y*d[1]+p[2],S=g-p[3],C=_-p[0];(m||u!==0)&&(gs[0]=S,ys[0]=S,gs[1]=C,_s[1]=C,_s[0]=S+b,vs[0]=_s[0],vs[1]=C+x,ys[1]=vs[1]);let w;return u===0?he(Math.min(S,S+b),Math.min(C,C+x),Math.max(S,S+b),Math.max(C,C+x),hs):(w=Bn(Rn(),n,r,1,1,u,-n,-r),R(w,gs),R(w,_s),R(w,vs),R(w,ys),he(Math.min(gs[0],_s[0],vs[0],ys[0]),Math.min(gs[1],_s[1],vs[1],ys[1]),Math.max(gs[0],_s[0],vs[0],ys[0]),Math.max(gs[1],_s[1],vs[1],ys[1]),hs)),f&&(g=Math.round(g),_=Math.round(_)),{drawImageX:g,drawImageY:_,drawImageW:v,drawImageH:y,originX:c,originY:l,declutterBox:{minX:hs[0],minY:hs[1],maxX:hs[2],maxY:hs[3],value:h},canvasTransform:w,scale:d}}replayImageOrLabel_(e,t,n,r,i,a,o){let s=!!(a||o),c=r.declutterBox,l=o?o[2]*r.scale[0]/2:0;return c.minX-l<=t[0]&&c.maxX+l>=0&&c.minY-l<=t[1]&&c.maxY+l>=0&&(s&&this.replayTextBackground_(e,gs,_s,vs,ys,a,o),Ra(e,r.canvasTransform,i,n,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(e){let t=this.alignAndScaleFill_;if(t){let n=R(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;e.save(),e.translate(n[0]%r,n[1]%r),t!==1&&e.scale(t,t)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,n,r){let i=this.textStates[t],a=this.createLabel(e,t,r,n),o=this.strokeStates[n],s=this.pixelRatio,c=Ss(Array.isArray(e)?e[0]:e,i.textAlign||`center`),l=us[i.textBaseline||`middle`],u=o&&o.lineWidth?o.lineWidth:0;return{label:a,anchorX:c*(a.width/s-2*i.scale[0])+2*(.5-c)*u,anchorY:l*a.height/s+2*(.5-l)*u}}execute_(e,t,n,r,i,a,o,s){let c=this.zIndexContext_,l;this.pixelCoordinates_&&g(n,this.renderedTransform_)?l=this.pixelCoordinates_:(this.pixelCoordinates_||=[],l=qn(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),zn(this.renderedTransform_,n));let u=0,d=r.length,f=0,p,m=[],h,_,v,y,b,x,S,C,w,T,E,D,O,k=0,A=0,j=this.coordinateCache_,ee=this.viewRotation_,te=Math.round(Math.atan2(-n[1],n[0])*0xe8d4a51000)/0xe8d4a51000,ne={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ee},M=this.instructions!=r||this.overlaps?0:200,re,ie,N,ae;for(;uM&&(this.fill_(e),k=0),A>M&&(e.stroke(),A=0),!k&&!A&&(e.beginPath(),b=NaN,x=NaN),++u;break;case U.CIRCLE:f=n[1],v=n[2]??0;let r=l[f],d=l[f+1],g=l[f+2]-v,oe=l[f+3]-v,se=g-r,ce=oe-d,le=Math.sqrt(se*se+ce*ce);e.moveTo(r+le,d),e.arc(r,d,le,0,2*Math.PI,!0),++u;break;case U.CLOSE_PATH:e.closePath(),++u;break;case U.CUSTOM:f=n[1],p=n[2];let ue=n[3],de=n[4],fe=n[5];ne.geometry=ue,ne.feature=re,u in j||(j[u]=[]);let pe=j[u];fe?fe(l,f,p,2,pe):(pe[0]=l[f],pe[1]=l[f+1],pe.length=2),c&&(c.zIndex=n[6]),de(pe,ne),++u;break;case U.DRAW_IMAGE:f=n[1],p=n[2],w=n[3],h=n[4],_=n[5];let me=n[6],he=n[7],ge=n[8],_e=n[9],ve=n[10],ye=n[11],be=n[12],xe=n[13];y=n[14]||`declutter`;let Se=n[15];if(!w&&n.length>=20){T=n[19],E=n[20],D=n[21],O=n[22];let e=this.drawLabelWithPointPlacement_(T,E,D,O);w=e.label,n[3]=w;let t=n[23];h=(e.anchorX-t)*this.pixelRatio,n[4]=h;let r=n[24];_=(e.anchorY-r)*this.pixelRatio,n[5]=_,me=w.height,n[6]=me,xe=w.width,n[13]=xe}let Ce;n.length>25&&(Ce=n[25]);let we,Te,Ee;n.length>17?(we=n[16],Te=n[17],Ee=n[18]):(we=Ta,Te=null,Ee=null),ve&&te?ye+=ee:!ve&&!te&&(ye-=ee);let De=0;for(;f!Ds.includes(e)),ks=!1,As=!1;function js(){let e=0,t=t=>{let n=V(1,1,null,{willReadFrequently:t}),r=0,i=performance.now();for(;performance.now()-i<50;++r)n.fillStyle=`rgba(255,0,${r%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return e=r>e?r:e,r};ks={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[e],As=!0}var Ms=class{constructor(e,t,n,r,i,a,o){this.maxExtent_=e,this.overlaps_=r,this.pixelRatio_=n,this.resolution_=t,this.renderBuffer_=a,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Rn(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(i,o)}clip(e,t){let n=this.getClipCoords(t);e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(n[2],n[3]),e.lineTo(n[4],n[5]),e.lineTo(n[6],n[7]),e.clip()}createExecutors_(e,t){for(let n in e){let r=this.executorsByZIndex_[n];r===void 0&&(r={},this.executorsByZIndex_[n]=r);let i=e[n];for(let e in i){let n=i[e];r[e]=new Ts(this.resolution_,this.pixelRatio_,this.overlaps_,n,t)}}}hasExecutors(e){for(let t in this.executorsByZIndex_){let n=this.executorsByZIndex_[t];for(let t=0,r=e.length;t0){if(!a||n===`none`||p!==`Image`&&p!==`Text`||a.includes(e)){let n=(f[c]-3)/4,a=r-n%o,s=r-(n/o|0),l=i(e,t,a*a+s*s);if(l)return l}l.clearRect(0,0,o,o);break}}let h=Object.keys(this.executorsByZIndex_).map(Number);h.sort(d);let g,_,v,y,b;for(g=h.length-1;g>=0;--g){let e=h[g].toString();for(v=this.executorsByZIndex_[e],_=Es.length-1;_>=0;--_)if(p=Es[_],y=v[p],y!==void 0&&(b=y.executeHitDetection(l,s,n,m,u),b))return b}}getClipCoords(e){let t=this.maxExtent_;if(!t)return null;let n=t[0],r=t[1],i=t[2],a=t[3],o=[n,r,n,a,i,a,i,r];return qn(o,0,8,2,e,o),o}isEmpty(){return i(this.executorsByZIndex_)}execute(e,t,n,r,i,a,o){let s=Object.keys(this.executorsByZIndex_).map(Number);s.sort(o?f:d),a||=Es;let c=Es.length;for(let l=0,u=s.length;lp.execute(e,t,n,r,i,o)),d&&u.restore(),a){a.offset();let e=s[l]*c+Es.indexOf(f);this.deferredZIndexContexts_[e]||(this.deferredZIndexContexts_[e]=[]),this.deferredZIndexContexts_[e].push(a)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(d);for(let n=0,r=t.length;n{e.draw(this.renderedContext_),e.clear()}),e[t[n]].length=0}},Ns={};function Ps(e){if(Ns[e]!==void 0)return Ns[e];let t=e*2+1,n=e*e,r=Array(n+1);for(let i=0;i<=e;++i)for(let a=0;a<=e;++a){let o=i*i+a*a;if(o>n)break;let s=r[o];s||(s=[],r[o]=s),s.push(((e+i)*t+(e+a))*4+3),i>0&&s.push(((e-i)*t+(e+a))*4+3),a>0&&(s.push(((e+i)*t+(e-a))*4+3),i>0&&s.push(((e-i)*t+(e-a))*4+3))}let i=[];for(let e=0,t=r.length;e0,"A defined and non-empty `src` or `image` must be provided"),M(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let s;if(e.src===void 0?a!==void 0&&(s=`complete`in a?a.complete?a.src?z.LOADED:z.IDLE:z.LOADING:z.LOADED):s=z.IDLE,this.color_=e.color===void 0?null:Yi(e.color),this.iconImage_=na(a,o,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,this.color_),this.offset_=e.offset===void 0?[0,0]:e.offset,this.offsetOrigin_=e.offsetOrigin===void 0?`top-left`:e.offsetOrigin,this.origin_=null,this.size_=e.size===void 0?null:e.size,this.initialOptions_,e.width!==void 0||e.height!==void 0){let t,n;if(e.size)[t,n]=e.size;else{let r=this.getImage(1);if(r.width&&r.height)t=r.width,n=r.height;else if(r instanceof HTMLImageElement){this.initialOptions_=e;let t=()=>{if(this.unlistenImageChange(t),!this.initialOptions_)return;let n=this.iconImage_.getSize();this.setScale(Fs(n[0],n[1],e.width,e.height))};this.listenImageChange(t);return}}t!==void 0&&this.setScale(Fs(t,n,e.width,e.height))}}clone(){let t,n,r;return this.initialOptions_?(n=this.initialOptions_.width,r=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new e({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:n,height:r,size:this.size_===null?void 0:this.size_.slice(),src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;let t=this.getSize();if(this.anchorXUnits_==`fraction`||this.anchorYUnits_==`fraction`){if(!t)return null;e=this.anchor_.slice(),this.anchorXUnits_==`fraction`&&(e[0]*=t[0]),this.anchorYUnits_==`fraction`&&(e[1]*=t[1])}if(this.anchorOrigin_!=`top-left`){if(!t)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_==`top-right`||this.anchorOrigin_==`bottom-right`)&&(e[0]=-e[0]+t[0]),(this.anchorOrigin_==`bottom-left`||this.anchorOrigin_==`bottom-right`)&&(e[1]=-e[1]+t[1])}this.normalizedAnchor_=e}let t=this.getDisplacement(),n=this.getScaleArray();return[e[0]-t[0]/n[0],e[1]+t[1]/n[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(e){let t=e?Yi(e):null;if(this.color_===t||this.color_&&t&&this.color_.length===t.length&&this.color_.every((e,n)=>e===t[n]))return;this.color_=t;let n=this.getSrc(),r=n===void 0?this.getHitDetectionImage():null,i=n===void 0?this.iconImage_.getImageState():z.IDLE;this.iconImage_=na(r,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},i,this.color_)}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!=`top-left`){let t=this.getSize(),n=this.iconImage_.getSize();if(!t||!n)return null;e=e.slice(),(this.offsetOrigin_==`top-right`||this.offsetOrigin_==`bottom-right`)&&(e[0]=n[0]-t[0]-e[0]),(this.offsetOrigin_==`bottom-left`||this.offsetOrigin_==`bottom-right`)&&(e[1]=n[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=na(null,e,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},z.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==z.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){let e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==z.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(c.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(c.CHANGE,e)}ready(){return this.iconImage_.ready()}},Ls=.5;function Rs(e,t,n,r,i,a,o,s,c){let l=c?Pn(i,c):i,u=V(e[0]*Ls,e[1]*Ls);u.imageSmoothingEnabled=!1;let f=u.canvas,p=new Ba(u,Ls,i,null,o,s,c?Tn(jn(),c):null),m=n.length,h=Math.floor((256*256*256-1)/m),g={};for(let e=1;e<=m;++e){let t=n[e-1],i=t.getStyleFunction()||r;if(!i)continue;let o=i(t,a);if(!o)continue;Array.isArray(o)||(o=[o]);let s=(e*h).toString(16).padStart(7,`#00000`);for(let e=0,n=o.length;ethis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return D()}getData(e){return null}prepareFrame(e){return D()}renderFrame(e,t){return D()}forEachFeatureAtCoordinate(e,t,n,r,i){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let t=e.target;(t.getState()===z.LOADED||t.getState()===z.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=z.LOADED&&t!=z.ERROR&&e.addEventListener(c.CHANGE,this.boundHandleImageChange_),t==z.IDLE&&(e.load(),t=e.getState()),t==z.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()===`ready`&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Us=[],Ws=null;function Gs(){Ws=V(1,1,void 0,{willReadFrequently:!0})}var Ks=class extends Hs{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Rn(),this.pixelTransform=Rn(),this.inversePixelTransform=Rn(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,n){Ws||Gs(),Ws.clearRect(0,0,1,1);let r;try{Ws.drawImage(e,t,n,1,1,0,0,1,1),r=Ws.getImageData(0,0,1,1).data}catch{return Ws=null,null}return r}getBackground(e){let t=this.getLayer().getBackground();return typeof t==`function`&&(t=t(e.viewState.resolution)),t||void 0}useContainer(e,t,n){let r=this.getLayer().getClassName(),i,a;if(e&&e.className===r&&(!n||e&&e.style.backgroundColor&&g(Yi(e.style.backgroundColor),Yi(n)))){let t=e.firstElementChild;vi(t)&&(a=t.getContext(`2d`))}if(a&&Kn(a.canvas.style.transform,t)?(this.container=e,this.context=a,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){i=ei?_i():document.createElement(`div`),i.className=r;let e=i.style;e.position=`absolute`,e.width=`100%`,e.height=`100%`,a=V();let t=a.canvas;i.appendChild(t),e=t.style,e.position=`absolute`,e.left=`0`,e.transformOrigin=`top left`,this.container=i,this.context=a}!this.containerReused&&n&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=n)}clipUnrotated(e,t,n){let r=Ne(n),i=Pe(n),a=De(n),o=Ee(n);R(t.coordinateToPixelTransform,r),R(t.coordinateToPixelTransform,i),R(t.coordinateToPixelTransform,a),R(t.coordinateToPixelTransform,o);let s=this.inversePixelTransform;R(s,r),R(s,i),R(s,a),R(s,o),e.save(),e.beginPath(),e.moveTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(i[0]),Math.round(i[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.clip()}prepareContainer(e,t){let n=e.extent,r=e.viewState.resolution,i=e.viewState.rotation,a=e.pixelRatio,o=Math.round(F(n)/r*a),s=Math.round(P(n)/r*a);Bn(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/a,1/a,i,-o/2,-s/2),Vn(this.inversePixelTransform,this.pixelTransform);let c=Wn(this.pixelTransform);if(this.useContainer(t,c,this.getBackground(e)),!this.containerReused){let e=this.context.canvas;e.width!=o||e.height!=s?(e.width=o,e.height=s):this.context.clearRect(0,0,o,s),c!==e.style.transform&&(e.style.transform=c)}}dispatchRenderEvent_(e,t,n){let r=this.getLayer();if(r.hasListener(e)){let i=new Bs(e,this.inversePixelTransform,n,t);r.dispatchEvent(i)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(ro.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(ro.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new ms),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(ro.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(ro.POSTRENDER,this.context,e))}getRenderTransform(e,t,n,r,i,a,o){let s=i/2,c=a/2,l=r/t,u=-l,d=-e[0]+o,f=-e[1];return Bn(this.tempTransform,s,c,l,u,-n,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}},qs=class extends Ks{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=me(),this.wrappedRenderedExtent_=me(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,t,n){let r=t.extent,i=t.viewState,a=i.center,o=i.resolution,s=i.projection,c=i.rotation,l=s.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=t.pixelRatio,p=t.viewHints,m=!(p[H.ANIMATING]||p[H.INTERACTING]),h=this.context,g=Math.round(F(r)/o*f),_=Math.round(P(r)/o*f),v=u.getWrapX()&&s.canWrapX(),y=v?F(l):null,b=v?Math.ceil((r[2]-l[2])/y)+(this.extendX_?2:1):1,x=v?Math.floor((r[0]-l[0])/y)-+!!this.extendX_:0;do{let r=this.getRenderTransform(a,o,0,f,g,_,x*y);t.declutter&&(r=r.slice(0)),e.execute(h,[h.canvas.width,h.canvas.height],r,c,m,n===void 0?Es:n?Ds:Os,n?d&&t.declutter[d]:void 0)}while(++x{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let e=this.frameState.size.slice(),t=this.renderedCenter_,n=this.renderedResolution_,r=this.renderedRotation_,i=this.renderedProjection_,a=this.wrappedRenderedExtent_,o=this.getLayer(),s=[],c=e[0]*Ls,l=e[1]*Ls;s.push(this.getRenderTransform(t,n,r,Ls,c,l,0).slice());let u=o.getSource(),d=i.getExtent();if(u.getWrapX()&&i.canWrapX()&&!de(d,a)){let e=a[0],i=F(d),o=0,u;for(;ed[2];)++o,u=i*o,s.push(this.getRenderTransform(t,n,r,Ls,c,l,u).slice()),e-=i}let f=jn();this.hitDetectionImageData_=Rs(e,s,this.renderedFeatures_,o.getStyleFunction(),a,n,r,Wa(n,this.renderedPixelRatio_),f?i:null)}t(zs(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,n,r,i){if(!this.replayGroup_)return;let a=t.viewState.resolution,o=t.viewState.rotation,s=this.getLayer(),c={},l=function(e,t,n){let a=k(e),o=c[a];if(!o){if(n===0)return c[a]=!0,r(e,s,t);i.push(c[a]={feature:e,layer:s,geometry:t,distanceSq:n,callback:r})}else if(o!==!0&&ne.value):null)}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let t=this.getLayer(),n=t.getSource();if(!n)return!1;let r=e.viewHints[H.ANIMATING],i=e.viewHints[H.INTERACTING],a=t.getUpdateWhileAnimating(),o=t.getUpdateWhileInteracting();if(this.ready&&!a&&r||!o&&i)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let s=e.extent,c=e.viewState,l=c.projection,u=c.resolution,d=e.pixelRatio,f=t.getRevision(),p=t.getRenderBuffer(),m=t.getRenderOrder();m===void 0&&(m=Ua);let h=c.center.slice(),_=se(s,p*u),v=_.slice(),y=[_.slice()],b=l.getExtent(),x=n.getWrapX()&&l.canWrapX();if(this.extendX_=!1,x){let e=n.getExtent();e&&!Ie(e)&&(this.extendX_=e[0]b[2])}if(x&&(!de(b,e.extent)||this.extendX_)){let e=F(b),t=Math.max(F(_)/2,e),n=b[0],r=b[2];this.extendX_&&(n-=e,r+=e),_[0]=n-t,_[2]=r+t,st(h,l);let i=Be(y[0],l);i[0]b[0]&&i[2]>b[2]&&y.push([i[0]-e,i[1],i[2]-e,i[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===d&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&de(this.wrappedRenderedExtent_,_))return g(this.renderedExtent_,v)||(this.hitDetectionImageData_=null,this.renderedExtent_=v),this.renderedCenter_=h,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let S=new fs(Ga(u,d),_,u,d),C=jn(),w;if(C){for(let e=0,t=y.length;e{let r,i=e.getStyleFunction()||t.getStyleFunction();if(i&&(r=i(e,u)),r){let t=this.renderFeature(e,T,r,S,w,this.getLayer().getDeclutter(),n);E&&=!t}},O=Pn(_,l),k=n.getFeaturesInExtent(O);m&&k.sort(m);for(let e=0,t=k.length;e`,GreaterThanOrEqualTo:`>=`,LessThan:`<`,LessThanOrEqualTo:`<=`,Multiply:`*`,Divide:`/`,Add:`+`,Subtract:`-`,Clamp:`clamp`,Mod:`%`,Pow:`^`,Abs:`abs`,Floor:`floor`,Ceil:`ceil`,Round:`round`,Sin:`sin`,Cos:`cos`,Atan:`atan`,Sqrt:`sqrt`,Match:`match`,Between:`between`,Interpolate:`interpolate`,Coalesce:`coalesce`,Case:`case`,In:`in`,Number:`number`,String:`string`,Array:`array`,Color:`color`,Id:`id`,Band:`band`,Palette:`palette`,ToString:`to-string`,Has:`has`},lc={[q.Get]:X(J(1,1/0),uc),[q.Var]:X(J(1,1),dc),[q.Has]:X(J(1,1/0),uc),[q.Id]:X(fc,gc),[q.Concat]:X(J(2,1/0),Y(Xs)),[q.GeometryType]:X(pc,gc),[q.LineMetric]:X(mc,gc),[q.Resolution]:X(hc,gc),[q.Zoom]:X(hc,gc),[q.Time]:X(hc,gc),[q.Any]:X(J(2,1/0),Y(Ys)),[q.All]:X(J(2,1/0),Y(Ys)),[q.Not]:X(J(1,1),Y(Ys)),[q.Equal]:X(J(2,2),Y(ec)),[q.NotEqual]:X(J(2,2),Y(ec)),[q.GreaterThan]:X(J(2,2),Y(W)),[q.GreaterThanOrEqualTo]:X(J(2,2),Y(W)),[q.LessThan]:X(J(2,2),Y(W)),[q.LessThanOrEqualTo]:X(J(2,2),Y(W)),[q.Multiply]:X(J(2,1/0),_c),[q.Coalesce]:X(J(2,1/0),_c),[q.Divide]:X(J(2,2),Y(W)),[q.Add]:X(J(2,1/0),Y(W)),[q.Subtract]:X(J(2,2),Y(W)),[q.Clamp]:X(J(3,3),Y(W)),[q.Mod]:X(J(2,2),Y(W)),[q.Pow]:X(J(2,2),Y(W)),[q.Abs]:X(J(1,1),Y(W)),[q.Floor]:X(J(1,1),Y(W)),[q.Ceil]:X(J(1,1),Y(W)),[q.Round]:X(J(1,1),Y(W)),[q.Sin]:X(J(1,1),Y(W)),[q.Cos]:X(J(1,1),Y(W)),[q.Atan]:X(J(1,2),Y(W)),[q.Sqrt]:X(J(1,1),Y(W)),[q.Match]:X(J(4,1/0),yc,bc),[q.Between]:X(J(3,3),Y(W)),[q.Interpolate]:X(J(6,1/0),yc,xc),[q.Case]:X(J(3,1/0),vc,Sc),[q.In]:X(J(2,2),Cc),[q.Number]:X(J(1,1/0),Y(ec)),[q.String]:X(J(1,1/0),Y(ec)),[q.Array]:X(J(1,1/0),Y(W)),[q.Color]:X(J(1,4),Y(W)),[q.Band]:X(J(1,3),Y(W)),[q.Palette]:X(J(2,2),wc),[q.ToString]:X(J(1,1),Y(Ys|W|Xs|Zs))};function uc(e,t,n){let r=e.length-1,i=Array(r);for(let t=0;tt){let n=t===1/0?`${e} or more`:`${e} to ${t}`;throw Error(`expected ${n} arguments for ${a}, got ${o}`)}}}function _c(e,t,n){let r=e.length-1,i=Array(r);for(let a=0;ae.featureId;case q.GeometryType:return e=>e.geometryType;case q.Concat:{let n=e.args.map(e=>kc(e,t));return e=>``.concat(...n.map(t=>t(e).toString()))}case q.Resolution:return e=>e.resolution;case q.Any:case q.All:case q.Between:case q.In:case q.Not:return Nc(e,t);case q.Equal:case q.NotEqual:case q.LessThan:case q.LessThanOrEqualTo:case q.GreaterThan:case q.GreaterThanOrEqualTo:return Mc(e,t);case q.Multiply:case q.Divide:case q.Add:case q.Subtract:case q.Clamp:case q.Mod:case q.Pow:case q.Abs:case q.Floor:case q.Ceil:case q.Round:case q.Sin:case q.Cos:case q.Atan:case q.Sqrt:return Pc(e,t);case q.Case:return Fc(e,t);case q.Match:return Ic(e,t);case q.Interpolate:return Lc(e,t);case q.ToString:return Rc(e,t);default:throw Error(`Unsupported operator ${n}`)}}function Ac(e,t){let n=e.operator,r=e.args.length,i=Array(r);for(let n=0;n{for(let t=0;t{for(let t=0;t{let r=e.args,i=t.properties[n];for(let e=1,t=r.length;ee.variables[n];case q.Has:return t=>{let r=e.args;if(!(n in t.properties))return!1;let i=t.properties[n];for(let e=1,t=r.length;er(e)===i(e);case q.NotEqual:return e=>r(e)!==i(e);case q.LessThan:return e=>r(e)r(e)<=i(e);case q.GreaterThan:return e=>r(e)>i(e);case q.GreaterThanOrEqualTo:return e=>r(e)>=i(e);default:throw Error(`Unsupported comparison operator ${n}`)}}function Nc(e,t){let n=e.operator,r=e.args.length,i=Array(r);for(let n=0;n{for(let t=0;t{for(let t=0;t{let t=i[0](e),n=i[1](e),r=i[2](e);return t>=n&&t<=r};case q.In:return e=>{let t=i[0](e);for(let n=1;n!i[0](e);default:throw Error(`Unsupported logical operator ${n}`)}}function Pc(e,t){let n=e.operator,r=e.args.length,i=Array(r);for(let n=0;n{let t=1;for(let n=0;ni[0](e)/i[1](e);case q.Add:return e=>{let t=0;for(let n=0;ni[0](e)-i[1](e);case q.Clamp:return e=>{let t=i[0](e),n=i[1](e);if(tr?r:t};case q.Mod:return e=>i[0](e)%i[1](e);case q.Pow:return e=>i[0](e)**+i[1](e);case q.Abs:return e=>Math.abs(i[0](e));case q.Floor:return e=>Math.floor(i[0](e));case q.Ceil:return e=>Math.ceil(i[0](e));case q.Round:return e=>Math.round(i[0](e));case q.Sin:return e=>Math.sin(i[0](e));case q.Cos:return e=>Math.cos(i[0](e));case q.Atan:return r===2?e=>Math.atan2(i[0](e),i[1](e)):e=>Math.atan(i[0](e));case q.Sqrt:return e=>Math.sqrt(i[0](e));default:throw Error(`Unsupported numeric operator ${n}`)}}function Fc(e,t){let n=e.args.length,r=Array(n);for(let i=0;i{for(let t=0;t{let t=r[0](e);for(let i=1;i{let t=r[0](e),i=r[1](e),a,o;for(let s=2;s=i)return s===2?c:l?Bc(t,i,a,o,n,c):zc(t,i,a,o,n,c);a=n,o=c}return o}}function Rc(e,t){let n=e.operator,r=e.args.length,i=Array(r);for(let n=0;n{let n=i[0](t);return e.args[0].type===Zs?Xi(n):n.toString()};default:throw Error(`Unsupported convert operator ${n}`)}}function zc(e,t,n,r,i,a){let o=i-n;if(o===0)return r;let s=t-n;return r+(e===1?s/o:(e**+s-1)/(e**+o-1))*(a-r)}function Bc(e,t,n,r,i,a){if(i-n===0)return r;let o=Ki(r),s=Ki(a),c=s[2]-o[2];return c>180?c-=360:c<-180&&(c+=360),qi([zc(e,t,n,o[0],i,s[0]),zc(e,t,n,o[1],i,s[1]),o[2]+zc(e,t,n,0,i,c),zc(e,t,n,r[3],i,a[3])])}function Vc(e){return!0}function Hc(e){let t=cc(),n=Wc(e,t),r=Dc();return function(e,i){if(r.properties=e.getPropertiesInternal(),r.resolution=i,t.featureId){let t=e.getId();t===void 0?r.featureId=null:r.featureId=t}return t.geometryType&&(r.geometryType=Ec(e.getGeometry())),n(r)}}function Uc(e){let t=cc(),n=e.length,r=Array(n);for(let i=0;inull;r=rl(e,t+`fill-color`,n)}if(!r)return null;let i=new zo;return function(e){let t=r(e);return t===Di?null:(i.setColor(t),i)}}function qc(e,t,n){let r=Z(e,t+`stroke-width`,n),i=rl(e,t+`stroke-color`,n);if(!r&&!i)return null;let a=el(e,t+`stroke-line-cap`,n),o=el(e,t+`stroke-line-join`,n),s=il(e,t+`stroke-line-dash`,n),c=Z(e,t+`stroke-line-dash-offset`,n),l=Z(e,t+`stroke-miter-limit`,n),u=Z(e,t+`stroke-offset`,n),d=new Bo;return function(e){if(i){let t=i(e);if(t===Di)return null;d.setColor(t)}if(r&&d.setWidth(r(e)),a){let t=a(e);if(t!==`butt`&&t!==`round`&&t!==`square`)throw Error(`Expected butt, round, or square line cap`);d.setLineCap(t)}if(o){let t=o(e);if(t!==`bevel`&&t!==`round`&&t!==`miter`)throw Error(`Expected bevel, round, or miter line join`);d.setLineJoin(t)}return s&&d.setLineDash(s(e)),c&&d.setLineDashOffset(c(e)),l&&d.setMiterLimit(l(e)),u&&d.setOffset(u(e)),d}}function Jc(e,t){let n=`text-`,r=el(e,n+`value`,t);if(!r)return null;let i=Kc(e,n,t),a=Kc(e,n+`background-`,t),o=qc(e,n,t),s=qc(e,n+`background-`,t),c=el(e,n+`font`,t),l=Z(e,n+`max-angle`,t),u=Z(e,n+`offset-x`,t),d=Z(e,n+`offset-y`,t),f=nl(e,n+`overflow`,t),p=el(e,n+`placement`,t),m=Z(e,n+`repeat`,t),h=sl(e,n+`scale`,t),g=nl(e,n+`rotate-with-view`,t),_=Z(e,n+`rotation`,t),v=el(e,n+`align`,t),y=el(e,n+`justify`,t),b=el(e,n+`baseline`,t),x=nl(e,n+`keep-upright`,t),S=il(e,n+`padding`,t),C=new $o({declutterMode:ml(e,n+`declutter-mode`)});return function(e){if(C.setText(r(e)),i&&C.setFill(i(e)),a&&C.setBackgroundFill(a(e)),o&&C.setStroke(o(e)),s&&C.setBackgroundStroke(s(e)),c&&C.setFont(c(e)),l&&C.setMaxAngle(l(e)),u&&C.setOffsetX(u(e)),d&&C.setOffsetY(d(e)),f&&C.setOverflow(f(e)),p){let t=p(e);if(t!==`point`&&t!==`line`)throw Error(`Expected point or line for text-placement`);C.setPlacement(t)}if(m&&C.setRepeat(m(e)),h&&C.setScale(h(e)),g&&C.setRotateWithView(g(e)),_&&C.setRotation(_(e)),v){let t=v(e);if(t!==`left`&&t!==`center`&&t!==`right`&&t!==`end`&&t!==`start`)throw Error(`Expected left, right, center, start, or end for text-align`);C.setTextAlign(t)}if(y){let t=y(e);if(t!==`left`&&t!==`right`&&t!==`center`)throw Error(`Expected left, right, or center for text-justify`);C.setJustify(t)}if(b){let t=b(e);if(t!==`bottom`&&t!==`top`&&t!==`middle`&&t!==`alphabetic`&&t!==`hanging`)throw Error(`Expected bottom, top, middle, alphabetic, or hanging for text-baseline`);C.setTextBaseline(t)}return S&&C.setPadding(S(e)),x&&C.setKeepUpright(x(e)),C}}function Yc(e,t){return`icon-src`in e?Xc(e,t):`shape-points`in e?Zc(e,t):`circle-radius`in e?Qc(e,t):null}function Xc(e,t){let n=`icon-`,r=n+`src`,i=gl(e[r],r),a=al(e,n+`anchor`,t),o=sl(e,n+`scale`,t),s=Z(e,n+`opacity`,t),c=al(e,n+`displacement`,t),l=Z(e,n+`rotation`,t),u=nl(e,n+`rotate-with-view`,t),d=dl(e,n+`anchor-origin`),f=fl(e,n+`anchor-x-units`),p=fl(e,n+`anchor-y-units`),m=$c(e,n+`color`),h,g=null;m!==void 0&&(Array.isArray(m)&&m.length>0&&typeof m[0]==`string`?g=rl(e,n+`color`,t):h=vl(m,n+`color`));let _=ul(e,n+`cross-origin`),v=pl(e,n+`offset`),y=dl(e,n+`offset-origin`),b=cl(e,n+`width`),x={src:i,anchorOrigin:d,anchorXUnits:f,anchorYUnits:p,crossOrigin:_,offset:v,offsetOrigin:y,height:cl(e,n+`height`),width:b,size:ll(e,n+`size`),declutterMode:ml(e,n+`declutter-mode`)},S=null;return function(e){if(S)g&&S.setColor(g(e));else{let t=g?g(e):h;S=new Is(t===void 0?Object.assign({},x):Object.assign({},x,{color:t}))}return s&&S.setOpacity(s(e)),c&&S.setDisplacement(c(e)),l&&S.setRotation(l(e)),u&&S.setRotateWithView(u(e)),o&&S.setScale(o(e)),a&&S.setAnchor(a(e)),S}}function Zc(e,t){let n=`shape-`,r=n+`points`,i=n+`radius`,a=_l(e[r],r);if(!(i in e))throw Error(`Expected a number for ${i}`);let o=Z(e,i,t),s=typeof e[i]==`number`?e[i]:5,c=n+`radius2`,l=Z(e,c,t),u=typeof e[c]==`number`?e[c]:void 0,d=Kc(e,n,t),f=qc(e,n,t),p=sl(e,n+`scale`,t),m=al(e,n+`displacement`,t),h=Z(e,n+`rotation`,t),g=nl(e,n+`rotate-with-view`,t),_=new Go({points:a,radius:s,radius2:u,angle:cl(e,n+`angle`),declutterMode:ml(e,n+`declutter-mode`)});return function(e){return o&&_.setRadius(o(e)),l&&_.setRadius2(l(e)),d&&_.setFill(d(e)),f&&_.setStroke(f(e)),m&&_.setDisplacement(m(e)),h&&_.setRotation(h(e)),g&&_.setRotateWithView(g(e)),p&&_.setScale(p(e)),_}}function Qc(e,t){let n=`circle-`,r=Kc(e,n,t),i=qc(e,n,t),a=Z(e,n+`radius`,t),o=sl(e,n+`scale`,t),s=al(e,n+`displacement`,t),c=Z(e,n+`rotation`,t),l=nl(e,n+`rotate-with-view`,t),u=new Ko({radius:5,declutterMode:ml(e,n+`declutter-mode`)});return function(e){return a&&u.setRadius(a(e)),r&&u.setFill(r(e)),i&&u.setStroke(i(e)),s&&u.setDisplacement(s(e)),c&&u.setRotation(c(e)),l&&u.setRotateWithView(l(e)),o&&u.setScale(o(e)),u}}function $c(e,t){if(!(t in e))return;let n=e[t];return n===void 0?void 0:n}function Z(e,t,n){let r=$c(e,t);if(r===void 0)return;let i=Oc(r,W,n);return function(e){return _l(i(e),t)}}function el(e,t,n){let r=$c(e,t);if(r===void 0)return null;let i=Oc(r,Xs,n);return function(e){return gl(i(e),t)}}function tl(e,t,n){let r=el(e,t+`pattern-src`,n),i=ol(e,t+`pattern-offset`,n),a=ol(e,t+`pattern-size`,n),o=rl(e,t+`color`,n);return function(e){return{src:r(e),offset:i&&i(e),size:a&&a(e),color:o&&o(e)}}}function nl(e,t,n){let r=$c(e,t);if(r===void 0)return null;let i=Oc(r,Ys,n);return function(e){let n=i(e);if(typeof n!=`boolean`)throw Error(`Expected a boolean for ${t}`);return n}}function rl(e,t,n){let r=$c(e,t);if(r===void 0)return null;let i=Oc(r,Zs,n);return function(e){return vl(i(e),t)}}function il(e,t,n){let r=$c(e,t);if(r===void 0)return null;if(Array.isArray(r)&&(r.length===0||typeof r[0]!=`string`)){let e=r.map((e,r)=>{if(typeof e==`number`)return()=>e;let i=Oc(e,W,n);return function(e){return _l(i(e),`${t}[${r}]`)}});return function(t){let n=Array(e.length);for(let r=0;r4)throw Error(`Expected a color with 3 or 4 values for ${t}`);return n}function yl(e,t){let n=hl(e,t);if(n.length!==2)throw Error(`Expected an array of two numbers for ${t}`);return n}function bl(e,t){return typeof e==`number`?e:yl(e,t)}var xl={CENTER:`center`,RESOLUTION:`resolution`,ROTATION:`rotation`};function Sl(e,t,n){return(function(r,i,a,o,s){if(!r)return;if(!i&&!t)return r;let c=t?0:a[0]*i,l=t?0:a[1]*i,u=s?s[0]:0,d=s?s[1]:0,f=e[0]+c/2+u,p=e[2]-c/2+u,m=e[1]+l/2+d,h=e[3]-l/2+d;f>p&&(f=(p+f)/2,p=f),m>h&&(m=(h+m)/2,h=m);let g=I(r[0],f,p),_=I(r[1],m,h);if(o&&n&&i){let e=30*i;g+=-e*Math.log(1+Math.max(0,f-r[0])/e)+e*Math.log(1+Math.max(0,r[0]-p)/e),_+=-e*Math.log(1+Math.max(0,m-r[1])/e)+e*Math.log(1+Math.max(0,r[1]-h)/e)}return[g,_]})}function Cl(e){return e}function wl(e,t,n,r){let i=F(t)/n[0],a=P(t)/n[1];return r?Math.min(e,Math.max(i,a)):Math.min(e,Math.min(i,a))}function Tl(e,t,n){let r=Math.min(e,t);return r*=Math.log(1+50*Math.max(0,e/t-1))/50+1,n&&(r=Math.max(r,n),r/=Math.log(1+50*Math.max(0,n/e-1))/50+1),I(r,n/2,t*2)}function El(e,t,n,r){return t=t===void 0?!0:t,(function(i,a,o,s){if(i!==void 0){let c=e[0],l=e[e.length-1],u=n?wl(c,n,o,r):c;if(s)return t?Tl(i,u,l):I(i,l,u);let d=Math.floor(p(e,Math.min(u,i),a));return e[d]>u&&d1&&typeof arguments[t-1]==`function`&&(n=arguments[t-1],--t);let r=0;for(;r0}getInteracting(){return this.hints_[H.INTERACTING]>0}cancelAnimations(){this.setHint(H.ANIMATING,-this.hints_[H.ANIMATING]);let e;for(let t=0,n=this.animations_.length;t=0;--n){let r=this.animations_[n],i=!0;for(let n=0,a=r.length;n0?o/a.duration:1;s>=1?(a.complete=!0,s=1):i=!1;let c=a.easing(s);if(a.sourceCenter){let e=a.sourceCenter[0],t=a.sourceCenter[1],n=a.targetCenter[0],r=a.targetCenter[1];this.nextCenter_=a.targetCenter,this.targetCenter_=[e+c*(n-e),t+c*(r-t)]}if(a.sourceResolution&&a.targetResolution){let e=c===1?a.targetResolution:a.sourceResolution+c*(a.targetResolution-a.sourceResolution);if(a.anchor){let t=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(e,0,t,!0);this.targetCenter_=this.calculateCenterZoom(n,a.anchor)}this.nextResolution_=a.targetResolution,this.targetResolution_=e,this.applyTargetState_(!0)}if(a.sourceRotation!==void 0&&a.targetRotation!==void 0){let e=c===1?qe(a.targetRotation+Math.PI,2*Math.PI)-Math.PI:a.sourceRotation+c*(a.targetRotation-a.sourceRotation);if(a.anchor){let t=this.constraints_.rotation(e,!0);this.targetCenter_=this.calculateCenterRotate(t,a.anchor)}this.nextRotation_=a.targetRotation,this.targetRotation_=e}if(this.applyTargetState_(!0),t=!0,!a.complete)break}if(i){this.animations_[n]=null,this.setHint(H.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let e=r[0].callback;e&&Fl(e,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let n,r=this.getCenterInternal();return r!==void 0&&(n=[r[0]-t[0],r[1]-t[1]],at(n,e-this.getRotation()),rt(n,t)),n}calculateCenterZoom(e,t){let n,r=this.getCenterInternal(),i=this.getResolution();return r!==void 0&&i!==void 0&&(n=[t[0]-e*(t[0]-r[0])/i,t[1]-e*(t[1]-r[1])/i]),n}getViewportSize_(e){let t=this.viewportSize_;if(e){let n=t[0],r=t[1];return[Math.abs(n*Math.cos(e))+Math.abs(r*Math.sin(e)),Math.abs(n*Math.sin(e))+Math.abs(r*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&Mn(e,this.getProjection())}getCenterInternal(){return this.get(xl.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get(`constrainResolution`)}getHints(e){return e===void 0?this.hints_.slice():(e[0]=this.hints_[0],e[1]=this.hints_[1],e)}calculateExtent(e){return Pn(this.calculateExtentInternal(e),this.getProjection())}calculateExtentInternal(e){e||=this.getViewportSizeMinusPadding_();let t=this.getCenterInternal();M(t,`The view center is not defined`);let n=this.getResolution();M(n!==void 0,`The view resolution is not defined`);let r=this.getRotation();return M(r!==void 0,`The view rotation is not defined`),Ae(t,n,r,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(xl.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(Fn(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t||=this.getViewportSizeMinusPadding_();let n=F(e)/t[0],r=P(e)/t[1];return Math.max(n,r)}getResolutionForValueFunction(e){e||=2;let t=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(t/n)/Math.log(e);return(function(n){return t/e**+(n*r)})}getRotation(){return this.get(xl.ROTATION)}getValueForResolutionFunction(e){let t=Math.log(e||2),n=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,i=Math.log(n/r)/t;return(function(e){return Math.log(n/e)/t/i})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e),n=this.padding_;return n&&(t=[t[0]-n[1]-n[3],t[1]-n[0]-n[2]]),t}getState(){let e=this.getProjection(),t=this.getResolution(),n=this.getRotation(),r=this.getCenterInternal(),i=this.padding_;if(i){let e=this.getViewportSizeMinusPadding_();r=Bl(r,this.getViewportSize_(),[e[0]/2+i[3],e[1]/2+i[0]],t,n)}return{center:r.slice(0),projection:e===void 0?null:e,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,n,r;if(this.resolutions_){let i=p(this.resolutions_,e,1);t=i,n=this.resolutions_[i],r=i==this.resolutions_.length-1?2:n/this.resolutions_[i+1]}else n=this.maxResolution_,r=this.zoomFactor_;return t+Math.log(n/e)/Math.log(r)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let t=I(Math.floor(e),0,this.resolutions_.length-2),n=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/n**+I(e-t,0,1)}return this.maxResolution_/this.zoomFactor_**+(e-this.minZoom_)}fit(e,t){let n;if(M(Array.isArray(e)||typeof e.getSimplifiedGeometry==`function`,"Invalid extent or geometry provided as `geometry`"),Array.isArray(e))M(!Ie(e),"Cannot fit empty extent provided as `geometry`"),n=Yr(Fn(e,this.getProjection()));else if(e.getType()===`Circle`){let t=Fn(e.getExtent(),this.getProjection());n=Yr(t),n.rotate(this.getRotation(),Oe(t))}else{let t=jn();n=t?e.clone().transform(t,this.getProjection()):e}this.fitInternal(n,t)}rotatedExtentForGeometry(e){let t=this.getRotation(),n=Math.cos(t),r=Math.sin(-t),i=e.getFlatCoordinates(),a=e.getStride(),o=1/0,s=1/0,c=-1/0,l=-1/0;for(let e=0,t=i.length;e{this.dispatchEvent(`sourceready`)},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t,n=this.getMapInternal();!e&&n&&(e=n.getView()),t=e instanceof Pl?{viewState:e.getState(),extent:e.calculateExtent()}:e,!t.layerStatesArray&&n&&(t.layerStatesArray=n.getLayerGroup().getLayerStatesArray());let r;if(t.layerStatesArray){if(r=t.layerStatesArray.find(e=>e.layer===this),!r)return!1}else r=this.getLayerState();let i=this.getExtent();return Ul(r,t.viewState)&&(!i||Fe(i,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t=this.getSource()?.getAttributions();if(!t)return[];let n=t(e instanceof Pl?e.getViewStateAndExtent():e);return Array.isArray(n)||(n=[n]),n}render(e,t){let n=this.getRenderer();return n.prepareFrame(e)?(this.rendered=!0,n.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){let t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Q.MAP,e)}getMapInternal(){return this.get(Q.MAP)}setMap(e){this.mapPrecomposeKey_&&=(s(this.mapPrecomposeKey_),null),e||this.changed(),this.mapRenderKey_&&=(s(this.mapRenderKey_),null),e&&(this.mapPrecomposeKey_=a(e,ro.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=a(this,c.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){let t=e.frameState.layerStatesArray,n=this.getLayerState(!1);M(!t.some(e=>e.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(n)}setSource(e){this.set(Q.SOURCE,e)}getRenderer(){return this.renderer_||=this.createRenderer(),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function Ul(e,t){if(!e.visible)return!1;let n=t.resolution;if(n=e.maxResolution)return!1;let r=t.zoom;return r>e.minZoom&&r<=e.maxZoom}var Wl={RENDER_ORDER:`renderOrder`},Gl=class extends Hl{constructor(e){e||={};let t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer===void 0?100:e.renderBuffer,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating===void 0?!1:e.updateWhileAnimating,this.updateWhileInteracting_=e.updateWhileInteracting===void 0?!1:e.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Wl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){let n=this.getDeclutter();n in e.declutter||(e.declutter[n]=new vo(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Wl.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Xo:e;let t=Kl(e);this.styleFunction_=e===null?void 0:Jo(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}};function Kl(e){if(e===void 0)return Xo;if(!e)return null;if(typeof e==`function`||e instanceof qo)return e;if(!Array.isArray(e))return Uc([e]);if(e.length===0)return[];let t=e.length,n=e[0];if(n instanceof qo){let n=Array(t);for(let r=0;r{this.clickTimeoutId_=void 0;let t=new Yl($.SINGLECLICK,this.map_,e);this.dispatchEvent(t)},250):(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Yl($.DBLCLICK,this.map_,e),this.dispatchEvent(t))}updateActivePointers_(e){let t=e,n=t.pointerId;if(t.type==$.POINTERUP||t.type==$.POINTERCANCEL){delete this.trackedTouches_[n];for(let e in this.trackedTouches_)if(this.trackedTouches_[e].target!==t.target){delete this.trackedTouches_[e];break}}else (t.type==$.POINTERDOWN||t.type==$.POINTERMOVE)&&(this.trackedTouches_[n]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);let t=new Yl($.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(s),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);let t=new Yl($.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,`target`,{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){let e=this.map_.getOwnerDocument();this.dragListenerKeys_.push(a(e,$.POINTERMOVE,this.handlePointerMove_,this),a(e,$.POINTERUP,this.handlePointerUp_,this),a(this.element_,$.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==e&&this.dragListenerKeys_.push(a(this.element_.getRootNode(),$.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;let t=new Yl($.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;let t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Yl($.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){let t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!=`boolean`||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&=(s(this.relayedListenerKey_),null),this.element_.removeEventListener(c.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&=(s(this.pointerdownListenerKey_),null),this.dragListenerKeys_.forEach(s),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},Ql={POSTRENDER:`postrender`,MOVESTART:`movestart`,MOVEEND:`moveend`,LOADSTART:`loadstart`,LOADEND:`loadend`},$l={LAYERGROUP:`layergroup`,SIZE:`size`,TARGET:`target`,VIEW:`view`},eu=1/0,tu=class{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,r(this.queuedElements_)}dequeue(){let e=this.elements_,t=this.priorities_,n=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));let r=this.keyFunction_(n);return delete this.queuedElements_[r],n}enqueue(e){M(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let t=this.priorityFunction_(e);return t==1/0?!1:(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){let t=this.elements_,n=this.priorities_,r=t.length,i=t[e],a=n[e],o=e;for(;e>1;){let i=this.getLeftChildIndex_(e),a=this.getRightChildIndex_(e),o=ae;){let e=this.getParentIndex_(t);if(r[e]>a)n[t]=n[e],r[t]=r[e],t=e;else break}n[t]=i,r[t]=a}reprioritize(){let e=this.priorityFunction_,t=this.elements_,n=this.priorities_,r=0,i=t.length,a,o,s;for(o=0;oe.apply(null,t),e=>e[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){let t=super.enqueue(e);return t&&e[0].addEventListener(c.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){let t=e.target,n=t.getState();if(n===B.LOADED||n===B.ERROR||n===B.EMPTY){n!==B.ERROR&&t.removeEventListener(c.CHANGE,this.boundHandleTileChange_);let e=t.getKey();e in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[e],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let n=0;for(;this.tilesLoading_0;){let e=this.dequeue()[0],t=e.getKey();e.getState()===B.IDLE&&!(t in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[t]=!0,++this.tilesLoading_,++n,e.load())}}};function ru(e,t,n,r,i){if(!e||!(n in e.wantedTiles)||!e.wantedTiles[n][t.getKey()])return eu;let a=e.viewState.center,o=r[0]-a[0],s=r[1]-a[1];return 65536*Math.log(i)+Math.sqrt(o*o+s*s)/i}var iu=class extends j{constructor(e){super();let t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents=`auto`),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let e=0,t=this.listenerKeys.length;et.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(e=>n.add(e)):n.add(this.attributions_)),!this.overrideCollapsible_){let e=!t.some(e=>e.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(e)}return Array.from(n)}async updateElement_(e){if(!e){this.renderedVisible_&&=(this.element.style.display=`none`,!1);return}let t=await Promise.all(this.collectSourceAttributions_(e).map(e=>S(()=>e))),n=t.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?``:`none`,this.renderedVisible_=n),!g(t,this.renderedAttributions_)){hi(this.ulElement_);for(let e=0,n=t.length;e0&&t%(2*Math.PI)!=0?e.animate({rotation:0,duration:this.duration_,easing:si}):e.setRotation(0))}render(e){let t=e.frameState;if(!t)return;let n=t.viewState.rotation;if(n!=this.rotation_){let e=`rotate(`+n+`rad)`;if(this.autoHide_){let e=this.element.classList.contains(la);!e&&n===0?this.element.classList.add(la):e&&n!==0&&this.element.classList.remove(la)}this.label_.style.transform=e}this.rotation_=n}},su=class extends iu{constructor(e){e||={},super({element:document.createElement(`div`),target:e.target});let t=e.className===void 0?`ol-zoom`:e.className,n=e.delta===void 0?1:e.delta,r=e.zoomInClassName===void 0?t+`-in`:e.zoomInClassName,i=e.zoomOutClassName===void 0?t+`-out`:e.zoomOutClassName,a=e.zoomInLabel===void 0?`+`:e.zoomInLabel,o=e.zoomOutLabel===void 0?`–`:e.zoomOutLabel,s=e.zoomInTipLabel===void 0?`Zoom in`:e.zoomInTipLabel,l=e.zoomOutTipLabel===void 0?`Zoom out`:e.zoomOutTipLabel,u=document.createElement(`button`);u.className=r,u.setAttribute(`type`,`button`),u.title=s,u.appendChild(typeof a==`string`?document.createTextNode(a):a),u.addEventListener(c.CLICK,this.handleClick_.bind(this,n),!1);let d=document.createElement(`button`);d.className=i,d.setAttribute(`type`,`button`),d.title=l,d.appendChild(typeof o==`string`?document.createTextNode(o):o),d.addEventListener(c.CLICK,this.handleClick_.bind(this,-n),!1);let f=t+` `+ua+` `+da,p=this.element;p.className=f,p.appendChild(u),p.appendChild(d),this.duration_=e.duration===void 0?250:e.duration}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){let t=this.getMap().getView();if(!t)return;let n=t.getZoom();if(n!==void 0){let r=t.getConstrainedZoom(n+e);this.duration_>0?(t.getAnimating()&&t.cancelAnimations(),t.animate({zoom:r,duration:this.duration_,easing:si})):t.setZoom(r)}}};function cu(e){e||={};let t=new ne;return(e.zoom===void 0||e.zoom)&&t.push(new su(e.zoomOptions)),(e.rotate===void 0||e.rotate)&&t.push(new ou(e.rotateOptions)),(e.attribution===void 0||e.attribution)&&t.push(new au(e.attributionOptions)),t}var lu={ACTIVE:`active`},uu=class extends j{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(lu.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(lu.ACTIVE,e)}setMap(e){this.map_=e}};function du(e,t,n){let r=e.getCenterInternal();if(r){let i=[r[0]+t[0],r[1]+t[1]];e.animateInternal({duration:n===void 0?250:n,easing:li,center:e.getConstrainedCenter(i)})}}function fu(e,t,n,r){let i=e.getZoom();if(i===void 0)return;let a=e.getConstrainedZoom(i+t),o=e.getResolutionForZoom(a);e.getAnimating()&&e.cancelAnimations(),e.animate({resolution:o,anchor:n,duration:r===void 0?250:r,easing:si})}var pu=class extends uu{constructor(e){super(),e||={},this.delta_=e.delta?e.delta:1,this.duration_=e.duration===void 0?250:e.duration}handleEvent(e){let t=!1;if(e.type==$.DBLCLICK){let n=e.originalEvent,r=e.map,i=e.coordinate,a=n.shiftKey?-this.delta_:this.delta_;fu(r.getView(),a,i,this.duration_),n.preventDefault(),t=!0}return!t}};function mu(e){let t=arguments;return function(e){let n=!0;for(let r=0,i=t.length;r0);else if(e.type==$.POINTERDOWN){let n=this.handleDownEvent(e);this.handlingDownUpSequence=n,t=this.stopDown(n)}else e.type==$.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};function Du(e){let t=e.length,n=0,r=0;for(let i=0;i0&&this.condition_(e)){let t=e.map.getView();return this.lastCentroid=null,t.getAnimating()&&t.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},ku=class extends Eu{constructor(e){e||={},super({stopDown:y}),this.condition_=e.condition?e.condition:hu,this.lastAngle_=void 0,this.duration_=e.duration===void 0?250:e.duration}handleDragEvent(e){if(!wu(e))return;let t=e.map,n=t.getView();if(n.getConstraints().rotation===kl)return;let r=t.getSize(),i=e.pixel,a=Math.atan2(r[1]/2-i[1],i[0]-r[0]/2);if(this.lastAngle_!==void 0){let e=a-this.lastAngle_;n.adjustRotationInternal(-e)}this.lastAngle_=a}handleUpEvent(e){return wu(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return wu(e)&&yu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Au=class extends l{constructor(e){super(),this.geometry_=null,this.element_=document.createElement(`div`),this.element_.style.position=`absolute`,this.element_.style.pointerEvents=`auto`,this.element_.className=`ol-box `+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let e=this.startPixel_,t=this.endPixel_,n=this.element_.style;n.left=Math.min(e[0],t[0])+`px`,n.top=Math.min(e[1],t[1])+`px`,n.width=Math.abs(t[0]-e[0])+`px`,n.height=Math.abs(t[1]-e[1])+`px`}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let e=this.element_.style;e.left=`inherit`,e.top=`inherit`,e.width=`inherit`,e.height=`inherit`}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let e=this.startPixel_,t=this.endPixel_,n=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new Jr([n])}getGeometry(){return this.geometry_}},ju={BOXSTART:`boxstart`,BOXDRAG:`boxdrag`,BOXEND:`boxend`,BOXCANCEL:`boxcancel`},Mu=class extends C{constructor(e,t,n){super(e),this.coordinate=t,this.mapBrowserEvent=n}},Nu=class extends Eu{constructor(e){super(),this.on,this.once,this.un,e??={},this.box_=new Au(e.className||`ol-dragbox`),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??yu,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,n){let r=n[0]-t[0],i=n[1]-t[1];return r*r+i*i>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new Mu(ju.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;let t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new Mu(t?ju.BOXEND:ju.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Mu(ju.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&=(this.dispatchEvent(new Mu(ju.BOXCANCEL,this.startPixel_,null)),null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&=(this.dispatchEvent(new Mu(ju.BOXCANCEL,this.startPixel_,null)),null)),super.setMap(e)}},Pu=class extends Nu{constructor(e){e||={};let t=e.condition?e.condition:Su;super({condition:t,className:e.className||`ol-dragzoom`,minArea:e.minArea}),this.duration_=e.duration===void 0?200:e.duration,this.out_=e.out===void 0?!1:e.out}onBoxEnd(e){let t=this.getMap().getView(),n=this.getGeometry();if(this.out_){let e=t.rotatedExtentForGeometry(n),r=t.getResolutionForExtentInternal(e),i=t.getResolution()/r;n=n.clone(),n.scale(i*i)}t.fitInternal(n,{duration:this.duration_,easing:si})}},Fu={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,DOWN:`ArrowDown`},Iu=class extends uu{constructor(e){super(),e||={},this.defaultCondition_=function(e){return bu(e)&&Cu(e)},this.condition_=e.condition===void 0?this.defaultCondition_:e.condition,this.duration_=e.duration===void 0?100:e.duration,this.pixelDelta_=e.pixelDelta===void 0?128:e.pixelDelta}handleEvent(e){let t=!1;if(e.type==c.KEYDOWN){let n=e.originalEvent,r=n.key;if(this.condition_(e)&&(r==Fu.DOWN||r==Fu.LEFT||r==Fu.RIGHT||r==Fu.UP)){let i=e.map.getView(),a=i.getResolution()*this.pixelDelta_,o=0,s=0;r==Fu.DOWN?s=-a:r==Fu.LEFT?o=-a:r==Fu.RIGHT?o=a:s=a;let c=[o,s];at(c,i.getRotation()),du(i,c,this.duration_),n.preventDefault(),t=!0}}return!t}},Lu=class extends uu{constructor(e){super(),e||={},this.condition_=e.condition?e.condition:function(e){return!xu(e)&&Cu(e)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration===void 0?100:e.duration}handleEvent(e){let t=!1;if(e.type==c.KEYDOWN||e.type==c.KEYPRESS){let n=e.originalEvent,r=n.key;if(this.condition_(e)&&(r===`+`||r===`-`)){let i=e.map,a=r===`+`?this.delta_:-this.delta_;fu(i.getView(),a,void 0,this.duration_),n.preventDefault(),t=!0}}return!t}},Ru=40,zu=300,Bu=3,Vu=class extends uu{constructor(e){e||={},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta===void 0?1:e.maxDelta,this.duration_=e.duration===void 0?250:e.duration,this.timeout_=e.timeout===void 0?80:e.timeout,this.useAnchor_=e.useAnchor===void 0?!0:e.useAnchor,this.constrainResolution_=e.constrainResolution===void 0?!1:e.constrainResolution;let t=e.condition?e.condition:vu;this.condition_=e.onFocusOnly?mu(_u,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(e){if(this.ctrlKeyListenerKeys_.forEach(s),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(e),e){let t=e.getOwnerDocument();this.ctrlKeyListenerKeys_.push(a(t,`keydown`,e=>{e.key===`Control`&&(this.ctrlKeyPressed_=!0)}),a(t,`keyup`,e=>{e.key===`Control`&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;let e=this.getMap();if(!e)return;let t=e.getView(),n=this.lastDelta_?this.lastDelta_>0?1:-1:0;t.endInteraction(this.constrainResolution_||t.getConstrainResolution()?100:void 0,n,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==c.WHEEL)return!0;let t=e.map,n=e.originalEvent;n.preventDefault();let r=n.ctrlKey&&!this.ctrlKeyPressed_;n.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=e.pixel);let i=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:i*=Ru;break;case WheelEvent.DOM_DELTA_PAGE:i*=zu;break;default:}if(i===0)return!1;this.lastDelta_=i;let a=Date.now();this.startTime_===void 0&&(this.startTime_=a),(!this.mode_||a-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(i)<4?`trackpad`:`wheel`);let o=t.getView();if(this.mode_===`trackpad`)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(o.getAnimating()&&o.cancelAnimations(),o.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),r&&(i*=Bu),o.adjustZoom(-i/this.deltaPerZoom_,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=a,!1;this.totalDelta_+=i;let s=Math.max(this.timeout_-(a-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,t),s),!1}handleWheelZoom_(e){let t=e.getView();t.getAnimating()&&t.cancelAnimations();let n=-I(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),fu(t,n,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}},Hu=class extends Eu{constructor(e){e||={};let t=e;t.stopDown||=y,super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold===void 0?.3:e.threshold,this.duration_=e.duration===void 0?250:e.duration}handleDragEvent(e){let t=0,n=this.targetPointers[0],r=this.targetPointers[1],i=Math.atan2(r.clientY-n.clientY,r.clientX-n.clientX);if(this.lastAngle_!==void 0){let e=i-this.lastAngle_;this.rotationDelta_+=e,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=e}this.lastAngle_=i;let a=e.map,o=a.getView();o.getConstraints().rotation!==kl&&(this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(Du(this.targetPointers))),this.rotating_&&(a.render(),o.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}},Uu=class extends Eu{constructor(e){e||={};let t=e;t.stopDown||=y,super(t),this.anchor_=null,this.duration_=e.duration===void 0?400:e.duration,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1,n=this.targetPointers[0],r=this.targetPointers[1],i=n.clientX-r.clientX,a=n.clientY-r.clientY,o=Math.sqrt(i*i+a*a);this.lastDistance_!==void 0&&(t=this.lastDistance_/o),this.lastDistance_=o;let s=e.map,c=s.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(Du(this.targetPointers))),s.render(),c.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){let t=e.map.getView(),n=this.lastScaleDelta_>1?1:-1;return t.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}};function Wu(e){e||={};let t=new ne,n=new xi(-.005,.05,100);return(e.altShiftDragRotate===void 0||e.altShiftDragRotate)&&t.push(new ku),(e.doubleClickZoom===void 0||e.doubleClickZoom)&&t.push(new pu({delta:e.zoomDelta,duration:e.zoomDuration})),(e.dragPan===void 0||e.dragPan)&&t.push(new Ou({onFocusOnly:e.onFocusOnly,kinetic:n})),(e.pinchRotate===void 0||e.pinchRotate)&&t.push(new Hu),(e.pinchZoom===void 0||e.pinchZoom)&&t.push(new Uu({duration:e.zoomDuration})),(e.keyboard===void 0||e.keyboard)&&(t.push(new Iu),t.push(new Lu({delta:e.zoomDelta,duration:e.zoomDuration}))),(e.mouseWheelZoom===void 0||e.mouseWheelZoom)&&t.push(new Vu({onFocusOnly:e.onFocusOnly,duration:e.zoomDuration})),(e.shiftDragZoom===void 0||e.shiftDragZoom)&&t.push(new Pu({duration:e.zoomDuration})),t}var Gu={ADDLAYER:`addlayer`,REMOVELAYER:`removelayer`},Ku=class extends C{constructor(e,t){super(e),this.layer=t}},qu={LAYERS:`layers`},Ju=class e extends Vl{constructor(e){e||={};let t=Object.assign({},e);delete t.layers;let n=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(qu.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new ne(n.slice(),{unique:!0}):M(typeof n.getArray==`function`,"Expected `layers` to be an array or a `Collection`"):n=new ne(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(s),this.layersListenerKeys_.length=0;let e=this.getLayers();this.layersListenerKeys_.push(a(e,t.ADD,this.handleLayersAdd_,this),a(e,t.REMOVE,this.handleLayersRemove_,this));for(let e in this.listenerKeys_)this.listenerKeys_[e].forEach(s);r(this.listenerKeys_);let n=e.getArray();for(let e=0,t=n.length;e=0;--i){let a=m[i],d=a.layer;if(d.hasRenderer()&&Ul(a,l)&&o.call(s,d)){let i=d.getRenderer(),o=d.getSource();if(i&&o){let s=o.getWrapX()?f:e,l=u.bind(null,a.managed);_[0]=s[0]+p[r][0],_[1]=s[1]+p[r][1],c=i.forEachFeatureAtCoordinate(_,t,n,l,g)}if(c)return c}}if(g.length===0)return;let v=1/g.length;return g.forEach((e,t)=>e.distanceSq+=t*v),g.sort((e,t)=>e.distanceSq-t.distanceSq),g.some(e=>c=e.callback(e.feature,e.layer,e.geometry)),c}hasFeatureAtCoordinate(e,t,n,r,i,a){return this.forEachFeatureAtCoordinate(e,t,n,r,v,this,i,a)!==void 0}getMap(){return this.map_}renderFrame(e){D()}scheduleExpireIconCache(e){$i.canExpireCache()&&e.postRenderFunctions.push(Xu)}};function Xu(e,t){$i.expire()}var Zu=class extends Yu{constructor(e){super(e),this.fontChangeListenerKey_=a(Ea,n.PROPERTYCHANGE,e.redrawText,e),this.element_=ei?_i():document.createElement(`div`);let t=this.element_.style;t.position=`absolute`,t.width=`100%`,t.height=`100%`,t.zIndex=`0`,this.element_.className=ua+` ol-layers`;let r=e.getViewport();r&&r.insertBefore(this.element_,r.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){let n=this.getMap();if(n.hasListener(e)){let r=new Bs(e,void 0,t);n.dispatchEvent(r)}}disposeInternal(){s(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&=(this.element_.style.display=`none`,!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(ro.PRECOMPOSE,e);let t=e.layerStatesArray.sort((e,t)=>e.zIndex-t.zIndex);t.some(e=>e.layer instanceof Gl&&e.layer.getDeclutter())&&(e.declutter={});let n=e.viewState;this.children_.length=0;let r=[],i=null;for(let a=0,o=t.length;a0)&&(e.fillStyle=r,e.fillRect(0,0,a.width,a.height)),vi(n)&&n.width>0){e.save();let r=t.style.opacity||n.style.opacity;e.globalAlpha=r===``?1:Number(r);let i=n.style.transform;if(i)e.transform(...Gn(i));else{let t=parseFloat(n.style.width)/n.width,r=parseFloat(n.style.height)/n.height;e.transform(t,0,0,r,0,0)}e.drawImage(n,0,0),e.restore()}}}this.dispatchRenderEvent(ro.POSTCOMPOSE,e),this.renderedVisible_||=(this.element_.style.display=``,!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let n=t.length-1;n>=0;--n){let r=t[n],i=r.layer;i.getDeclutter()&&i.renderDeclutter(e,r)}t.forEach(t=>t.layer.renderDeferred(e))}}};function Qu(e){if(e instanceof Hl){e.setMapInternal(null);return}e instanceof Ju&&e.getLayers().forEach(Qu)}function $u(e,t){if(e instanceof Hl){e.setMapInternal(t);return}if(e instanceof Ju){let n=e.getLayers().getArray();for(let e=0,r=n.length;ethis.updateSize())),this.controls=n.controls||(ei?new ne:cu()),this.interactions=n.interactions||(ei?new ne:Wu({onFocusOnly:!0})),this.overlays_=n.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new nu(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener($l.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener($l.VIEW,this.handleViewChanged_),this.addChangeListener($l.SIZE,this.handleSizeChanged_),this.addChangeListener($l.TARGET,this.handleTargetChanged_),this.setProperties(n.values);let r=this;e.view&&!(e.view instanceof Pl)&&e.view.then(function(e){r.setView(new Pl(e))}),this.controls.addEventListener(t.ADD,e=>{e.element.setMap(this)}),this.controls.addEventListener(t.REMOVE,e=>{e.element.setMap(null)}),this.interactions.addEventListener(t.ADD,e=>{e.element.setMap(this)}),this.interactions.addEventListener(t.REMOVE,e=>{e.element.setMap(null)}),this.overlays_.addEventListener(t.ADD,e=>{this.addOverlayInternal_(e.element)}),this.overlays_.addEventListener(t.REMOVE,e=>{let t=e.element.getId();t!==void 0&&delete this.overlayIdIndex_[t.toString()],e.element.setMap(null)}),this.controls.forEach(e=>{e.setMap(this)}),this.interactions.forEach(e=>{e.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){$u(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){let t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,n){if(!this.frameState_||!this.renderer_)return;let r=this.getCoordinateFromPixelInternal(e);n=n===void 0?{}:n;let i=n.hitTolerance===void 0?0:n.hitTolerance,a=n.layerFilter===void 0?v:n.layerFilter,o=n.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,i,o,t,null,a,null)}getFeaturesAtPixel(e,t){let n=[];return this.forEachFeatureAtPixel(e,function(e){n.push(e)},t),n}getAllLayers(){let e=[];function t(n){n.forEach(function(n){n instanceof Ju?t(n.getLayers()):e.push(n)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;let n=this.getCoordinateFromPixelInternal(e);t=t===void 0?{}:t;let r=t.layerFilter===void 0?v:t.layerFilter,i=t.hitTolerance===void 0?0:t.hitTolerance,a=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,i,a,r,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){let t=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=t.width/n[0],i=t.height/n[1],a=`changedTouches`in e?e.changedTouches[0]:e;return[(a.clientX-t.left)/r,(a.clientY-t.top)/i]}getTarget(){return this.get($l.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return Mn(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){let t=this.frameState_;return t?R(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){let t=this.overlayIdIndex_[e.toString()];return t===void 0?null:t}getInteractions(){return this.interactions}getLayerGroup(){return this.get($l.LAYERGROUP)}setLayers(e){let t=this.getLayerGroup();if(e instanceof ne){t.setLayers(e);return}let n=t.getLayers();n.clear(),n.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let e=this.getLayerGroup().getLayerStatesArray();for(let t=0,n=e.length;t=0;n--){let r=t[n];if(!(r.getMap()!==this||!r.getActive()||!this.getTargetElement())&&(!r.handleEvent(e)||e.propagationStopped))break}}}handlePostRender(){let e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let n=this.maxTilesLoading_,r=n,i=e?e.viewHints:void 0,a=i?i[H.ANIMATING]||i[H.INTERACTING]:!1;if(a){let t=Date.now()-e.time>8;n=t?0:8,r=t?0:2}t.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0)}setLayerGroup(e){let t=this.getLayerGroup();t&&this.handleLayerRemove_(new Ku(`removelayer`,t)),this.set($l.LAYERGROUP,e)}setSize(e){this.set($l.SIZE,e)}setTarget(e){this.set($l.TARGET,e)}setView(e){if(!e||e instanceof Pl){this.set($l.VIEW,e);return}this.set($l.VIEW,new Pl);let t=this;e.then(function(e){t.setView(new Pl(e))})}updateSize(){let e=this.getTargetElement(),t;if(e){let n,r;if(vi(e)){let t=e.getContext(`2d`).getTransform();n=e.width/t.a,r=e.height/t.d}else{let t=getComputedStyle(e);n=e.offsetWidth-parseFloat(t.borderLeftWidth)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderRightWidth),r=e.offsetHeight-parseFloat(t.borderTopWidth)-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)-parseFloat(t.borderBottomWidth)}!isNaN(n)&&!isNaN(r)&&(t=[Math.max(0,n),Math.max(0,r)],!Vo(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&nt(`No map visible because the map container's width or height are 0.`))}let n=this.getSize();t&&(!n||!g(t,n))&&(this.updateViewportSize_(t),this.setSize(t))}updateViewportSize_(e){let t=this.getView();t&&t.setViewportSize(e)}};function td(e){let t=null;e.keyboardEventTarget!==void 0&&(t=typeof e.keyboardEventTarget==`string`?document.getElementById(e.keyboardEventTarget):e.keyboardEventTarget);let n={},r=e.layers&&typeof e.layers.getLayers==`function`?e.layers:new Ju({layers:e.layers});n[$l.LAYERGROUP]=r,n[$l.TARGET]=e.target,n[$l.VIEW]=e.view instanceof Pl?e.view:new Pl;let i;e.controls!==void 0&&(Array.isArray(e.controls)?i=new ne(e.controls.slice()):(M(typeof e.controls.getArray==`function`,"Expected `controls` to be an array or an `ol/Collection.js`"),i=e.controls));let a;e.interactions!==void 0&&(Array.isArray(e.interactions)?a=new ne(e.interactions.slice()):(M(typeof e.interactions.getArray==`function`,"Expected `interactions` to be an array or an `ol/Collection.js`"),a=e.interactions));let o;return e.overlays===void 0?o=new ne:Array.isArray(e.overlays)?o=new ne(e.overlays.slice()):(M(typeof e.overlays.getArray==`function`,"Expected `overlays` to be an array or an `ol/Collection.js`"),o=e.overlays),{controls:i,interactions:a,keyboardEventTarget:t,overlays:o,values:n}}var nd=class{constructor(e,t,n,r){this.minX=e,this.maxX=t,this.minY=n,this.maxY=r}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}};function rd(e,t,n,r,i){return i===void 0?new nd(e,t,n,r):(i.minX=e,i.maxX=t,i.minY=n,i.maxY=r,i)}var id=class e extends $n{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(s),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let t=0,n=e.length;te.clone())}var od=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=re,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let n=t.dataProjection?L(t.dataProjection):this.readProjection(e);t.extent&&n&&n.getUnits()===`tile-pixels`&&(n=L(n),n.setWorldExtent(t.extent)),t={dataProjection:n,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return D()}readFeature(e,t){return D()}readFeatures(e,t){return D()}readGeometry(e,t){return D()}readProjection(e){return D()}writeFeature(e,t){return D()}writeFeatures(e,t){return D()}writeGeometry(e,t){return D()}};function sd(e,t,n){let r=n?L(n.featureProjection):null,i=n?L(n.dataProjection):null,a=e;if(r&&i&&!wn(r,i)){t&&(a=e.clone());let n=t?r:i,o=t?i:r;n.getUnits()===`tile-pixels`?a.transform(n,o):a.applyTransform(Dn(n,o))}if(t&&n&&n.decimals!==void 0){let t=10**n.decimals;a===e&&(a=e.clone()),a.applyTransform(function(e){for(let n=0,r=e.length;nud({...e,geometry:t})).flat();let r=n.type===`MultiPolygon`?`Polygon`:n.type;if(r===`GeometryCollection`||r===`Circle`)throw Error(`Unsupported geometry type: `+r);let i=n.layout.length;return sd(new mo(r,r===`Polygon`?ld(n.flatCoordinates,n.ends,i):n.flatCoordinates,n.ends?.flat(),i,e.properties||{},e.id).enableSimplifyTransformed(),!1,t)}function dd(e,t){if(!e)return null;if(Array.isArray(e))return new id(e.map(e=>dd(e,t)));let n=cd[e.type];return sd(new n(e.flatCoordinates,e.layout||`XY`,e.ends),!1,t)}var fd=class extends od{constructor(){super()}getType(){return`json`}readFeature(e,t){return this.readFeatureFromObject(pd(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(pd(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return D()}readFeaturesFromObject(e,t){return D()}readGeometry(e,t){return this.readGeometryFromObject(pd(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return D()}readProjection(e){return this.readProjectionFromObject(pd(e))}readProjectionFromObject(e){return D()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return D()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return D()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return D()}};function pd(e){return typeof e==`string`?JSON.parse(e)||null:e===null?null:e}var md=class extends fd{constructor(e){e||={},super(),this.dataProjection=L(e.dataProjection?e.dataProjection:`EPSG:4326`),e.featureProjection&&(this.defaultFeatureProjection=L(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=[`application/geo+json`,`application/vnd.geo+json`]}readFeatureFromObject(e,t){let n=null;n=e.type===`Feature`?e:{type:`Feature`,geometry:e,properties:null};let r=hd(n.geometry,t);if(this.featureClass===mo)return ud({geometry:r,id:n.id,properties:n.properties},t);let i=new re;return this.geometryName_?i.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&i.setGeometryName(n.geometry_name),i.setGeometry(dd(r,t)),`id`in n&&i.setId(n.id),n.properties&&i.setProperties(n.properties,!0),i}readFeaturesFromObject(e,t){let n=e,r=null;if(n.type===`FeatureCollection`){let n=e;r=[];let i=n.features;for(let e=0,n=i.length;e2||Math.abs(e[t*4+3]-.75*255)>2}function Bd(){if(Id===void 0){let e=V(6,6,Ld);e.globalCompositeOperation=`lighter`,e.fillStyle=`rgba(210, 0, 0, 0.75)`,Rd(e,4,5,4,0),Rd(e,4,5,0,5);let t=e.getImageData(0,0,3,3).data;Id=zd(t,0)||zd(t,4)||zd(t,8),pi(e),Ld.push(e.canvas)}return Id}function Vd(e,t,n,r){let i=On(n,t,e),a=vn(t,r,n),o=t.getMetersPerUnit();o!==void 0&&(a*=o);let s=e.getMetersPerUnit();s!==void 0&&(a/=s);let c=e.getExtent();if(!c||ue(c,i)){let t=vn(e,a,i)/a;isFinite(t)&&t>0&&(a/=t)}return a}function Hd(e,t,n,r){let i=Vd(e,t,Oe(n),r);return(!isFinite(i)||i<=0)&&we(n,function(n){return i=Vd(e,t,n,r),isFinite(i)&&i>0}),i}function Ud(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=V(Math.round(n*e),Math.round(n*t),Ld);if(d||(m.imageSmoothingEnabled=!1),c.length===0)return m.canvas;m.scale(n,n);function h(e){return Math.round(e*n)/n}m.globalCompositeOperation=`lighter`;let g=me();c.forEach(function(e,t,n){be(g,e.extent)});let _,v=n/r,y=(d?1:1+2**-24)/v;if(!f||c.length!==1||l!==0){if(_=V(Math.round(F(g)*v),Math.round(P(g)*v),Ld),d||(_.imageSmoothingEnabled=!1),i&&p){let e=(i[0]-g[0])*v,t=-(i[3]-g[3])*v,n=F(i)*v,r=P(i)*v;_.rect(e,t,n,r),_.clip()}c.forEach(function(e,t,n){if(e.image.width>0&&e.image.height>0){if(e.clipExtent){_.save();let t=(e.clipExtent[0]-g[0])*v,n=-(e.clipExtent[3]-g[3])*v,r=F(e.clipExtent)*v,i=P(e.clipExtent)*v;_.rect(d?t:Math.round(t),d?n:Math.round(n),d?r:Math.round(t+r)-Math.round(t),d?i:Math.round(n+i)-Math.round(n)),_.clip()}let t=(e.extent[0]-g[0])*v,n=-(e.extent[3]-g[3])*v,r=F(e.extent)*v,i=P(e.extent)*v;_.drawImage(e.image,l,l,e.image.width-2*l,e.image.height-2*l,d?t:Math.round(t),d?n:Math.round(n),d?r:Math.round(t+r)-Math.round(t),d?i:Math.round(n+i)-Math.round(n)),e.clipExtent&&_.restore()}})}let b=Ne(o);return s.getTriangles().forEach(function(e,t,n){let r=e.source,i=e.target,o=r[0][0],s=r[0][1],l=r[1][0],u=r[1][1],f=r[2][0],p=r[2][1],v=h((i[0][0]-b[0])/a),x=h(-(i[0][1]-b[1])/a),S=h((i[1][0]-b[0])/a),C=h(-(i[1][1]-b[1])/a),w=h((i[2][0]-b[0])/a),T=h(-(i[2][1]-b[1])/a),E=o,D=s;o=0,s=0,l-=E,u-=D,f-=E,p-=D;let O=We([[l,u,0,0,S-v],[f,p,0,0,w-v],[0,0,l,u,C-x],[0,0,f,p,T-x]]);if(!O)return;if(m.save(),m.beginPath(),Bd()||!d){m.moveTo(S,C);let e=v-S,t=x-C;for(let n=0;n<4;n++)m.lineTo(S+h((n+1)*e/4),C+h(n*t/3)),n!=3&&m.lineTo(S+h((n+1)*e/4),C+h((n+1)*t/3));m.lineTo(w,T)}else m.moveTo(S,C),m.lineTo(v,x),m.lineTo(w,T);m.clip(),m.transform(O[0],O[2],O[1],O[3],v,x),m.translate(g[0]-E,g[3]-D);let k;if(_)k=_.canvas,m.scale(y,-y);else{let e=c[0],t=e.extent;k=e.image,m.scale(F(t)/k.width,-P(t)/k.height)}m.drawImage(k,0,0),m.restore()}),_&&(pi(_),Ld.push(_.canvas)),u&&(m.save(),m.globalCompositeOperation=`source-over`,m.strokeStyle=`black`,m.lineWidth=1,s.getTriangles().forEach(function(e,t,n){let r=e.target,i=(r[0][0]-b[0])/a,o=-(r[0][1]-b[1])/a,s=(r[1][0]-b[0])/a,c=-(r[1][1]-b[1])/a,l=(r[2][0]-b[0])/a,u=-(r[2][1]-b[1])/a;m.beginPath(),m.moveTo(s,c),m.lineTo(i,o),m.lineTo(l,u),m.closePath(),m.stroke()}),m.restore()),m.canvas}var Wd=10,Gd=.25,Kd=class{constructor(e,t,n,r,i,a,o){this.sourceProj_=e,this.targetProj_=t;let s={},c=o?Sn(e=>R(o,On(e,this.targetProj_,this.sourceProj_))):Dn(this.targetProj_,this.sourceProj_);this.transformInv_=function(e){let t=e[0]+`/`+e[1];return s[t]||(s[t]=c(e)),s[t]},this.maxSourceExtent_=r,this.errorThresholdSquared_=i*i,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&F(r)>=F(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?F(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?F(this.targetProj_.getExtent()):null;let l=Ne(n),u=Pe(n),d=De(n),f=Ee(n),p=this.transformInv_(l),m=this.transformInv_(u),h=this.transformInv_(d),g=this.transformInv_(f),_=Wd+(a?Math.max(0,Math.ceil(Math.log2(Te(n)/(a*a*256*256)))):0);if(this.addQuad_(l,u,d,f,p,m,h,g,_),this.wrapsXInSource_){let e=1/0;this.triangles_.forEach(function(t,n,r){e=Math.min(e,t.source[0][0],t.source[1][0],t.source[2][0])}),this.triangles_.forEach(t=>{if(Math.max(t.source[0][0],t.source[1][0],t.source[2][0])-e>this.sourceWorldWidth_/2){let n=[[t.source[0][0],t.source[0][1]],[t.source[1][0],t.source[1][1]],[t.source[2][0],t.source[2][1]]];n[0][0]-e>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-e>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-e>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);let r=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-r.5&&u<1,p=!1;if(c>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(p=F(ae([e,t,n,r]))/this.targetWorldWidth_>Gd||p),!f&&this.sourceProj_.isGlobal()&&u&&(p=u>Gd||p)),!p&&this.maxSourceExtent_&&isFinite(l[0])&&isFinite(l[1])&&isFinite(l[2])&&isFinite(l[3])&&!Fe(l,this.maxSourceExtent_))return;let m=0;if(!p&&(!isFinite(i[0])||!isFinite(i[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(s[0])||!isFinite(s[1]))){if(c>0)p=!0;else if(m=(!isFinite(i[0])||!isFinite(i[1])?8:0)+(!isFinite(a[0])||!isFinite(a[1])?4:0)+(!isFinite(o[0])||!isFinite(o[1])?2:0)+ +(!isFinite(s[0])||!isFinite(s[1])),m!=1&&m!=2&&m!=4&&m!=8)return}if(c>0){if(!p){let t=[(e[0]+n[0])/2,(e[1]+n[1])/2],r=this.transformInv_(t),a;a=f?(qe(i[0],d)+qe(o[0],d))/2-qe(r[0],d):(i[0]+o[0])/2-r[0];let s=(i[1]+o[1])/2-r[1];p=a*a+s*s>this.errorThresholdSquared_}if(p){if(Math.abs(e[0]-n[0])<=Math.abs(e[1]-n[1])){let l=[(t[0]+n[0])/2,(t[1]+n[1])/2],u=this.transformInv_(l),d=[(r[0]+e[0])/2,(r[1]+e[1])/2],f=this.transformInv_(d);this.addQuad_(e,t,l,d,i,a,u,f,c-1),this.addQuad_(d,l,n,r,f,u,o,s,c-1)}else{let l=[(e[0]+t[0])/2,(e[1]+t[1])/2],u=this.transformInv_(l),d=[(n[0]+r[0])/2,(n[1]+r[1])/2],f=this.transformInv_(d);this.addQuad_(e,l,d,r,i,u,f,s,c-1),this.addQuad_(l,t,n,d,u,a,o,f,c-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}m&11||this.addTriangle_(e,n,r,i,o,s),m&14||this.addTriangle_(e,n,t,i,o,a),m&&(m&13||this.addTriangle_(t,r,e,a,s,i),m&7||this.addTriangle_(t,r,n,a,s,o))}calculateSourceExtent(){let e=me();return this.triangles_.forEach(function(t,n,r){let i=t.source;xe(e,i[0]),xe(e,i[1]),xe(e,i[2])}),e}getTriangles(){return this.triangles_}},qd=.5,Jd=class extends ui{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(i,B.IDLE,d),this.renderEdges_=u===void 0?!1:u,this.pixelRatio_=o,this.gutter_=s,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=r,this.wrappedTileCoord_=a||i,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;let f=r.getTileCoordExtent(this.wrappedTileCoord_),p=this.targetTileGrid_.getExtent(),m=this.sourceTileGrid_.getExtent(),h=p?Me(f,p):f;if(Te(h)===0){this.state=B.EMPTY;return}let g=e.getExtent();g&&(m=m?Me(m,g):g);let _=r.getResolution(this.wrappedTileCoord_[0]),v=Hd(e,n,h,_);if(!isFinite(v)||v<=0){this.state=B.EMPTY;return}if(this.triangulation_=new Kd(e,n,h,m,v*(l===void 0?qd:l),_),this.triangulation_.getTriangles().length===0){this.state=B.EMPTY;return}this.sourceZ_=t.getZForResolution(v);let y=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(y[1]=I(y[1],m[1],m[3]),y[3]=I(y[3],m[1],m[3])):y=Me(y,m)),!Te(y))this.state=B.EMPTY;else{let n=0,r=0;e.canWrapX()&&(n=F(g),r=Math.floor((y[0]-g[0])/n)),Ve(y.slice(),e,!0).forEach(e=>{let i=t.getTileRangeForExtentAndZ(e,this.sourceZ_);for(let e=i.minX;e<=i.maxX;e++)for(let t=i.minY;t<=i.maxY;t++){let i=r*n;this.sourceTiles_.push({getTile:()=>c(this.sourceZ_,e,t,o),offset:i})}++r}),this.sourceTiles_.length===0&&(this.state=B.EMPTY)}}getImage(){return this.canvas_}reproject_(){let e=[];if(this.sourceTiles_.forEach(t=>{let n=t.tile;if(n&&n.getState()==B.LOADED){let r=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);r[0]+=t.offset,r[2]+=t.offset;let i=this.clipExtent_?.slice();i&&(i[0]+=t.offset,i[2]+=t.offset),e.push({extent:r,clipExtent:i,image:n.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=B.ERROR;else{let t=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(t),r=typeof n==`number`?n:n[0],i=typeof n==`number`?n:n[1],a=this.targetTileGrid_.getResolution(t),o=this.sourceTileGrid_.getResolution(this.sourceZ_),s=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Ud(r,i,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),a,s,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=B.LOADED}this.changed()}load(){for(let e of this.sourceTiles_)e.tile=e.getTile();if(this.state==B.IDLE){this.state=B.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{let n=t.getState();if(n==B.IDLE||n==B.LOADING){e++;let n=a(t,c.CHANGE,r=>{let i=t.getState();(i==B.LOADED||i==B.ERROR||i==B.EMPTY)&&(s(n),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},t,n){e.getState()==B.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(s),this.sourcesListenerKeys_=null}release(){this.canvas_&&=(pi(this.canvas_.getContext(`2d`)),Ld.push(this.canvas_),null),this.sourceTiles_.length=0,super.release()}},Yd=class{constructor(e){this.highWaterMark=e===void 0?2048:e,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let e=this.pop();e instanceof l&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){let n=this.entries_[e];return M(n!==void 0,`Tried to get a value for a key that does not exist in the cache`),n===this.newest_?n.value_:(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n,n.value_)}remove(e){let t=this.entries_[e];return M(t!==void 0,`Tried to get a value for a key that does not exist in the cache`),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){let e=Array(this.count_),t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.key_;return e}getValues(){let e=Array(this.count_),t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){let e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){M(!(e in this.entries_),`Tried to set a value for a key that is used already`);let n={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[e]=n,++this.count_}setSize(e){this.highWaterMark=e}};function Xd(e,t,n,r){return r===void 0?[e,t,n]:(r[0]=e,r[1]=t,r[2]=n,r)}function Zd(e,t,n){return e+`/`+t+`/`+n}function Qd(e,t,n,r,i){return`${k(e)},${t},${Zd(n,r,i)}`}function $d(e){return ef(e[0],e[1],e[2])}function ef(e,t,n){return(t<n||n>t.getMaxZoom())return!1;let a=t.getFullTileRange(n);return a?a.containsXY(r,i):!0}function nf(e,t,n){if(!(n in e))return e[n]=new Set([t]),!0;let r=e[n],i=r.has(t);return i||r.add(t),!i}function rf(e,t,n){let r=e[n];return r?r.delete(t):!1}function af(e,t){let n=e.layerStatesArray[e.layerIndex];n.extent&&(t=Me(t,Fn(n.extent,e.viewState.projection)));let r=n.layer.getRenderSource();if(!r.getWrapX()){let n=r.getTileGridForProjection(e.viewState.projection).getExtent();n&&(t=Me(t,n))}return t}var of=class extends Ks{constructor(e,t){super(e),t||={},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=me(),this.tempTileRange_=new nd(0,0,0,0),this.tempTileCoord_=Xd(0,0,0);let n=t.cacheSize===void 0?512:t.cacheSize;this.tileCache_=new Yd(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=n*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||=new Yd(512),this.sourceTileCache_}getOrCreateTile(e,t,n,r){let i=this.tileCache_,a=this.getLayer().getSource(),o=Qd(a,a.getKey(),e,t,n),s;if(i.containsKey(o))s=i.get(o);else{let c=r.viewState.projection,l=a.getProjection();if(s=a.getTile(e,t,n,r.pixelRatio,c,!l||wn(l,c)?void 0:this.getSourceTileCache()),!s)return null;i.set(o,s)}return s}getTile(e,t,n,r){return this.getOrCreateTile(e,t,n,r)||null}getData(e){let t=this.frameState;if(!t)return null;let n=this.getLayer(),r=R(t.pixelToCoordinateTransform,e.slice()),i=n.getExtent();if(i&&!ue(i,r))return null;let a=t.viewState,o=n.getRenderSource(),s=o.getTileGridForProjection(a.projection),c=o.getTilePixelRatio(t.pixelRatio);for(let e=s.getZForResolution(a.resolution);e>=s.getMinZoom();--e){let n=s.getTileCoordForCoordAndZ(r,e),i=this.getTile(e,n[1],n[2],t);if(!i||i.getState()!==B.LOADED)continue;let l=s.getOrigin(e),u=Uo(s.getTileSize(e)),d=s.getResolution(e),f;if(i instanceof yi||i instanceof Jd)f=i.getImage();else if(i instanceof Fd){if(f=Md(i.getData()),!f)continue}else continue;let p=Math.floor(c*((r[0]-l[0])/d-n[1]*u[0])),m=Math.floor(c*((l[1]-r[1])/d-n[2]*u[1])),h=Math.round(c*o.getGutterForProjection(a.projection));return this.getImageData(f,p+h,m+h)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;let t=this.getLayer().getSource();if(!t)return!1;let n=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,n,r,i){let a=e.viewState,o=this.getLayer(),s=o.getRenderSource(),c=s.getTileGridForProjection(a.projection),l=k(s);l in e.wantedTiles||(e.wantedTiles[l]={});let u=e.wantedTiles[l],d=o.getMapInternal(),f=Math.max(n-i,c.getMinZoom(),c.getZForResolution(Math.min(o.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):c.getResolution(0)),s.zDirection)),p=a.rotation,m=p?je(a.center,a.resolution,p,e.size):void 0;for(let i=n;i>=f;--i){let n=c.getTileRangeForExtentAndZ(t,i,this.tempTileRange_),a=c.getResolution(i);for(let t=n.minX;t<=n.maxX;++t)for(let o=n.minY;o<=n.maxY;++o){if(p&&!c.tileCoordIntersectsViewport([i,t,o],m))continue;let n=this.getTile(i,t,o,e);if(!n||!nf(r,n,i))continue;let s=n.getKey();if(u[s]=!0,n.getState()===B.IDLE&&!e.tileQueue.isKeyQueued(s)){let r=Xd(i,t,o,this.tempTileCoord_);e.tileQueue.enqueue([n,l,c.getTileCoordCenter(r),a])}}}}findStaleTile_(e,t){let n=this.tileCache_,r=e[0],i=e[1],a=e[2],o=this.getStaleKeys();for(let e=0;e0&&setTimeout(()=>{this.enqueueTiles(e,w,f-1,S,C-1)},0),!(f in S))return this.container;let T=k(this),E=e.time;for(let t of S[f]){let n=t.getState();if(n===B.EMPTY)continue;let r=t.tileCoord;if(n===B.LOADED&&t.getAlpha(T,E)===1){t.endTransition(T);continue}if(n!==B.ERROR&&(this.renderComplete=!1),this.findStaleTile_(r,S)){rf(S,t,f),e.animate=!0;continue}if(this.findAltTiles_(u,r,f+1,S))continue;let i=u.getMinZoom();for(let e=f-1;e>=i&&!this.findAltTiles_(u,r,e,S);--e);}let D=p/a*s/g,O=this.getRenderContext(e);Bn(this.tempTransform,_/2,v/2,D,D,0,-_/2,-v/2),this.layerExtent&&this.clipUnrotated(O,e,this.layerExtent),l.getInterpolate()||(O.imageSmoothingEnabled=!1),this.preRender(O,e);let A=Object.keys(S).map(Number);A.sort(d);let j,ee=[],te=[];for(let t=A.length-1;t>=0;--t){let n=A[t],r=l.getTilePixelSize(n,s,i),a=u.getResolution(n)/p,o=r[0]*a*D,c=r[1]*a*D,d=u.getTileCoordForCoordAndZ(Ne(x),n),f=u.getTileCoordExtent(d),m=R(this.tempTransform,[g*(f[0]-x[0])/p,g*(x[3]-f[3])/p]),h=g*l.getGutterForProjection(i);for(let t of S[n]){if(t.getState()!==B.LOADED)continue;let r=t.tileCoord,i=d[1]-r[1],a=Math.round(m[0]-(i-1)*o),s=d[2]-r[2],u=Math.round(m[1]-(s-1)*c),f=Math.round(m[0]-i*o),p=Math.round(m[1]-s*c),g=a-f,_=u-p,v=A.length===1,y=!1;j=[f,p,f+g,p,f+g,p+_,f,p+_];for(let e=0,t=ee.length;e{let n=k(l),r=t.wantedTiles[n],i=r?Object.keys(r).length:0;this.updateCacheSize(i),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()}),this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,n,r,i,a,o,s){let c;if(e instanceof Fd){if(c=Md(e.getData()),!c)throw Error(`Rendering array data is not yet supported`)}else c=this.getTileImage(e);if(!c)return;let l=this.getRenderContext(t),u=k(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(s?e.getAlpha(u,t.time):1),p=f!==l.globalAlpha;p&&(l.save(),l.globalAlpha=f),l.drawImage(c,o,o,c.width-2*o,c.height-2*o,n,r,i,a),p&&l.restore(),f===d.opacity?s&&e.endTransition(u):t.animate=!0}getImage(){let e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,n){let r=k(t);r in e||(e[r]={}),e[r][n.getKey()]=!0}},sf={PRELOAD:`preload`,USE_INTERIM_TILES_ON_ERROR:`useInterimTilesOnError`},cf=class extends Hl{constructor(e){e||={};let t=Object.assign({},e),n=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n,this.setPreload(e.preload===void 0?0:e.preload),this.setUseInterimTilesOnError(e.useInterimTilesOnError===void 0?!0:e.useInterimTilesOnError)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(sf.PRELOAD)}setPreload(e){this.set(sf.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(sf.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(sf.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}},lf=class extends cf{constructor(e){super(e)}createRenderer(){return new of(this,{cacheSize:this.getCacheSize()})}},uf=/\{z\}/g,df=/\{x\}/g,ff=/\{y\}/g,pf=/\{-y\}/g;function mf(e,t,n,r,i){return e.replace(uf,t.toString()).replace(df,n.toString()).replace(ff,r.toString()).replace(pf,function(){if(i===void 0)throw Error(`If the URL template has a {-y} placeholder, the grid extent must be known`);return(i-r).toString()})}function hf(e){let t=[],n=/\{([a-z])-([a-z])\}/.exec(e);if(n){let r=n[1].charCodeAt(0),i=n[2].charCodeAt(0),a;for(a=r;a<=i;++a)t.push(e.replace(n[0],String.fromCharCode(a)));return t}if(n=/\{(\d+)-(\d+)\}/.exec(e),n){let r=parseInt(n[2],10);for(let i=parseInt(n[1],10);i<=r;i++)t.push(e.replace(n[0],i.toString()));return t}return t.push(e),t}var gf=[0,0,0],_f=5,vf=class{constructor(e){this.minZoom=e.minZoom===void 0?0:e.minZoom,this.resolutions_=e.resolutions,M(_(this.resolutions_,(e,t)=>t-e,!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let e=0,n=this.resolutions_.length-1;e{let r=new nd(Math.min(0,e[0]),Math.max(e[0]-1,-1),Math.min(0,e[1]),Math.max(e[1]-1,-1));if(n){let e=this.getTileRangeForExtentAndZ(n,t);r.minX=Math.max(e.minX,r.minX),r.maxX=Math.min(e.maxX,r.maxX),r.minY=Math.max(e.minY,r.minY),r.maxY=Math.min(e.maxY,r.maxY)}return r})}forEachTileCoord(e,t,n){let r=this.getTileRangeForExtentAndZ(e,t);for(let e=r.minX,i=r.maxX;e<=i;++e)for(let i=r.minY,a=r.maxY;i<=a;++i)n([t,e,i])}forEachTileCoordParentTileRange(e,t,n,r){let i,a,o,s=null,c=e[0]-1;for(this.zoomFactor_===2?(a=e[1],o=e[2]):s=this.getTileCoordExtent(e,r);c>=this.minZoom;){if(a!==void 0&&o!==void 0?(a=Math.floor(a/2),o=Math.floor(o/2),i=rd(a,a,o,o,n)):i=this.getTileRangeForExtentAndZ(s,c,n),t(c,i))return!0;--c}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getOrigins(){return this.origins_}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,n){if(e[0]this.maxZoom||t0?r:Math.max(a/n[0],i/n[1]);let o=t+1,s=Array(o);for(let e=0;ethis.getTileInternal(e,t,n,r,o,a),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return l.key=c,l}getTileInternal(e,t,n,r,i,a){let o=this.getKey(),s=Qd(this,o,e,t,n);if(a&&a.containsKey(s))return a.get(s);let c=this.createTile_(e,t,n,r,i,o);return a?.set(s,c),c}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){let n=L(e);if(n){let e=k(n);e in this.tileGridForProjection||(this.tileGridForProjection[e]=t)}}};function Pf(e,t){if(ei){let n=e.getCrossOrigin(),r=`same-origin`,i=`same-origin`;n===`anonymous`||n===``?(r=`cors`,i=`omit`):n===`use-credentials`&&(r=`cors`,i=`include`);let a={mode:r,credentials:i,referrerPolicy:e.getReferrerPolicy()};fetch(t,a).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}).then(e=>createImageBitmap(e)).then(t=>{let n=e.getImage();n.width=t.width,n.height=t.height,n.getContext(`2d`).drawImage(t,0,0),t.close?.(),n.dispatchEvent(new Event(`load`))}).catch(()=>{e.getImage().dispatchEvent(new Event(`error`))});return}e.getImage().src=t}var Ff=class extends Nf{constructor(e){e||={};let t=e.projection===void 0?`EPSG:3857`:e.projection,n=e.tileGrid===void 0?Sf({extent:Tf(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize}):e.tileGrid;super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,referrerPolicy:e.referrerPolicy,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:n,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX===void 0?!0:e.wrapX,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter===void 0?0:e.gutter}getGutter(){return this.gutter_}},If=`© OpenStreetMap contributors.`,Lf=class extends Ff{constructor(e){e||={};let t;t=e.attributions===void 0?[If]:e.attributions;let n=e.url===void 0?`https://tile.openstreetmap.org/{z}/{x}/{y}.png`:e.url;super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin===void 0?`anonymous`:e.crossOrigin,referrerPolicy:e.referrerPolicy||`origin-when-cross-origin`,interpolate:e.interpolate,maxZoom:e.maxZoom===void 0?19:e.maxZoom,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:n,wrapX:e.wrapX,zDirection:e.zDirection})}},Rf=class extends e{map;constructor(e){super(`mapView`),this.map=e}async run(){let{leafletTarget:e,mapLon:t=`0`,mapLat:n=`0`,mapGeojson:r}=this.map.dataset,i=Number.parseFloat(t),a=Number.parseFloat(n),o=new Pl({maxZoom:16,enableRotation:!1}),s=new ed({target:e,layers:[new lf({source:new Lf({maxZoom:16})})],view:o});try{let e=new ql({source:new Ro({features:[new re({geometry:new Or(Cn([i,a]))})]}),style:new qo({image:new Ko({radius:6,fill:new zo({color:`#3050ff`})})})});s.addLayer(e)}catch(e){console.error(`Failed to create marker layer:`,e)}if(r)try{let e=new Ro({features:new md().readFeatures(JSON.parse(r),{dataProjection:`EPSG:4326`,featureProjection:`EPSG:3857`})}),t=new ql({source:e,style:new qo({stroke:new Bo({color:`#3050ff`,width:2}),fill:new zo({color:`#3050ff33`})})});s.addLayer(t);let n=e.getExtent();n&&o.fit(n,{padding:[20,20,20,20]})}catch(e){console.error(`Failed to create GeoJSON layer:`,e)}}async post(){}};export{Rf as default}; +//# sourceMappingURL=Cj4jNiaB.min.js.map \ No newline at end of file diff --git a/searx/static/themes/simple/chunk/Cj4jNiaB.min.js.map b/searx/static/themes/simple/chunk/Cj4jNiaB.min.js.map new file mode 100644 index 000000000..6f439fe2b --- /dev/null +++ b/searx/static/themes/simple/chunk/Cj4jNiaB.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Cj4jNiaB.min.js","names":["isEmpty","extend","equals","arrayEquals","Event","EventTarget","EventType","Event","ObjectEventType","isEmpty","Property","Event","CollectionEventType","EventType","createOrUpdate","Relationship","equals","extend","intersects","wrapX","add","rotate","scale","wrapX","METERS_PER_UNIT","METERS_PER_UNIT","RADIUS","EXTENT","PROJECTIONS","cache","get","add","get","fromLonLat","makeUTMTransforms","makeUTMProjection","get","getProj","METERS_PER_UNIT","equivalent","getTransformFunc","EPSG3857_PROJECTIONS","EPSG4326_PROJECTIONS","toString","fromString","scale","tmpTransform","createTransform","getProjection","linearRingss","squaredDx","squaredDistance","linearRingArea","squaredDistance","squaredDx","intersects","forEachSegment","linearRingsArea","EventType","EventTarget","EventType","TileState","TileState","forEachSegment","getCacheKey","ImageState","EventTarget","ImageState","EventType","iconImageCache","iconCache","ImageState","createTransform","intersects","equals","ImageState","all","squaredDistance","squaredDx","linearRingssArea","linearRingssCenter","createTransform","linearRingssCenter","getProjection","RBush","RBush_","equals","isEmpty","createOrUpdate","getProjection","Event","allStrategy","VectorEventType","EventType","ObjectEventType","CollectionEventType","isEmpty","equals","getIconImage","ImageState","ImageState","iconImageCache","Relationship","CanvasInstruction","equals","CanvasInstruction","CanvasInstruction","CanvasInstruction","intersects","CanvasInstruction","PolygonBuilder","Builder","ImageBuilder","LineStringBuilder","TextBuilder","createTransform","composeTransform","applyTransform","equals","CanvasInstruction","intersects","createTransform","composeTransform","isEmpty","ImageState","getIconImage","EventType","intersects","Event","ImageState","EventType","canvasPool","createTransform","equals","toTransformString","RenderEventType","composeTransform","ViewHint","canvasPool","RenderEventType","intersectsExtent","getSquaredRenderTolerance","defaultRenderOrder","wrapExtentX","equals","CanvasBuilderGroup","getRenderTolerance","colorFromString","always","isEmpty","Circle","none","ViewProperty","ViewHint","polygonFromExtent","centerNone","METERS_PER_UNIT","rotationNone","coordinatesEqual","LayerProperty","LayerProperty","EventType","intersects","RenderEventType","Property","RBush","toStyleFunction","Event","EventType","PointerEventType","EventType","MapBrowserEventType","EventType","TileState","MapEventType","EventType","equals","EventType","EventType","defaults","InteractionProperty","MapBrowserEventType","MapBrowserEventType","centroid","centroidFromPointers","Event","EventType","Key","EventType","EventType","centroidFromPointers","centroidFromPointers","Event","CollectionEventType","ObjectEventType","EventType","wrapX","iconImageCache","ObjectEventType","RenderEventType","fromString","createTransform","defaultControls","defaultInteractions","MapProperty","CollectionEventType","applyTransform","PointerEventType","EventType","ViewHint","RenderEventType","MapEventType","MapBrowserEventType","ObjectEventType","equalsExtent","equals","createOrUpdate","EventType","getProjection","equivalentProjection","getProjection","isEmpty","TileState","applyMatrix","intersects","TileState","renderReprojected","EventType","createTileCoord","equivalent","applyTransform","TileState","intersects","equals","TileProperty","createOrUpdateTileRange","createOrUpdate","createOrUpdateTileCoord","getProjection","METERS_PER_UNIT","createOrUpdate","tileCoordHash","getTileGridForProjection","scaleSize","Event","TileState","TileEventType","equivalent","getTileGridForProjection","TileState","EventType","getProjection"],"sources":["../../../../../client/simple/node_modules/ol/CollectionEventType.js","../../../../../client/simple/node_modules/ol/ObjectEventType.js","../../../../../client/simple/node_modules/ol/obj.js","../../../../../client/simple/node_modules/ol/events.js","../../../../../client/simple/node_modules/ol/events/EventType.js","../../../../../client/simple/node_modules/ol/Disposable.js","../../../../../client/simple/node_modules/ol/array.js","../../../../../client/simple/node_modules/ol/functions.js","../../../../../client/simple/node_modules/ol/events/Event.js","../../../../../client/simple/node_modules/ol/events/Target.js","../../../../../client/simple/node_modules/ol/Observable.js","../../../../../client/simple/node_modules/ol/util.js","../../../../../client/simple/node_modules/ol/Object.js","../../../../../client/simple/node_modules/ol/Collection.js","../../../../../client/simple/node_modules/ol/asserts.js","../../../../../client/simple/node_modules/ol/Feature.js","../../../../../client/simple/node_modules/ol/extent/Relationship.js","../../../../../client/simple/node_modules/ol/extent.js","../../../../../client/simple/node_modules/ol/math.js","../../../../../client/simple/node_modules/ol/sphere.js","../../../../../client/simple/node_modules/ol/console.js","../../../../../client/simple/node_modules/ol/coordinate.js","../../../../../client/simple/node_modules/ol/proj/Units.js","../../../../../client/simple/node_modules/ol/proj/Projection.js","../../../../../client/simple/node_modules/ol/proj/epsg3857.js","../../../../../client/simple/node_modules/ol/proj/epsg4326.js","../../../../../client/simple/node_modules/ol/proj/projections.js","../../../../../client/simple/node_modules/ol/proj/transforms.js","../../../../../client/simple/node_modules/ol/proj/utm.js","../../../../../client/simple/node_modules/ol/proj.js","../../../../../client/simple/node_modules/ol/transform.js","../../../../../client/simple/node_modules/ol/geom/flat/transform.js","../../../../../client/simple/node_modules/ol/geom/Geometry.js","../../../../../client/simple/node_modules/ol/geom/SimpleGeometry.js","../../../../../client/simple/node_modules/ol/geom/flat/area.js","../../../../../client/simple/node_modules/ol/geom/flat/closest.js","../../../../../client/simple/node_modules/ol/geom/flat/deflate.js","../../../../../client/simple/node_modules/ol/geom/flat/inflate.js","../../../../../client/simple/node_modules/ol/geom/flat/simplify.js","../../../../../client/simple/node_modules/ol/geom/LinearRing.js","../../../../../client/simple/node_modules/ol/geom/Point.js","../../../../../client/simple/node_modules/ol/geom/flat/contains.js","../../../../../client/simple/node_modules/ol/geom/flat/interiorpoint.js","../../../../../client/simple/node_modules/ol/geom/flat/segments.js","../../../../../client/simple/node_modules/ol/geom/flat/intersectsextent.js","../../../../../client/simple/node_modules/ol/geom/flat/reverse.js","../../../../../client/simple/node_modules/ol/geom/flat/orient.js","../../../../../client/simple/node_modules/ol/geom/Polygon.js","../../../../../client/simple/node_modules/ol/ImageState.js","../../../../../client/simple/node_modules/ol/has.js","../../../../../client/simple/node_modules/ol/Image.js","../../../../../client/simple/node_modules/ol/TileState.js","../../../../../client/simple/node_modules/ol/easing.js","../../../../../client/simple/node_modules/ol/Tile.js","../../../../../client/simple/node_modules/ol/dom.js","../../../../../client/simple/node_modules/ol/ImageTile.js","../../../../../client/simple/node_modules/ol/Kinetic.js","../../../../../client/simple/node_modules/ol/geom/flat/interpolate.js","../../../../../client/simple/node_modules/ol/geom/flat/length.js","../../../../../client/simple/node_modules/ol/geom/LineString.js","../../../../../client/simple/node_modules/ol/color.js","../../../../../client/simple/node_modules/ol/style/IconImageCache.js","../../../../../client/simple/node_modules/ol/style/IconImage.js","../../../../../client/simple/node_modules/ol/colorlike.js","../../../../../client/simple/node_modules/ol/geom/flat/lineoffset.js","../../../../../client/simple/node_modules/ol/render/VectorContext.js","../../../../../client/simple/node_modules/ol/css.js","../../../../../client/simple/node_modules/ol/render/canvas.js","../../../../../client/simple/node_modules/ol/render/canvas/Immediate.js","../../../../../client/simple/node_modules/ol/renderer/vector.js","../../../../../client/simple/node_modules/ol/render/EventType.js","../../../../../client/simple/node_modules/ol/featureloader.js","../../../../../client/simple/node_modules/ol/loadingstrategy.js","../../../../../client/simple/node_modules/ol/geom/MultiLineString.js","../../../../../client/simple/node_modules/ol/geom/MultiPoint.js","../../../../../client/simple/node_modules/ol/geom/flat/center.js","../../../../../client/simple/node_modules/ol/geom/MultiPolygon.js","../../../../../client/simple/node_modules/ol/render/Feature.js","../../../../../client/simple/node_modules/quickselect/index.js","../../../../../client/simple/node_modules/rbush/index.js","../../../../../client/simple/node_modules/ol/structs/RBush.js","../../../../../client/simple/node_modules/ol/source/Source.js","../../../../../client/simple/node_modules/ol/source/VectorEventType.js","../../../../../client/simple/node_modules/ol/source/Vector.js","../../../../../client/simple/node_modules/ol/style/Fill.js","../../../../../client/simple/node_modules/ol/style/Stroke.js","../../../../../client/simple/node_modules/ol/size.js","../../../../../client/simple/node_modules/ol/style/Image.js","../../../../../client/simple/node_modules/ol/style/RegularShape.js","../../../../../client/simple/node_modules/ol/style/Circle.js","../../../../../client/simple/node_modules/ol/style/Style.js","../../../../../client/simple/node_modules/ol/style/Text.js","../../../../../client/simple/node_modules/ol/ViewHint.js","../../../../../client/simple/node_modules/ol/render/canvas/Instruction.js","../../../../../client/simple/node_modules/ol/render/canvas/Builder.js","../../../../../client/simple/node_modules/ol/render/canvas/ImageBuilder.js","../../../../../client/simple/node_modules/ol/render/canvas/LineStringBuilder.js","../../../../../client/simple/node_modules/ol/render/canvas/PolygonBuilder.js","../../../../../client/simple/node_modules/ol/geom/flat/linechunk.js","../../../../../client/simple/node_modules/ol/geom/flat/straightchunk.js","../../../../../client/simple/node_modules/ol/render/canvas/TextBuilder.js","../../../../../client/simple/node_modules/ol/render/canvas/BuilderGroup.js","../../../../../client/simple/node_modules/ol/geom/flat/textpath.js","../../../../../client/simple/node_modules/ol/render/canvas/ZIndexContext.js","../../../../../client/simple/node_modules/ol/render/canvas/Executor.js","../../../../../client/simple/node_modules/ol/render/canvas/ExecutorGroup.js","../../../../../client/simple/node_modules/ol/style/Icon.js","../../../../../client/simple/node_modules/ol/render/canvas/hitdetect.js","../../../../../client/simple/node_modules/ol/render/Event.js","../../../../../client/simple/node_modules/ol/renderer/Layer.js","../../../../../client/simple/node_modules/ol/renderer/canvas/Layer.js","../../../../../client/simple/node_modules/ol/renderer/canvas/VectorLayer.js","../../../../../client/simple/node_modules/ol/expr/expression.js","../../../../../client/simple/node_modules/ol/expr/cpu.js","../../../../../client/simple/node_modules/ol/render/canvas/style.js","../../../../../client/simple/node_modules/ol/ViewProperty.js","../../../../../client/simple/node_modules/ol/centerconstraint.js","../../../../../client/simple/node_modules/ol/resolutionconstraint.js","../../../../../client/simple/node_modules/ol/rotationconstraint.js","../../../../../client/simple/node_modules/ol/View.js","../../../../../client/simple/node_modules/ol/layer/Property.js","../../../../../client/simple/node_modules/ol/layer/Base.js","../../../../../client/simple/node_modules/ol/layer/Layer.js","../../../../../client/simple/node_modules/ol/layer/BaseVector.js","../../../../../client/simple/node_modules/ol/layer/Vector.js","../../../../../client/simple/node_modules/ol/MapEvent.js","../../../../../client/simple/node_modules/ol/MapBrowserEvent.js","../../../../../client/simple/node_modules/ol/MapBrowserEventType.js","../../../../../client/simple/node_modules/ol/pointer/EventType.js","../../../../../client/simple/node_modules/ol/MapBrowserEventHandler.js","../../../../../client/simple/node_modules/ol/MapEventType.js","../../../../../client/simple/node_modules/ol/MapProperty.js","../../../../../client/simple/node_modules/ol/structs/PriorityQueue.js","../../../../../client/simple/node_modules/ol/TileQueue.js","../../../../../client/simple/node_modules/ol/control/Control.js","../../../../../client/simple/node_modules/ol/control/Attribution.js","../../../../../client/simple/node_modules/ol/control/Rotate.js","../../../../../client/simple/node_modules/ol/control/Zoom.js","../../../../../client/simple/node_modules/ol/control/defaults.js","../../../../../client/simple/node_modules/ol/interaction/Property.js","../../../../../client/simple/node_modules/ol/interaction/Interaction.js","../../../../../client/simple/node_modules/ol/interaction/DoubleClickZoom.js","../../../../../client/simple/node_modules/ol/events/condition.js","../../../../../client/simple/node_modules/ol/interaction/Pointer.js","../../../../../client/simple/node_modules/ol/interaction/DragPan.js","../../../../../client/simple/node_modules/ol/interaction/DragRotate.js","../../../../../client/simple/node_modules/ol/render/Box.js","../../../../../client/simple/node_modules/ol/interaction/DragBox.js","../../../../../client/simple/node_modules/ol/interaction/DragZoom.js","../../../../../client/simple/node_modules/ol/events/Key.js","../../../../../client/simple/node_modules/ol/interaction/KeyboardPan.js","../../../../../client/simple/node_modules/ol/interaction/KeyboardZoom.js","../../../../../client/simple/node_modules/ol/interaction/MouseWheelZoom.js","../../../../../client/simple/node_modules/ol/interaction/PinchRotate.js","../../../../../client/simple/node_modules/ol/interaction/PinchZoom.js","../../../../../client/simple/node_modules/ol/interaction/defaults.js","../../../../../client/simple/node_modules/ol/layer/Group.js","../../../../../client/simple/node_modules/ol/renderer/Map.js","../../../../../client/simple/node_modules/ol/renderer/Composite.js","../../../../../client/simple/node_modules/ol/Map.js","../../../../../client/simple/node_modules/ol/TileRange.js","../../../../../client/simple/node_modules/ol/geom/GeometryCollection.js","../../../../../client/simple/node_modules/ol/format/Feature.js","../../../../../client/simple/node_modules/ol/format/JSONFeature.js","../../../../../client/simple/node_modules/ol/format/GeoJSON.js","../../../../../client/simple/node_modules/ol/DataTile.js","../../../../../client/simple/node_modules/ol/reproj.js","../../../../../client/simple/node_modules/ol/reproj/Triangulation.js","../../../../../client/simple/node_modules/ol/reproj/common.js","../../../../../client/simple/node_modules/ol/reproj/Tile.js","../../../../../client/simple/node_modules/ol/structs/LRUCache.js","../../../../../client/simple/node_modules/ol/tilecoord.js","../../../../../client/simple/node_modules/ol/renderer/canvas/TileLayer.js","../../../../../client/simple/node_modules/ol/layer/TileProperty.js","../../../../../client/simple/node_modules/ol/layer/BaseTile.js","../../../../../client/simple/node_modules/ol/layer/Tile.js","../../../../../client/simple/node_modules/ol/uri.js","../../../../../client/simple/node_modules/ol/tilegrid/TileGrid.js","../../../../../client/simple/node_modules/ol/tilegrid.js","../../../../../client/simple/node_modules/ol/tileurlfunction.js","../../../../../client/simple/node_modules/ol/source/Tile.js","../../../../../client/simple/node_modules/ol/source/TileEventType.js","../../../../../client/simple/node_modules/ol/source/UrlTile.js","../../../../../client/simple/node_modules/ol/source/TileImage.js","../../../../../client/simple/node_modules/ol/source/XYZ.js","../../../../../client/simple/node_modules/ol/source/OSM.js","../../../../../client/simple/src/js/plugin/MapView.ts"],"sourcesContent":["/**\n * @module ol/CollectionEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when an item is added to the collection.\n * @event module:ol/Collection.CollectionEvent#add\n * @api\n */\n ADD: 'add',\n /**\n * Triggered when an item is removed from the collection.\n * @event module:ol/Collection.CollectionEvent#remove\n * @api\n */\n REMOVE: 'remove',\n};\n","/**\n * @module ol/ObjectEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when a property is changed.\n * @event module:ol/Object.ObjectEvent#propertychange\n * @api\n */\n PROPERTYCHANGE: 'propertychange',\n};\n\n/**\n * @typedef {'propertychange'} Types\n */\n","/**\n * @module ol/obj\n */\n\n/**\n * Removes all properties from an object.\n * @param {Object} object The object to clear.\n */\nexport function clear(object) {\n for (const property in object) {\n delete object[property];\n }\n}\n\n/**\n * Determine if an object has any properties.\n * @param {Object} object The object to check.\n * @return {boolean} The object is empty.\n */\nexport function isEmpty(object) {\n let property;\n for (property in object) {\n return false;\n }\n return !property;\n}\n","/**\n * @module ol/events\n */\nimport {clear} from './obj.js';\n\n/**\n * Key to use with {@link module:ol/Observable.unByKey}.\n * @typedef {Object} EventsKey\n * @property {ListenerFunction} listener Listener.\n * @property {import(\"./events/Target.js\").EventTargetLike} target Target.\n * @property {string} type Type.\n * @api\n */\n\n/**\n * Listener function. This function is called with an event object as argument.\n * When the function returns `false`, event propagation will stop.\n *\n * @typedef {function((Event|import(\"./events/Event.js\").default)): (void|boolean)} ListenerFunction\n * @api\n */\n\n/**\n * @typedef {Object} ListenerObject\n * @property {ListenerFunction} handleEvent HandleEvent listener function.\n */\n\n/**\n * @typedef {ListenerFunction|ListenerObject} Listener\n */\n\n/**\n * Registers an event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` to a `this` object, and returns\n * a key for use with {@link module:ol/events.unlistenByKey}.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @param {boolean} [once] If true, add the listener as one-off listener.\n * @return {EventsKey} Unique key for the listener.\n */\nexport function listen(target, type, listener, thisArg, once) {\n if (once) {\n const originalListener = listener;\n /**\n * @param {Event|import('./events/Event.js').default} event The event\n * @return {void|boolean} When the function returns `false`, event propagation will stop.\n * @this {typeof target}\n */\n listener = function (event) {\n target.removeEventListener(type, listener);\n return originalListener.call(thisArg ?? this, event);\n };\n } else if (thisArg && thisArg !== target) {\n listener = listener.bind(thisArg);\n }\n const eventsKey = {\n target: target,\n type: type,\n listener: listener,\n };\n target.addEventListener(type, listener);\n return eventsKey;\n}\n\n/**\n * Registers a one-off event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` as self-unregistering listener\n * to a `this` object, and returns a key for use with\n * {@link module:ol/events.unlistenByKey} in case the listener needs to be\n * unregistered before it is called.\n *\n * When {@link module:ol/events.listen} is called with the same arguments after this\n * function, the self-unregistering listener will be turned into a permanent\n * listener.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @return {EventsKey} Key for unlistenByKey.\n */\nexport function listenOnce(target, type, listener, thisArg) {\n return listen(target, type, listener, thisArg, true);\n}\n\n/**\n * Unregisters event listeners on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * The argument passed to this function is the key returned from\n * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.\n *\n * @param {EventsKey} key The key.\n */\nexport function unlistenByKey(key) {\n if (key && key.target) {\n key.target.removeEventListener(key.type, key.listener);\n clear(key);\n }\n}\n","/**\n * @module ol/events/EventType\n */\n\n/**\n * @enum {string}\n * @const\n */\nexport default {\n /**\n * Generic change event. Triggered when the revision counter is increased.\n * @event module:ol/events/Event~BaseEvent#change\n * @api\n */\n CHANGE: 'change',\n\n /**\n * Generic error event. Triggered when an error occurs.\n * @event module:ol/events/Event~BaseEvent#error\n * @api\n */\n ERROR: 'error',\n\n BLUR: 'blur',\n CLEAR: 'clear',\n CONTEXTMENU: 'contextmenu',\n CLICK: 'click',\n DBLCLICK: 'dblclick',\n DRAGENTER: 'dragenter',\n DRAGOVER: 'dragover',\n DROP: 'drop',\n FOCUS: 'focus',\n KEYDOWN: 'keydown',\n KEYPRESS: 'keypress',\n LOAD: 'load',\n RESIZE: 'resize',\n TOUCHMOVE: 'touchmove',\n WHEEL: 'wheel',\n};\n","/**\n * @module ol/Disposable\n */\n\n/**\n * @classdesc\n * Objects that need to clean up after themselves.\n */\nclass Disposable {\n constructor() {\n /**\n * The object has already been disposed.\n * @type {boolean}\n * @protected\n */\n this.disposed = false;\n }\n\n /**\n * Clean up.\n */\n dispose() {\n if (!this.disposed) {\n this.disposed = true;\n this.disposeInternal();\n }\n }\n\n /**\n * Extension point for disposable objects.\n * @protected\n */\n disposeInternal() {}\n}\n\nexport default Disposable;\n","/**\n * @module ol/array\n */\n\n/**\n * Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.\n * https://github.com/darkskyapp/binary-search\n *\n * @param {Array<*>} haystack Items to search through.\n * @param {*} needle The item to look for.\n * @param {Function} [comparator] Comparator function.\n * @return {number} The index of the item if found, -1 if not.\n */\nexport function binarySearch(haystack, needle, comparator) {\n let mid, cmp;\n comparator = comparator || ascending;\n let low = 0;\n let high = haystack.length;\n let found = false;\n\n while (low < high) {\n /* Note that \"(low + high) >>> 1\" may overflow, and results in a typecast\n * to double (which gives the wrong results). */\n mid = low + ((high - low) >> 1);\n cmp = +comparator(haystack[mid], needle);\n\n if (cmp < 0.0) {\n /* Too low. */\n low = mid + 1;\n } else {\n /* Key found or too high */\n high = mid;\n found = !cmp;\n }\n }\n\n /* Key not found. */\n return found ? low : ~low;\n}\n\n/**\n * Compare function sorting arrays in ascending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is less than, equal to, or greater than the second.\n */\nexport function ascending(a, b) {\n return a > b ? 1 : a < b ? -1 : 0;\n}\n\n/**\n * Compare function sorting arrays in descending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is greater than, equal to, or less than the second.\n */\nexport function descending(a, b) {\n return a < b ? 1 : a > b ? -1 : 0;\n}\n\n/**\n * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function\n * of this type to determine which nearest resolution to use.\n *\n * This function takes a `{number}` representing a value between two array entries,\n * a `{number}` representing the value of the nearest higher entry and\n * a `{number}` representing the value of the nearest lower entry\n * as arguments and returns a `{number}`. If a negative number or zero is returned\n * the lower value will be used, if a positive number is returned the higher value\n * will be used.\n * @typedef {function(number, number, number): number} NearestDirectionFunction\n * @api\n */\n\n/**\n * @param {Array} arr Array in descending order.\n * @param {number} target Target.\n * @param {number|NearestDirectionFunction} direction\n * 0 means return the nearest,\n * > 0 means return the largest nearest,\n * < 0 means return the smallest nearest.\n * @return {number} Index.\n */\nexport function linearFindNearest(arr, target, direction) {\n if (arr[0] <= target) {\n return 0;\n }\n\n const n = arr.length;\n if (target <= arr[n - 1]) {\n return n - 1;\n }\n\n if (typeof direction === 'function') {\n for (let i = 1; i < n; ++i) {\n const candidate = arr[i];\n if (candidate === target) {\n return i;\n }\n if (candidate < target) {\n if (direction(target, arr[i - 1], candidate) > 0) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n }\n\n if (direction > 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] < target) {\n return i - 1;\n }\n }\n return n - 1;\n }\n\n if (direction < 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] <= target) {\n return i;\n }\n }\n return n - 1;\n }\n\n for (let i = 1; i < n; ++i) {\n if (arr[i] == target) {\n return i;\n }\n if (arr[i] < target) {\n if (arr[i - 1] - target < target - arr[i]) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n}\n\n/**\n * @param {Array<*>} arr Array.\n * @param {number} begin Begin index.\n * @param {number} end End index.\n */\nexport function reverseSubArray(arr, begin, end) {\n while (begin < end) {\n const tmp = arr[begin];\n arr[begin] = arr[end];\n arr[end] = tmp;\n ++begin;\n --end;\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {!Array|VALUE} data The elements or arrays of elements to add to arr.\n * @template VALUE\n */\nexport function extend(arr, data) {\n const extension = Array.isArray(data) ? data : [data];\n const length = extension.length;\n for (let i = 0; i < length; i++) {\n arr[arr.length] = extension[i];\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {VALUE} obj The element to remove.\n * @template VALUE\n * @return {boolean} If the element was removed.\n */\nexport function remove(arr, obj) {\n const i = arr.indexOf(obj);\n const found = i > -1;\n if (found) {\n arr.splice(i, 1);\n }\n return found;\n}\n\n/**\n * @param {Array|Uint8ClampedArray} arr1 The first array to compare.\n * @param {Array|Uint8ClampedArray} arr2 The second array to compare.\n * @return {boolean} Whether the two arrays are equal.\n */\nexport function equals(arr1, arr2) {\n const len1 = arr1.length;\n if (len1 !== arr2.length) {\n return false;\n }\n for (let i = 0; i < len1; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sort the passed array such that the relative order of equal elements is preserved.\n * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details.\n * @param {Array<*>} arr The array to sort (modifies original).\n * @param {!function(*, *): number} compareFnc Comparison function.\n * @api\n * @deprecated\n */\nexport function stableSort(arr, compareFnc) {\n const length = arr.length;\n const tmp = Array(arr.length);\n let i;\n for (i = 0; i < length; i++) {\n tmp[i] = {index: i, value: arr[i]};\n }\n tmp.sort(function (a, b) {\n return compareFnc(a.value, b.value) || a.index - b.index;\n });\n for (i = 0; i < arr.length; i++) {\n arr[i] = tmp[i].value;\n }\n}\n\n/**\n * @param {Array<*>} arr The array to test.\n * @param {Function} [func] Comparison function.\n * @param {boolean} [strict] Strictly sorted (default false).\n * @return {boolean} Return index.\n */\nexport function isSorted(arr, func, strict) {\n const compare = func || ascending;\n return arr.every(function (currentVal, index) {\n if (index === 0) {\n return true;\n }\n const res = compare(arr[index - 1], currentVal);\n return !(res > 0 || (strict && res === 0));\n });\n}\n","/**\n * @module ol/functions\n */\n\nimport {equals as arrayEquals} from './array.js';\n\n/**\n * Always returns true.\n * @return {boolean} true.\n */\nexport function TRUE() {\n return true;\n}\n\n/**\n * Always returns false.\n * @return {boolean} false.\n */\nexport function FALSE() {\n return false;\n}\n\n/**\n * A reusable function, used e.g. as a default for callbacks.\n *\n * @return {void} Nothing.\n */\nexport function VOID() {}\n\n/**\n * Wrap a function in another function that remembers the last return. If the\n * returned function is called twice in a row with the same arguments and the same\n * this object, it will return the value from the first call in the second call.\n *\n * @param {function(...any): ReturnType} fn The function to memoize.\n * @return {function(...any): ReturnType} The memoized function.\n * @template ReturnType\n */\nexport function memoizeOne(fn) {\n /** @type {ReturnType} */\n let lastResult;\n\n /** @type {Array|undefined} */\n let lastArgs;\n\n let lastThis;\n\n /**\n * @this {*} Only need to know if `this` changed, don't care what type\n * @return {ReturnType} Memoized value\n */\n return function () {\n const nextArgs = Array.prototype.slice.call(arguments);\n if (!lastArgs || this !== lastThis || !arrayEquals(nextArgs, lastArgs)) {\n lastThis = this;\n lastArgs = nextArgs;\n lastResult = fn.apply(this, arguments);\n }\n return lastResult;\n };\n}\n\n/**\n * @template T\n * @param {function(): (T | Promise)} getter A function that returns a value or a promise for a value.\n * @return {Promise} A promise for the value.\n */\nexport function toPromise(getter) {\n function promiseGetter() {\n let value;\n try {\n value = getter();\n } catch (err) {\n return Promise.reject(err);\n }\n if (value instanceof Promise) {\n return value;\n }\n return Promise.resolve(value);\n }\n return promiseGetter();\n}\n","/**\n * @module ol/events/Event\n */\n\n/**\n * @classdesc\n * Stripped down implementation of the W3C DOM Level 2 Event interface.\n * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.\n *\n * This implementation only provides `type` and `target` properties, and\n * `stopPropagation` and `preventDefault` methods. It is meant as base class\n * for higher level events defined in the library, and works with\n * {@link module:ol/events/Target~Target}.\n */\nclass BaseEvent {\n /**\n * @param {string} type Type.\n */\n constructor(type) {\n /**\n * @type {boolean}\n */\n this.propagationStopped;\n\n /**\n * @type {boolean}\n */\n this.defaultPrevented;\n\n /**\n * The event type.\n * @type {string}\n * @api\n */\n this.type = type;\n\n /**\n * The event target.\n * @type {Object}\n * @api\n */\n this.target = null;\n }\n\n /**\n * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events\n * will be fired.\n * @api\n */\n preventDefault() {\n this.defaultPrevented = true;\n }\n\n /**\n * Stop event propagation.\n * @api\n */\n stopPropagation() {\n this.propagationStopped = true;\n }\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function stopPropagation(evt) {\n evt.stopPropagation();\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function preventDefault(evt) {\n evt.preventDefault();\n}\n\nexport default BaseEvent;\n","/**\n * @module ol/events/Target\n */\nimport Disposable from '../Disposable.js';\nimport {VOID} from '../functions.js';\nimport {clear} from '../obj.js';\nimport Event from './Event.js';\n\n/**\n * @typedef {EventTarget|Target} EventTargetLike\n */\n\n/**\n * @classdesc\n * A simplified implementation of the W3C DOM Level 2 EventTarget interface.\n * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.\n *\n * There are two important simplifications compared to the specification:\n *\n * 1. The handling of `useCapture` in `addEventListener` and\n * `removeEventListener`. There is no real capture model.\n * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.\n * There is no event target hierarchy. When a listener calls\n * `stopPropagation` or `preventDefault` on an event object, it means that no\n * more listeners after this one will be called. Same as when the listener\n * returns false.\n */\nclass Target extends Disposable {\n /**\n * @param {*} [target] Default event target for dispatched events.\n */\n constructor(target) {\n super();\n\n /**\n * @private\n * @type {*}\n */\n this.eventTarget_ = target;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.pendingRemovals_ = null;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.dispatching_ = null;\n\n /**\n * @private\n * @type {Object>|null}\n */\n this.listeners_ = null;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n addEventListener(type, listener) {\n if (!type || !listener) {\n return;\n }\n const listeners = this.listeners_ || (this.listeners_ = {});\n const listenersForType = listeners[type] || (listeners[type] = []);\n if (!listenersForType.includes(listener)) {\n listenersForType.push(listener);\n }\n }\n\n /**\n * Dispatches an event and calls all listeners listening for events\n * of this type. The event parameter can either be a string or an\n * Object with a `type` property.\n *\n * @param {import(\"./Event.js\").default|string} event Event object.\n * @return {boolean|undefined} `false` if anyone called preventDefault on the\n * event object or if any of the listeners returned false.\n * @api\n */\n dispatchEvent(event) {\n const isString = typeof event === 'string';\n const type = isString ? event : event.type;\n const listeners = this.listeners_ && this.listeners_[type];\n if (!listeners) {\n return;\n }\n\n const evt = isString ? new Event(event) : /** @type {Event} */ (event);\n if (!evt.target) {\n evt.target = this.eventTarget_ || this;\n }\n const dispatching = this.dispatching_ || (this.dispatching_ = {});\n const pendingRemovals =\n this.pendingRemovals_ || (this.pendingRemovals_ = {});\n if (!(type in dispatching)) {\n dispatching[type] = 0;\n pendingRemovals[type] = 0;\n }\n ++dispatching[type];\n let propagate;\n for (let i = 0, ii = listeners.length; i < ii; ++i) {\n if ('handleEvent' in listeners[i]) {\n propagate = /** @type {import(\"../events.js\").ListenerObject} */ (\n listeners[i]\n ).handleEvent(evt);\n } else {\n propagate = /** @type {import(\"../events.js\").ListenerFunction} */ (\n listeners[i]\n ).call(this, evt);\n }\n if (propagate === false || evt.propagationStopped) {\n propagate = false;\n break;\n }\n }\n if (--dispatching[type] === 0) {\n let pr = pendingRemovals[type];\n delete pendingRemovals[type];\n while (pr--) {\n this.removeEventListener(type, VOID);\n }\n delete dispatching[type];\n }\n return propagate;\n }\n\n /**\n * Clean up.\n * @override\n */\n disposeInternal() {\n this.listeners_ && clear(this.listeners_);\n }\n\n /**\n * Get the listeners for a specified event type. Listeners are returned in the\n * order that they will be called in.\n *\n * @param {string} type Type.\n * @return {Array|undefined} Listeners.\n */\n getListeners(type) {\n return (this.listeners_ && this.listeners_[type]) || undefined;\n }\n\n /**\n * @param {string} [type] Type. If not provided,\n * `true` will be returned if this event target has any listeners.\n * @return {boolean} Has listeners.\n */\n hasListener(type) {\n if (!this.listeners_) {\n return false;\n }\n return type\n ? type in this.listeners_\n : Object.keys(this.listeners_).length > 0;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n removeEventListener(type, listener) {\n if (!this.listeners_) {\n return;\n }\n const listeners = this.listeners_[type];\n if (!listeners) {\n return;\n }\n const index = listeners.indexOf(listener);\n if (index !== -1) {\n if (this.pendingRemovals_ && type in this.pendingRemovals_) {\n // make listener a no-op, and remove later in #dispatchEvent()\n listeners[index] = VOID;\n ++this.pendingRemovals_[type];\n } else {\n listeners.splice(index, 1);\n if (listeners.length === 0) {\n delete this.listeners_[type];\n }\n }\n }\n }\n}\n\nexport default Target;\n","/**\n * @module ol/Observable\n */\nimport {listen, listenOnce, unlistenByKey} from './events.js';\nimport EventType from './events/EventType.js';\nimport EventTarget from './events/Target.js';\n\n/***\n * @template {string} Type\n * @template {Event|import(\"./events/Event.js\").default} EventClass\n * @template Return\n * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature\n */\n\n/***\n * @template {string} Type\n * @template Return\n * @typedef {(type: Type[], listener: (event: Event|import(\"./events/Event.js\").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature\n */\n\n/**\n * @typedef {'change'|'error'} EventTypes\n */\n\n/***\n * @template Return\n * @typedef {OnSignature & CombinedOnSignature} ObservableOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * An event target providing convenient methods for listener registration\n * and unregistration. A generic `change` event is always available through\n * {@link module:ol/Observable~Observable#changed}.\n *\n * @fires import(\"./events/Event.js\").default\n * @api\n */\nclass Observable extends EventTarget {\n constructor() {\n super();\n\n this.on =\n /** @type {ObservableOnSignature} */ (\n this.onInternal\n );\n\n this.once =\n /** @type {ObservableOnSignature} */ (\n this.onceInternal\n );\n\n this.un = /** @type {ObservableOnSignature} */ (this.unInternal);\n\n /**\n * @private\n * @type {number}\n */\n this.revision_ = 0;\n }\n\n /**\n * Increases the revision counter and dispatches a 'change' event.\n * @api\n */\n changed() {\n ++this.revision_;\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * Get the version number for this object. Each time the object is modified,\n * its version number will be incremented.\n * @return {number} Revision.\n * @api\n */\n getRevision() {\n return this.revision_;\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onInternal(type, listener) {\n if (Array.isArray(type)) {\n const len = type.length;\n const keys = new Array(len);\n for (let i = 0; i < len; ++i) {\n keys[i] = listen(this, type[i], listener);\n }\n return keys;\n }\n return listen(this, /** @type {string} */ (type), listener);\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onceInternal(type, listener) {\n let key;\n if (Array.isArray(type)) {\n const len = type.length;\n key = new Array(len);\n for (let i = 0; i < len; ++i) {\n key[i] = listenOnce(this, type[i], listener);\n }\n } else {\n key = listenOnce(this, /** @type {string} */ (type), listener);\n }\n /** @type {Object} */ (listener).ol_key = key;\n return key;\n }\n\n /**\n * Unlisten for a certain type of event.\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener Listener.\n * @protected\n */\n unInternal(type, listener) {\n const key = /** @type {Object} */ (listener).ol_key;\n if (key) {\n unByKey(key);\n } else if (Array.isArray(type)) {\n for (let i = 0, ii = type.length; i < ii; ++i) {\n this.removeEventListener(type[i], listener);\n }\n } else {\n this.removeEventListener(type, listener);\n }\n }\n}\n\n/**\n * Listen for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.on;\n\n/**\n * Listen once for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.once;\n\n/**\n * Unlisten for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event.js\").default)): ?} listener The listener function.\n * @api\n */\nObservable.prototype.un;\n\n/**\n * Removes an event listener using the key returned by `on()` or `once()`.\n * @param {import(\"./events.js\").EventsKey|Array} key The key returned by `on()`\n * or `once()` (or an array of keys).\n * @api\n */\nexport function unByKey(key) {\n if (Array.isArray(key)) {\n for (let i = 0, ii = key.length; i < ii; ++i) {\n unlistenByKey(key[i]);\n }\n } else {\n unlistenByKey(/** @type {import(\"./events.js\").EventsKey} */ (key));\n }\n}\n\nexport default Observable;\n","/**\n * @module ol/util\n */\n\n/**\n * @return {never} Any return.\n */\nexport function abstract() {\n throw new Error('Unimplemented abstract method.');\n}\n\n/**\n * Counter for getUid.\n * @type {number}\n * @private\n */\nlet uidCounter_ = 0;\n\n/**\n * Gets a unique ID for an object. This mutates the object so that further calls\n * with the same object as a parameter returns the same value. Unique IDs are generated\n * as a strictly increasing sequence. Adapted from goog.getUid.\n *\n * @param {Object} obj The object to get the unique ID for.\n * @return {string} The unique ID for the object.\n * @api\n */\nexport function getUid(obj) {\n return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));\n}\n\n/**\n * OpenLayers version.\n * @type {string}\n */\nexport const VERSION = '10.9.0';\n","/**\n * @module ol/Object\n */\nimport ObjectEventType from './ObjectEventType.js';\nimport Observable from './Observable.js';\nimport Event from './events/Event.js';\nimport {isEmpty} from './obj.js';\nimport {getUid} from './util.js';\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.\n */\nexport class ObjectEvent extends Event {\n /**\n * @param {string} type The event type.\n * @param {string} key The property name.\n * @param {*} oldValue The old value for `key`.\n */\n constructor(type, key, oldValue) {\n super(type);\n\n /**\n * The name of the property whose value is changing.\n * @type {string}\n * @api\n */\n this.key = key;\n\n /**\n * The old value. To get the new value use `e.target.get(e.key)` where\n * `e` is the event object.\n * @type {*}\n * @api\n */\n this.oldValue = oldValue;\n }\n}\n\n/***\n * @template Return\n * @typedef {import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").CombinedOnSignature} ObjectOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Most non-trivial classes inherit from this.\n *\n * This extends {@link module:ol/Observable~Observable} with observable\n * properties, where each property is observable as well as the object as a\n * whole.\n *\n * Classes that inherit from this have pre-defined properties, to which you can\n * add your owns. The pre-defined properties are listed in this documentation as\n * 'Observable Properties', and have their own accessors; for example,\n * {@link module:ol/Map~Map} has a `target` property, accessed with\n * `getTarget()` and changed with `setTarget()`. Not all properties are however\n * settable. There are also general-purpose accessors `get()` and `set()`. For\n * example, `get('target')` is equivalent to `getTarget()`.\n *\n * The `set` accessors trigger a change event, and you can monitor this by\n * registering a listener. For example, {@link module:ol/View~View} has a\n * `center` property, so `view.on('change:center', function(evt) {...});` would\n * call the function whenever the value of the center property changes. Within\n * the function, `evt.target` would be the view, so `evt.target.getCenter()`\n * would return the new center.\n *\n * You can add your own observable properties with\n * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.\n * You can listen for changes on that property value with\n * `object.on('change:prop', listener)`. You can get a list of all\n * properties with {@link module:ol/Object~BaseObject#getProperties}.\n *\n * Note that the observable properties are separate from standard JS properties.\n * You can, for example, give your map object a title with\n * `map.title='New title'` and with `map.set('title', 'Another title')`. The\n * first will be a `hasOwnProperty`; the second will appear in\n * `getProperties()`. Only the second is observable.\n *\n * Properties can be deleted by using the unset method. E.g.\n * object.unset('foo').\n *\n * @fires ObjectEvent\n * @template {Object} [Properties=Object]\n * @api\n */\nclass BaseObject extends Observable {\n /**\n * @param {NoInfer} [values] An object with key-value pairs.\n */\n constructor(values) {\n super();\n\n /***\n * @type {ObjectOnSignature}\n */\n this.on;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.once;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.un;\n\n // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is\n // the same as the order in which they were created. This also helps to\n // ensure that object properties are always added in the same order, which\n // helps many JavaScript engines generate faster code.\n getUid(this);\n\n /**\n * @private\n * @type {Partial>|null}\n */\n this.values_ = null;\n\n if (values !== undefined) {\n this.setProperties(values);\n }\n }\n\n /**\n * Gets a value.\n * @param {string} key Key name.\n * @return {*} Value.\n * @api\n */\n get(key) {\n let value;\n if (this.values_ && this.values_.hasOwnProperty(key)) {\n value = this.values_[key];\n }\n return value;\n }\n\n /**\n * Get a list of object property names.\n * @return {Array} List of property names.\n * @api\n */\n getKeys() {\n return (this.values_ && Object.keys(this.values_)) || [];\n }\n\n /**\n * Get an object of all property names and values.\n * @return {NoInfer} Object.\n * @api\n */\n getProperties() {\n return /** @type {NoInfer} */ (\n (this.values_ && Object.assign({}, this.values_)) || {}\n );\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Partial>?} Object.\n */\n getPropertiesInternal() {\n return this.values_;\n }\n\n /**\n * @return {boolean} The object has properties.\n */\n hasProperties() {\n return !!this.values_;\n }\n\n /**\n * @param {string} key Key name.\n * @param {*} oldValue Old value.\n */\n notify(key, oldValue) {\n let eventType;\n eventType = `change:${key}`;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n eventType = ObjectEventType.PROPERTYCHANGE;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n addChangeListener(key, listener) {\n this.addEventListener(`change:${key}`, listener);\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n removeChangeListener(key, listener) {\n this.removeEventListener(`change:${key}`, listener);\n }\n\n /**\n * Sets a value.\n * @param {string} key Key name.\n * @param {*} value Value.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n set(key, value, silent) {\n const values = this.values_ || (this.values_ = {});\n if (silent) {\n values[key] = value;\n } else {\n const oldValue = values[key];\n values[key] = value;\n if (oldValue !== value) {\n this.notify(key, oldValue);\n }\n }\n }\n\n /**\n * Sets a collection of key-value pairs. Note that this changes any existing\n * properties and adds new ones (it does not remove any existing properties).\n * @param {Partial>} values Values.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n setProperties(values, silent) {\n for (const key in values) {\n this.set(key, values[key], silent);\n }\n }\n\n /**\n * Apply any properties from another object without triggering events.\n * @param {BaseObject} source The source object.\n * @protected\n */\n applyProperties(source) {\n if (!source.values_) {\n return;\n }\n Object.assign(this.values_ || (this.values_ = {}), source.values_);\n }\n\n /**\n * Unsets a property.\n * @param {string} key Key name.\n * @param {boolean} [silent] Unset without triggering an event.\n * @api\n */\n unset(key, silent) {\n if (this.values_ && key in this.values_) {\n const oldValue = this.values_[key];\n delete this.values_[key];\n if (isEmpty(this.values_)) {\n this.values_ = null;\n }\n if (!silent) {\n this.notify(key, oldValue);\n }\n }\n }\n}\n\nexport default BaseObject;\n","/**\n * @module ol/Collection\n */\nimport CollectionEventType from './CollectionEventType.js';\nimport BaseObject from './Object.js';\nimport Event from './events/Event.js';\n\n/**\n * @enum {string}\n * @private\n */\nconst Property = {\n LENGTH: 'length',\n};\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Collection~Collection} instances are instances of this\n * type.\n * @template T\n */\nexport class CollectionEvent extends Event {\n /**\n * @param {import(\"./CollectionEventType.js\").default} type Type.\n * @param {T} element Element.\n * @param {number} index The index of the added or removed element.\n */\n constructor(type, element, index) {\n super(type);\n\n /**\n * The element that is added to or removed from the collection.\n * @type {T}\n * @api\n */\n this.element = element;\n\n /**\n * The index of the added or removed element.\n * @type {number}\n * @api\n */\n this.index = index;\n }\n}\n\n/***\n * @template T\n * @template Return\n * @typedef {import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").OnSignature<'add'|'remove', CollectionEvent, Return> &\n * import(\"./Observable.js\").CombinedOnSignature} CollectionOnSignature\n */\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [unique=false] Disallow the same item from being added to\n * the collection twice.\n */\n\n/**\n * @classdesc\n * An expanded version of standard JS Array, adding convenience methods for\n * manipulation. Add and remove changes to the Collection trigger a Collection\n * event. Note that this does not cover changes to the objects _within_ the\n * Collection; they trigger events on the appropriate object, not on the\n * Collection as a whole.\n *\n * @fires CollectionEvent\n *\n * @template T\n * @api\n */\nclass Collection extends BaseObject {\n /**\n * @param {Array} [array] Array.\n * @param {Options} [options] Collection options.\n */\n constructor(array, options) {\n super();\n\n /***\n * @type {CollectionOnSignature}\n */\n this.on;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.once;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.un;\n\n options = options || {};\n\n /**\n * @private\n * @type {boolean}\n */\n this.unique_ = !!options.unique;\n\n /**\n * @private\n * @type {!Array}\n */\n this.array_ = array ?? [];\n\n if (this.unique_) {\n for (let i = 1, ii = this.array_.length; i < ii; ++i) {\n this.assertUnique_(this.array_[i], i);\n }\n }\n\n this.updateLength_();\n }\n\n /**\n * Remove all elements from the collection.\n * @api\n */\n clear() {\n while (this.getLength() > 0) {\n this.pop();\n }\n }\n\n /**\n * Add elements to the collection. This pushes each item in the provided array\n * to the end of the collection.\n * @param {!Array} arr Array.\n * @return {Collection} This collection.\n * @api\n */\n extend(arr) {\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n this.push(arr[i]);\n }\n return this;\n }\n\n /**\n * Iterate over each element, calling the provided callback.\n * @param {function(T, number, Array): *} f The function to call\n * for every element. This function takes 3 arguments (the element, the\n * index and the array). The return value is ignored.\n * @api\n */\n forEach(f) {\n const array = this.array_;\n for (let i = 0, ii = array.length; i < ii; ++i) {\n f(array[i], i, array);\n }\n }\n\n /**\n * Get a reference to the underlying Array object. Warning: if the array\n * is mutated, no events will be dispatched by the collection, and the\n * collection's \"length\" property won't be in sync with the actual length\n * of the array.\n * @return {!Array} Array.\n * @api\n */\n getArray() {\n return this.array_;\n }\n\n /**\n * Get the element at the provided index.\n * @param {number} index Index.\n * @return {T} Element.\n * @api\n */\n item(index) {\n return this.array_[index];\n }\n\n /**\n * Get the length of this collection.\n * @return {number} The length of the array.\n * @observable\n * @api\n */\n getLength() {\n return this.get(Property.LENGTH);\n }\n\n /**\n * Insert an element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n insertAt(index, elem) {\n if (index < 0 || index > this.getLength()) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem);\n }\n this.array_.splice(index, 0, elem);\n this.updateLength_();\n this.dispatchEvent(\n new CollectionEvent(CollectionEventType.ADD, elem, index),\n );\n }\n\n /**\n * Remove the last element of the collection and return it.\n * Return `undefined` if the collection is empty.\n * @return {T|undefined} Element.\n * @api\n */\n pop() {\n return this.removeAt(this.getLength() - 1);\n }\n\n /**\n * Insert the provided element at the end of the collection.\n * @param {T} elem Element.\n * @return {number} New length of the collection.\n * @api\n */\n push(elem) {\n const n = this.getLength();\n this.insertAt(n, elem);\n return this.getLength();\n }\n\n /**\n * Remove the first occurrence of an element from the collection.\n * @param {T} elem Element.\n * @return {T|undefined} The removed element or undefined if none found.\n * @api\n */\n remove(elem) {\n const arr = this.array_;\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n if (arr[i] === elem) {\n return this.removeAt(i);\n }\n }\n return undefined;\n }\n\n /**\n * Remove the element at the provided index and return it.\n * Return `undefined` if the collection does not contain this index.\n * @param {number} index Index.\n * @return {T|undefined} Value.\n * @api\n */\n removeAt(index) {\n if (index < 0 || index >= this.getLength()) {\n return undefined;\n }\n const prev = this.array_[index];\n this.array_.splice(index, 1);\n this.updateLength_();\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n return prev;\n }\n\n /**\n * Set the element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n setAt(index, elem) {\n const n = this.getLength();\n if (index >= n) {\n this.insertAt(index, elem);\n return;\n }\n if (index < 0) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem, index);\n }\n const prev = this.array_[index];\n this.array_[index] = elem;\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.ADD, elem, index)\n ),\n );\n }\n\n /**\n * @private\n */\n updateLength_() {\n this.set(Property.LENGTH, this.array_.length);\n }\n\n /**\n * @private\n * @param {T} elem Element.\n * @param {number} [except] Optional index to ignore.\n */\n assertUnique_(elem, except) {\n const array = this.array_;\n for (let i = 0, ii = array.length; i < ii; ++i) {\n if (array[i] === elem && i !== except) {\n throw new Error('Duplicate item added to a unique collection');\n }\n }\n }\n}\n\nexport default Collection;\n","/**\n * @module ol/asserts\n */\n\n/**\n * @param {*} assertion Assertion we expected to be truthy.\n * @param {string} errorMessage Error message.\n */\nexport function assert(assertion, errorMessage) {\n if (!assertion) {\n throw new Error(errorMessage);\n }\n}\n","/**\n * @module ol/Feature\n */\nimport BaseObject from './Object.js';\nimport {assert} from './asserts.js';\nimport {listen, unlistenByKey} from './events.js';\nimport EventType from './events/EventType.js';\n\n/**\n * @typedef {typeof Feature|typeof import(\"./render/Feature.js\").default} FeatureClass\n */\n\n/**\n * @typedef {Feature|import(\"./render/Feature.js\").default} FeatureLike\n */\n\n/***\n * @template Return\n * @typedef {import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").OnSignature &\n * import(\"./Observable.js\").CombinedOnSignature} FeatureOnSignature\n */\n\n/***\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n * @template {Object} [Properties=Object]\n * @typedef {Properties & { geometry?: Geometry }} ObjectWithGeometry\n */\n\n/**\n * @classdesc\n * A vector object for geographic features with a geometry and other\n * attribute properties, similar to the features in vector file formats like\n * GeoJSON.\n *\n * Features can be styled individually with `setStyle`; otherwise they use the\n * style of their vector layer.\n *\n * Note that attribute properties are set as {@link module:ol/Object~BaseObject} properties on\n * the feature object, so they are observable, and have get/set accessors.\n *\n * Typically, a feature has a single geometry property. You can set the\n * geometry using the `setGeometry` method and get it with `getGeometry`.\n * It is possible to store more than one geometry on a feature using attribute\n * properties. By default, the geometry used for rendering is identified by\n * the property name `geometry`. If you want to use another geometry property\n * for rendering, use the `setGeometryName` method to change the attribute\n * property associated with the geometry for the feature. For example:\n *\n * ```js\n *\n * import Feature from 'ol/Feature.js';\n * import Polygon from 'ol/geom/Polygon.js';\n * import Point from 'ol/geom/Point.js';\n *\n * const feature = new Feature({\n * geometry: new Polygon(polyCoords),\n * labelPoint: new Point(labelCoords),\n * name: 'My Polygon',\n * });\n *\n * // get the polygon geometry\n * const poly = feature.getGeometry();\n *\n * // Render the feature as a point using the coordinates from labelPoint\n * feature.setGeometryName('labelPoint');\n *\n * // get the point geometry\n * const point = feature.getGeometry();\n * ```\n *\n * @api\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n * @template {Object} [Properties=Object]\n * @extends {BaseObject>}\n */\nclass Feature extends BaseObject {\n /**\n * @param {Geometry|ObjectWithGeometry>} [geometryOrProperties]\n * You may pass a Geometry object directly, or an object literal containing\n * properties. If you pass an object literal, you may include a Geometry\n * associated with a `geometry` key.\n */\n constructor(geometryOrProperties) {\n super();\n\n /***\n * @type {FeatureOnSignature}\n */\n this.on;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.once;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.un;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = undefined;\n\n /**\n * @type {string}\n * @private\n */\n this.geometryName_ = 'geometry';\n\n /**\n * User provided style.\n * @private\n * @type {import(\"./style/Style.js\").StyleLike}\n */\n this.style_ = null;\n\n /**\n * @private\n * @type {import(\"./style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction_ = undefined;\n\n /**\n * @private\n * @type {?import(\"./events.js\").EventsKey}\n */\n this.geometryChangeKey_ = null;\n\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n\n if (geometryOrProperties) {\n if (\n typeof (\n /** @type {?} */ (geometryOrProperties).getSimplifiedGeometry\n ) === 'function'\n ) {\n const geometry = /** @type {Geometry} */ (geometryOrProperties);\n this.setGeometry(geometry);\n } else {\n /** @type {?} */\n const properties = geometryOrProperties;\n this.setProperties(properties);\n }\n }\n }\n\n /**\n * Clone this feature. If the original feature has a geometry it\n * is also cloned. The feature id is not set in the clone.\n * @return {Feature} The clone.\n * @api\n */\n clone() {\n const clone = /** @type {Feature} */ (new Feature());\n const geometryName = this.geometryName_;\n clone.setGeometryName(geometryName);\n\n const properties = this.getPropertiesInternal();\n if (properties) {\n const geometry = this.getGeometry();\n for (const key in properties) {\n if (key === geometryName && geometry) {\n clone.set(key, geometry.clone());\n } else {\n clone.set(key, properties[key], true);\n }\n }\n }\n\n const style = this.getStyle();\n if (style) {\n clone.setStyle(style);\n }\n return clone;\n }\n\n /**\n * Get the feature's default geometry. A feature may have any number of named\n * geometries. The \"default\" geometry (the one that is rendered by default) is\n * set when calling {@link module:ol/Feature~Feature#setGeometry}.\n * @return {Geometry|undefined} The default geometry for the feature.\n * @api\n * @observable\n */\n getGeometry() {\n return /** @type {Geometry|undefined} */ (this.get(this.geometryName_));\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is either set when reading data from a remote source or set explicitly by\n * calling {@link module:ol/Feature~Feature#setId}.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * Get the name of the feature's default geometry. By default, the default\n * geometry is named `geometry`.\n * @return {string} Get the property name associated with the default geometry\n * for this feature.\n * @api\n */\n getGeometryName() {\n return this.geometryName_;\n }\n\n /**\n * Get the feature's style. Will return what was provided to the\n * {@link module:ol/Feature~Feature#setStyle} method.\n * @return {import(\"./style/Style.js\").StyleLike|undefined} The feature style.\n * @api\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * Get the feature's style function.\n * @return {import(\"./style/Style.js\").StyleFunction|undefined} Return a function\n * representing the current style of this feature.\n * @api\n */\n getStyleFunction() {\n return this.styleFunction_;\n }\n\n /**\n * @private\n */\n handleGeometryChange_() {\n this.changed();\n }\n\n /**\n * @private\n */\n handleGeometryChanged_() {\n if (this.geometryChangeKey_) {\n unlistenByKey(this.geometryChangeKey_);\n this.geometryChangeKey_ = null;\n }\n const geometry = this.getGeometry();\n if (geometry) {\n this.geometryChangeKey_ = listen(\n geometry,\n EventType.CHANGE,\n this.handleGeometryChange_,\n this,\n );\n }\n this.changed();\n }\n\n /**\n * Set the default geometry for the feature. This will update the property\n * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.\n * @param {Geometry|undefined} geometry The new geometry.\n * @api\n * @observable\n */\n setGeometry(geometry) {\n this.set(this.geometryName_, geometry);\n }\n\n /**\n * Set the style for the feature to override the layer style. This can be a\n * single style object, an array of styles, or a function that takes a\n * resolution and returns an array of styles. To unset the feature style, call\n * `setStyle()` without arguments or a falsey value.\n * @param {import(\"./style/Style.js\").StyleLike} [style] Style for this feature.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setStyle(style) {\n this.style_ = style;\n this.styleFunction_ = !style ? undefined : createStyleFunction(style);\n this.changed();\n }\n\n /**\n * Set the feature id. The feature id is considered stable and may be used when\n * requesting features or comparing identifiers returned from a remote source.\n * The feature id can be used with the\n * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.\n * @param {number|string|undefined} id The feature id.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setId(id) {\n this.id_ = id;\n this.changed();\n }\n\n /**\n * Set the property name to be used when getting the feature's default geometry.\n * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with\n * this name will be returned.\n * @param {string} name The property name of the default geometry.\n * @api\n */\n setGeometryName(name) {\n if (name === this.geometryName_) {\n return;\n }\n this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.geometryName_ = name;\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.handleGeometryChanged_();\n }\n}\n\n/**\n * Convert the provided object into a feature style function. Functions passed\n * through unchanged. Arrays of Style or single style objects wrapped\n * in a new feature style function.\n * @param {!import(\"./style/Style.js\").StyleFunction|!Array|!import(\"./style/Style.js\").default} obj\n * A feature style function, a single style, or an array of styles.\n * @return {import(\"./style/Style.js\").StyleFunction} A style function.\n */\nexport function createStyleFunction(obj) {\n if (typeof obj === 'function') {\n return obj;\n }\n /**\n * @type {Array}\n */\n let styles;\n if (Array.isArray(obj)) {\n styles = obj;\n } else {\n assert(\n typeof (/** @type {?} */ (obj).getZIndex) === 'function',\n 'Expected an `ol/style/Style` or an array of `ol/style/Style.js`',\n );\n const style = /** @type {import(\"./style/Style.js\").default} */ (obj);\n styles = [style];\n }\n return function () {\n return styles;\n };\n}\nexport default Feature;\n","/**\n * @module ol/extent/Relationship\n */\n\n/**\n * Relationship to an extent.\n * @enum {number}\n */\nexport default {\n UNKNOWN: 0,\n INTERSECTING: 1,\n ABOVE: 2,\n RIGHT: 4,\n BELOW: 8,\n LEFT: 16,\n};\n","/**\n * @module ol/extent\n */\nimport Relationship from './extent/Relationship.js';\n\n/**\n * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`.\n * @typedef {Array} Extent\n * @api\n */\n\n/**\n * Extent corner.\n * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner\n */\n\n/**\n * Build an extent that includes all given coordinates.\n *\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Bounding extent.\n * @api\n */\nexport function boundingExtent(coordinates) {\n const extent = createEmpty();\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Array} xs Xs.\n * @param {Array} ys Ys.\n * @param {Extent} [dest] Destination extent.\n * @private\n * @return {Extent} Extent.\n */\nfunction _boundingExtentXYs(xs, ys, dest) {\n const minX = Math.min.apply(null, xs);\n const minY = Math.min.apply(null, ys);\n const maxX = Math.max.apply(null, xs);\n const maxY = Math.max.apply(null, ys);\n return createOrUpdate(minX, minY, maxX, maxY, dest);\n}\n\n/**\n * Return extent increased by the provided value.\n * @param {Extent} extent Extent.\n * @param {number} value The amount by which the extent should be buffered.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n * @api\n */\nexport function buffer(extent, value, dest) {\n if (dest) {\n dest[0] = extent[0] - value;\n dest[1] = extent[1] - value;\n dest[2] = extent[2] + value;\n dest[3] = extent[3] + value;\n return dest;\n }\n return [\n extent[0] - value,\n extent[1] - value,\n extent[2] + value,\n extent[3] + value,\n ];\n}\n\n/**\n * Creates a clone of an extent.\n *\n * @param {Extent} extent Extent to clone.\n * @param {Extent} [dest] Extent.\n * @return {Extent} The clone.\n */\nexport function clone(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent.slice();\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {number} Closest squared distance.\n */\nexport function closestSquaredDistanceXY(extent, x, y) {\n let dx, dy;\n if (x < extent[0]) {\n dx = extent[0] - x;\n } else if (extent[2] < x) {\n dx = x - extent[2];\n } else {\n dx = 0;\n }\n if (y < extent[1]) {\n dy = extent[1] - y;\n } else if (extent[3] < y) {\n dy = y - extent[3];\n } else {\n dy = 0;\n }\n return dx * dx + dy * dy;\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} The coordinate is contained in the extent.\n * @api\n */\nexport function containsCoordinate(extent, coordinate) {\n return containsXY(extent, coordinate[0], coordinate[1]);\n}\n\n/**\n * Check if one extent contains another.\n *\n * An extent is deemed contained if it lies completely within the other extent,\n * including if they share one or more edges.\n *\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The second extent is contained by or on the edge of the\n * first.\n * @api\n */\nexport function containsExtent(extent1, extent2) {\n return (\n extent1[0] <= extent2[0] &&\n extent2[2] <= extent1[2] &&\n extent1[1] <= extent2[1] &&\n extent2[3] <= extent1[3]\n );\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {number} x X coordinate.\n * @param {number} y Y coordinate.\n * @return {boolean} The x, y values are contained in the extent.\n * @api\n */\nexport function containsXY(extent, x, y) {\n return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];\n}\n\n/**\n * Get the relationship between a coordinate and extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate The coordinate.\n * @return {import(\"./extent/Relationship.js\").default} The relationship (bitwise compare with\n * import(\"./extent/Relationship.js\").Relationship).\n */\nexport function coordinateRelationship(extent, coordinate) {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const x = coordinate[0];\n const y = coordinate[1];\n let relationship = Relationship.UNKNOWN;\n if (x < minX) {\n relationship = relationship | Relationship.LEFT;\n } else if (x > maxX) {\n relationship = relationship | Relationship.RIGHT;\n }\n if (y < minY) {\n relationship = relationship | Relationship.BELOW;\n } else if (y > maxY) {\n relationship = relationship | Relationship.ABOVE;\n }\n if (relationship === Relationship.UNKNOWN) {\n relationship = Relationship.INTERSECTING;\n }\n return relationship;\n}\n\n/**\n * Create an empty extent.\n * @return {Extent} Empty extent.\n * @api\n */\nexport function createEmpty() {\n return [Infinity, Infinity, -Infinity, -Infinity];\n}\n\n/**\n * Create a new extent or update the provided extent.\n * @param {number} minX Minimum X.\n * @param {number} minY Minimum Y.\n * @param {number} maxX Maximum X.\n * @param {number} maxY Maximum Y.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdate(minX, minY, maxX, maxY, dest) {\n if (dest) {\n dest[0] = minX;\n dest[1] = minY;\n dest[2] = maxX;\n dest[3] = maxY;\n return dest;\n }\n return [minX, minY, maxX, maxY];\n}\n\n/**\n * Create a new empty extent or make the provided one empty.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateEmpty(dest) {\n return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, dest);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinate(coordinate, dest) {\n const x = coordinate[0];\n const y = coordinate[1];\n return createOrUpdate(x, y, x, y, dest);\n}\n\n/**\n * @param {Array} coordinates Coordinates.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinates(coordinates, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendCoordinates(extent, coordinates);\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n dest,\n) {\n const extent = createOrUpdateEmpty(dest);\n return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);\n}\n\n/**\n * @param {Array>} rings Rings.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromRings(rings, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendRings(extent, rings);\n}\n\n/**\n * Determine if two extents are equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The two extents are equivalent.\n * @api\n */\nexport function equals(extent1, extent2) {\n return (\n extent1[0] == extent2[0] &&\n extent1[2] == extent2[2] &&\n extent1[1] == extent2[1] &&\n extent1[3] == extent2[3]\n );\n}\n\n/**\n * Determine if two extents are approximately equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {number} tolerance Tolerance in extent coordinate units.\n * @return {boolean} The two extents differ by less than the tolerance.\n */\nexport function approximatelyEquals(extent1, extent2, tolerance) {\n return (\n Math.abs(extent1[0] - extent2[0]) < tolerance &&\n Math.abs(extent1[2] - extent2[2]) < tolerance &&\n Math.abs(extent1[1] - extent2[1]) < tolerance &&\n Math.abs(extent1[3] - extent2[3]) < tolerance\n );\n}\n\n/**\n * Modify an extent to include another extent.\n * @param {Extent} extent1 The extent to be modified.\n * @param {Extent} extent2 The extent that will be included in the first.\n * @return {Extent} A reference to the first (extended) extent.\n * @api\n */\nexport function extend(extent1, extent2) {\n if (extent2[0] < extent1[0]) {\n extent1[0] = extent2[0];\n }\n if (extent2[2] > extent1[2]) {\n extent1[2] = extent2[2];\n }\n if (extent2[1] < extent1[1]) {\n extent1[1] = extent2[1];\n }\n if (extent2[3] > extent1[3]) {\n extent1[3] = extent2[3];\n }\n return extent1;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n */\nexport function extendCoordinate(extent, coordinate) {\n if (coordinate[0] < extent[0]) {\n extent[0] = coordinate[0];\n }\n if (coordinate[0] > extent[2]) {\n extent[2] = coordinate[0];\n }\n if (coordinate[1] < extent[1]) {\n extent[1] = coordinate[1];\n }\n if (coordinate[1] > extent[3]) {\n extent[3] = coordinate[1];\n }\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Extent.\n */\nexport function extendCoordinates(extent, coordinates) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {Extent} Extent.\n */\nexport function extendFlatCoordinates(\n extent,\n flatCoordinates,\n offset,\n end,\n stride,\n) {\n for (; offset < end; offset += stride) {\n extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array>} rings Rings.\n * @return {Extent} Extent.\n */\nexport function extendRings(extent, rings) {\n for (let i = 0, ii = rings.length; i < ii; ++i) {\n extendCoordinates(extent, rings[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n */\nexport function extendXY(extent, x, y) {\n extent[0] = Math.min(extent[0], x);\n extent[1] = Math.min(extent[1], y);\n extent[2] = Math.max(extent[2], x);\n extent[3] = Math.max(extent[3], y);\n}\n\n/**\n * This function calls `callback` for each corner of the extent. If the\n * callback returns a truthy value the function returns that value\n * immediately. Otherwise the function returns `false`.\n * @param {Extent} extent Extent.\n * @param {function(import(\"./coordinate.js\").Coordinate): S} callback Callback.\n * @return {S|boolean} Value.\n * @template S\n */\nexport function forEachCorner(extent, callback) {\n let val;\n val = callback(getBottomLeft(extent));\n if (val) {\n return val;\n }\n val = callback(getBottomRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopLeft(extent));\n if (val) {\n return val;\n }\n return false;\n}\n\n/**\n * Get the size of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Area.\n * @api\n */\nexport function getArea(extent) {\n let area = 0;\n if (!isEmpty(extent)) {\n area = getWidth(extent) * getHeight(extent);\n }\n return area;\n}\n\n/**\n * Get the bottom left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom left coordinate.\n * @api\n */\nexport function getBottomLeft(extent) {\n return [extent[0], extent[1]];\n}\n\n/**\n * Get the bottom right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom right coordinate.\n * @api\n */\nexport function getBottomRight(extent) {\n return [extent[2], extent[1]];\n}\n\n/**\n * Get the center coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Center.\n * @api\n */\nexport function getCenter(extent) {\n return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];\n}\n\n/**\n * Get a corner coordinate of an extent.\n * @param {Extent} extent Extent.\n * @param {Corner} corner Corner.\n * @return {import(\"./coordinate.js\").Coordinate} Corner coordinate.\n */\nexport function getCorner(extent, corner) {\n let coordinate;\n if (corner === 'bottom-left') {\n coordinate = getBottomLeft(extent);\n } else if (corner === 'bottom-right') {\n coordinate = getBottomRight(extent);\n } else if (corner === 'top-left') {\n coordinate = getTopLeft(extent);\n } else if (corner === 'top-right') {\n coordinate = getTopRight(extent);\n } else {\n throw new Error('Invalid corner');\n }\n return coordinate;\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Enlarged area.\n */\nexport function getEnlargedArea(extent1, extent2) {\n const minX = Math.min(extent1[0], extent2[0]);\n const minY = Math.min(extent1[1], extent2[1]);\n const maxX = Math.max(extent1[2], extent2[2]);\n const maxY = Math.max(extent1[3], extent2[3]);\n return (maxX - minX) * (maxY - minY);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function getForViewAndSize(center, resolution, rotation, size, dest) {\n const [x0, y0, x1, y1, x2, y2, x3, y3] = getRotatedViewport(\n center,\n resolution,\n rotation,\n size,\n );\n return createOrUpdate(\n Math.min(x0, x1, x2, x3),\n Math.min(y0, y1, y2, y3),\n Math.max(x0, x1, x2, x3),\n Math.max(y0, y1, y2, y3),\n dest,\n );\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @return {Array} Linear ring representing the viewport.\n */\nexport function getRotatedViewport(center, resolution, rotation, size) {\n const dx = (resolution * size[0]) / 2;\n const dy = (resolution * size[1]) / 2;\n const cosRotation = Math.cos(rotation);\n const sinRotation = Math.sin(rotation);\n const xCos = dx * cosRotation;\n const xSin = dx * sinRotation;\n const yCos = dy * cosRotation;\n const ySin = dy * sinRotation;\n const x = center[0];\n const y = center[1];\n return [\n x - xCos + ySin,\n y - xSin - yCos,\n x - xCos - ySin,\n y - xSin + yCos,\n x + xCos - ySin,\n y + xSin + yCos,\n x + xCos + ySin,\n y + xSin - yCos,\n x - xCos + ySin,\n y - xSin - yCos,\n ];\n}\n\n/**\n * Get the height of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Height.\n * @api\n */\nexport function getHeight(extent) {\n return extent[3] - extent[1];\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Intersection area.\n */\nexport function getIntersectionArea(extent1, extent2) {\n const intersection = getIntersection(extent1, extent2);\n return getArea(intersection);\n}\n\n/**\n * Get the intersection of two extents.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {Extent} [dest] Optional extent to populate with intersection.\n * @return {Extent} Intersecting extent.\n * @api\n */\nexport function getIntersection(extent1, extent2, dest) {\n const intersection = dest ? dest : createEmpty();\n if (intersects(extent1, extent2)) {\n if (extent1[0] > extent2[0]) {\n intersection[0] = extent1[0];\n } else {\n intersection[0] = extent2[0];\n }\n if (extent1[1] > extent2[1]) {\n intersection[1] = extent1[1];\n } else {\n intersection[1] = extent2[1];\n }\n if (extent1[2] < extent2[2]) {\n intersection[2] = extent1[2];\n } else {\n intersection[2] = extent2[2];\n }\n if (extent1[3] < extent2[3]) {\n intersection[3] = extent1[3];\n } else {\n intersection[3] = extent2[3];\n }\n } else {\n createOrUpdateEmpty(intersection);\n }\n return intersection;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @return {number} Margin.\n */\nexport function getMargin(extent) {\n return getWidth(extent) + getHeight(extent);\n}\n\n/**\n * Get the size (width, height) of an extent.\n * @param {Extent} extent The extent.\n * @return {import(\"./size.js\").Size} The extent size.\n * @api\n */\nexport function getSize(extent) {\n return [extent[2] - extent[0], extent[3] - extent[1]];\n}\n\n/**\n * Get the top left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top left coordinate.\n * @api\n */\nexport function getTopLeft(extent) {\n return [extent[0], extent[3]];\n}\n\n/**\n * Get the top right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top right coordinate.\n * @api\n */\nexport function getTopRight(extent) {\n return [extent[2], extent[3]];\n}\n\n/**\n * Get the width of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Width.\n * @api\n */\nexport function getWidth(extent) {\n return extent[2] - extent[0];\n}\n\n/**\n * Determine if one extent intersects another.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent.\n * @return {boolean} The two extents intersect.\n * @api\n */\nexport function intersects(extent1, extent2) {\n return (\n extent1[0] <= extent2[2] &&\n extent1[2] >= extent2[0] &&\n extent1[1] <= extent2[3] &&\n extent1[3] >= extent2[1]\n );\n}\n\n/**\n * Determine if an extent is empty.\n * @param {Extent} extent Extent.\n * @return {boolean} Is empty.\n * @api\n */\nexport function isEmpty(extent) {\n return extent[2] < extent[0] || extent[3] < extent[1];\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function returnOrUpdate(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} value Value.\n */\nexport function scaleFromCenter(extent, value) {\n const deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);\n const deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);\n extent[0] -= deltaX;\n extent[2] += deltaX;\n extent[1] -= deltaY;\n extent[3] += deltaY;\n}\n\n/**\n * Determine if the segment between two coordinates intersects (crosses,\n * touches, or is contained by) the provided extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} start Segment start coordinate.\n * @param {import(\"./coordinate.js\").Coordinate} end Segment end coordinate.\n * @return {boolean} The segment intersects the extent.\n */\nexport function intersectsSegment(extent, start, end) {\n let intersects = false;\n const startRel = coordinateRelationship(extent, start);\n const endRel = coordinateRelationship(extent, end);\n if (\n startRel === Relationship.INTERSECTING ||\n endRel === Relationship.INTERSECTING\n ) {\n intersects = true;\n } else {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const startX = start[0];\n const startY = start[1];\n const endX = end[0];\n const endY = end[1];\n const slope = (endY - startY) / (endX - startX);\n let x, y;\n if (!!(endRel & Relationship.ABOVE) && !(startRel & Relationship.ABOVE)) {\n // potentially intersects top\n x = endX - (endY - maxY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.RIGHT) &&\n !(startRel & Relationship.RIGHT)\n ) {\n // potentially intersects right\n y = endY - (endX - maxX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.BELOW) &&\n !(startRel & Relationship.BELOW)\n ) {\n // potentially intersects bottom\n x = endX - (endY - minY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.LEFT) &&\n !(startRel & Relationship.LEFT)\n ) {\n // potentially intersects left\n y = endY - (endX - minX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n }\n return intersects;\n}\n\n/**\n * Apply a transform function to the extent.\n * @param {Extent} extent Extent.\n * @param {import(\"./proj.js\").TransformFunction} transformFn Transform function.\n * Called with `[minX, minY, maxX, maxY]` extent coordinates.\n * @param {Extent} [dest] Destination extent.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {Extent} Extent.\n * @api\n */\nexport function applyTransform(extent, transformFn, dest, stops) {\n if (isEmpty(extent)) {\n return createOrUpdateEmpty(dest);\n }\n let coordinates = [];\n if (stops > 1) {\n const width = extent[2] - extent[0];\n const height = extent[3] - extent[1];\n for (let i = 0; i < stops; ++i) {\n coordinates.push(\n extent[0] + (width * i) / stops,\n extent[1],\n extent[2],\n extent[1] + (height * i) / stops,\n extent[2] - (width * i) / stops,\n extent[3],\n extent[0],\n extent[3] - (height * i) / stops,\n );\n }\n } else {\n coordinates = [\n extent[0],\n extent[1],\n extent[2],\n extent[1],\n extent[2],\n extent[3],\n extent[0],\n extent[3],\n ];\n }\n transformFn(coordinates, coordinates, 2);\n const xs = [];\n const ys = [];\n for (let i = 0, l = coordinates.length; i < l; i += 2) {\n xs.push(coordinates[i]);\n ys.push(coordinates[i + 1]);\n }\n return _boundingExtentXYs(xs, ys, dest);\n}\n\n/**\n * Modifies the provided extent in-place to be within the real world\n * extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Extent} The extent within the real world extent.\n */\nexport function wrapX(extent, projection) {\n const projectionExtent = projection.getExtent();\n const center = getCenter(extent);\n if (\n projection.canWrapX() &&\n (center[0] < projectionExtent[0] || center[0] >= projectionExtent[2])\n ) {\n const worldWidth = getWidth(projectionExtent);\n const worldsAway = Math.floor(\n (center[0] - projectionExtent[0]) / worldWidth,\n );\n const offset = worldsAway * worldWidth;\n extent[0] -= offset;\n extent[2] -= offset;\n }\n return extent;\n}\n\n/**\n * Fits the extent to the real world\n *\n * If the extent does not cross the anti meridian, this will return the extent in an array\n * If the extent crosses the anti meridian, the extent will be sliced, so each part fits within the\n * real world\n *\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @param {boolean} [multiWorld] Return all worlds\n * @return {Array} The extent within the real world extent.\n */\nexport function wrapAndSliceX(extent, projection, multiWorld) {\n if (projection.canWrapX()) {\n const projectionExtent = projection.getExtent();\n\n if (!isFinite(extent[0]) || !isFinite(extent[2])) {\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n\n wrapX(extent, projection);\n const worldWidth = getWidth(projectionExtent);\n\n if (getWidth(extent) > worldWidth && !multiWorld) {\n // the extent wraps around on itself\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n if (extent[0] < projectionExtent[0]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2], extent[3]],\n ];\n }\n if (extent[2] > projectionExtent[2]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0], extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2] - worldWidth, extent[3]],\n ];\n }\n }\n\n return [extent];\n}\n","/**\n * @module ol/math\n */\n\n/**\n * Takes a number and clamps it to within the provided bounds.\n * @param {number} value The input number.\n * @param {number} min The minimum value to return.\n * @param {number} max The maximum value to return.\n * @return {number} The input number if it is within bounds, or the nearest\n * number within the bounds.\n */\nexport function clamp(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns the square of the closest distance between the point (x, y) and the\n * line segment (x1, y1) to (x2, y2).\n * @param {number} x X.\n * @param {number} y Y.\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredSegmentDistance(x, y, x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n if (dx !== 0 || dy !== 0) {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x1 = x2;\n y1 = y2;\n } else if (t > 0) {\n x1 += dx * t;\n y1 += dy * t;\n }\n }\n return squaredDistance(x, y, x1, y1);\n}\n\n/**\n * Returns the square of the distance between the points (x1, y1) and (x2, y2).\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredDistance(x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n return dx * dx + dy * dy;\n}\n\n/**\n * Solves system of linear equations using Gaussian elimination method.\n *\n * @param {Array>} mat Augmented matrix (n x n + 1 column)\n * in row-major order.\n * @return {Array|null} The resulting vector.\n */\nexport function solveLinearSystem(mat) {\n const n = mat.length;\n\n for (let i = 0; i < n; i++) {\n // Find max in the i-th column (ignoring i - 1 first rows)\n let maxRow = i;\n let maxEl = Math.abs(mat[i][i]);\n for (let r = i + 1; r < n; r++) {\n const absValue = Math.abs(mat[r][i]);\n if (absValue > maxEl) {\n maxEl = absValue;\n maxRow = r;\n }\n }\n\n if (maxEl === 0) {\n return null; // matrix is singular\n }\n\n // Swap max row with i-th (current) row\n const tmp = mat[maxRow];\n mat[maxRow] = mat[i];\n mat[i] = tmp;\n\n // Subtract the i-th row to make all the remaining rows 0 in the i-th column\n for (let j = i + 1; j < n; j++) {\n const coef = -mat[j][i] / mat[i][i];\n for (let k = i; k < n + 1; k++) {\n if (i == k) {\n mat[j][k] = 0;\n } else {\n mat[j][k] += coef * mat[i][k];\n }\n }\n }\n }\n\n // Solve Ax=b for upper triangular matrix A (mat)\n const x = new Array(n);\n for (let l = n - 1; l >= 0; l--) {\n x[l] = mat[l][n] / mat[l][l];\n for (let m = l - 1; m >= 0; m--) {\n mat[m][n] -= mat[m][l] * x[l];\n }\n }\n return x;\n}\n\n/**\n * Converts radians to to degrees.\n *\n * @param {number} angleInRadians Angle in radians.\n * @return {number} Angle in degrees.\n */\nexport function toDegrees(angleInRadians) {\n return (angleInRadians * 180) / Math.PI;\n}\n\n/**\n * Converts degrees to radians.\n *\n * @param {number} angleInDegrees Angle in degrees.\n * @return {number} Angle in radians.\n */\nexport function toRadians(angleInDegrees) {\n return (angleInDegrees * Math.PI) / 180;\n}\n\n/**\n * Returns the modulo of a / b, depending on the sign of b.\n *\n * @param {number} a Dividend.\n * @param {number} b Divisor.\n * @return {number} Modulo.\n */\nexport function modulo(a, b) {\n const r = a % b;\n return r * b < 0 ? r + b : r;\n}\n\n/**\n * Calculates the linearly interpolated value of x between a and b.\n *\n * @param {number} a Number\n * @param {number} b Number\n * @param {number} x Value to be interpolated.\n * @return {number} Interpolated value.\n */\nexport function lerp(a, b, x) {\n return a + x * (b - a);\n}\n\n/**\n * Returns a number with a limited number of decimal digits.\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The input number with a limited number of decimal digits.\n */\nexport function toFixed(n, decimals) {\n const factor = Math.pow(10, decimals);\n return Math.round(n * factor) / factor;\n}\n\n/**\n * Rounds a number to the nearest integer value considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The nearest integer.\n */\nexport function round(n, decimals) {\n return Math.round(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next smaller integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next smaller integer.\n */\nexport function floor(n, decimals) {\n return Math.floor(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next bigger integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next bigger integer.\n */\nexport function ceil(n, decimals) {\n return Math.ceil(toFixed(n, decimals));\n}\n\n/**\n * Wraps a number between some minimum and maximum values.\n * @param {number} n The number to wrap.\n * @param {number} min The minimum of the range (inclusive).\n * @param {number} max The maximum of the range (exclusive).\n * @return {number} The wrapped number.\n */\nexport function wrap(n, min, max) {\n if (n >= min && n < max) {\n return n;\n }\n const range = max - min;\n return ((((n - min) % range) + range) % range) + min;\n}\n","/**\n * @module ol/sphere\n */\nimport {toDegrees, toRadians} from './math.js';\n\n/**\n * Object literal with options for the {@link getLength} or {@link getArea}\n * functions.\n * @typedef {Object} SphereMetricOptions\n * @property {import(\"./proj.js\").ProjectionLike} [projection='EPSG:3857']\n * Projection of the geometry. By default, the geometry is assumed to be in\n * Web Mercator.\n * @property {number} [radius=6371008.8] Sphere radius. By default, the\n * [mean Earth radius](https://en.wikipedia.org/wiki/Earth_radius#Mean_radius)\n * for the WGS84 ellipsoid is used.\n */\n\n/**\n * The mean Earth radius (1/3 * (2a + b)) for the WGS84 ellipsoid.\n * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius\n * @type {number}\n */\nexport const DEFAULT_RADIUS = 6371008.8;\n\n/**\n * Get the great circle distance (in meters) between two geographic coordinates.\n * @param {Array} c1 Starting coordinate.\n * @param {Array} c2 Ending coordinate.\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {number} The great circle distance between the points (in meters).\n * @api\n */\nexport function getDistance(c1, c2, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lat2 = toRadians(c2[1]);\n const deltaLatBy2 = (lat2 - lat1) / 2;\n const deltaLonBy2 = toRadians(c2[0] - c1[0]) / 2;\n const a =\n Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +\n Math.sin(deltaLonBy2) *\n Math.sin(deltaLonBy2) *\n Math.cos(lat1) *\n Math.cos(lat2);\n return 2 * radius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n}\n\n/**\n * Get the cumulative great circle length of linestring coordinates (geographic).\n * @param {Array} coordinates Linestring coordinates.\n * @param {number} radius The sphere radius to use.\n * @return {number} The length (in meters).\n */\nfunction getLengthInternal(coordinates, radius) {\n let length = 0;\n for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {\n length += getDistance(coordinates[i], coordinates[i + 1], radius);\n }\n return length;\n}\n\n/**\n * Get the spherical length of a geometry. This length is the sum of the\n * great circle distances between coordinates. For polygons, the length is\n * the sum of all rings. For points, the length is zero. For multi-part\n * geometries, the length is the sum of the length of each part.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the\n * length calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical length (in meters).\n * @api\n */\nexport function getLength(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let length = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint': {\n break;\n }\n case 'LineString':\n case 'LinearRing': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n length = getLengthInternal(coordinates, radius);\n break;\n }\n case 'MultiLineString':\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n length += getLengthInternal(coordinates[i], radius);\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n for (j = 0, jj = coords.length; j < jj; ++j) {\n length += getLengthInternal(coords[j], radius);\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n length += getLength(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return length;\n}\n\n/**\n * Returns the spherical area for a list of coordinates.\n *\n * [Reference](https://trs.jpl.nasa.gov/handle/2014/40409)\n * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n * Laboratory, Pasadena, CA, June 2007\n *\n * @param {Array} coordinates List of coordinates of a linear\n * ring. If the ring is oriented clockwise, the area will be positive,\n * otherwise it will be negative.\n * @param {number} radius The sphere radius.\n * @return {number} Area (in square meters).\n */\nfunction getAreaInternal(coordinates, radius) {\n let area = 0;\n const len = coordinates.length;\n let x1 = coordinates[len - 1][0];\n let y1 = coordinates[len - 1][1];\n for (let i = 0; i < len; i++) {\n const x2 = coordinates[i][0];\n const y2 = coordinates[i][1];\n area +=\n toRadians(x2 - x1) *\n (2 + Math.sin(toRadians(y1)) + Math.sin(toRadians(y2)));\n x1 = x2;\n y1 = y2;\n }\n return (area * radius * radius) / 2.0;\n}\n\n/**\n * Get the spherical area of a geometry. This is the area (in meters) assuming\n * that polygon edges are segments of great circles on a sphere.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the area\n * calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical area (in square meters).\n * @api\n */\nexport function getArea(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let area = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint':\n case 'LineString':\n case 'MultiLineString':\n case 'LinearRing': {\n break;\n }\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/Polygon.js\").default} */ (\n geometry\n ).getCoordinates();\n area = Math.abs(getAreaInternal(coordinates[0], radius));\n for (i = 1, ii = coordinates.length; i < ii; ++i) {\n area -= Math.abs(getAreaInternal(coordinates[i], radius));\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n area += Math.abs(getAreaInternal(coords[0], radius));\n for (j = 1, jj = coords.length; j < jj; ++j) {\n area -= Math.abs(getAreaInternal(coords[j], radius));\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n area += getArea(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return area;\n}\n\n/**\n * Returns the coordinate at the given distance and bearing from `c1`.\n *\n * @param {import(\"./coordinate.js\").Coordinate} c1 The origin point (`[lon, lat]` in degrees).\n * @param {number} distance The great-circle distance between the origin\n * point and the target point.\n * @param {number} bearing The bearing (in radians).\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {import(\"./coordinate.js\").Coordinate} The target point.\n */\nexport function offset(c1, distance, bearing, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lon1 = toRadians(c1[0]);\n const dByR = distance / radius;\n const lat = Math.asin(\n Math.sin(lat1) * Math.cos(dByR) +\n Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing),\n );\n const lon =\n lon1 +\n Math.atan2(\n Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),\n Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat),\n );\n return [toDegrees(lon), toDegrees(lat)];\n}\n","/**\n * @module ol/console\n */\n\n/**\n * @typedef {'info'|'warn'|'error'|'none'} Level\n */\n\n/**\n * @type {Object}\n */\nconst levels = {\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n};\n\n/**\n * @type {number}\n */\nlet level = levels.info;\n\n/**\n * Set the logging level. By default, the level is set to 'info' and all\n * messages will be logged. Set to 'warn' to only display warnings and errors.\n * Set to 'error' to only display errors. Set to 'none' to silence all messages.\n *\n * @param {Level} l The new level.\n */\nexport function setLevel(l) {\n level = levels[l];\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function log(...args) {\n if (level > levels.info) {\n return;\n }\n console.log(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function warn(...args) {\n if (level > levels.warn) {\n return;\n }\n console.warn(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function error(...args) {\n if (level > levels.error) {\n return;\n }\n console.error(...args); // eslint-disable-line no-console\n}\n","/**\n * @module ol/coordinate\n */\nimport {getWidth} from './extent.js';\nimport {clamp, modulo, toFixed} from './math.js';\nimport {padNumber} from './string.js';\n\n/**\n * An array of numbers representing an `xy`, `xyz` or `xyzm` coordinate.\n * Example: `[16, 48]`.\n * @typedef {Array} Coordinate\n * @api\n */\n\n/**\n * A function that takes a {@link module:ol/coordinate~Coordinate} and\n * transforms it into a `{string}`.\n *\n * @typedef {function((Coordinate|undefined)): string} CoordinateFormat\n * @api\n */\n\n/**\n * Add `delta` to `coordinate`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {add} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * add(coord, [-2, 4]);\n * // coord is now [5.85, 51.983333]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {Coordinate} delta Delta.\n * @return {Coordinate} The input coordinate adjusted by\n * the given delta.\n * @api\n */\nexport function add(coordinate, delta) {\n coordinate[0] += +delta[0];\n coordinate[1] += +delta[1];\n return coordinate;\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed circle.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {import(\"./geom/Circle.js\").default} circle The circle.\n * @return {Coordinate} Closest point on the circumference.\n */\nexport function closestOnCircle(coordinate, circle) {\n const r = circle.getRadius();\n const center = circle.getCenter();\n const x0 = center[0];\n const y0 = center[1];\n const x1 = coordinate[0];\n const y1 = coordinate[1];\n\n let dx = x1 - x0;\n const dy = y1 - y0;\n if (dx === 0 && dy === 0) {\n dx = 1;\n }\n const d = Math.sqrt(dx * dx + dy * dy);\n\n const x = x0 + (r * dx) / d;\n const y = y0 + (r * dy) / d;\n\n return [x, y];\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed segment.\n * This is the foot of the perpendicular of the coordinate to the segment when\n * the foot is on the segment, or the closest segment coordinate when the foot\n * is outside the segment.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {Array} segment The two coordinates\n * of the segment.\n * @return {Coordinate} The foot of the perpendicular of\n * the coordinate to the segment.\n */\nexport function closestOnSegment(coordinate, segment) {\n const x0 = coordinate[0];\n const y0 = coordinate[1];\n const start = segment[0];\n const end = segment[1];\n const x1 = start[0];\n const y1 = start[1];\n const x2 = end[0];\n const y2 = end[1];\n const dx = x2 - x1;\n const dy = y2 - y1;\n const along =\n dx === 0 && dy === 0\n ? 0\n : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);\n let x, y;\n if (along <= 0) {\n x = x1;\n y = y1;\n } else if (along >= 1) {\n x = x2;\n y = y2;\n } else {\n x = x1 + along * dx;\n y = y1 + along * dy;\n }\n return [x, y];\n}\n\n/**\n * Returns a {@link module:ol/coordinate~CoordinateFormat} function that can be\n * used to format\n * a {Coordinate} to a string.\n *\n * Example without specifying the fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY();\n * const out = stringifyFunc(coord);\n * // out is now '8, 48'\n *\n * Example with explicitly specifying 2 fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY(2);\n * const out = stringifyFunc(coord);\n * // out is now '7.85, 47.98'\n *\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {CoordinateFormat} Coordinate format.\n * @api\n */\nexport function createStringXY(fractionDigits) {\n return (\n /**\n * @param {Coordinate} coordinate Coordinate.\n * @return {string} String XY.\n */\n function (coordinate) {\n return toStringXY(coordinate, fractionDigits);\n }\n );\n}\n\n/**\n * @param {string} hemispheres Hemispheres.\n * @param {number} degrees Degrees.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} String.\n */\nexport function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {\n const normalizedDegrees = modulo(degrees + 180, 360) - 180;\n const x = Math.abs(3600 * normalizedDegrees);\n const decimals = fractionDigits || 0;\n\n let deg = Math.floor(x / 3600);\n let min = Math.floor((x - deg * 3600) / 60);\n let sec = toFixed(x - deg * 3600 - min * 60, decimals);\n\n if (sec >= 60) {\n sec = 0;\n min += 1;\n }\n\n if (min >= 60) {\n min = 0;\n deg += 1;\n }\n\n let hdms = deg + '\\u00b0';\n if (min !== 0 || sec !== 0) {\n hdms += ' ' + padNumber(min, 2) + '\\u2032';\n }\n if (sec !== 0) {\n hdms += ' ' + padNumber(sec, 2, decimals) + '\\u2033';\n }\n if (normalizedDegrees !== 0) {\n hdms += ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);\n }\n\n return hdms;\n}\n\n/**\n * Transforms the given {@link module:ol/coordinate~Coordinate} to a string\n * using the given string template. The strings `{x}` and `{y}` in the template\n * will be replaced with the first and second coordinate values respectively.\n *\n * Example without specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template);\n * // out is now 'Coordinate is (8|48).'\n *\n * Example explicitly specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template, 2);\n * // out is now 'Coordinate is (7.85|47.98).'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {string} template A template string with `{x}` and `{y}` placeholders\n * that will be replaced by first and second coordinate values.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Formatted coordinate.\n * @api\n */\nexport function format(coordinate, template, fractionDigits) {\n if (coordinate) {\n return template\n .replace('{x}', coordinate[0].toFixed(fractionDigits))\n .replace('{y}', coordinate[1].toFixed(fractionDigits));\n }\n return '';\n}\n\n/**\n * @param {Coordinate} coordinate1 First coordinate.\n * @param {Coordinate} coordinate2 Second coordinate.\n * @return {boolean} The two coordinates are equal.\n */\nexport function equals(coordinate1, coordinate2) {\n let equals = true;\n for (let i = coordinate1.length - 1; i >= 0; --i) {\n if (coordinate1[i] != coordinate2[i]) {\n equals = false;\n break;\n }\n }\n return equals;\n}\n\n/**\n * Rotate `coordinate` by `angle`. `coordinate` is modified in place and\n * returned by the function.\n *\n * Example:\n *\n * import {rotate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const rotateRadians = Math.PI / 2; // 90 degrees\n * rotate(coord, rotateRadians);\n * // coord is now [-47.983333, 7.85]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} angle Angle in radian.\n * @return {Coordinate} Coordinate.\n * @api\n */\nexport function rotate(coordinate, angle) {\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;\n const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;\n coordinate[0] = x;\n coordinate[1] = y;\n return coordinate;\n}\n\n/**\n * Scale `coordinate` by `scale`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {scale as scaleCoordinate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const scale = 1.2;\n * scaleCoordinate(coord, scale);\n * // coord is now [9.42, 57.5799996]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} scale Scale factor.\n * @return {Coordinate} Coordinate.\n */\nexport function scale(coordinate, scale) {\n coordinate[0] *= scale;\n coordinate[1] *= scale;\n return coordinate;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Squared distance between coord1 and coord2.\n */\nexport function squaredDistance(coord1, coord2) {\n const dx = coord1[0] - coord2[0];\n const dy = coord1[1] - coord2[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Distance between coord1 and coord2.\n */\nexport function distance(coord1, coord2) {\n return Math.sqrt(squaredDistance(coord1, coord2));\n}\n\n/**\n * Calculate the squared distance from a coordinate to a line segment.\n *\n * @param {Coordinate} coordinate Coordinate of the point.\n * @param {Array} segment Line segment (2\n * coordinates).\n * @return {number} Squared distance from the point to the line segment.\n */\nexport function squaredDistanceToSegment(coordinate, segment) {\n return squaredDistance(coordinate, closestOnSegment(coordinate, segment));\n}\n\n/**\n * Format a geographic coordinate with the hemisphere, degrees, minutes, and\n * seconds.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord);\n * // out is now '47° 58′ 60″ N 7° 50′ 60″ E'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord, 1);\n * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Hemisphere, degrees, minutes and seconds.\n * @api\n */\nexport function toStringHDMS(coordinate, fractionDigits) {\n if (coordinate) {\n return (\n degreesToStringHDMS('NS', coordinate[1], fractionDigits) +\n ' ' +\n degreesToStringHDMS('EW', coordinate[0], fractionDigits)\n );\n }\n return '';\n}\n\n/**\n * Format a coordinate as a comma delimited string.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord);\n * // out is now '8, 48'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord, 1);\n * // out is now '7.8, 48.0'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} XY.\n * @api\n */\nexport function toStringXY(coordinate, fractionDigits) {\n return format(coordinate, '{x}, {y}', fractionDigits);\n}\n\n/**\n * Modifies the provided coordinate in-place to be within the real world\n * extent. The lower projection extent boundary is inclusive, the upper one\n * exclusive.\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @return {Coordinate} The coordinate within the real world extent.\n */\nexport function wrapX(coordinate, projection) {\n if (projection.canWrapX()) {\n const worldWidth = getWidth(projection.getExtent());\n const worldsAway = getWorldsAway(coordinate, projection, worldWidth);\n if (worldsAway) {\n coordinate[0] -= worldsAway * worldWidth;\n }\n }\n return coordinate;\n}\n/**\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {number} [sourceExtentWidth] Width of the source extent.\n * @return {number} Offset in world widths.\n */\nexport function getWorldsAway(coordinate, projection, sourceExtentWidth) {\n const projectionExtent = projection.getExtent();\n let worldsAway = 0;\n if (\n projection.canWrapX() &&\n (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])\n ) {\n sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);\n worldsAway = Math.floor(\n (coordinate[0] - projectionExtent[0]) / sourceExtentWidth,\n );\n }\n return worldsAway;\n}\n\n/**\n * Compute the angle between p0pA and p0pB\n * @param {Coordinate} p0 Point 0\n * @param {Coordinate} pA Point A\n * @param {Coordinate} pB Point B\n * @return {number} a value in [0, 2PI]\n */\nexport function angleBetween(p0, pA, pB) {\n const lenA = Math.sqrt(\n (pA[0] - p0[0]) * (pA[0] - p0[0]) + (pA[1] - p0[1]) * (pA[1] - p0[1]),\n );\n const tangentA = [(pA[0] - p0[0]) / lenA, (pA[1] - p0[1]) / lenA];\n const orthoA = [-tangentA[1], tangentA[0]];\n const lenB = Math.sqrt(\n (pB[0] - p0[0]) * (pB[0] - p0[0]) + (pB[1] - p0[1]) * (pB[1] - p0[1]),\n );\n const tangentB = [(pB[0] - p0[0]) / lenB, (pB[1] - p0[1]) / lenB];\n\n // this angle can be clockwise or anticlockwise; hence the computation afterwards\n let angle =\n lenA === 0 || lenB === 0\n ? 0\n : Math.acos(\n clamp(tangentB[0] * tangentA[0] + tangentB[1] * tangentA[1], -1, 1),\n );\n angle = Math.max(angle, 0.00001); // avoid a zero angle otherwise this is detected as a line cap\n const isClockwise = tangentB[0] * orthoA[0] + tangentB[1] * orthoA[1] > 0;\n return !isClockwise ? Math.PI * 2 - angle : angle;\n}\n","/**\n * @module ol/proj/Units\n */\n\n/**\n * @typedef {'radians' | 'degrees' | 'ft' | 'm' | 'pixels' | 'tile-pixels' | 'us-ft'} Units\n * Projection units.\n */\n\n/**\n * See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt\n * @type {Object}\n */\nconst unitByCode = {\n '9001': 'm',\n '9002': 'ft',\n '9003': 'us-ft',\n '9101': 'radians',\n '9102': 'degrees',\n};\n\n/**\n * @param {number} code Unit code.\n * @return {Units} Units.\n */\nexport function fromCode(code) {\n return unitByCode[code];\n}\n\n/**\n * @typedef {Object} MetersPerUnitLookup\n * @property {number} radians Radians\n * @property {number} degrees Degrees\n * @property {number} ft Feet\n * @property {number} m Meters\n * @property {number} us-ft US feet\n */\n\n/**\n * Meters per unit lookup table.\n * @const\n * @type {MetersPerUnitLookup}\n * @api\n */\nexport const METERS_PER_UNIT = {\n // use the radius of the Normal sphere\n 'radians': 6370997 / (2 * Math.PI),\n 'degrees': (2 * Math.PI * 6370997) / 360,\n 'ft': 0.3048,\n 'm': 1,\n 'us-ft': 1200 / 3937,\n};\n","/**\n * @module ol/proj/Projection\n */\nimport {METERS_PER_UNIT} from './Units.js';\n\n/**\n * The function is called with a `number` view resolution and a\n * {@link module:ol/coordinate~Coordinate} as arguments, and returns the `number` resolution\n * in projection units at the passed coordinate.\n * @typedef {function(number, import(\"../coordinate.js\").Coordinate):number} GetPointResolution\n * @api\n */\n\n/**\n * @typedef {Object} Options\n * @property {string} code The SRS identifier code, e.g. `EPSG:4326`.\n * @property {import(\"./Units.js\").Units} [units] Units. Required unless a\n * proj4 projection is defined for `code`.\n * @property {import(\"../extent.js\").Extent} [extent] The validity extent for the SRS.\n * @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.\n * @property {boolean} [global=false] Whether the projection is valid for the whole globe.\n * @property {number} [metersPerUnit] The meters per unit for the SRS.\n * If not provided, the `units` are used to get the meters per unit from the {@link METERS_PER_UNIT}\n * lookup table.\n * @property {import(\"../extent.js\").Extent} [worldExtent] The world extent for the SRS.\n * @property {GetPointResolution} [getPointResolution]\n * Function to determine resolution at a point. The function is called with a\n * `number` view resolution and a {@link module:ol/coordinate~Coordinate} as arguments, and returns\n * the `number` resolution in projection units at the passed coordinate. If this is `undefined`,\n * the default {@link module:ol/proj.getPointResolution} function will be used.\n */\n\n/**\n * @classdesc\n * In most cases, you should not need to create instances of this class.\n * Instead, where projection information is required, you can use a string\n * projection code or identifier (e.g. `EPSG:4326`) instead of a projection\n * instance.\n *\n * The library includes support for transforming coordinates between the following\n * projections:\n *\n * WGS 84 / Geographic - Using codes `EPSG:4326`, `CRS:84`, `urn:ogc:def:crs:EPSG:6.6:4326`,\n * `urn:ogc:def:crs:OGC:1.3:CRS84`, `urn:ogc:def:crs:OGC:2:84`, `http://www.opengis.net/gml/srs/epsg.xml#4326`,\n * or `urn:x-ogc:def:crs:EPSG:4326`\n * WGS 84 / Spherical Mercator - Using codes `EPSG:3857`, `EPSG:102100`, `EPSG:102113`, `EPSG:900913`,\n * `urn:ogc:def:crs:EPSG:6.18:3:3857`, or `http://www.opengis.net/gml/srs/epsg.xml#3857`\n * WGS 84 / UTM zones - Using codes `EPSG:32601` through `EPSG:32660` for northern zones\n * and `EPSG:32701` through `EPSG:32760` for southern zones. Note that the built-in UTM transforms\n * are lower accuracy (with errors on the order of 0.1 m) than those that you might get in a\n * library like [proj4js](https://github.com/proj4js/proj4js).\n *\n * For additional projection support, or to use higher accuracy transforms than the built-in ones, you can use\n * the [proj4js](https://github.com/proj4js/proj4js) library. With `proj4js`, after adding any new projection\n * definitions, call the {@link module:ol/proj/proj4.register} function.\n *\n * You can use the {@link module:ol/proj.get} function to retrieve a projection instance\n * for one of the registered projections.\n *\n * @api\n */\nclass Projection {\n /**\n * @param {Options} options Projection options.\n */\n constructor(options) {\n /**\n * @private\n * @type {string}\n */\n this.code_ = options.code;\n\n /**\n * Units of projected coordinates. When set to `TILE_PIXELS`, a\n * `this.extent_` and `this.worldExtent_` must be configured properly for each\n * tile.\n * @private\n * @type {import(\"./Units.js\").Units}\n */\n this.units_ = /** @type {import(\"./Units.js\").Units} */ (options.units);\n\n /**\n * Validity extent of the projection in projected coordinates. For projections\n * with `TILE_PIXELS` units, this is the extent of the tile in\n * tile pixel space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = options.extent !== undefined ? options.extent : null;\n\n /**\n * Extent of the world in EPSG:4326. For projections with\n * `TILE_PIXELS` units, this is the extent of the tile in\n * projected coordinate space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.worldExtent_ =\n options.worldExtent !== undefined ? options.worldExtent : null;\n\n /**\n * @private\n * @type {string}\n */\n this.axisOrientation_ =\n options.axisOrientation !== undefined ? options.axisOrientation : 'enu';\n\n /**\n * @private\n * @type {boolean}\n */\n this.global_ = options.global !== undefined ? options.global : false;\n\n /**\n * @private\n * @type {boolean}\n */\n this.canWrapX_ = !!(this.global_ && this.extent_);\n\n /**\n * @private\n * @type {GetPointResolution|undefined}\n */\n this.getPointResolutionFunc_ = options.getPointResolution;\n\n /**\n * @private\n * @type {import(\"../tilegrid/TileGrid.js\").default}\n */\n this.defaultTileGrid_ = null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.metersPerUnit_ = options.metersPerUnit;\n }\n\n /**\n * @return {boolean} The projection is suitable for wrapping the x-axis\n */\n canWrapX() {\n return this.canWrapX_;\n }\n\n /**\n * Get the code for this projection, e.g. 'EPSG:4326'.\n * @return {string} Code.\n * @api\n */\n getCode() {\n return this.code_;\n }\n\n /**\n * Get the validity extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n return this.extent_;\n }\n\n /**\n * Get the units of this projection.\n * @return {import(\"./Units.js\").Units} Units.\n * @api\n */\n getUnits() {\n return this.units_;\n }\n\n /**\n * Get the amount of meters per unit of this projection. If the projection is\n * not configured with `metersPerUnit` or a units identifier, the return is\n * `undefined`.\n * @return {number|undefined} Meters.\n * @api\n */\n getMetersPerUnit() {\n return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];\n }\n\n /**\n * Get the world extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getWorldExtent() {\n return this.worldExtent_;\n }\n\n /**\n * Get the axis orientation of this projection.\n * Example values are:\n * enu - the default easting, northing, elevation.\n * neu - northing, easting, up - useful for \"lat/long\" geographic coordinates,\n * or south orientated transverse mercator.\n * wnu - westing, northing, up - some planetary coordinate systems have\n * \"west positive\" coordinate systems\n * @return {string} Axis orientation.\n * @api\n */\n getAxisOrientation() {\n return this.axisOrientation_;\n }\n\n /**\n * Is this projection a global projection which spans the whole world?\n * @return {boolean} Whether the projection is global.\n * @api\n */\n isGlobal() {\n return this.global_;\n }\n\n /**\n * Set if the projection is a global projection which spans the whole world\n * @param {boolean} global Whether the projection is global.\n * @api\n */\n setGlobal(global) {\n this.global_ = global;\n this.canWrapX_ = !!(global && this.extent_);\n }\n\n /**\n * @return {import(\"../tilegrid/TileGrid.js\").default} The default tile grid.\n */\n getDefaultTileGrid() {\n return this.defaultTileGrid_;\n }\n\n /**\n * @param {import(\"../tilegrid/TileGrid.js\").default} tileGrid The default tile grid.\n */\n setDefaultTileGrid(tileGrid) {\n this.defaultTileGrid_ = tileGrid;\n }\n\n /**\n * Set the validity extent for this projection.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n setExtent(extent) {\n this.extent_ = extent;\n this.canWrapX_ = !!(this.global_ && extent);\n }\n\n /**\n * Set the world extent for this projection.\n * @param {import(\"../extent.js\").Extent} worldExtent World extent\n * [minlon, minlat, maxlon, maxlat].\n * @api\n */\n setWorldExtent(worldExtent) {\n this.worldExtent_ = worldExtent;\n }\n\n /**\n * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}\n * for this projection.\n * @param {function(number, import(\"../coordinate.js\").Coordinate):number} func Function\n * @api\n */\n setGetPointResolution(func) {\n this.getPointResolutionFunc_ = func;\n }\n\n /**\n * Get the custom point resolution function for this projection (if set).\n * @return {GetPointResolution|undefined} The custom point\n * resolution function (if set).\n */\n getPointResolutionFunc() {\n return this.getPointResolutionFunc_;\n }\n}\n\nexport default Projection;\n","/**\n * @module ol/proj/epsg3857\n */\nimport Projection from './Projection.js';\n\n/**\n * Radius of WGS84 sphere\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * @const\n * @type {number}\n */\nexport const HALF_SIZE = Math.PI * RADIUS;\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const WORLD_EXTENT = [-180, -85, 180, 85];\n\n/**\n * Maximum safe value in y direction\n * @const\n * @type {number}\n */\nexport const MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));\n\n/**\n * @classdesc\n * Projection object for web/spherical Mercator (EPSG:3857).\n */\nclass EPSG3857Projection extends Projection {\n /**\n * @param {string} code Code.\n */\n constructor(code) {\n super({\n code: code,\n units: 'm',\n extent: EXTENT,\n global: true,\n worldExtent: WORLD_EXTENT,\n getPointResolution: function (resolution, point) {\n return resolution / Math.cosh(point[1] / RADIUS);\n },\n });\n }\n}\n\n/**\n * Projections equal to EPSG:3857.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG3857Projection('EPSG:3857'),\n new EPSG3857Projection('EPSG:102100'),\n new EPSG3857Projection('EPSG:102113'),\n new EPSG3857Projection('EPSG:900913'),\n new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),\n new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),\n];\n\n/**\n * Transformation from EPSG:4326 to EPSG:3857.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @param {number} [stride] Stride (default is `dimension`).\n * @return {Array} Output array of coordinate values.\n */\nexport function fromEPSG4326(input, output, dimension, stride) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n stride = stride ?? dimension;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += stride) {\n output[i] = (HALF_SIZE * input[i]) / 180;\n let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));\n if (y > MAX_SAFE_Y) {\n y = MAX_SAFE_Y;\n } else if (y < -MAX_SAFE_Y) {\n y = -MAX_SAFE_Y;\n }\n output[i + 1] = y;\n }\n return output;\n}\n\n/**\n * Transformation from EPSG:3857 to EPSG:4326.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @param {number} [stride] Stride (default is `dimension`).\n * @return {Array} Output array of coordinate values.\n */\nexport function toEPSG4326(input, output, dimension, stride) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n stride = stride ?? dimension;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += stride) {\n output[i] = (180 * input[i]) / HALF_SIZE;\n output[i + 1] =\n (360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;\n }\n return output;\n}\n","/**\n * @module ol/proj/epsg4326\n */\nimport Projection from './Projection.js';\n\n/**\n * Semi-major radius of the WGS84 ellipsoid.\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * Extent of the EPSG:4326 projection which is the whole world.\n *\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-180, -90, 180, 90];\n\n/**\n * @const\n * @type {number}\n */\nexport const METERS_PER_UNIT = (Math.PI * RADIUS) / 180;\n\n/**\n * @classdesc\n * Projection object for WGS84 geographic coordinates (EPSG:4326).\n *\n * Note that OpenLayers does not strictly comply with the EPSG definition.\n * The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).\n * OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.\n */\nclass EPSG4326Projection extends Projection {\n /**\n * @param {string} code Code.\n * @param {string} [axisOrientation] Axis orientation.\n */\n constructor(code, axisOrientation) {\n super({\n code: code,\n units: 'degrees',\n extent: EXTENT,\n axisOrientation: axisOrientation,\n global: true,\n metersPerUnit: METERS_PER_UNIT,\n worldExtent: EXTENT,\n });\n }\n}\n\n/**\n * Projections equal to EPSG:4326.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG4326Projection('CRS:84'),\n new EPSG4326Projection('EPSG:4326', 'neu'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/OGC/1.3/CRS84'),\n new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),\n];\n","/**\n * @module ol/proj/projections\n */\n\n/**\n * @type {Object}\n */\nlet cache = {};\n\n/**\n * Clear the projections cache.\n */\nexport function clear() {\n cache = {};\n}\n\n/**\n * Get a cached projection by code.\n * @param {string} code The code for the projection.\n * @return {import(\"./Projection.js\").default|null} The projection (if cached).\n */\nexport function get(code) {\n return (\n cache[code] ||\n cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\\w+)$/, 'EPSG:$3')] ||\n null\n );\n}\n\n/**\n * Add a projection to the cache.\n * @param {string} code The projection code.\n * @param {import(\"./Projection.js\").default} projection The projection to cache.\n */\nexport function add(code, projection) {\n cache[code] = projection;\n}\n","/**\n * @module ol/proj/transforms\n */\nimport {isEmpty} from '../obj.js';\n\n/**\n * @private\n * @type {!Object>}\n */\nlet transforms = {};\n\n/**\n * Clear the transform cache.\n */\nexport function clear() {\n transforms = {};\n}\n\n/**\n * Registers a conversion function to convert coordinates from the source\n * projection to the destination projection.\n *\n * @param {import(\"./Projection.js\").default} source Source.\n * @param {import(\"./Projection.js\").default} destination Destination.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform.\n */\nexport function add(source, destination, transformFn) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n if (!(sourceCode in transforms)) {\n transforms[sourceCode] = {};\n }\n transforms[sourceCode][destinationCode] = transformFn;\n}\n\n/**\n * Unregisters the conversion function to convert coordinates from the source\n * projection to the destination projection. This method is used to clean up\n * cached transforms during testing.\n *\n * @param {import(\"./Projection.js\").default} source Source projection.\n * @param {import(\"./Projection.js\").default} destination Destination projection.\n * @return {import(\"../proj.js\").TransformFunction} transformFn The unregistered transform.\n */\nexport function remove(source, destination) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n const transform = transforms[sourceCode][destinationCode];\n delete transforms[sourceCode][destinationCode];\n if (isEmpty(transforms[sourceCode])) {\n delete transforms[sourceCode];\n }\n return transform;\n}\n\n/**\n * Get a transform given a source code and a destination code.\n * @param {string} sourceCode The code for the source projection.\n * @param {string} destinationCode The code for the destination projection.\n * @return {import(\"../proj.js\").TransformFunction|null} The transform function (if found).\n */\nexport function get(sourceCode, destinationCode) {\n if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {\n return transforms[sourceCode][destinationCode];\n }\n return null;\n}\n","/**\n * @module ol/proj/utm\n */\n\n/**\n * Adapted from https://github.com/Turbo87/utm\n * Copyright (c) 2012-2017 Tobias Bieniek\n *\n * The functions here provide approximate transforms to and from UTM.\n * They are not appropriate for use beyond the validity extend of a UTM\n * zone, and the accuracy of the transform decreases toward the zone\n * edges.\n */\n\nimport {toDegrees, toRadians, wrap} from '../math.js';\nimport Projection from './Projection.js';\n\n/**\n * @typedef {Object} UTMZone\n * @property {number} number The zone number (1 - 60).\n * @property {boolean} north The northern hemisphere.\n */\n\nconst K0 = 0.9996;\n\nconst E = 0.00669438;\nconst E2 = E * E;\nconst E3 = E2 * E;\nconst E_P2 = E / (1 - E);\n\nconst SQRT_E = Math.sqrt(1 - E);\nconst _E = (1 - SQRT_E) / (1 + SQRT_E);\nconst _E2 = _E * _E;\nconst _E3 = _E2 * _E;\nconst _E4 = _E3 * _E;\nconst _E5 = _E4 * _E;\n\nconst M1 = 1 - E / 4 - (3 * E2) / 64 - (5 * E3) / 256;\nconst M2 = (3 * E) / 8 + (3 * E2) / 32 + (45 * E3) / 1024;\nconst M3 = (15 * E2) / 256 + (45 * E3) / 1024;\nconst M4 = (35 * E3) / 3072;\n\nconst P2 = (3 / 2) * _E - (27 / 32) * _E3 + (269 / 512) * _E5;\nconst P3 = (21 / 16) * _E2 - (55 / 32) * _E4;\nconst P4 = (151 / 96) * _E3 - (417 / 128) * _E5;\nconst P5 = (1097 / 512) * _E4;\n\nconst R = 6378137;\n\n/**\n * @param {number} easting Easting value of coordinate.\n * @param {number} northing Northing value of coordinate.\n * @param {UTMZone} zone The UTM zone.\n * @return {import(\"../coordinate.js\").Coordinate} The transformed coordinate.\n */\nfunction toLonLat(easting, northing, zone) {\n const x = easting - 500000;\n const y = zone.north ? northing : northing - 10000000;\n\n const m = y / K0;\n const mu = m / (R * M1);\n\n const pRad =\n mu +\n P2 * Math.sin(2 * mu) +\n P3 * Math.sin(4 * mu) +\n P4 * Math.sin(6 * mu) +\n P5 * Math.sin(8 * mu);\n\n const pSin = Math.sin(pRad);\n const pSin2 = pSin * pSin;\n\n const pCos = Math.cos(pRad);\n\n const pTan = pSin / pCos;\n const pTan2 = pTan * pTan;\n const pTan4 = pTan2 * pTan2;\n\n const epSin = 1 - E * pSin2;\n const epSinSqrt = Math.sqrt(1 - E * pSin2);\n\n const n = R / epSinSqrt;\n const r = (1 - E) / epSin;\n\n const c = E_P2 * pCos ** 2;\n const c2 = c * c;\n\n const d = x / (n * K0);\n const d2 = d * d;\n const d3 = d2 * d;\n const d4 = d3 * d;\n const d5 = d4 * d;\n const d6 = d5 * d;\n\n const latitude =\n pRad -\n (pTan / r) *\n (d2 / 2 - (d4 / 24) * (5 + 3 * pTan2 + 10 * c - 4 * c2 - 9 * E_P2)) +\n (d6 / 720) * (61 + 90 * pTan2 + 298 * c + 45 * pTan4 - 252 * E_P2 - 3 * c2);\n\n let longitude =\n (d -\n (d3 / 6) * (1 + 2 * pTan2 + c) +\n (d5 / 120) * (5 - 2 * c + 28 * pTan2 - 3 * c2 + 8 * E_P2 + 24 * pTan4)) /\n pCos;\n\n longitude = wrap(\n longitude + toRadians(zoneToCentralLongitude(zone.number)),\n -Math.PI,\n Math.PI,\n );\n\n return [toDegrees(longitude), toDegrees(latitude)];\n}\n\nconst MIN_LATITUDE = -80;\nconst MAX_LATITUDE = 84;\nconst MIN_LONGITUDE = -180;\nconst MAX_LONGITUDE = 180;\n\n/**\n * @param {number} longitude The longitude.\n * @param {number} latitude The latitude.\n * @param {UTMZone} zone The UTM zone.\n * @return {import('../coordinate.js').Coordinate} The UTM coordinate.\n */\nfunction fromLonLat(longitude, latitude, zone) {\n longitude = wrap(longitude, MIN_LONGITUDE, MAX_LONGITUDE);\n\n if (latitude < MIN_LATITUDE) {\n latitude = MIN_LATITUDE;\n } else if (latitude > MAX_LATITUDE) {\n latitude = MAX_LATITUDE;\n }\n\n const latRad = toRadians(latitude);\n const latSin = Math.sin(latRad);\n const latCos = Math.cos(latRad);\n\n const latTan = latSin / latCos;\n const latTan2 = latTan * latTan;\n const latTan4 = latTan2 * latTan2;\n\n const lonRad = toRadians(longitude);\n const centralLon = zoneToCentralLongitude(zone.number);\n const centralLonRad = toRadians(centralLon);\n\n const n = R / Math.sqrt(1 - E * latSin ** 2);\n const c = E_P2 * latCos ** 2;\n\n const a = latCos * wrap(lonRad - centralLonRad, -Math.PI, Math.PI);\n const a2 = a * a;\n const a3 = a2 * a;\n const a4 = a3 * a;\n const a5 = a4 * a;\n const a6 = a5 * a;\n\n const m =\n R *\n (M1 * latRad -\n M2 * Math.sin(2 * latRad) +\n M3 * Math.sin(4 * latRad) -\n M4 * Math.sin(6 * latRad));\n\n const easting =\n K0 *\n n *\n (a +\n (a3 / 6) * (1 - latTan2 + c) +\n (a5 / 120) * (5 - 18 * latTan2 + latTan4 + 72 * c - 58 * E_P2)) +\n 500000;\n\n let northing =\n K0 *\n (m +\n n *\n latTan *\n (a2 / 2 +\n (a4 / 24) * (5 - latTan2 + 9 * c + 4 * c ** 2) +\n (a6 / 720) * (61 - 58 * latTan2 + latTan4 + 600 * c - 330 * E_P2)));\n\n if (!zone.north) {\n northing += 10000000;\n }\n\n return [easting, northing];\n}\n\n/**\n * @param {number} zone The zone number.\n * @return {number} The central longitude in degrees.\n */\nfunction zoneToCentralLongitude(zone) {\n return (zone - 1) * 6 - 180 + 3;\n}\n\n/**\n * @type {Array}\n */\nconst epsgRegExes = [\n /^EPSG:(\\d+)$/,\n /^urn:ogc:def:crs:EPSG::(\\d+)$/,\n /^http:\\/\\/www\\.opengis\\.net\\/def\\/crs\\/EPSG\\/0\\/(\\d+)$/,\n];\n\n/**\n * @param {string} code The projection code.\n * @return {UTMZone|null} The UTM zone info (or null if not UTM).\n */\nexport function zoneFromCode(code) {\n let epsgId = 0;\n for (const re of epsgRegExes) {\n const match = code.match(re);\n if (match) {\n epsgId = parseInt(match[1]);\n break;\n }\n }\n if (!epsgId) {\n return null;\n }\n\n let number = 0;\n let north = false;\n if (epsgId > 32700 && epsgId < 32761) {\n number = epsgId - 32700;\n } else if (epsgId > 32600 && epsgId < 32661) {\n north = true;\n number = epsgId - 32600;\n }\n if (!number) {\n return null;\n }\n\n return {number, north};\n}\n\n/**\n * @param {function(number, number, UTMZone): import('../coordinate.js').Coordinate} transformer The transformer.\n * @param {UTMZone} zone The UTM zone.\n * @return {import('../proj.js').TransformFunction} The transform function.\n */\nfunction makeTransformFunction(transformer, zone) {\n return function (input, output, dimension, stride) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n stride = stride ?? dimension;\n if (!output) {\n if (dimension > 2) {\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += stride) {\n const x = input[i];\n const y = input[i + 1];\n const coord = transformer(x, y, zone);\n output[i] = coord[0];\n output[i + 1] = coord[1];\n }\n return output;\n };\n}\n\n/**\n * @param {string} code The projection code.\n * @return {import('./Projection.js').default|null} A projection or null if unable to create one.\n */\nexport function makeProjection(code) {\n const zone = zoneFromCode(code);\n if (!zone) {\n return null;\n }\n return new Projection({code, units: 'm'});\n}\n\n/**\n * @param {import('./Projection.js').default} projection The projection.\n * @return {import('../proj.js').Transforms|null} The transforms lookup or null if unable to handle projection.\n */\nexport function makeTransforms(projection) {\n const zone = zoneFromCode(projection.getCode());\n if (!zone) {\n return null;\n }\n\n return {\n forward: makeTransformFunction(fromLonLat, zone),\n inverse: makeTransformFunction(toLonLat, zone),\n };\n}\n","/**\n * @module ol/proj\n */\n\n/**\n * The ol/proj module stores:\n * a list of {@link module:ol/proj/Projection~Projection}\n * objects, one for each projection supported by the application\n * a list of transform functions needed to convert coordinates in one projection\n * into another.\n *\n * The static functions are the methods used to maintain these.\n * Each transform function can handle not only simple coordinate pairs, but also\n * large arrays of coordinates such as vector geometries.\n *\n * When loaded, the library adds projection objects for EPSG:4326 (WGS84\n * geographic coordinates) and EPSG:3857 (Web or Spherical Mercator, as used\n * for example by Bing Maps or OpenStreetMap), together with the relevant\n * transform functions.\n *\n * Additional transforms may be added by using the http://proj4js.org/\n * library (version 2.2 or later). You can use the full build supplied by\n * Proj4js, or create a custom build to support those projections you need; see\n * the Proj4js website for how to do this. You also need the Proj4js definitions\n * for the required projections. These definitions can be obtained from\n * https://spatialreference.org/, and are a JS function, so can be loaded in a\n * script tag (as in the examples) or pasted into your application.\n *\n * After all required projection definitions are added to proj4's registry (by\n * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`\n * package. Existing transforms are not changed by this function. See\n * examples/wms-image-custom-proj for an example of this.\n *\n * Additional projection definitions can be registered with `proj4.defs()` any\n * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't\n * know in advance what projections are needed, you can initially load minimal\n * support and then load whichever are requested.\n *\n * Note that Proj4js does not support projection extents. If you want to add\n * one for creating default tile grids, you can add it after the Projection\n * object has been created with `setExtent`, for example,\n * `get('EPSG:1234').setExtent(extent)`.\n *\n * In addition to Proj4js support, any transform functions can be added with\n * {@link module:ol/proj.addCoordinateTransforms}. To use this, you must first create\n * a {@link module:ol/proj/Projection~Projection} object for the new projection and add it with\n * {@link module:ol/proj.addProjection}. You can then add the forward and inverse\n * functions with {@link module:ol/proj.addCoordinateTransforms}. See\n * examples/wms-custom-proj for an example of this.\n *\n * Note that if no transforms are needed and you only need to define the\n * projection, just add a {@link module:ol/proj/Projection~Projection} with\n * {@link module:ol/proj.addProjection}. See examples/wms-no-proj for an example of\n * this.\n */\nimport {warn} from './console.js';\nimport {equals, getWorldsAway} from './coordinate.js';\nimport {applyTransform, getWidth} from './extent.js';\nimport {clamp, modulo} from './math.js';\nimport Projection from './proj/Projection.js';\nimport {METERS_PER_UNIT} from './proj/Units.js';\nimport {\n PROJECTIONS as EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n} from './proj/epsg3857.js';\nimport {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';\nimport {\n add as addProj,\n clear as clearProj,\n get as getProj,\n} from './proj/projections.js';\nimport {\n add as addTransformFunc,\n clear as clearTransformFuncs,\n get as getTransformFunc,\n} from './proj/transforms.js';\nimport {\n makeProjection as makeUTMProjection,\n makeTransforms as makeUTMTransforms,\n} from './proj/utm.js';\nimport {getDistance} from './sphere.js';\n\n/**\n * A projection as {@link module:ol/proj/Projection~Projection}, SRS identifier\n * string or undefined.\n * @typedef {Projection|string|undefined} ProjectionLike\n * @api\n */\n\n/**\n * @typedef {Object} Transforms\n * @property {TransformFunction} forward The forward transform (from geographic).\n * @property {TransformFunction} inverse The inverse transform (to geographic).\n */\n\n/**\n * @type {Array}\n */\nconst transformFactories = [makeUTMTransforms];\n\n/**\n * @type {Array}\n */\nconst projectionFactories = [makeUTMProjection];\n\n/**\n * A transform function accepts an array of input coordinate values, an optional\n * output array, and an optional dimension (default should be 2). The function\n * transforms the input coordinate values, populates the output array, and\n * returns the output array.\n *\n * @callback TransformFunction\n * @param {Array} input\n * @param {Array} [output]\n * @param {number} [dimension]\n * @param {number} [stride]\n * @return {Array}\n *\n * @api\n */\n\nexport {METERS_PER_UNIT};\n\nexport {Projection};\n\nlet showCoordinateWarning = true;\n\n/**\n * @param {boolean} [disable] Disable console info about `useGeographic()`\n */\nexport function disableCoordinateWarning(disable) {\n const hide = disable === undefined ? true : disable;\n showCoordinateWarning = !hide;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Output coordinate array (new array, same coordinate\n * values).\n */\nexport function cloneTransform(input, output) {\n if (output !== undefined) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n output = output;\n } else {\n output = input.slice();\n }\n return output;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Input coordinate array (same array as input).\n */\nexport function identityTransform(input, output) {\n if (output !== undefined && input !== output) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n input = output;\n }\n return input;\n}\n\n/**\n * Add a Projection object to the list of supported projections that can be\n * looked up by their code.\n *\n * @param {Projection} projection Projection instance.\n * @api\n */\nexport function addProjection(projection) {\n addProj(projection.getCode(), projection);\n addTransformFunc(projection, projection, cloneTransform);\n}\n\n/**\n * @param {Array} projections Projections.\n */\nexport function addProjections(projections) {\n projections.forEach(addProjection);\n}\n\n/**\n * Fetches a Projection object for the code specified.\n *\n * @param {ProjectionLike} projectionLike Either a code string which is\n * a combination of authority and identifier such as \"EPSG:4326\", or an\n * existing projection object, or undefined.\n * @return {Projection|null} Projection object, or null if not in list.\n * @api\n */\nexport function get(projectionLike) {\n if (!(typeof projectionLike === 'string')) {\n return projectionLike;\n }\n const projection = getProj(projectionLike);\n if (projection) {\n return projection;\n }\n for (const makeProjection of projectionFactories) {\n const projection = makeProjection(projectionLike);\n if (projection) {\n return projection;\n }\n }\n return null;\n}\n\n/**\n * Get the resolution of the point in degrees or distance units.\n * For projections with degrees as the unit this will simply return the\n * provided resolution. For other projections the point resolution is\n * by default estimated by transforming the `point` pixel to EPSG:4326,\n * measuring its width and height on the normal sphere,\n * and taking the average of the width and height.\n * A custom function can be provided for a specific projection, either\n * by setting the `getPointResolution` option in the\n * {@link module:ol/proj/Projection~Projection} constructor or by using\n * {@link module:ol/proj/Projection~Projection#setGetPointResolution} to change an existing\n * projection object.\n * @param {ProjectionLike} projection The projection.\n * @param {number} resolution Nominal resolution in projection units.\n * @param {import(\"./coordinate.js\").Coordinate} point Point to find adjusted resolution at.\n * @param {import(\"./proj/Units.js\").Units} [units] Units to get the point resolution in.\n * Default is the projection's units.\n * @return {number} Point resolution.\n * @api\n */\nexport function getPointResolution(projection, resolution, point, units) {\n projection = get(projection);\n let pointResolution;\n const getter = projection.getPointResolutionFunc();\n if (getter) {\n pointResolution = getter(resolution, point);\n if (units && units !== projection.getUnits()) {\n const metersPerUnit = projection.getMetersPerUnit();\n if (metersPerUnit) {\n pointResolution =\n (pointResolution * metersPerUnit) / METERS_PER_UNIT[units];\n }\n }\n } else {\n const projUnits = projection.getUnits();\n if ((projUnits == 'degrees' && !units) || units == 'degrees') {\n pointResolution = resolution;\n } else {\n // Estimate point resolution by transforming the center pixel to EPSG:4326,\n // measuring its width and height on the normal sphere, and taking the\n // average of the width and height.\n const toEPSG4326 = getTransformFromProjections(\n projection,\n get('EPSG:4326'),\n );\n if (!toEPSG4326 && projUnits !== 'degrees') {\n // no transform is available\n pointResolution = resolution * projection.getMetersPerUnit();\n } else {\n let vertices = [\n point[0] - resolution / 2,\n point[1],\n point[0] + resolution / 2,\n point[1],\n point[0],\n point[1] - resolution / 2,\n point[0],\n point[1] + resolution / 2,\n ];\n vertices = toEPSG4326(vertices, vertices, 2);\n const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));\n const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));\n pointResolution = (width + height) / 2;\n }\n const metersPerUnit = units\n ? METERS_PER_UNIT[units]\n : projection.getMetersPerUnit();\n if (metersPerUnit !== undefined) {\n pointResolution /= metersPerUnit;\n }\n }\n }\n return pointResolution;\n}\n\n/**\n * Registers transformation functions that don't alter coordinates. Those allow\n * to transform between projections with equal meaning.\n *\n * @param {Array} projections Projections.\n * @api\n */\nexport function addEquivalentProjections(projections) {\n addProjections(projections);\n projections.forEach(function (source) {\n projections.forEach(function (destination) {\n if (source !== destination) {\n addTransformFunc(source, destination, cloneTransform);\n }\n });\n });\n}\n\n/**\n * Registers transformation functions to convert coordinates in any projection\n * in projection1 to any projection in projection2.\n *\n * @param {Array} projections1 Projections with equal\n * meaning.\n * @param {Array} projections2 Projections with equal\n * meaning.\n * @param {TransformFunction} forwardTransform Transformation from any\n * projection in projection1 to any projection in projection2.\n * @param {TransformFunction} inverseTransform Transform from any projection\n * in projection2 to any projection in projection1..\n */\nexport function addEquivalentTransforms(\n projections1,\n projections2,\n forwardTransform,\n inverseTransform,\n) {\n projections1.forEach(function (projection1) {\n projections2.forEach(function (projection2) {\n addTransformFunc(projection1, projection2, forwardTransform);\n addTransformFunc(projection2, projection1, inverseTransform);\n });\n });\n}\n\n/**\n * Clear all cached projections and transforms.\n */\nexport function clearAllProjections() {\n clearProj();\n clearTransformFuncs();\n}\n\n/**\n * @param {Projection|string|undefined} projection Projection.\n * @param {string} defaultCode Default code.\n * @return {Projection} Projection.\n */\nexport function createProjection(projection, defaultCode) {\n if (!projection) {\n return get(defaultCode);\n }\n if (typeof projection === 'string') {\n return get(projection);\n }\n return /** @type {Projection} */ (projection);\n}\n\n/**\n * Creates a {@link module:ol/proj~TransformFunction} from a simple 2D coordinate transform\n * function.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} coordTransform Coordinate\n * transform.\n * @return {TransformFunction} Transform function.\n */\nexport function createTransformFromCoordinateTransform(coordTransform) {\n return (\n /**\n * @param {Array} input Input.\n * @param {Array} [output] Output.\n * @param {number} [dimension] Dimensions that should be transformed.\n * @param {number} [stride] Stride.\n * @return {Array} Output.\n */\n function (input, output, dimension, stride) {\n const length = input.length;\n dimension = dimension !== undefined ? dimension : 2;\n stride = stride ?? dimension;\n output = output !== undefined ? output : new Array(length);\n for (let i = 0; i < length; i += stride) {\n const point = coordTransform(input.slice(i, i + dimension));\n const pointLength = point.length;\n for (let j = 0, jj = stride; j < jj; ++j) {\n output[i + j] = j >= pointLength ? input[i + j] : point[j];\n }\n }\n return output;\n }\n );\n}\n\n/**\n * Registers coordinate transform functions to convert coordinates between the\n * source projection and the destination projection.\n * The forward and inverse functions convert coordinate pairs; this function\n * converts these into the functions used internally which also handle\n * extents and coordinate arrays.\n *\n * @param {ProjectionLike} source Source projection.\n * @param {ProjectionLike} destination Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} forward The forward transform\n * function (that is, from the source projection to the destination\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} inverse The inverse transform\n * function (that is, from the destination projection to the source\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}. If the transform function can only\n * transform less dimensions than the input coordinate, it is supposeed to return a coordinate\n * with only the length it can transform. The other dimensions will be taken unchanged from the\n * source.\n * @api\n */\nexport function addCoordinateTransforms(source, destination, forward, inverse) {\n const sourceProj = get(source);\n const destProj = get(destination);\n addTransformFunc(\n sourceProj,\n destProj,\n createTransformFromCoordinateTransform(forward),\n );\n addTransformFunc(\n destProj,\n sourceProj,\n createTransformFromCoordinateTransform(inverse),\n );\n}\n\n/**\n * Transforms a coordinate from longitude/latitude to a different projection.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate as longitude and latitude, i.e.\n * an array with longitude as 1st and latitude as 2nd element.\n * @param {ProjectionLike} [projection] Target projection. The\n * default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate projected to the target projection.\n * @api\n */\nexport function fromLonLat(coordinate, projection) {\n disableCoordinateWarning();\n return transform(\n coordinate,\n 'EPSG:4326',\n projection !== undefined ? projection : 'EPSG:3857',\n );\n}\n\n/**\n * Transforms a coordinate to longitude/latitude.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Projected coordinate.\n * @param {ProjectionLike} [projection] Projection of the coordinate.\n * The default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate as longitude and latitude, i.e. an array\n * with longitude as 1st and latitude as 2nd element.\n * @api\n */\nexport function toLonLat(coordinate, projection) {\n const lonLat = transform(\n coordinate,\n projection !== undefined ? projection : 'EPSG:3857',\n 'EPSG:4326',\n );\n const lon = lonLat[0];\n if (lon < -180 || lon > 180) {\n lonLat[0] = modulo(lon + 180, 360) - 180;\n }\n return lonLat;\n}\n\n/**\n * Checks if two projections are the same, that is every coordinate in one\n * projection does represent the same geographic point as the same coordinate in\n * the other projection.\n *\n * @param {Projection} projection1 Projection 1.\n * @param {Projection} projection2 Projection 2.\n * @return {boolean} Equivalent.\n * @api\n */\nexport function equivalent(projection1, projection2) {\n if (projection1 === projection2) {\n return true;\n }\n const equalUnits = projection1.getUnits() === projection2.getUnits();\n if (projection1.getCode() === projection2.getCode()) {\n return equalUnits;\n }\n const transformFunc = getTransformFromProjections(projection1, projection2);\n return transformFunc === cloneTransform && equalUnits;\n}\n\n/**\n * Searches in the list of transform functions for the function for converting\n * coordinates from the source projection to the destination projection.\n *\n * @param {Projection} source Source Projection object.\n * @param {Projection} destination Destination Projection\n * object.\n * @return {TransformFunction|null} Transform function.\n */\nexport function getTransformFromProjections(source, destination) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n let transformFunc = getTransformFunc(sourceCode, destinationCode);\n if (transformFunc) {\n return transformFunc;\n }\n\n /**\n * @type {Transforms|null}\n */\n let sourceTransforms = null;\n\n /**\n * @type {Transforms|null}\n */\n let destinationTransforms = null;\n\n // lazily add projections if we have supported transforms\n for (const makeTransforms of transformFactories) {\n if (!sourceTransforms) {\n sourceTransforms = makeTransforms(source);\n }\n if (!destinationTransforms) {\n destinationTransforms = makeTransforms(destination);\n }\n }\n\n if (!sourceTransforms && !destinationTransforms) {\n return null;\n }\n\n const intermediateCode = 'EPSG:4326';\n if (!destinationTransforms) {\n const toDestination = getTransformFunc(intermediateCode, destinationCode);\n if (toDestination) {\n transformFunc = composeTransformFuncs(\n sourceTransforms.inverse,\n toDestination,\n );\n }\n } else if (!sourceTransforms) {\n const fromSource = getTransformFunc(sourceCode, intermediateCode);\n if (fromSource) {\n transformFunc = composeTransformFuncs(\n fromSource,\n destinationTransforms.forward,\n );\n }\n } else {\n transformFunc = composeTransformFuncs(\n sourceTransforms.inverse,\n destinationTransforms.forward,\n );\n }\n\n if (transformFunc) {\n addProjection(source);\n addProjection(destination);\n addTransformFunc(source, destination, transformFunc);\n }\n\n return transformFunc;\n}\n\n/**\n * @param {TransformFunction} t1 The first transform function.\n * @param {TransformFunction} t2 The second transform function.\n * @return {TransformFunction} The composed transform function.\n */\nfunction composeTransformFuncs(t1, t2) {\n return function (input, output, dimensions, stride) {\n output = t1(input, output, dimensions, stride);\n return t2(output, output, dimensions, stride);\n };\n}\n\n/**\n * Given the projection-like objects, searches for a transformation\n * function to convert a coordinates array from the source projection to the\n * destination projection.\n *\n * @param {ProjectionLike} source Source.\n * @param {ProjectionLike} destination Destination.\n * @return {TransformFunction} Transform function.\n * @api\n */\nexport function getTransform(source, destination) {\n const sourceProjection = get(source);\n const destinationProjection = get(destination);\n return getTransformFromProjections(sourceProjection, destinationProjection);\n}\n\n/**\n * Transforms a coordinate from source projection to destination projection.\n * This returns a new coordinate (and does not modify the original). If there\n * is no available transform between the two projection, the function will throw\n * an error.\n *\n * See {@link module:ol/proj.transformExtent} for extent transformation.\n * See the transform method of {@link module:ol/geom/Geometry~Geometry} and its\n * subclasses for geometry transforms.\n *\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate.\n * @api\n */\nexport function transform(coordinate, source, destination) {\n const transformFunc = getTransform(source, destination);\n if (!transformFunc) {\n const sourceCode = get(source).getCode();\n const destinationCode = get(destination).getCode();\n throw new Error(\n `No transform available between ${sourceCode} and ${destinationCode}`,\n );\n }\n return transformFunc(coordinate, undefined, coordinate.length);\n}\n\n/**\n * Transforms an extent from source projection to destination projection. This\n * returns a new extent (and does not modify the original).\n *\n * @param {import(\"./extent.js\").Extent} extent The extent to transform.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {import(\"./extent.js\").Extent} The transformed extent.\n * @api\n */\nexport function transformExtent(extent, source, destination, stops) {\n const transformFunc = getTransform(source, destination);\n return applyTransform(extent, transformFunc, undefined, stops);\n}\n\n/**\n * Transforms the given point to the destination projection.\n *\n * @param {import(\"./coordinate.js\").Coordinate} point Point.\n * @param {Projection} sourceProjection Source projection.\n * @param {Projection} destinationProjection Destination projection.\n * @return {import(\"./coordinate.js\").Coordinate} Point.\n */\nexport function transformWithProjections(\n point,\n sourceProjection,\n destinationProjection,\n) {\n const transformFunc = getTransformFromProjections(\n sourceProjection,\n destinationProjection,\n );\n return transformFunc(point);\n}\n\n/**\n * @type {Projection|null}\n */\nlet userProjection = null;\n\n/**\n * Set the projection for coordinates supplied from and returned by API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @param {ProjectionLike} projection The user projection.\n * @api\n */\nexport function setUserProjection(projection) {\n userProjection = get(projection);\n}\n\n/**\n * Clear the user projection if set.\n * @api\n */\nexport function clearUserProjection() {\n userProjection = null;\n}\n\n/**\n * Get the projection for coordinates supplied from and returned by API methods.\n * @return {Projection|null} The user projection (or null if not set).\n * @api\n */\nexport function getUserProjection() {\n return userProjection;\n}\n\n/**\n * Use geographic coordinates (WGS-84 datum) in API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @api\n */\nexport function useGeographic() {\n setUserProjection('EPSG:4326');\n}\n\n/**\n * Return a coordinate transformed into the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} sourceProjection The input coordinate projection.\n * @return {Array} The input coordinate in the user projection.\n */\nexport function toUserCoordinate(coordinate, sourceProjection) {\n if (!userProjection) {\n return coordinate;\n }\n return transform(coordinate, sourceProjection, userProjection);\n}\n\n/**\n * Return a coordinate transformed from the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {Array} The input coordinate transformed.\n */\nexport function fromUserCoordinate(coordinate, destProjection) {\n if (!userProjection) {\n if (\n showCoordinateWarning &&\n !equals(coordinate, [0, 0]) &&\n coordinate[0] >= -180 &&\n coordinate[0] <= 180 &&\n coordinate[1] >= -90 &&\n coordinate[1] <= 90\n ) {\n showCoordinateWarning = false;\n warn(\n 'Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.',\n );\n }\n return coordinate;\n }\n return transform(coordinate, userProjection, destProjection);\n}\n\n/**\n * Return an extent transformed into the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} sourceProjection The input extent projection.\n * @return {import(\"./extent.js\").Extent} The input extent in the user projection.\n */\nexport function toUserExtent(extent, sourceProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, sourceProjection, userProjection);\n}\n\n/**\n * Return an extent transformed from the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {import(\"./extent.js\").Extent} The input extent transformed.\n */\nexport function fromUserExtent(extent, destProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, userProjection, destProjection);\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in input projection units per pixel.\n * @param {ProjectionLike} sourceProjection The input projection.\n * @return {number} Resolution in user projection units per pixel.\n */\nexport function toUserResolution(resolution, sourceProjection) {\n if (!userProjection) {\n return resolution;\n }\n const sourceMetersPerUnit = get(sourceProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return sourceMetersPerUnit && userMetersPerUnit\n ? (resolution * sourceMetersPerUnit) / userMetersPerUnit\n : resolution;\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in user projection units per pixel.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {number} Resolution in destination projection units per pixel.\n */\nexport function fromUserResolution(resolution, destProjection) {\n if (!userProjection) {\n return resolution;\n }\n const destMetersPerUnit = get(destProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return destMetersPerUnit && userMetersPerUnit\n ? (resolution * userMetersPerUnit) / destMetersPerUnit\n : resolution;\n}\n\n/**\n * Creates a safe coordinate transform function from a coordinate transform function.\n * \"Safe\" means that it can handle wrapping of x-coordinates for global projections,\n * and that coordinates exceeding the source projection validity extent's range will be\n * clamped to the validity range.\n * @param {Projection} sourceProj Source projection.\n * @param {Projection} destProj Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} transform Transform function (source to destination).\n * @return {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} Safe transform function (source to destination).\n */\nexport function createSafeCoordinateTransform(sourceProj, destProj, transform) {\n return function (coord) {\n let transformed, worldsAway;\n if (sourceProj.canWrapX()) {\n const sourceExtent = sourceProj.getExtent();\n const sourceExtentWidth = getWidth(sourceExtent);\n coord = coord.slice(0);\n worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);\n if (worldsAway) {\n // Move x to the real world\n coord[0] = coord[0] - worldsAway * sourceExtentWidth;\n }\n coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);\n coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);\n transformed = transform(coord);\n } else {\n transformed = transform(coord);\n }\n if (worldsAway && destProj.canWrapX()) {\n // Move transformed coordinate back to the offset world\n transformed[0] += worldsAway * getWidth(destProj.getExtent());\n }\n return transformed;\n };\n}\n\n/**\n * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called\n * by when this module is executed and should only need to be called again after\n * `clearAllProjections()` is called (e.g. in tests).\n */\nexport function addCommon() {\n // Add transformations that don't alter coordinates to convert within set of\n // projections with equal meaning.\n addEquivalentProjections(EPSG3857_PROJECTIONS);\n addEquivalentProjections(EPSG4326_PROJECTIONS);\n // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like\n // coordinates and back.\n addEquivalentTransforms(\n EPSG4326_PROJECTIONS,\n EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n );\n}\n\naddCommon();\n","/**\n * @module ol/transform\n */\nimport {assert} from './asserts.js';\n\n/**\n * An array representing an affine 2d transformation for use with\n * {@link module:ol/transform} functions. The array has 6 elements.\n * @typedef {!Array} Transform\n * @api\n */\n\n/**\n * Collection of affine 2d transformation functions. The functions work on an\n * array of 6 elements. The element order is compatible with the [SVGMatrix\n * interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) and is\n * a subset (elements a to f) of a 3×3 matrix:\n * ```\n * [ a c e ]\n * [ b d f ]\n * [ 0 0 1 ]\n * ```\n */\n\n/**\n * @private\n * @type {Transform}\n */\nconst tmp_ = new Array(6);\n\n/**\n * Create an identity transform.\n * @return {!Transform} Identity transform.\n */\nexport function create() {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/**\n * Resets the given transform to an identity transform.\n * @param {!Transform} transform Transform.\n * @return {!Transform} Transform.\n */\nexport function reset(transform) {\n return set(transform, 1, 0, 0, 1, 0, 0);\n}\n\n/**\n * Multiply the underlying matrices of two transforms and return the result in\n * the first transform.\n * @param {!Transform} transform1 Transform parameters of matrix 1.\n * @param {!Transform} transform2 Transform parameters of matrix 2.\n * @return {!Transform} transform1 multiplied with transform2.\n */\nexport function multiply(transform1, transform2) {\n const a1 = transform1[0];\n const b1 = transform1[1];\n const c1 = transform1[2];\n const d1 = transform1[3];\n const e1 = transform1[4];\n const f1 = transform1[5];\n const a2 = transform2[0];\n const b2 = transform2[1];\n const c2 = transform2[2];\n const d2 = transform2[3];\n const e2 = transform2[4];\n const f2 = transform2[5];\n\n transform1[0] = a1 * a2 + c1 * b2;\n transform1[1] = b1 * a2 + d1 * b2;\n transform1[2] = a1 * c2 + c1 * d2;\n transform1[3] = b1 * c2 + d1 * d2;\n transform1[4] = a1 * e2 + c1 * f2 + e1;\n transform1[5] = b1 * e2 + d1 * f2 + f1;\n\n return transform1;\n}\n\n/**\n * Set the transform components a-f on a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} a The a component of the transform.\n * @param {number} b The b component of the transform.\n * @param {number} c The c component of the transform.\n * @param {number} d The d component of the transform.\n * @param {number} e The e component of the transform.\n * @param {number} f The f component of the transform.\n * @return {!Transform} Matrix with transform applied.\n */\nexport function set(transform, a, b, c, d, e, f) {\n transform[0] = a;\n transform[1] = b;\n transform[2] = c;\n transform[3] = d;\n transform[4] = e;\n transform[5] = f;\n return transform;\n}\n\n/**\n * Set transform on one matrix from another matrix.\n * @param {!Transform} transform1 Matrix to set transform to.\n * @param {!Transform} transform2 Matrix to set transform from.\n * @return {!Transform} transform1 with transform from transform2 applied.\n */\nexport function setFromArray(transform1, transform2) {\n transform1[0] = transform2[0];\n transform1[1] = transform2[1];\n transform1[2] = transform2[2];\n transform1[3] = transform2[3];\n transform1[4] = transform2[4];\n transform1[5] = transform2[5];\n return transform1;\n}\n\n/**\n * Transforms the given coordinate with the given transform returning the\n * resulting, transformed coordinate. The coordinate will be modified in-place.\n *\n * @param {Transform} transform The transformation.\n * @param {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} coordinate The coordinate to transform.\n * @return {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} return coordinate so that operations can be\n * chained together.\n */\nexport function apply(transform, coordinate) {\n const x = coordinate[0];\n const y = coordinate[1];\n coordinate[0] = transform[0] * x + transform[2] * y + transform[4];\n coordinate[1] = transform[1] * x + transform[3] * y + transform[5];\n return coordinate;\n}\n\n/**\n * Applies rotation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} angle Angle in radians.\n * @return {!Transform} The rotated transform.\n */\nexport function rotate(transform, angle) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return multiply(transform, set(tmp_, cos, sin, -sin, cos, 0, 0));\n}\n\n/**\n * Applies scale to a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scaled transform.\n */\nexport function scale(transform, x, y) {\n return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));\n}\n\n/**\n * Creates a scale transform.\n * @param {!Transform} target Transform to overwrite.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scale transform.\n */\nexport function makeScale(target, x, y) {\n return set(target, x, 0, 0, y, 0, 0);\n}\n\n/**\n * Applies translation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} dx Translation x.\n * @param {number} dy Translation y.\n * @return {!Transform} The translated transform.\n */\nexport function translate(transform, dx, dy) {\n return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative).\n * @param {!Transform} transform The transform (will be modified in place).\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {!Transform} The composite transform.\n */\nexport function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n transform[0] = sx * cos;\n transform[1] = sy * sin;\n transform[2] = -sx * sin;\n transform[3] = sy * cos;\n transform[4] = dx2 * sx * cos - dy2 * sx * sin + dx1;\n transform[5] = dx2 * sy * sin + dy2 * sy * cos + dy1;\n return transform;\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative). The resulting transform\n * string can be applied as `transform` property of an HTMLElement's style.\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {string} The composite css transform.\n * @api\n */\nexport function composeCssTransform(dx1, dy1, sx, sy, angle, dx2, dy2) {\n return toString(compose(create(), dx1, dy1, sx, sy, angle, dx2, dy2));\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (source) transform.\n */\nexport function invert(source) {\n return makeInverse(source, source);\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} target Transform to be set as the inverse of\n * the source transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (target) transform.\n */\nexport function makeInverse(target, source) {\n const det = determinant(source);\n assert(det !== 0, 'Transformation matrix cannot be inverted');\n\n const a = source[0];\n const b = source[1];\n const c = source[2];\n const d = source[3];\n const e = source[4];\n const f = source[5];\n\n target[0] = d / det;\n target[1] = -b / det;\n target[2] = -c / det;\n target[3] = a / det;\n target[4] = (c * f - d * e) / det;\n target[5] = -(a * f - b * e) / det;\n\n return target;\n}\n\n/**\n * Returns the determinant of the given matrix.\n * @param {!Transform} mat Matrix.\n * @return {number} Determinant.\n */\nexport function determinant(mat) {\n return mat[0] * mat[3] - mat[1] * mat[2];\n}\n\n/**\n * @type {Array}\n */\nconst matrixPrecision = [1e5, 1e5, 1e5, 1e5, 2, 2];\n\n/**\n * A matrix string version of the transform. This can be used\n * for CSS transforms.\n * @param {!Transform} mat Matrix.\n * @return {string} The transform as a string.\n */\nexport function toString(mat) {\n const transformString = 'matrix(' + mat.join(', ') + ')';\n return transformString;\n}\n\n/**\n * Create a transform from a CSS transform matrix string.\n * @param {string} cssTransform The CSS string to parse.\n * @return {!Transform} The transform.\n */\nexport function fromString(cssTransform) {\n const values = cssTransform.substring(7, cssTransform.length - 1).split(',');\n return values.map(parseFloat);\n}\n\n/**\n * Compare two matrices for equality.\n * @param {!string} cssTransform1 A CSS transform matrix string.\n * @param {!string} cssTransform2 A CSS transform matrix string.\n * @return {boolean} The two matrices are equal.\n */\nexport function equivalent(cssTransform1, cssTransform2) {\n const mat1 = fromString(cssTransform1);\n const mat2 = fromString(cssTransform2);\n for (let i = 0; i < 6; ++i) {\n if (Math.round((mat1[i] - mat2[i]) * matrixPrecision[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n","/**\n * @module ol/geom/flat/transform\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @param {number} [destinationStride] Stride of destination coordinates; if unspecified, assumed to be 2.\n * @return {Array} Transformed coordinates.\n */\nexport function transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n transform,\n dest,\n destinationStride,\n) {\n dest = dest ? dest : [];\n destinationStride = destinationStride ? destinationStride : 2;\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const x = flatCoordinates[j];\n const y = flatCoordinates[j + 1];\n dest[i++] = transform[0] * x + transform[2] * y + transform[4];\n dest[i++] = transform[1] * x + transform[3] * y + transform[5];\n\n for (let k = 2; k < destinationStride; k++) {\n dest[i++] = flatCoordinates[j + k];\n }\n }\n\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} angle Angle.\n * @param {Array} anchor Rotation anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function rotate(\n flatCoordinates,\n offset,\n end,\n stride,\n angle,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + deltaX * cos - deltaY * sin;\n dest[i++] = anchorY + deltaX * sin + deltaY * cos;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Scale the coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} sx Scale factor in the x-direction.\n * @param {number} sy Scale factor in the y-direction.\n * @param {Array} anchor Scale anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function scale(\n flatCoordinates,\n offset,\n end,\n stride,\n sx,\n sy,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + sx * deltaX;\n dest[i++] = anchorY + sy * deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function translate(\n flatCoordinates,\n offset,\n end,\n stride,\n deltaX,\n deltaY,\n dest,\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n dest[i++] = flatCoordinates[j] + deltaX;\n dest[i++] = flatCoordinates[j + 1] + deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n","/**\n * @module ol/geom/Geometry\n */\nimport BaseObject from '../Object.js';\nimport {\n createEmpty,\n createOrUpdateEmpty,\n getHeight,\n returnOrUpdate,\n} from '../extent.js';\nimport {memoizeOne} from '../functions.js';\nimport {get as getProjection, getTransform} from '../proj.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\nimport {abstract} from '../util.js';\nimport {transform2D} from './flat/transform.js';\n\n/**\n * @typedef {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout\n * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')\n * or measure ('M') coordinate is available.\n */\n\n/**\n * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type\n * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,\n * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,\n * `'GeometryCollection'`, or `'Circle'`.\n */\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/** @type {import('../coordinate.js').Coordinate} */\nconst tmpPoint = [NaN, NaN];\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for vector geometries.\n *\n * To get notified of changes to the geometry, register a listener for the\n * generic `change` event on your geometry instance.\n *\n * @abstract\n * @api\n */\nclass Geometry extends BaseObject {\n constructor() {\n super();\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = createEmpty();\n\n /**\n * @private\n * @type {number}\n */\n this.extentRevision_ = -1;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryRevision = 0;\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} revision The geometry revision.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n this.simplifyTransformedInternal = memoizeOne(\n (revision, squaredTolerance, transform) => {\n if (!transform) {\n return this.getSimplifiedGeometry(squaredTolerance);\n }\n const clone = this.clone();\n clone.applyTransform(transform);\n return clone.getSimplifiedGeometry(squaredTolerance);\n },\n );\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this.simplifyTransformedInternal(\n this.getRevision(),\n squaredTolerance,\n transform,\n );\n }\n\n /**\n * Make a complete copy of the geometry.\n * @abstract\n * @return {!Geometry} Clone.\n */\n clone() {\n return abstract();\n }\n\n /**\n * @abstract\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n return abstract();\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n return this.closestPointXY(x, y, tmpPoint, Number.MIN_VALUE) === 0;\n }\n\n /**\n * Return the closest point of the geometry to the passed point as\n * {@link module:ol/coordinate~Coordinate coordinate}.\n * @param {import(\"../coordinate.js\").Coordinate} point Point.\n * @param {import(\"../coordinate.js\").Coordinate} [closestPoint] Closest point.\n * @return {import(\"../coordinate.js\").Coordinate} Closest point.\n * @api\n */\n getClosestPoint(point, closestPoint) {\n closestPoint = closestPoint ? closestPoint : [NaN, NaN];\n this.closestPointXY(point[0], point[1], closestPoint, Infinity);\n return closestPoint;\n }\n\n /**\n * Returns true if this geometry includes the specified coordinate. If the\n * coordinate is on the boundary of the geometry, returns false.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains coordinate.\n * @api\n */\n intersectsCoordinate(coordinate) {\n return this.containsXY(coordinate[0], coordinate[1]);\n }\n\n /**\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return abstract();\n }\n\n /**\n * Get the extent of the geometry.\n * @param {import(\"../extent.js\").Extent} [extent] Extent.\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n getExtent(extent) {\n if (this.extentRevision_ != this.getRevision()) {\n const extent = this.computeExtent(this.extent_);\n if (isNaN(extent[0]) || isNaN(extent[1])) {\n createOrUpdateEmpty(extent);\n }\n this.extentRevision_ = this.getRevision();\n }\n return returnOrUpdate(this.extent_, extent);\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} angle Rotation angle in radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n abstract();\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n abstract();\n }\n\n /**\n * Create a simplified version of this geometry. For linestrings, this uses\n * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)\n * algorithm. For polygons, a quantization-based\n * simplification is used to preserve topology.\n * @param {number} tolerance The tolerance distance for simplification.\n * @return {Geometry} A new, simplified version of the original geometry.\n * @api\n */\n simplify(tolerance) {\n return this.getSimplifiedGeometry(tolerance * tolerance);\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker\n * algorithm.\n * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Geometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return abstract();\n }\n\n /**\n * Get the type of this geometry.\n * @abstract\n * @return {Type} Geometry type.\n */\n getType() {\n return abstract();\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @abstract\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n */\n applyTransform(transformFn) {\n abstract();\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n */\n intersectsExtent(extent) {\n return abstract();\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @abstract\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n abstract();\n }\n\n /**\n * Transform each coordinate of the geometry from one coordinate reference\n * system to another. The geometry is modified in place.\n * For example, a line will be transformed to a line and a circle to a circle.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n *\n * @param {import(\"../proj.js\").ProjectionLike} source The current projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @param {import(\"../proj.js\").ProjectionLike} destination The desired projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @return {this} This geometry. Note that original geometry is\n * modified in place.\n * @api\n */\n transform(source, destination) {\n /** @type {import(\"../proj/Projection.js\").default} */\n const sourceProj = getProjection(source);\n const transformFn =\n sourceProj.getUnits() == 'tile-pixels'\n ? function (inCoordinates, outCoordinates, stride) {\n const pixelExtent = sourceProj.getExtent();\n const projectedExtent = sourceProj.getWorldExtent();\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0,\n );\n const transformed = transform2D(\n inCoordinates,\n 0,\n inCoordinates.length,\n stride,\n tmpTransform,\n outCoordinates,\n );\n const projTransform = getTransform(sourceProj, destination);\n if (projTransform) {\n return projTransform(transformed, transformed, stride);\n }\n return transformed;\n }\n : getTransform(sourceProj, destination);\n this.applyTransform(transformFn);\n return this;\n }\n}\n\nexport default Geometry;\n","/**\n * @module ol/geom/SimpleGeometry\n */\nimport {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';\nimport {abstract} from '../util.js';\nimport Geometry from './Geometry.js';\nimport {rotate, scale, transform2D, translate} from './flat/transform.js';\n\n/**\n * @classdesc\n * Abstract base class; only used for creating subclasses; do not instantiate\n * in apps, as cannot be rendered.\n *\n * @abstract\n * @api\n */\nclass SimpleGeometry extends Geometry {\n constructor() {\n super();\n\n /**\n * @protected\n * @type {import(\"./Geometry.js\").GeometryLayout}\n */\n this.layout = 'XY';\n\n /**\n * @protected\n * @type {number}\n */\n this.stride = 2;\n\n /**\n * @protected\n * @type {Array}\n */\n this.flatCoordinates;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @override\n */\n computeExtent(extent) {\n return createOrUpdateFromFlatCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent,\n );\n }\n\n /**\n * @abstract\n * @return {Array<*> | null} Coordinates.\n */\n getCoordinates() {\n return abstract();\n }\n\n /**\n * Return the first coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} First coordinate.\n * @api\n */\n getFirstCoordinate() {\n return this.flatCoordinates.slice(0, this.stride);\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getFlatCoordinates() {\n return this.flatCoordinates;\n }\n\n /**\n * Return the last coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} Last point.\n * @api\n */\n getLastCoordinate() {\n return this.flatCoordinates.slice(\n this.flatCoordinates.length - this.stride,\n );\n }\n\n /**\n * Return the {@link import(\"./Geometry.js\").GeometryLayout layout} of the geometry.\n * @return {import(\"./Geometry.js\").GeometryLayout} Layout.\n * @api\n */\n getLayout() {\n return this.layout;\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker algorithm.\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n * @override\n */\n getSimplifiedGeometry(squaredTolerance) {\n if (this.simplifiedGeometryRevision !== this.getRevision()) {\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n this.simplifiedGeometryRevision = this.getRevision();\n }\n // If squaredTolerance is negative or if we know that simplification will not\n // have any effect then just return this.\n if (\n squaredTolerance < 0 ||\n (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&\n squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)\n ) {\n return this;\n }\n\n const simplifiedGeometry =\n this.getSimplifiedGeometryInternal(squaredTolerance);\n const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();\n if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {\n return simplifiedGeometry;\n }\n // Simplification did not actually remove any coordinates. We now know\n // that any calls to getSimplifiedGeometry with a squaredTolerance less\n // than or equal to the current squaredTolerance will also not have any\n // effect. This allows us to short circuit simplification (saving CPU\n // cycles) and prevents the cache of simplified geometries from filling\n // up with useless identical copies of this geometry (saving memory).\n this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n return this;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return this.stride;\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @param {Array} flatCoordinates Flat coordinates.\n */\n setFlatCoordinates(layout, flatCoordinates) {\n this.stride = getStrideForLayout(layout);\n this.layout = layout;\n this.flatCoordinates = flatCoordinates;\n }\n\n /**\n * @abstract\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n setCoordinates(coordinates, layout) {\n abstract();\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout|undefined} layout Layout.\n * @param {Array<*>} coordinates Coordinates.\n * @param {number} nesting Nesting.\n * @protected\n */\n setLayout(layout, coordinates, nesting) {\n let stride;\n if (layout) {\n stride = getStrideForLayout(layout);\n } else {\n for (let i = 0; i < nesting; ++i) {\n if (coordinates.length === 0) {\n this.layout = 'XY';\n this.stride = 2;\n return;\n }\n coordinates = /** @type {Array} */ (coordinates[0]);\n }\n stride = coordinates.length;\n layout = getLayoutForStride(stride);\n }\n this.layout = layout;\n this.stride = stride;\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n * @api\n * @override\n */\n applyTransform(transformFn) {\n if (this.flatCoordinates) {\n transformFn(\n this.flatCoordinates,\n this.flatCoordinates,\n this.layout.startsWith('XYZ') ? 3 : 2,\n this.stride,\n );\n this.changed();\n }\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @param {number} angle Rotation angle in counter-clockwise radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n * @override\n */\n rotate(angle, anchor) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n rotate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n angle,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n * @override\n */\n scale(sx, sy, anchor) {\n if (sy === undefined) {\n sy = sx;\n }\n if (!anchor) {\n anchor = getCenter(this.getExtent());\n }\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n scale(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n sx,\n sy,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n * @override\n */\n translate(deltaX, deltaY) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n translate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n deltaX,\n deltaY,\n flatCoordinates,\n );\n this.changed();\n }\n }\n}\n\n/**\n * @param {number} stride Stride.\n * @return {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n */\nexport function getLayoutForStride(stride) {\n let layout;\n if (stride == 2) {\n layout = 'XY';\n } else if (stride == 3) {\n layout = 'XYZ';\n } else if (stride == 4) {\n layout = 'XYZM';\n }\n return /** @type {import(\"./Geometry.js\").GeometryLayout} */ (layout);\n}\n\n/**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @return {number} Stride.\n */\nexport function getStrideForLayout(layout) {\n let stride;\n if (layout == 'XY') {\n stride = 2;\n } else if (layout == 'XYZ' || layout == 'XYM') {\n stride = 3;\n } else if (layout == 'XYZM') {\n stride = 4;\n }\n return /** @type {number} */ (stride);\n}\n\n/**\n * @param {SimpleGeometry} simpleGeometry Simple geometry.\n * @param {import(\"../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed flat coordinates.\n */\nexport function transformGeom2D(simpleGeometry, transform, dest) {\n const flatCoordinates = simpleGeometry.getFlatCoordinates();\n if (!flatCoordinates) {\n return null;\n }\n const stride = simpleGeometry.getStride();\n return transform2D(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n transform,\n dest,\n );\n}\n\nexport default SimpleGeometry;\n","/**\n * @module ol/geom/flat/area\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRing(flatCoordinates, offset, end, stride) {\n let twiceArea = 0;\n const x0 = flatCoordinates[end - stride];\n const y0 = flatCoordinates[end - stride + 1];\n let dx1 = 0;\n let dy1 = 0;\n for (; offset < end; offset += stride) {\n const dx2 = flatCoordinates[offset] - x0;\n const dy2 = flatCoordinates[offset + 1] - y0;\n twiceArea += dy1 * dx2 - dx1 * dy2;\n dx1 = dx2;\n dy1 = dy2;\n }\n return twiceArea / 2;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRings(flatCoordinates, offset, ends, stride) {\n let area = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n area += linearRing(flatCoordinates, offset, end, stride);\n offset = end;\n }\n return area;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n let area = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n area += linearRings(flatCoordinates, offset, ends, stride);\n offset = ends[ends.length - 1];\n }\n return area;\n}\n","/**\n * @module ol/geom/flat/closest\n */\nimport {lerp, squaredDistance as squaredDx} from '../../math.js';\n\n/**\n * Returns the point on the 2D line segment flatCoordinates[offset1] to\n * flatCoordinates[offset2] that is closest to the point (x, y). Extra\n * dimensions are linearly interpolated.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset1 Offset 1.\n * @param {number} offset2 Offset 2.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n */\nfunction assignClosest(\n flatCoordinates,\n offset1,\n offset2,\n stride,\n x,\n y,\n closestPoint,\n) {\n const x1 = flatCoordinates[offset1];\n const y1 = flatCoordinates[offset1 + 1];\n const dx = flatCoordinates[offset2] - x1;\n const dy = flatCoordinates[offset2 + 1] - y1;\n let offset;\n if (dx === 0 && dy === 0) {\n offset = offset1;\n } else {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n offset = offset2;\n } else if (t > 0) {\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = lerp(\n flatCoordinates[offset1 + i],\n flatCoordinates[offset2 + i],\n t,\n );\n }\n closestPoint.length = stride;\n return;\n } else {\n offset = offset1;\n }\n }\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n}\n\n/**\n * Return the squared of the largest distance between any pair of consecutive\n * coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n for (offset += stride; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n const squaredDelta = squaredDx(x1, y1, x2, y2);\n if (squaredDelta > max) {\n max = squaredDelta;\n }\n x1 = x2;\n y1 = y2;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function arrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n ends,\n stride,\n max,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n max = maxSquaredDelta(flatCoordinates, offset, end, stride, max);\n offset = end;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function multiArrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n endss,\n stride,\n max,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n max = arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max);\n offset = ends[ends.length - 1];\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n if (offset == end) {\n return minSquaredDistance;\n }\n let i, squaredDistance;\n if (maxDelta === 0) {\n // All points are identical, so just test the first point.\n squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[offset],\n flatCoordinates[offset + 1],\n );\n if (squaredDistance < minSquaredDistance) {\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n let index = offset + stride;\n while (index < end) {\n assignClosest(\n flatCoordinates,\n index - stride,\n index,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n index += stride;\n } else {\n // Skip ahead multiple points, because we know that all the skipped\n // points cannot be any closer than the closest point we have found so\n // far. We know this because we know how close the current point is, how\n // close the closest point we have found so far is, and the maximum\n // distance between consecutive points. For example, if we're currently\n // at distance 10, the best we've found so far is 3, and that the maximum\n // distance between consecutive points is 2, then we'll need to skip at\n // least (10 - 3) / 2 == 3 (rounded down) points to have any chance of\n // finding a closer point. We use Math.max(..., 1) to ensure that we\n // always advance at least one point, to avoid an infinite loop.\n index +=\n stride *\n Math.max(\n ((Math.sqrt(squaredDistance) - Math.sqrt(minSquaredDistance)) /\n maxDelta) |\n 0,\n 1,\n );\n }\n }\n if (isRing) {\n // Check the closing segment.\n assignClosest(\n flatCoordinates,\n end - stride,\n offset,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n minSquaredDistance = assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = end;\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestMultiArrayPoint(\n flatCoordinates,\n offset,\n endss,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n minSquaredDistance = assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = ends[ends.length - 1];\n }\n return minSquaredDistance;\n}\n","/**\n * @module ol/geom/flat/deflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {\n for (let i = 0, ii = coordinate.length; i < ii; ++i) {\n flatCoordinates[offset++] = coordinate[i];\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} coordinates Coordinates.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinates(\n flatCoordinates,\n offset,\n coordinates,\n stride,\n) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n const coordinate = coordinates[i];\n for (let j = 0; j < stride; ++j) {\n flatCoordinates[offset++] = coordinate[j];\n }\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} coordinatess Coordinatess.\n * @param {number} stride Stride.\n * @param {Array} [ends] Ends.\n * @return {Array} Ends.\n */\nexport function deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatess,\n stride,\n ends,\n) {\n ends = ends ? ends : [];\n let i = 0;\n for (let j = 0, jj = coordinatess.length; j < jj; ++j) {\n const end = deflateCoordinates(\n flatCoordinates,\n offset,\n coordinatess[j],\n stride,\n );\n ends[i++] = end;\n offset = end;\n }\n ends.length = i;\n return ends;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>>} coordinatesss Coordinatesss.\n * @param {number} stride Stride.\n * @param {Array>} [endss] Endss.\n * @return {Array>} Endss.\n */\nexport function deflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss,\n stride,\n endss,\n) {\n endss = endss ? endss : [];\n let i = 0;\n for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {\n const ends = deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss[j],\n stride,\n endss[i],\n );\n if (ends.length === 0) {\n ends[0] = offset;\n }\n endss[i++] = ends;\n offset = ends[ends.length - 1];\n }\n endss.length = i;\n return endss;\n}\n","/**\n * @module ol/geom/flat/inflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Array} [coordinates] Coordinates.\n * @return {Array} Coordinates.\n */\nexport function inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinates,\n) {\n coordinates = coordinates !== undefined ? coordinates : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n coordinates[i++] = flatCoordinates.slice(j, j + stride);\n }\n coordinates.length = i;\n return coordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array>} [coordinatess] Coordinatess.\n * @return {Array>} Coordinatess.\n */\nexport function inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatess,\n) {\n coordinatess = coordinatess !== undefined ? coordinatess : [];\n let i = 0;\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n coordinatess[i++] = inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinatess[i],\n );\n offset = end;\n }\n coordinatess.length = i;\n return coordinatess;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array>>} [coordinatesss]\n * Coordinatesss.\n * @return {Array>>} Coordinatesss.\n */\nexport function inflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n coordinatesss,\n) {\n coordinatesss = coordinatesss !== undefined ? coordinatesss : [];\n let i = 0;\n for (let j = 0, jj = endss.length; j < jj; ++j) {\n const ends = endss[j];\n coordinatesss[i++] =\n ends.length === 1 && ends[0] === offset\n ? []\n : inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatesss[i],\n );\n offset = ends[ends.length - 1];\n }\n coordinatesss.length = i;\n return coordinatesss;\n}\n","/**\n * @module ol/geom/flat/simplify\n */\n// Based on simplify-js https://github.com/mourner/simplify-js\n// Copyright (c) 2012, Vladimir Agafonkin\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n// POSSIBILITY OF SUCH DAMAGE.\n\nimport {squaredDistance, squaredSegmentDistance} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {boolean} highQuality Highest quality.\n * @param {Array} [simplifiedFlatCoordinates] Simplified flat\n * coordinates.\n * @return {Array} Simplified line string.\n */\nexport function simplifyLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n highQuality,\n simplifiedFlatCoordinates,\n) {\n simplifiedFlatCoordinates =\n simplifiedFlatCoordinates !== undefined ? simplifiedFlatCoordinates : [];\n if (!highQuality) {\n end = radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n flatCoordinates = simplifiedFlatCoordinates;\n offset = 0;\n stride = 2;\n }\n simplifiedFlatCoordinates.length = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return simplifiedFlatCoordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n const n = (end - offset) / stride;\n if (n < 3) {\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n /** @type {Array} */\n const markers = new Array(n);\n markers[0] = 1;\n markers[n - 1] = 1;\n /** @type {Array} */\n const stack = [offset, end - stride];\n let index = 0;\n while (stack.length > 0) {\n const last = stack.pop();\n const first = stack.pop();\n let maxSquaredDistance = 0;\n const x1 = flatCoordinates[first];\n const y1 = flatCoordinates[first + 1];\n const x2 = flatCoordinates[last];\n const y2 = flatCoordinates[last + 1];\n for (let i = first + stride; i < last; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n const squaredDistance = squaredSegmentDistance(x, y, x1, y1, x2, y2);\n if (squaredDistance > maxSquaredDistance) {\n index = i;\n maxSquaredDistance = squaredDistance;\n }\n }\n if (maxSquaredDistance > squaredTolerance) {\n markers[(index - offset) / stride] = 1;\n if (first + stride < index) {\n stack.push(first, index);\n }\n if (index + stride < last) {\n stack.push(index, last);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (markers[i]) {\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride + 1];\n }\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n if (end <= offset + stride) {\n // zero or one point, no simplification possible, so copy and return\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n // copy first point\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n let x2 = x1;\n let y2 = y1;\n for (offset += stride; offset < end; offset += stride) {\n x2 = flatCoordinates[offset];\n y2 = flatCoordinates[offset + 1];\n if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {\n // copy point at offset\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n }\n }\n if (x2 != x1 || y2 != y1) {\n // copy last point\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {number} value Value.\n * @param {number} tolerance Tolerance.\n * @return {number} Rounded value.\n */\nexport function snap(value, tolerance) {\n return tolerance * Math.round(value / tolerance);\n}\n\n/**\n * Simplifies a line string using an algorithm designed by Tim Schaub.\n * Coordinates are snapped to the nearest value in a virtual grid and\n * consecutive duplicate coordinates are discarded. This effectively preserves\n * topology as the simplification of any subsection of a line string is\n * independent of the rest of the line string. This means that, for examples,\n * the common edge between two polygons will be simplified to the same line\n * string independently in both polygons. This implementation uses a single\n * pass over the coordinates and eliminates intermediate collinear points.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n // do nothing if the line is empty\n if (offset == end) {\n return simplifiedOffset;\n }\n // snap the first coordinate (P1)\n let x1 = snap(flatCoordinates[offset], tolerance);\n let y1 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // add the first coordinate to the output\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n // find the next coordinate that does not snap to the same value as the first\n // coordinate (P2)\n let x2, y2;\n do {\n x2 = snap(flatCoordinates[offset], tolerance);\n y2 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n if (offset == end) {\n // all coordinates snap to the same value, the line collapses to a point\n // push the last snapped value anyway to ensure that the output contains\n // at least two points\n // FIXME should we really return at least two points anyway?\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n }\n } while (x2 == x1 && y2 == y1);\n while (offset < end) {\n // snap the next coordinate (P3)\n const x3 = snap(flatCoordinates[offset], tolerance);\n const y3 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // skip P3 if it is equal to P2\n if (x3 == x2 && y3 == y2) {\n continue;\n }\n // calculate the delta between P1 and P2\n const dx1 = x2 - x1;\n const dy1 = y2 - y1;\n // calculate the delta between P3 and P1\n const dx2 = x3 - x1;\n const dy2 = y3 - y1;\n // if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from\n // P1 in the same direction then P2 is on the straight line between P1 and\n // P3\n if (\n dx1 * dy2 == dy1 * dx2 &&\n ((dx1 < 0 && dx2 < dx1) || dx1 == dx2 || (dx1 > 0 && dx2 > dx1)) &&\n ((dy1 < 0 && dy2 < dy1) || dy1 == dy2 || (dy1 > 0 && dy2 > dy1))\n ) {\n // discard P2 and set P2 = P3\n x2 = x3;\n y2 = y3;\n continue;\n }\n // either P1, P2, and P3 are not colinear, or they are colinear but P3 is\n // between P3 and P1 or on the opposite half of the line to P2. add P2,\n // and continue with P1 = P2 and P2 = P3\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n x2 = x3;\n y2 = y3;\n }\n // add the last point (P2)\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function quantizeMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n","/**\n * @module ol/geom/LinearRing\n */\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {linearRing as linearRingArea} from './flat/area.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Linear ring geometry. Only used as part of polygon; cannot be rendered\n * on its own.\n *\n * @api\n */\nclass LinearRing extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LinearRing} Clone.\n * @api\n * @override\n */\n clone() {\n return new LinearRing(this.flatCoordinates.slice(), this.layout);\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Return the area of the linear ring on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingArea(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the coordinates of the linear ring.\n * @return {Array} Coordinates.\n * @api\n * @override\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LinearRing} Simplified LinearRing.\n * @protected\n * @override\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return new LinearRing(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'LinearRing';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return false;\n }\n\n /**\n * Set the coordinates of the linear ring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default LinearRing;\n","/**\n * @module ol/geom/Point\n */\nimport {containsXY, createOrUpdateFromCoordinate} from '../extent.js';\nimport {squaredDistance as squaredDx} from '../math.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {deflateCoordinate} from './flat/deflate.js';\n\n/**\n * @classdesc\n * Point geometry.\n *\n * @api\n */\nclass Point extends SimpleGeometry {\n /**\n * @param {import(\"../coordinate.js\").Coordinate} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n this.setCoordinates(coordinates, layout);\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Point} Clone.\n * @api\n * @override\n */\n clone() {\n const point = new Point(this.flatCoordinates.slice(), this.layout);\n point.applyProperties(this);\n return point;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n const flatCoordinates = this.flatCoordinates;\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[0],\n flatCoordinates[1],\n );\n if (squaredDistance < minSquaredDistance) {\n const stride = this.stride;\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinate of the point.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinates.\n * @api\n * @override\n */\n getCoordinates() {\n return this.flatCoordinates.slice();\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @override\n */\n computeExtent(extent) {\n return createOrUpdateFromCoordinate(this.flatCoordinates, extent);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'Point';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);\n }\n\n /**\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 0);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinate(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default Point;\n","/**\n * @module ol/geom/flat/contains\n */\nimport {forEachCorner} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} Contains extent.\n */\nexport function linearRingContainsExtent(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n const outside = forEachCorner(\n extent,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains (x, y).\n */\n function (coordinate) {\n return !linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinate[0],\n coordinate[1],\n );\n },\n );\n return !outside;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n x,\n y,\n) {\n // https://web.archive.org/web/20210504233957/http://geomalgorithms.com/a03-_inclusion.html\n // Copyright 2000 softSurfer, 2012 Dan Sunday\n // This code may be freely used and modified for any purpose\n // providing that this copyright notice is included with it.\n // SoftSurfer makes no warranty for this code, and cannot be held\n // liable for any real or imagined damage resulting from its use.\n // Users of this code must verify correctness for their application.\n let wn = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n if (y1 <= y) {\n if (y2 > y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) > 0) {\n wn++;\n }\n } else if (y2 <= y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) < 0) {\n wn--;\n }\n x1 = x2;\n y1 = y2;\n }\n return wn !== 0;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingsContainsXY(\n flatCoordinates,\n offset,\n ends,\n stride,\n x,\n y,\n) {\n if (ends.length === 0) {\n return false;\n }\n if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {\n return false;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingssContainsXY(\n flatCoordinates,\n offset,\n endss,\n stride,\n x,\n y,\n) {\n if (endss.length === 0) {\n return false;\n }\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/interiorpoint\n */\nimport {ascending} from '../../array.js';\nimport {linearRingsContainsXY} from './contains.js';\n\n/**\n * Calculates a point that is likely to lie in the interior of the linear rings.\n * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @param {number} flatCentersOffset Flat center offset.\n * @param {Array} [dest] Destination.\n * @return {Array} Destination point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n flatCentersOffset,\n dest,\n) {\n let i, ii, x, x1, x2, y1, y2;\n const y = flatCenters[flatCentersOffset + 1];\n /** @type {Array} */\n const intersections = [];\n // Calculate intersections with the horizontal line\n for (let r = 0, rr = ends.length; r < rr; ++r) {\n const end = ends[r];\n x1 = flatCoordinates[end - stride];\n y1 = flatCoordinates[end - stride + 1];\n for (i = offset; i < end; i += stride) {\n x2 = flatCoordinates[i];\n y2 = flatCoordinates[i + 1];\n if ((y <= y1 && y2 <= y) || (y1 <= y && y <= y2)) {\n x = ((y - y1) / (y2 - y1)) * (x2 - x1) + x1;\n intersections.push(x);\n }\n x1 = x2;\n y1 = y2;\n }\n }\n // Find the longest segment of the horizontal line that has its center point\n // inside the linear ring.\n let pointX = NaN;\n let maxSegmentLength = -Infinity;\n intersections.sort(ascending);\n x1 = intersections[0];\n for (i = 1, ii = intersections.length; i < ii; ++i) {\n x2 = intersections[i];\n const segmentLength = Math.abs(x2 - x1);\n if (segmentLength > maxSegmentLength) {\n x = (x1 + x2) / 2;\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n pointX = x;\n maxSegmentLength = segmentLength;\n }\n }\n x1 = x2;\n }\n if (isNaN(pointX)) {\n // There is no horizontal line that has its center point inside the linear\n // ring. Use the center of the the linear ring's extent.\n pointX = flatCenters[flatCentersOffset];\n }\n if (dest) {\n dest.push(pointX, y, maxSegmentLength);\n return dest;\n }\n return [pointX, y, maxSegmentLength];\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @return {Array} Interior points as XYM coordinates, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointsOfMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n flatCenters,\n) {\n /** @type {Array} */\n let interiorPoints = [];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n interiorPoints = getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n 2 * i,\n interiorPoints,\n );\n offset = ends[ends.length - 1];\n }\n return interiorPoints;\n}\n","/**\n * @module ol/geom/flat/segments\n */\n\n/**\n * This function calls `callback` for each segment of the flat coordinates\n * array. If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {function(import(\"../../coordinate.js\").Coordinate, import(\"../../coordinate.js\").Coordinate): T} callback Function\n * called for each segment.\n * @return {T|boolean} Value.\n * @template T\n */\nexport function forEach(flatCoordinates, offset, end, stride, callback) {\n let ret;\n offset += stride;\n for (; offset < end; offset += stride) {\n ret = callback(\n flatCoordinates.slice(offset - stride, offset),\n flatCoordinates.slice(offset, offset + stride),\n );\n if (ret) {\n return ret;\n }\n }\n return false;\n}\n\n/**\n * Calculate the intersection point of two line segments.\n * Reference: https://stackoverflow.com/a/72474223/2389327\n * @param {Array} segment1 The first line segment as an array of two points.\n * @param {Array} segment2 The second line segment as an array of two points.\n * @return {import(\"../../coordinate.js\").Coordinate|undefined} The intersection point or `undefined` if no intersection.\n */\nexport function getIntersectionPoint(segment1, segment2) {\n const [a, b] = segment1;\n const [c, d] = segment2;\n const t =\n ((a[0] - c[0]) * (c[1] - d[1]) - (a[1] - c[1]) * (c[0] - d[0])) /\n ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0]));\n const u =\n ((a[0] - c[0]) * (a[1] - b[1]) - (a[1] - c[1]) * (a[0] - b[0])) /\n ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0]));\n\n // Check if lines actually intersect\n if (0 <= t && t <= 1 && 0 <= u && u <= 1) {\n return [a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])];\n }\n return undefined;\n}\n","/**\n * @module ol/geom/flat/intersectsextent\n */\nimport {\n createEmpty,\n extendFlatCoordinates,\n intersects,\n intersectsSegment,\n} from '../../extent.js';\nimport {linearRingContainsExtent, linearRingContainsXY} from './contains.js';\nimport {forEach as forEachSegment} from './segments.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @param {import('../../extent.js').Extent} [coordinatesExtent] Coordinates extent\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n coordinatesExtent,\n) {\n coordinatesExtent =\n coordinatesExtent ??\n extendFlatCoordinates(createEmpty(), flatCoordinates, offset, end, stride);\n if (!intersects(extent, coordinatesExtent)) {\n return false;\n }\n if (\n (coordinatesExtent[0] >= extent[0] && coordinatesExtent[2] <= extent[2]) ||\n (coordinatesExtent[1] >= extent[1] && coordinatesExtent[3] <= extent[3])\n ) {\n return true;\n }\n return forEachSegment(\n flatCoordinates,\n offset,\n end,\n stride,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} point1 Start point.\n * @param {import(\"../../coordinate.js\").Coordinate} point2 End point.\n * @return {boolean} `true` if the segment and the extent intersect,\n * `false` otherwise.\n */\n function (point1, point2) {\n return intersectsSegment(extent, point1, point2);\n },\n );\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineStringArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n if (\n intersectsLineString(flatCoordinates, offset, ends[i], stride, extent)\n ) {\n return true;\n }\n offset = ends[i];\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRing(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n if (intersectsLineString(flatCoordinates, offset, end, stride, extent)) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[3],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[3],\n )\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n if (!intersectsLinearRing(flatCoordinates, offset, ends[0], stride, extent)) {\n return false;\n }\n if (ends.length === 1) {\n return true;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsExtent(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n if (\n !intersectsLineString(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n extent,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (\n intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent)\n ) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/reverse\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n */\nexport function coordinates(flatCoordinates, offset, end, stride) {\n while (offset < end - stride) {\n for (let i = 0; i < stride; ++i) {\n const tmp = flatCoordinates[offset + i];\n flatCoordinates[offset + i] = flatCoordinates[end - stride + i];\n flatCoordinates[end - stride + i] = tmp;\n }\n offset += stride;\n end -= stride;\n }\n}\n","/**\n * @module ol/geom/flat/orient\n */\nimport {coordinates as reverseCoordinates} from './reverse.js';\n\n/**\n * Is the linear ring oriented clockwise in a coordinate system with a bottom-left\n * coordinate origin? For a coordinate system with a top-left coordinate origin,\n * the ring's orientation is clockwise when this function returns false.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {boolean|undefined} Is clockwise.\n */\nexport function linearRingIsClockwise(flatCoordinates, offset, end, stride) {\n // https://stackoverflow.com/q/1165647/clockwise-method#1165943\n // https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrlinearring.cpp\n let edge = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n edge += (x2 - x1) * (y2 + y1);\n x1 = x2;\n y1 = y2;\n }\n return edge === 0 ? undefined : edge > 0;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingsAreOriented(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n if (i === 0) {\n if ((right && isClockwise) || (!right && !isClockwise)) {\n return false;\n }\n } else {\n if ((right && !isClockwise) || (!right && isClockwise)) {\n return false;\n }\n }\n offset = end;\n }\n return true;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingssAreOriented(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, right)) {\n return false;\n }\n if (ends.length) {\n offset = ends[ends.length - 1];\n }\n }\n return true;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRings(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n const reverse =\n i === 0\n ? (right && isClockwise) || (!right && !isClockwise)\n : (right && !isClockwise) || (!right && isClockwise);\n if (reverse) {\n reverseCoordinates(flatCoordinates, offset, end, stride);\n }\n offset = end;\n }\n return offset;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRingsArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n offset = orientLinearRings(\n flatCoordinates,\n offset,\n endss[i],\n stride,\n right,\n );\n }\n return offset;\n}\n\n/**\n * Return a two-dimensional endss\n * @param {Array} flatCoordinates Flat coordinates\n * @param {Array} ends Linear ring end indexes\n * @return {Array>} Two dimensional endss array that can\n * be used to construct a MultiPolygon\n */\nexport function inflateEnds(flatCoordinates, ends) {\n const endss = [];\n let offset = 0;\n let prevEndIndex = 0;\n let startOrientation;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n // classifies an array of rings into polygons with outer rings and holes\n const orientation = linearRingIsClockwise(flatCoordinates, offset, end, 2);\n if (startOrientation === undefined) {\n startOrientation = orientation;\n }\n if (orientation === startOrientation) {\n endss.push(ends.slice(prevEndIndex, i + 1));\n } else {\n if (endss.length === 0) {\n continue;\n }\n endss[endss.length - 1].push(ends[prevEndIndex]);\n }\n prevEndIndex = i + 1;\n offset = end;\n }\n return endss;\n}\n","/**\n * @module ol/geom/Polygon\n */\nimport {extend} from '../array.js';\nimport {closestSquaredDistanceXY, getCenter, isEmpty} from '../extent.js';\nimport {modulo} from '../math.js';\nimport {offset as sphereOffset} from '../sphere.js';\nimport LinearRing from './LinearRing.js';\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {linearRings as linearRingsArea} from './flat/area.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {linearRingsContainsXY} from './flat/contains.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {getInteriorPointOfArray} from './flat/interiorpoint.js';\nimport {intersectsLinearRingArray} from './flat/intersectsextent.js';\nimport {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';\nimport {quantizeArray} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Polygon geometry.\n *\n * @api\n */\nclass Polygon extends SimpleGeometry {\n /**\n * @param {!Array>|!Array} coordinates\n * Array of linear rings that define the polygon. The first linear ring of the\n * array defines the outer-boundary or surface of the polygon. Each subsequent\n * linear ring defines a hole in the surface of the polygon. A linear ring is\n * an array of vertices' coordinates where the first coordinate and the last are\n * equivalent. (For internal use, flat coordinates in combination with\n * `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Ends (for internal use with flat coordinates).\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointRevision_ = -1;\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate|null}\n */\n this.flatInteriorPoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n this.ends_ = ends;\n } else {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed linear ring to this polygon.\n * @param {LinearRing} linearRing Linear ring.\n * @api\n */\n appendLinearRing(linearRing) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = linearRing.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, linearRing.getFlatCoordinates());\n }\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Polygon} Clone.\n * @api\n * @override\n */\n clone() {\n const polygon = new Polygon(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice(),\n );\n polygon.applyProperties(this);\n return polygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n * @override\n */\n containsXY(x, y) {\n return linearRingsContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n x,\n y,\n );\n }\n\n /**\n * Return the area of the polygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingsArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>} Coordinates.\n * @api\n * @override\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * @return {Array} Interior point.\n */\n getFlatInteriorPoint() {\n if (this.flatInteriorPointRevision_ != this.getRevision()) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoint_ = getInteriorPointOfArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n flatCenter,\n 0,\n );\n this.flatInteriorPointRevision_ = this.getRevision();\n }\n return /** @type {import(\"../coordinate.js\").Coordinate} */ (\n this.flatInteriorPoint_\n );\n }\n\n /**\n * Return an interior point of the polygon.\n * @return {Point} Interior point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoint() {\n return new Point(this.getFlatInteriorPoint(), 'XYM');\n }\n\n /**\n * Return the number of rings of the polygon, this includes the exterior\n * ring and any interior rings.\n *\n * @return {number} Number of rings.\n * @api\n */\n getLinearRingCount() {\n return this.ends_.length;\n }\n\n /**\n * Return the Nth linear ring of the polygon geometry. Return `null` if the\n * given index is out of range.\n * The exterior linear ring is available at index `0` and the interior rings\n * at index `1` and beyond.\n *\n * @param {number} index Index.\n * @return {LinearRing|null} Linear ring.\n * @api\n */\n getLinearRing(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LinearRing(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index],\n ),\n this.layout,\n );\n }\n\n /**\n * Return the linear rings of the polygon.\n * @return {Array} Linear rings.\n * @api\n */\n getLinearRings() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const linearRings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const linearRing = new LinearRing(\n flatCoordinates.slice(offset, end),\n layout,\n );\n linearRings.push(linearRing);\n offset = end;\n }\n return linearRings;\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRings(\n this.orientedFlatCoordinates_,\n 0,\n this.ends_,\n this.stride,\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.orientedFlatCoordinates_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Polygon} Simplified Polygon.\n * @protected\n * @override\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = quantizeArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'Polygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return intersectsLinearRingArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the polygon.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_,\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default Polygon;\n\n/**\n * Create an approximation of a circle on the surface of a sphere.\n * @param {import(\"../coordinate.js\").Coordinate} center Center (`[lon, lat]` in degrees).\n * @param {number} radius The great-circle distance from the center to\n * the polygon vertices in meters.\n * @param {number} [n] Optional number of vertices for the resulting\n * polygon. Default is `32`.\n * @param {number} [sphereRadius] Optional radius for the sphere (defaults to\n * the Earth's mean radius using the WGS84 ellipsoid).\n * @return {Polygon} The \"circular\" polygon.\n * @api\n */\nexport function circular(center, radius, n, sphereRadius) {\n n = n ? n : 32;\n /** @type {Array} */\n const flatCoordinates = [];\n for (let i = 0; i < n; ++i) {\n extend(\n flatCoordinates,\n sphereOffset(center, radius, (2 * Math.PI * i) / n, sphereRadius),\n );\n }\n flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a polygon from an extent. The layout used is `XY`.\n * @param {import(\"../extent.js\").Extent} extent The extent.\n * @return {Polygon} The polygon.\n * @api\n */\nexport function fromExtent(extent) {\n if (isEmpty(extent)) {\n throw new Error('Cannot create polygon from empty extent');\n }\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const flatCoordinates = [\n minX,\n minY,\n minX,\n maxY,\n maxX,\n maxY,\n maxX,\n minY,\n minX,\n minY,\n ];\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a regular polygon from a circle.\n * @param {import(\"./Circle.js\").default} circle Circle geometry.\n * @param {number} [sides] Number of sides of the polygon. Default is 32.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n * @return {Polygon} Polygon geometry.\n * @api\n */\nexport function fromCircle(circle, sides, angle) {\n sides = sides ? sides : 32;\n const stride = circle.getStride();\n const layout = circle.getLayout();\n const center = circle.getCenter();\n const arrayLength = stride * (sides + 1);\n const flatCoordinates = new Array(arrayLength);\n for (let i = 0; i < arrayLength; i += stride) {\n flatCoordinates[i] = 0;\n flatCoordinates[i + 1] = 0;\n for (let j = 2; j < stride; j++) {\n flatCoordinates[i + j] = center[j];\n }\n }\n const ends = [flatCoordinates.length];\n const polygon = new Polygon(flatCoordinates, layout, ends);\n makeRegular(polygon, center, circle.getRadius(), angle);\n return polygon;\n}\n\n/**\n * Modify the coordinates of a polygon to make it a regular polygon.\n * @param {Polygon} polygon Polygon geometry.\n * @param {import(\"../coordinate.js\").Coordinate} center Center of the regular polygon.\n * @param {number} radius Radius of the regular polygon.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n */\nexport function makeRegular(polygon, center, radius, angle) {\n const flatCoordinates = polygon.getFlatCoordinates();\n const stride = polygon.getStride();\n const sides = flatCoordinates.length / stride - 1;\n const startAngle = angle ? angle : 0;\n for (let i = 0; i <= sides; ++i) {\n const offset = i * stride;\n const angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;\n flatCoordinates[offset] = center[0] + radius * Math.cos(angle);\n flatCoordinates[offset + 1] = center[1] + radius * Math.sin(angle);\n }\n polygon.changed();\n}\n","/**\n * @module ol/ImageState\n */\n\n/**\n * @enum {number}\n */\nexport default {\n IDLE: 0,\n LOADING: 1,\n LOADED: 2,\n ERROR: 3,\n EMPTY: 4,\n};\n","/**\n * @module ol/has\n */\n\nconst ua =\n typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined'\n ? navigator.userAgent.toLowerCase()\n : '';\n\n/**\n * User agent string says we are dealing with Safari as browser.\n * @type {boolean}\n */\nexport const SAFARI = ua.includes('safari') && !ua.includes('chrom');\n\n/**\n * https://bugs.webkit.org/show_bug.cgi?id=237906\n * @type {boolean}\n */\nexport const SAFARI_BUG_237906 =\n SAFARI &&\n (ua.includes('version/15.4') ||\n /cpu (os|iphone os) 15_4 like mac os x/.test(ua));\n\n/**\n * User agent string says we are dealing with a WebKit engine.\n * @type {boolean}\n */\nexport const WEBKIT = ua.includes('webkit') && !ua.includes('edge');\n\n/**\n * User agent string says we are dealing with a Mac as platform.\n * @type {boolean}\n */\nexport const MAC = ua.includes('macintosh');\n\n/**\n * The ratio between physical pixels and device-independent pixels\n * (dips) on the device (`window.devicePixelRatio`).\n * @const\n * @type {number}\n * @api\n */\nexport const DEVICE_PIXEL_RATIO =\n typeof devicePixelRatio !== 'undefined' ? devicePixelRatio : 1;\n\n/**\n * The execution context is a worker with OffscreenCanvas available.\n * @const\n * @type {boolean}\n */\nexport const WORKER_OFFSCREEN_CANVAS =\n typeof WorkerGlobalScope !== 'undefined' &&\n typeof OffscreenCanvas !== 'undefined' &&\n self instanceof WorkerGlobalScope; //eslint-disable-line\n\n/**\n * Image.prototype.decode() is supported.\n * @type {boolean}\n */\nexport const IMAGE_DECODE =\n typeof Image !== 'undefined' && Image.prototype.decode;\n\n/**\n * createImageBitmap() is supported.\n * @type {boolean}\n */\nexport const CREATE_IMAGE_BITMAP = typeof createImageBitmap === 'function';\n\n/**\n * @type {boolean}\n */\nexport const PASSIVE_EVENT_LISTENERS = (function () {\n let passive = false;\n try {\n const options = Object.defineProperty({}, 'passive', {\n get: function () {\n passive = true;\n },\n });\n\n // @ts-ignore Ignore invalid event type '_'\n window.addEventListener('_', null, options);\n // @ts-ignore Ignore invalid event type '_'\n window.removeEventListener('_', null, options);\n } catch {\n // passive not supported\n }\n return passive;\n})();\n","/**\n * @module ol/Image\n */\nimport ImageState from './ImageState.js';\nimport {listenOnce, unlistenByKey} from './events.js';\nimport EventType from './events/EventType.js';\nimport EventTarget from './events/Target.js';\nimport {toPromise} from './functions.js';\nimport {CREATE_IMAGE_BITMAP, IMAGE_DECODE} from './has.js';\n\n/**\n * A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a\n * `{string}` for the src as arguments. It is supposed to make it so the\n * underlying image {@link module:ol/Image~ImageWrapper#getImage} is assigned the\n * content specified by the src. If not specified, the default is\n *\n * function(image, src) {\n * image.getImage().src = src;\n * }\n *\n * Providing a custom `imageLoadFunction` can be useful to load images with\n * post requests or - in general - through XHR requests, where the src of the\n * image element would be set to a data URI when the content is loaded.\n *\n * @typedef {function(import(\"./Image.js\").default, string): void} LoadFunction\n * @api\n */\n\n/**\n * @typedef {Object} ImageObject\n * @property {import(\"./extent.js\").Extent} [extent] Extent, if different from the requested one.\n * @property {import(\"./resolution.js\").ResolutionLike} [resolution] Resolution, if different from the requested one.\n * When x and y resolution are different, use the array type (`[xResolution, yResolution]`).\n * @property {number} [pixelRatio] Pixel ratio, if different from the requested one.\n * @property {import('./DataTile.js').ImageLike} image Image.\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * For images that cover any extent and resolution (static images), the loader function should not accept\n * any arguments. The function returns an {@link import(\"./DataTile.js\").ImageLike image}, an\n * {@link import(\"./Image.js\").ImageObject image object}, or a promise for the same.\n * For loaders that generate images, the promise should not resolve until the image is loaded.\n * If the returned image does not match the extent, resolution or pixel ratio passed to the loader,\n * it has to return an {@link import(\"./Image.js\").ImageObject image object} with the `image` and the\n * correct `extent`, `resolution` and `pixelRatio`.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} Loader\n * @api\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * The function returns a promise for an {@link import(\"./Image.js\").ImageObject image object}.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): Promise} ImageObjectPromiseLoader\n */\n\nclass ImageWrapper extends EventTarget {\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number|Array|undefined} resolution Resolution. If provided as array, x and y\n * resolution will be assumed.\n * @param {number} pixelRatio Pixel ratio.\n * @param {import(\"./ImageState.js\").default|Loader} stateOrLoader State.\n */\n constructor(extent, resolution, pixelRatio, stateOrLoader) {\n super();\n\n /**\n * @protected\n * @type {import(\"./extent.js\").Extent}\n */\n this.extent = extent;\n\n /**\n * @private\n * @type {number}\n */\n this.pixelRatio_ = pixelRatio;\n\n /**\n * @protected\n * @type {number|Array|undefined}\n */\n this.resolution = resolution;\n\n /**\n * @protected\n * @type {import(\"./ImageState.js\").default}\n */\n this.state =\n typeof stateOrLoader === 'function' ? ImageState.IDLE : stateOrLoader;\n\n /**\n * @private\n * @type {import('./DataTile.js').ImageLike|null}\n */\n this.image_ = null;\n\n /**\n * @protected\n * @type {Loader|null}\n */\n this.loader = typeof stateOrLoader === 'function' ? stateOrLoader : null;\n }\n\n /**\n * @protected\n */\n changed() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @return {import(\"./extent.js\").Extent} Extent.\n */\n getExtent() {\n return this.extent;\n }\n\n /**\n * @return {import('./DataTile.js').ImageLike} Image.\n */\n getImage() {\n return this.image_;\n }\n\n /**\n * @return {number} PixelRatio.\n */\n getPixelRatio() {\n return this.pixelRatio_;\n }\n\n /**\n * @return {number|Array} Resolution.\n */\n getResolution() {\n return /** @type {number} */ (this.resolution);\n }\n\n /**\n * @return {import(\"./ImageState.js\").default} State.\n */\n getState() {\n return this.state;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.state == ImageState.IDLE) {\n if (this.loader) {\n this.state = ImageState.LOADING;\n this.changed();\n const resolution = this.getResolution();\n const requestResolution = Array.isArray(resolution)\n ? resolution[0]\n : resolution;\n toPromise(() =>\n this.loader(\n this.getExtent(),\n requestResolution,\n this.getPixelRatio(),\n ),\n )\n .then((image) => {\n if ('image' in image) {\n this.image_ = image.image;\n }\n if ('extent' in image) {\n this.extent = image.extent;\n }\n if ('resolution' in image) {\n this.resolution = image.resolution;\n }\n if ('pixelRatio' in image) {\n this.pixelRatio_ = image.pixelRatio;\n }\n if (\n image instanceof HTMLImageElement ||\n (CREATE_IMAGE_BITMAP && image instanceof ImageBitmap) ||\n image instanceof HTMLCanvasElement ||\n image instanceof HTMLVideoElement\n ) {\n this.image_ = image;\n }\n this.state = ImageState.LOADED;\n })\n .catch((error) => {\n this.state = ImageState.ERROR;\n console.error(error); // eslint-disable-line no-console\n })\n .finally(() => this.changed());\n }\n }\n }\n\n /**\n * @param {import('./DataTile.js').ImageLike} image The image.\n */\n setImage(image) {\n this.image_ = image;\n }\n\n /**\n * @param {number|Array} resolution Resolution.\n */\n setResolution(resolution) {\n this.resolution = resolution;\n }\n}\n\n/**\n * @param {import('./DataTile.js').ImageLike} image Image element.\n * @param {function():any} loadHandler Load callback function.\n * @param {function():any} errorHandler Error callback function.\n * @return {function():void} Callback to stop listening.\n */\nexport function listenImage(image, loadHandler, errorHandler) {\n const img = /** @type {HTMLImageElement} */ (image);\n let listening = true;\n let decoding = false;\n let loaded = false;\n\n const listenerKeys = [\n listenOnce(img, EventType.LOAD, function () {\n loaded = true;\n if (!decoding) {\n loadHandler();\n }\n }),\n ];\n\n if (img.src && IMAGE_DECODE) {\n decoding = true;\n img\n .decode()\n .then(function () {\n if (listening) {\n loadHandler();\n }\n })\n .catch(function (error) {\n if (listening) {\n if (loaded) {\n loadHandler();\n } else {\n errorHandler();\n }\n }\n });\n } else {\n listenerKeys.push(listenOnce(img, EventType.ERROR, errorHandler));\n }\n\n return function unlisten() {\n listening = false;\n listenerKeys.forEach(unlistenByKey);\n };\n}\n\n/**\n * Loads an image.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n * @api\n */\nexport function load(image, src) {\n return new Promise((resolve, reject) => {\n function handleLoad() {\n unlisten();\n resolve(image);\n }\n function handleError() {\n unlisten();\n reject(new Error('Image load error'));\n }\n function unlisten() {\n image.removeEventListener('load', handleLoad);\n image.removeEventListener('error', handleError);\n }\n image.addEventListener('load', handleLoad);\n image.addEventListener('error', handleError);\n if (src) {\n image.src = src;\n }\n });\n}\n\n/**\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n */\nexport function decodeFallback(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE\n ? new Promise((resolve, reject) =>\n image\n .decode()\n .then(() => resolve(image))\n .catch((e) =>\n image.complete && image.width ? resolve(image) : reject(e),\n ),\n )\n : load(image);\n}\n\n/**\n * Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns\n * the loaded image otherwise.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `ImageBitmap` or an\n * `HTMLImageElement` if `createImageBitmap()` is not supported.\n * @api\n */\nexport function decode(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE && CREATE_IMAGE_BITMAP\n ? image\n .decode()\n .then(() => createImageBitmap(image))\n .catch((e) => {\n if (image.complete && image.width) {\n return image;\n }\n throw e;\n })\n : decodeFallback(image);\n}\n\nexport default ImageWrapper;\n","/**\n * @module ol/TileState\n */\n\n/**\n * @enum {number}\n */\nexport default {\n IDLE: 0,\n LOADING: 1,\n LOADED: 2,\n /**\n * Indicates that tile loading failed\n * @type {number}\n */\n ERROR: 3,\n EMPTY: 4,\n};\n","/**\n * @module ol/easing\n */\n\n/**\n * Start slow and speed up.\n * @param {number} t Input between 0 and 1.\n * @return {number} Output between 0 and 1.\n * @api\n */\nexport function easeIn(t) {\n return Math.pow(t, 3);\n}\n\n/**\n * Start fast and slow down.\n * @param {number} t Input between 0 and 1.\n * @return {number} Output between 0 and 1.\n * @api\n */\nexport function easeOut(t) {\n return 1 - easeIn(1 - t);\n}\n\n/**\n * Start slow, speed up, and then slow down again.\n * @param {number} t Input between 0 and 1.\n * @return {number} Output between 0 and 1.\n * @api\n */\nexport function inAndOut(t) {\n return 3 * t * t - 2 * t * t * t;\n}\n\n/**\n * Maintain a constant speed over time.\n * @param {number} t Input between 0 and 1.\n * @return {number} Output between 0 and 1.\n * @api\n */\nexport function linear(t) {\n return t;\n}\n\n/**\n * Start slow, speed up, and at the very end slow down again. This has the\n * same general behavior as {@link module:ol/easing.inAndOut}, but the final\n * slowdown is delayed.\n * @param {number} t Input between 0 and 1.\n * @return {number} Output between 0 and 1.\n * @api\n */\nexport function upAndDown(t) {\n if (t < 0.5) {\n return inAndOut(2 * t);\n }\n return 1 - inAndOut(2 * (t - 0.5));\n}\n","/**\n * @module ol/Tile\n */\nimport TileState from './TileState.js';\nimport {easeIn} from './easing.js';\nimport EventType from './events/EventType.js';\nimport EventTarget from './events/Target.js';\nimport {abstract} from './util.js';\n\n/**\n * A function that takes a {@link module:ol/Tile~Tile} for the tile and a\n * `{string}` for the url as arguments. The default is\n * ```js\n * source.setTileLoadFunction(function(tile, src) {\n * tile.getImage().src = src;\n * });\n * ```\n * For more fine grained control, the load function can use fetch or XMLHttpRequest and involve\n * error handling:\n *\n * ```js\n * import TileState from 'ol/TileState.js';\n *\n * source.setTileLoadFunction(function(tile, src) {\n * const xhr = new XMLHttpRequest();\n * xhr.responseType = 'blob';\n * xhr.addEventListener('loadend', function (evt) {\n * const data = this.response;\n * if (data !== undefined) {\n * tile.getImage().src = URL.createObjectURL(data);\n * } else {\n * tile.setState(TileState.ERROR);\n * }\n * });\n * xhr.addEventListener('error', function () {\n * tile.setState(TileState.ERROR);\n * });\n * xhr.open('GET', src);\n * xhr.send();\n * });\n * ```\n *\n * @typedef {function(Tile, string): void} LoadFunction\n * @api\n */\n\n/**\n * {@link module:ol/source/Tile~TileSource} sources use a function of this type to get\n * the url that provides a tile for a given tile coordinate.\n *\n * This function takes a {@link module:ol/tilecoord~TileCoord} for the tile\n * coordinate, a `{number}` representing the pixel ratio and a\n * {@link module:ol/proj/Projection~Projection} for the projection as arguments\n * and returns a `{string}` representing the tile URL, or undefined if no tile\n * should be requested for the passed tile coordinate.\n *\n * @typedef {function(import(\"./tilecoord.js\").TileCoord, number,\n * import(\"./proj/Projection.js\").default): (string|undefined)} UrlFunction\n * @api\n */\n\n/**\n * @typedef {Object} Options\n * @property {number} [transition=250] A duration for tile opacity\n * transitions in milliseconds. A duration of 0 disables the opacity transition.\n * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,\n * the nearest neighbor is used when resampling.\n * @api\n */\n\n/**\n * @classdesc\n * Base class for tiles.\n *\n * @abstract\n */\nclass Tile extends EventTarget {\n /**\n * @param {import(\"./tilecoord.js\").TileCoord} tileCoord Tile coordinate.\n * @param {import(\"./TileState.js\").default} state State.\n * @param {Options} [options] Tile options.\n */\n constructor(tileCoord, state, options) {\n super();\n\n options = options ? options : {};\n\n /**\n * @type {import(\"./tilecoord.js\").TileCoord}\n */\n this.tileCoord = tileCoord;\n\n /**\n * @protected\n * @type {import(\"./TileState.js\").default}\n */\n this.state = state;\n\n /**\n * A key assigned to the tile. This is used in conjunction with a source key\n * to determine if a cached version of this tile may be used by the renderer.\n * @type {string}\n */\n this.key = '';\n\n /**\n * The duration for the opacity transition.\n * @private\n * @type {number}\n */\n this.transition_ =\n options.transition === undefined ? 250 : options.transition;\n\n /**\n * Lookup of start times for rendering transitions. If the start time is\n * equal to -1, the transition is complete.\n * @private\n * @type {Object}\n */\n this.transitionStarts_ = {};\n\n /**\n * @type {boolean}\n */\n this.interpolate = !!options.interpolate;\n }\n\n /**\n * @protected\n */\n changed() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * Called by the tile cache when the tile is removed from the cache due to expiry\n */\n release() {\n // to remove the `change` listener on this tile in `ol/TileQueue#handleTileChange`\n this.setState(TileState.EMPTY);\n }\n\n /**\n * @return {string} Key.\n */\n getKey() {\n return this.key + '/' + this.tileCoord;\n }\n\n /**\n * Get the tile coordinate for this tile.\n * @return {import(\"./tilecoord.js\").TileCoord} The tile coordinate.\n * @api\n */\n getTileCoord() {\n return this.tileCoord;\n }\n\n /**\n * @return {import(\"./TileState.js\").default} State.\n */\n getState() {\n return this.state;\n }\n\n /**\n * Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} ,\n * it is important to set the state correctly to {@link module:ol/TileState~ERROR}\n * when the tile cannot be loaded. Otherwise the tile cannot be removed from\n * the tile queue and will block other requests.\n * @param {import(\"./TileState.js\").default} state State.\n * @api\n */\n setState(state) {\n if (this.state === TileState.EMPTY) {\n // no more state changes\n return;\n }\n if (this.state !== TileState.ERROR && this.state > state) {\n throw new Error('Tile load sequence violation');\n }\n this.state = state;\n this.changed();\n }\n\n /**\n * Load the image or retry if loading previously failed.\n * Loading is taken care of by the tile queue, and calling this method is\n * only needed for preloading or for reloading in case of an error.\n * @abstract\n * @api\n */\n load() {\n abstract();\n }\n\n /**\n * Get the alpha value for rendering.\n * @param {string} id An id for the renderer.\n * @param {number} time The render frame time.\n * @return {number} A number between 0 and 1.\n */\n getAlpha(id, time) {\n if (!this.transition_) {\n return 1;\n }\n\n let start = this.transitionStarts_[id];\n if (!start) {\n start = time;\n this.transitionStarts_[id] = start;\n } else if (start === -1) {\n return 1;\n }\n\n const delta = time - start + 1000 / 60; // avoid rendering at 0\n if (delta >= this.transition_) {\n return 1;\n }\n return easeIn(delta / this.transition_);\n }\n\n /**\n * Determine if a tile is in an alpha transition. A tile is considered in\n * transition if tile.getAlpha() has not yet been called or has been called\n * and returned 1.\n * @param {string} id An id for the renderer.\n * @return {boolean} The tile is in transition.\n */\n inTransition(id) {\n if (!this.transition_) {\n return false;\n }\n return this.transitionStarts_[id] !== -1;\n }\n\n /**\n * Mark a transition as complete.\n * @param {string} id An id for the renderer.\n */\n endTransition(id) {\n if (this.transition_) {\n this.transitionStarts_[id] = -1;\n }\n }\n\n /**\n * @override\n */\n disposeInternal() {\n this.release();\n super.disposeInternal();\n }\n}\n\nexport default Tile;\n","import {WORKER_OFFSCREEN_CANVAS} from './has.js';\n\n/**\n * @module ol/dom\n */\n\n/**\n * @typedef {Object} ImageAttributes\n * @property {string|null} [crossOrigin] Cross origin.\n * @property {ReferrerPolicy} [referrerPolicy] Referrer policy.\n */\n\n//FIXME Move this function to the canvas module\n/**\n * Create an html canvas element and returns its 2d context.\n * @param {number} [width] Canvas width.\n * @param {number} [height] Canvas height.\n * @param {Array} [canvasPool] Canvas pool to take existing canvas from.\n * @param {CanvasRenderingContext2DSettings} [settings] CanvasRenderingContext2DSettings\n * @return {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} The context.\n */\nexport function createCanvasContext2D(width, height, canvasPool, settings) {\n /** @type {HTMLCanvasElement|OffscreenCanvas} */\n let canvas;\n if (canvasPool && canvasPool.length) {\n canvas = /** @type {HTMLCanvasElement} */ (canvasPool.shift());\n } else if (WORKER_OFFSCREEN_CANVAS) {\n canvas = new (class extends OffscreenCanvas {\n style = {};\n })(width ?? 300, height ?? 150);\n } else {\n canvas = document.createElement('canvas');\n }\n if (width) {\n canvas.width = width;\n }\n if (height) {\n canvas.height = height;\n }\n return /** @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} */ (\n canvas.getContext('2d', settings)\n );\n}\n\n/**\n * @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}\n */\nlet sharedCanvasContext;\n\n/**\n * @return {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} Shared canvas context.\n */\nexport function getSharedCanvasContext2D() {\n if (!sharedCanvasContext) {\n sharedCanvasContext = createCanvasContext2D(1, 1);\n }\n return sharedCanvasContext;\n}\n\n/**\n * Releases canvas memory to avoid exceeding memory limits in Safari.\n * See https://pqina.nl/blog/total-canvas-memory-use-exceeds-the-maximum-limit/\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context Context.\n */\nexport function releaseCanvas(context) {\n const canvas = context.canvas;\n canvas.width = 1;\n canvas.height = 1;\n context.clearRect(0, 0, 1, 1);\n}\n\n/**\n * Get the current computed width for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerWidth(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The width.\n */\nexport function outerWidth(element) {\n let width = element.offsetWidth;\n const style = getComputedStyle(element);\n width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);\n\n return width;\n}\n\n/**\n * Get the current computed height for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerHeight(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The height.\n */\nexport function outerHeight(element) {\n let height = element.offsetHeight;\n const style = getComputedStyle(element);\n height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);\n\n return height;\n}\n\n/**\n * @param {Node} newNode Node to replace old node\n * @param {Node} oldNode The node to be replaced\n */\nexport function replaceNode(newNode, oldNode) {\n const parent = oldNode.parentNode;\n if (parent) {\n parent.replaceChild(newNode, oldNode);\n }\n}\n\n/**\n * @param {Node} node The node to remove the children from.\n */\nexport function removeChildren(node) {\n while (node.lastChild) {\n node.lastChild.remove();\n }\n}\n\n/**\n * Transform the children of a parent node so they match the\n * provided list of children. This function aims to efficiently\n * remove, add, and reorder child nodes while maintaining a simple\n * implementation (it is not guaranteed to minimize DOM operations).\n * @param {Node} node The parent node whose children need reworking.\n * @param {Array} children The desired children.\n */\nexport function replaceChildren(node, children) {\n const oldChildren = node.childNodes;\n\n for (let i = 0; true; ++i) {\n const oldChild = oldChildren[i];\n const newChild = children[i];\n\n // check if our work is done\n if (!oldChild && !newChild) {\n break;\n }\n\n // check if children match\n if (oldChild === newChild) {\n continue;\n }\n\n // check if a new child needs to be added\n if (!oldChild) {\n node.appendChild(newChild);\n continue;\n }\n\n // check if an old child needs to be removed\n if (!newChild) {\n node.removeChild(oldChild);\n --i;\n continue;\n }\n\n // reorder\n node.insertBefore(newChild, oldChild);\n }\n}\n\n/**\n * Creates a minimal structure that mocks a DIV to be used by the composite and\n * layer renderer in a worker environment\n * @return {HTMLDivElement} mocked DIV\n */\nexport function createMockDiv() {\n const mockedDiv = new Proxy(\n {\n /**\n * @type {Array}\n */\n childNodes: [],\n /**\n * @param {HTMLElement} node html node.\n * @return {HTMLElement} html node.\n */\n appendChild: function (node) {\n this.childNodes.push(node);\n return node;\n },\n /**\n * dummy function, as this structure is not supposed to have a parent.\n */\n remove: function () {},\n /**\n * @param {HTMLElement} node html node.\n * @return {HTMLElement} html node.\n */\n removeChild: function (node) {\n const index = this.childNodes.indexOf(node);\n if (index === -1) {\n throw new Error('Node to remove was not found');\n }\n this.childNodes.splice(index, 1);\n return node;\n },\n /**\n * @param {HTMLElement} newNode new html node.\n * @param {HTMLElement} referenceNode reference html node.\n * @return {HTMLElement} new html node.\n */\n insertBefore: function (newNode, referenceNode) {\n const index = this.childNodes.indexOf(referenceNode);\n if (index === -1) {\n throw new Error('Reference node not found');\n }\n this.childNodes.splice(index, 0, newNode);\n return newNode;\n },\n style: {},\n },\n {\n get(target, prop, receiver) {\n if (prop === 'firstElementChild') {\n return target.childNodes.length > 0 ? target.childNodes[0] : null;\n }\n return Reflect.get(target, prop, receiver);\n },\n },\n );\n return /** @type {HTMLDivElement} */ (/** @type {*} */ (mockedDiv));\n}\n\n/***\n * @param {*} obj The object to check.\n * @return {obj is (HTMLCanvasElement | OffscreenCanvas)} The object is a canvas.\n */\nexport function isCanvas(obj) {\n return (\n (typeof HTMLCanvasElement !== 'undefined' &&\n obj instanceof HTMLCanvasElement) ||\n (typeof OffscreenCanvas !== 'undefined' && obj instanceof OffscreenCanvas)\n );\n}\n","/**\n * @module ol/ImageTile\n */\nimport {listenImage} from './Image.js';\nimport Tile from './Tile.js';\nimport TileState from './TileState.js';\nimport {createCanvasContext2D} from './dom.js';\nimport {WORKER_OFFSCREEN_CANVAS} from './has.js';\n\nclass ImageTile extends Tile {\n /**\n * @param {import(\"./tilecoord.js\").TileCoord} tileCoord Tile coordinate.\n * @param {import(\"./TileState.js\").default} state State.\n * @param {string} src Image source URI.\n * @param {import('./dom.js').ImageAttributes} imageAttributes Image attributes options.\n * @param {import(\"./Tile.js\").LoadFunction} tileLoadFunction Tile load function.\n * @param {import(\"./Tile.js\").Options} [options] Tile options.\n */\n constructor(\n tileCoord,\n state,\n src,\n imageAttributes,\n tileLoadFunction,\n options,\n ) {\n super(tileCoord, state, options);\n\n /**\n * @private\n * @type {?string}\n */\n this.crossOrigin_ = imageAttributes?.crossOrigin;\n\n /**\n * @private\n * @type {ReferrerPolicy}\n */\n this.referrerPolicy_ = imageAttributes?.referrerPolicy;\n\n /**\n * Image URI\n *\n * @private\n * @type {string}\n */\n this.src_ = src;\n\n this.key = src;\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas}\n */\n this.image_;\n\n if (WORKER_OFFSCREEN_CANVAS) {\n this.image_ = new OffscreenCanvas(1, 1);\n } else {\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n if (this.referrerPolicy_ !== undefined) {\n this.image_.referrerPolicy = this.referrerPolicy_;\n }\n }\n\n /**\n * @private\n * @type {?function():void}\n */\n this.unlisten_ = null;\n\n /**\n * @private\n * @type {import(\"./Tile.js\").LoadFunction}\n */\n this.tileLoadFunction_ = tileLoadFunction;\n }\n\n /**\n * Get the HTML image element for this tile (may be a Canvas, OffscreenCanvas, Image, or Video).\n * @return {HTMLCanvasElement|OffscreenCanvas|HTMLImageElement|HTMLVideoElement} Image.\n * @api\n */\n getImage() {\n return this.image_;\n }\n\n /**\n * Sets an HTML image element for this tile (may be a Canvas or preloaded Image).\n * @param {HTMLCanvasElement|OffscreenCanvas|HTMLImageElement} element Element.\n */\n setImage(element) {\n this.image_ = element;\n this.state = TileState.LOADED;\n this.unlistenImage_();\n this.changed();\n }\n\n /**\n * Get the cross origin of the ImageTile.\n * @return {string} Cross origin.\n */\n getCrossOrigin() {\n return this.crossOrigin_;\n }\n\n /**\n * Get the referrer policy of the ImageTile.\n * @return {ReferrerPolicy} Referrer policy.\n */\n getReferrerPolicy() {\n return this.referrerPolicy_;\n }\n\n /**\n * Tracks loading or read errors.\n *\n * @private\n */\n handleImageError_() {\n this.state = TileState.ERROR;\n this.unlistenImage_();\n this.image_ = getBlankImage();\n this.changed();\n }\n\n /**\n * Tracks successful image load.\n *\n * @private\n */\n handleImageLoad_() {\n if (WORKER_OFFSCREEN_CANVAS) {\n // OffscreenCanvas does not have naturalWidth and naturalHeight\n this.state = TileState.LOADED;\n } else {\n const image = /** @type {HTMLImageElement} */ (this.image_);\n if (image.naturalWidth && image.naturalHeight) {\n this.state = TileState.LOADED;\n } else {\n this.state = TileState.EMPTY;\n }\n }\n this.unlistenImage_();\n this.changed();\n }\n\n /**\n * Load the image or retry if loading previously failed.\n * Loading is taken care of by the tile queue, and calling this method is\n * only needed for preloading or for reloading in case of an error.\n *\n * To retry loading tiles on failed requests, use a custom `tileLoadFunction`\n * that checks for error status codes and reloads only when the status code is\n * 408, 429, 500, 502, 503 and 504, and only when not too many retries have been\n * made already:\n *\n * ```js\n * const retryCodes = [408, 429, 500, 502, 503, 504];\n * const retries = {};\n * source.setTileLoadFunction((tile, src) => {\n * const image = tile.getImage();\n * fetch(src)\n * .then((response) => {\n * if (retryCodes.includes(response.status)) {\n * retries[src] = (retries[src] || 0) + 1;\n * if (retries[src] <= 3) {\n * setTimeout(() => tile.load(), retries[src] * 1000);\n * }\n * return Promise.reject();\n * }\n * return response.blob();\n * })\n * .then((blob) => {\n * const imageUrl = URL.createObjectURL(blob);\n * image.src = imageUrl;\n * setTimeout(() => URL.revokeObjectURL(imageUrl), 5000);\n * })\n * .catch(() => tile.setState(3)); // error\n * });\n * ```\n * @api\n * @override\n */\n load() {\n if (this.state == TileState.ERROR) {\n this.state = TileState.IDLE;\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n if (this.referrerPolicy_ !== undefined) {\n this.image_.referrerPolicy = this.referrerPolicy_;\n }\n }\n if (this.state == TileState.IDLE) {\n this.state = TileState.LOADING;\n this.changed();\n this.tileLoadFunction_(this, this.src_);\n this.unlisten_ = listenImage(\n this.image_,\n this.handleImageLoad_.bind(this),\n this.handleImageError_.bind(this),\n );\n }\n }\n\n /**\n * Discards event handlers which listen for load completion or errors.\n *\n * @private\n */\n unlistenImage_() {\n if (this.unlisten_) {\n this.unlisten_();\n this.unlisten_ = null;\n }\n }\n\n /**\n * @override\n */\n disposeInternal() {\n this.unlistenImage_();\n this.image_ = null;\n super.disposeInternal();\n }\n}\n\n/**\n * Get a 1-pixel blank image.\n * @return {HTMLCanvasElement|OffscreenCanvas} Blank image.\n */\nfunction getBlankImage() {\n const ctx = createCanvasContext2D(1, 1);\n ctx.fillStyle = 'rgba(0,0,0,0)';\n ctx.fillRect(0, 0, 1, 1);\n return ctx.canvas;\n}\n\nexport default ImageTile;\n","/**\n * @module ol/Kinetic\n */\n\n/**\n * @classdesc\n * Implementation of inertial deceleration for map movement.\n *\n * @api\n */\nclass Kinetic {\n /**\n * @param {number} decay Rate of decay (must be negative).\n * @param {number} minVelocity Minimum velocity (pixels/millisecond).\n * @param {number} delay Delay to consider to calculate the kinetic\n * initial values (milliseconds).\n */\n constructor(decay, minVelocity, delay) {\n /**\n * @private\n * @type {number}\n */\n this.decay_ = decay;\n\n /**\n * @private\n * @type {number}\n */\n this.minVelocity_ = minVelocity;\n\n /**\n * @private\n * @type {number}\n */\n this.delay_ = delay;\n\n /**\n * @private\n * @type {Array}\n */\n this.points_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.angle_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.initialVelocity_ = 0;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n begin() {\n this.points_.length = 0;\n this.angle_ = 0;\n this.initialVelocity_ = 0;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n */\n update(x, y) {\n this.points_.push(x, y, Date.now());\n }\n\n /**\n * @return {boolean} Whether we should do kinetic animation.\n */\n end() {\n if (this.points_.length < 6) {\n // at least 2 points are required (i.e. there must be at least 6 elements\n // in the array)\n return false;\n }\n const delay = Date.now() - this.delay_;\n const lastIndex = this.points_.length - 3;\n if (this.points_[lastIndex + 2] < delay) {\n // the last tracked point is too old, which means that the user stopped\n // panning before releasing the map\n return false;\n }\n\n // get the first point which still falls into the delay time\n let firstIndex = lastIndex - 3;\n while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {\n firstIndex -= 3;\n }\n\n const duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];\n // we don't want a duration of 0 (divide by zero)\n // we also make sure the user panned for a duration of at least one frame\n // (1/60s) to compute sane displacement values\n if (duration < 1000 / 60) {\n return false;\n }\n\n const dx = this.points_[lastIndex] - this.points_[firstIndex];\n const dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];\n this.angle_ = Math.atan2(dy, dx);\n this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;\n return this.initialVelocity_ > this.minVelocity_;\n }\n\n /**\n * @return {number} Total distance travelled (pixels).\n */\n getDistance() {\n return (this.minVelocity_ - this.initialVelocity_) / this.decay_;\n }\n\n /**\n * @return {number} Angle of the kinetic panning animation (radians).\n */\n getAngle() {\n return this.angle_;\n }\n}\n\nexport default Kinetic;\n","/**\n * @module ol/geom/flat/interpolate\n */\nimport {binarySearch} from '../../array.js';\nimport {lerp} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} fraction Fraction.\n * @param {Array} [dest] Destination.\n * @param {number} [dimension] Destination dimension (default is `2`)\n * @return {Array} Destination.\n */\nexport function interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n fraction,\n dest,\n dimension,\n) {\n let o, t;\n const n = (end - offset) / stride;\n if (n === 1) {\n o = offset;\n } else if (n === 2) {\n o = offset;\n t = fraction;\n } else if (n !== 0) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n const cumulativeLengths = [0];\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n cumulativeLengths.push(length);\n x1 = x2;\n y1 = y2;\n }\n const target = fraction * length;\n const index = binarySearch(cumulativeLengths, target);\n if (index < 0) {\n t =\n (target - cumulativeLengths[-index - 2]) /\n (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);\n o = offset + (-index - 2) * stride;\n } else {\n o = offset + index * stride;\n }\n }\n dimension = dimension > 1 ? dimension : 2;\n dest = dest ? dest : new Array(dimension);\n for (let i = 0; i < dimension; ++i) {\n dest[i] =\n o === undefined\n ? NaN\n : t === undefined\n ? flatCoordinates[o + i]\n : lerp(flatCoordinates[o + i], flatCoordinates[o + stride + i], t);\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n extrapolate,\n) {\n if (end == offset) {\n return null;\n }\n let coordinate;\n if (m < flatCoordinates[offset + stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(offset, offset + stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[end - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(end - stride, end);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n // FIXME use O(1) search\n if (m == flatCoordinates[offset + stride - 1]) {\n return flatCoordinates.slice(offset, offset + stride);\n }\n let lo = offset / stride;\n let hi = end / stride;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (m < flatCoordinates[(mid + 1) * stride - 1]) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n const m0 = flatCoordinates[lo * stride - 1];\n if (m == m0) {\n return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);\n }\n const m1 = flatCoordinates[(lo + 1) * stride - 1];\n const t = (m - m0) / (m1 - m0);\n coordinate = [];\n for (let i = 0; i < stride - 1; ++i) {\n coordinate.push(\n lerp(\n flatCoordinates[(lo - 1) * stride + i],\n flatCoordinates[lo * stride + i],\n t,\n ),\n );\n }\n coordinate.push(m);\n return coordinate;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @param {boolean} interpolate Interpolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringsCoordinateAtM(\n flatCoordinates,\n offset,\n ends,\n stride,\n m,\n extrapolate,\n interpolate,\n) {\n if (interpolate) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n ends[ends.length - 1],\n stride,\n m,\n extrapolate,\n );\n }\n let coordinate;\n if (m < flatCoordinates[stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(0, stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[flatCoordinates.length - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(flatCoordinates.length - stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n if (offset == end) {\n continue;\n }\n if (m < flatCoordinates[offset + stride - 1]) {\n return null;\n }\n if (m <= flatCoordinates[end - 1]) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n false,\n );\n }\n offset = end;\n }\n return null;\n}\n","/**\n * @module ol/geom/flat/length\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Length.\n */\nexport function lineStringLength(flatCoordinates, offset, end, stride) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n x1 = x2;\n y1 = y2;\n }\n return length;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Perimeter.\n */\nexport function linearRingLength(flatCoordinates, offset, end, stride) {\n let perimeter = lineStringLength(flatCoordinates, offset, end, stride);\n const dx = flatCoordinates[end - stride] - flatCoordinates[offset];\n const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];\n perimeter += Math.sqrt(dx * dx + dy * dy);\n return perimeter;\n}\n","/**\n * @module ol/geom/LineString\n */\nimport {extend} from '../array.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {interpolatePoint, lineStringCoordinateAtM} from './flat/interpolate.js';\nimport {intersectsLineString} from './flat/intersectsextent.js';\nimport {lineStringLength} from './flat/length.js';\nimport {forEach as forEachSegment} from './flat/segments.js';\nimport {douglasPeucker} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Linestring geometry.\n *\n * @api\n */\nclass LineString extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate|null}\n */\n this.flatMidpoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.flatMidpointRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed coordinate to the coordinates of the linestring.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @api\n */\n appendCoordinate(coordinate) {\n extend(this.flatCoordinates, coordinate);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LineString} Clone.\n * @api\n * @override\n */\n clone() {\n const lineString = new LineString(\n this.flatCoordinates.slice(),\n this.layout,\n );\n lineString.applyProperties(this);\n return lineString;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n false,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Iterate over each segment, calling the provided callback.\n * If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n *\n * @param {function(this: S, import(\"../coordinate.js\").Coordinate, import(\"../coordinate.js\").Coordinate): T} callback Function\n * called for each segment. The function will receive two arguments, the start and end coordinates of the segment.\n * @return {T|boolean} Value.\n * @template T,S\n * @api\n */\n forEachSegment(callback) {\n return forEachSegment(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n callback,\n );\n }\n\n /**\n * Returns the coordinate at `m` using linear interpolation, or `null` if no\n * such coordinate exists.\n *\n * `extrapolate` controls extrapolation beyond the range of Ms in the\n * MultiLineString. If `extrapolate` is `true` then Ms less than the first\n * M will return the first coordinate and Ms greater than the last M will\n * return the last coordinate.\n *\n * @param {number} m M.\n * @param {boolean} [extrapolate] Extrapolate. Default is `false`.\n * @return {import(\"../coordinate.js\").Coordinate|null} Coordinate.\n * @api\n */\n getCoordinateAtM(m, extrapolate) {\n if (this.layout != 'XYM' && this.layout != 'XYZM') {\n return null;\n }\n extrapolate = extrapolate !== undefined ? extrapolate : false;\n return lineStringCoordinateAtM(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n m,\n extrapolate,\n );\n }\n\n /**\n * Return the coordinates of the linestring.\n * @return {Array} Coordinates.\n * @api\n * @override\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the coordinate at the provided fraction along the linestring.\n * The `fraction` is a number between 0 and 1, where 0 is the start of the\n * linestring and 1 is the end.\n * @param {number} fraction Fraction.\n * @param {import(\"../coordinate.js\").Coordinate} [dest] Optional coordinate whose values will\n * be modified. If not provided, a new coordinate will be returned.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinate of the interpolated point.\n * @api\n */\n getCoordinateAt(fraction, dest) {\n return interpolatePoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n fraction,\n dest,\n this.stride,\n );\n }\n\n /**\n * Return the length of the linestring on projected plane.\n * @return {number} Length (on projected plane).\n * @api\n */\n getLength() {\n return lineStringLength(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * @return {Array} Flat midpoint.\n */\n getFlatMidpoint() {\n if (this.flatMidpointRevision_ != this.getRevision()) {\n this.flatMidpoint_ = this.getCoordinateAt(\n 0.5,\n this.flatMidpoint_ ?? undefined,\n );\n this.flatMidpointRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.flatMidpoint_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LineString} Simplified LineString.\n * @protected\n * @override\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return new LineString(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'LineString';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return intersectsLineString(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent,\n this.getExtent(),\n );\n }\n\n /**\n * Set the coordinates of the linestring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default LineString;\n","/**\n * @module ol/color\n */\nimport {createCanvasContext2D} from './dom.js';\nimport {clamp, toFixed} from './math.js';\n\n/**\n * A color represented as a short array [red, green, blue, alpha].\n * red, green, and blue should be integers in the range 0..255 inclusive.\n * alpha should be a float in the range 0..1 inclusive. If no alpha value is\n * given then `1` will be used.\n * @typedef {Array} Color\n * @api\n */\n\n/**\n * Color to indicate that no color should be rendered. This is meant to be used for per-reference\n * comparisons only.\n * @type {Color}\n */\nexport const NO_COLOR = [NaN, NaN, NaN, 0];\n\nlet colorParseContext;\n/**\n * @return {CanvasRenderingContext2D} The color parse context\n */\nfunction getColorParseContext() {\n if (!colorParseContext) {\n colorParseContext = createCanvasContext2D(1, 1, undefined, {\n willReadFrequently: true,\n desynchronized: true,\n });\n }\n return colorParseContext;\n}\n\nconst rgbModernRegEx =\n /^rgba?\\(\\s*(\\d+%?)\\s+(\\d+%?)\\s+(\\d+%?)(?:\\s*\\/\\s*(\\d+%|\\d*\\.\\d+|[01]))?\\s*\\)$/i;\nconst rgbLegacyAbsoluteRegEx =\n /^rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(?:\\s*,\\s*(\\d+%|\\d*\\.\\d+|[01]))?\\s*\\)$/i;\nconst rgbLegacyPercentageRegEx =\n /^rgba?\\(\\s*(\\d+%)\\s*,\\s*(\\d+%)\\s*,\\s*(\\d+%)(?:\\s*,\\s*(\\d+%|\\d*\\.\\d+|[01]))?\\s*\\)$/i;\nconst hexRegEx = /^#([\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/i;\n\n/**\n * @param {string} s Color component as number or percentage.\n * @param {number} divider Divider for percentage.\n * @return {number} Color component.\n */\nfunction toColorComponent(s, divider) {\n return s.endsWith('%')\n ? Number(s.substring(0, s.length - 1)) / divider\n : Number(s);\n}\n\n/**\n * @param {string} color Color string.\n */\nfunction throwInvalidColor(color) {\n throw new Error('failed to parse \"' + color + '\" as color');\n}\n\n/**\n * @param {string} color Color string.\n * @return {Color} RGBa color array.\n */\nfunction parseRgba(color) {\n // Fast lane for rgb(a) colors\n if (color.toLowerCase().startsWith('rgb')) {\n const rgb =\n color.match(rgbLegacyAbsoluteRegEx) ||\n color.match(rgbModernRegEx) ||\n color.match(rgbLegacyPercentageRegEx);\n if (rgb) {\n const alpha = rgb[4];\n const rgbDivider = 100 / 255;\n return [\n clamp((toColorComponent(rgb[1], rgbDivider) + 0.5) | 0, 0, 255),\n clamp((toColorComponent(rgb[2], rgbDivider) + 0.5) | 0, 0, 255),\n clamp((toColorComponent(rgb[3], rgbDivider) + 0.5) | 0, 0, 255),\n alpha !== undefined ? clamp(toColorComponent(alpha, 100), 0, 1) : 1,\n ];\n }\n throwInvalidColor(color);\n }\n // Fast lane for hex colors (also with alpha)\n if (color.startsWith('#')) {\n if (hexRegEx.test(color)) {\n const hex = color.substring(1);\n const step = hex.length <= 4 ? 1 : 2;\n const colorFromHex = [0, 0, 0, 255];\n for (let i = 0, ii = hex.length; i < ii; i += step) {\n let colorComponent = parseInt(hex.substring(i, i + step), 16);\n if (step === 1) {\n colorComponent += colorComponent << 4;\n }\n colorFromHex[i / step] = colorComponent;\n }\n colorFromHex[3] = colorFromHex[3] / 255;\n return colorFromHex;\n }\n throwInvalidColor(color);\n }\n // Use canvas color serialization to parse the color into hex or rgba\n // See https://www.w3.org/TR/2021/SPSD-2dcontext-20210128/#serialization-of-a-color\n const context = getColorParseContext();\n context.fillStyle = '#abcdef';\n let invalidCheckFillStyle = context.fillStyle;\n context.fillStyle = color;\n if (context.fillStyle === invalidCheckFillStyle) {\n context.fillStyle = '#fedcba';\n invalidCheckFillStyle = context.fillStyle;\n context.fillStyle = color;\n if (context.fillStyle === invalidCheckFillStyle) {\n throwInvalidColor(color);\n }\n }\n const colorString = context.fillStyle;\n if (colorString.startsWith('#') || colorString.startsWith('rgba')) {\n return parseRgba(colorString);\n }\n context.clearRect(0, 0, 1, 1);\n context.fillRect(0, 0, 1, 1);\n const colorFromImage = Array.from(context.getImageData(0, 0, 1, 1).data);\n colorFromImage[3] = toFixed(colorFromImage[3] / 255, 3);\n return colorFromImage;\n}\n\n/**\n * Return the color as an rgba string.\n * @param {Color|string} color Color.\n * @return {string} Rgba string.\n * @api\n */\nexport function asString(color) {\n if (typeof color === 'string') {\n return color;\n }\n return toString(color);\n}\n\n/**\n * @type {number}\n */\nconst MAX_CACHE_SIZE = 1024;\n\n/**\n * We maintain a small cache of parsed strings. Whenever the cache grows too large,\n * we delete an arbitrary set of the entries.\n *\n * @type {Object}\n */\nconst cache = {};\n\n/**\n * @type {number}\n */\nlet cacheSize = 0;\n\n/**\n * @param {Color} color A color that may or may not have an alpha channel.\n * @return {Color} The input color with an alpha channel. If the input color has\n * an alpha channel, the input color will be returned unchanged. Otherwise, a new\n * array will be returned with the input color and an alpha channel of 1.\n */\nexport function withAlpha(color) {\n if (color.length === 4) {\n return color;\n }\n const output = color.slice();\n output[3] = 1;\n return output;\n}\n\n// The functions b1, b2, a1, a2, rgbaToLcha and lchaToRgba below are adapted from\n// https://stackoverflow.com/a/67219995/2389327\n\n/**\n * @param {number} v Input value.\n * @return {number} Output value.\n */\nfunction b1(v) {\n return v > 0.0031308 ? Math.pow(v, 1 / 2.4) * 269.025 - 14.025 : v * 3294.6;\n}\n\n/**\n * @param {number} v Input value.\n * @return {number} Output value.\n */\nfunction b2(v) {\n return v > 0.2068965 ? Math.pow(v, 3) : (v - 4 / 29) * (108 / 841);\n}\n\n/**\n * @param {number} v Input value.\n * @return {number} Output value.\n */\nfunction a1(v) {\n return v > 10.314724 ? Math.pow((v + 14.025) / 269.025, 2.4) : v / 3294.6;\n}\n\n/**\n * @param {number} v Input value.\n * @return {number} Output value.\n */\nfunction a2(v) {\n return v > 0.0088564 ? Math.pow(v, 1 / 3) : v / (108 / 841) + 4 / 29;\n}\n\n/**\n * @param {Color} color RGBA color.\n * @return {Color} LCHuv color with alpha.\n */\nexport function rgbaToLcha(color) {\n const r = a1(color[0]);\n const g = a1(color[1]);\n const b = a1(color[2]);\n const y = a2(r * 0.222488403 + g * 0.716873169 + b * 0.06060791);\n const l = 500 * (a2(r * 0.452247074 + g * 0.399439023 + b * 0.148375274) - y);\n const q = 200 * (y - a2(r * 0.016863605 + g * 0.117638439 + b * 0.865350722));\n const h = Math.atan2(q, l) * (180 / Math.PI);\n return [\n 116 * y - 16,\n Math.sqrt(l * l + q * q),\n h < 0 ? h + 360 : h,\n color[3],\n ];\n}\n\n/**\n * @param {Color} color LCHuv color with alpha.\n * @return {Color} RGBA color.\n */\nexport function lchaToRgba(color) {\n const l = (color[0] + 16) / 116;\n const c = color[1];\n const h = (color[2] * Math.PI) / 180;\n const y = b2(l);\n const x = b2(l + (c / 500) * Math.cos(h));\n const z = b2(l - (c / 200) * Math.sin(h));\n const r = b1(x * 3.021973625 - y * 1.617392459 - z * 0.404875592);\n const g = b1(x * -0.943766287 + y * 1.916279586 + z * 0.027607165);\n const b = b1(x * 0.069407491 - y * 0.22898585 + z * 1.159737864);\n return [\n clamp((r + 0.5) | 0, 0, 255),\n clamp((g + 0.5) | 0, 0, 255),\n clamp((b + 0.5) | 0, 0, 255),\n color[3],\n ];\n}\n\n/**\n * @param {string} s String.\n * @return {Color} Color.\n */\nexport function fromString(s) {\n if (s === 'none') {\n return NO_COLOR;\n }\n if (cache.hasOwnProperty(s)) {\n return cache[s];\n }\n if (cacheSize >= MAX_CACHE_SIZE) {\n let i = 0;\n for (const key in cache) {\n if ((i++ & 3) === 0) {\n delete cache[key];\n --cacheSize;\n }\n }\n }\n\n const color = parseRgba(s);\n if (color.length !== 4) {\n throwInvalidColor(s);\n }\n for (const c of color) {\n if (isNaN(c)) {\n throwInvalidColor(s);\n }\n }\n cache[s] = color;\n ++cacheSize;\n return color;\n}\n\n/**\n * Return the color as an array. This function maintains a cache of calculated\n * arrays which means the result should not be modified.\n * @param {Color|string} color Color.\n * @return {Color} Color.\n * @api\n */\nexport function asArray(color) {\n if (Array.isArray(color)) {\n return color;\n }\n return fromString(color);\n}\n\n/**\n * @param {Color} color Color.\n * @return {string} String.\n */\nexport function toString(color) {\n let r = color[0];\n if (r != (r | 0)) {\n r = (r + 0.5) | 0;\n }\n let g = color[1];\n if (g != (g | 0)) {\n g = (g + 0.5) | 0;\n }\n let b = color[2];\n if (b != (b | 0)) {\n b = (b + 0.5) | 0;\n }\n const a = color[3] === undefined ? 1 : Math.round(color[3] * 1000) / 1000;\n return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';\n}\n\n/**\n * @param {string} s String.\n * @return {boolean} Whether the string is actually a valid color\n */\nexport function isStringColor(s) {\n try {\n fromString(s);\n return true;\n } catch {\n return false;\n }\n}\n","/**\n * @module ol/style/IconImageCache\n */\nimport ImageState from '../ImageState.js';\nimport {asArray} from '../color.js';\nimport {getSharedCanvasContext2D} from '../dom.js';\n\n/**\n * @classdesc\n * Singleton class. Available through {@link module:ol/style/IconImageCache.shared}.\n */\nclass IconImageCache {\n constructor() {\n /**\n * @type {!Object}\n * @private\n */\n this.cache_ = {};\n\n /**\n * @type {!Object}\n * @private\n */\n this.patternCache_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.cacheSize_ = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.maxCacheSize_ = 1024;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n clear() {\n this.cache_ = {};\n this.patternCache_ = {};\n this.cacheSize_ = 0;\n }\n\n /**\n * @return {boolean} Can expire cache.\n */\n canExpireCache() {\n return this.cacheSize_ > this.maxCacheSize_;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n expire() {\n if (this.canExpireCache()) {\n let i = 0;\n for (const key in this.cache_) {\n const iconImage = this.cache_[key];\n if ((i++ & 3) === 0 && !iconImage.hasListener()) {\n delete this.cache_[key];\n delete this.patternCache_[key];\n --this.cacheSize_;\n }\n }\n }\n }\n\n /**\n * @param {string} src Src.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {import(\"./IconImage.js\").default} Icon image.\n */\n get(src, color) {\n const key = getCacheKey(src, color);\n\n const icon = key in this.cache_ ? this.cache_[key] : null;\n return icon;\n }\n\n /**\n * @param {string} src Src.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {CanvasPattern} Icon image.\n */\n getPattern(src, color) {\n const key = getCacheKey(src, color);\n return key in this.patternCache_ ? this.patternCache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {import(\"./IconImage.js\").default|null} iconImage Icon image.\n * @param {boolean} [pattern] Also cache a `'repeat'` pattern with this `iconImage`.\n */\n set(src, color, iconImage, pattern) {\n const key = getCacheKey(src, color);\n const update = key in this.cache_;\n this.cache_[key] = iconImage;\n if (pattern) {\n if (iconImage.getImageState() === ImageState.IDLE) {\n iconImage.load();\n }\n if (iconImage.getImageState() === ImageState.LOADING) {\n iconImage.ready().then(() => {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n });\n } else {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n }\n }\n if (!update) {\n ++this.cacheSize_;\n }\n }\n\n /**\n * Set the cache size of the icon cache. Default is `1024`. Change this value when\n * your map uses more than 1024 different icon images and you are not caching icon\n * styles on the application level.\n * @param {number} maxCacheSize Cache max size.\n * @api\n */\n setSize(maxCacheSize) {\n this.maxCacheSize_ = maxCacheSize;\n this.expire();\n }\n}\n\n/**\n * @param {string} src Src.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {string} Cache key.\n */\nexport function getCacheKey(src, color) {\n const colorString = color ? asArray(color) : 'null';\n return src + ':' + colorString;\n}\n\nexport default IconImageCache;\n\n/**\n * The {@link module:ol/style/IconImageCache~IconImageCache} for\n * {@link module:ol/style/Icon~Icon} images.\n * @api\n */\nexport const shared = new IconImageCache();\n","/**\n * @module ol/style/IconImage\n */\n\nimport {decodeFallback} from '../Image.js';\nimport ImageState from '../ImageState.js';\nimport {asString} from '../color.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport EventType from '../events/EventType.js';\nimport EventTarget from '../events/Target.js';\nimport {shared as iconImageCache} from './IconImageCache.js';\n\n/**\n * @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}\n */\nlet taintedTestContext = null;\n\nclass IconImage extends EventTarget {\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null} image Image.\n * @param {string|undefined} src Src.\n * @param {import('../dom.js').ImageAttributes} imageAttributes Image attributes options.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n */\n constructor(image, src, imageAttributes, imageState, color) {\n super();\n\n /**\n * @private\n * @type {HTMLImageElement|OffscreenCanvas|HTMLCanvasElement|ImageBitmap}\n */\n this.hitDetectionImage_ = null;\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}\n */\n this.image_ = image;\n\n /**\n * @private\n * @type {string|null}\n */\n this.crossOrigin_ = imageAttributes?.crossOrigin;\n\n /**\n * @private\n * @type {ReferrerPolicy}\n */\n this.referrerPolicy_ = imageAttributes?.referrerPolicy;\n\n /**\n * @private\n * @type {Object}\n */\n this.canvas_ = {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|string|null}\n */\n this.color_ = color;\n\n /**\n * @private\n * @type {import(\"../ImageState.js\").default}\n */\n this.imageState_ = imageState === undefined ? ImageState.IDLE : imageState;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size|null}\n */\n this.size_ =\n image && image.width && image.height ? [image.width, image.height] : null;\n\n /**\n * @private\n * @type {string|undefined}\n */\n this.src_ = src;\n\n /**\n * @private\n */\n this.tainted_;\n\n /**\n * @private\n * @type {Promise|null}\n */\n this.ready_ = null;\n }\n\n /**\n * @private\n */\n initializeImage_() {\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n if (this.referrerPolicy_ !== undefined) {\n this.image_.referrerPolicy = this.referrerPolicy_;\n }\n }\n\n /**\n * @private\n * @return {boolean} The image canvas is tainted.\n */\n isTainted_() {\n if (this.tainted_ === undefined && this.imageState_ === ImageState.LOADED) {\n if (!taintedTestContext) {\n taintedTestContext = createCanvasContext2D(1, 1, undefined, {\n willReadFrequently: true,\n });\n }\n taintedTestContext.drawImage(this.image_, 0, 0);\n try {\n taintedTestContext.getImageData(0, 0, 1, 1);\n this.tainted_ = false;\n } catch {\n taintedTestContext = null;\n this.tainted_ = true;\n }\n }\n return this.tainted_ === true;\n }\n\n /**\n * @private\n */\n dispatchChangeEvent_() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @private\n */\n handleImageError_() {\n this.imageState_ = ImageState.ERROR;\n this.dispatchChangeEvent_();\n }\n\n /**\n * @private\n */\n handleImageLoad_() {\n this.imageState_ = ImageState.LOADED;\n this.size_ = [this.image_.width, this.image_.height];\n this.dispatchChangeEvent_();\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} Image or Canvas element or image bitmap.\n */\n getImage(pixelRatio) {\n if (!this.image_) {\n this.initializeImage_();\n }\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;\n }\n\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image Image.\n */\n setImage(image) {\n this.image_ = image;\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Image or Canvas element.\n */\n getPixelRatio(pixelRatio) {\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? pixelRatio : 1;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * @return {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} Image element.\n */\n getHitDetectionImage() {\n if (!this.image_) {\n this.initializeImage_();\n }\n if (!this.hitDetectionImage_) {\n if (this.isTainted_()) {\n const width = this.size_[0];\n const height = this.size_[1];\n const context = createCanvasContext2D(width, height);\n context.fillRect(0, 0, width, height);\n this.hitDetectionImage_ = context.canvas;\n } else {\n this.hitDetectionImage_ = this.image_;\n }\n }\n return this.hitDetectionImage_;\n }\n\n /**\n * Get the size of the icon (in pixels).\n * @return {import(\"../size.js\").Size} Image size.\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * @return {string|undefined} Image src.\n */\n getSrc() {\n return this.src_;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.imageState_ !== ImageState.IDLE) {\n return;\n }\n if (!this.image_) {\n this.initializeImage_();\n }\n\n this.imageState_ = ImageState.LOADING;\n try {\n if (this.src_ !== undefined) {\n /** @type {HTMLImageElement} */ (this.image_).src = this.src_;\n }\n } catch {\n this.handleImageError_();\n }\n if (this.image_ instanceof HTMLImageElement) {\n decodeFallback(this.image_, this.src_)\n .then((image) => {\n this.image_ = image;\n this.handleImageLoad_();\n })\n .catch(this.handleImageError_.bind(this));\n }\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @private\n */\n replaceColor_(pixelRatio) {\n if (\n !this.color_ ||\n this.canvas_[pixelRatio] ||\n this.imageState_ !== ImageState.LOADED\n ) {\n return;\n }\n\n const image = this.image_;\n const ctx = createCanvasContext2D(\n Math.ceil(image.width * pixelRatio),\n Math.ceil(image.height * pixelRatio),\n );\n const canvas = ctx.canvas;\n\n ctx.scale(pixelRatio, pixelRatio);\n ctx.drawImage(image, 0, 0);\n\n ctx.globalCompositeOperation = 'multiply';\n ctx.fillStyle = asString(this.color_);\n ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);\n\n ctx.globalCompositeOperation = 'destination-in';\n ctx.drawImage(image, 0, 0);\n\n this.canvas_[pixelRatio] = canvas;\n }\n\n /**\n * @return {Promise} Promise that resolves when the image is loaded.\n */\n ready() {\n if (!this.ready_) {\n this.ready_ = new Promise((resolve) => {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n resolve();\n } else {\n const onChange = () => {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n this.removeEventListener(EventType.CHANGE, onChange);\n resolve();\n }\n };\n this.addEventListener(EventType.CHANGE, onChange);\n }\n });\n }\n return this.ready_;\n }\n}\n\n/**\n * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null} image Image.\n * @param {string|undefined} src Src.\n * @param {import('../dom.js').ImageAttributes} imageAttributes Image attributes options.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {boolean} [pattern] Also cache a `repeat` pattern with the icon image.\n * @return {IconImage} Icon image.\n */\nexport function get(image, src, imageAttributes, imageState, color, pattern) {\n let iconImage =\n src === undefined ? undefined : iconImageCache.get(src, color);\n if (!iconImage) {\n iconImage = new IconImage(\n image,\n image && 'src' in image ? image.src || undefined : src,\n imageAttributes,\n imageState,\n color,\n );\n iconImageCache.set(src, color, iconImage, pattern);\n }\n if (pattern && iconImage && !iconImageCache.getPattern(src, color)) {\n iconImageCache.set(src, color, iconImage, pattern);\n }\n return iconImage;\n}\n\nexport default IconImage;\n","/**\n * @module ol/colorlike\n */\nimport ImageState from './ImageState.js';\nimport {toString} from './color.js';\nimport {createCanvasContext2D} from './dom.js';\nimport {get as getIconImage} from './style/IconImage.js';\nimport {shared as iconCache} from './style/IconImageCache.js';\n\n/**\n * @typedef {Object} PatternDescriptor\n * @property {string} src Pattern image URL\n * @property {import(\"./color.js\").Color|string} [color] Color to tint the pattern with.\n * @property {import(\"./size.js\").Size} [size] Size of the desired slice from the pattern image.\n * Use this together with `offset` when the pattern image is a sprite sheet.\n * @property {import(\"./size.js\").Size} [offset] Offset of the desired slice from the pattern image.\n * Use this together with `size` when the pattern image is a sprite sheet.\n */\n\n/**\n * A type accepted by CanvasRenderingContext2D.fillStyle\n * or CanvasRenderingContext2D.strokeStyle.\n * Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),\n * or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for\n * patterns and gradients as fill style is an increment of 512 css pixels from map coordinate\n * `[0, 0]`. For seamless repeat patterns, width and height of the pattern image\n * must be a factor of two (2, 4, 8, ..., 512).\n *\n * @typedef {string|CanvasPattern|CanvasGradient} ColorLike\n * @api\n */\n\n/**\n * @param {import(\"./color.js\").Color|ColorLike|PatternDescriptor|null} color Color.\n * @return {ColorLike|null} The color as an {@link ol/colorlike~ColorLike}.\n * @api\n */\nexport function asColorLike(color) {\n if (!color) {\n return null;\n }\n if (Array.isArray(color)) {\n return toString(color);\n }\n if (typeof color === 'object' && 'src' in color) {\n return asCanvasPattern(color);\n }\n return color;\n}\n\n/**\n * @param {PatternDescriptor} pattern Pattern descriptor.\n * @return {CanvasPattern|null} Canvas pattern or null if the pattern referenced in the\n * PatternDescriptor was not found in the icon image cache.\n */\nfunction asCanvasPattern(pattern) {\n if (!pattern.offset || !pattern.size) {\n return iconCache.getPattern(pattern.src, pattern.color);\n }\n\n const cacheKey = pattern.src + ':' + pattern.offset;\n\n const canvasPattern = iconCache.getPattern(cacheKey, pattern.color);\n if (canvasPattern) {\n return canvasPattern;\n }\n\n const iconImage = iconCache.get(pattern.src, null);\n if (iconImage.getImageState() !== ImageState.LOADED) {\n return null;\n }\n const patternCanvasContext = createCanvasContext2D(\n pattern.size[0],\n pattern.size[1],\n );\n patternCanvasContext.drawImage(\n iconImage.getImage(1),\n pattern.offset[0],\n pattern.offset[1],\n pattern.size[0],\n pattern.size[1],\n 0,\n 0,\n pattern.size[0],\n pattern.size[1],\n );\n getIconImage(\n patternCanvasContext.canvas,\n cacheKey,\n undefined,\n ImageState.LOADED,\n pattern.color,\n true,\n );\n return iconCache.getPattern(cacheKey, pattern.color);\n}\n","import {angleBetween} from '../../coordinate.js';\n\n/**\n * Offsets a line string to the left / right along its segments direction.\n * Offset is applied to each segment of the line in the direciton of the segment normal (positive offset goes \"right\" relative to the line direction).\n * For very sharp angles between segments, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.\n *\n * Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} start Start index.\n * @param {number} end End index.\n * @param {number} stride Stride.\n * @param {number} offset Offset distance along the segment normal direction.\n * Positive values offset to the right relative to the direction of the line.\n * Negative values offset to the left.\n * @param {boolean} isClosedRing If coordinates build a closed circle (in this the first and the last coordinate offsets will consider previous / next ring coordinate)\n * @param {Array} [dest] Destination coordinate array. If not provided a new one will be created\n * @param {number} [destinationStride] Stride of destination coordinates. If unspecified, assumed to be same as the source coordinates stride.\n * @return {Array} Result flat coordinates of the offset line.\n */\nexport function offsetLineString(\n flatCoordinates,\n start,\n end,\n stride,\n offset,\n isClosedRing,\n dest,\n destinationStride,\n) {\n dest = dest ?? [];\n destinationStride = destinationStride ?? stride;\n\n const secondPointX = flatCoordinates[start + stride];\n const secondPointY = flatCoordinates[start + stride + 1];\n const secondToLastPointX = flatCoordinates[end - 2 * stride];\n const secondToLastPointY = flatCoordinates[end - 2 * stride + 1];\n let x, y, prevX, prevY, nextX, nextY, offsetX, offsetY;\n\n let i = 0;\n for (let j = start; j < end; j += stride) {\n // 1. Detect previous and next coordinates of a current vertex\n prevX = x;\n prevY = y;\n nextX = undefined;\n nextY = undefined;\n if (j + stride < end) {\n nextX = flatCoordinates[j + stride];\n nextY = flatCoordinates[j + stride + 1];\n }\n // First coordinate of a closed ring -> previous coordinate is the second to last one\n if (isClosedRing && j === start) {\n prevX = secondToLastPointX;\n prevY = secondToLastPointY;\n }\n // Last coordinate of a closed ring -> next coordinate is the second vertex of a line string (the last one is same as the first one for a closed ring)\n if (isClosedRing && j === end - stride) {\n nextX = secondPointX;\n nextY = secondPointY;\n }\n\n // 2. Current vertex to offset\n x = flatCoordinates[j];\n y = flatCoordinates[j + 1];\n\n // 3. Offset the vertex\n [offsetX, offsetY] = offsetLineVertex(\n x,\n y,\n prevX,\n prevY,\n nextX,\n nextY,\n offset,\n );\n dest[i++] = offsetX;\n dest[i++] = offsetY;\n\n // 4. Copy over other dimension values if any\n for (let k = 2; k < destinationStride; k++) {\n dest[i++] = flatCoordinates[j + k];\n }\n }\n\n if (dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Computes the offset of a single vertex of a line string.\n *\n * The function calculates a new vertex coordinate offset along the normal/miter direction of the line at this vertex.\n * Offset is applied along the segment normal (positive offset goes \"right\" relative to the line direction).\n * It handles first and last vertices (caps) as well as joins between two segments (mitering).\n * For very sharp angles, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.\n *\n * Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.\n *\n * @param {number} x Vertex x-coordinate.\n * @param {number} y Vertex y-coordinate.\n * @param {number|undefined} prevX Previous vertex x-coordinate.\n * Pass undefined if computing the offset for the first vertex (no previous vertex).\n * @param {number|undefined} prevY Previous vertex y-coordinate.\n * Pass undefined if computing the offset for the first vertex (no previous vertex).\n * @param {number|undefined} nextX Next vertex x-coordinate.\n * Pass undefined if computing the offset for the last vertex (no next vertex).\n * @param {number|undefined} nextY Next vertex y-coordinate.\n * Pass undefined if computing the offset for the last vertex (no next vertex).\n * @param {number} offset Offset distance along the segment normal direction.\n * Positive values offset to the right relative to the direction from previous to next vertex.\n * Negative values offset to the left.\n * @return {import(\"../../coordinate.js\").Coordinate} Offset vertex coordinate as `[x, y]`.\n */\nfunction offsetLineVertex(x, y, prevX, prevY, nextX, nextY, offset) {\n // Compute segment direction\n let nx, ny;\n if (prevX !== undefined && prevY !== undefined) {\n nx = x - prevX;\n ny = y - prevY;\n } else if (nextX !== undefined && nextY !== undefined) {\n nx = nextX - x;\n ny = nextY - y;\n } else {\n // no next, no previous point given -> just assume some default (horizontal) direction\n nx = 1;\n ny = 0;\n }\n\n // Normalize -> tangent\n const len = Math.hypot(nx, ny);\n const tx = nx / len;\n const ty = ny / len;\n\n // Rotate tangent 90° -> normal\n nx = -ty;\n ny = tx;\n\n // First / last vertex -> offset the point in the direction of the normal vector\n if (prevX === undefined || prevY === undefined) {\n return [x + nx * offset, y + ny * offset];\n }\n if (nextX === undefined || nextY === undefined) {\n return [x + nx * offset, y + ny * offset];\n }\n\n // Compute join angle - angle between 2 segments of the vertex.\n const joinAngle = angleBetween([x, y], [prevX, prevY], [nextX, nextY]);\n\n // Avoid huge or infinite miter joins for very sharp angles, offset in the segment direction in this case.\n if (Math.cos(joinAngle) > 0.998) {\n return [x + tx * offset, y + ty * offset];\n }\n\n // Compute join offset direction.\n // We rotate the normal vector by half of the join angle.\n // This gives the direction of the miter at the vertex.\n const cos = Math.cos(joinAngle / 2);\n const sin = Math.sin(joinAngle / 2);\n\n // Rotate the normal vector (nx, ny) by half of the join angle.\n // bx/by = bisector direction before normalization\n const bx = sin * nx + cos * ny;\n const by = -cos * nx + sin * ny;\n\n // Scale the bisector so that moving along it preserves the correct offset distance.\n // Dividing by sin(half of angle) converts the bisector into the true miter vector.\n // (This expands the miter for sharp angles and shortens it for wide ones.)\n const dx = bx * (1 / sin);\n const dy = by * (1 / sin);\n\n // Offset final vertex along miter direction\n return [x + dx * offset, y + dy * offset];\n}\n\n/**\n * Removes self-intersection loops (cycles) from an offset line.\n * When a polyline is offset, sharp turns can create self-intersecting loops.\n * This function detects those crossings and splices out the looped portions,\n * replacing them with the intersection point.\n *\n * @param {Array} coords Flat offset coordinates (modified in-place).\n * @param {number} stride Coordinate stride (typically 2).\n * @return {Array} The cleaned coordinate array.\n */\nexport function removeOffsetCycles(coords, stride) {\n for (let i = 0, ii = coords.length - 2; i < ii; i += stride) {\n for (let j = coords.length - 2 * stride; j > i + stride; j -= stride) {\n const p1x = coords[i];\n const p1y = coords[i + 1];\n const p2x = coords[i + stride];\n const p2y = coords[i + stride + 1];\n const p3x = coords[j];\n const p3y = coords[j + 1];\n const p4x = coords[j + stride];\n const p4y = coords[j + stride + 1];\n const d = (p4y - p3y) * (p2x - p1x) - (p4x - p3x) * (p2y - p1y);\n if (d === 0) {\n continue;\n }\n const t = ((p4x - p3x) * (p1y - p3y) - (p4y - p3y) * (p1x - p3x)) / d;\n const u = ((p2x - p1x) * (p1y - p3y) - (p2y - p1y) * (p1x - p3x)) / d;\n if (t > 0 && t < 1 && u > 0 && u < 1) {\n const ix = p1x + t * (p2x - p1x);\n const iy = p1y + t * (p2y - p1y);\n coords[i + stride] = ix;\n coords[i + stride + 1] = iy;\n coords.splice(i + 2 * stride, j - i - stride);\n break;\n }\n }\n }\n return coords;\n}\n","/**\n * @module ol/render/VectorContext\n */\n\n/**\n * @classdesc\n * Context for drawing geometries. A vector context is available on render\n * events and does not need to be constructed directly.\n * @api\n */\nclass VectorContext {\n /**\n * Render a geometry with a custom renderer.\n *\n * @param {import(\"../geom/SimpleGeometry.js\").default} geometry Geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {Function} renderer Renderer.\n * @param {Function} hitDetectionRenderer Renderer.\n * @param {number} [index] Render order index.\n */\n drawCustom(geometry, feature, renderer, hitDetectionRenderer, index) {}\n\n /**\n * Render a geometry.\n *\n * @param {import(\"../geom/Geometry.js\").default} geometry The geometry to render.\n */\n drawGeometry(geometry) {}\n\n /**\n * Set the rendering style.\n *\n * @param {import(\"../style/Style.js\").default} style The rendering style.\n */\n setStyle(style) {}\n\n /**\n * @param {import(\"../geom/Circle.js\").default} circleGeometry Circle geometry.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawCircle(circleGeometry, feature, index) {}\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {number} [index] Render order index.\n */\n drawFeature(feature, style, index) {}\n\n /**\n * @param {import(\"../geom/GeometryCollection.js\").default} geometryCollectionGeometry Geometry collection.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawGeometryCollection(geometryCollectionGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/LineString.js\").default|import(\"./Feature.js\").default} lineStringGeometry Line string geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawLineString(lineStringGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiLineString.js\").default|import(\"./Feature.js\").default} multiLineStringGeometry MultiLineString geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiLineString(multiLineStringGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiPoint.js\").default|import(\"./Feature.js\").default} multiPointGeometry MultiPoint geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiPoint(multiPointGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiPolygon.js\").default} multiPolygonGeometry MultiPolygon geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiPolygon(multiPolygonGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/Point.js\").default|import(\"./Feature.js\").default} pointGeometry Point geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawPoint(pointGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/Polygon.js\").default|import(\"./Feature.js\").default} polygonGeometry Polygon geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawPolygon(polygonGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/SimpleGeometry.js\").default|import(\"./Feature.js\").default} geometry Geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawText(geometry, feature, index) {}\n\n /**\n * @param {import(\"../style/Fill.js\").default} fillStyle Fill style.\n * @param {import(\"../style/Stroke.js\").default} strokeStyle Stroke style.\n */\n setFillStrokeStyle(fillStyle, strokeStyle) {}\n\n /**\n * @param {import(\"../style/Image.js\").default} imageStyle Image style.\n * @param {import(\"../render/canvas.js\").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with a text style.\n */\n setImageStyle(imageStyle, declutterImageWithText) {}\n\n /**\n * @param {import(\"../style/Text.js\").default} textStyle Text style.\n * @param {import(\"../render/canvas.js\").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with an image style.\n */\n setTextStyle(textStyle, declutterImageWithText) {}\n}\n\nexport default VectorContext;\n","/**\n * @module ol/css\n */\n\n/**\n * @typedef {Object} FontParameters\n * @property {string} style Style.\n * @property {string} variant Variant.\n * @property {string} weight Weight.\n * @property {string} size Size.\n * @property {string} lineHeight LineHeight.\n * @property {string} family Family.\n * @property {Array} families Families.\n */\n\n/**\n * The CSS class for hidden feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_HIDDEN = 'ol-hidden';\n\n/**\n * The CSS class that we'll give the DOM elements to have them selectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_SELECTABLE = 'ol-selectable';\n\n/**\n * The CSS class that we'll give the DOM elements to have them unselectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSELECTABLE = 'ol-unselectable';\n\n/**\n * The CSS class for unsupported feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSUPPORTED = 'ol-unsupported';\n\n/**\n * The CSS class for controls.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_CONTROL = 'ol-control';\n\n/**\n * The CSS class that we'll give the DOM elements that are collapsed, i.e.\n * to those elements which usually can be expanded.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_COLLAPSED = 'ol-collapsed';\n\n/**\n * From https://stackoverflow.com/questions/10135697/regex-to-parse-any-css-font\n * @type {RegExp}\n */\nconst fontRegEx = new RegExp(\n [\n '^\\\\s*(?=(?:(?:[-a-z]+\\\\s*){0,2}(italic|oblique))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(small-caps))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)',\n '(?:(?:normal|\\\\1|\\\\2|\\\\3)\\\\s*){0,3}((?:xx?-)?',\n '(?:small|large)|medium|smaller|larger|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx]))',\n '(?:\\\\s*\\\\/\\\\s*(normal|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx])?))',\n '?\\\\s*([-,\\\\\"\\\\\\'\\\\sa-z0-9]+?)\\\\s*$',\n ].join(''),\n 'i',\n);\n/** @type {Array<'style'|'variant'|'weight'|'size'|'lineHeight'|'family'>} */\nconst fontRegExMatchIndex = [\n 'style',\n 'variant',\n 'weight',\n 'size',\n 'lineHeight',\n 'family',\n];\n\n/** @type {Object} */\nexport const fontWeights = {\n normal: 400,\n bold: 700,\n};\n\n/**\n * Get the list of font families from a font spec. Note that this doesn't work\n * for font families that have commas in them.\n * @param {string} fontSpec The CSS font property.\n * @return {FontParameters|null} The font parameters (or null if the input spec is invalid).\n */\nexport const getFontParameters = function (fontSpec) {\n const match = fontSpec.match(fontRegEx);\n if (!match) {\n return null;\n }\n const style = /** @type {FontParameters} */ ({\n lineHeight: 'normal',\n size: '1.2em',\n style: 'normal',\n weight: '400',\n variant: 'normal',\n });\n for (let i = 0, ii = fontRegExMatchIndex.length; i < ii; ++i) {\n const value = match[i + 1];\n if (value !== undefined) {\n style[fontRegExMatchIndex[i]] =\n typeof value === 'string' ? value.trim() : value;\n }\n }\n if (isNaN(Number(style.weight)) && style.weight in fontWeights) {\n style.weight = fontWeights[style.weight];\n }\n style.families = style.family\n .split(/,\\s?/)\n .map((f) => f.trim().replace(/^['\"]|['\"]$/g, ''));\n return style;\n};\n","/**\n * @module ol/render/canvas\n */\nimport BaseObject from '../Object.js';\nimport {fontWeights, getFontParameters} from '../css.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {WORKER_OFFSCREEN_CANVAS} from '../has.js';\nimport {clear} from '../obj.js';\n\n/**\n * @typedef {'Circle' | 'Image' | 'LineString' | 'Polygon' | 'Text' | 'Default'} BuilderType\n */\n\n/**\n * @typedef {Object} FillState\n * @property {import(\"../colorlike.js\").ColorLike} fillStyle FillStyle.\n */\n\n/**\n * @typedef Label\n * @property {number} width Width.\n * @property {number} height Height.\n * @property {Array} contextInstructions ContextInstructions.\n */\n\n/**\n * @typedef {Object} FillStrokeState\n * @property {import(\"../colorlike.js\").ColorLike} [currentFillStyle] Current FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [currentStrokeStyle] Current StrokeStyle.\n * @property {CanvasLineCap} [currentLineCap] Current LineCap.\n * @property {Array} currentLineDash Current LineDash.\n * @property {number} [currentLineDashOffset] Current LineDashOffset.\n * @property {CanvasLineJoin} [currentLineJoin] Current LineJoin.\n * @property {number} [currentLineWidth] Current LineWidth.\n * @property {number} [currentMiterLimit] Current MiterLimit.\n * @property {number} [currentStrokeOffset] Current StrokeOffset.\n * @property {number} [lastStroke] Last stroke.\n * @property {import(\"../colorlike.js\").ColorLike} [fillStyle] FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [strokeStyle] StrokeStyle.\n * @property {CanvasLineCap} [lineCap] LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} [lineDashOffset] LineDashOffset.\n * @property {CanvasLineJoin} [lineJoin] LineJoin.\n * @property {number} [lineWidth] LineWidth.\n * @property {number} [miterLimit] MiterLimit.\n * @property {number} [strokeOffset] StrokeOffset.\n * @property {number} [fillPatternScale] Fill pattern scale.\n */\n\n/**\n * @typedef {Object} StrokeState\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} lineWidth LineWidth.\n * @property {number} miterLimit MiterLimit.\n * @property {number} [strokeOffset] StrokeOffset.\n * @property {import(\"../colorlike.js\").ColorLike} strokeStyle StrokeStyle.\n */\n\n/**\n * @typedef {Object} TextState\n * @property {string} font Font.\n * @property {CanvasTextAlign} [textAlign] TextAlign.\n * @property {number} [repeat] Repeat.\n * @property {import(\"../style/Text.js\").TextJustify} [justify] Justify.\n * @property {CanvasTextBaseline} textBaseline TextBaseline.\n * @property {import(\"../style/Text.js\").TextPlacement} [placement] Placement.\n * @property {number} [maxAngle] MaxAngle.\n * @property {boolean} [overflow] Overflow.\n * @property {import(\"../style/Fill.js\").default} [backgroundFill] BackgroundFill.\n * @property {import(\"../style/Stroke.js\").default} [backgroundStroke] BackgroundStroke.\n * @property {import(\"../size.js\").Size} [scale] Scale.\n * @property {Array} [padding] Padding.\n */\n\n/**\n * @typedef {Object} SerializableInstructions\n * @property {Array<*>} instructions The rendering instructions.\n * @property {Array<*>} hitDetectionInstructions The rendering hit detection instructions.\n * @property {Array} coordinates The array of all coordinates.\n * @property {!Object} [textStates] The text states (decluttering).\n * @property {!Object} [fillStates] The fill states (decluttering).\n * @property {!Object} [strokeStates] The stroke states (decluttering).\n */\n\n/**\n * @typedef {Object} DeclutterImageWithText\n */\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFont = '10px sans-serif';\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFillStyle = '#000';\n\n/**\n * @const\n * @type {CanvasLineCap}\n */\nexport const defaultLineCap = 'round';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultLineDash = [];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineDashOffset = 0;\n\n/**\n * @const\n * @type {CanvasLineJoin}\n */\nexport const defaultLineJoin = 'round';\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultMiterLimit = 10;\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultStrokeOffset = 0;\n\n/**\n * @const\n * @type {import(\"../colorlike.js\").ColorLike}\n */\nexport const defaultStrokeStyle = '#000';\n\n/**\n * @const\n * @type {CanvasTextAlign}\n */\nexport const defaultTextAlign = 'center';\n\n/**\n * @const\n * @type {CanvasTextBaseline}\n */\nexport const defaultTextBaseline = 'middle';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultPadding = [0, 0, 0, 0];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineWidth = 1;\n\n/**\n * @type {BaseObject}\n */\nexport const checkedFonts = new BaseObject();\n\n/**\n * @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}\n */\nlet measureContext = null;\n\n/**\n * @type {string}\n */\nlet measureFont;\n\n/**\n * @type {!Object}\n */\nexport const textHeights = {};\n\nconst genericFontFamilies = new Set([\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'emoji',\n 'math',\n 'fangsong',\n]);\n\n/**\n * @param {string} style Css font-style\n * @param {string} weight Css font-weight\n * @param {string} family Css font-family\n * @return {string} Font key.\n */\nfunction getFontKey(style, weight, family) {\n return `${style} ${weight} 16px \"${family}\"`;\n}\n\n/**\n * Clears the label cache when a font becomes available.\n * @param {string} fontSpec CSS font spec.\n */\nexport const registerFont = (function () {\n const retries = 100;\n let timeout, fontFaceSet;\n\n /**\n * @param {string} fontSpec Css font spec\n * @return {Promise} Font with style and weight is available\n */\n async function isAvailable(fontSpec) {\n await fontFaceSet.ready;\n const fontFaces = await fontFaceSet.load(fontSpec);\n if (fontFaces.length === 0) {\n return false;\n }\n const font = getFontParameters(fontSpec);\n const checkFamily = font.families[0].toLowerCase();\n const checkWeight = font.weight;\n return fontFaces.some(\n /**\n * @param {import('../css.js').FontParameters} f Font.\n * @return {boolean} Font matches.\n */\n (f) => {\n const family = f.family.replace(/^['\"]|['\"]$/g, '').toLowerCase();\n const weight = fontWeights[f.weight] || f.weight;\n return (\n family === checkFamily &&\n f.style === font.style &&\n weight == checkWeight\n );\n },\n );\n }\n\n async function check() {\n await fontFaceSet.ready;\n let done = true;\n const checkedFontsProperties = checkedFonts.getProperties();\n const fonts = Object.keys(checkedFontsProperties).filter(\n (key) => checkedFontsProperties[key] < retries,\n );\n for (let i = fonts.length - 1; i >= 0; --i) {\n const font = fonts[i];\n let currentRetries = checkedFontsProperties[font];\n if (currentRetries < retries) {\n if (await isAvailable(font)) {\n clear(textHeights);\n checkedFonts.set(font, retries);\n } else {\n currentRetries += 10;\n checkedFonts.set(font, currentRetries, true);\n if (currentRetries < retries) {\n done = false;\n }\n }\n }\n }\n timeout = undefined;\n if (!done) {\n timeout = setTimeout(check, 100);\n }\n }\n\n return async function (fontSpec) {\n if (!fontFaceSet) {\n fontFaceSet = WORKER_OFFSCREEN_CANVAS ? self.fonts : document.fonts;\n }\n const font = getFontParameters(fontSpec);\n if (!font) {\n return;\n }\n const families = font.families;\n let needCheck = false;\n for (const family of families) {\n if (genericFontFamilies.has(family)) {\n continue;\n }\n const key = getFontKey(font.style, font.weight, family);\n if (checkedFonts.get(key) !== undefined) {\n continue;\n }\n checkedFonts.set(key, 0, true);\n needCheck = true;\n }\n if (needCheck) {\n clearTimeout(timeout);\n timeout = setTimeout(check, 100);\n }\n };\n})();\n\n/**\n * @param {string} font Font to use for measuring.\n * @return {import(\"../size.js\").Size} Measurement.\n */\nexport const measureTextHeight = (function () {\n /**\n * @type {HTMLDivElement}\n */\n let measureElement;\n return function (fontSpec) {\n let height = textHeights[fontSpec];\n if (height == undefined) {\n if (WORKER_OFFSCREEN_CANVAS) {\n const font = getFontParameters(fontSpec);\n const metrics = measureText(fontSpec, 'Žg');\n const lineHeight = isNaN(Number(font.lineHeight))\n ? 1.2\n : Number(font.lineHeight);\n height =\n lineHeight *\n (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);\n } else {\n if (!measureElement) {\n measureElement = document.createElement('div');\n measureElement.innerHTML = 'M';\n measureElement.style.minHeight = '0';\n measureElement.style.maxHeight = 'none';\n measureElement.style.height = 'auto';\n measureElement.style.padding = '0';\n measureElement.style.border = 'none';\n measureElement.style.position = 'absolute';\n measureElement.style.display = 'block';\n measureElement.style.left = '-99999px';\n }\n measureElement.style.font = fontSpec;\n document.body.appendChild(measureElement);\n height = measureElement.offsetHeight;\n document.body.removeChild(measureElement);\n }\n textHeights[fontSpec] = height;\n }\n return height;\n };\n})();\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {TextMetrics} Text metrics.\n */\nfunction measureText(font, text) {\n if (!measureContext) {\n measureContext = createCanvasContext2D(1, 1);\n }\n if (font != measureFont) {\n measureContext.font = font;\n measureFont = measureContext.font;\n }\n return measureContext.measureText(text);\n}\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {number} Width.\n */\nexport function measureTextWidth(font, text) {\n return measureText(font, text).width;\n}\n\n/**\n * Measure text width using a cache.\n * @param {string} font The font.\n * @param {string} text The text to measure.\n * @param {Object} cache A lookup of cached widths by text.\n * @return {number} The text width.\n */\nexport function measureAndCacheTextWidth(font, text, cache) {\n if (text in cache) {\n return cache[text];\n }\n const width = text\n .split('\\n')\n .reduce((prev, curr) => Math.max(prev, measureTextWidth(font, curr)), 0);\n cache[text] = width;\n return width;\n}\n\n/**\n * @param {TextState} baseStyle Base style.\n * @param {Array} chunks Text chunks to measure.\n * @return {{width: number, height: number, widths: Array, heights: Array, lineWidths: Array}}} Text metrics.\n */\nexport function getTextDimensions(baseStyle, chunks) {\n const widths = [];\n const heights = [];\n const lineWidths = [];\n let width = 0;\n let lineWidth = 0;\n let height = 0;\n let lineHeight = 0;\n for (let i = 0, ii = chunks.length; i <= ii; i += 2) {\n const text = chunks[i];\n if (text === '\\n' || i === ii) {\n width = Math.max(width, lineWidth);\n lineWidths.push(lineWidth);\n lineWidth = 0;\n height += lineHeight;\n lineHeight = 0;\n continue;\n }\n const font = chunks[i + 1] || baseStyle.font;\n const currentWidth = measureTextWidth(font, text);\n widths.push(currentWidth);\n lineWidth += currentWidth;\n const currentHeight = measureTextHeight(font);\n heights.push(currentHeight);\n lineHeight = Math.max(lineHeight, currentHeight);\n }\n return {width, height, widths, heights, lineWidths};\n}\n\n/**\n * @param {CanvasRenderingContext2D} context Context.\n * @param {number} rotation Rotation.\n * @param {number} offsetX X offset.\n * @param {number} offsetY Y offset.\n */\nexport function rotateAtOffset(context, rotation, offsetX, offsetY) {\n if (rotation !== 0) {\n context.translate(offsetX, offsetY);\n context.rotate(rotation);\n context.translate(-offsetX, -offsetY);\n }\n}\n\n/**\n * @param {CanvasRenderingContext2D|import(\"../render/canvas/ZIndexContext.js\").ZIndexContextProxy} context Context.\n * @param {import(\"../transform.js\").Transform|null} transform Transform.\n * @param {number} opacity Opacity.\n * @param {Label|HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} labelOrImage Label.\n * @param {number} originX Origin X.\n * @param {number} originY Origin Y.\n * @param {number} w Width.\n * @param {number} h Height.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../size.js\").Size} scale Scale.\n */\nexport function drawImageOrLabel(\n context,\n transform,\n opacity,\n labelOrImage,\n originX,\n originY,\n w,\n h,\n x,\n y,\n scale,\n) {\n context.save();\n\n if (opacity !== 1) {\n if (context.globalAlpha === undefined) {\n context.globalAlpha = (context) => (context.globalAlpha *= opacity);\n } else {\n context.globalAlpha *= opacity;\n }\n }\n if (transform) {\n context.transform.apply(context, transform);\n }\n\n if (/** @type {*} */ (labelOrImage).contextInstructions) {\n // label\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n executeLabelInstructions(/** @type {Label} */ (labelOrImage), context);\n } else if (scale[0] < 0 || scale[1] < 0) {\n // flipped image\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n 0,\n 0,\n w,\n h,\n );\n } else {\n // if image not flipped translate and scale can be avoided\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n x,\n y,\n w * scale[0],\n h * scale[1],\n );\n }\n\n context.restore();\n}\n\n/**\n * @param {Label} label Label.\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context Context.\n */\nfunction executeLabelInstructions(label, context) {\n const contextInstructions = label.contextInstructions;\n for (let i = 0, ii = contextInstructions.length; i < ii; i += 2) {\n if (Array.isArray(contextInstructions[i + 1])) {\n context[contextInstructions[i]].apply(\n context,\n contextInstructions[i + 1],\n );\n } else {\n context[contextInstructions[i]] = contextInstructions[i + 1];\n }\n }\n}\n","/**\n * @module ol/render/canvas/Immediate\n */\n// FIXME test, especially polygons with holes and multipolygons\n// FIXME need to handle large thick features (where pixel size matters)\n// FIXME add offset and end to ol/geom/flat/transform~transform2D?\n\nimport {equals} from '../../array.js';\nimport {asColorLike} from '../../colorlike.js';\nimport {intersects} from '../../extent.js';\nimport {transformGeom2D} from '../../geom/SimpleGeometry.js';\nimport {\n offsetLineString,\n removeOffsetCycles,\n} from '../../geom/flat/lineoffset.js';\nimport {transform2D} from '../../geom/flat/transform.js';\nimport {toFixed} from '../../math.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../../transform.js';\nimport VectorContext from '../VectorContext.js';\nimport {\n defaultFillStyle,\n defaultFont,\n defaultLineCap,\n defaultLineDash,\n defaultLineDashOffset,\n defaultLineJoin,\n defaultLineWidth,\n defaultMiterLimit,\n defaultStrokeStyle,\n defaultTextAlign,\n defaultTextBaseline,\n} from '../canvas.js';\n\n/**\n * @classdesc\n * A concrete subclass of {@link module:ol/render/VectorContext~VectorContext} that implements\n * direct rendering of features and geometries to an HTML5 Canvas context.\n * Instances of this class are created internally by the library and\n * provided to application code as vectorContext member of the\n * {@link module:ol/render/Event~RenderEvent} object associated with postcompose, precompose and\n * render events emitted by layers and maps.\n */\nclass CanvasImmediateRenderer extends VectorContext {\n /**\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context Context.\n * @param {number} pixelRatio Pixel ratio.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n * @param {number} viewRotation View rotation.\n * @param {number} [squaredTolerance] Optional squared tolerance for simplification.\n * @param {import(\"../../proj.js\").TransformFunction} [userTransform] Transform from user to view projection.\n */\n constructor(\n context,\n pixelRatio,\n extent,\n transform,\n viewRotation,\n squaredTolerance,\n userTransform,\n ) {\n super();\n\n /**\n * @private\n * @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}\n */\n this.context_ = context;\n\n /**\n * @private\n * @type {number}\n */\n this.pixelRatio_ = pixelRatio;\n\n /**\n * @private\n * @type {import(\"../../extent.js\").Extent}\n */\n this.extent_ = extent;\n\n /**\n * @private\n * @type {import(\"../../transform.js\").Transform}\n */\n this.transform_ = transform;\n\n /**\n * @private\n * @type {number}\n */\n this.transformRotation_ = transform\n ? toFixed(Math.atan2(transform[1], transform[0]), 10)\n : 0;\n\n /**\n * @private\n * @type {number}\n */\n this.viewRotation_ = viewRotation;\n\n /**\n * @private\n * @type {number}\n */\n this.squaredTolerance_ = squaredTolerance;\n\n /**\n * @private\n * @type {import(\"../../proj.js\").TransformFunction}\n */\n this.userTransform_ = userTransform;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").FillState}\n */\n this.contextFillState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").StrokeState}\n */\n this.contextStrokeState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").TextState}\n */\n this.contextTextState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").FillState}\n */\n this.fillState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").StrokeState}\n */\n this.strokeState_ = null;\n\n /**\n * @private\n * @type {import('../../DataTile.js').ImageLike}\n */\n this.image_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.imageAnchorX_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.imageAnchorY_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.imageHeight_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.imageOpacity_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.imageOriginX_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.imageOriginY_ = 0;\n\n /**\n * @private\n * @type {boolean}\n */\n this.imageRotateWithView_ = false;\n\n /**\n * @private\n * @type {number}\n */\n this.imageRotation_ = 0;\n\n /**\n * @private\n * @type {import(\"../../size.js\").Size}\n */\n this.imageScale_ = [0, 0];\n\n /**\n * @private\n * @type {number}\n */\n this.imageWidth_ = 0;\n\n /**\n * @private\n * @type {string}\n */\n this.text_ = '';\n\n /**\n * @private\n * @type {number}\n */\n this.textOffsetX_ = 0;\n\n /**\n * @private\n * @type {number}\n */\n this.textOffsetY_ = 0;\n\n /**\n * @private\n * @type {boolean}\n */\n this.textRotateWithView_ = false;\n\n /**\n * @private\n * @type {number}\n */\n this.textRotation_ = 0;\n\n /**\n * @private\n * @type {import(\"../../size.js\").Size}\n */\n this.textScale_ = [0, 0];\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").FillState}\n */\n this.textFillState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").StrokeState}\n */\n this.textStrokeState_ = null;\n\n /**\n * @private\n * @type {?import(\"../canvas.js\").TextState}\n */\n this.textState_ = null;\n\n /**\n * @private\n * @type {Array}\n */\n this.pixelCoordinates_ = [];\n\n /**\n * @private\n * @type {import(\"../../transform.js\").Transform}\n */\n this.tmpLocalTransform_ = createTransform();\n }\n\n /**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @private\n */\n drawImages_(flatCoordinates, offset, end, stride) {\n if (!this.image_) {\n return;\n }\n const pixelCoordinates = transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n this.transform_,\n this.pixelCoordinates_,\n );\n const context = this.context_;\n const localTransform = this.tmpLocalTransform_;\n const alpha = context.globalAlpha;\n if (this.imageOpacity_ != 1) {\n context.globalAlpha = alpha * this.imageOpacity_;\n }\n let rotation = this.imageRotation_;\n if (this.transformRotation_ === 0) {\n rotation -= this.viewRotation_;\n }\n if (this.imageRotateWithView_) {\n rotation += this.viewRotation_;\n }\n for (let i = 0, ii = pixelCoordinates.length; i < ii; i += 2) {\n const x = pixelCoordinates[i] - this.imageAnchorX_;\n const y = pixelCoordinates[i + 1] - this.imageAnchorY_;\n if (\n rotation !== 0 ||\n this.imageScale_[0] != 1 ||\n this.imageScale_[1] != 1\n ) {\n const centerX = x + this.imageAnchorX_;\n const centerY = y + this.imageAnchorY_;\n composeTransform(\n localTransform,\n centerX,\n centerY,\n 1,\n 1,\n rotation,\n -centerX,\n -centerY,\n );\n context.save();\n context.transform.apply(context, localTransform);\n context.translate(centerX, centerY);\n context.scale(this.imageScale_[0], this.imageScale_[1]);\n context.drawImage(\n this.image_,\n this.imageOriginX_,\n this.imageOriginY_,\n this.imageWidth_,\n this.imageHeight_,\n -this.imageAnchorX_,\n -this.imageAnchorY_,\n this.imageWidth_,\n this.imageHeight_,\n );\n context.restore();\n } else {\n context.drawImage(\n this.image_,\n this.imageOriginX_,\n this.imageOriginY_,\n this.imageWidth_,\n this.imageHeight_,\n x,\n y,\n this.imageWidth_,\n this.imageHeight_,\n );\n }\n }\n if (this.imageOpacity_ != 1) {\n context.globalAlpha = alpha;\n }\n }\n\n /**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @private\n */\n drawText_(flatCoordinates, offset, end, stride) {\n if (!this.textState_ || this.text_ === '') {\n return;\n }\n if (this.textFillState_) {\n this.setContextFillState_(this.textFillState_);\n }\n if (this.textStrokeState_) {\n this.setContextStrokeState_(this.textStrokeState_);\n }\n this.setContextTextState_(this.textState_);\n const pixelCoordinates = transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n this.transform_,\n this.pixelCoordinates_,\n );\n const context = this.context_;\n let rotation = this.textRotation_;\n if (this.transformRotation_ === 0) {\n rotation -= this.viewRotation_;\n }\n if (this.textRotateWithView_) {\n rotation += this.viewRotation_;\n }\n for (; offset < end; offset += stride) {\n const x = pixelCoordinates[offset] + this.textOffsetX_;\n const y = pixelCoordinates[offset + 1] + this.textOffsetY_;\n if (\n rotation !== 0 ||\n this.textScale_[0] != 1 ||\n this.textScale_[1] != 1\n ) {\n context.save();\n context.translate(x - this.textOffsetX_, y - this.textOffsetY_);\n context.rotate(rotation);\n context.translate(this.textOffsetX_, this.textOffsetY_);\n context.scale(this.textScale_[0], this.textScale_[1]);\n if (this.textStrokeState_) {\n context.strokeText(this.text_, 0, 0);\n }\n if (this.textFillState_) {\n context.fillText(this.text_, 0, 0);\n }\n context.restore();\n } else {\n if (this.textStrokeState_) {\n context.strokeText(this.text_, x, y);\n }\n if (this.textFillState_) {\n context.fillText(this.text_, x, y);\n }\n }\n }\n }\n\n /**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {boolean} close Close.\n * @param {number} [strokeOffset] Stroke Offset.\n * @private\n * @return {number} end End.\n */\n moveToLineTo_(flatCoordinates, offset, end, stride, close, strokeOffset) {\n const context = this.context_;\n let pixelCoordinates = transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n this.transform_,\n this.pixelCoordinates_,\n );\n if (Math.abs(strokeOffset) > 0) {\n pixelCoordinates = offsetLineString(\n pixelCoordinates,\n 0,\n pixelCoordinates.length,\n 2,\n strokeOffset,\n close,\n pixelCoordinates,\n );\n removeOffsetCycles(pixelCoordinates, 2);\n }\n context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);\n let length = pixelCoordinates.length;\n if (close) {\n length -= 2;\n }\n for (let i = 2; i < length; i += 2) {\n context.lineTo(pixelCoordinates[i], pixelCoordinates[i + 1]);\n }\n if (close) {\n context.closePath();\n }\n return end;\n }\n\n /**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} [strokeOffset] Stroke Offset.\n * @private\n * @return {number} End.\n */\n drawRings_(flatCoordinates, offset, ends, stride, strokeOffset) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n offset = this.moveToLineTo_(\n flatCoordinates,\n offset,\n ends[i],\n stride,\n true,\n strokeOffset,\n );\n }\n return offset;\n }\n\n /**\n * Render a circle geometry into the canvas. Rendering is immediate and uses\n * the current fill and stroke styles.\n *\n * @param {import(\"../../geom/Circle.js\").default} geometry Circle geometry.\n * @api\n * @override\n */\n drawCircle(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/Circle.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n if (!intersects(this.extent_, geometry.getExtent())) {\n return;\n }\n if (this.fillState_ || this.strokeState_) {\n if (this.fillState_) {\n this.setContextFillState_(this.fillState_);\n }\n if (this.strokeState_) {\n this.setContextStrokeState_(this.strokeState_);\n }\n const pixelCoordinates = transformGeom2D(\n geometry,\n this.transform_,\n this.pixelCoordinates_,\n );\n const dx = pixelCoordinates[2] - pixelCoordinates[0];\n const dy = pixelCoordinates[3] - pixelCoordinates[1];\n const radius = Math.sqrt(dx * dx + dy * dy);\n const context = this.context_;\n context.beginPath();\n context.arc(\n pixelCoordinates[0],\n pixelCoordinates[1],\n radius,\n 0,\n 2 * Math.PI,\n );\n if (this.fillState_) {\n context.fill();\n }\n if (this.strokeState_) {\n context.stroke();\n }\n }\n if (this.text_ !== '') {\n this.drawText_(geometry.getCenter(), 0, 2, 2);\n }\n }\n\n /**\n * Set the rendering style. Note that since this is an immediate rendering API,\n * any `zIndex` on the provided style will be ignored.\n *\n * @param {import(\"../../style/Style.js\").default} style The rendering style.\n * @api\n * @override\n */\n setStyle(style) {\n this.setFillStrokeStyle(style.getFill(), style.getStroke());\n this.setImageStyle(style.getImage());\n this.setTextStyle(style.getText());\n }\n\n /**\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n */\n setTransform(transform) {\n this.transform_ = transform;\n }\n\n /**\n * Render a geometry into the canvas. Call\n * {@link module:ol/render/canvas/Immediate~CanvasImmediateRenderer#setStyle renderer.setStyle()} first to set the rendering style.\n *\n * @param {import(\"../../geom/Geometry.js\").default|import(\"../Feature.js\").default} geometry The geometry to render.\n * @api\n * @override\n */\n drawGeometry(geometry) {\n const type = geometry.getType();\n switch (type) {\n case 'Point':\n this.drawPoint(\n /** @type {import(\"../../geom/Point.js\").default} */ (geometry),\n );\n break;\n case 'LineString':\n this.drawLineString(\n /** @type {import(\"../../geom/LineString.js\").default} */ (geometry),\n );\n break;\n case 'Polygon':\n this.drawPolygon(\n /** @type {import(\"../../geom/Polygon.js\").default} */ (geometry),\n );\n break;\n case 'MultiPoint':\n this.drawMultiPoint(\n /** @type {import(\"../../geom/MultiPoint.js\").default} */ (geometry),\n );\n break;\n case 'MultiLineString':\n this.drawMultiLineString(\n /** @type {import(\"../../geom/MultiLineString.js\").default} */ (\n geometry\n ),\n );\n break;\n case 'MultiPolygon':\n this.drawMultiPolygon(\n /** @type {import(\"../../geom/MultiPolygon.js\").default} */ (\n geometry\n ),\n );\n break;\n case 'GeometryCollection':\n this.drawGeometryCollection(\n /** @type {import(\"../../geom/GeometryCollection.js\").default} */ (\n geometry\n ),\n );\n break;\n case 'Circle':\n this.drawCircle(\n /** @type {import(\"../../geom/Circle.js\").default} */ (geometry),\n );\n break;\n default:\n }\n }\n\n /**\n * Render a feature into the canvas. Note that any `zIndex` on the provided\n * style will be ignored - features are rendered immediately in the order that\n * this method is called. If you need `zIndex` support, you should be using an\n * {@link module:ol/layer/Vector~VectorLayer} instead.\n *\n * @param {import(\"../../Feature.js\").default} feature Feature.\n * @param {import(\"../../style/Style.js\").default} style Style.\n * @api\n * @override\n */\n drawFeature(feature, style) {\n const geometry = style.getGeometryFunction()(feature);\n if (!geometry) {\n return;\n }\n this.setStyle(style);\n this.drawGeometry(geometry);\n }\n\n /**\n * Render a GeometryCollection to the canvas. Rendering is immediate and\n * uses the current styles appropriate for each geometry in the collection.\n *\n * @param {import(\"../../geom/GeometryCollection.js\").default} geometry Geometry collection.\n * @override\n */\n drawGeometryCollection(geometry) {\n const geometries = geometry.getGeometriesArray();\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n this.drawGeometry(geometries[i]);\n }\n }\n\n /**\n * Render a Point geometry into the canvas. Rendering is immediate and uses\n * the current style.\n *\n * @param {import(\"../../geom/Point.js\").default|import(\"../Feature.js\").default} geometry Point geometry.\n * @override\n */\n drawPoint(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/Point.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n const flatCoordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n if (this.image_) {\n this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);\n }\n if (this.text_ !== '') {\n this.drawText_(flatCoordinates, 0, flatCoordinates.length, stride);\n }\n }\n\n /**\n * Render a MultiPoint geometry into the canvas. Rendering is immediate and\n * uses the current style.\n *\n * @param {import(\"../../geom/MultiPoint.js\").default|import(\"../Feature.js\").default} geometry MultiPoint geometry.\n * @override\n */\n drawMultiPoint(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/MultiPoint.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n const flatCoordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n if (this.image_) {\n this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);\n }\n if (this.text_ !== '') {\n this.drawText_(flatCoordinates, 0, flatCoordinates.length, stride);\n }\n }\n\n /**\n * Render a LineString into the canvas. Rendering is immediate and uses\n * the current style.\n *\n * @param {import(\"../../geom/LineString.js\").default|import(\"../Feature.js\").default} geometry LineString geometry.\n * @override\n */\n drawLineString(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/LineString.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n if (!intersects(this.extent_, geometry.getExtent())) {\n return;\n }\n if (this.strokeState_) {\n this.setContextStrokeState_(this.strokeState_);\n const context = this.context_;\n const flatCoordinates = geometry.getFlatCoordinates();\n context.beginPath();\n this.moveToLineTo_(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n geometry.getStride(),\n false,\n this.strokeState_.strokeOffset,\n );\n context.stroke();\n }\n if (this.text_ !== '') {\n const flatMidpoint = geometry.getFlatMidpoint();\n this.drawText_(flatMidpoint, 0, 2, 2);\n }\n }\n\n /**\n * Render a MultiLineString geometry into the canvas. Rendering is immediate\n * and uses the current style.\n *\n * @param {import(\"../../geom/MultiLineString.js\").default|import(\"../Feature.js\").default} geometry MultiLineString geometry.\n * @override\n */\n drawMultiLineString(geometry) {\n if (this.squaredTolerance_) {\n geometry =\n /** @type {import(\"../../geom/MultiLineString.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n const geometryExtent = geometry.getExtent();\n if (!intersects(this.extent_, geometryExtent)) {\n return;\n }\n if (this.strokeState_) {\n this.setContextStrokeState_(this.strokeState_);\n const context = this.context_;\n const flatCoordinates = geometry.getFlatCoordinates();\n let offset = 0;\n const ends = /** @type {Array} */ (geometry.getEnds());\n const stride = geometry.getStride();\n context.beginPath();\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n offset = this.moveToLineTo_(\n flatCoordinates,\n offset,\n ends[i],\n stride,\n false,\n this.strokeState_.strokeOffset,\n );\n }\n context.stroke();\n }\n if (this.text_ !== '') {\n const flatMidpoints = geometry.getFlatMidpoints();\n this.drawText_(flatMidpoints, 0, flatMidpoints.length, 2);\n }\n }\n\n /**\n * Render a Polygon geometry into the canvas. Rendering is immediate and uses\n * the current style.\n *\n * @param {import(\"../../geom/Polygon.js\").default|import(\"../Feature.js\").default} geometry Polygon geometry.\n * @override\n */\n drawPolygon(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/Polygon.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n if (!intersects(this.extent_, geometry.getExtent())) {\n return;\n }\n if (this.strokeState_ || this.fillState_) {\n if (this.fillState_) {\n this.setContextFillState_(this.fillState_);\n }\n if (this.strokeState_) {\n this.setContextStrokeState_(this.strokeState_);\n }\n const context = this.context_;\n context.beginPath();\n this.drawRings_(\n geometry.getOrientedFlatCoordinates(),\n 0,\n /** @type {Array} */ (geometry.getEnds()),\n geometry.getStride(),\n this.strokeState_?.strokeOffset,\n );\n if (this.fillState_) {\n context.fill();\n }\n if (this.strokeState_) {\n context.stroke();\n }\n }\n if (this.text_ !== '') {\n const flatInteriorPoint = geometry.getFlatInteriorPoint();\n this.drawText_(flatInteriorPoint, 0, 2, 2);\n }\n }\n\n /**\n * Render MultiPolygon geometry into the canvas. Rendering is immediate and\n * uses the current style.\n * @param {import(\"../../geom/MultiPolygon.js\").default} geometry MultiPolygon geometry.\n * @override\n */\n drawMultiPolygon(geometry) {\n if (this.squaredTolerance_) {\n geometry = /** @type {import(\"../../geom/MultiPolygon.js\").default} */ (\n geometry.simplifyTransformed(\n this.squaredTolerance_,\n this.userTransform_,\n )\n );\n }\n if (!intersects(this.extent_, geometry.getExtent())) {\n return;\n }\n if (this.strokeState_ || this.fillState_) {\n if (this.fillState_) {\n this.setContextFillState_(this.fillState_);\n }\n if (this.strokeState_) {\n this.setContextStrokeState_(this.strokeState_);\n }\n const context = this.context_;\n const flatCoordinates = geometry.getOrientedFlatCoordinates();\n let offset = 0;\n const endss = geometry.getEndss();\n const stride = geometry.getStride();\n context.beginPath();\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n offset = this.drawRings_(\n flatCoordinates,\n offset,\n ends,\n stride,\n this.strokeState_?.strokeOffset,\n );\n }\n if (this.fillState_) {\n context.fill();\n }\n if (this.strokeState_) {\n context.stroke();\n }\n }\n if (this.text_ !== '') {\n const flatInteriorPoints = geometry.getFlatInteriorPoints();\n this.drawText_(flatInteriorPoints, 0, flatInteriorPoints.length, 2);\n }\n }\n\n /**\n * @param {import(\"../canvas.js\").FillState} fillState Fill state.\n * @private\n */\n setContextFillState_(fillState) {\n const context = this.context_;\n const contextFillState = this.contextFillState_;\n if (!contextFillState) {\n context.fillStyle = fillState.fillStyle;\n this.contextFillState_ = {\n fillStyle: fillState.fillStyle,\n };\n } else {\n if (contextFillState.fillStyle != fillState.fillStyle) {\n contextFillState.fillStyle = fillState.fillStyle;\n context.fillStyle = fillState.fillStyle;\n }\n }\n }\n\n /**\n * @param {import(\"../canvas.js\").StrokeState} strokeState Stroke state.\n * @private\n */\n setContextStrokeState_(strokeState) {\n const context = this.context_;\n const contextStrokeState = this.contextStrokeState_;\n if (!contextStrokeState) {\n context.lineCap = strokeState.lineCap;\n context.setLineDash(strokeState.lineDash);\n context.lineDashOffset = strokeState.lineDashOffset;\n context.lineJoin = strokeState.lineJoin;\n context.lineWidth = strokeState.lineWidth;\n context.miterLimit = strokeState.miterLimit;\n context.strokeStyle = strokeState.strokeStyle;\n this.contextStrokeState_ = {\n lineCap: strokeState.lineCap,\n lineDash: strokeState.lineDash,\n lineDashOffset: strokeState.lineDashOffset,\n lineJoin: strokeState.lineJoin,\n lineWidth: strokeState.lineWidth,\n miterLimit: strokeState.miterLimit,\n strokeStyle: strokeState.strokeStyle,\n };\n } else {\n if (contextStrokeState.lineCap != strokeState.lineCap) {\n contextStrokeState.lineCap = strokeState.lineCap;\n context.lineCap = strokeState.lineCap;\n }\n if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {\n context.setLineDash(\n (contextStrokeState.lineDash = strokeState.lineDash),\n );\n }\n if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {\n contextStrokeState.lineDashOffset = strokeState.lineDashOffset;\n context.lineDashOffset = strokeState.lineDashOffset;\n }\n if (contextStrokeState.lineJoin != strokeState.lineJoin) {\n contextStrokeState.lineJoin = strokeState.lineJoin;\n context.lineJoin = strokeState.lineJoin;\n }\n if (contextStrokeState.lineWidth != strokeState.lineWidth) {\n contextStrokeState.lineWidth = strokeState.lineWidth;\n context.lineWidth = strokeState.lineWidth;\n }\n if (contextStrokeState.miterLimit != strokeState.miterLimit) {\n contextStrokeState.miterLimit = strokeState.miterLimit;\n context.miterLimit = strokeState.miterLimit;\n }\n if (contextStrokeState.strokeStyle != strokeState.strokeStyle) {\n contextStrokeState.strokeStyle = strokeState.strokeStyle;\n context.strokeStyle = strokeState.strokeStyle;\n }\n }\n }\n\n /**\n * @param {import(\"../canvas.js\").TextState} textState Text state.\n * @private\n */\n setContextTextState_(textState) {\n const context = this.context_;\n const contextTextState = this.contextTextState_;\n const textAlign = textState.textAlign\n ? textState.textAlign\n : defaultTextAlign;\n if (!contextTextState) {\n context.font = textState.font;\n context.textAlign = textAlign;\n context.textBaseline = textState.textBaseline;\n this.contextTextState_ = {\n font: textState.font,\n textAlign: textAlign,\n textBaseline: textState.textBaseline,\n };\n } else {\n if (contextTextState.font != textState.font) {\n contextTextState.font = textState.font;\n context.font = textState.font;\n }\n if (contextTextState.textAlign != textAlign) {\n contextTextState.textAlign = textAlign;\n context.textAlign = textAlign;\n }\n if (contextTextState.textBaseline != textState.textBaseline) {\n contextTextState.textBaseline = textState.textBaseline;\n context.textBaseline = textState.textBaseline;\n }\n }\n }\n\n /**\n * Set the fill and stroke style for subsequent draw operations. To clear\n * either fill or stroke styles, pass null for the appropriate parameter.\n *\n * @param {import(\"../../style/Fill.js\").default} fillStyle Fill style.\n * @param {import(\"../../style/Stroke.js\").default} strokeStyle Stroke style.\n * @override\n */\n setFillStrokeStyle(fillStyle, strokeStyle) {\n if (!fillStyle) {\n this.fillState_ = null;\n } else {\n const fillStyleColor = fillStyle.getColor();\n this.fillState_ = {\n fillStyle: asColorLike(\n fillStyleColor ? fillStyleColor : defaultFillStyle,\n ),\n };\n }\n if (!strokeStyle) {\n this.strokeState_ = null;\n } else {\n const strokeStyleColor = strokeStyle.getColor();\n const strokeStyleLineCap = strokeStyle.getLineCap();\n const strokeStyleLineDash = strokeStyle.getLineDash();\n const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();\n const strokeStyleLineJoin = strokeStyle.getLineJoin();\n const strokeStyleWidth = strokeStyle.getWidth();\n const strokeStyleMiterLimit = strokeStyle.getMiterLimit();\n const lineDash = strokeStyleLineDash\n ? strokeStyleLineDash\n : defaultLineDash;\n const strokeOffset = strokeStyle.getOffset();\n this.strokeState_ = {\n lineCap:\n strokeStyleLineCap !== undefined\n ? strokeStyleLineCap\n : defaultLineCap,\n lineDash:\n this.pixelRatio_ === 1\n ? lineDash\n : lineDash.map((n) => n * this.pixelRatio_),\n lineDashOffset:\n (strokeStyleLineDashOffset\n ? strokeStyleLineDashOffset\n : defaultLineDashOffset) * this.pixelRatio_,\n lineJoin:\n strokeStyleLineJoin !== undefined\n ? strokeStyleLineJoin\n : defaultLineJoin,\n lineWidth:\n (strokeStyleWidth !== undefined\n ? strokeStyleWidth\n : defaultLineWidth) * this.pixelRatio_,\n miterLimit:\n strokeStyleMiterLimit !== undefined\n ? strokeStyleMiterLimit\n : defaultMiterLimit,\n strokeStyle: asColorLike(\n strokeStyleColor ? strokeStyleColor : defaultStrokeStyle,\n ),\n strokeOffset: (strokeOffset ?? 0) * this.pixelRatio_,\n };\n }\n }\n\n /**\n * Set the image style for subsequent draw operations. Pass null to remove\n * the image style.\n *\n * @param {import(\"../../style/Image.js\").default} imageStyle Image style.\n * @override\n */\n setImageStyle(imageStyle) {\n let imageSize;\n if (!imageStyle || !(imageSize = imageStyle.getSize())) {\n this.image_ = null;\n return;\n }\n const imagePixelRatio = imageStyle.getPixelRatio(this.pixelRatio_);\n const imageAnchor = imageStyle.getAnchor();\n const imageOrigin = imageStyle.getOrigin();\n this.image_ = imageStyle.getImage(this.pixelRatio_);\n this.imageAnchorX_ = imageAnchor[0] * imagePixelRatio;\n this.imageAnchorY_ = imageAnchor[1] * imagePixelRatio;\n this.imageHeight_ = imageSize[1] * imagePixelRatio;\n this.imageOpacity_ = imageStyle.getOpacity();\n this.imageOriginX_ = imageOrigin[0];\n this.imageOriginY_ = imageOrigin[1];\n this.imageRotateWithView_ = imageStyle.getRotateWithView();\n this.imageRotation_ = imageStyle.getRotation();\n const imageScale = imageStyle.getScaleArray();\n this.imageScale_ = [\n (imageScale[0] * this.pixelRatio_) / imagePixelRatio,\n (imageScale[1] * this.pixelRatio_) / imagePixelRatio,\n ];\n this.imageWidth_ = imageSize[0] * imagePixelRatio;\n }\n\n /**\n * Set the text style for subsequent draw operations. Pass null to\n * remove the text style.\n *\n * @param {import(\"../../style/Text.js\").default} textStyle Text style.\n * @override\n */\n setTextStyle(textStyle) {\n if (!textStyle) {\n this.text_ = '';\n } else {\n const textFillStyle = textStyle.getFill();\n if (!textFillStyle) {\n this.textFillState_ = null;\n } else {\n const textFillStyleColor = textFillStyle.getColor();\n this.textFillState_ = {\n fillStyle: asColorLike(\n textFillStyleColor ? textFillStyleColor : defaultFillStyle,\n ),\n };\n }\n const textStrokeStyle = textStyle.getStroke();\n if (!textStrokeStyle) {\n this.textStrokeState_ = null;\n } else {\n const textStrokeStyleColor = textStrokeStyle.getColor();\n const textStrokeStyleLineCap = textStrokeStyle.getLineCap();\n const textStrokeStyleLineDash = textStrokeStyle.getLineDash();\n const textStrokeStyleLineDashOffset =\n textStrokeStyle.getLineDashOffset();\n const textStrokeStyleLineJoin = textStrokeStyle.getLineJoin();\n const textStrokeStyleWidth = textStrokeStyle.getWidth();\n const textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();\n this.textStrokeState_ = {\n lineCap:\n textStrokeStyleLineCap !== undefined\n ? textStrokeStyleLineCap\n : defaultLineCap,\n lineDash: textStrokeStyleLineDash\n ? textStrokeStyleLineDash\n : defaultLineDash,\n lineDashOffset: textStrokeStyleLineDashOffset\n ? textStrokeStyleLineDashOffset\n : defaultLineDashOffset,\n lineJoin:\n textStrokeStyleLineJoin !== undefined\n ? textStrokeStyleLineJoin\n : defaultLineJoin,\n lineWidth:\n textStrokeStyleWidth !== undefined\n ? textStrokeStyleWidth\n : defaultLineWidth,\n miterLimit:\n textStrokeStyleMiterLimit !== undefined\n ? textStrokeStyleMiterLimit\n : defaultMiterLimit,\n strokeStyle: asColorLike(\n textStrokeStyleColor ? textStrokeStyleColor : defaultStrokeStyle,\n ),\n };\n }\n const textFont = textStyle.getFont();\n const textOffsetX = textStyle.getOffsetX();\n const textOffsetY = textStyle.getOffsetY();\n const textRotateWithView = textStyle.getRotateWithView();\n const textRotation = textStyle.getRotation();\n const textScale = textStyle.getScaleArray();\n const textText = textStyle.getText();\n const textTextAlign = textStyle.getTextAlign();\n const textTextBaseline = textStyle.getTextBaseline();\n this.textState_ = {\n font: textFont !== undefined ? textFont : defaultFont,\n textAlign:\n textTextAlign !== undefined ? textTextAlign : defaultTextAlign,\n textBaseline:\n textTextBaseline !== undefined\n ? textTextBaseline\n : defaultTextBaseline,\n };\n this.text_ =\n textText !== undefined\n ? Array.isArray(textText)\n ? textText.reduce((acc, t, i) => (acc += i % 2 ? ' ' : t), '')\n : textText\n : '';\n this.textOffsetX_ =\n textOffsetX !== undefined ? this.pixelRatio_ * textOffsetX : 0;\n this.textOffsetY_ =\n textOffsetY !== undefined ? this.pixelRatio_ * textOffsetY : 0;\n this.textRotateWithView_ =\n textRotateWithView !== undefined ? textRotateWithView : false;\n this.textRotation_ = textRotation !== undefined ? textRotation : 0;\n this.textScale_ = [\n this.pixelRatio_ * textScale[0],\n this.pixelRatio_ * textScale[1],\n ];\n }\n }\n}\n\nexport default CanvasImmediateRenderer;\n","/**\n * @module ol/renderer/vector\n */\nimport ImageState from '../ImageState.js';\nimport {getUid} from '../util.js';\n\n/**\n * Feature callback. The callback will be called with three arguments. The first\n * argument is one {@link module:ol/Feature~Feature feature} or {@link module:ol/render/Feature~RenderFeature render feature}\n * at the pixel, the second is the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for\n * unmanaged layers. The third is the {@link module:ol/geom/SimpleGeometry~SimpleGeometry} of the feature. For features\n * with a GeometryCollection geometry, it will be the first detected geometry from the collection.\n * @template T\n * @typedef {function(import(\"../Feature.js\").FeatureLike, import(\"../layer/Layer.js\").default, import(\"../geom/SimpleGeometry.js\").default): T} FeatureCallback\n */\n\n/**\n * Tolerance for geometry simplification in device pixels.\n * @type {number}\n */\nconst SIMPLIFY_TOLERANCE = 0.5;\n\n/**\n * @const\n * @type {Object}\n */\nconst GEOMETRY_RENDERERS = {\n 'Point': renderPointGeometry,\n 'LineString': renderLineStringGeometry,\n 'Polygon': renderPolygonGeometry,\n 'MultiPoint': renderMultiPointGeometry,\n 'MultiLineString': renderMultiLineStringGeometry,\n 'MultiPolygon': renderMultiPolygonGeometry,\n 'GeometryCollection': renderGeometryCollectionGeometry,\n 'Circle': renderCircleGeometry,\n};\n\n/**\n * @param {import(\"../Feature.js\").FeatureLike} feature1 Feature 1.\n * @param {import(\"../Feature.js\").FeatureLike} feature2 Feature 2.\n * @return {number} Order.\n */\nexport function defaultOrder(feature1, feature2) {\n return parseInt(getUid(feature1), 10) - parseInt(getUid(feature2), 10);\n}\n\n/**\n * @param {number} resolution Resolution.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Squared pixel tolerance.\n */\nexport function getSquaredTolerance(resolution, pixelRatio) {\n const tolerance = getTolerance(resolution, pixelRatio);\n return tolerance * tolerance;\n}\n\n/**\n * @param {number} resolution Resolution.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel tolerance.\n */\nexport function getTolerance(resolution, pixelRatio) {\n return (SIMPLIFY_TOLERANCE * resolution) / pixelRatio;\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Builder group.\n * @param {import(\"../geom/Circle.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderCircleGeometry(builderGroup, geometry, style, feature, index) {\n const fillStyle = style.getFill();\n const strokeStyle = style.getStroke();\n if (fillStyle || strokeStyle) {\n const circleReplay = builderGroup.getBuilder(style.getZIndex(), 'Circle');\n circleReplay.setFillStrokeStyle(fillStyle, strokeStyle);\n circleReplay.drawCircle(geometry, feature, index);\n }\n const textStyle = style.getText();\n if (textStyle && textStyle.getText()) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} replayGroup Replay group.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Transform from user to view projection.\n * @param {boolean} [declutter] Enable decluttering.\n * @param {number} [index] Render order index..\n * @return {boolean} `true` if style is loading.\n */\nexport function renderFeature(\n replayGroup,\n feature,\n style,\n squaredTolerance,\n listener,\n transform,\n declutter,\n index,\n) {\n const loadingPromises = [];\n const imageStyle = style.getImage();\n if (imageStyle) {\n let loading = true;\n const imageState = imageStyle.getImageState();\n if (imageState == ImageState.LOADED || imageState == ImageState.ERROR) {\n loading = false;\n } else {\n if (imageState == ImageState.IDLE) {\n imageStyle.load();\n }\n }\n if (loading) {\n loadingPromises.push(imageStyle.ready());\n }\n }\n const fillStyle = style.getFill();\n if (fillStyle && fillStyle.loading()) {\n loadingPromises.push(fillStyle.ready());\n }\n const loading = loadingPromises.length > 0;\n if (loading) {\n Promise.all(loadingPromises).then(() => listener(null));\n }\n renderFeatureInternal(\n replayGroup,\n feature,\n style,\n squaredTolerance,\n transform,\n declutter,\n index,\n );\n\n return loading;\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} replayGroup Replay group.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @param {boolean} [declutter] Enable decluttering.\n * @param {number} [index] Render order index..\n */\nfunction renderFeatureInternal(\n replayGroup,\n feature,\n style,\n squaredTolerance,\n transform,\n declutter,\n index,\n) {\n const geometry = style.getGeometryFunction()(feature);\n if (!geometry) {\n return;\n }\n const simplifiedGeometry = geometry.simplifyTransformed(\n squaredTolerance,\n transform,\n );\n const renderer = style.getRenderer();\n if (renderer) {\n renderGeometry(replayGroup, simplifiedGeometry, style, feature, index);\n } else {\n const geometryRenderer = GEOMETRY_RENDERERS[simplifiedGeometry.getType()];\n geometryRenderer(\n replayGroup,\n simplifiedGeometry,\n style,\n feature,\n index,\n declutter,\n );\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} replayGroup Replay group.\n * @param {import(\"../geom/Geometry.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderGeometry(replayGroup, geometry, style, feature, index) {\n if (geometry.getType() == 'GeometryCollection') {\n const geometries =\n /** @type {import(\"../geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n renderGeometry(replayGroup, geometries[i], style, feature, index);\n }\n return;\n }\n const replay = replayGroup.getBuilder(style.getZIndex(), 'Default');\n replay.drawCustom(\n /** @type {import(\"../geom/SimpleGeometry.js\").default} */ (geometry),\n feature,\n style.getRenderer(),\n style.getHitDetectionRenderer(),\n index,\n );\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} replayGroup Replay group.\n * @param {import(\"../geom/GeometryCollection.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} [declutterBuilderGroup] Builder for decluttering.\n * @param {number} [index] Render order index.\n */\nfunction renderGeometryCollectionGeometry(\n replayGroup,\n geometry,\n style,\n feature,\n declutterBuilderGroup,\n index,\n) {\n const geometries = geometry.getGeometriesArray();\n let i, ii;\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n const geometryRenderer = GEOMETRY_RENDERERS[geometries[i].getType()];\n geometryRenderer(\n replayGroup,\n geometries[i],\n style,\n feature,\n declutterBuilderGroup,\n index,\n );\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/LineString.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderLineStringGeometry(\n builderGroup,\n geometry,\n style,\n feature,\n index,\n) {\n const strokeStyle = style.getStroke();\n if (strokeStyle) {\n const lineStringReplay = builderGroup.getBuilder(\n style.getZIndex(),\n 'LineString',\n );\n lineStringReplay.setFillStrokeStyle(null, strokeStyle);\n lineStringReplay.drawLineString(geometry, feature, index);\n }\n const textStyle = style.getText();\n if (textStyle && textStyle.getText()) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/MultiLineString.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderMultiLineStringGeometry(\n builderGroup,\n geometry,\n style,\n feature,\n index,\n) {\n const strokeStyle = style.getStroke();\n if (strokeStyle) {\n const lineStringReplay = builderGroup.getBuilder(\n style.getZIndex(),\n 'LineString',\n );\n lineStringReplay.setFillStrokeStyle(null, strokeStyle);\n lineStringReplay.drawMultiLineString(geometry, feature, index);\n }\n const textStyle = style.getText();\n if (textStyle && textStyle.getText()) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/MultiPolygon.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderMultiPolygonGeometry(\n builderGroup,\n geometry,\n style,\n feature,\n index,\n) {\n const fillStyle = style.getFill();\n const strokeStyle = style.getStroke();\n if (strokeStyle || fillStyle) {\n const polygonReplay = builderGroup.getBuilder(style.getZIndex(), 'Polygon');\n polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);\n polygonReplay.drawMultiPolygon(geometry, feature, index);\n }\n const textStyle = style.getText();\n if (textStyle && textStyle.getText()) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/Point.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n * @param {boolean} [declutter] Enable decluttering.\n */\nfunction renderPointGeometry(\n builderGroup,\n geometry,\n style,\n feature,\n index,\n declutter,\n) {\n const imageStyle = style.getImage();\n const textStyle = style.getText();\n const hasText = textStyle && textStyle.getText();\n /** @type {import(\"../render/canvas.js\").DeclutterImageWithText} */\n const declutterImageWithText =\n declutter && imageStyle && hasText ? {} : undefined;\n if (imageStyle) {\n if (imageStyle.getImageState() != ImageState.LOADED) {\n return;\n }\n const imageReplay = builderGroup.getBuilder(style.getZIndex(), 'Image');\n imageReplay.setImageStyle(imageStyle, declutterImageWithText);\n imageReplay.drawPoint(geometry, feature, index);\n }\n if (hasText) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle, declutterImageWithText);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/MultiPoint.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n * @param {boolean} [declutter] Enable decluttering.\n */\nfunction renderMultiPointGeometry(\n builderGroup,\n geometry,\n style,\n feature,\n index,\n declutter,\n) {\n const imageStyle = style.getImage();\n const hasImage = imageStyle && imageStyle.getOpacity() !== 0;\n const textStyle = style.getText();\n const hasText = textStyle && textStyle.getText();\n /** @type {import(\"../render/canvas.js\").DeclutterImageWithText} */\n const declutterImageWithText =\n declutter && hasImage && hasText ? {} : undefined;\n if (hasImage) {\n if (imageStyle.getImageState() != ImageState.LOADED) {\n return;\n }\n const imageReplay = builderGroup.getBuilder(style.getZIndex(), 'Image');\n imageReplay.setImageStyle(imageStyle, declutterImageWithText);\n imageReplay.drawMultiPoint(geometry, feature, index);\n }\n if (hasText) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle, declutterImageWithText);\n textReplay.drawText(geometry, feature, index);\n }\n}\n\n/**\n * @param {import(\"../render/canvas/BuilderGroup.js\").default} builderGroup Replay group.\n * @param {import(\"../geom/Polygon.js\").default|import(\"../render/Feature.js\").default} geometry Geometry.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\nfunction renderPolygonGeometry(builderGroup, geometry, style, feature, index) {\n const fillStyle = style.getFill();\n const strokeStyle = style.getStroke();\n if (fillStyle || strokeStyle) {\n const polygonReplay = builderGroup.getBuilder(style.getZIndex(), 'Polygon');\n polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);\n polygonReplay.drawPolygon(geometry, feature, index);\n }\n const textStyle = style.getText();\n if (textStyle && textStyle.getText()) {\n const textReplay = builderGroup.getBuilder(style.getZIndex(), 'Text');\n textReplay.setTextStyle(textStyle);\n textReplay.drawText(geometry, feature, index);\n }\n}\n","/**\n * @module ol/render/EventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered before a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#prerender\n * @api\n */\n PRERENDER: 'prerender',\n\n /**\n * Triggered after a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#postrender\n * @api\n */\n POSTRENDER: 'postrender',\n\n /**\n * Triggered before layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#precompose\n * @api\n */\n PRECOMPOSE: 'precompose',\n\n /**\n * Triggered after layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#postcompose\n * @api\n */\n POSTCOMPOSE: 'postcompose',\n\n /**\n * Triggered when rendering is complete, i.e. all sources and tiles have\n * finished loading for the current viewport, and all tiles are faded in.\n * The event object will not have a `context` set.\n * @event module:ol/render/Event~RenderEvent#rendercomplete\n * @api\n */\n RENDERCOMPLETE: 'rendercomplete',\n};\n\n/**\n * @typedef {'postrender'|'precompose'|'postcompose'|'rendercomplete'} MapRenderEventTypes\n */\n\n/**\n * @typedef {'postrender'|'prerender'} LayerRenderEventTypes\n */\n","/**\n * @module ol/featureloader\n */\n\n/**\n *\n * @type {boolean}\n * @private\n */\nlet withCredentials = false;\n\n/**\n * {@link module:ol/source/Vector~VectorSource} sources use a function of this type to\n * load features.\n *\n * This function takes 3 arguments: an {@link module:ol/extent~Extent} representing\n * the area to be loaded, a `{number}` representing the resolution (map units per pixel), and a\n * {@link module:ol/proj/Projection~Projection} for the projection. The function is expeced to return\n * a promise that resolves to an array of features.\n *\n * There are also a deprecated signature, with `void` as\n * return, and two additional arguments: an optional success callback that should get\n * the loaded features passed as an argument and an optional failure callback with no arguments.\n *\n * The function is responsible for loading the features and adding them to the\n * source.\n *\n * @template {import(\"./Feature.js\").FeatureLike} [FeatureType=import(\"./Feature.js\").FeatureLike]\n * @typedef {(\n * extent: import(\"./extent.js\").Extent,\n * resolution: number,\n * projection: import(\"./proj/Projection.js\").default,\n * success?: (features: Array) => void,\n * failure?: () => void) => void|Promise>} FeatureLoader\n * @api\n */\n\n/**\n * {@link module:ol/source/Vector~VectorSource} sources use a function of this type to\n * get the url to load features from.\n *\n * This function takes an {@link module:ol/extent~Extent} representing the area\n * to be loaded, a `{number}` representing the resolution (map units per pixel)\n * and an {@link module:ol/proj/Projection~Projection} for the projection as\n * arguments and returns a `{string}` representing the URL.\n * @typedef {function(import(\"./extent.js\").Extent, number, import(\"./proj/Projection.js\").default): string} FeatureUrlFunction\n * @api\n */\n\n/**\n * @template {import(\"./Feature.js\").FeatureLike} [FeatureType=import(\"./Feature.js\").default]\n * @param {string|FeatureUrlFunction} url Feature URL service.\n * @param {import(\"./format/Feature.js\").default} format Feature format.\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {function(Array, import(\"./proj/Projection.js\").default): void} success Success\n * Function called with the loaded features and optionally with the data projection.\n * @param {function(): void} failure Failure\n * Function called when loading failed.\n */\nexport function loadFeaturesXhr(\n url,\n format,\n extent,\n resolution,\n projection,\n success,\n failure,\n) {\n const xhr = new XMLHttpRequest();\n xhr.open(\n 'GET',\n typeof url === 'function' ? url(extent, resolution, projection) : url,\n true,\n );\n if (format.getType() == 'arraybuffer') {\n xhr.responseType = 'arraybuffer';\n }\n xhr.withCredentials = withCredentials;\n /**\n * @param {Event} event Event.\n * @private\n */\n xhr.onload = function (event) {\n // status will be 0 for file:// urls\n if (!xhr.status || (xhr.status >= 200 && xhr.status < 300)) {\n const type = format.getType();\n try {\n /** @type {Document|Node|Object|string|undefined} */\n let source;\n if (type == 'text' || type == 'json') {\n source = xhr.responseText;\n } else if (type == 'xml') {\n source = xhr.responseXML || xhr.responseText;\n } else if (type == 'arraybuffer') {\n source = /** @type {ArrayBuffer} */ (xhr.response);\n }\n if (source) {\n success(\n /** @type {Array} */\n (\n format.readFeatures(source, {\n extent: extent,\n featureProjection: projection,\n })\n ),\n format.readProjection(source),\n );\n } else {\n failure();\n }\n } catch {\n failure();\n }\n } else {\n failure();\n }\n };\n /**\n * @private\n */\n xhr.onerror = failure;\n xhr.send();\n}\n\n/**\n * Create an XHR feature loader for a `url` and `format`. The feature loader\n * loads features (with XHR), parses the features, and adds them to the\n * vector source.\n *\n * @template {import(\"./Feature.js\").FeatureLike} [FeatureType=import(\"./Feature.js\").default]\n * @param {string|FeatureUrlFunction} url Feature URL service.\n * @param {import(\"./format/Feature.js\").default} format Feature format.\n * @return {FeatureLoader} The feature loader.\n * @api\n */\nexport function xhr(url, format) {\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {function(Array): void} [success] Success\n * Function called when loading succeeded.\n * @param {function(): void} [failure] Failure\n * Function called when loading failed.\n * @this {import(\"./source/Vector.js\").default}\n */\n return function (extent, resolution, projection, success, failure) {\n loadFeaturesXhr(\n url,\n format,\n extent,\n resolution,\n projection,\n /**\n * @param {Array} features The loaded features.\n * @param {import(\"./proj/Projection.js\").default} dataProjection Data\n * projection.\n */\n (features, dataProjection) => {\n this.addFeatures(features);\n if (success !== undefined) {\n success(features);\n }\n },\n () => {\n this.changed();\n if (failure !== undefined) {\n failure();\n }\n },\n );\n };\n}\n\n/**\n * Setter for the withCredentials configuration for the XHR.\n *\n * @param {boolean} xhrWithCredentials The value of withCredentials to set.\n * Compare https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/\n * @api\n */\nexport function setWithCredentials(xhrWithCredentials) {\n withCredentials = xhrWithCredentials;\n}\n","/**\n * @module ol/loadingstrategy\n */\n\nimport {fromUserExtent, fromUserResolution, toUserExtent} from './proj.js';\n\n/**\n * Strategy function for loading all features with a single request.\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @return {Array} Extents.\n * @api\n */\nexport function all(extent, resolution) {\n return [[-Infinity, -Infinity, Infinity, Infinity]];\n}\n\n/**\n * Strategy function for loading features based on the view's extent and\n * resolution.\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @return {Array} Extents.\n * @api\n */\nexport function bbox(extent, resolution) {\n return [extent];\n}\n\n/**\n * Creates a strategy function for loading features based on a tile grid.\n * @param {import(\"./tilegrid/TileGrid.js\").default} tileGrid Tile grid.\n * @return {function(import(\"./extent.js\").Extent, number, import(\"./proj.js\").Projection): Array} Loading strategy.\n * @api\n */\nexport function tile(tileGrid) {\n return (\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @param {import(\"./proj.js\").Projection} projection Projection.\n * @return {Array} Extents.\n */\n function (extent, resolution, projection) {\n const z = tileGrid.getZForResolution(\n fromUserResolution(resolution, projection),\n );\n const tileRange = tileGrid.getTileRangeForExtentAndZ(\n fromUserExtent(extent, projection),\n z,\n );\n /** @type {Array} */\n const extents = [];\n /** @type {import(\"./tilecoord.js\").TileCoord} */\n const tileCoord = [z, 0, 0];\n for (\n tileCoord[1] = tileRange.minX;\n tileCoord[1] <= tileRange.maxX;\n ++tileCoord[1]\n ) {\n for (\n tileCoord[2] = tileRange.minY;\n tileCoord[2] <= tileRange.maxY;\n ++tileCoord[2]\n ) {\n extents.push(\n toUserExtent(tileGrid.getTileCoordExtent(tileCoord), projection),\n );\n }\n }\n return extents;\n }\n );\n}\n","/**\n * @module ol/geom/MultiLineString\n */\nimport {extend} from '../array.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport LineString from './LineString.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {\n interpolatePoint,\n lineStringsCoordinateAtM,\n} from './flat/interpolate.js';\nimport {intersectsLineStringArray} from './flat/intersectsextent.js';\nimport {lineStringLength} from './flat/length.js';\nimport {douglasPeuckerArray} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Multi-linestring geometry.\n *\n * @api\n */\nclass MultiLineString extends SimpleGeometry {\n /**\n * @param {Array|LineString>|Array} coordinates\n * Coordinates or LineString geometries. (For internal use, flat coordinates in\n * combination with `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Flat coordinate ends for internal use.\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (Array.isArray(coordinates[0])) {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout,\n );\n } else if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n this.ends_ = ends;\n } else {\n const lineStrings = /** @type {Array} */ (coordinates);\n /** @type {Array} */\n const flatCoordinates = [];\n const ends = [];\n for (let i = 0, ii = lineStrings.length; i < ii; ++i) {\n const lineString = lineStrings[i];\n extend(flatCoordinates, lineString.getFlatCoordinates());\n ends.push(flatCoordinates.length);\n }\n const layout =\n lineStrings.length === 0\n ? this.getLayout()\n : lineStrings[0].getLayout();\n this.setFlatCoordinates(layout, flatCoordinates);\n this.ends_ = ends;\n }\n }\n\n /**\n * Append the passed linestring to the multilinestring.\n * @param {LineString} lineString LineString.\n * @api\n */\n appendLineString(lineString) {\n extend(this.flatCoordinates, lineString.getFlatCoordinates().slice());\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiLineString} Clone.\n * @api\n * @override\n */\n clone() {\n const multiLineString = new MultiLineString(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice(),\n );\n multiLineString.applyProperties(this);\n return multiLineString;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n false,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Returns the coordinate at `m` using linear interpolation, or `null` if no\n * such coordinate exists.\n *\n * `extrapolate` controls extrapolation beyond the range of Ms in the\n * MultiLineString. If `extrapolate` is `true` then Ms less than the first\n * M will return the first coordinate and Ms greater than the last M will\n * return the last coordinate.\n *\n * `interpolate` controls interpolation between consecutive LineStrings\n * within the MultiLineString. If `interpolate` is `true` the coordinates\n * will be linearly interpolated between the last coordinate of one LineString\n * and the first coordinate of the next LineString. If `interpolate` is\n * `false` then the function will return `null` for Ms falling between\n * LineStrings.\n *\n * @param {number} m M.\n * @param {boolean} [extrapolate] Extrapolate. Default is `false`.\n * @param {boolean} [interpolate] Interpolate. Default is `false`.\n * @return {import(\"../coordinate.js\").Coordinate|null} Coordinate.\n * @api\n */\n getCoordinateAtM(m, extrapolate, interpolate) {\n if (\n (this.layout != 'XYM' && this.layout != 'XYZM') ||\n this.flatCoordinates.length === 0\n ) {\n return null;\n }\n extrapolate = extrapolate !== undefined ? extrapolate : false;\n interpolate = interpolate !== undefined ? interpolate : false;\n return lineStringsCoordinateAtM(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n m,\n extrapolate,\n interpolate,\n );\n }\n\n /**\n * Return the coordinates of the multilinestring.\n * @return {Array>} Coordinates.\n * @api\n * @override\n */\n getCoordinates() {\n return inflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n );\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * Return the linestring at the specified index.\n * @param {number} index Index.\n * @return {LineString} LineString.\n * @api\n */\n getLineString(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LineString(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index],\n ),\n this.layout,\n );\n }\n\n /**\n * Return the linestrings of this multilinestring.\n * @return {Array} LineStrings.\n * @api\n */\n getLineStrings() {\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const layout = this.layout;\n /** @type {Array} */\n const lineStrings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const lineString = new LineString(\n flatCoordinates.slice(offset, end),\n layout,\n );\n lineStrings.push(lineString);\n offset = end;\n }\n return lineStrings;\n }\n\n /**\n * Return the sum of all line string lengths\n * @return {number} Length (on projected plane).\n * @api\n */\n getLength() {\n const ends = this.ends_;\n let start = 0;\n let length = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n length += lineStringLength(\n this.flatCoordinates,\n start,\n ends[i],\n this.stride,\n );\n start = ends[i];\n }\n return length;\n }\n\n /**\n * @return {Array} Flat midpoints.\n */\n getFlatMidpoints() {\n /** @type {Array} */\n const midpoints = [];\n const flatCoordinates = this.flatCoordinates;\n let offset = 0;\n const ends = this.ends_;\n const stride = this.stride;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const midpoint = interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n 0.5,\n );\n extend(midpoints, midpoint);\n offset = end;\n }\n return midpoints;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {MultiLineString} Simplified MultiLineString.\n * @protected\n * @override\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = douglasPeuckerArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n return new MultiLineString(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'MultiLineString';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return intersectsLineStringArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the multilinestring.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_,\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default MultiLineString;\n","/**\n * @module ol/geom/MultiPoint\n */\nimport {extend} from '../array.js';\nimport {closestSquaredDistanceXY, containsXY} from '../extent.js';\nimport {squaredDistance as squaredDx} from '../math.js';\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {inflateCoordinates} from './flat/inflate.js';\n\n/**\n * @classdesc\n * Multi-point geometry.\n *\n * @api\n */\nclass MultiPoint extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n if (layout && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed point to this multipoint.\n * @param {Point} point Point.\n * @api\n */\n appendPoint(point) {\n extend(this.flatCoordinates, point.getFlatCoordinates());\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiPoint} Clone.\n * @api\n * @override\n */\n clone() {\n const multiPoint = new MultiPoint(\n this.flatCoordinates.slice(),\n this.layout,\n );\n multiPoint.applyProperties(this);\n return multiPoint;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n const flatCoordinates = this.flatCoordinates;\n const stride = this.stride;\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[i],\n flatCoordinates[i + 1],\n );\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (let j = 0; j < stride; ++j) {\n closestPoint[j] = flatCoordinates[i + j];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinates of the multipoint.\n * @return {Array} Coordinates.\n * @api\n * @override\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the point at the specified index.\n * @param {number} index Index.\n * @return {Point} Point.\n * @api\n */\n getPoint(index) {\n const n = this.flatCoordinates.length / this.stride;\n if (index < 0 || n <= index) {\n return null;\n }\n return new Point(\n this.flatCoordinates.slice(\n index * this.stride,\n (index + 1) * this.stride,\n ),\n this.layout,\n );\n }\n\n /**\n * Return the points of this multipoint.\n * @return {Array} Points.\n * @api\n */\n getPoints() {\n const flatCoordinates = this.flatCoordinates;\n const layout = this.layout;\n const stride = this.stride;\n /** @type {Array} */\n const points = [];\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const point = new Point(flatCoordinates.slice(i, i + stride), layout);\n points.push(point);\n }\n return points;\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'MultiPoint';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n const flatCoordinates = this.flatCoordinates;\n const stride = this.stride;\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n if (containsXY(extent, x, y)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Set the coordinates of the multipoint.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default MultiPoint;\n","/**\n * @module ol/geom/flat/center\n */\nimport {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {Array} Flat centers.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n const flatCenters = [];\n let extent = createEmpty();\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n extent = createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n ends[0],\n stride,\n );\n flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2);\n offset = ends[ends.length - 1];\n }\n return flatCenters;\n}\n","/**\n * @module ol/geom/MultiPolygon\n */\nimport {extend} from '../array.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport MultiPoint from './MultiPoint.js';\nimport Polygon from './Polygon.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {linearRingss as linearRingssArea} from './flat/area.js';\nimport {linearRingss as linearRingssCenter} from './flat/center.js';\nimport {\n assignClosestMultiArrayPoint,\n multiArrayMaxSquaredDelta,\n} from './flat/closest.js';\nimport {linearRingssContainsXY} from './flat/contains.js';\nimport {deflateMultiCoordinatesArray} from './flat/deflate.js';\nimport {inflateMultiCoordinatesArray} from './flat/inflate.js';\nimport {getInteriorPointsOfMultiArray} from './flat/interiorpoint.js';\nimport {intersectsLinearRingMultiArray} from './flat/intersectsextent.js';\nimport {\n linearRingssAreOriented,\n orientLinearRingsArray,\n} from './flat/orient.js';\nimport {quantizeMultiArray} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Multi-polygon geometry.\n *\n * @api\n */\nclass MultiPolygon extends SimpleGeometry {\n /**\n * @param {Array>|Polygon>|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` and `endss` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array>} [endss] Array of ends for internal use with flat coordinates.\n */\n constructor(coordinates, layout, endss) {\n super();\n\n /**\n * @type {Array>}\n * @private\n */\n this.endss_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointsRevision_ = -1;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.flatInteriorPoints_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (!endss && !Array.isArray(coordinates[0])) {\n const polygons = /** @type {Array} */ (coordinates);\n /** @type {Array} */\n const flatCoordinates = [];\n const thisEndss = [];\n for (let i = 0, ii = polygons.length; i < ii; ++i) {\n const polygon = polygons[i];\n const offset = flatCoordinates.length;\n const ends = polygon.getEnds();\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n ends[j] += offset;\n }\n extend(flatCoordinates, polygon.getFlatCoordinates());\n thisEndss.push(ends);\n }\n layout =\n polygons.length === 0 ? this.getLayout() : polygons[0].getLayout();\n coordinates = flatCoordinates;\n endss = thisEndss;\n }\n if (layout !== undefined && endss) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n this.endss_ = endss;\n } else {\n this.setCoordinates(\n /** @type {Array>>} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed polygon to this multipolygon.\n * @param {Polygon} polygon Polygon.\n * @api\n */\n appendPolygon(polygon) {\n /** @type {Array} */\n let ends;\n if (!this.flatCoordinates) {\n this.flatCoordinates = polygon.getFlatCoordinates().slice();\n ends = polygon.getEnds().slice();\n this.endss_.push();\n } else {\n const offset = this.flatCoordinates.length;\n extend(this.flatCoordinates, polygon.getFlatCoordinates());\n ends = polygon.getEnds().slice();\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n ends[i] += offset;\n }\n }\n this.endss_.push(ends);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiPolygon} Clone.\n * @api\n * @override\n */\n clone() {\n const len = this.endss_.length;\n const newEndss = new Array(len);\n for (let i = 0; i < len; ++i) {\n newEndss[i] = this.endss_[i].slice();\n }\n\n const multiPolygon = new MultiPolygon(\n this.flatCoordinates.slice(),\n this.layout,\n newEndss,\n );\n multiPolygon.applyProperties(this);\n\n return multiPolygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n * @override\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n multiArrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestMultiArrayPoint(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n * @override\n */\n containsXY(x, y) {\n return linearRingssContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n x,\n y,\n );\n }\n\n /**\n * Return the area of the multipolygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingssArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for multi-polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>>} Coordinates.\n * @api\n * @override\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRingsArray(\n flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n right,\n );\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateMultiCoordinatesArray(\n flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n );\n }\n\n /**\n * @return {Array>} Endss.\n */\n getEndss() {\n return this.endss_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoints() {\n if (this.flatInteriorPointsRevision_ != this.getRevision()) {\n const flatCenters = linearRingssCenter(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n );\n this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n flatCenters,\n );\n this.flatInteriorPointsRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.flatInteriorPoints_);\n }\n\n /**\n * Return the interior points as {@link module:ol/geom/MultiPoint~MultiPoint multipoint}.\n * @return {MultiPoint} Interior points as XYM coordinates, where M is\n * the length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoints() {\n return new MultiPoint(this.getFlatInteriorPoints().slice(), 'XYM');\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (\n linearRingssAreOriented(flatCoordinates, 0, this.endss_, this.stride)\n ) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRingsArray(\n this.orientedFlatCoordinates_,\n 0,\n this.endss_,\n this.stride,\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.orientedFlatCoordinates_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {MultiPolygon} Simplified MultiPolygon.\n * @protected\n * @override\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n /** @type {Array>} */\n const simplifiedEndss = [];\n simplifiedFlatCoordinates.length = quantizeMultiArray(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEndss,\n );\n return new MultiPolygon(simplifiedFlatCoordinates, 'XY', simplifiedEndss);\n }\n\n /**\n * Return the polygon at the specified index.\n * @param {number} index Index.\n * @return {Polygon} Polygon.\n * @api\n */\n getPolygon(index) {\n if (index < 0 || this.endss_.length <= index) {\n return null;\n }\n let offset;\n if (index === 0) {\n offset = 0;\n } else {\n const prevEnds = this.endss_[index - 1];\n offset = prevEnds[prevEnds.length - 1];\n }\n const ends = this.endss_[index].slice();\n const end = ends[ends.length - 1];\n if (offset !== 0) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n ends[i] -= offset;\n }\n }\n return new Polygon(\n this.flatCoordinates.slice(offset, end),\n this.layout,\n ends,\n );\n }\n\n /**\n * Return the polygons of this multipolygon.\n * @return {Array} Polygons.\n * @api\n */\n getPolygons() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const endss = this.endss_;\n const polygons = [];\n let offset = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i].slice();\n const end = ends[ends.length - 1];\n if (offset !== 0) {\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n ends[j] -= offset;\n }\n }\n const polygon = new Polygon(\n flatCoordinates.slice(offset, end),\n layout,\n ends,\n );\n polygons.push(polygon);\n offset = end;\n }\n return polygons;\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n * @override\n */\n getType() {\n return 'MultiPolygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n * @override\n */\n intersectsExtent(extent) {\n return intersectsLinearRingMultiArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the multipolygon.\n * @param {!Array>>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n * @override\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 3);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const endss = deflateMultiCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.endss_,\n );\n if (endss.length === 0) {\n this.flatCoordinates.length = 0;\n } else {\n const lastEnds = endss[endss.length - 1];\n this.flatCoordinates.length =\n lastEnds.length === 0 ? 0 : lastEnds[lastEnds.length - 1];\n }\n this.changed();\n }\n}\n\nexport default MultiPolygon;\n","/**\n * @module ol/render/Feature\n */\nimport Feature from '../Feature.js';\nimport {extend} from '../array.js';\nimport {\n createOrUpdateFromCoordinate,\n createOrUpdateFromFlatCoordinates,\n getCenter,\n getHeight,\n} from '../extent.js';\nimport {memoizeOne} from '../functions.js';\nimport LineString from '../geom/LineString.js';\nimport MultiLineString from '../geom/MultiLineString.js';\nimport MultiPoint from '../geom/MultiPoint.js';\nimport MultiPolygon from '../geom/MultiPolygon.js';\nimport Point from '../geom/Point.js';\nimport Polygon from '../geom/Polygon.js';\nimport {linearRingss as linearRingssCenter} from '../geom/flat/center.js';\nimport {\n getInteriorPointOfArray,\n getInteriorPointsOfMultiArray,\n} from '../geom/flat/interiorpoint.js';\nimport {interpolatePoint} from '../geom/flat/interpolate.js';\nimport {inflateEnds} from '../geom/flat/orient.js';\nimport {\n douglasPeucker,\n douglasPeuckerArray,\n quantizeArray,\n} from '../geom/flat/simplify.js';\nimport {transform2D} from '../geom/flat/transform.js';\nimport {get as getProjection} from '../proj.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\n\n/**\n * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString'} Type\n * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,\n * `'Polygon'`, `'MultiPoint'` or 'MultiLineString'`.\n */\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/**\n * Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like\n * structure, optimized for vector tile rendering and styling. Geometry access\n * through the API is limited to getting the type and extent of the geometry.\n */\nclass RenderFeature {\n /**\n * @param {Type} type Geometry type.\n * @param {Array} flatCoordinates Flat coordinates. These always need\n * to be right-handed for polygons.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Object} properties Properties.\n * @param {number|string|undefined} id Feature id.\n */\n constructor(type, flatCoordinates, ends, stride, properties, id) {\n /**\n * @type {import(\"../style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction;\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent|undefined}\n */\n this.extent_;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = id;\n\n /**\n * @private\n * @type {Type}\n */\n this.type_ = type;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatCoordinates_ = flatCoordinates;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatInteriorPoints_ = null;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatMidpoints_ = null;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.ends_ = ends || null;\n\n /**\n * @private\n * @type {Object}\n */\n this.properties_ = properties;\n\n /**\n * @private\n * @type {number}\n */\n this.squaredTolerance_;\n\n /**\n * @private\n * @type {number}\n */\n this.stride_ = stride;\n\n /**\n * @private\n * @type {RenderFeature}\n */\n this.simplifiedGeometry_;\n }\n\n /**\n * Get a feature property by its key.\n * @param {string} key Key\n * @return {*} Value for the requested key.\n * @api\n */\n get(key) {\n return this.properties_[key];\n }\n\n /**\n * Get the extent of this feature's geometry.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n if (!this.extent_) {\n this.extent_ =\n this.type_ === 'Point'\n ? createOrUpdateFromCoordinate(this.flatCoordinates_)\n : createOrUpdateFromFlatCoordinates(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n this.stride_,\n );\n }\n return this.extent_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoint() {\n if (!this.flatInteriorPoints_) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoints_ = getInteriorPointOfArray(\n this.flatCoordinates_,\n 0,\n this.ends_,\n this.stride_,\n flatCenter,\n 0,\n );\n }\n return this.flatInteriorPoints_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoints() {\n if (!this.flatInteriorPoints_) {\n const ends = inflateEnds(this.flatCoordinates_, this.ends_);\n const flatCenters = linearRingssCenter(\n this.flatCoordinates_,\n 0,\n ends,\n this.stride_,\n );\n this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(\n this.flatCoordinates_,\n 0,\n ends,\n this.stride_,\n flatCenters,\n );\n }\n return this.flatInteriorPoints_;\n }\n\n /**\n * @return {Array} Flat midpoint.\n */\n getFlatMidpoint() {\n if (!this.flatMidpoints_) {\n this.flatMidpoints_ = interpolatePoint(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n this.stride_,\n 0.5,\n );\n }\n return this.flatMidpoints_;\n }\n\n /**\n * @return {Array} Flat midpoints.\n */\n getFlatMidpoints() {\n if (!this.flatMidpoints_) {\n this.flatMidpoints_ = [];\n const flatCoordinates = this.flatCoordinates_;\n let offset = 0;\n const ends = /** @type {Array} */ (this.ends_);\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const midpoint = interpolatePoint(\n flatCoordinates,\n offset,\n end,\n this.stride_,\n 0.5,\n );\n extend(this.flatMidpoints_, midpoint);\n offset = end;\n }\n }\n return this.flatMidpoints_;\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is set when reading data from a remote source.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getOrientedFlatCoordinates() {\n return this.flatCoordinates_;\n }\n\n /**\n * For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when\n * determining the geometry type in style function (see {@link #getType}).\n * @return {RenderFeature} Feature.\n * @api\n */\n getGeometry() {\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {RenderFeature} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return this;\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {RenderFeature} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this;\n }\n\n /**\n * Get the feature properties.\n * @return {Object} Feature properties.\n * @api\n */\n getProperties() {\n return this.properties_;\n }\n\n /**\n * Get an object of all property names and values. This has the same behavior as getProperties,\n * but is here to conform with the {@link module:ol/Feature~Feature} interface.\n * @return {Object?} Object.\n */\n getPropertiesInternal() {\n return this.properties_;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return this.stride_;\n }\n\n /**\n * @return {import('../style/Style.js').StyleFunction|undefined} Style\n */\n getStyleFunction() {\n return this.styleFunction;\n }\n\n /**\n * Get the type of this feature's geometry.\n * @return {Type} Geometry type.\n * @api\n */\n getType() {\n return this.type_;\n }\n\n /**\n * Transform geometry coordinates from tile pixel space to projected.\n *\n * @param {import(\"../proj.js\").ProjectionLike} projection The data projection\n */\n transform(projection) {\n projection = getProjection(projection);\n const pixelExtent = projection.getExtent();\n const projectedExtent = projection.getWorldExtent();\n if (pixelExtent && projectedExtent) {\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0,\n );\n transform2D(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n this.stride_,\n tmpTransform,\n this.flatCoordinates_,\n );\n }\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n */\n applyTransform(transformFn) {\n transformFn(this.flatCoordinates_, this.flatCoordinates_, this.stride_);\n }\n\n /**\n * @return {RenderFeature} A cloned render feature.\n */\n clone() {\n return new RenderFeature(\n this.type_,\n this.flatCoordinates_.slice(),\n this.ends_?.slice(),\n this.stride_,\n Object.assign({}, this.properties_),\n this.id_,\n );\n }\n\n /**\n * @return {Array|null} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * Add transform and resolution based geometry simplification to this instance.\n * @return {RenderFeature} This render feature.\n */\n enableSimplifyTransformed() {\n this.simplifyTransformed = memoizeOne((squaredTolerance, transform) => {\n if (squaredTolerance === this.squaredTolerance_) {\n return this.simplifiedGeometry_;\n }\n this.simplifiedGeometry_ = this.clone();\n if (transform) {\n this.simplifiedGeometry_.applyTransform(transform);\n }\n const simplifiedFlatCoordinates =\n this.simplifiedGeometry_.getFlatCoordinates();\n let simplifiedEnds;\n switch (this.type_) {\n case 'LineString':\n simplifiedFlatCoordinates.length = douglasPeucker(\n simplifiedFlatCoordinates,\n 0,\n this.simplifiedGeometry_.flatCoordinates_.length,\n this.simplifiedGeometry_.stride_,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n simplifiedEnds = [simplifiedFlatCoordinates.length];\n break;\n case 'MultiLineString':\n simplifiedEnds = [];\n simplifiedFlatCoordinates.length = douglasPeuckerArray(\n simplifiedFlatCoordinates,\n 0,\n this.simplifiedGeometry_.ends_,\n this.simplifiedGeometry_.stride_,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n break;\n case 'Polygon':\n simplifiedEnds = [];\n simplifiedFlatCoordinates.length = quantizeArray(\n simplifiedFlatCoordinates,\n 0,\n this.simplifiedGeometry_.ends_,\n this.simplifiedGeometry_.stride_,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n break;\n default:\n }\n if (simplifiedEnds) {\n this.simplifiedGeometry_ = new RenderFeature(\n this.type_,\n simplifiedFlatCoordinates,\n simplifiedEnds,\n this.stride_,\n this.properties_,\n this.id_,\n );\n }\n this.squaredTolerance_ = squaredTolerance;\n return this.simplifiedGeometry_;\n });\n return this;\n }\n}\n\n/**\n * @return {Array} Flat coordinates.\n */\nRenderFeature.prototype.getFlatCoordinates =\n RenderFeature.prototype.getOrientedFlatCoordinates;\n\n/**\n * Create a geometry from an `ol/render/Feature`\n * @param {RenderFeature} renderFeature\n * Render Feature\n * @return {Point|MultiPoint|LineString|MultiLineString|Polygon|MultiPolygon}\n * New geometry instance.\n * @api\n */\nexport function toGeometry(renderFeature) {\n const geometryType = renderFeature.getType();\n switch (geometryType) {\n case 'Point':\n return new Point(renderFeature.getFlatCoordinates());\n case 'MultiPoint':\n return new MultiPoint(renderFeature.getFlatCoordinates(), 'XY');\n case 'LineString':\n return new LineString(renderFeature.getFlatCoordinates(), 'XY');\n case 'MultiLineString':\n return new MultiLineString(\n renderFeature.getFlatCoordinates(),\n 'XY',\n /** @type {Array} */ (renderFeature.getEnds()),\n );\n case 'Polygon':\n const flatCoordinates = renderFeature.getFlatCoordinates();\n const ends = renderFeature.getEnds();\n const endss = inflateEnds(flatCoordinates, ends);\n return endss.length > 1\n ? new MultiPolygon(flatCoordinates, 'XY', endss)\n : new Polygon(flatCoordinates, 'XY', ends);\n default:\n throw new Error('Invalid geometry type:' + geometryType);\n }\n}\n\n/**\n * Create an `ol/Feature` from an `ol/render/Feature`\n * @param {RenderFeature} renderFeature RenderFeature\n * @param {string} [geometryName] Geometry name to use\n * when creating the Feature.\n * @return {Feature} Newly constructed `ol/Feature` with properties,\n * geometry, and id copied over.\n * @api\n */\nexport function toFeature(renderFeature, geometryName) {\n const id = renderFeature.getId();\n const geometry = toGeometry(renderFeature);\n const properties = renderFeature.getProperties();\n const feature = new Feature();\n if (geometryName !== undefined) {\n feature.setGeometryName(geometryName);\n }\n feature.setGeometry(geometry);\n if (id !== undefined) {\n feature.setId(id);\n }\n feature.setProperties(properties, true);\n return feature;\n}\n\nexport default RenderFeature;\n","\n/**\n * Rearranges items so that all items in the [left, k] are the smallest.\n * The k-th element will have the (k - left + 1)-th smallest value in [left, right].\n *\n * @template T\n * @param {T[]} arr the array to partially sort (in place)\n * @param {number} k middle index for partial sorting (as defined above)\n * @param {number} [left=0] left index of the range to sort\n * @param {number} [right=arr.length-1] right index\n * @param {(a: T, b: T) => number} [compare = (a, b) => a - b] compare function\n */\nexport default function quickselect(arr, k, left = 0, right = arr.length - 1, compare = defaultCompare) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselect(arr, k, newLeft, newRight, compare);\n }\n\n const t = arr[k];\n let i = left;\n /** @type {number} */\n let j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @template T\n * @param {T[]} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @template T\n * @param {T} a\n * @param {T} b\n * @returns {number}\n */\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","import quickselect from 'quickselect';\n\nexport default class RBush {\n constructor(maxEntries = 9) {\n // max entries in a node is 9 by default; min node fill is 40% for best performance\n this._maxEntries = Math.max(4, maxEntries);\n this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));\n this.clear();\n }\n\n all() {\n return this._all(this.data, []);\n }\n\n search(bbox) {\n let node = this.data;\n const result = [];\n\n if (!intersects(bbox, node)) return result;\n\n const toBBox = this.toBBox;\n const nodesToSearch = [];\n\n while (node) {\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const childBBox = node.leaf ? toBBox(child) : child;\n\n if (intersects(bbox, childBBox)) {\n if (node.leaf) result.push(child);\n else if (contains(bbox, childBBox)) this._all(child, result);\n else nodesToSearch.push(child);\n }\n }\n node = nodesToSearch.pop();\n }\n\n return result;\n }\n\n collides(bbox) {\n let node = this.data;\n\n if (!intersects(bbox, node)) return false;\n\n const nodesToSearch = [];\n while (node) {\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const childBBox = node.leaf ? this.toBBox(child) : child;\n\n if (intersects(bbox, childBBox)) {\n if (node.leaf || contains(bbox, childBBox)) return true;\n nodesToSearch.push(child);\n }\n }\n node = nodesToSearch.pop();\n }\n\n return false;\n }\n\n load(data) {\n if (!(data && data.length)) return this;\n\n if (data.length < this._minEntries) {\n for (let i = 0; i < data.length; i++) {\n this.insert(data[i]);\n }\n return this;\n }\n\n // recursively build the tree with the given data from scratch using OMT algorithm\n let node = this._build(data.slice(), 0, data.length - 1, 0);\n\n if (!this.data.children.length) {\n // save as is if tree is empty\n this.data = node;\n\n } else if (this.data.height === node.height) {\n // split root if trees have the same height\n this._splitRoot(this.data, node);\n\n } else {\n if (this.data.height < node.height) {\n // swap trees if inserted one is bigger\n const tmpNode = this.data;\n this.data = node;\n node = tmpNode;\n }\n\n // insert the small tree into the large tree at appropriate level\n this._insert(node, this.data.height - node.height - 1, true);\n }\n\n return this;\n }\n\n insert(item) {\n if (item) this._insert(item, this.data.height - 1);\n return this;\n }\n\n clear() {\n this.data = createNode([]);\n return this;\n }\n\n remove(item, equalsFn) {\n if (!item) return this;\n\n let node = this.data;\n const bbox = this.toBBox(item);\n const path = [];\n const indexes = [];\n let i, parent, goingUp;\n\n // depth-first iterative tree traversal\n while (node || path.length) {\n\n if (!node) { // go up\n node = path.pop();\n parent = path[path.length - 1];\n i = indexes.pop();\n goingUp = true;\n }\n\n if (node.leaf) { // check current node\n const index = findItem(item, node.children, equalsFn);\n\n if (index !== -1) {\n // item found, remove the item and condense tree upwards\n node.children.splice(index, 1);\n path.push(node);\n this._condense(path);\n return this;\n }\n }\n\n if (!goingUp && !node.leaf && contains(node, bbox)) { // go down\n path.push(node);\n indexes.push(i);\n i = 0;\n parent = node;\n node = node.children[0];\n\n } else if (parent) { // go right\n i++;\n node = parent.children[i];\n goingUp = false;\n\n } else node = null; // nothing found\n }\n\n return this;\n }\n\n toBBox(item) { return item; }\n\n compareMinX(a, b) { return a.minX - b.minX; }\n compareMinY(a, b) { return a.minY - b.minY; }\n\n toJSON() { return this.data; }\n\n fromJSON(data) {\n this.data = data;\n return this;\n }\n\n _all(node, result) {\n const nodesToSearch = [];\n while (node) {\n if (node.leaf) result.push(...node.children);\n else nodesToSearch.push(...node.children);\n\n node = nodesToSearch.pop();\n }\n return result;\n }\n\n _build(items, left, right, height) {\n\n const N = right - left + 1;\n let M = this._maxEntries;\n let node;\n\n if (N <= M) {\n // reached leaf level; return leaf\n node = createNode(items.slice(left, right + 1));\n calcBBox(node, this.toBBox);\n return node;\n }\n\n if (!height) {\n // target height of the bulk-loaded tree\n height = Math.ceil(Math.log(N) / Math.log(M));\n\n // target number of root entries to maximize storage utilization\n M = Math.ceil(N / Math.pow(M, height - 1));\n }\n\n node = createNode([]);\n node.leaf = false;\n node.height = height;\n\n // split the items into M mostly square tiles\n\n const N2 = Math.ceil(N / M);\n const N1 = N2 * Math.ceil(Math.sqrt(M));\n\n multiSelect(items, left, right, N1, this.compareMinX);\n\n for (let i = left; i <= right; i += N1) {\n\n const right2 = Math.min(i + N1 - 1, right);\n\n multiSelect(items, i, right2, N2, this.compareMinY);\n\n for (let j = i; j <= right2; j += N2) {\n\n const right3 = Math.min(j + N2 - 1, right2);\n\n // pack each entry recursively\n node.children.push(this._build(items, j, right3, height - 1));\n }\n }\n\n calcBBox(node, this.toBBox);\n\n return node;\n }\n\n _chooseSubtree(bbox, node, level, path) {\n while (true) {\n path.push(node);\n\n if (node.leaf || path.length - 1 === level) break;\n\n let minArea = Infinity;\n let minEnlargement = Infinity;\n let targetNode;\n\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const area = bboxArea(child);\n const enlargement = enlargedArea(bbox, child) - area;\n\n // choose entry with the least area enlargement\n if (enlargement < minEnlargement) {\n minEnlargement = enlargement;\n minArea = area < minArea ? area : minArea;\n targetNode = child;\n\n } else if (enlargement === minEnlargement) {\n // otherwise choose one with the smallest area\n if (area < minArea) {\n minArea = area;\n targetNode = child;\n }\n }\n }\n\n node = targetNode || node.children[0];\n }\n\n return node;\n }\n\n _insert(item, level, isNode) {\n const bbox = isNode ? item : this.toBBox(item);\n const insertPath = [];\n\n // find the best node for accommodating the item, saving all nodes along the path too\n const node = this._chooseSubtree(bbox, this.data, level, insertPath);\n\n // put the item into the node\n node.children.push(item);\n extend(node, bbox);\n\n // split on node overflow; propagate upwards if necessary\n while (level >= 0) {\n if (insertPath[level].children.length > this._maxEntries) {\n this._split(insertPath, level);\n level--;\n } else break;\n }\n\n // adjust bboxes along the insertion path\n this._adjustParentBBoxes(bbox, insertPath, level);\n }\n\n // split overflowed node into two\n _split(insertPath, level) {\n const node = insertPath[level];\n const M = node.children.length;\n const m = this._minEntries;\n\n this._chooseSplitAxis(node, m, M);\n\n const splitIndex = this._chooseSplitIndex(node, m, M);\n\n const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));\n newNode.height = node.height;\n newNode.leaf = node.leaf;\n\n calcBBox(node, this.toBBox);\n calcBBox(newNode, this.toBBox);\n\n if (level) insertPath[level - 1].children.push(newNode);\n else this._splitRoot(node, newNode);\n }\n\n _splitRoot(node, newNode) {\n // split root node\n this.data = createNode([node, newNode]);\n this.data.height = node.height + 1;\n this.data.leaf = false;\n calcBBox(this.data, this.toBBox);\n }\n\n _chooseSplitIndex(node, m, M) {\n let index;\n let minOverlap = Infinity;\n let minArea = Infinity;\n\n for (let i = m; i <= M - m; i++) {\n const bbox1 = distBBox(node, 0, i, this.toBBox);\n const bbox2 = distBBox(node, i, M, this.toBBox);\n\n const overlap = intersectionArea(bbox1, bbox2);\n const area = bboxArea(bbox1) + bboxArea(bbox2);\n\n // choose distribution with minimum overlap\n if (overlap < minOverlap) {\n minOverlap = overlap;\n index = i;\n\n minArea = area < minArea ? area : minArea;\n\n } else if (overlap === minOverlap) {\n // otherwise choose distribution with minimum area\n if (area < minArea) {\n minArea = area;\n index = i;\n }\n }\n }\n\n return index || M - m;\n }\n\n // sorts node children by the best axis for split\n _chooseSplitAxis(node, m, M) {\n const compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;\n const compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;\n const xMargin = this._allDistMargin(node, m, M, compareMinX);\n const yMargin = this._allDistMargin(node, m, M, compareMinY);\n\n // if total distributions margin value is minimal for x, sort by minX,\n // otherwise it's already sorted by minY\n if (xMargin < yMargin) node.children.sort(compareMinX);\n }\n\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(node, m, M, compare) {\n node.children.sort(compare);\n\n const toBBox = this.toBBox;\n const leftBBox = distBBox(node, 0, m, toBBox);\n const rightBBox = distBBox(node, M - m, M, toBBox);\n let margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);\n\n for (let i = m; i < M - m; i++) {\n const child = node.children[i];\n extend(leftBBox, node.leaf ? toBBox(child) : child);\n margin += bboxMargin(leftBBox);\n }\n\n for (let i = M - m - 1; i >= m; i--) {\n const child = node.children[i];\n extend(rightBBox, node.leaf ? toBBox(child) : child);\n margin += bboxMargin(rightBBox);\n }\n\n return margin;\n }\n\n _adjustParentBBoxes(bbox, path, level) {\n // adjust bboxes along the given tree path\n for (let i = level; i >= 0; i--) {\n extend(path[i], bbox);\n }\n }\n\n _condense(path) {\n // go through the path, removing empty nodes and updating bboxes\n for (let i = path.length - 1, siblings; i >= 0; i--) {\n if (path[i].children.length === 0) {\n if (i > 0) {\n siblings = path[i - 1].children;\n siblings.splice(siblings.indexOf(path[i]), 1);\n\n } else this.clear();\n\n } else calcBBox(path[i], this.toBBox);\n }\n }\n}\n\nfunction findItem(item, items, equalsFn) {\n if (!equalsFn) return items.indexOf(item);\n\n for (let i = 0; i < items.length; i++) {\n if (equalsFn(item, items[i])) return i;\n }\n return -1;\n}\n\n// calculate node's bbox from bboxes of its children\nfunction calcBBox(node, toBBox) {\n distBBox(node, 0, node.children.length, toBBox, node);\n}\n\n// min bounding rectangle of node children from k to p-1\nfunction distBBox(node, k, p, toBBox, destNode) {\n if (!destNode) destNode = createNode(null);\n destNode.minX = Infinity;\n destNode.minY = Infinity;\n destNode.maxX = -Infinity;\n destNode.maxY = -Infinity;\n\n for (let i = k; i < p; i++) {\n const child = node.children[i];\n extend(destNode, node.leaf ? toBBox(child) : child);\n }\n\n return destNode;\n}\n\nfunction extend(a, b) {\n a.minX = Math.min(a.minX, b.minX);\n a.minY = Math.min(a.minY, b.minY);\n a.maxX = Math.max(a.maxX, b.maxX);\n a.maxY = Math.max(a.maxY, b.maxY);\n return a;\n}\n\nfunction compareNodeMinX(a, b) { return a.minX - b.minX; }\nfunction compareNodeMinY(a, b) { return a.minY - b.minY; }\n\nfunction bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }\nfunction bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }\n\nfunction enlargedArea(a, b) {\n return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *\n (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));\n}\n\nfunction intersectionArea(a, b) {\n const minX = Math.max(a.minX, b.minX);\n const minY = Math.max(a.minY, b.minY);\n const maxX = Math.min(a.maxX, b.maxX);\n const maxY = Math.min(a.maxY, b.maxY);\n\n return Math.max(0, maxX - minX) *\n Math.max(0, maxY - minY);\n}\n\nfunction contains(a, b) {\n return a.minX <= b.minX &&\n a.minY <= b.minY &&\n b.maxX <= a.maxX &&\n b.maxY <= a.maxY;\n}\n\nfunction intersects(a, b) {\n return b.minX <= a.maxX &&\n b.minY <= a.maxY &&\n b.maxX >= a.minX &&\n b.maxY >= a.minY;\n}\n\nfunction createNode(children) {\n return {\n children,\n height: 1,\n leaf: true,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n}\n\n// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;\n// combines selection algorithm with binary divide & conquer approach\n\nfunction multiSelect(arr, left, right, n, compare) {\n const stack = [left, right];\n\n while (stack.length) {\n right = stack.pop();\n left = stack.pop();\n\n if (right - left <= n) continue;\n\n const mid = left + Math.ceil((right - left) / n / 2) * n;\n quickselect(arr, mid, left, right, compare);\n\n stack.push(left, mid, mid, right);\n }\n}\n","/**\n * @module ol/structs/RBush\n */\nimport RBush_ from 'rbush';\nimport {createOrUpdate, equals} from '../extent.js';\nimport {isEmpty} from '../obj.js';\nimport {getUid} from '../util.js';\n\n/**\n * @typedef {import(\"rbush\").BBox & {value: T}} Entry\n * @template T\n */\n\n/**\n * @classdesc\n * Wrapper around the RBush by Vladimir Agafonkin.\n * See https://github.com/mourner/rbush.\n *\n * @template {Object} T\n */\nclass RBush {\n /**\n * @param {number} [maxEntries] Max entries.\n */\n constructor(maxEntries) {\n /**\n * @private\n * @type {RBush_>}\n */\n this.rbush_ = new RBush_(maxEntries);\n\n /**\n * A mapping between the objects added to this rbush wrapper\n * and the objects that are actually added to the internal rbush.\n * @private\n * @type {Object>}\n */\n this.items_ = {};\n }\n\n /**\n * Insert a value into the RBush.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {T} value Value.\n */\n insert(extent, value) {\n /** @type {Entry} */\n const item = {\n minX: extent[0],\n minY: extent[1],\n maxX: extent[2],\n maxY: extent[3],\n value: value,\n };\n\n this.rbush_.insert(item);\n this.items_[getUid(value)] = item;\n }\n\n /**\n * Bulk-insert values into the RBush.\n * @param {Array} extents Extents.\n * @param {Array} values Values.\n */\n load(extents, values) {\n const items = new Array(values.length);\n for (let i = 0, l = values.length; i < l; i++) {\n const extent = extents[i];\n const value = values[i];\n\n /** @type {Entry} */\n const item = {\n minX: extent[0],\n minY: extent[1],\n maxX: extent[2],\n maxY: extent[3],\n value: value,\n };\n items[i] = item;\n this.items_[getUid(value)] = item;\n }\n this.rbush_.load(items);\n }\n\n /**\n * Remove a value from the RBush.\n * @param {T} value Value.\n * @return {boolean} Removed.\n */\n remove(value) {\n const uid = getUid(value);\n\n // get the object in which the value was wrapped when adding to the\n // internal rbush. then use that object to do the removal.\n const item = this.items_[uid];\n delete this.items_[uid];\n return this.rbush_.remove(item) !== null;\n }\n\n /**\n * Update the extent of a value in the RBush.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {T} value Value.\n */\n update(extent, value) {\n const item = this.items_[getUid(value)];\n const bbox = [item.minX, item.minY, item.maxX, item.maxY];\n if (!equals(bbox, extent)) {\n this.remove(value);\n this.insert(extent, value);\n }\n }\n\n /**\n * Return all values in the RBush.\n * @return {Array} All.\n */\n getAll() {\n const items = this.rbush_.all();\n return items.map(function (item) {\n return item.value;\n });\n }\n\n /**\n * Return all values in the given extent.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {Array} All in extent.\n */\n getInExtent(extent) {\n /** @type {import(\"rbush\").BBox} */\n const bbox = {\n minX: extent[0],\n minY: extent[1],\n maxX: extent[2],\n maxY: extent[3],\n };\n const items = this.rbush_.search(bbox);\n return items.map(function (item) {\n return item.value;\n });\n }\n\n /**\n * Calls a callback function with each value in the tree.\n * If the callback returns a truthy value, this value is returned without\n * checking the rest of the tree.\n * @param {function(T): R} callback Callback.\n * @return {R|undefined} Callback return value.\n * @template R\n */\n forEach(callback) {\n return this.forEach_(this.getAll(), callback);\n }\n\n /**\n * Calls a callback function with each value in the provided extent.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {function(T): R} callback Callback.\n * @return {R|undefined} Callback return value.\n * @template R\n */\n forEachInExtent(extent, callback) {\n return this.forEach_(this.getInExtent(extent), callback);\n }\n\n /**\n * @param {Array} values Values.\n * @param {function(T): R} callback Callback.\n * @return {R|undefined} Callback return value.\n * @template R\n * @private\n */\n forEach_(values, callback) {\n let result;\n for (let i = 0, l = values.length; i < l; i++) {\n result = callback(values[i]);\n if (result) {\n return result;\n }\n }\n return result;\n }\n\n /**\n * @return {boolean} Is empty.\n */\n isEmpty() {\n return isEmpty(this.items_);\n }\n\n /**\n * Remove all values from the RBush.\n */\n clear() {\n this.rbush_.clear();\n this.items_ = {};\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} [extent] Extent.\n * @return {import(\"../extent.js\").Extent} Extent.\n */\n getExtent(extent) {\n const data = this.rbush_.toJSON();\n return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, extent);\n }\n\n /**\n * @param {RBush} rbush R-Tree.\n */\n concat(rbush) {\n this.rbush_.load(rbush.rbush_.all());\n for (const i in rbush.items_) {\n this.items_[i] = rbush.items_[i];\n }\n }\n}\n\nexport default RBush;\n","/**\n * @module ol/source/Source\n */\nimport BaseObject from '../Object.js';\nimport {get as getProjection} from '../proj.js';\n\n/**\n * @typedef {'undefined' | 'loading' | 'ready' | 'error'} State\n * State of the source, one of 'undefined', 'loading', 'ready' or 'error'.\n */\n\n/**\n * A function that takes a {@link import(\"../View.js\").ViewStateLayerStateExtent} and returns a string or\n * an array of strings representing source attributions.\n *\n * @typedef {function(import(\"../View.js\").ViewStateLayerStateExtent): (string|Array)} Attribution\n */\n\n/**\n * A type that can be used to provide attribution information for data sources.\n *\n * It represents either\n * a simple string (e.g. `'© Acme Inc.'`)\n * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)\n * a function that returns a string or array of strings ({@link module:ol/source/Source~Attribution})\n *\n * @typedef {string|Array|Attribution} AttributionLike\n */\n\n/**\n * @typedef {Object} Options\n * @property {AttributionLike} [attributions] Attributions.\n * @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.\n * @property {import(\"../proj.js\").ProjectionLike} [projection] Projection. Default is the view projection.\n * @property {import(\"./Source.js\").State} [state='ready'] State.\n * @property {boolean} [wrapX=false] WrapX.\n * @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,\n * the nearest neighbor is used when resampling.\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for {@link module:ol/layer/Layer~Layer} sources.\n *\n * A generic `change` event is triggered when the state of the source changes.\n * @abstract\n * @api\n */\nclass Source extends BaseObject {\n /**\n * @param {Options} options Source options.\n */\n constructor(options) {\n super();\n\n /**\n * @protected\n * @type {import(\"../proj/Projection.js\").default|null}\n */\n this.projection = getProjection(options.projection);\n\n /**\n * @private\n * @type {?Attribution}\n */\n this.attributions_ = adaptAttributions(options.attributions);\n\n /**\n * @private\n * @type {boolean}\n */\n this.attributionsCollapsible_ = options.attributionsCollapsible ?? true;\n\n /**\n * This source is currently loading data. Sources that defer loading to the\n * map's tile queue never set this to a `truthy` value.\n * @type {boolean|number}\n */\n this.loading = false;\n\n /**\n * @private\n * @type {import(\"./Source.js\").State}\n */\n this.state_ = options.state !== undefined ? options.state : 'ready';\n\n /**\n * @private\n * @type {boolean}\n */\n this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;\n\n /**\n * @private\n * @type {boolean}\n */\n this.interpolate_ = !!options.interpolate;\n\n /**\n * @protected\n * @type {function(import(\"../View.js\").ViewOptions):void}\n */\n this.viewResolver = null;\n\n /**\n * @protected\n * @type {function(Error):void}\n */\n this.viewRejector = null;\n\n const self = this;\n /**\n * @private\n * @type {Promise}\n */\n this.viewPromise_ = new Promise(function (resolve, reject) {\n self.viewResolver = resolve;\n self.viewRejector = reject;\n });\n }\n\n /**\n * Get the attribution function for the source.\n * @return {?Attribution} Attribution function.\n * @api\n */\n getAttributions() {\n return this.attributions_;\n }\n\n /**\n * @return {boolean} Attributions are collapsible.\n * @api\n */\n getAttributionsCollapsible() {\n return this.attributionsCollapsible_;\n }\n\n /**\n * Get the projection of the source.\n * @return {import(\"../proj/Projection.js\").default|null} Projection.\n * @api\n */\n getProjection() {\n return this.projection;\n }\n\n /**\n * @param {import(\"../proj/Projection.js\").default} [projection] Projection.\n * @return {Array|null} Resolutions.\n */\n getResolutions(projection) {\n return null;\n }\n\n /**\n * @return {Promise} A promise for view-related properties.\n */\n getView() {\n return this.viewPromise_;\n }\n\n /**\n * Get the state of the source, see {@link import(\"./Source.js\").State} for possible states.\n * @return {import(\"./Source.js\").State} State.\n * @api\n */\n getState() {\n return this.state_;\n }\n\n /**\n * @return {boolean|undefined} Wrap X.\n */\n getWrapX() {\n return this.wrapX_;\n }\n\n /**\n * @return {boolean} Use linear interpolation when resampling.\n */\n getInterpolate() {\n return this.interpolate_;\n }\n\n /**\n * Refreshes the source. The source will be cleared, and data from the server will be reloaded.\n * @api\n */\n refresh() {\n this.changed();\n }\n\n /**\n * Set the attributions of the source.\n * @param {AttributionLike|undefined} attributions Attributions.\n * Can be passed as `string`, `Array`, {@link module:ol/source/Source~Attribution},\n * or `undefined`.\n * @api\n */\n setAttributions(attributions) {\n this.attributions_ = adaptAttributions(attributions);\n this.changed();\n }\n\n /**\n * Set the state of the source.\n * @param {import(\"./Source.js\").State} state State.\n */\n setState(state) {\n this.state_ = state;\n this.changed();\n }\n}\n\n/**\n * Turns the attributions option into an attributions function.\n * @param {AttributionLike|undefined} attributionLike The attribution option.\n * @return {Attribution|null} An attribution function (or null).\n */\nfunction adaptAttributions(attributionLike) {\n if (!attributionLike) {\n return null;\n }\n if (typeof attributionLike === 'function') {\n return attributionLike;\n }\n if (!Array.isArray(attributionLike)) {\n attributionLike = [attributionLike];\n }\n return (frameState) => attributionLike;\n}\n\nexport default Source;\n","/**\n * @module ol/source/VectorEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when a feature is added to the source.\n * @event module:ol/source/Vector.VectorSourceEvent#addfeature\n * @api\n */\n ADDFEATURE: 'addfeature',\n\n /**\n * Triggered when a feature is updated.\n * @event module:ol/source/Vector.VectorSourceEvent#changefeature\n * @api\n */\n CHANGEFEATURE: 'changefeature',\n\n /**\n * Triggered when the clear method is called on the source.\n * @event module:ol/source/Vector.VectorSourceEvent#clear\n * @api\n */\n CLEAR: 'clear',\n\n /**\n * Triggered when a feature is removed from the source.\n * See {@link module:ol/source/Vector~VectorSource#clear source.clear()} for exceptions.\n * @event module:ol/source/Vector.VectorSourceEvent#removefeature\n * @api\n */\n REMOVEFEATURE: 'removefeature',\n\n /**\n * Triggered when features starts loading.\n * @event module:ol/source/Vector.VectorSourceEvent#featuresloadstart\n * @api\n */\n FEATURESLOADSTART: 'featuresloadstart',\n\n /**\n * Triggered when features finishes loading.\n * @event module:ol/source/Vector.VectorSourceEvent#featuresloadend\n * @api\n */\n FEATURESLOADEND: 'featuresloadend',\n\n /**\n * Triggered if feature loading results in an error.\n * @event module:ol/source/Vector.VectorSourceEvent#featuresloaderror\n * @api\n */\n FEATURESLOADERROR: 'featuresloaderror',\n};\n\n/**\n * @typedef {'addfeature'|'changefeature'|'clear'|'removefeature'|'featuresloadstart'|'featuresloadend'|'featuresloaderror'} VectorSourceEventTypes\n */\n","/**\n * @module ol/source/Vector\n */\n\nimport Collection from '../Collection.js';\nimport CollectionEventType from '../CollectionEventType.js';\nimport ObjectEventType from '../ObjectEventType.js';\nimport {extend} from '../array.js';\nimport {assert} from '../asserts.js';\nimport {listen, unlistenByKey} from '../events.js';\nimport Event from '../events/Event.js';\nimport EventType from '../events/EventType.js';\nimport {containsExtent, equals, wrapAndSliceX} from '../extent.js';\nimport {xhr} from '../featureloader.js';\nimport {TRUE, VOID} from '../functions.js';\nimport {all as allStrategy} from '../loadingstrategy.js';\nimport {isEmpty} from '../obj.js';\nimport RenderFeature from '../render/Feature.js';\nimport RBush from '../structs/RBush.js';\nimport {getUid} from '../util.js';\nimport Source from './Source.js';\nimport VectorEventType from './VectorEventType.js';\n\n/**\n * A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and\n * returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this\n * is one of the standard {@link module:ol/loadingstrategy} strategies.\n *\n * @typedef {function(import(\"../extent.js\").Extent, number, import(\"../proj/Projection.js\").default): Array} LoadingStrategy\n * @api\n */\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/source/Vector~VectorSource} instances are instances of this\n * type.\n * @template {import(\"../Feature.js\").FeatureLike} [FeatureType=import(\"../Feature.js\").default]\n */\nexport class VectorSourceEvent extends Event {\n /**\n * @param {string} type Type.\n * @param {FeatureType} [feature] Feature.\n * @param {Array} [features] Features.\n */\n constructor(type, feature, features) {\n super(type);\n\n /**\n * The added or removed feature for the `ADDFEATURE` and `REMOVEFEATURE` events, `undefined` otherwise.\n * @type {FeatureType|undefined}\n * @api\n */\n this.feature = feature;\n\n /**\n * The loaded features for the `FEATURESLOADED` event, `undefined` otherwise.\n * @type {Array|undefined}\n * @api\n */\n this.features = features;\n }\n}\n\n/***\n * @template {import(\"../Feature.js\").FeatureLike} [T=import(\"../Feature.js\").default]\n * @typedef {T extends RenderFeature ? T|Array : T} FeatureClassOrArrayOfRenderFeatures\n */\n\n/***\n * @template Return\n * @template {import(\"../Feature.js\").FeatureLike} [FeatureType=import(\"../Feature.js\").default]\n * @typedef {import(\"../Observable.js\").OnSignature &\n * import(\"../Observable.js\").OnSignature &\n * import(\"../Observable.js\").OnSignature, Return> &\n * import(\"../Observable.js\").CombinedOnSignature} VectorSourceOnSignature\n */\n\n/**\n * @template {import(\"../Feature.js\").FeatureLike} [FeatureType=import(\"../Feature.js\").default]\n * @typedef {Object} Options\n * @property {import(\"./Source.js\").AttributionLike} [attributions] Attributions.\n * @property {Array|Collection} [features]\n * Features. If provided as {@link module:ol/Collection~Collection}, the features in the source\n * and the collection will stay in sync.\n * @property {import(\"../format/Feature.js\").default} [format] The feature format used by the XHR\n * feature loader when `url` is set. Required if `url` is set, otherwise ignored.\n * @property {import(\"../featureloader.js\").FeatureLoader} [loader]\n * The loader function used to load features, from a remote source for example.\n * If this is not set and `url` is set, the source will create and use an XHR\n * feature loader. The `'featuresloadend'` and `'featuresloaderror'` events\n * will only fire if the `success` and `failure` callbacks are used.\n *\n * Example:\n *\n * ```js\n * import Vector from 'ol/source/Vector.js';\n * import GeoJSON from 'ol/format/GeoJSON.js';\n * import {bbox} from 'ol/loadingstrategy.js';\n *\n * const vectorSource = new Vector({\n * loader: async (extent, resolution, projection) => {\n * const url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +\n * 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +\n * 'outputFormat=application/json' +\n * 'bbox=' + extent.join(',') + ',' + projection.getCode();\n * const response = await fetch(url);\n * if (!response.ok) {\n * throw new Error('Network response was not ok');\n * }\n * const json = await response.json();\n * const features = new GeoJSON().readFeatures(json, {\n * featureProjection: projection,\n * });\n * return features;\n * },\n * strategy: bbox,\n * });\n * ```\n *\n * When you want to retry a failed request, use\n * ```js\n * vectorSource.removeLoadedExtent(extent);\n * vectorSource.changed();\n * ```\n *\n * @property {boolean} [overlaps=true] This source may have overlapping geometries.\n * Setting this to `false` (e.g. for sources with polygons that represent administrative\n * boundaries or TopoJSON sources) allows the renderer to optimise fill and\n * stroke operations.\n * @property {LoadingStrategy} [strategy] The loading strategy to use.\n * By default an {@link module:ol/loadingstrategy.all}\n * strategy is used, a one-off strategy which loads all features at once.\n * @property {string|import(\"../featureloader.js\").FeatureUrlFunction} [url]\n * Setting this option instructs the source to load features using an XHR loader\n * (see {@link module:ol/featureloader.xhr}). Use a `string` and an\n * {@link module:ol/loadingstrategy.all} for a one-off download of all features from\n * the given URL. Use a {@link module:ol/featureloader~FeatureUrlFunction} to generate the url with\n * other loading strategies.\n * Requires `format` to be set as well.\n * When default XHR feature loader is provided, the features will\n * be transformed from the data projection to the view projection\n * during parsing. If your remote data source does not advertise its projection\n * properly, this transformation will be incorrect. For some formats, the\n * default projection (usually EPSG:4326) can be overridden by setting the\n * dataProjection constructor option on the format.\n * Note that if a source contains non-feature data, such as a GeoJSON geometry\n * or a KML NetworkLink, these will be ignored. Use a custom loader to load these.\n * @property {boolean} [useSpatialIndex=true]\n * By default, an RTree is used as spatial index. When features are removed and\n * added frequently, and the total number of features is low, setting this to\n * `false` may improve performance.\n *\n * Note that\n * {@link module:ol/source/Vector~VectorSource#getFeaturesInExtent},\n * {@link module:ol/source/Vector~VectorSource#getClosestFeatureToCoordinate} and\n * {@link module:ol/source/Vector~VectorSource#getExtent} cannot be used when `useSpatialIndex` is\n * set to `false`, and {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent} will loop\n * through all features.\n *\n * When set to `false`, the features will be maintained in an\n * {@link module:ol/Collection~Collection}, which can be retrieved through\n * {@link module:ol/source/Vector~VectorSource#getFeaturesCollection}.\n * @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the\n * -180° and 180° meridians to work properly, this should be set to `false`. The\n * resulting geometry coordinates will then exceed the world bounds.\n */\n\n/**\n * @classdesc\n * Provides a source of features for vector layers. Vector features provided\n * by this source are suitable for editing. See {@link module:ol/source/VectorTile~VectorTile} for\n * vector data that is optimized for rendering.\n *\n * @fires VectorSourceEvent\n * @api\n * @template {import(\"../Feature.js\").FeatureLike} [FeatureType=import(\"../Feature.js\").default]\n */\nclass VectorSource extends Source {\n /**\n * @param {Options} [options] Vector source options.\n */\n constructor(options) {\n options = options || {};\n\n super({\n attributions: options.attributions,\n interpolate: true,\n projection: undefined,\n state: 'ready',\n wrapX: options.wrapX !== undefined ? options.wrapX : true,\n });\n\n /***\n * @type {VectorSourceOnSignature}\n */\n this.on;\n\n /***\n * @type {VectorSourceOnSignature}\n */\n this.once;\n\n /***\n * @type {VectorSourceOnSignature}\n */\n this.un;\n\n /**\n * @private\n * @type {import(\"../featureloader.js\").FeatureLoader}\n */\n this.loader_ = VOID;\n\n /**\n * @private\n * @type {import(\"../format/Feature.js\").default|null}\n */\n this.format_ = options.format || null;\n\n /**\n * @private\n * @type {boolean}\n */\n this.overlaps_ = options.overlaps === undefined ? true : options.overlaps;\n\n /**\n * @private\n * @type {string|import(\"../featureloader.js\").FeatureUrlFunction|undefined}\n */\n this.url_ = options.url;\n\n if (options.loader !== undefined) {\n this.loader_ = options.loader;\n } else if (this.url_ !== undefined) {\n assert(this.format_, '`format` must be set when `url` is set');\n // create a XHR feature loader for \"url\" and \"format\"\n this.loader_ = xhr(this.url_, this.format_);\n }\n\n /**\n * @private\n * @type {LoadingStrategy}\n */\n this.strategy_ =\n options.strategy !== undefined ? options.strategy : allStrategy;\n\n const useSpatialIndex =\n options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;\n\n /**\n * @private\n * @type {RBush}\n */\n this.featuresRtree_ = useSpatialIndex ? new RBush() : null;\n\n /**\n * @private\n * @type {RBush<{extent: import(\"../extent.js\").Extent}>}\n */\n this.loadedExtentsRtree_ = new RBush();\n\n /**\n * @private\n * @type {!Object}\n */\n this.nullGeometryFeatures_ = {};\n\n /**\n * A lookup of features by id (the return from feature.getId()).\n * @private\n * @type {!Object>}\n */\n this.idIndex_ = {};\n\n /**\n * A lookup of features by uid (using getUid(feature)).\n * @private\n * @type {!Object}\n */\n this.uidIndex_ = {};\n\n /**\n * @private\n * @type {Object>}\n */\n this.featureChangeKeys_ = {};\n\n /**\n * @private\n * @type {Collection|null}\n */\n this.featuresCollection_ = null;\n\n /** @type {Collection} */\n let collection;\n /** @type {Array} */\n let features;\n if (Array.isArray(options.features)) {\n features = options.features;\n } else if (options.features) {\n collection = options.features;\n features = collection.getArray();\n }\n if (!useSpatialIndex && collection === undefined) {\n collection = new Collection(features);\n }\n if (features !== undefined) {\n this.addFeaturesInternal(features);\n }\n if (collection !== undefined) {\n this.bindFeaturesCollection_(collection);\n }\n }\n\n /**\n * Add a single feature to the source. If you want to add a batch of features\n * at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}\n * instead. A feature will not be added to the source if feature with\n * the same id is already there. The reason for this behavior is to avoid\n * feature duplication when using bbox or tile loading strategies.\n * Note: this also applies if a {@link module:ol/Collection~Collection} is used for features,\n * meaning that if a feature with a duplicate id is added in the collection, it will\n * be removed from it right away.\n * @param {FeatureType} feature Feature to add.\n * @api\n */\n addFeature(feature) {\n this.addFeatureInternal(feature);\n this.changed();\n }\n\n /**\n * Add a feature without firing a `change` event.\n * @param {FeatureType} feature Feature.\n * @protected\n */\n addFeatureInternal(feature) {\n const featureKey = getUid(feature);\n\n if (!this.addToIndex_(featureKey, feature)) {\n if (this.featuresCollection_) {\n this.featuresCollection_.remove(feature);\n }\n return;\n }\n\n this.setupChangeEvents_(featureKey, feature);\n\n const geometry = feature.getGeometry();\n if (geometry) {\n const extent = geometry.getExtent();\n if (this.featuresRtree_) {\n this.featuresRtree_.insert(extent, feature);\n }\n } else {\n this.nullGeometryFeatures_[featureKey] = feature;\n }\n\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.ADDFEATURE, feature),\n );\n }\n\n /**\n * @param {string} featureKey Unique identifier for the feature.\n * @param {FeatureType} feature The feature.\n * @private\n */\n setupChangeEvents_(featureKey, feature) {\n if (feature instanceof RenderFeature) {\n return;\n }\n this.featureChangeKeys_[featureKey] = [\n listen(feature, EventType.CHANGE, this.handleFeatureChange_, this),\n listen(\n feature,\n ObjectEventType.PROPERTYCHANGE,\n this.handleFeatureChange_,\n this,\n ),\n ];\n }\n\n /**\n * @param {string} featureKey Unique identifier for the feature.\n * @param {FeatureType} feature The feature.\n * @return {boolean} The feature is \"valid\", in the sense that it is also a\n * candidate for insertion into the Rtree.\n * @private\n */\n addToIndex_(featureKey, feature) {\n let valid = true;\n if (feature.getId() !== undefined) {\n const id = String(feature.getId());\n if (!(id in this.idIndex_)) {\n this.idIndex_[id] = feature;\n } else if (feature instanceof RenderFeature) {\n const indexedFeature = this.idIndex_[id];\n if (!(indexedFeature instanceof RenderFeature)) {\n valid = false;\n } else if (!Array.isArray(indexedFeature)) {\n this.idIndex_[id] = [indexedFeature, feature];\n } else {\n indexedFeature.push(feature);\n }\n } else {\n valid = false;\n }\n }\n if (valid) {\n assert(\n !(featureKey in this.uidIndex_),\n 'The passed `feature` was already added to the source',\n );\n this.uidIndex_[featureKey] = feature;\n }\n return valid;\n }\n\n /**\n * Add a batch of features to the source.\n * @param {Array} features Features to add.\n * @api\n */\n addFeatures(features) {\n this.addFeaturesInternal(features);\n this.changed();\n }\n\n /**\n * Add features without firing a `change` event.\n * @param {Array} features Features.\n * @protected\n */\n addFeaturesInternal(features) {\n const extents = [];\n /** @type {Array} */\n const newFeatures = [];\n /** @type {Array} */\n const geometryFeatures = [];\n\n for (let i = 0, length = features.length; i < length; i++) {\n const feature = features[i];\n const featureKey = getUid(feature);\n if (this.addToIndex_(featureKey, feature)) {\n newFeatures.push(feature);\n }\n }\n\n for (let i = 0, length = newFeatures.length; i < length; i++) {\n const feature = newFeatures[i];\n const featureKey = getUid(feature);\n this.setupChangeEvents_(featureKey, feature);\n\n const geometry = feature.getGeometry();\n if (geometry) {\n const extent = geometry.getExtent();\n extents.push(extent);\n geometryFeatures.push(feature);\n } else {\n this.nullGeometryFeatures_[featureKey] = feature;\n }\n }\n if (this.featuresRtree_) {\n this.featuresRtree_.load(extents, geometryFeatures);\n }\n\n if (this.hasListener(VectorEventType.ADDFEATURE)) {\n for (let i = 0, length = newFeatures.length; i < length; i++) {\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i]),\n );\n }\n }\n }\n\n /**\n * @param {!Collection} collection Collection.\n * @private\n */\n bindFeaturesCollection_(collection) {\n let modifyingCollection = false;\n this.addEventListener(\n VectorEventType.ADDFEATURE,\n /**\n * @param {VectorSourceEvent} evt The vector source event\n */\n function (evt) {\n if (!modifyingCollection) {\n modifyingCollection = true;\n collection.push(evt.feature);\n modifyingCollection = false;\n }\n },\n );\n this.addEventListener(\n VectorEventType.REMOVEFEATURE,\n /**\n * @param {VectorSourceEvent} evt The vector source event\n */\n function (evt) {\n if (!modifyingCollection) {\n modifyingCollection = true;\n collection.remove(evt.feature);\n modifyingCollection = false;\n }\n },\n );\n collection.addEventListener(\n CollectionEventType.ADD,\n /**\n * @param {import(\"../Collection.js\").CollectionEvent} evt The collection event\n */\n (evt) => {\n if (!modifyingCollection) {\n modifyingCollection = true;\n this.addFeature(evt.element);\n modifyingCollection = false;\n }\n },\n );\n collection.addEventListener(\n CollectionEventType.REMOVE,\n /**\n * @param {import(\"../Collection.js\").CollectionEvent} evt The collection event\n */\n (evt) => {\n if (!modifyingCollection) {\n modifyingCollection = true;\n this.removeFeature(evt.element);\n modifyingCollection = false;\n }\n },\n );\n this.featuresCollection_ = collection;\n }\n\n /**\n * Remove all features from the source.\n * @param {boolean} [fast] Skip dispatching of {@link module:ol/source/Vector.VectorSourceEvent#event:removefeature} events.\n * @api\n */\n clear(fast) {\n if (fast) {\n for (const featureId in this.featureChangeKeys_) {\n const keys = this.featureChangeKeys_[featureId];\n keys.forEach(unlistenByKey);\n }\n if (!this.featuresCollection_) {\n this.featureChangeKeys_ = {};\n this.idIndex_ = {};\n this.uidIndex_ = {};\n }\n } else {\n if (this.featuresRtree_) {\n this.featuresRtree_.forEach((feature) => {\n this.removeFeatureInternal(feature);\n });\n for (const id in this.nullGeometryFeatures_) {\n this.removeFeatureInternal(this.nullGeometryFeatures_[id]);\n }\n }\n }\n if (this.featuresCollection_) {\n this.featuresCollection_.clear();\n }\n\n if (this.featuresRtree_) {\n this.featuresRtree_.clear();\n }\n this.nullGeometryFeatures_ = {};\n\n const clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);\n this.dispatchEvent(clearEvent);\n this.changed();\n }\n\n /**\n * Iterate through all features on the source, calling the provided callback\n * with each one. If the callback returns any \"truthy\" value, iteration will\n * stop and the function will return the same value.\n * Note: this function only iterate through the feature that have a defined geometry.\n *\n * @param {function(FeatureType): T} callback Called with each feature\n * on the source. Return a truthy value to stop iteration.\n * @return {T|undefined} The return value from the last call to the callback.\n * @template T\n * @api\n */\n forEachFeature(callback) {\n if (this.featuresRtree_) {\n return this.featuresRtree_.forEach(callback);\n }\n if (this.featuresCollection_) {\n this.featuresCollection_.forEach(callback);\n }\n }\n\n /**\n * Iterate through all features whose geometries contain the provided\n * coordinate, calling the callback with each feature. If the callback returns\n * a \"truthy\" value, iteration will stop and the function will return the same\n * value.\n *\n * For {@link module:ol/render/Feature~RenderFeature} features, the callback will be\n * called for all features.\n *\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {function(FeatureType): T} callback Called with each feature\n * whose goemetry contains the provided coordinate.\n * @return {T|undefined} The return value from the last call to the callback.\n * @template T\n */\n forEachFeatureAtCoordinateDirect(coordinate, callback) {\n const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];\n return this.forEachFeatureInExtent(extent, function (feature) {\n const geometry = feature.getGeometry();\n if (\n geometry instanceof RenderFeature ||\n geometry.intersectsCoordinate(coordinate)\n ) {\n return callback(feature);\n }\n return undefined;\n });\n }\n\n /**\n * Iterate through all features whose bounding box intersects the provided\n * extent (note that the feature's geometry may not intersect the extent),\n * calling the callback with each feature. If the callback returns a \"truthy\"\n * value, iteration will stop and the function will return the same value.\n *\n * If you are interested in features whose geometry intersects an extent, call\n * the {@link module:ol/source/Vector~VectorSource#forEachFeatureIntersectingExtent #forEachFeatureIntersectingExtent()} method instead.\n *\n * When `useSpatialIndex` is set to false, this method will loop through all\n * features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.\n *\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {function(FeatureType): T} callback Called with each feature\n * whose bounding box intersects the provided extent.\n * @return {T|undefined} The return value from the last call to the callback.\n * @template T\n * @api\n */\n forEachFeatureInExtent(extent, callback) {\n if (this.featuresRtree_) {\n return this.featuresRtree_.forEachInExtent(extent, callback);\n }\n if (this.featuresCollection_) {\n this.featuresCollection_.forEach(callback);\n }\n }\n\n /**\n * Iterate through all features whose geometry intersects the provided extent,\n * calling the callback with each feature. If the callback returns a \"truthy\"\n * value, iteration will stop and the function will return the same value.\n *\n * If you only want to test for bounding box intersection, call the\n * {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.\n *\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {function(FeatureType): T} callback Called with each feature\n * whose geometry intersects the provided extent.\n * @return {T|undefined} The return value from the last call to the callback.\n * @template T\n * @api\n */\n forEachFeatureIntersectingExtent(extent, callback) {\n return this.forEachFeatureInExtent(\n extent,\n /**\n * @param {FeatureType} feature Feature.\n * @return {T|undefined} The return value from the last call to the callback.\n */\n function (feature) {\n const geometry = feature.getGeometry();\n if (\n geometry instanceof RenderFeature ||\n geometry.intersectsExtent(extent)\n ) {\n const result = callback(feature);\n if (result) {\n return result;\n }\n }\n },\n );\n }\n\n /**\n * Get the features collection associated with this source. Will be `null`\n * unless the source was configured with `useSpatialIndex` set to `false`, or\n * with a {@link module:ol/Collection~Collection} as `features`.\n * @return {Collection|null} The collection of features.\n * @api\n */\n getFeaturesCollection() {\n return this.featuresCollection_;\n }\n\n /**\n * Get a snapshot of the features currently on the source in random order. The returned array\n * is a copy, the features are references to the features in the source.\n * @return {Array} Features.\n * @api\n */\n getFeatures() {\n let features;\n if (this.featuresCollection_) {\n features = this.featuresCollection_.getArray().slice(0);\n } else if (this.featuresRtree_) {\n features = this.featuresRtree_.getAll();\n if (!isEmpty(this.nullGeometryFeatures_)) {\n extend(features, Object.values(this.nullGeometryFeatures_));\n }\n }\n return features;\n }\n\n /**\n * Get all features whose geometry intersects the provided coordinate.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {Array} Features.\n * @api\n */\n getFeaturesAtCoordinate(coordinate) {\n /** @type {Array} */\n const features = [];\n this.forEachFeatureAtCoordinateDirect(coordinate, function (feature) {\n features.push(feature);\n });\n return features;\n }\n\n /**\n * Get all features whose bounding box intersects the provided extent. Note that this returns an array of\n * all features intersecting the given extent in random order (so it may include\n * features whose geometries do not intersect the extent).\n *\n * When `useSpatialIndex` is set to false, this method will return all\n * features.\n *\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {import(\"../proj/Projection.js\").default} [projection] Include features\n * where `extent` exceeds the x-axis bounds of `projection` and wraps around the world.\n * @return {Array} Features.\n * @api\n */\n getFeaturesInExtent(extent, projection) {\n if (this.featuresRtree_) {\n const multiWorld = projection && projection.canWrapX() && this.getWrapX();\n\n if (!multiWorld) {\n return this.featuresRtree_.getInExtent(extent);\n }\n\n const extents = wrapAndSliceX(extent, projection);\n\n return [].concat(\n ...extents.map((anExtent) => this.featuresRtree_.getInExtent(anExtent)),\n );\n }\n if (this.featuresCollection_) {\n return this.featuresCollection_.getArray().slice(0);\n }\n return [];\n }\n\n /**\n * Get the closest feature to the provided coordinate.\n *\n * This method is not available when the source is configured with\n * `useSpatialIndex` set to `false` and the features in this source are of type\n * {@link module:ol/Feature~Feature}.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {function(FeatureType):boolean} [filter] Feature filter function.\n * The filter function will receive one argument, the {@link module:ol/Feature~Feature feature}\n * and it should return a boolean value. By default, no filtering is made.\n * @return {FeatureType|null} Closest feature (or `null` if none found).\n * @api\n */\n getClosestFeatureToCoordinate(coordinate, filter) {\n // Find the closest feature using branch and bound. We start searching an\n // infinite extent, and find the distance from the first feature found. This\n // becomes the closest feature. We then compute a smaller extent which any\n // closer feature must intersect. We continue searching with this smaller\n // extent, trying to find a closer feature. Every time we find a closer\n // feature, we update the extent being searched so that any even closer\n // feature must intersect it. We continue until we run out of features.\n const x = coordinate[0];\n const y = coordinate[1];\n let closestFeature = null;\n const closestPoint = [NaN, NaN];\n let minSquaredDistance = Infinity;\n const extent = [-Infinity, -Infinity, Infinity, Infinity];\n filter = filter ? filter : TRUE;\n this.featuresRtree_.forEachInExtent(\n extent,\n /**\n * @param {FeatureType} feature Feature.\n */\n function (feature) {\n if (filter(feature)) {\n const geometry = feature.getGeometry();\n const previousMinSquaredDistance = minSquaredDistance;\n minSquaredDistance =\n geometry instanceof RenderFeature\n ? 0\n : geometry.closestPointXY(x, y, closestPoint, minSquaredDistance);\n if (minSquaredDistance < previousMinSquaredDistance) {\n closestFeature = feature;\n // This is sneaky. Reduce the extent that it is currently being\n // searched while the R-Tree traversal using this same extent object\n // is still in progress. This is safe because the new extent is\n // strictly contained by the old extent.\n const minDistance = Math.sqrt(minSquaredDistance);\n extent[0] = x - minDistance;\n extent[1] = y - minDistance;\n extent[2] = x + minDistance;\n extent[3] = y + minDistance;\n }\n }\n },\n );\n return closestFeature;\n }\n\n /**\n * Get the extent of the features currently in the source.\n *\n * This will return `null` when the source is configured with\n * `useSpatialIndex` set to `false`.\n * @param {import(\"../extent.js\").Extent} [extent] Destination extent. If provided, no new extent\n * will be created. Instead, that extent's coordinates will be overwritten.\n * @return {import(\"../extent.js\").Extent | null} Extent.\n * @api\n */\n getExtent(extent) {\n return this.featuresRtree_?.getExtent(extent) ?? null;\n }\n\n /**\n * Get a feature by its identifier (the value returned by feature.getId()). When `RenderFeature`s\n * are used, `getFeatureById()` can return an array of `RenderFeature`s. This allows for handling\n * of `GeometryCollection` geometries, where format readers create one `RenderFeature` per\n * `GeometryCollection` member.\n * Note that the index treats string and numeric identifiers as the same. So\n * `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.\n *\n * @param {string|number} id Feature identifier.\n * @return {FeatureClassOrArrayOfRenderFeatures|null} The feature (or `null` if not found).\n * @api\n */\n getFeatureById(id) {\n const feature = this.idIndex_[id.toString()];\n return feature !== undefined\n ? /** @type {FeatureClassOrArrayOfRenderFeatures} */ (\n feature\n )\n : null;\n }\n\n /**\n * Get a feature by its internal unique identifier (using `getUid`).\n *\n * @param {string} uid Feature identifier.\n * @return {FeatureType|null} The feature (or `null` if not found).\n */\n getFeatureByUid(uid) {\n const feature = this.uidIndex_[uid];\n return feature !== undefined ? feature : null;\n }\n\n /**\n * Get the format associated with this source.\n *\n * @return {import(\"../format/Feature.js\").default|null}} The feature format.\n * @api\n */\n getFormat() {\n return this.format_;\n }\n\n /**\n * @return {boolean} The source can have overlapping geometries.\n */\n getOverlaps() {\n return this.overlaps_;\n }\n\n /**\n * Get the url associated with this source.\n *\n * @return {string|import(\"../featureloader.js\").FeatureUrlFunction|undefined} The url.\n * @api\n */\n getUrl() {\n return this.url_;\n }\n\n /**\n * @param {Event} event Event.\n * @private\n */\n handleFeatureChange_(event) {\n const feature = /** @type {FeatureType} */ (event.target);\n const featureKey = getUid(feature);\n const geometry = feature.getGeometry();\n if (!geometry) {\n if (!(featureKey in this.nullGeometryFeatures_)) {\n if (this.featuresRtree_) {\n this.featuresRtree_.remove(feature);\n }\n this.nullGeometryFeatures_[featureKey] = feature;\n }\n } else {\n const extent = geometry.getExtent();\n if (featureKey in this.nullGeometryFeatures_) {\n delete this.nullGeometryFeatures_[featureKey];\n if (this.featuresRtree_) {\n this.featuresRtree_.insert(extent, feature);\n }\n } else {\n if (this.featuresRtree_) {\n this.featuresRtree_.update(extent, feature);\n }\n }\n }\n const id = feature.getId();\n if (id !== undefined) {\n const sid = id.toString();\n if (this.idIndex_[sid] !== feature) {\n this.removeFromIdIndex_(feature);\n this.idIndex_[sid] = feature;\n }\n } else {\n this.removeFromIdIndex_(feature);\n this.uidIndex_[featureKey] = feature;\n }\n this.changed();\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.CHANGEFEATURE, feature),\n );\n }\n\n /**\n * Returns true if the feature is contained within the source.\n * @param {FeatureType} feature Feature.\n * @return {boolean} Has feature.\n * @api\n */\n hasFeature(feature) {\n const id = feature.getId();\n if (id !== undefined) {\n return id in this.idIndex_;\n }\n return getUid(feature) in this.uidIndex_;\n }\n\n /**\n * @return {boolean} Is empty.\n */\n isEmpty() {\n if (this.featuresRtree_) {\n return (\n this.featuresRtree_.isEmpty() && isEmpty(this.nullGeometryFeatures_)\n );\n }\n if (this.featuresCollection_) {\n return this.featuresCollection_.getLength() === 0;\n }\n return true;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {number} resolution Resolution.\n * @param {import(\"../proj/Projection.js\").default} projection Projection.\n */\n loadFeatures(extent, resolution, projection) {\n const loadedExtentsRtree = this.loadedExtentsRtree_;\n const extentsToLoad = this.strategy_(extent, resolution, projection);\n for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {\n const extentToLoad = extentsToLoad[i];\n const alreadyLoaded = loadedExtentsRtree.forEachInExtent(\n extentToLoad,\n /**\n * @param {{extent: import(\"../extent.js\").Extent}} object Object.\n * @return {boolean} Contains.\n */\n function (object) {\n return containsExtent(object.extent, extentToLoad);\n },\n );\n if (!alreadyLoaded) {\n this.loading = Number(this.loading) + 1;\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.FEATURESLOADSTART),\n );\n\n /**\n * @param {Array} features Loaded features\n */\n const success = (features) => {\n this.loading = Number(this.loading) - 1;\n this.dispatchEvent(\n new VectorSourceEvent(\n VectorEventType.FEATURESLOADEND,\n undefined,\n features,\n ),\n );\n };\n\n const failure = () => {\n this.changed();\n this.loading = Number(this.loading) - 1;\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.FEATURESLOADERROR),\n );\n };\n\n //TODO Remove this when the deprecatedsuccess and failure arguments are removed\n let disableCallbacks = false;\n\n const loaded = this.loader_.call(\n this,\n extentToLoad,\n resolution,\n projection,\n (features) => disableCallbacks || success(features),\n () => disableCallbacks || failure(),\n );\n if (loaded instanceof Promise) {\n //TODO Remove this when the deprecatedsuccess and failure arguments are removed\n disableCallbacks = true;\n loaded\n .then((features) => {\n this.addFeatures(features);\n success(features);\n })\n .catch(failure);\n } else if (this.loader_.length < 4) {\n this.loading = false;\n }\n loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});\n }\n }\n }\n\n /**\n * @override\n */\n refresh() {\n this.clear(true);\n this.loadedExtentsRtree_.clear();\n super.refresh();\n }\n\n /**\n * Remove an extent from the list of loaded extents.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n removeLoadedExtent(extent) {\n const loadedExtentsRtree = this.loadedExtentsRtree_;\n const obj = loadedExtentsRtree.forEachInExtent(extent, function (object) {\n if (equals(object.extent, extent)) {\n return object;\n }\n });\n if (obj) {\n loadedExtentsRtree.remove(obj);\n }\n }\n\n /**\n * Batch remove features from the source. If you want to remove all features\n * at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method\n * instead.\n * @param {Array} features Features to remove.\n * @api\n */\n removeFeatures(features) {\n let removed = false;\n for (let i = 0, ii = features.length; i < ii; ++i) {\n removed = this.removeFeatureInternal(features[i]) || removed;\n }\n if (removed) {\n this.changed();\n }\n }\n\n /**\n * Remove a single feature from the source. If you want to batch remove\n * features, use the {@link module:ol/source/Vector~VectorSource#removeFeatures #removeFeatures()} method\n * instead.\n * @param {FeatureType} feature Feature to remove.\n * @api\n */\n removeFeature(feature) {\n if (!feature) {\n return;\n }\n const removed = this.removeFeatureInternal(feature);\n if (removed) {\n this.changed();\n }\n }\n\n /**\n * Remove feature without firing a `change` event.\n * @param {FeatureType} feature Feature.\n * @return {boolean} True if the feature was removed, false if it was not found.\n * @protected\n */\n removeFeatureInternal(feature) {\n const featureKey = getUid(feature);\n if (!(featureKey in this.uidIndex_)) {\n return false;\n }\n\n if (featureKey in this.nullGeometryFeatures_) {\n delete this.nullGeometryFeatures_[featureKey];\n } else {\n if (this.featuresRtree_) {\n this.featuresRtree_.remove(feature);\n }\n }\n\n const featureChangeKeys = this.featureChangeKeys_[featureKey];\n featureChangeKeys?.forEach(unlistenByKey);\n delete this.featureChangeKeys_[featureKey];\n\n const id = feature.getId();\n if (id !== undefined) {\n const idString = id.toString();\n const indexedFeature = this.idIndex_[idString];\n if (indexedFeature === feature) {\n delete this.idIndex_[idString];\n } else if (Array.isArray(indexedFeature)) {\n indexedFeature.splice(indexedFeature.indexOf(feature), 1);\n if (indexedFeature.length === 1) {\n this.idIndex_[idString] = indexedFeature[0];\n }\n }\n }\n delete this.uidIndex_[featureKey];\n if (this.hasListener(VectorEventType.REMOVEFEATURE)) {\n this.dispatchEvent(\n new VectorSourceEvent(VectorEventType.REMOVEFEATURE, feature),\n );\n }\n return true;\n }\n\n /**\n * Remove a feature from the id index. Called internally when the feature id\n * may have changed.\n * @param {FeatureType} feature The feature.\n * @private\n */\n removeFromIdIndex_(feature) {\n for (const id in this.idIndex_) {\n if (this.idIndex_[id] === feature) {\n delete this.idIndex_[id];\n break;\n }\n }\n }\n\n /**\n * Set the new loader of the source. The next render cycle will use the\n * new loader.\n * @param {import(\"../featureloader.js\").FeatureLoader} loader The loader to set.\n * @api\n */\n setLoader(loader) {\n this.loader_ = loader;\n }\n\n /**\n * Points the source to a new url. The next render cycle will use the new url.\n * @param {string|import(\"../featureloader.js\").FeatureUrlFunction} url Url.\n * @api\n */\n setUrl(url) {\n assert(this.format_, '`format` must be set when `url` is set');\n this.url_ = url;\n this.setLoader(xhr(url, this.format_));\n }\n\n /**\n * @param {boolean} overlaps The source can have overlapping geometries.\n */\n setOverlaps(overlaps) {\n this.overlaps_ = overlaps;\n this.changed();\n }\n}\n\nexport default VectorSource;\n","/**\n * @module ol/style/Fill\n */\n\nimport ImageState from '../ImageState.js';\nimport {asArray} from '../color.js';\nimport {getUid} from '../util.js';\nimport {get as getIconImage} from './IconImage.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} [color=null] A color,\n * gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats. For polygon fills (not for {@link import(\"./RegularShape.js\").default} fills),\n * a pattern can also be provided as {@link module:ol/colorlike~PatternDescriptor}.\n * Default null; if null, the Canvas/renderer default black will be used.\n */\n\n/**\n * @classdesc\n * Set fill style for vector features.\n * @api\n */\nclass Fill {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"./IconImage.js\").default|null}\n */\n this.patternImage_ = null;\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null}\n */\n this.color_ = null;\n if (options.color !== undefined) {\n this.setColor(options.color);\n }\n }\n\n /**\n * Clones the style. The color is not cloned if it is a {@link module:ol/colorlike~ColorLike}.\n * @return {Fill} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Fill({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n });\n }\n\n /**\n * Get the fill color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} color Color.\n * @api\n */\n setColor(color) {\n if (color !== null && typeof color === 'object' && 'src' in color) {\n const patternImage = getIconImage(\n null,\n color.src,\n {crossOrigin: 'anonymous'},\n undefined,\n color.offset ? null : color.color ? color.color : null,\n !(color.offset && color.size),\n );\n patternImage.ready().then(() => {\n this.patternImage_ = null;\n });\n if (patternImage.getImageState() === ImageState.IDLE) {\n patternImage.load();\n }\n if (patternImage.getImageState() === ImageState.LOADING) {\n this.patternImage_ = patternImage;\n }\n }\n this.color_ = color;\n }\n\n /**\n * @return {string} Key of the fill for cache lookup.\n */\n getKey() {\n const fill = this.getColor();\n if (!fill) {\n return '';\n }\n return fill instanceof CanvasPattern || fill instanceof CanvasGradient\n ? getUid(fill)\n : typeof fill === 'object' && 'src' in fill\n ? fill.src + ':' + fill.offset\n : asArray(fill).toString();\n }\n\n /**\n * @return {boolean} The fill style is loading an image pattern.\n */\n loading() {\n return !!this.patternImage_;\n }\n\n /**\n * @return {Promise} `false` or a promise that resolves when the style is ready to use.\n */\n ready() {\n return this.patternImage_ ? this.patternImage_.ready() : Promise.resolve();\n }\n}\n\nexport default Fill;\n","/**\n * @module ol/style/Stroke\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} [color] A color, gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.\n * Default null; if null, the Canvas/renderer default black will be used.\n * @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.\n * @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.\n * @property {Array} [lineDash] Line dash pattern. Default is `null` (no dash).\n * @property {number} [lineDashOffset=0] Line dash offset.\n * @property {number} [miterLimit=10] Miter limit.\n * @property {number} [offset] Line offset in pixels along the normal. A positive value offsets the line to the right,\n * relative to the direction of the line. Default is `undefined` (no offset).\n * @property {number} [width] Width.\n */\n\n/**\n * @classdesc\n * Set stroke style for vector features.\n * Note that the defaults given are the Canvas defaults, which will be used if\n * option is not defined. The `get` functions return whatever was entered in\n * the options; they will not return the default.\n * @api\n */\nclass Stroke {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike}\n */\n this.color_ = options.color !== undefined ? options.color : null;\n\n /**\n * @private\n * @type {CanvasLineCap|undefined}\n */\n this.lineCap_ = options.lineCap;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.lineDashOffset_ = options.lineDashOffset;\n\n /**\n * @private\n * @type {CanvasLineJoin|undefined}\n */\n this.lineJoin_ = options.lineJoin;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.miterLimit_ = options.miterLimit;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.offset_ = options.offset;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.width_ = options.width;\n }\n\n /**\n * Clones the style.\n * @return {Stroke} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Stroke({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n lineCap: this.getLineCap(),\n lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined,\n lineDashOffset: this.getLineDashOffset(),\n lineJoin: this.getLineJoin(),\n miterLimit: this.getMiterLimit(),\n offset: this.getOffset(),\n width: this.getWidth(),\n });\n }\n\n /**\n * Get the stroke color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Get the line cap type for the stroke.\n * @return {CanvasLineCap|undefined} Line cap.\n * @api\n */\n getLineCap() {\n return this.lineCap_;\n }\n\n /**\n * Get the line dash style for the stroke.\n * @return {Array|null} Line dash.\n * @api\n */\n getLineDash() {\n return this.lineDash_;\n }\n\n /**\n * Get the line dash offset for the stroke.\n * @return {number|undefined} Line dash offset.\n * @api\n */\n getLineDashOffset() {\n return this.lineDashOffset_;\n }\n\n /**\n * Get the line join type for the stroke.\n * @return {CanvasLineJoin|undefined} Line join.\n * @api\n */\n getLineJoin() {\n return this.lineJoin_;\n }\n\n /**\n * Get the miter limit for the stroke.\n * @return {number|undefined} Miter limit.\n * @api\n */\n getMiterLimit() {\n return this.miterLimit_;\n }\n\n /**\n * Get the line offset in pixels.\n * @return {number|undefined} Offset.\n * @api\n */\n getOffset() {\n return this.offset_;\n }\n\n /**\n * Get the stroke width.\n * @return {number|undefined} Width.\n * @api\n */\n getWidth() {\n return this.width_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} color Color.\n * @api\n */\n setColor(color) {\n this.color_ = color;\n }\n\n /**\n * Set the line cap.\n *\n * @param {CanvasLineCap|undefined} lineCap Line cap.\n * @api\n */\n setLineCap(lineCap) {\n this.lineCap_ = lineCap;\n }\n\n /**\n * Set the line dash.\n *\n * @param {Array|null} lineDash Line dash.\n * @api\n */\n setLineDash(lineDash) {\n this.lineDash_ = lineDash;\n }\n\n /**\n * Set the line dash offset.\n *\n * @param {number|undefined} lineDashOffset Line dash offset.\n * @api\n */\n setLineDashOffset(lineDashOffset) {\n this.lineDashOffset_ = lineDashOffset;\n }\n\n /**\n * Set the line join.\n *\n * @param {CanvasLineJoin|undefined} lineJoin Line join.\n * @api\n */\n setLineJoin(lineJoin) {\n this.lineJoin_ = lineJoin;\n }\n\n /**\n * Set the miter limit.\n *\n * @param {number|undefined} miterLimit Miter limit.\n * @api\n */\n setMiterLimit(miterLimit) {\n this.miterLimit_ = miterLimit;\n }\n\n /**\n * Set the line offset in pixels.\n *\n * @param {number|undefined} offset Offset.\n * @api\n */\n setOffset(offset) {\n this.offset_ = offset;\n }\n\n /**\n * Set the width.\n *\n * @param {number|undefined} width Width.\n * @api\n */\n setWidth(width) {\n this.width_ = width;\n }\n}\n\nexport default Stroke;\n","/**\n * @module ol/size\n */\n\n/**\n * An array of numbers representing a size: `[width, height]`.\n * @typedef {Array} Size\n * @api\n */\n\n/**\n * Returns a buffered size.\n * @param {Size} size Size.\n * @param {number} num The amount by which to buffer.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The buffered size.\n */\nexport function buffer(size, num, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = size[0] + 2 * num;\n dest[1] = size[1] + 2 * num;\n return dest;\n}\n\n/**\n * Determines if a size has a positive area.\n * @param {Size} size The size to test.\n * @return {boolean} The size has a positive area.\n */\nexport function hasArea(size) {\n return size[0] > 0 && size[1] > 0;\n}\n\n/**\n * Returns a size scaled by a ratio. The result will be an array of integers.\n * @param {Size} size Size.\n * @param {number} ratio Ratio.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The scaled size.\n */\nexport function scale(size, ratio, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = (size[0] * ratio + 0.5) | 0;\n dest[1] = (size[1] * ratio + 0.5) | 0;\n return dest;\n}\n\n/**\n * Returns an `Size` array for the passed in number (meaning: square) or\n * `Size` array.\n * (meaning: non-square),\n * @param {number|Size} size Width and height.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} Size.\n * @api\n */\nexport function toSize(size, dest) {\n if (Array.isArray(size)) {\n return size;\n }\n if (dest === undefined) {\n dest = [size, size];\n } else {\n dest[0] = size;\n dest[1] = size;\n }\n return dest;\n}\n","/**\n * @module ol/style/Image\n */\nimport {toSize} from '../size.js';\nimport {abstract} from '../util.js';\n\n/**\n * @typedef {Object} Options\n * @property {number} opacity Opacity.\n * @property {boolean} rotateWithView If the image should get rotated with the view.\n * @property {number} rotation Rotation.\n * @property {number|import(\"../size.js\").Size} scale Scale.\n * @property {Array} displacement Displacement.\n * @property {import('../style/Style.js').DeclutterMode} declutterMode Declutter mode: `declutter`, `obstacle`, `none`.\n */\n\n/**\n * @classdesc\n * A base class used for creating subclasses and not instantiated in\n * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and\n * {@link module:ol/style/RegularShape~RegularShape}.\n * @abstract\n * @api\n */\nclass ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n /**\n * @private\n * @type {number}\n */\n this.opacity_ = options.opacity;\n\n /**\n * @private\n * @type {boolean}\n */\n this.rotateWithView_ = options.rotateWithView;\n\n /**\n * @private\n * @type {number}\n */\n this.rotation_ = options.rotation;\n\n /**\n * @private\n * @type {number|import(\"../size.js\").Size}\n */\n this.scale_ = options.scale;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.scaleArray_ = toSize(options.scale);\n\n /**\n * @private\n * @type {Array}\n */\n this.displacement_ = options.displacement;\n\n /**\n * @private\n * @type {import('../style/Style.js').DeclutterMode}\n */\n this.declutterMode_ = options.declutterMode;\n }\n\n /**\n * Clones the style.\n * @return {ImageStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n return new ImageStyle({\n opacity: this.getOpacity(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n }\n\n /**\n * Get the symbolizer opacity.\n * @return {number} Opacity.\n * @api\n */\n getOpacity() {\n return this.opacity_;\n }\n\n /**\n * Determine whether the symbolizer rotates with the map.\n * @return {boolean} Rotate with map.\n * @api\n */\n getRotateWithView() {\n return this.rotateWithView_;\n }\n\n /**\n * Get the symoblizer rotation.\n * @return {number} Rotation.\n * @api\n */\n getRotation() {\n return this.rotation_;\n }\n\n /**\n * Get the symbolizer scale.\n * @return {number|import(\"../size.js\").Size} Scale.\n * @api\n */\n getScale() {\n return this.scale_;\n }\n\n /**\n * Get the symbolizer scale array.\n * @return {import(\"../size.js\").Size} Scale array.\n */\n getScaleArray() {\n return this.scaleArray_;\n }\n\n /**\n * Get the displacement of the shape\n * @return {Array} Shape's center displacement\n * @api\n */\n getDisplacement() {\n return this.displacement_;\n }\n\n /**\n * Get the declutter mode of the shape\n * @return {import(\"./Style.js\").DeclutterMode} Shape's declutter mode\n * @api\n */\n getDeclutterMode() {\n return this.declutterMode_;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @abstract\n * @return {Array} Anchor.\n */\n getAnchor() {\n return abstract();\n }\n\n /**\n * Get the image element for the symbolizer.\n * @abstract\n * @param {number} pixelRatio Pixel ratio.\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getImage(pixelRatio) {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getHitDetectionImage() {\n return abstract();\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return 1;\n }\n\n /**\n * @abstract\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return abstract();\n }\n\n /**\n * Get the origin of the symbolizer.\n * @abstract\n * @return {Array} Origin.\n */\n getOrigin() {\n return abstract();\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @abstract\n * @return {import(\"../size.js\").Size} Size.\n */\n getSize() {\n return abstract();\n }\n\n /**\n * Set the displacement.\n *\n * @param {Array} displacement Displacement.\n * @api\n */\n setDisplacement(displacement) {\n this.displacement_ = displacement;\n }\n\n /**\n * Set the opacity.\n *\n * @param {number} opacity Opacity.\n * @api\n */\n setOpacity(opacity) {\n this.opacity_ = opacity;\n }\n\n /**\n * Set whether to rotate the style with the view.\n *\n * @param {boolean} rotateWithView Rotate with map.\n * @api\n */\n setRotateWithView(rotateWithView) {\n this.rotateWithView_ = rotateWithView;\n }\n\n /**\n * Set the rotation.\n *\n * @param {number} rotation Rotation.\n * @api\n */\n setRotation(rotation) {\n this.rotation_ = rotation;\n }\n\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size} scale Scale.\n * @api\n */\n setScale(scale) {\n this.scale_ = scale;\n this.scaleArray_ = toSize(scale);\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {\n abstract();\n }\n\n /**\n * Load not yet loaded URI.\n * @abstract\n */\n load() {\n abstract();\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {\n abstract();\n }\n\n /**\n * @return {Promise} `false` or Promise that resolves when the style is ready to use.\n */\n ready() {\n return Promise.resolve();\n }\n}\n\nexport default ImageStyle;\n","/**\n * @module ol/style/RegularShape\n */\n\nimport ImageState from '../ImageState.js';\nimport {asArray} from '../color.js';\nimport {asColorLike} from '../colorlike.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {\n defaultFillStyle,\n defaultLineCap,\n defaultLineJoin,\n defaultLineWidth,\n defaultMiterLimit,\n defaultStrokeStyle,\n} from '../render/canvas.js';\nimport IconImage from './IconImage.js';\nimport {shared as iconImageCache} from './IconImageCache.js';\nimport ImageStyle from './Image.js';\n\n/**\n * Specify radius for regular polygons, or both radius and radius2 for stars.\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points\n * is the number of sides.\n * @property {number} radius Radius of a regular polygon.\n * @property {number} [radius2] Second radius to make a star instead of a regular polygon.\n * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's points facing up.\n * @property {Array} [displacement=[0, 0]] Displacement of the shape in pixels.\n * Positive values will shift the shape right and up.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. Unless two dimensional scaling is required a better\n * result may be obtained with appropriate settings for `radius` and `radius2`.\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode.\n */\n\n/**\n * @typedef {Object} RenderOptions\n * @property {import(\"../colorlike.js\").ColorLike|undefined} strokeStyle StrokeStyle.\n * @property {number} strokeWidth StrokeWidth.\n * @property {number} size Size.\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array|null} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} miterLimit MiterLimit.\n */\n\n/**\n * @classdesc\n * Set regular shape style for vector features. The resulting shape will be\n * a regular polygon when `radius` is provided, or a star when both `radius` and\n * `radius2` are provided.\n * @api\n */\nclass RegularShape extends ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n super({\n opacity: 1,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n scale: options.scale !== undefined ? options.scale : 1,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n\n /**\n * @private\n * @type {HTMLCanvasElement|OffscreenCanvas|null}\n */\n this.hitDetectionCanvas_ = null;\n\n /**\n * @private\n * @type {import(\"./Fill.js\").default|null}\n */\n this.fill_ = options.fill !== undefined ? options.fill : null;\n\n /**\n * @private\n * @type {Array}\n */\n this.origin_ = [0, 0];\n\n /**\n * @private\n * @type {number}\n */\n this.points_ = options.points;\n\n /**\n * @protected\n * @type {number}\n */\n this.radius = options.radius;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.radius2_ = options.radius2;\n\n /**\n * @private\n * @type {number}\n */\n this.angle_ = options.angle !== undefined ? options.angle : 0;\n\n /**\n * @private\n * @type {import(\"./Stroke.js\").default|null}\n */\n this.stroke_ = options.stroke !== undefined ? options.stroke : null;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.size_;\n\n /**\n * @private\n * @type {RenderOptions}\n */\n this.renderOptions_;\n\n /**\n * @private\n */\n this.imageState_ =\n this.fill_ && this.fill_.loading()\n ? ImageState.LOADING\n : ImageState.LOADED;\n if (this.imageState_ === ImageState.LOADING) {\n this.ready().then(() => (this.imageState_ = ImageState.LOADED));\n }\n this.render();\n }\n\n /**\n * Clones the style.\n * @return {RegularShape} The cloned style.\n * @api\n * @override\n */\n clone() {\n const scale = this.getScale();\n const style = new RegularShape({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n points: this.getPoints(),\n radius: this.getRadius(),\n radius2: this.getRadius2(),\n angle: this.getAngle(),\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @return {Array} Anchor.\n * @api\n * @override\n */\n getAnchor() {\n const size = this.size_;\n const displacement = this.getDisplacement();\n const scale = this.getScaleArray();\n // anchor is scaled by renderer but displacement should not be scaled\n // so divide by scale here\n return [\n size[0] / 2 - displacement[0] / scale[0],\n size[1] / 2 + displacement[1] / scale[1],\n ];\n }\n\n /**\n * Get the angle used in generating the shape.\n * @return {number} Shape's rotation in radians.\n * @api\n */\n getAngle() {\n return this.angle_;\n }\n\n /**\n * Get the fill style for the shape.\n * @return {import(\"./Fill.js\").default|null} Fill style.\n * @api\n */\n getFill() {\n return this.fill_;\n }\n\n /**\n * Set the fill style.\n * @param {import(\"./Fill.js\").default|null} fill Fill style.\n * @api\n */\n setFill(fill) {\n this.fill_ = fill;\n this.render();\n }\n\n /**\n * @return {HTMLCanvasElement|OffscreenCanvas} Image element.\n * @override\n */\n getHitDetectionImage() {\n if (!this.hitDetectionCanvas_) {\n this.hitDetectionCanvas_ = this.createHitDetectionCanvas_(\n this.renderOptions_,\n );\n }\n return this.hitDetectionCanvas_;\n }\n\n /**\n * Get the image icon.\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLCanvasElement|OffscreenCanvas} Image or Canvas element.\n * @api\n * @override\n */\n getImage(pixelRatio) {\n const fillKey = this.fill_?.getKey();\n const cacheKey =\n `${pixelRatio},${this.angle_},${this.radius},${this.radius2_},${this.points_},${fillKey}` +\n Object.values(this.renderOptions_).join(',');\n let image = /** @type {HTMLCanvasElement|OffscreenCanvas} */ (\n iconImageCache.get(cacheKey, null)?.getImage(1)\n );\n if (!image) {\n const renderOptions = this.renderOptions_;\n const size = Math.ceil(renderOptions.size * pixelRatio);\n const context = createCanvasContext2D(size, size);\n this.draw_(renderOptions, context, pixelRatio);\n\n image = context.canvas;\n const iconImage = new IconImage(\n image,\n undefined,\n null,\n ImageState.LOADED,\n null,\n );\n iconImageCache.set(cacheKey, null, iconImage);\n // Update the image in place to an ImageBitmap for better performance and lower memory usage\n createImageBitmap(image).then((imageBitmap) => {\n iconImage.setImage(imageBitmap);\n });\n }\n return image;\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n * @override\n */\n getPixelRatio(pixelRatio) {\n return pixelRatio;\n }\n\n /**\n * @return {import(\"../size.js\").Size} Image size.\n * @override\n */\n getImageSize() {\n return this.size_;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n * @override\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * Get the origin of the symbolizer.\n * @return {Array} Origin.\n * @api\n * @override\n */\n getOrigin() {\n return this.origin_;\n }\n\n /**\n * Get the number of points for generating the shape.\n * @return {number} Number of points for stars and regular polygons.\n * @api\n */\n getPoints() {\n return this.points_;\n }\n\n /**\n * Get the (primary) radius for the shape.\n * @return {number} Radius.\n * @api\n */\n getRadius() {\n return this.radius;\n }\n\n /**\n * Set the (primary) radius for the shape.\n * @param {number} radius Radius.\n * @api\n */\n setRadius(radius) {\n if (this.radius === radius) {\n return;\n }\n this.radius = radius;\n this.render();\n }\n\n /**\n * Get the secondary radius for the shape.\n * @return {number|undefined} Radius2.\n * @api\n */\n getRadius2() {\n return this.radius2_;\n }\n\n /**\n * Set the secondary radius for the shape.\n * @param {number|undefined} radius2 Radius2.\n * @api\n */\n setRadius2(radius2) {\n if (this.radius2_ === radius2) {\n return;\n }\n this.radius2_ = radius2;\n this.render();\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @return {import(\"../size.js\").Size} Size.\n * @api\n * @override\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * Get the stroke style for the shape.\n * @return {import(\"./Stroke.js\").default|null} Stroke style.\n * @api\n */\n getStroke() {\n return this.stroke_;\n }\n\n /**\n * Set the stroke style.\n * @param {import(\"./Stroke.js\").default|null} stroke Stroke style.\n * @api\n */\n setStroke(stroke) {\n this.stroke_ = stroke;\n this.render();\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n * @override\n */\n listenImageChange(listener) {}\n\n /**\n * Load not yet loaded URI.\n * @override\n */\n load() {}\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n * @override\n */\n unlistenImageChange(listener) {}\n\n /**\n * Calculate additional canvas size needed for the miter.\n * @param {string} lineJoin Line join\n * @param {number} strokeWidth Stroke width\n * @param {number} miterLimit Miter limit\n * @return {number} Additional canvas size needed\n * @private\n */\n calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit) {\n if (\n strokeWidth === 0 ||\n this.points_ === Infinity ||\n (lineJoin !== 'bevel' && lineJoin !== 'miter')\n ) {\n return strokeWidth;\n }\n // m | ^\n // i | |\\ .\n // t >| #\\\n // e | |\\ \\ .\n // r \\s\\\n // | \\t\\ . .\n // \\r\\ . .\n // | \\o\\ . . . . .\n // e \\k\\ . . . .\n // | \\e\\ . . . . .\n // d \\ \\ . . . .\n // | _ _a_ _\\# . . .\n // r1 / ` . .\n // | . .\n // b / . .\n // | . .\n // / r2 . .\n // | . .\n // / . .\n // |α . .\n // / . .\n // ° center\n let r1 = this.radius;\n let r2 = this.radius2_ === undefined ? r1 : this.radius2_;\n if (r1 < r2) {\n const tmp = r1;\n r1 = r2;\n r2 = tmp;\n }\n const points =\n this.radius2_ === undefined ? this.points_ : this.points_ * 2;\n const alpha = (2 * Math.PI) / points;\n const a = r2 * Math.sin(alpha);\n const b = Math.sqrt(r2 * r2 - a * a);\n const d = r1 - b;\n const e = Math.sqrt(a * a + d * d);\n const miterRatio = e / a;\n if (lineJoin === 'miter' && miterRatio <= miterLimit) {\n return miterRatio * strokeWidth;\n }\n // Calculate the distance from center to the stroke corner where\n // it was cut short because of the miter limit.\n // l\n // ----+---- <= distance from center to here is maxr\n // /####|k ##\\\n // /#####^#####\\\n // /#### /+\\# s #\\\n // /### h/+++\\# t #\\\n // /### t/+++++\\# r #\\\n // /### a/+++++++\\# o #\\\n // /### p/++ fill +\\# k #\\\n ///#### /+++++^+++++\\# e #\\\n //#####/+++++/+\\+++++\\#####\\\n const k = strokeWidth / 2 / miterRatio;\n const l = (strokeWidth / 2) * (d / e);\n const maxr = Math.sqrt((r1 + k) * (r1 + k) + l * l);\n const bevelAdd = maxr - r1;\n if (this.radius2_ === undefined || lineJoin === 'bevel') {\n return bevelAdd * 2;\n }\n // If outer miter is over the miter limit the inner miter may reach through the\n // center and be longer than the bevel, same calculation as above but swap r1 / r2.\n const aa = r1 * Math.sin(alpha);\n const bb = Math.sqrt(r1 * r1 - aa * aa);\n const dd = r2 - bb;\n const ee = Math.sqrt(aa * aa + dd * dd);\n const innerMiterRatio = ee / aa;\n if (innerMiterRatio <= miterLimit) {\n const innerLength = (innerMiterRatio * strokeWidth) / 2 - r2 - r1;\n return 2 * Math.max(bevelAdd, innerLength);\n }\n return bevelAdd * 2;\n }\n\n /**\n * @return {RenderOptions} The render options\n * @protected\n */\n createRenderOptions() {\n let lineCap = defaultLineCap;\n let lineJoin = defaultLineJoin;\n let miterLimit = 0;\n let lineDash = null;\n let lineDashOffset = 0;\n let strokeStyle;\n let strokeWidth = 0;\n\n if (this.stroke_) {\n strokeStyle = asColorLike(this.stroke_.getColor() ?? defaultStrokeStyle);\n strokeWidth = this.stroke_.getWidth() ?? defaultLineWidth;\n lineDash = this.stroke_.getLineDash();\n lineDashOffset = this.stroke_.getLineDashOffset() ?? 0;\n lineJoin = this.stroke_.getLineJoin() ?? defaultLineJoin;\n lineCap = this.stroke_.getLineCap() ?? defaultLineCap;\n miterLimit = this.stroke_.getMiterLimit() ?? defaultMiterLimit;\n }\n\n const add = this.calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit);\n const maxRadius = Math.max(this.radius, this.radius2_ || 0);\n const size = Math.ceil(2 * maxRadius + add);\n\n return {\n strokeStyle: strokeStyle,\n strokeWidth: strokeWidth,\n size: size,\n lineCap: lineCap,\n lineDash: lineDash,\n lineDashOffset: lineDashOffset,\n lineJoin: lineJoin,\n miterLimit: miterLimit,\n };\n }\n\n /**\n * @protected\n */\n render() {\n this.renderOptions_ = this.createRenderOptions();\n const size = this.renderOptions_.size;\n this.hitDetectionCanvas_ = null;\n this.size_ = [size, size];\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context The rendering context.\n * @param {number} pixelRatio The pixel ratio.\n */\n draw_(renderOptions, context, pixelRatio) {\n context.scale(pixelRatio, pixelRatio);\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n if (this.fill_) {\n let color = this.fill_.getColor();\n if (color === null) {\n color = defaultFillStyle;\n }\n context.fillStyle = asColorLike(color);\n context.fill();\n }\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineCap = renderOptions.lineCap;\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @return {HTMLCanvasElement|OffscreenCanvas} Canvas containing the icon\n */\n createHitDetectionCanvas_(renderOptions) {\n let context;\n if (this.fill_) {\n let color = this.fill_.getColor();\n\n // determine if fill is transparent (or pattern or gradient)\n let opacity = 0;\n if (typeof color === 'string') {\n color = asArray(color);\n }\n if (color === null) {\n opacity = 1;\n } else if (Array.isArray(color)) {\n opacity = color.length === 4 ? color[3] : 1;\n }\n if (opacity === 0) {\n // if a transparent fill style is set, create an extra hit-detection image\n // with a default fill style\n context = createCanvasContext2D(renderOptions.size, renderOptions.size);\n this.drawHitDetectionCanvas_(renderOptions, context);\n }\n }\n return context ? context.canvas : this.getImage(1);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context The context to draw in.\n */\n createPath_(context) {\n let points = this.points_;\n const radius = this.radius;\n if (points === Infinity) {\n context.arc(0, 0, radius, 0, 2 * Math.PI);\n } else {\n const radius2 = this.radius2_ === undefined ? radius : this.radius2_;\n if (this.radius2_ !== undefined) {\n points *= 2;\n }\n const startAngle = this.angle_ - Math.PI / 2;\n const step = (2 * Math.PI) / points;\n for (let i = 0; i < points; i++) {\n const angle0 = startAngle + i * step;\n const radiusC = i % 2 === 0 ? radius : radius2;\n context.lineTo(radiusC * Math.cos(angle0), radiusC * Math.sin(angle0));\n }\n context.closePath();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context The context.\n */\n drawHitDetectionCanvas_(renderOptions, context) {\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n context.fillStyle = defaultFillStyle;\n context.fill();\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n /**\n * @override\n */\n ready() {\n return this.fill_ ? this.fill_.ready() : Promise.resolve();\n }\n}\n\nexport default RegularShape;\n","/**\n * @module ol/style/Circle\n */\n\nimport RegularShape from './RegularShape.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} radius Circle radius.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {Array} [displacement=[0,0]] displacement\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. A two dimensional scale will produce an ellipse.\n * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `radius`.\n * @property {number} [rotation=0] Rotation in radians\n * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view\n * (meaningful only when used in conjunction with a two dimensional scale).\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode\n */\n\n/**\n * @classdesc\n * Set circle style for vector features.\n * @api\n */\nclass CircleStyle extends RegularShape {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {radius: 5};\n\n super({\n points: Infinity,\n fill: options.fill,\n radius: options.radius,\n stroke: options.stroke,\n scale: options.scale !== undefined ? options.scale : 1,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n }\n\n /**\n * Clones the style.\n * @return {CircleStyle} The cloned style.\n * @api\n * @override\n */\n clone() {\n const scale = this.getScale();\n const style = new CircleStyle({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n radius: this.getRadius(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n}\n\nexport default CircleStyle;\n","/**\n * @module ol/style/Style\n */\n\nimport {assert} from '../asserts.js';\nimport CircleStyle from './Circle.js';\nimport Fill from './Fill.js';\nimport Stroke from './Stroke.js';\n\n/**\n * Defines how symbols and text are decluttered on layers ith `declutter` set to `true`\n * **declutter**: Overlapping symbols and text are decluttered.\n * **obstacle**: Symbols and text are rendered, but serve as obstacle for subsequent attempts\n * to place a symbol or text at the same location.\n * **none**: No decluttering is done.\n *\n * @typedef {\"declutter\"|\"obstacle\"|\"none\"} DeclutterMode\n */\n\n/**\n * A function that takes a {@link module:ol/Feature~Feature} and a `{number}`\n * representing the view's resolution. The function should return a\n * {@link module:ol/style/Style~Style} or an array of them. This way e.g. a\n * vector layer can be styled. If the function returns `undefined`, the\n * feature will not be rendered.\n *\n * @typedef {function(import(\"../Feature.js\").FeatureLike, number):(Style|Array