diff --git a/.dprint.json b/.dprint.json new file mode 100644 index 0000000..3e80381 --- /dev/null +++ b/.dprint.json @@ -0,0 +1,34 @@ +{ + "typescript": { + }, + "json": { + }, + "markdown": { + "ignoreDirective": "prettier-ignore", + "ignoreFileDirective": "prettier-ignore-file", + "ignoreStartDirective": "prettier-ignore-start", + "ignoreEndDirective": "prettier-ignore-end" + }, + "toml": { + }, + "excludes": [ + "**/html*", + "**/.yarn", + "**/node_modules", + "tools/**/*min.js", + "tools/plugin/chart", + "tools/plugin/mermaid.js", + "**/*-lock.json" + ], + // TODO get reveal template html files supported by dprint + // https://github.com/g-plane/markup_fmt/issues/15 + // "markup": { + // }, + "plugins": [ + // "https://plugins.dprint.dev/g-plane/markup_fmt-v0.9.0.wasm", + "https://plugins.dprint.dev/typescript-0.87.1.wasm", + "https://plugins.dprint.dev/json-0.17.4.wasm", + "https://plugins.dprint.dev/markdown-0.16.1.wasm", + "https://plugins.dprint.dev/toml-0.5.4.wasm" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f62fa23 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length=120 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..8613a07 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,35 @@ +name: Checks +on: + workflow_dispatch: # Allows you to run this workflow manually from the Actions tab + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ci-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + id: cache + uses: actions/cache@v3 + with: + path: ~/.cache/dprint # TODO add more paths here for various checkers + key: ${{ runner.os }}-${{ hashFiles('**/*dprint.json') }} + + - name: Format Check (dprint) + uses: dprint/check@v2.2 + with: + config-path: .dprint.json + + # FIXME .mlc.toml config not working... https://github.com/becheran/mlc/issues/78 + - name: Markup Link Checker (mlc) + uses: becheran/mlc@v0.16.2 + with: + args: "./content/ --ignore-links '*slides.md,*slides.html,*twitter.com*,*sec.gov*,*support.giphy.com*,*bitdefender.com*,*etherscan.io*,*cryptoslate.com*,*golden.com*,'" + + - name: Check for image issues (orphans and broken links) + run: ${PWD}/tools/scripts/orphan-image-scan.sh content/ diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..484b236 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,78 @@ +# From https://github.com/rust-lang/mdBook/wiki/Automated-Deployment%3A-GitHub-Actions#raw-example +name: Build `html-*` static files, publish `html-book` to Pages +on: + workflow_dispatch: # Allows you to run this workflow manually from the Actions tab + push: + branches: + - main + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: write # need write to push to branches + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + env: + MDBOOK_VERSION: v0.4.34 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install Bun (uses cache in action) + uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.0 + - name: Install js/ts dependencies with Bun + run: bun install + + - name: Install mdBook + run: | + url="https://github.com/rust-lang/mdbook/releases/download/${MDBOOK_VERSION}/mdbook-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" + mkdir mdbook + curl -sSL $url | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + - name: Build static slides to embed in gh-pages book + run: bun build-slides-gh-pages + - name: Build book + run: mdbook build + - name: Embed `html-slides` into `html-book`, fix relative paths + run: | + rsync -av html-slides/content/ html-book/ --ignore-existing + rsync -av html-slides/ --exclude 'content' html-book/ --ignore-existing + find html-book/ -regex .*\.html | xargs sed -i'' -e 's#./../../../#../../#g' > /dev/null + + # TODO: Without making a _branch_ that bloats the .git object, + # we should push out the static build files in html-book/ and html-slides/ to some archive, + # thus the bok and slides will be usable anywhere independently and + # a simple download to have a copy locally without building it yourself + + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + - name: Fix permissions # https://github.com/actions/upload-pages-artifact#file-permissions + run: | + chmod -c -R +rX "html-book" + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: ./html-book + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5cc887 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Build artifacts +/html* + +# Rust artifacts +**/target + +# Jupyter artifacts +**/.ipynb_checkpoints/** + +# Some common ones +tmp +tmp/** +*.log +log/** +.vscode +.idea/ +*.iml +*.iws +*.eml +out/ +.DS_Store +.svn +node_modules/ +.sass-cache +_static/ + +# Yarn, not using zero-installs +# ref: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions +# Yarn Integrity file +.yarn-integrity + +## Draw,io +*.bkp +*.dtmp diff --git a/.mlc.toml b/.mlc.toml new file mode 100644 index 0000000..5e928b1 --- /dev/null +++ b/.mlc.toml @@ -0,0 +1,20 @@ +# FIXME this config is not working... https://github.com/becheran/mlc/issues/78 +# Print debug information to console +debug = false +# Do not check web links +offline = false +# Check the exact file extension when searching for a file +match-file-extension = true +# List of files and directories which will be ignored +ignore-path = [""] +# List of links which will be ignored +ignore-links = [ + "*slides.md,*slides.html,*twitter.com*,*sec.gov*,*support.giphy.com*,*bitdefender.com*,*etherscan.io*,*cryptoslate.com*,*golden.com*,", +] +# List of markup types which shall be checked +markup-types = ["Markdown", "Html"] +# Wait time in milliseconds between http request to the same host +# Consider use only if getting `429 - Too Many Requests` +throttle = 0 +# Path to the root folder used to resolve all relative paths +root-dir = "./content/" diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1490f5c --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +# Ignore build/dev artifacts: +html* +node_modules +build +.cache +.yarn +.github +public +package-lock.json +yarn.lock + +# Ignore files that don't need *text* formatting +assets +plugin diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..9561c2d --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,15 @@ +module.exports = { + arrowParens: "avoid", + endOfLine: "lf", + semi: true, + singleQuote: true, + trailingComma: "es5", + overrides: [ + { + files: "*.md", + options: { + singleQuote: false, + }, + }, + ], +}; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..53000fb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +See the [Contributing Guide](./content/contribute/index.md). diff --git a/LICENSE.md b/LICENSE.md new file mode 120000 index 0000000..e838b05 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +./content/LICENSE.md \ No newline at end of file diff --git a/README.md b/README.md new file mode 120000 index 0000000..e7a71cf --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +./content/README.md \ No newline at end of file diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..20d9cae --- /dev/null +++ b/book.toml @@ -0,0 +1,32 @@ +[book] +title = "Nuke 🌄 's Book" +authors = ["Nuke-Web3"] +description = "The materials used in Nuke 🌄 's talks and workshops" +language = "en" +multilingual = false +src = "content" + +[build] +build-dir = "html-book" +create-missing = false # opt out of helper to create missing stub files, we want to fail if the SUMMARY is incorrect. + +[rust] +edition = "2021" + +[output.html] +site-url = "/book/" # needed for gh-pages, MUST match repo name on github! +git-repository-url = "https://github.com/nuke-web3/book" +edit-url-template = "https://github.com/nuke-web3/book/edit/main/{path}" +default-theme = "Ayu" +preferred-dark-theme = "Ayu" +fold.enable = true # Sidebar collapses automatically +print.enable = false # disclude support for printable output (slides are mangled) + +[output.html.search] +limit-results = 20 +use-boolean-and = true +boost-title = 2 +boost-hierarchy = 2 +boost-paragraph = 1 +expand = true +heading-split-level = 2 diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..34c39bc Binary files /dev/null and b/bun.lockb differ diff --git a/content/404.md b/content/404.md new file mode 100644 index 0000000..b56f359 --- /dev/null +++ b/content/404.md @@ -0,0 +1,14 @@ +# Document not found (404) + +🙃 This URL isn't working right now. +Try the search, maybe the content moved! + +Press `s` or click top-left (🔍 icon) of the outermost window. ↖️ + +--- + +🫠 ... Is this _supposed_ to be some embedded slides but is an embedded 404 in a valid page? + +- If you are _developing_ slides, you must rebuild & serve with `just s` command, embedded slides are NOT present in the mdBook watching serve 😭. +- If still broken, or you are looking at the hosted or slides - please `suggest an edit` so we can fix it together, pointing to the exact source of the problem. + Click the 📝 icon is top-right of the outermost window to open one up. ↗️ diff --git a/content/LICENSE.md b/content/LICENSE.md new file mode 100644 index 0000000..4da0667 --- /dev/null +++ b/content/LICENSE.md @@ -0,0 +1,187 @@ +# Mozilla Public License Version 2.0 + +## 1. Definitions + +### 1.1. “Contributor” + +means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. + +### 1.2. “Contributor Version” + +means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. + +### 1.3. “Contribution” + +means Covered Software of a particular Contributor. + +### 1.4. “Covered Software” + +means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. + +### 1.5. “Incompatible With Secondary Licenses” + +means + +1. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or +2. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. + +### 1.6. “Executable Form” + +means any form of the work other than Source Code Form. + +### 1.7. “Larger Work” + +means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. + +### 1.8. “License” + +means this document. + +### 1.9. “Licensable” + +means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. + +### 1.10. “Modifications” + +means any of the following: + +1. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or +2. any new file in Source Code Form that contains any Covered Software. + +### 1.11. “Patent Claims” of a Contributor + +means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. + +### 1.12. “Secondary License” + +means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. + +### 1.13. “Source Code Form” + +means the form of the work preferred for making modifications. + +### 1.14. “You” (or “Your”) + +means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. + +## 2. License Grants and Conditions + +### 2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: + +1. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and +2. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. + +### 2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. + +### 2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: + +1. for any code that a Contributor has removed from Covered Software; or +2. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or +3. under Patent Claims infringed by Covered Software in the absence of its Contributions. + +This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). + +### 2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). + +### 2.5. Representation + +Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. + +### 2.6. Fair Use + +This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. + +### 2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. + +## 3. Responsibilities + +### 3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. + +### 3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +1. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and +2. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. + +### 3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). + +### 3.4. Notices + +You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. + +### 3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. + +## 4. Inability to Comply Due to Statute or Regulation + +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. + +## 5. Termination + +5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. + +## 6. Disclaimer of Warranty + +> Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. + +## 7. Limitation of Liability + +> Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. + +## 8. Litigation + +Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. + +## 9. Miscellaneous + +This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. + +## 10. Versions of the License + +### 10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. + +### 10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. + +### 10.3. Modified Versions + +If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). + +### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + +If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. + +## Exhibit A - Source Code Form License Notice + +> This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at . + +If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +## Exhibit B - “Incompatible With Secondary Licenses” Notice + +> This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0. diff --git a/content/README.md b/content/README.md new file mode 100644 index 0000000..ba91823 --- /dev/null +++ b/content/README.md @@ -0,0 +1,31 @@ +# Nuke 🌄 Slides + +This book is the home of the majority of Nuke's slides used various places. + +Why an mdbook? Searchability mostly ✨- just hit `s` to find by keyword! + +## Read the Book + +We suggest the [online](#hosted-online) version for general use, but cloning, installing, and building this book [offline](#build-offline) is a great option on-the-go. + +### Hosted Online + +The latest version is hosted at: TODO + +### Build Offline + +In order to `make` your life easy 😉, there is a set of tasks that use [`just`](https://just.systems/man/en/chapter_1.html). + +With [`just`](https://github.com/casey/just?tab=readme-ov-file#installation) installed, you can list all tasks included to facilitate further installation, building, serving, formatting, and more with: + +```sh +# Run from the top-level working dir of this repo +just --list +``` + +The tasks should be self-explanatory, if they are not - please file an issue to help us make them better. + +## License + +All materials found within this repository are licensed under Mozilla Public License Version 2.0 - See the [License](./LICENSE.md) for details. +Please do give Nuke 🌄 credit if you end up using or referencing these materials 😀. diff --git a/content/SUMMARY.md b/content/SUMMARY.md new file mode 100644 index 0000000..2541870 --- /dev/null +++ b/content/SUMMARY.md @@ -0,0 +1,20 @@ +# Summary + +[🏠 Start Here](README.md) +[🪄 Using this Book](./contribute/how-to/page.md) +[📒 Book Overview](overview.md) + +--- + +- [RISC Zero](./risc-zero/index.md) + - [🗃️ Zypher Games Buildathon - June 2024](./risc-zero/zypher-buildathon/materials.md) + - [🪧 Verifiable Games Using RISC Zero](./risc-zero/zypher-buildathon/presentation.md) + - [👷 ZK Chess Checkmate](./risc-zero/zypher-buildathon/workshop.md) + +--- + +- [🙋 Guide](./contribute/index.md) + - [🌀 Topic Template](./contribute/template/page.md) + - [📋 Copy & Paste Slides](./contribute/copy-paste-slides/page.md) + +[🏷️ License](./LICENSE.md) diff --git a/content/contribute/README.md b/content/contribute/README.md new file mode 120000 index 0000000..dd0ea36 --- /dev/null +++ b/content/contribute/README.md @@ -0,0 +1 @@ +index.md \ No newline at end of file diff --git a/content/contribute/copy-paste-slides/img/makeitmove.gif b/content/contribute/copy-paste-slides/img/makeitmove.gif new file mode 100644 index 0000000..eee51fd Binary files /dev/null and b/content/contribute/copy-paste-slides/img/makeitmove.gif differ diff --git a/content/contribute/copy-paste-slides/page.md b/content/contribute/copy-paste-slides/page.md new file mode 100644 index 0000000..747a551 --- /dev/null +++ b/content/contribute/copy-paste-slides/page.md @@ -0,0 +1,16 @@ +# Copy and Paste Slide Templates + + +
+ +
+ How to use the slides - + Full screen (new tab) +
+ + + + +
Slides Content
+{{#include slides.md}} + diff --git a/content/contribute/copy-paste-slides/slides.md b/content/contribute/copy-paste-slides/slides.md new file mode 100644 index 0000000..81ba564 --- /dev/null +++ b/content/contribute/copy-paste-slides/slides.md @@ -0,0 +1,1089 @@ +--- +title: Copy and Paste Slide Templates # Also update the h1 header on the first slide to the same name +description: A sentence for what these slides are about. +duration: 15 minuets +# nuke has a theme: "reveal-md/nuke-theme.css", alternatively, you can use a named default like "night" from this list: https://github.com/hakimel/reveal.js/tree/master/css/theme/source +# Add custom css files for your slides here, comma separated: +separator: "\r?\n---\r?\n" +verticalSeparator: "\r?\n---v\r?\n" +# Below can be any of these: https://revealjs.com/config/ +revealOptions: + theme: reveal-md/base-theme.css + transition: "slide" # animation between slides = none/fade/slide/convex/concave/zoom + backgroundTransition: "fade" # background swap between slides = none/fade/slide/convex/concave/zoom + slideNumber: true + controls: true + progress: true +--- + +# Copy and Paste Slide Templates + +--- + +### _At the end of this talk, you will be able to:_ + +- Describe ... +- Navigate ... +- Justify ... + +--- + +## Here is a topic + +- Use some bullets +- To make a few points + +Notes: + +Speaker view ONLY notes + +--- + +## Here is an important point + +#### _Make it clear_ + +Notes: + +Stuff you should remember to say + +--- + +## Code Highlight & Transitions + +Syntax for many langs is possible, and very easy to style. +You can _and should_ use highlighting of lines in a large snippets of code. + +You an also add comments to make "fragments" for specific components + + + +_They can ordered how you see fit!_ + + + +See the source for syntax + + + +--- + +## Rust Example + +```rust [0|1,6|15-25|30-31] +#![cfg_attr(not(feature = "std"), no_std)] +// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. +#![recursion_limit = "256"] + +// Make the Wasm binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +mod weights; +pub mod xcm_config; + +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = generic::CheckedExtrinsic; + +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; +``` + +--- + +## Design system examples + +Use `o` to open the overview mode and explore slides here. + +You can see the source of these slides to copy&paste
+as slide templates in your slides! + + + +1. Columns +1. Images +1. MarkDown examples + + + +--- + +## Two Column + + + + +### Center 1 + +Using
`` + + + + +### Center 2 + +Using
`` + + +
+ +---v + +## Two Column + + +```html + + + +### Center 1 + +Using
`` + + + + +### Center 2 + +Using
`` + + +
+``` + +--- + +## Three Columns + + + + +### Left + +Using
`` + + + + +### Center + +Using
`` + + + + +### Right + +Using
`` + + +
+ +---v + +## Three Columns + + +```html + + + +### Left + +Using
`` + + + + +### Center + +Using
`` + + + + +### Right + +Using
`` + + +
+``` + +--- + + + + +### This column has a bit of a statement to make. + + + + +- Lorem ipsum dolor sit amet, consectetur adipiscing elit +- Ut enim ad minim veniam, quis nostrud exercitation +- Duis aute irure dolor in reprehenderit in +- Excepteur sint occaecat cupidatat non proident, sunt in + + + + +---v + + +```html + + + +### This column has a bit of a statement to make. + + + + +- Lorem ipsum dolor sit amet, consectetur adipiscing elit +- Ut enim ad minim veniam, quis nostrud exercitation +- Duis aute irure dolor in reprehenderit in +- Excepteur sint occaecat cupidatat non proident, sunt in + + + +``` + +--- + +## Images + + + + +#### _Leave a note on why this one matters_ + +Notes: + + + +---v + + +```html + +``` + +--- + +## Graphics + + + + +svg, png, gif, ... anything that works on the web should work here! +(Please do be mindful of file size, and minimize where practical) + +> Where possible use `svg` or vector graphics... +> Consider using a [mermaid diagram](#mermaid-diagrams) instead 🤩 + +Notes: + +Image source: +License: + +---v + + +```html + +``` + +--- + +## Video + + + + +mp4, webm, ... anything that works on the web should work here! + +> Please do be mindful of file size, and minimize and compress before committing! + +Notes: + +Video source: +License: + +---v + + +```html + +``` + +--- + + + +# Section title + +---v + + + + +```html + + +# Section title +``` + +--- + +> A quote of myself, saying great stuff, as always. + +Source: me™ at the last event + +--- + +Testing **bold** and _italic_ markdown texts! + + +```html +Testing **bold** and *italic* markdown texts! +``` + +--- + +## Rust Example + +```rust [0|1,6|15-25|30-31] +#![cfg_attr(not(feature = "std"), no_std)] +// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. +#![recursion_limit = "256"] + +// Make the Wasm binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +mod weights; +pub mod xcm_config; + +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = generic::CheckedExtrinsic; + +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; +``` + +---v + + +~~~ + +## Rust Example + +```rust [0|1,6|15-25|30-31] +#![cfg_attr(not(feature = "std"), no_std)] +// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. +#![recursion_limit = "256"] + +// Make the Wasm binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +mod weights; +pub mod xcm_config; + +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = generic::CheckedExtrinsic; + +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; +``` + +~~~ + +--- + + + + +### Column + Code + +- Some +- Observations +- Others + + + + +```rust [0|1,13|4-8] +fn largest_i32(list: &[i32]) -> i32 { + let mut largest = list[0]; + + for &item in list { + if item > largest { + largest = item; + } + } + + largest +} + +fn largest_char(list: &[char]) -> char { + let mut largest = list[0]; + + for &item in list { + if item > largest { + largest = item; + } + } + + largest +} + +fn main() { + let number_list = vec![34, 50, 25, 100, 65]; + + let result = largest_i32(&number_list); + println!("The largest number is {}", result); + assert_eq!(result, 100); + + let char_list = vec!['y', 'm', 'a', 'q']; + + let result = largest_char(&char_list); + println!("The largest char is {}", result); + assert_eq!(result, 'y'); +} +``` + + + + +---v + + +```html + + + +### Column + Code + +- Some +- Observations +- Others + + + + + +```rust [0|1,13|4-8] +fn largest_i32(list: &[i32]) -> i32 { + let mut largest = list[0]; + + for &item in list { + if item > largest { + largest = item; + } + } + + largest +} + +fn largest_char(list: &[char]) -> char { + let mut largest = list[0]; + + for &item in list { + if item > largest { + largest = item; + } + } + + largest +} + +fn main() { + let number_list = vec![34, 50, 25, 100, 65]; + + let result = largest_i32(&number_list); + println!("The largest number is {}", result); + assert_eq!(result, 100); + + let char_list = vec!['y', 'm', 'a', 'q']; + + let result = largest_char(&char_list); + println!("The largest char is {}", result); + assert_eq!(result, 'y'); +} +``` + + + +```` + +--- + +## Tables + +| Tables | Are | Cool | +| ------------------- | :-----------------: | ----------------------: | +| col 1 is | left-aligned | $1600 | +| col 2 is | centered | $12 | +| col 3 is | right-aligned | $1 | +| This row sure has a | _lot_ of text so it | spaces the columns outs | + +---v + +``` +| Tables | Are | Cool | +| ------------------- | :-----------------: | ----------------------: | +| col 1 is | left-aligned | $1600 | +| col 2 is | centered | $12 | +| col 3 is | right-aligned | $1 | +| This row sure has a | _lot_ of text so it | spaces the columns outs | +``` + +--- + +## Math + +KaTeX/LaTeX rendered within blocks with "`$$`" delimiters + +$$J(\theta_0,\theta_1) = \sum_{i=0}$$ + +In line uses "`\\(`" and "`\\)`" to render: \\(\alpha\beta\gamma\\) +. + +More info: https://revealjs.com/math/ + +--- + +## Charts + +

+A plugin for Reveal.js allowing to easily add charts using Chart.js. +

+ +

There is a known bug:
Chart (meaning the < canvas > tag) needs to be in a full HTML slide (no md allowed); this means that the whole slide that contains a chart MUST be written in plain HTML. + +---v + + + + + +---v + +### The code + +```html + + + +``` + + + Note : < !-- and --> are intentional + + +---v + +

+
Bar chart with CSV data
+
+ + January, February, March, April, May, June, July + My first dataset, 65, 59, 80, 81, 56, 55, 40 + My second dataset, 28, 48, 40, 19, 86, 27, 90 + +
+
+ +---v + +### Previous slides' code: + +```html +
+
Bar chart with CSV data
+
+ + January, February, March, April, May, June, July My first dataset, 65, 59, 80, 81, 56, 55, 40 My second dataset, + 28, 48, 40, 19, 86, 27, 90 + +
+
+``` + +---v + +
+
Stacked bar chart from CSV file with JSON configuration
+
+ + + +
+
(There is a data.csv file located under same dir in order for this slide to work
+
+ +---v + +### Previous slide's code: + +```html +
+
Stacked bar chart from CSV file with JSON configuration
+
+ + + +
+
+``` + +--- + +# Mermaid Diagrams + +[Mermaid](https://mermaid.js.org) lets you create diagrams and visualizations using text and code. + +It is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. + +First of all lets see some examples of diagrams that Mermaid can show with its integration with revealJS; + +---v + +### [A Flowchart](https://mermaid.js.org/syntax/flowchart.html) + + + %%{init: {'theme': 'dark', 'themeVariables': { 'darkMode': true }}}%% + flowchart TD + A(Start) --> B{Is it?}; + B -- Yes --> C(OK); + C --> D(Rethink); + D --> B; + B -- No ----> E(End); + + +---v + +### And its code + + +```html + + %%{init: {'theme': 'dark', 'themeVariables': { 'darkMode': true }}}%% + flowchart TD + A(Start) --> B{Is it?}; + B -- Yes --> C(OK); + C --> D(Rethink); + D --> B; + B -- No ----> E(End); + +``` + +---v + +### Entity relationship diagram + + + erDiagram + Node ||--o{ Wallet : places_order + Wallet ||--|{ Account : owner + Node }|..|{ Some-IP : uses + + +---v + +### And its code + + +```html + + erDiagram + Node ||--o{ Wallet : places_order + Wallet ||--|{ Account : owner + Node }|..|{ Some-IP : uses + +``` + +---v + +### Sequence diagram + + + sequenceDiagram + Alice->>John: Hello John, how are you? + John-->>Alice: Great! + Alice-)John: See you later! + + +---v + +### And its code + + +```html + + sequenceDiagram + Alice->>John: Hello John, how are you? + John-->>Alice: Great! + Alice-)John: See you later! + +``` + +---v + +### Class Diagram + + + classDiagram + note "From Duck till Zebra" + Animal <|-- Duck + note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging" + Animal <|-- Fish + Animal <|-- Zebra + Animal : +int age + Animal : +String gender + Animal: +isMammal() + Animal: +mate() + class Duck{ + +String beakColor + +swim() + +quack() + } + class Fish{ + -int sizeInFeet + -canEat() + } + class Zebra{ + +bool is_wild + +run() + } + + +---v + +### And its code + + +```html + + classDiagram + note "From Duck till Zebra" + Animal <|-- Duck + note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging" + Animal <|-- Fish + Animal <|-- Zebra + Animal : +int age + Animal : +String gender + Animal: +isMammal() + Animal: +mate() + class Duck{ + +String beakColor + +swim() + +quack() + } + class Fish{ + -int sizeInFeet + -canEat() + } + class Zebra{ + +bool is_wild + +run() + } + +``` + +---v + +### State diagram (v2) + + + stateDiagram-v2 + [*] --> Still + Still --> [*] + + Still --> Moving + Moving --> Still + Moving --> Crash + Crash --> [*] + + + +---v + +### And its code + + +```html + + stateDiagram-v2 + [*] --> Still + Still --> [*] + + Still --> Moving + Moving --> Still + Moving --> Crash + Crash --> [*] + +``` + +---v + +### User Journey + + + journey + title My working day + section Go to work + Make tea: 5: Me + Go upstairs: 3: Me + Do work: 1: Me, Cat + section Go home + Go downstairs: 5: Me + Sit down: 5: Me + + +---v + +### And its code + + +```html + + journey + title My working day + section Go to work + Make tea: 5: Me + Go upstairs: 3: Me + Do work: 1: Me, Cat + section Go home + Go downstairs: 5: Me + Sit down: 5: Me + +``` + +---v + +### Gantt + + + gantt + apple :a, 2017-07-20, 1w + banana :crit, b, 2017-07-23, 1d + cherry :active, c, after b a, 1d + + +---v + +### And its code + + +```html + + gantt + apple :a, 2017-07-20, 1w + banana :crit, b, 2017-07-23, 1d + cherry :active, c, after b a, 1d + +``` + +---v + +### Pie Chart + + + pie title Pets adopted by volunteers + "Dogs" : 386 + "Cats" : 85 + "Rats" : 15 + + +---v + +### And its code + + +```html + + pie title Pets adopted by volunteers + "Dogs" : 386 + "Cats" : 85 + "Rats" : 15 + +``` + +---v + +### Git Graph + + + gitGraph + commit + commit + branch develop + checkout develop + commit + commit + checkout main + merge develop + commit + commit + + +---v + +### And its code + + +```html + + gitGraph + commit + commit + branch develop + checkout develop + commit + commit + checkout main + merge develop + commit + commit + +``` + +---v + +### Useful links + +- [Mermaid Syntax](https://mermaid.js.org/syntax/flowchart.html) +- [Mermaid Live Editor with examples](https://mermaid.live/) + +--- + +# More help needed? + +_Please reach out to a contributor_ diff --git a/content/contribute/how-to/page.md b/content/contribute/how-to/page.md new file mode 100644 index 0000000..fec2667 --- /dev/null +++ b/content/contribute/how-to/page.md @@ -0,0 +1,74 @@ +# 🪄 Using this Book + +This book contains all the Nuke 🌄's content in _sequence_. +It is intended to read from start to finish, in order, and following the `index.md` page for each series. + +## 📔 How to use `mdBook` + +This book is made with [mdBook](https://rust-lang.github.io/mdBook/) - a Rust native documentation tool. +Please give the official docs there a read to see what nice features are included. +To name a [few key items](https://rust-lang.github.io/mdBook/guide/reading.html#top-menu-bar): + +| Icon | Description | +| --------------------------------- | ------------------------------------------------------------------------------- | +| | Opens and closes the chapter listing sidebar. | +| | Opens a picker to choose a different color theme. | +| | Opens a search bar for searching within the book. | +| | Instructs the web browser to print the entire book. | +| | Opens a link to the website that hosts the source code of the book. | +| | Opens a page to directly edit the source of the page you are currently reading. | + +### Search + +Pressing the search icon () in the menu bar, or pressing the `S` key on the keyboard will open an input box for entering search terms. +Typing some terms will show matching chapters and sections in real time. + +Clicking any of the results will jump to that section. +The up and down arrow keys can be used to navigate the results, and enter will open the highlighted section. + +After loading a search result, the matching search terms will be highlighted in the text. +Clicking a highlighted word or pressing the `Esc` key will remove the highlighting. + +## 🎞️ How-to use `reveal.js` Slides + +Most pages include _embedded slides_ that have a lot of handy features. +These are with [`reveal-md`](https://github.com/webpro/reveal-md): a tool built with `reveal.js` to allow for [Markdown](https://commonmark.org/help/) only slides, with a few extra syntax items to make _your slides look and feel awesome_ with very little effort. + +> 📝 Be use to have _the slides `iframe` on a page active_ (🖱️ click on it) to use slide keybindings... +> Otherwise those are captured by the `mdbook` tools! +> (`s` is search for the book, and speaker notes for the slides) + +Be a `power user` of these by using the **keybindings** to interact with them: + +- Use `space` to navigate _all_ slides: top to bottom, left to right. + - Use `down/up` arrow keys to navigate _vertical_ slides. + - Use `left/right` arrow keys to navigate horizontal slides. +- Press `Esc` or `o` to see an `overview` view that arrow keys can navigate. +- Press `s` to open up speaker view.
+ **👀 Speaker notes include very important information, not to be missed!** + +### 💫 Slides Demo + +Tryout those keybindings (🖱️ click on the slides to start) below: + + + +
+ How to use the slides - + Full screen slides (new tab) +
+
+
+(🖱️ expand) Raw Markdown of Slides Content +{{#include slides.md}} +
+ + +☝️ All slides `Slides Content` is available on all pages. +This enables **search** to work throughout this book to **jump-to-location** for any keywords you remember related to something covered in a topic 🚀. + +### 📖 Learn More + +- + - [Official Slides Demo](https://revealjs.com/demo/) +- [Markdown ➡ Slides Build Tooling](https://github.com/webpro/reveal-md/) diff --git a/content/contribute/how-to/slides.md b/content/contribute/how-to/slides.md new file mode 100644 index 0000000..cf1a47e --- /dev/null +++ b/content/contribute/how-to/slides.md @@ -0,0 +1,60 @@ +--- +title: How-to use Reveal.js Slides +description: How to use reveal.js +duration: 5 minuets +--- + +# How-to use Reveal.js Slides + +These slides are built with [reveal.js](https://revealjs.com/). + +These slides serve as a feature demo of reveal for you! 🎉 + +--- + +## What are we going to see: + +- How to use Reveal.js Features + + - Useful `reveal.js` tips + - Speaker Notes + +--- + +## How to use Reveal.js Features + +_Press the `down/up` keys to navigate \_vertical_ slides\_ + +Try doing down a slide. + + + +---v + +### Use the keybindings! + +- **Overview mode**: “O” to see a birds-eye view of your presentation, “ESC” to return to the highlighted slide (you can quickly navigate with arrows) + +- **Full-screen**: “F”, “ESC” to exit full-screen mode + +- **Speaker mode**: “S” it synchronizes 2 windows: one with the presentation, and another with a timer and all speaker notes! + +- **Zoom-in**: ALT+click make the view zoom at the position of your mouse’s pointer; very useful to look closely at a picture or chart surrounded by too much bullet points. + +---v + +## Speaker Notes & Viewer + +_Press the `s` key to bring up a popup window with speaker view_ + +**You need to unblock popups to have the window open** + +Notes: +This is a note just for you. Set under a line in your slide starting with "`Note`:" all +subsequent lines are just seen in speaker view. + +--- + +# Enjoy! + +## 😎 diff --git a/content/contribute/index.md b/content/contribute/index.md new file mode 100644 index 0000000..47aace6 --- /dev/null +++ b/content/contribute/index.md @@ -0,0 +1,359 @@ +# Contributor Guide + +If you want to _develop_ with these slides, these instructions are for you. + +## Installation + +In order to `make` your life easy 😉, there is a set of tasks that use [`just`](https://just.systems/man/en/chapter_1.html). + +With [`just`](https://github.com/casey/just?tab=readme-ov-file#installation) installed, you can list all tasks included to facilitate further installation, building, serving, formatting, and more with: + +```sh +# Run from the top-level working dir of this repo +just --list +``` + +The tasks should be self-explanatory, if they are not - please file an issue to help us make them better. + +```sh +# Install all dependencies +just i +``` + +
+(Not advised) Manual Install + +You may opt out of `just` described, but minimally will need to have: + +### Book - `mdBook` + +- [Install of `mdBook`](https://rust-lang.github.io/mdBook/guide/installation.html) + +Serve the book offline with: + +```sh +# Run from the working dir of this repo +mdbook serve --open +``` + +### Slides and Tooling - `bun` + +Use [bun](https://bun.sh/) to install and run the javascript and node tooling. +With `bun` installed, from the top level dir: + +```sh +if ! $(echo "type bun" | sh > /dev/null ); then + echo "🥟 Installing https://bun.sh ..." + curl -fsSL https://bun.sh/install | bash +fi +echo "💽 Bun installed." + +echo "🥟 Install slides tooling with Bun..." +bun install +echo "✅ Slides instalation complete!" +``` + +This should open a new browser tab with a simple listing of all slide decks to choose from. + +### Embedded Slides + +At this time, there is a "hack" to get the slides embedded in the book, where the static HTML assets from a slides build are coppiced _into_ the book so that they function in an `iframe`. +See the `Makefile.toml` for `[tasks.serve]` to see the commands required to manually get this working. +Again, it's much more convenient to use `just` here vs. manually running this! + +
+ +## Content Design + +I focused on _practical application_ of web3 concepts I cover, more than simply discussing. + +### Organization + +The entirety of the book, including assets (images, code, etc.) needed in this book lives in `./content/*`. +The directory structure is as follows: + +```sh +content +├── +├── index.md # Series overview with many materials associated with it +├── guide.md # Presentor/Host facing guide on running these materials +├── README.md -> index.md # Soft link `ln -s index.md README.md` - for Github web reading +│ ├── # Talk related, has slides +│ │ ├── img +│ │ │ ├── # png, gif, mp4, jpg, etc. used in *these slides/examples* +│ │ │ ├── ... +│ │ ├── page.md # Typically a stub file for embedding `slides.md` +│ │ └── slides.md # A `reveal-md` formatted document +│ ├── _materials # Workshop, Exercise, or Activity related +│ │ ├── img +│ │ │ ├── # png, gif, mp4, jpg, etc. used in *these slides/examples* +│ │ │ ├── ... +│ │ ├── .md # Audience facing instructions on some material +. . . ... +``` + +- `/README.md` - **_required_** soft link to `index.md`. +- `/index.md` - **_required_** book page, **_must_** be listed in `SUMMARY.md`. +- `/guide.md` - **_optional_** page _not_ used in the book, **_must NOT_** be listed in `SUMMARY.md`. +- `//page.md` - **_required_** book page, **_must_** be listed in `SUMMARY.md`. +- `//slides.md` - **_optional_** slides, embedded into a `page.md`, **_must_** be embedded into `page.md`if slides are used. +- `//img` - **_optional_** directory with media used in slides or pages in _this topic_. +- `//_materials` - **_optional_** directory with inclusions referenced in slides or pages + +## Development Workflow + +Typically, most work for topics centers on the development of slides. +The pages they are embedded into are _primarily_ static stubs to host the slides within. +Workshop and Activity pages are an exception, where they do not usually have slides associated, or need more information outside slides. +Viewing the rendered markdown of slides is more important than when iterating on pages, in practice. + +### Working on Slides with `reveal-md` + +Slides include primarily talk materials used to present in class, and those slides must contain `Notes:` sections with detailed **audience facing** information about what is covered on a slide, _not only_ speaker-facing notes! +Typically the slide notes should embed all the references, resources, and further considerations for audiences to have as a resource during and after class. + +To view and edit slides (only) in **watching** mode (updates immediately on changes to any file changes in the content): + +```sh +# WATCHING server for slides only +just serve-slides +# Or simply: +bun s +``` + +See the [Using this Book](./how-to/page.md) page for more details on `reveal.js` features and use. + +**If this is your first time using `reveal.js`, we encourage you to explore [the official demo](https://revealjs.com/demo/#/2) to see what sort of things you can do with it!** +We are creating and customizing slides with [`reveal-md`](https://github.com/webpro/reveal-md): a tool built with `reveal.js` to allow for [Markdown](https://commonmark.org/help/) only slides, with a few extra syntax items to make _your slides look and feel awesome_ with as little effort as possible on style and visual design. + +##### Copy & Paste Slides + +The [Copy and Paste Slide Templates](./copy-paste-slides/page.md) page and source for the embedded slideshow demonstrate use and code snippets to accommodate **many common slide archetypes**. +It should be possible to modify examples in your slides from these templates, including: + +- Multi-column slides +- Embedded media +- Diagrams (mermaid, and more) + +### Working on Pages with `mdBook` + +Pages embed slides, and may include links to materials, references and other things **_when it's impractical to include it within speaker notes for slides_**. +Most pages are just "stub" files to embed the slides into. + +To work on both the embedded slides and the book in tandem in **non-watching mode**: + +```sh +just s # Build the slides (clobbering those tracked by the book repo in `./slides`), embed in the book, view the updated book. + +# ... Make changes to the book and/or the slides ... +# ... kill the server with `ctrl+c` ... + +just s # Build the slides (clobbering those tracked by the book repo in `./slides`), embed in the book, view the updated book. +``` + +> 😭 At this time, this is a non-watching server, you must manually open the page and _hard refresh_ pages served before to see them updated. +> +> You must _rerun_ this command to update on file changes! + +### Topic Template + +Head over to the [Topic Template](./template/page.md) page, and _carefully read through the source_ before you continue. +The entire directory is intended to be copied & pasted into the correct series to kickoff new topic development: + +```sh +# Copy this whole thing 👇😀 +└── template + ├── img + │ └── REMOVE-ME-example-img.png + ├── page.md + └── slides.md +``` + +The `page.md` file should \_embed the `slides.html` page that isn't going to work until the build process creates it, but it will exist once that happens & render 😉. + +### File Size Considerations + +We strive to not overload this book with excessively large assets, to that end we ask that all contributors _before committing to this repo_ any assets: + +- Review image file size & compress minimal possible looking OK-ish full screen, or use smaller alternatives. + Example: + ```sh + # Compress with imagemagick + convert -quality 20% + ``` +- Scale down all videos to minimal possible looking OK-ish full screen. + Example: + ```sh + # What is the bitrate? + ffmpeg -i 2> >(grep -i bitrate) + # Reduce bitrate, iterate to find the *good enough* one for minimal size + ffmpeg -i -b 400k + ``` + +### Refactoring Considerations + +
+🚧 This workflow is not _normally_ needed by most contributors. Click to view anyway 🚧 + +We opt out of the handy helper to create missing files if linked in `SUMMARY.md`, as this indicates something is likely amis in our translation of slides -> stub pages mapping correctly. + +This is useful to turn back on when _radically_ updating the slides path structure and/or file names as changes must be _manually_ applied otherwise to link to the correct new location in `/slides/.../*-slides.html` + +You can opt in by editing `book.toml`: + +```diff,toml +[build] +- create-missing = false # do not create missing pages ++ create-missing = true # create missing pages +``` + +### Tips on the Embedded Slides + +All series are of the structure described in the [Content Organization](#organization) section. + +All `slides.md` files are the source of the associated slide content for that the `page.md` files that embed them in the book itself. +The `page.md` files are typically just stubs, but do the option to add more details, instructions, etc. +They typically are identical to: + +```md +# SOME TITLE HERE + + + +
+ +
+ How to use the slides - + Full screen (new tab) +

+
Raw Slides Markdown
+
+
+{ {#include slides.md} } + + + +``` + +- `find . -name 'page.md' -exec bash -c 'cat ../tmp >> "{}"' \;` to apply the page stuff to embed slides + +
+ +### ⏰ Critical Considerations + +- Always use proper MarkDown links! + `` is required, raw links _will not be rendered_ in mdBook! +- Never use links that are likely ephemeral and will break. + This example is in main, not some PR branch: + You _must_ be permalinks to a commit hash when using a github link, not `main` or other branch. +- Reuse images and have no duplication of any images, with close _enough_ ones considered to replace where possible. + **_Relative_** paths are supported: `../..//img/` + +--- + +## Conventions and Helpers + +This book, and all content within have style and typographic conventions that, where practical, have tooling to help everyone conform to them. + +```sh +# This will install the tooling needed for formatting, linting, checkers, etc. +just install-dev +``` + +### Formatting + +All Markdown, TOML, JSON, Typescript, and Javascript files in this repository are formatter with [dprint](https://dprint.dev/). +The setting for this formatter are found in `.dprint.json`. +We use `just` to run this: + +```sh +# This will format all files SUPER FAST after the first run is cached +just f +``` + +If (and only if) formatting _breaks_ Markdown from rendering correctly, you may use `` preceding a block in markdown to skip formatting like this: + +````markdown + +```html + + + + ### What's up, yo? + + + + + - Yo +- Yo +- Yo + + + +``` + + + +Some text + +* other text +* testing + + +```` + +See [the docs on Markdown for dprint](https://dprint.dev/plugins/markdown/#ignore-comments) for more. + +### Checking Links + +To ensure all `*.md` and `.html` files contain no broken links within them, we use a [the `mlc` link checker](https://github.com/becheran/mlc). +Run with: + +```sh +# Link check all content files +just l + +# Link check a single file: +just links-for + +# Link check a directory, recursively +just links-for <./content/some-dir/inner-dir> +``` + +The checker configuration is set ine `Makefile.rs` task to see settings. +The `.mlc.toml` config file is used to _globally_ ignore specific common URLs that throw errors, in error 😛... +at least it should, but is [not working at this time](https://github.com/becheran/mlc/issues/76). +_Notice that ignored links must be check from time to time manually!_ +_Thus don't use this unless explicitly needed, rather use a know good URL if at all possible, perhaps from the _ +The same tool is also run by our CI on all files for all pushes to all branches. +See the `.github/workflows/link-check.yml` file in this repo for details. + +> You can ignore the link check for a `regex` compliant entry in: +> +> 1. `.mlc.toml` +> 1. `.github/workflows/check.yml` +> 1. `justfile` +> +> [Eventually](https://github.com/becheran/mlc/issues/78) just `.mlc.toml` will do. + +### Checking Images + +In order to ensure that there are no issues with images in this book, we check for: + +1. Broken links to images that will not be found in the build. +1. Orphaned image files - not linked to at all from the book. + +```sh +# Link check all `` tags +just img +``` + +Please **_delete_** any assets you do not need, we can always `git recover` at a latter time to bring them back in 💽. + +## CI + +1. `.github/workflows/pages.yml` - On any merge with `main`, the CI is tasked with building the book and deploying a hosted version of it. +1. `.github/workflows/check.yml` - On any merge with `main`, the CI is tasked with checking book for any issues with format, links, and images. + +See `.github/workflows/` in this repository for more details. +Other tasks mostly stand alone from the `` tooling suggested in development workflows at this time, but some require the `bun` tooling to properly build and test things. diff --git a/content/contribute/template/img/REMOVE-ME-example-img.png b/content/contribute/template/img/REMOVE-ME-example-img.png new file mode 100644 index 0000000..df96022 Binary files /dev/null and b/content/contribute/template/img/REMOVE-ME-example-img.png differ diff --git a/content/contribute/template/page.md b/content/contribute/template/page.md new file mode 100644 index 0000000..d4b86a0 --- /dev/null +++ b/content/contribute/template/page.md @@ -0,0 +1,16 @@ +# Talk Template Slides + + +
+ +
+ How to use the slides - + Full screen (new tab) +
+ + + + +
Slides Content
+{{#include slides.md}} + diff --git a/content/contribute/template/slides.md b/content/contribute/template/slides.md new file mode 100644 index 0000000..9789512 --- /dev/null +++ b/content/contribute/template/slides.md @@ -0,0 +1,206 @@ +--- +title: Talk Template Slides # Also update the h1 header on the first slide to the same name +description: Describe your slides here +duration: 1 hour +--- + +# Talk Title + +--- + +### Outline + + + + + +1. [Pre-requisites](#pre-requisites) +1. [Major Topic A](#major-topic-a) +1. [Exercise X](#exercise-title) +1. [Conclusion](#conclusion) +1. [Next Steps](#next-steps) +1. [References](#references) + + + +--- + +## Pre-requisites + +No background in X is necessary. + +However, the following are expected: + + + +- Y +- Z +- \\(\alpha\\) + + + +--- + +### _At the end of this talk, you will be able to:_ + + + + + +- Describe ... +- Navigate ... +- Justify ... + + + +--- + +## Major Topic A + + + +- Use some bullets +- To make a few points + + + +More context here. + +And even more here... and more and more... + +Notes: + +Speaker view ONLY notes + +--- + +# An Important Point + +### _Make it clear_ + +Notes: + +Stuff you should remember to say + +--- + +## Some Image + + + + + +Notes: + + + +Image source: (some URL here!) +License: (some URL, annotated with the know license of this img. Eg: `[CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/)` - if unknown please mark `UNKNOWN` here) + +--- + +## Some Shared Image + + + +Notes: + + + +--- + +--- + +# Exercise Title + +### _Describe it here_ + +--- + +## Exercise Instructions + + + + + +1. Uno +1. Dos +1. Tres + + + +Notes: + +Make sure to include things here to say to audiences, perhaps a hint or two. +Realize that audiences will be able to view the speaker's notes, as they will have access to them on their devices. + +--- + +## Conclusion + + + +--- + + + +# Questions + + + +--- + +## Next Steps + + + + + +1. Eins +1. Zwei +1. Drei + + + +--- + +## References + + diff --git a/content/overview.md b/content/overview.md new file mode 100644 index 0000000..0b8f351 --- /dev/null +++ b/content/overview.md @@ -0,0 +1,3 @@ +# 📒 Book Overview + +This book contains a set of slides, materials, and hands-on experiences in developing (mostly) blockchain and web3 technologies. diff --git a/content/risc-zero/README.md b/content/risc-zero/README.md new file mode 120000 index 0000000..dd0ea36 --- /dev/null +++ b/content/risc-zero/README.md @@ -0,0 +1 @@ +index.md \ No newline at end of file diff --git a/content/risc-zero/index.md b/content/risc-zero/index.md new file mode 100644 index 0000000..fa397cf --- /dev/null +++ b/content/risc-zero/index.md @@ -0,0 +1,7 @@ +# RISC Zero + +These slides focus on [RISC Zero](https://www.risczero.com) development. + +## Resources + +- TODO diff --git a/content/risc-zero/zypher-buildathon/img/fusion-dragon-ball.gif b/content/risc-zero/zypher-buildathon/img/fusion-dragon-ball.gif new file mode 100644 index 0000000..f4bd373 Binary files /dev/null and b/content/risc-zero/zypher-buildathon/img/fusion-dragon-ball.gif differ diff --git a/content/risc-zero/zypher-buildathon/materials.md b/content/risc-zero/zypher-buildathon/materials.md new file mode 100644 index 0000000..3474cb4 --- /dev/null +++ b/content/risc-zero/zypher-buildathon/materials.md @@ -0,0 +1,53 @@ +# Zypher gZKm Provable Games Buildathon + +## 📝 Event Specific Info + +- Dora Hacks Event Page (APPLY HERE) +- Event & RISC Zero Track Info +- Zypher Homepage +- RISC Zero [🪧 Presentation (Video & Sides)](./presentation.md) +- RISC Zero [👷 Workshop (ZK Chess Checkmate)](./workshop.md) + +### ⭐ Zypher 🤝 RISC Zero Example + +poker0 - A poker game leveraging RISC Zero and PLONK for off-chain proof of game processes, with on-chain validation, built on the Z4 engine. + +> Note: This perhaps is a rather complex starting point from without any experience with RISC Zero or PLONK, we suggest experimenting with the [more basic examples](#risc-zero-game-examples) first to get a feel for things first 😸. + +## 🧠 Further Reading & Resources + +### RISC Zero Game Examples + +Note that many other examples showcase things you might want (reading a JSON file, checking a password, and more!) + +Here are a few key game specific ones: + +- Bevy - a serious Rust game engine +- Wordl - A non-trivial game +- Chess +- Bevy + +### RISC Zero powered zkSnake (R0 v0.20) + + + +> https://github.com/0xAndoroid/zkSnake + +- Winner of RISC Zero Coprocessor Bounty at ETHDenver 2024 and did well in community quadratic voting too! +- Idea: take it further and make a bevy app in wasm w/ webGPU with **shared core logic identical on web & "re-player" zkVM** + +### Dark Forest + + + +☝️ A fantastic verteran review of their work and showcases fundementally new type of game that web3 makes possible: build base infrastructure for others **to build on top of _permissionlessly_**. +Shared infra -> purality of ways to interact with a wider community on the same base layer opens up novel MMO games _**built by and for players**_! + +Although today zkVMs help devs avoid needing to write most of the game in some contract language or (zk)DSL, like is enabled in RISC Zero with the bevy game engine. +And it's very likely to be far more cost effective to run too! + +### More for RISC Zero + +- [zkVM Guest Optimization Tips and Tricks (RISC Zero Study Club)](https://www.youtube.com/watch?v=MckieUBpakw) +- [DOOM on RISC Zero](https://www.risczero.com/blog/when-the-doom-music-kicks-in) (not playable, but proof DOOM can run _**everything**_ in zkVM guest) +- [zkVM Benchmarks, Tested Crates & More](https://reports.risczero.com/) diff --git a/content/risc-zero/zypher-buildathon/presentation.md b/content/risc-zero/zypher-buildathon/presentation.md new file mode 100644 index 0000000..fae53c8 --- /dev/null +++ b/content/risc-zero/zypher-buildathon/presentation.md @@ -0,0 +1,14 @@ +# Verifiable Games Using RISC Zero + + +
+ +
+ How to use the slides - + Full screen (new tab) +
+ + +
Slides Content
+{{#include slides.md}} + diff --git a/content/risc-zero/zypher-buildathon/slides.md b/content/risc-zero/zypher-buildathon/slides.md new file mode 100644 index 0000000..00da9f4 --- /dev/null +++ b/content/risc-zero/zypher-buildathon/slides.md @@ -0,0 +1,241 @@ +--- +title: Verifiale Games Using RISC Zero +tags: RISC Zero, Talk, Presentation, Workshop, zkVM, zkGames, Zypher, Hackathon, Buildathon, Zero Knowledge Proof, Applied Cryptography, Rust, Zypher +duration: 60 minuets +description: RISC Zero Workshop for the Zypher Provable Games Buildathon - June 2024 +date: 2024-06-01 +# +# RevealJS Settings +# +# Add custom css files for your slides here, comma separated: +separator: "\r?\n---\r?\n" +verticalSeparator: "\r?\n---v\r?\n" +# Below can be any of these: https://revealjs.com/config/ +revealOptions: + transition: "slide" # animation between slides = none/fade/slide/convex/concave/zoom + backgroundTransition: "fade" # background swap between slides = none/fade/slide/convex/concave/zoom + slideNumber: true + controls: true + progress: true +--- + + + +# Verifiable Games + +#### _Using RISC Zero_ + + + +**_On-chain_ $~~~$ $ 👉 ZK 👈 $ $~~~$ _Off-chain_** + +Workshop Materials ↗️ + +--- + +## Why RISC Zero? + +- **Verifiable Computation**: outsource-able +- **Highly Scalable**: low-cost verification +- **Tunable Privacy**: robust & universal\* + +Notes: + +- you can verify that a computation of a specific program ran exactly as it should, even if done by untrusted executor! +- _Prover_ that runs program & produces _receipt_ reveals as little as nothing to everything about execution to _verifier_. +- Verification is significantly cheaper than running computation yourself... at the cost of prover doing significantly more work to run the _zkVM_ +- \* Privacy is from everyone outside the prover, if you are the prover, no one but you has secret data. + +--- + +## What problems can ZK address for games? + +On-chain (coprocessor): + +- calldata limits restrict complexity +- gas costs are prohibitive +- public blockchains don’t support incomplete information games +- Zypher’s bullet points for challenges of on-chain gaming + +Off-chain (TODO): + +- Cheating through manipulation of official game logic +- Private game aspects without any 3rd party / admin to adjudicate. + +Notes: + +- Added **security** and **fairness** and **privacy** that zero-knowledge proofs can provide, as they involve complex decision-making and competitive interactions. +- Commonly turn based, but can simply be tick based (STF analogy -> blocks) +- Privacy is optional, fully transparent games with ZKPs _can_ provided added guarantees around many things other than that (if carefully designed) + - cheating specifically in being able to go around rules of game logic, especially in cases with hidden player data/logic. (Don't trust. verify!) +- Private: + - moves of known players + - cards in your hand / hidden from all deck shuffle + - hidden ID / anonymous interactions in multiplayer + - Enabling incomplete information games (e.g. “fog of war” mechanics) +- Can prove final score without revealing _anything_ about the game that resulted in it! Proof of Exploit CTF. + +- todo Mention alternatives? Why we are a good or the best choice? (privacy possible, not solidity or DSL specific) +- Off-chain: CFT game where you prove you got a flag without revealing it (because that needs to remain secret) no 3rd party to check, use a proof! + +--- + +## RISC Zero Track Objective + +> Develop games using RISC Zero to ensure **privacy and fairness**. + +Notes: + +Developers are encouraged to implement game designs that can verify player actions without disclosing specific game data. This approach allows for the exploration of new gaming models that operate off-chain but utilize on-chain verification to ensure transparency and fairness. + +--- + +## Definitions & Lingo + +- TODO diagram of host that encapsulates guest w/ input & output +- see https://www.youtube.com/watch?v=DzOWh3Ht0_Q & get diagrams + +Notes: + +- deeper understanding as exercise for views of this presentation. + See the official docs & youtube for great deep +- very happy to answer questions on our discord! + +--- + +# ✨ Inspiration + +> :warning: _Do not copy&paste submissions_ :pray: + +Notes: + +Plagiarism, missing attribution and violating licenses will disqualify you! +Building on them to something significantly enhancements _**may**_ be considered - please let us know what you are planning :grin: + +--- + +## ZK Checkmate Demo + + + +Join in following the [Hands-on instructions ↗️](./checkmate-chess-example.md) + +Notes: + +- Chess demo for verifying a winning move (checkmate) without revealing what the move is. + Contrived example a bit, but highlights: + - use crates without modification - no need to rewrite in circuits or zkDSL! + - Use standard patterns like `println!` & `fmt!` normally for basic experiments. + - 10s on lines of code overall -> useful proof, easily extensible! +- Original [deep dive video](https://www.youtube.com/watch?v=vxqxRiTXGBI&list=PLcPzhUaCxlCgig7ofeARMPwQ8vbuD6hC5&index=10) ([slides](https://drive.google.com/file/d/1Bum4x50qatqBUlQyNVkt90nnA2SEOHNO/view)) + +--- + +## Bevy (R0 v0.21) + +- Serious Rust game engine for ZK games +- BEST place to start to see if you can compile & run this without modification on your machine. + +--- + +## zkSnake (R0 v0.20) + + + +> https://github.com/0xAndoroid/zkSnake + +Notes: + +- Winner of RISC Zero Coprocessor Bounty at ETHDenver 2024 and did well in community quadratic voting too! +- Idea: take it further and make a bevy app in wasm w/ webGPU with **shared core logic identical on web & "re-player" zkVM** + +--- + +## 3D ZK Games?! + +## ▶️ Bevy Wasm webGPL/webGPU example + +🤯 Zypher Real-time Multiplayer Games Track featured demo! + +- Rendered web game + wallet connect +- Original Bevy docs source to generate the playable browser example + +--- + +## 🤔 What is special about RISC Zero? + +- developer productivity (@ hackathons & beyond) + - Top 1000 [crates.io](https://crates.io/) tested ~nightly: [reports.risczero.com](https://reports.risczero.com/) +- todo: key features that are HARD in zkDLS +- proof continuation +- execution separate from proof (realtime exec & prove in parallel / after / remote) +- foundry template & steel & mainnet verifiers + +Notes: + +- lots of ZKP option, why use R0? +- What killer features does R0 provide? + +- Not exclusive on ZKP world for these in many cases longer term, but the collection of them together today makes it very compelling! + +- Zeth _could_ run existing solidity games off chain, optionally unbounded computation per block (gasless). [Zeth deep dive](https://www.youtube.com/watch?v=4pBmf839eOA) +- NOTE: 256 view call limit - could you do inclusion proof checkpoints? contract state is simply recursive proof of minimal thing needed (maybe block header / hash?) updated by anyone to use for deep archival view calls? prove "this state was in block X that is a child of recent block {younger than 256}" + +--- + +## 📝 Key Takeaways + +- IMPORTANT: match version of `cargo risczero` & examples / templates / examples +- keep guest minimal - extra cycles are VERY expensive (but this is a hackathon, don't over optimize) +- USE DEV MODE! +- Bonsai API key priority & support +- you are designing a cryptographic system, not just a game +- Support forum on discord for help! +- dedicated channel for this event? +- TODO more + +--- + +## TODO + +- You emphasized that the proofs are “verrrry” expensive to build — I think we can dial that back. As a it’s something like 100k-1M times more expensive than native compute. +- Not sure what we can offer re malware/viruses — that felt a bit confusing to me +- Jumping around windows was disorienting — would suggest figuring out the specific ordering of which windows you want to open and try to use more words to flag what’s about to happen. perhaps even grabbing the relevant screenshots and importing things into the slides rather than doing a live-tour +- Make text bigger pretty much everywhere, but especially in terminal windows +- FEN is a format for notation chess games and chess positions https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation +- Nice job highlighting the idea that you don't have to do everything inside the zkvm +- Would be nice to synthesize the design patterns. i.e., things we can do are: + - Prove transcript of game for verifiable high scores + - Prove state update based on complex game logic. + - Prove validity of player moves while concealing +- Question about pulling something out into core library. +- Typo on last slide re: zkDSL (it says zkDLS) + +youtube description workshop instructions? + +see discord ref page for moving to book + +missing: + +- synthesis of design patterns used in games + - play & prove latter (snake game) + - proof for each hidden move, perhaps in a tx on chain + - can run only core game logic in zkVM - GUI and other non-security/privacy/fairness aspects can live outside the proven core logic (diagram) +- recap + - as a game dev: what does zk do and not do for me? +- randomness + - cannot do within guest - only fake & deterministic random for replay of moves perhaps (who gets to know seed? Choose? VRF maybe?) +- video or screen shots instead of live code +- more diagrams especially wrt games + - how the proof works in game context (seq. diagrams with actors IDed (player, execution, prover)) +- what do we not know about web3 games... more on chain that we know of as a team? +- bigger text (for term especially) +- More about web3 integrations specifically? Does foundry worth with zypher? + - scale solidity games off-chain with Zeth... but should rewrite in rust! + - + +--- + +# Further Reading & Resources + +- Event Materials ↗️ diff --git a/content/risc-zero/zypher-buildathon/workshop.md b/content/risc-zero/zypher-buildathon/workshop.md new file mode 100644 index 0000000..b94d6df --- /dev/null +++ b/content/risc-zero/zypher-buildathon/workshop.md @@ -0,0 +1,58 @@ +## ZK Checkmate (R0 v1.0) + +Let's experiment with a ZK chess game for verifying a winning move (a checkmate) is possible next turn without revealing what the move is to anyone. + +1. Watch this playlist to learn the basics +1. Use `rzup` to setup your development environment based on the **correct version of the RISC Zero Getting Started Docs** for you. + ```sh + # Get rzup + curl -L https://risczero.com/install | bash + # Follow command instructions to use rzup + # ... This will take a while first time! + ``` +1. Clone and run the chess example with: + ```sh + git clone --branch v1.0.1 --depth=1 https://github.com/risc0/risc0 + cd risc0 + cd examples/chess + cargo r -r + # ... This will take a while first time! + # If you get errors, see step one to get setup! + ``` +1. Take a look at the structure of the code: + ```sh + risc0/examples/chess + ├── Cargo.toml + ├── core + │ ├── Cargo.toml + │ └── src + │ └── lib.rs # SHARED logic (host & guest) + ├── methods + │ ├── build.rs + │ ├── Cargo.toml + │ ├── guest + │ │ ├── Cargo.lock + │ │ ├── Cargo.toml + │ │ └── src + │ │ └── main.rs # 🌟 Guest = Game Logic to be proven + │ └── src + │ └── lib.rs + ├── README.md + └── src + └── main.rs # Host = Execution of guest & GUI & more unproven + ``` +1. Make some changes to: + 1. `src/main.rs` to change the FEN game state and see if a non-mate move is detected. + 1. `methods/guest/src/main.rs` to change what is proven about the game. + Perhaps add something to `core/src/lib.rs` around player ID that could be proven? + +## 📝 Key Takeaways + +This example is a bit contrived as it's a single move that should be easy to spot, but highlights: + +- Use crates in the zkVM without modification - no need to rewrite in circuits or zkDSL! +- Use standard patterns like `println!` & `fmt!` normally for basic experiments and debugging in `DEV_MODE`. +- 10s on lines of code overall -> useful proof, easily extensible! +- Incomplete information games are possible on-chain! Hidden data/moves for players are proven, never revealed to _anyone_! + +> Original deep dive video & slides & source - a great reference to supliment, but outdated using R0 v0.12 . diff --git a/justfile b/justfile new file mode 100644 index 0000000..98c8659 --- /dev/null +++ b/justfile @@ -0,0 +1,146 @@ +# Use with https://github.com/casey/just +# https://just.systems/man/en/chapter_42.html#safer-bash-shebang-recipes + +alias s := serve +alias ss := serve-slides +alias sb := serve-book +alias b := build +alias f := fmt +alias c := clean +alias i := install +alias l := links + +default: serve-slides + +# ----------------------------------------------------------------------------- +# Installation + +# Install required tools (bun, mdbook, dprint, ...) +install: + #!/usr/bin/env bash + set -euxo pipefail + if ! $(echo "type bun" | sh > /dev/null ); then + echo "🥟 Installing https://bun.sh ..." + curl -fsSL https://bun.sh/install | bash + fi + echo "💽 Bun installed. NOTE: you may need to update your shell to include this, see above output." + + echo "🥟 Install slides tooling with Bun..." + bun install + echo "✅ Slides instalation complete!" + + # Install book engine. + if ! $(echo "type mdbook" | sh > /dev/null ); then + cargo install --locked mdbook + fi + + # install deps for web + bun i + +# Wipeout build and dependancy artifacts, then install. +reinstall: clean + rm -rf node_modules/ && just install + +# Wipeout build and dependancy artifacts, then install (including dev tooling). +reinstall-dev: reinstall install-dev + +# Install base deps and dev tools. +install-dev: install + # Install markup link checker (mlc). + if ! $(echo "type dprint" | sh > /dev/null ); then + cargo install --locked mlc + fi + + # Install formatter (dprint). + if ! $(echo "type dprint" | sh > /dev/null ); then + cargo install dprint + fi + +# First *build* the embedded slides, then serve book. + +# We must build static HTML for slides that is embedded into the book +serve: build-slides build-book + #!/usr/bin/env bash + set -euxo pipefail + # FIXME - want some way to have a watching server for slides AND the book. Likely some hooks in mdBook and/or reveal-md could be used. + # copy files from slides build to book build + rsync -av html-slides/content/ html-book/ --ignore-existing > /dev/null + rsync -av html-slides/ --exclude "content" html-book/ --ignore-existing > /dev/null + + # The reveal tooling uses a one-too-deep path for the book + # "./../../../" in ALL CASES within the html flies should be "../../" so we fix those: + find html-book/ -regex .*\.html | xargs sed -i'' -e 's#./../../../#../../#g' > /dev/null + + # serve the book with embedded slides + # FIXME non-watching server becuase mdBook clobbers the rsync we did above 😭 + just serve-embedded + +# Serve book for local viewing, auto-updates for book file changes +serve-book: + mdbook serve -o + +# Serve slides only for local viewing, auto-updates for slides-source file changes +serve-slides: + bun s + +# Serve book with embedd slides for local viewing, NO updates for slides-source file changes +serve-embedded: + bun serve-book 2> /dev/null + +# ----------------------------------------------------------------------------- +# Build, staging for and/or publishing for production + +# Build the embedded slides, then the static site for the book. +build: build-slides build-book + +# Build the static site for the book. +build-book: + mdbook build + +# Build the static slides only, local developmet. +build-slides: + bun build-slides-local > /dev/null + +# ----------------------------------------------------------------------------- +# Dev tools for style, convention, and formatting + +# Cleanup build artifacts +clean: clean-book clean-slides + #!/usr/bin/env bash + set -euxo pipefail + # cargo clean + +# Clean the book static build files +clean-book: + #!/usr/bin/env bash + set -euxo pipefail + # Wipeout build artifacts + rm -rf html-book/ + +# Clean the slides static build files +clean-slides: + #!/usr/bin/env bash + set -euxo pipefail + rm -rf html-slides + +# Scan for image issues througout content. +img: + ./tools/scripts/orphan-image-scan.sh content/ + +# Check included links for all markup (.md|.html) files. +links: + # FIXME .mlc.toml config not working... https://github.com/becheran/mlc/issues/78 + mlc content/ --ignore-links '*slides.md,*slides.html,*twitter.com*,' + +# Check links for specific file(s). Example: `just links-for ./content/contribute/**/*.md` +links-for: + # FIXME .mlc.toml config not working... https://github.com/becheran/mlc/issues/78 + mlc ${@} --ignore-links '*slides.md,*slides.html,*twitter.com*,' + +# Format .rs (with cargo) and .ts, .md,... (config in .dprint) +fmt: + #!/usr/bin/env bash + set -euxo pipefail + # cargo fmt + dprint fmt + just --unstable --fmt diff --git a/package.json b/package.json new file mode 100644 index 0000000..9aa7d78 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "nuke-book", + "version": "1.0.0", + "description": "The materials used in Nuke 🌄 's talks and workshops", + "scripts": { + "s": "bun serve-slides", + "dev": "bun serve-slides", + "start": "bun serve-slides", + "b": "bun build-slides-local", + "help-rmd": "reveal-md --help", + "serve-slides": "reveal-md ./ --watch --absolute-url http://localhost:1948", + "serve-book": "printf '****************************** 👇 ctrl+click to open 👇 ******\\nNon-watching server started @ http://localhost:1949\\n (Close with SIGINT [Ctrl-C])' & bun tools/scripts/devserver.ts ", + "build-slides-local": "rm -rf html-slides && reveal-md ./ --static html-slides", + "build-slides-gh-pages": "rm -rf html-slides && reveal-md ./ --static html-slides --absolute-url https://nuke-web3.github.io/book/" + }, + "dependencies": { + "reveal-md": "^5.5.2" + } +} diff --git a/reveal-md.json b/reveal-md.json new file mode 100644 index 0000000..c2ea19f --- /dev/null +++ b/reveal-md.json @@ -0,0 +1,20 @@ +{ + "title": "Nuke 🌄 's Book", + "theme": "tools/styles/base-theme.css", + "css": [ + "tools/styles/custom-classes.css" + ], + "assetsDir": ".", + "separator": "\r?\n---\r?\n", + "verticalSeparator": "\r?\n---v\r?\n", + "highlightTheme": "shades-of-purple", + "template": "./tools/templates/slide-template.html", + "listingTemplate": "./tools/templates/listing-template.html", + "host": "localhost", + "staticDir": "slides-html", + "staticDirs": [ + "tools" + ], + "preprocessor": null, + "glob": "./content/**/*[Ss]lides.md" +} diff --git a/reveal.json b/reveal.json new file mode 100644 index 0000000..102023f --- /dev/null +++ b/reveal.json @@ -0,0 +1,13 @@ +{ + "width": 1400, + "height": 900, + "margin": 0, + "minScale": 0.2, + "maxScale": 2.0, + "transition": "none", + "controls": true, + "progress": true, + "center": true, + "slideNumber": true, + "backgroundTransition": "fade" +} diff --git a/tools/plugin/chart/chart.js b/tools/plugin/chart/chart.js new file mode 100644 index 0000000..326056e --- /dev/null +++ b/tools/plugin/chart/chart.js @@ -0,0 +1,198 @@ +/***************************************************************** +** Author: Asvin Goel, goel@telematique.eu +** Fixed for Reveal4: kotborealis@awooo.ru +** +** A plugin for reveal.js allowing to integrate Chart.js +** +** Version: 1.3.1 +** +** License: MIT license (see LICENSE.md) +** +******************************************************************/ + +/** + * Reveal Plugin + * https://revealjs.com/creating-plugins/ + */ +window.RevealChart = window.RevealChart || { + id: 'RevealChart', + init: function(deck) { + initChart(deck); + }, + update: function(canvas, idx, data) { update(canvas, idx, data); }, +}; + +const initChart = function(Reveal){ +function parseJSON(str) { + var json; + try { + json = JSON.parse(str); + } catch (e) { + return null; + } + return json; +} + +/* +* Recursively merge properties of two objects +*/ +function mergeRecursive(obj1, obj2) { + + for (var p in obj2) { + try { + // Property in destination object set; update its value. + if ( obj1[p] !== null && typeof obj1[p] === 'object' && typeof obj2[p] === 'object' ) { + obj1[p] = mergeRecursive(obj1[p], obj2[p]); + } + else { + obj1[p] = obj2[p]; + } + } catch(e) { + // Property in destination object not set; create it and set its value. + obj1[p] = obj2[p]; + } + } + + return obj1; +} + + +function createChart(canvas, CSV, comments) { + canvas.chart = null; + var ctx = canvas.getContext("2d"); + var chartOptions = { responsive: true, maintainAspectRatio: false }; + var chartData = { labels: null, datasets: []}; + if ( comments !== null ) for (var j = 0; j < comments.length; j++ ){ + comments[j] = comments[j].replace(//,''); + var config = parseJSON(comments[j]); + if ( config ) { + if ( config.data ) { + mergeRecursive( chartData, config.data); + } + if ( config.options ) { + mergeRecursive( chartOptions, config.options); + } + } + } + + var lines = CSV.split('\n').filter(function(v){return v!==''}); + // if labels are not defined, get them from first line + if ( chartData.labels === null && lines.length > 0 ) { + chartData.labels = lines[0].split(','); + chartData.labels.shift(); + lines.shift(); + } + // get data values + for (var j = 0; j < lines.length; j++ ){ + if (chartData.datasets.length <= j) chartData.datasets[j] = {}; + chartData.datasets[j].data = lines[j].split(','); //.filter(function(v){return v!==''}); + chartData.datasets[j].label = chartData.datasets[j].data[0]; + chartData.datasets[j].data.shift(); + for (var k = 0; k < chartData.datasets[j].data.length; k++ ){ + chartData.datasets[j].data[k] = Number(chartData.datasets[j].data[k]); + } + } + + // add chart options + var config = chartConfig[canvas.getAttribute("data-chart")]; + if ( config ) { + for (var j = 0; j < chartData.datasets.length; j++ ){ + for (var attrname in config) { + if ( !chartData.datasets[j][attrname] ) { + chartData.datasets[j][attrname] = config[attrname][j%config[attrname].length]; + } + } + } + } + + canvas.chart = new Chart(ctx, { type: canvas.getAttribute("data-chart"), data: chartData, options: chartOptions }); + +} + +function updateChart(canvas, idx, data) { + canvas.chart.data.datasets[idx].data = data; + recreateChart( canvas ); +} + +var initializeCharts = function(){ + // Get all canvases + var canvases = document.querySelectorAll("canvas"); + for (var i = 0; i < canvases.length; i++ ){ + // check if canvas has data-chart attribute + if ( canvases[i].hasAttribute("data-chart") ){ + var CSV = canvases[i].innerHTML.trim(); + var comments = CSV.match(//g); + CSV = CSV.replace(//g,'').replace(/^\s*\n/gm, "") + if ( ! canvases[i].hasAttribute("data-chart-src") ) { + createChart(canvases[i], CSV, comments); + } + else { + var canvas = canvases[i]; + var xhr = new XMLHttpRequest(); + xhr.onload = function() { + if (xhr.readyState === 4) { + createChart(canvas, xhr.responseText, comments); + } + else { + console.warn( 'Failed to get file ' + canvas.getAttribute("data-chart-src") +". ReadyState: " + xhr.readyState + ", Status: " + xhr.status); + } + }; + + xhr.open( 'GET', canvas.getAttribute("data-chart-src"), false ); + try { + xhr.send(); + } + catch ( error ) { + console.warn( 'Failed to get file ' + canvas.getAttribute("data-chart-src") + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + error ); + } + } + + } + } +} + +function recreateChart(canvas) { + // clear data to redraw animation + var data = canvas.chart.data.datasets; + canvas.chart.data.datasets = []; + canvas.chart.update(); + canvas.style.visibility = "hidden"; + setTimeout( function(canvas, data) { + canvas.chart.data.datasets = data; + canvas.style.visibility = "visible"; + canvas.chart.update(); + }, 500, canvas, data); // wait for slide transition to re-add data and animation +/* + var config = canvas.chart.config; + canvas.chart.destroy(); + setTimeout( function() { canvas.chart = new Chart(canvas, config);}, 500); // wait for slide transition +*/ +} + +// check if chart option is given or not +var chartConfig = Reveal.getConfig().chart || {}; + +// set global chart options +var config = chartConfig.defaults; +if ( config ) { + mergeRecursive(Chart.defaults, config); +} + +Reveal.addEventListener('ready', function(){ + initializeCharts(); + Reveal.addEventListener('slidechanged', function(){ + var canvases = Reveal.getCurrentSlide().querySelectorAll("canvas[data-chart]"); + for (var i = 0; i < canvases.length; i++ ){ + if ( canvases[i].chart && canvases[i].chart.config.options.animation !== false ) { + recreateChart( canvases[i] ); + } + } + + }); +}); + +this.update = updateChart; + +return this; +}; diff --git a/tools/plugin/chart/chart.min.js b/tools/plugin/chart/chart.min.js new file mode 100644 index 0000000..3d3a0e9 --- /dev/null +++ b/tools/plugin/chart/chart.min.js @@ -0,0 +1,13 @@ +/*! + * Chart.js v3.9.0 + * https://www.chartjs.org + * (c) 2022 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";function t(){}const e=function(){let t=0;return function(){return t++}}();function i(t){return null==t}function s(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function n(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const o=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function a(t,e){return o(t)?t:e}function r(t,e){return void 0===t?e:t}const l=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,h=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function c(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function d(t,e,i,o){let a,r,l;if(s(t))if(r=t.length,o)for(a=r-1;a>=0;a--)e.call(i,t[a],a);else for(a=0;at,x:t=>t.x,y:t=>t.y};function y(t,e){const i=_[e]||(_[e]=function(t){const e=v(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}(e));return i(t)}function v(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function w(t){return t.charAt(0).toUpperCase()+t.slice(1)}const M=t=>void 0!==t,k=t=>"function"==typeof t,S=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function P(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const D=Math.PI,O=2*D,C=O+D,A=Number.POSITIVE_INFINITY,T=D/180,L=D/2,E=D/4,R=2*D/3,I=Math.log10,z=Math.sign;function F(t){const e=Math.round(t);t=N(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(I(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function V(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e)).pop(),e}function B(t){return!isNaN(parseFloat(t))&&isFinite(t)}function N(t,e,i){return Math.abs(t-e)=t}function j(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&h=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function tt(t,e,i){i=i||(i=>t[i]1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const et=(t,e,i,s)=>tt(t,i,s?s=>t[s][e]<=i:s=>t[s][e]tt(t,i,(s=>t[s][e]>=i));function st(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+w(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function at(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(nt.forEach((e=>{delete t[e]})),delete t._chartjs)}function rt(t){const e=new Set;let i,s;for(i=0,s=t.length;iArray.prototype.slice.call(t));let n=!1,o=[];return function(...i){o=s(i),n||(n=!0,lt.call(window,(()=>{n=!1,t.apply(e,o)})))}}function ct(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const dt=t=>"start"===t?"left":"end"===t?"right":"center",ut=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,ft=(t,e,i,s)=>t===(s?"left":"right")?i:"center"===t?(e+i)/2:e;function gt(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=Z(Math.min(et(r,a.axis,h).lo,i?s:et(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?Z(Math.max(et(r,a.axis,c,!0).hi+1,i?0:et(e,l,a.getPixelForValue(c),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function pt(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}var mt=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach((s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=lt.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)o=n[a],o._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}; +/*! + * @kurkle/color v0.2.1 + * https://github.com/kurkle/color#readme + * (c) 2022 Jukka Kurkela + * Released under the MIT License + */function bt(t){return t+.5|0}const xt=(t,e,i)=>Math.max(Math.min(t,i),e);function _t(t){return xt(bt(2.55*t),0,255)}function yt(t){return xt(bt(255*t),0,255)}function vt(t){return xt(bt(t/2.55)/100,0,1)}function wt(t){return xt(bt(100*t),0,100)}const Mt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},kt=[..."0123456789ABCDEF"],St=t=>kt[15&t],Pt=t=>kt[(240&t)>>4]+kt[15&t],Dt=t=>(240&t)>>4==(15&t);function Ot(t){var e=(t=>Dt(t.r)&&Dt(t.g)&&Dt(t.b)&&Dt(t.a))(t)?St:Pt;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}const Ct=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function At(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function Tt(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function Lt(t,e,i){const s=At(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function Et(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=function(t,e,i,s,n){return t===n?(e-i)/s+(e>16&255,o>>8&255,255&o]}return t}(),Nt.transparent=[0,0,0,0]);const e=Nt[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}const jt=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const Ht=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,$t=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function Yt(t,e,i){if(t){let s=Et(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=It(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function Ut(t,e){return t?Object.assign(e||{},t):t}function Xt(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=yt(t[3]))):(e=Ut(t,{r:0,g:0,b:0,a:1})).a=yt(e.a),e}function qt(t){return"r"===t.charAt(0)?function(t){const e=jt.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=e[8]?_t(t):xt(255*t,0,255)}return i=+e[1],s=+e[3],n=+e[5],i=255&(e[2]?_t(i):xt(i,0,255)),s=255&(e[4]?_t(s):xt(s,0,255)),n=255&(e[6]?_t(n):xt(n,0,255)),{r:i,g:s,b:n,a:o}}}(t):Ft(t)}class Kt{constructor(t){if(t instanceof Kt)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=Xt(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*Mt[s[1]],g:255&17*Mt[s[2]],b:255&17*Mt[s[3]],a:5===o?17*Mt[s[4]]:255}:7!==o&&9!==o||(n={r:Mt[s[1]]<<4|Mt[s[2]],g:Mt[s[3]]<<4|Mt[s[4]],b:Mt[s[5]]<<4|Mt[s[6]],a:9===o?Mt[s[7]]<<4|Mt[s[8]]:255})),i=n||Wt(t)||qt(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Ut(this._rgb);return t&&(t.a=vt(t.a)),t}set rgb(t){this._rgb=Xt(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${vt(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Ot(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;const e=Et(t),i=e[0],s=wt(e[1]),n=wt(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${vt(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):void 0}mix(t,e){if(t){const i=this.rgb,s=t.rgb;let n;const o=e===n?.5:e,a=2*o-1,r=i.a-s.a,l=((a*r==-1?a:(a+r)/(1+a*r))+1)/2;n=1-l,i.r=255&l*i.r+n*s.r+.5,i.g=255&l*i.g+n*s.g+.5,i.b=255&l*i.b+n*s.b+.5,i.a=o*i.a+(1-o)*s.a,this.rgb=i}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,i){const s=$t(vt(t.r)),n=$t(vt(t.g)),o=$t(vt(t.b));return{r:yt(Ht(s+i*($t(vt(e.r))-s))),g:yt(Ht(n+i*($t(vt(e.g))-n))),b:yt(Ht(o+i*($t(vt(e.b))-o))),a:t.a+i*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new Kt(this.rgb)}alpha(t){return this._rgb.a=yt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=bt(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Yt(this._rgb,2,t),this}darken(t){return Yt(this._rgb,2,-t),this}saturate(t){return Yt(this._rgb,1,t),this}desaturate(t){return Yt(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=Et(t);i[0]=zt(i[0]+e),i=It(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function Gt(t){return new Kt(t)}function Zt(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Jt(t){return Zt(t)?t:Gt(t)}function Qt(t){return Zt(t)?t:Gt(t).saturate(.5).darken(.1).hexString()}const te=Object.create(null),ee=Object.create(null);function ie(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>Qt(e.backgroundColor),this.hoverBorderColor=(t,e)=>Qt(e.borderColor),this.hoverColor=(t,e)=>Qt(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t)}set(t,e){return se(this,t,e)}get(t){return ie(this,t)}describe(t,e){return se(ee,t,e)}override(t,e){return se(te,t,e)}route(t,e,i,s){const o=ie(this,t),a=ie(this,i),l="_"+e;Object.defineProperties(o,{[l]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[l],e=a[s];return n(t)?Object.assign({},e,t):r(t,e)},set(t){this[l]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});function oe(){return"undefined"!=typeof window&&"undefined"!=typeof document}function ae(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function re(t,e,i){let s;return"string"==typeof t?(s=parseInt(t,10),-1!==t.indexOf("%")&&(s=s/100*e.parentNode[i])):s=t,s}const le=t=>window.getComputedStyle(t,null);function he(t,e){return le(t).getPropertyValue(e)}const ce=["top","right","bottom","left"];function de(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=ce[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}function ue(t,e){if("native"in t)return t;const{canvas:i,currentDevicePixelRatio:s}=e,n=le(i),o="border-box"===n.boxSizing,a=de(n,"padding"),r=de(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.touches,s=i&&i.length?i[0]:t,{offsetX:n,offsetY:o}=s;let a,r,l=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(n,o,t.target))a=n,r=o;else{const t=e.getBoundingClientRect();a=s.clientX-t.left,r=s.clientY-t.top,l=!0}return{x:a,y:r,box:l}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const fe=t=>Math.round(10*t)/10;function ge(t,e,i,s){const n=le(t),o=de(n,"margin"),a=re(n.maxWidth,t,"clientWidth")||A,r=re(n.maxHeight,t,"clientHeight")||A,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=ae(t);if(o){const t=o.getBoundingClientRect(),a=le(o),r=de(a,"border","width"),l=de(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=re(a.maxWidth,o,"clientWidth"),n=re(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||A,maxHeight:n||A}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=de(n,"border","width"),e=de(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=fe(Math.min(h,a,l.maxWidth)),c=fe(Math.min(c,r,l.maxHeight)),h&&!c&&(c=fe(h/2)),{width:h,height:c}}function pe(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const me=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function be(t,e){const i=he(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function xe(t){return!t||i(t.size)||i(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function _e(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function ye(t,e,i,n){let o=(n=n||{}).data=n.data||{},a=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(o=n.data={},a=n.garbageCollect=[],n.font=e),t.save(),t.font=e;let r=0;const l=i.length;let h,c,d,u,f;for(h=0;hi.length){for(h=0;h0&&t.stroke()}}function Se(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==r.strokeColor;let c,d;for(t.save(),t.font=a.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);i(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,r),c=0;ct[0])){M(s)||(s=$e("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>Ee([n,...t],e,i,s)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>Ve(i,s,(()=>function(t,e,i,s){let n;for(const o of e)if(n=$e(ze(o,t),i),M(n))return Fe(t,n)?je(i,s,t,n):n}(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>Ye(t).includes(e),ownKeys:t=>Ye(t),set(t,e,i){const s=t._storage||(t._storage=n());return t[e]=s[e]=i,delete t._keys,!0}})}function Re(t,e,i,o){const a={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:Ie(t,o),setContext:e=>Re(t,e,i,o),override:s=>Re(t.override(s),e,i,o)};return new Proxy(a,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>Ve(t,e,(()=>function(t,e,i){const{_proxy:o,_context:a,_subProxy:r,_descriptors:l}=t;let h=o[e];k(h)&&l.isScriptable(e)&&(h=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),Fe(t,e)&&(e=je(n._scopes,n,t,e));return e}(e,h,t,i));s(h)&&h.length&&(h=function(t,e,i,s){const{_proxy:o,_context:a,_subProxy:r,_descriptors:l}=i;if(M(a.index)&&s(t))e=e[a.index%e.length];else if(n(e[0])){const i=e,s=o._scopes.filter((t=>t!==i));e=[];for(const n of i){const i=je(s,o,t,n);e.push(Re(i,a,r&&r[t],l))}}return e}(e,h,t,l.isIndexable));Fe(e,h)&&(h=Re(h,a,r&&r[e],l));return h}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function Ie(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:k(i)?i:()=>i,isIndexable:k(s)?s:()=>s}}const ze=(t,e)=>t?t+w(e):e,Fe=(t,e)=>n(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function Ve(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function Be(t,e,i){return k(t)?t(e,i):t}const Ne=(t,e)=>!0===t?e:"string"==typeof t?y(e,t):void 0;function We(t,e,i,s,n){for(const o of e){const e=Ne(i,o);if(e){t.add(e);const o=Be(e._fallback,i,n);if(M(o)&&o!==i&&o!==s)return o}else if(!1===e&&M(s)&&i!==s)return null}return!1}function je(t,e,i,o){const a=e._rootScopes,r=Be(e._fallback,i,o),l=[...t,...a],h=new Set;h.add(o);let c=He(h,l,i,r||i,o);return null!==c&&((!M(r)||r===i||(c=He(h,l,r,c,o),null!==c))&&Ee(Array.from(h),[""],a,r,(()=>function(t,e,i){const o=t._getTarget();e in o||(o[e]={});const a=o[e];if(s(a)&&n(i))return i;return a}(e,i,o))))}function He(t,e,i,s,n){for(;i;)i=We(t,e,i,s,n);return i}function $e(t,e){for(const i of e){if(!i)continue;const e=i[t];if(M(e))return e}}function Ye(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function Ue(t,e,i,s){const{iScale:n}=t,{key:o="r"}=this._parsing,a=new Array(s);let r,l,h,c;for(r=0,l=s;re"x"===t?"y":"x";function Ge(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=X(o,n),l=X(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function Ze(t,e="x"){const i=Ke(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=qe(t,0);for(a=0;a!t.skip))),"monotone"===e.cubicInterpolationMode)Ze(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,ei=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*O/i),ii=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*O/i)+1,si={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*L),easeOutSine:t=>Math.sin(t*L),easeInOutSine:t=>-.5*(Math.cos(D*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>ti(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>ti(t)?t:ei(t,.075,.3),easeOutElastic:t=>ti(t)?t:ii(t,.075,.3),easeInOutElastic(t){const e=.1125;return ti(t)?t:t<.5?.5*ei(2*t,e,.45):.5+.5*ii(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-si.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*si.easeInBounce(2*t):.5*si.easeOutBounce(2*t-1)+.5};function ni(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function oi(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function ai(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=ni(t,n,i),r=ni(n,o,i),l=ni(o,e,i),h=ni(a,r,i),c=ni(r,l,i);return ni(h,c,i)}const ri=new Map;function li(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=ri.get(i);return s||(s=new Intl.NumberFormat(t,e),ri.set(i,s)),s}(e,i).format(t)}const hi=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),ci=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function di(t,e){const i=(""+t).match(hi);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function ui(t,e){const i={},s=n(e),o=s?Object.keys(e):e,a=n(t)?s?i=>r(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of o)i[t]=+a(t)||0;return i}function fi(t){return ui(t,{top:"y",right:"x",bottom:"y",left:"x"})}function gi(t){return ui(t,["topLeft","topRight","bottomLeft","bottomRight"])}function pi(t){const e=fi(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function mi(t,e){t=t||{},e=e||ne.font;let i=r(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=r(t.style,e.style);s&&!(""+s).match(ci)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:r(t.family,e.family),lineHeight:di(r(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:r(t.weight,e.weight),string:""};return n.string=xe(n),n}function bi(t,e,i,n){let o,a,r,l=!0;for(o=0,a=t.length;oi&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function _i(t,e){return Object.assign(Object.create(t),e)}function yi(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function vi(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function wi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Mi(t){return"angle"===t?{between:G,compare:q,normalize:K}:{between:Q,compare:(t,e)=>t-e,normalize:t=>t}}function ki({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Si(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Mi(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Mi(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hx||l(n,b,p)&&0!==r(n,b),v=()=>!x||0===r(o,p)||l(o,b,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(ki({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,b=p));return null!==_&&g.push(ki({start:_,end:d,loop:u,count:a,style:f})),g}function Pi(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}(i,n,o,s);if(!0===s)return Oi(t,[{start:a,end:r,loop:o}],i,e);return Oi(t,function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,r{t[a](e[i],n)&&(o.push({element:t,datasetIndex:s,index:l}),r=r||t.inRange(e.x,e.y,n))})),s&&!r?[]:o}var Vi={evaluateInteractionItems:Ei,modes:{index(t,e,i,s){const n=ue(e,t),o=i.axis||"x",a=i.includeInvisible||!1,r=i.intersect?Ri(t,n,o,s,a):zi(t,n,o,!1,s,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,i=t.data[e];i&&!i.skip&&l.push({element:i,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,i,s){const n=ue(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;let r=i.intersect?Ri(t,n,o,s,a):zi(t,n,o,!1,s,a);if(r.length>0){const e=r[0].datasetIndex,i=t.getDatasetMeta(e).data;r=[];for(let t=0;tRi(t,ue(e,t),i.axis||"xy",s,i.includeInvisible||!1),nearest(t,e,i,s){const n=ue(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;return zi(t,n,o,i.intersect,s,a)},x:(t,e,i,s)=>Fi(t,ue(e,t),"x",i.intersect,s),y:(t,e,i,s)=>Fi(t,ue(e,t),"y",i.intersect,s)}};const Bi=["left","top","right","bottom"];function Ni(t,e){return t.filter((t=>t.pos===e))}function Wi(t,e){return t.filter((t=>-1===Bi.indexOf(t.pos)&&t.box.axis===e))}function ji(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function Hi(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!Bi.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function qi(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize)),!0),s=ji(Ni(e,"left"),!0),n=ji(Ni(e,"right")),o=ji(Ni(e,"top"),!0),a=ji(Ni(e,"bottom")),r=Wi(e,"x"),l=Wi(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ni(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;d(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,u=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),f=Object.assign({},n);Yi(f,pi(s));const g=Object.assign({maxPadding:f,w:o,h:a,x:n.left,y:n.top},n),p=Hi(l.concat(h),u);qi(r.fullSize,g,u,p),qi(l,g,u,p),qi(h,g,u,p)&&qi(l,g,u,p),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(g),Gi(r.leftAndTop,g,u,p),g.x+=g.w,g.y+=g.h,Gi(r.rightAndBottom,g,u,p),t.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},d(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class Ji{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Qi extends Ji{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const ts={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},es=t=>null===t||""===t;const is=!!me&&{passive:!0};function ss(t,e,i){t.canvas.removeEventListener(e,i,is)}function ns(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function os(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||ns(i.addedNodes,s),e=e&&!ns(i.removedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function as(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||ns(i.removedNodes,s),e=e&&!ns(i.addedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const rs=new Map;let ls=0;function hs(){const t=window.devicePixelRatio;t!==ls&&(ls=t,rs.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function cs(t,e,i){const s=t.canvas,n=s&&ae(s);if(!n)return;const o=ht(((t,e)=>{const s=n.clientWidth;i(t,e),s{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||o(i,s)}));return a.observe(n),function(t,e){rs.size||window.addEventListener("resize",hs),rs.set(t,e)}(t,o),a}function ds(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){rs.delete(t),rs.size||window.removeEventListener("resize",hs)}(t)}function us(t,e,i){const s=t.canvas,n=ht((e=>{null!==t.ctx&&i(function(t,e){const i=ts[t.type]||t.type,{x:s,y:n}=ue(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))}),t,(t=>{const e=t[0];return[e,e.offsetX,e.offsetY]}));return function(t,e,i){t.addEventListener(e,i,is)}(s,e,n),n}class fs extends Ji{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",es(n)){const e=be(t,"width");void 0!==e&&(t.width=e)}if(es(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=be(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const s=e.$chartjs.initial;["height","width"].forEach((t=>{const n=s[t];i(n)?e.removeAttribute(t):e.setAttribute(t,n)}));const n=s.style||{};return Object.keys(n).forEach((t=>{e.style[t]=n[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:os,detach:as,resize:cs}[e]||us;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:ds,detach:ds,resize:ds}[e]||ss)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return ge(t,e,i,s)}isAttached(t){const e=ae(t);return!(!e||!e.isConnected)}}function gs(t){return!oe()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Qi:fs}var ps=Object.freeze({__proto__:null,_detectPlatform:gs,BasePlatform:Ji,BasicPlatform:Qi,DomPlatform:fs});const ms="transparent",bs={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=Jt(t||ms),n=s.valid&&Jt(e||ms);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class xs{constructor(t,e,i,s){const n=e[i];s=bi([t.to,s,n,t.from]);const o=bi([t.from,n,s]);this._active=!0,this._fn=t.fn||bs[t.type||typeof o],this._easing=si[t.easing]||si.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=bi([t.to,e,s,t.from]),this._from=bi([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),ne.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),ne.describe("animations",{_fallback:"animation"}),ne.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class ys{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!n(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const o=t[i];if(!n(o))return;const a={};for(const t of _s)a[t]=o[t];(s(o.properties)&&o.properties||[i]).forEach((t=>{t!==i&&e.has(t)||e.set(t,a)}))}))}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new xs(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(mt.add(this._chart,i),!0):void 0}}function vs(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function ws(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function Ds(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e)).shift()}function Cs(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const As=t=>"reset"===t||"none"===t,Ts=(t,e)=>e?t:Object.assign({},t);class Ls{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ks(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&Cs(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=r(i.xAxisID,Os(t,"x")),o=e.yAxisID=r(i.yAxisID,Os(t,"y")),a=e.rAxisID=r(i.rAxisID,Os(t,"r")),l=e.indexAxis,h=e.iAxisID=s(l,n,o,a),c=e.vAxisID=s(l,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(h),e.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&at(this._data,this),t._stacked&&Cs(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(n(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=o,i._sorted=!0,d=o;else{d=s(o[t])?this.parseArrayData(i,o,t,e):n(o[t])?this.parseObjectData(i,o,t,e):this.parsePrimitiveData(i,o,t,e);const a=()=>null===c[l]||f&&c[l]t&&!e.hidden&&e._stacked&&{keys:ws(i,!0),values:null})(e,i,this.chart),h={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=function(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}(r);let u,f;function g(){f=s[u];const e=f[r.axis];return!o(f[t.axis])||c>e||d=0;--u)if(!g()){this.updateRangeFromParsed(h,t,f,l);break}return h}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,a;for(s=0,n=e.length;s=0&&tthis.getContext(i,s)),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Ts(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new ys(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||As(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,n=this.getSharedOptions(i),o=this.includeOptions(e,n)||n!==s;return this.updateSharedOptions(n,e,i),{sharedOptions:n,includeOptions:o}}updateElement(t,e,i,s){As(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!As(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}Es.defaults={},Es.defaultRoutes=void 0;const Rs={values:t=>s(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=I(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),li(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(I(t)));return 1===s||2===s||5===s?Rs.numeric.call(this,t,e,i):""}};var Is={formatters:Rs};function zs(t,e){const s=t.options.ticks,n=s.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),o=s.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;in)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(o,e,n);if(a>0){let t,s;const n=a>1?Math.round((l-r)/(a-1)):null;for(Fs(e,h,c,i(n)?0:r-n,r),t=0,s=a-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Is.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),ne.route("scale.ticks","color","","color"),ne.route("scale.grid","color","","borderColor"),ne.route("scale.grid","borderColor","","borderColor"),ne.route("scale.title","color","","color"),ne.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),ne.describe("scales",{_fallback:"scale"}),ne.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const Vs=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Bs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+r)))return h}function Ws(t){return t.drawTicks?t.tickLength:0}function js(t,e){if(!t.display)return 0;const i=mi(t.font,e),n=pi(t.padding);return(s(t.text)?t.text.length:1)*i.lineHeight+n.height}function Hs(t,e,i){let s=dt(t);return(i&&"right"!==e||!i&&"right"===e)&&(s=(t=>"left"===t?"right":"right"===t?"left":t)(s)),s}class $s extends Es{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=a(t,Number.POSITIVE_INFINITY),e=a(e,Number.NEGATIVE_INFINITY),i=a(i,Number.POSITIVE_INFINITY),s=a(s,Number.NEGATIVE_INFINITY),{min:a(t,i),max:a(e,s),minDefined:o(t),maxDefined:o(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const r=this.getMatchingVisibleMetas();for(let a=0,l=r.length;as?s:i,s=n&&i>s?i:s,{min:a(i,a(s,i)),max:a(s,a(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){c(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=xi(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=Z(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Ws(t.grid)-e.padding-js(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=$(Math.min(Math.asin(Z((h.highest.height+6)/o,-1,1)),Math.asin(Z(a/r,-1,1))-Math.asin(Z(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){c(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){c(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=js(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ws(n)+o):(t.height=this.maxHeight,t.width=Ws(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=H(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:"inner"!==n&&(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){c(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,s;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,s=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:a[t]||0,height:r[t]||0});return{first:k(0),last:k(e-1),widest:k(w),highest:k(M),widths:a,heights:r}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return J(this._alignToPixels?ve(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:o,position:a}=s,l=o.offset,h=this.isHorizontal(),c=this.ticks.length+(l?1:0),d=Ws(o),u=[],f=o.setContext(this.getContext()),g=f.drawBorder?f.borderWidth:0,p=g/2,m=function(t){return ve(i,t,g)};let b,x,_,y,v,w,M,k,S,P,D,O;if("top"===a)b=m(this.bottom),w=this.bottom-d,k=b-p,P=m(t.top)+p,O=t.bottom;else if("bottom"===a)b=m(this.top),P=t.top,O=m(t.bottom)-p,w=b+p,k=this.top+d;else if("left"===a)b=m(this.right),v=this.right-d,M=b-p,S=m(t.left)+p,D=t.right;else if("right"===a)b=m(this.left),S=t.left,D=m(t.right)-p,v=b+p,M=this.left+d;else if("x"===e){if("center"===a)b=m((t.top+t.bottom)/2+.5);else if(n(a)){const t=Object.keys(a)[0],e=a[t];b=m(this.chart.scales[t].getPixelForValue(e))}P=t.top,O=t.bottom,w=b+p,k=w+d}else if("y"===e){if("center"===a)b=m((t.left+t.right)/2);else if(n(a)){const t=Object.keys(a)[0],e=a[t];b=m(this.chart.scales[t].getPixelForValue(e))}v=b-p,M=v-d,S=t.left,D=t.right}const C=r(s.ticks.maxTicksLimit,c),A=Math.max(1,Math.ceil(c/C));for(x=0;xe.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");ne.route(o,n,l,r)}))}(e,t.defaultRoutes);t.descriptors&&ne.describe(e,t.descriptors)}(t,o,i),this.override&&ne.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in ne[s]&&(delete ne[s][i],this.override&&delete te[i])}}var Us=new class{constructor(){this.controllers=new Ys(Ls,"datasets",!0),this.elements=new Ys(Es,"elements"),this.plugins=new Ys(Object,"plugins"),this.scales=new Ys($s,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):d(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=w(t);c(i["before"+s],[],i),e[t](i),c(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function qs(t,e){return e||!1!==t?!0===t?{}:t:null}function Ks(t,{plugin:e,local:i},s,n){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(s,o);return i&&e.defaults&&a.push(e.defaults),t.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Gs(t,e){const i=ne.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Zs(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Js(t){const e=t.options||(t.options={});e.plugins=r(e.plugins,{}),e.scales=function(t,e){const i=te[t.type]||{scales:{}},s=e.scales||{},o=Gs(t.type,e),a=Object.create(null),r=Object.create(null);return Object.keys(s).forEach((t=>{const e=s[t];if(!n(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const l=Zs(t,e),h=function(t,e){return t===e?"_index_":"_value_"}(l,o),c=i.scales||{};a[l]=a[l]||t,r[t]=b(Object.create(null),[{axis:l},e,c[l],c[h]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,o=i.indexAxis||Gs(n,e),l=(te[n]||{}).scales||{};Object.keys(l).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,o),n=i[e+"AxisID"]||a[e]||e;r[n]=r[n]||Object.create(null),b(r[n],[{axis:e},s[n],l[t]])}))})),Object.keys(r).forEach((t=>{const e=r[t];b(e,[ne.scales[e.type],ne.scale])})),r}(t,e)}function Qs(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const tn=new Map,en=new Set;function sn(t,e){let i=tn.get(t);return i||(i=e(),tn.set(t,i),en.add(i)),i}const nn=(t,e,i)=>{const s=y(e,i);void 0!==s&&t.add(s)};class on{constructor(t){this._config=function(t){return(t=t||{}).data=Qs(t.data),Js(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Qs(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Js(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return sn(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return sn(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return sn(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return sn(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>nn(r,t,e)))),e.forEach((t=>nn(r,s,t))),e.forEach((t=>nn(r,te[n]||{},t))),e.forEach((t=>nn(r,ne,t))),e.forEach((t=>nn(r,ee,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),en.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,te[e]||{},ne.datasets[e]||{},{type:e},ne,ee]}resolveNamedOptions(t,e,i,n=[""]){const o={$shared:!0},{resolver:a,subPrefixes:r}=an(this._resolverCache,t,n);let l=a;if(function(t,e){const{isScriptable:i,isIndexable:n}=Ie(t);for(const o of e){const e=i(o),a=n(o),r=(a||e)&&t[o];if(e&&(k(r)||rn(r))||a&&s(r))return!0}return!1}(a,e)){o.$shared=!1;l=Re(a,i=k(i)?i():i,this.createResolver(t,i,r))}for(const t of e)o[t]=l[t];return o}createResolver(t,e,i=[""],s){const{resolver:o}=an(this._resolverCache,t,i);return n(e)?Re(o,e,void 0,s):o}}function an(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:Ee(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const rn=t=>n(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||k(t[i])),!1);const ln=["top","bottom","left","right","chartArea"];function hn(t,e){return"top"===t||"bottom"===t||-1===ln.indexOf(t)&&"x"===e}function cn(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function dn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),c(i&&i.onComplete,[t],e)}function un(t){const e=t.chart,i=e.options.animation;c(i&&i.onProgress,[t],e)}function fn(t){return oe()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const gn={},pn=t=>{const e=fn(t);return Object.values(gn).filter((t=>t.canvas===e)).pop()};function mn(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}class bn{constructor(t,i){const s=this.config=new on(i),n=fn(t),o=pn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||gs(n)),this.platform.updateConfig(s);const r=this.platform.acquireContext(n,a.aspectRatio),l=r&&r.canvas,h=l&&l.height,c=l&&l.width;this.id=e(),this.ctx=r,this.canvas=l,this.width=c,this.height=h,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Xs,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ct((t=>this.update(t)),a.resizeDelay||0),this._dataChanges=[],gn[this.id]=this,r&&l?(mt.listen(this,"complete",dn),mt.listen(this,"progress",un),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:n,_aspectRatio:o}=this;return i(t)?e&&o?o:n?s/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():pe(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return we(this.canvas,this.ctx),this}stop(){return mt.stop(this),this}resize(t,e){mt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,pe(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),c(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){d(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=Zs(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),d(n,(e=>{const n=e.options,o=n.id,a=Zs(o,n),l=r(n.type,e.dtype);void 0!==n.position&&hn(n.position,a)===hn(e.dposition)||(n.position=e.dposition),s[o]=!0;let h=null;if(o in i&&i[o].type===l)h=i[o];else{h=new(Us.getScale(l))({id:o,type:l,ctx:this.ctx,chart:this}),i[h.id]=h}h.init(n,t)})),d(s,((t,e)=>{t||delete i[e]})),d(i,(t=>{Zi.configure(this,t,t.options),Zi.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(cn("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){d(this.scales,(t=>{Zi.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);S(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){mn(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),s=i(0);for(let t=1;tt.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;Zi.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],d(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Pe(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&De(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(t){return Se(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const n=Vi.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=_i(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);M(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),mt.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};d(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){d(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},d(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!u(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:n}=this,o=e,a=this._getActiveElements(t,s,i,o),r=P(t),l=function(t,e,i,s){return i&&"mouseout"!==t.type?s?e:t:null}(t,this._lastEvent,i,r);i&&(this._lastEvent=null,c(n.onHover,[t,a,this],this),r&&c(n.onClick,[t,a,this],this));const h=!u(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=l,h}_getActiveElements(t,e,i,s){if("mouseout"===t.type)return[];if(!i)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,s)}}const xn=()=>d(bn.instances,(t=>t._plugins.invalidate())),_n=!0;function yn(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(bn,{defaults:{enumerable:_n,value:ne},instances:{enumerable:_n,value:gn},overrides:{enumerable:_n,value:te},registry:{enumerable:_n,value:Us},version:{enumerable:_n,value:"3.9.0"},getChart:{enumerable:_n,value:pn},register:{enumerable:_n,value:(...t)=>{Us.add(...t),xn()}},unregister:{enumerable:_n,value:(...t)=>{Us.remove(...t),xn()}}});class vn{constructor(t){this.options=t||{}}init(t){}formats(){return yn()}parse(t,e){return yn()}format(t,e){return yn()}add(t,e,i){return yn()}diff(t,e,i){return yn()}startOf(t,e,i){return yn()}endOf(t,e){return yn()}}vn.override=function(t){Object.assign(vn.prototype,t)};var wn={_date:vn};function Mn(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e)))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(M(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,n):e[i.axis]=i.parse(t,n),e}function Sn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.baset.controller.options.grouped)),o=s.options.stacked,a=[],r=t=>{const s=t.controller.getParsed(e),n=s&&s[t.vScale.axis];if(i(n)||isNaN(n))return!0};for(const i of n)if((void 0===e||!r(i))&&((!1===o||-1===a.indexOf(i.stack)||void 0===o&&void 0===i.stack)&&a.push(i.stack),i.index===t))break;return a.length||a.push(void 0),a}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),n=void 0!==e?s.indexOf(e):-1;return-1===n?s.length-1:n}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let n,o;for(n=0,o=e.data.length;n=i?1:-1)}(d,e,a)*o,u===a&&(m-=d/2);const t=e.getPixelForDecimal(0),i=e.getPixelForDecimal(1),s=Math.min(t,i),n=Math.max(t,i);m=Math.max(Math.min(m,n),s),c=m+d}if(m===e.getPixelForValue(a)){const t=z(d)*e.getLineWidthForValue(a)/2;m+=t,d-=t}return{size:d,base:m,head:c,center:c+d/2}}_calculateBarIndexPixels(t,e){const s=e.scale,n=this.options,o=n.skipNull,a=r(n.maxBarThickness,1/0);let l,h;if(e.grouped){const s=o?this._getStackCount(t):e.stackCount,r="flex"===n.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,s),h=o.axis,c=a.axis;for(let d=e;d""}}}};class En extends Ls{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let o,a,r=t=>+i[t];if(n(i[t])){const{key:t="value"}=this._parsing;r=e=>+y(i[e],t)}for(o=t,a=t+e;oG(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>G(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(L,c,u),b=g(D,h,d),x=g(D+L,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(u,d,r),b=(i.width-o)/f,x=(i.height-o)/g,_=Math.max(Math.min(b,x)/2,0),y=h(this.options.radius,_),v=(y-Math.max(y*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*y,this.offsetY=m*y,s.total=this.calculateTotal(),this.outerRadius=y-v*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-v*c,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/O)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,{sharedOptions:f,includeOptions:g}=this._getSharedOptions(e,s);let p,m=this._getRotation();for(p=0;p0&&!isNaN(t)?O*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=li(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},En.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return s(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class Rn extends Ls{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=gt(e,s,o);this._drawStart=a,this._drawCount=r,pt(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,s,n){const o="reset"===n,{iScale:a,vScale:r,_stacked:l,_dataset:h}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(e,n),u=a.axis,f=r.axis,{spanGaps:g,segment:p}=this.options,m=B(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||"none"===n;let x=e>0&&this.getParsed(e-1);for(let g=e;g0&&Math.abs(s[u]-x[u])>m,p&&(_.parsed=s,_.raw=h.data[g]),d&&(_.options=c||this.resolveDataElementOptions(g,e.active?"active":n)),b||this.updateElement(e,g,_,n),x=s}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Rn.id="line",Rn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Rn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class In extends Ls{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=li(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}parseObjectData(t,e,i,s){return Ue.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach(((t,i)=>{const s=this.getParsed(i).r;!isNaN(s)&&this.chart.getDataVisibility(i)&&(se.max&&(e.max=s))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,h=r.yCenter,c=r.getIndexAngle(0)-.5*D;let d,u=c;const f=360/this.countVisibleElements();for(d=0;d{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++})),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?H(this.resolveDataElementOptions(t,e).angle||i):0}}In.id="polarArea",In.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},In.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class zn extends En{}zn.id="pie",zn.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class Fn extends Ls{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,s){return Ue.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this._cachedMeta.rScale,o="reset"===s;for(let a=e;a0&&this.getParsed(e-1);for(let c=e;c0&&Math.abs(s[f]-_[f])>b,m&&(p.parsed=s,p.raw=h.data[c]),u&&(p.options=d||this.resolveDataElementOptions(c,e.active?"active":n)),x||this.updateElement(e,c,p,n),_=s}this.updateSharedOptions(d,n,c)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let i=e.length-1;i>=0;--i)t=Math.max(t,e[i].size(this.resolveDataElementOptions(i))/2);return t>0&&t}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const n=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,n,o)/2}}Vn.id="scatter",Vn.defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1},Vn.overrides={interaction:{mode:"point"},plugins:{tooltip:{callbacks:{title:()=>"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Bn=Object.freeze({__proto__:null,BarController:Tn,BubbleController:Ln,DoughnutController:En,LineController:Rn,PolarAreaController:In,PieController:zn,RadarController:Fn,ScatterController:Vn});function Nn(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+L,s-L),t.closePath(),t.clip()}function Wn(t,e,i,s){const n=ui(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return Z(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Z(n.innerStart,0,a),innerEnd:Z(n.innerEnd,0,a)}}function jn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function Hn(t,e,i,s,n,o){const{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:c}=e,d=Math.max(e.outerRadius+s+i-h,0),u=c>0?c+s+i+h:0;let f=0;const g=n-l;if(s){const t=((c>0?c-s:0)+(d>0?d-s:0))/2;f=(g-(0!==t?g*t/(t+s):g))/2}const p=(g-Math.max(.001,g*d-i/D)/d)/2,m=l+p+f,b=n-p-f,{outerStart:x,outerEnd:_,innerStart:y,innerEnd:v}=Wn(e,u,d,b-m),w=d-x,M=d-_,k=m+x/w,S=b-_/M,P=u+y,O=u+v,C=m+y/P,A=b-v/O;if(t.beginPath(),o){if(t.arc(a,r,d,k,S),_>0){const e=jn(M,S,a,r);t.arc(e.x,e.y,_,S,b+L)}const e=jn(O,b,a,r);if(t.lineTo(e.x,e.y),v>0){const e=jn(O,A,a,r);t.arc(e.x,e.y,v,b+L,A+Math.PI)}if(t.arc(a,r,u,b-v/u,m+y/u,!0),y>0){const e=jn(P,C,a,r);t.arc(e.x,e.y,y,C+Math.PI,m-L)}const i=jn(w,m,a,r);if(t.lineTo(i.x,i.y),x>0){const e=jn(w,k,a,r);t.arc(e.x,e.y,x,m-L,k)}}else{t.moveTo(a,r);const e=Math.cos(k)*d+a,i=Math.sin(k)*d+r;t.lineTo(e,i);const s=Math.cos(S)*d+a,n=Math.sin(S)*d+r;t.lineTo(s,n)}t.closePath()}function $n(t,e,i,s,n,o){const{options:a}=e,{borderWidth:r,borderJoinStyle:l}=a,h="inner"===a.borderAlign;r&&(h?(t.lineWidth=2*r,t.lineJoin=l||"round"):(t.lineWidth=r,t.lineJoin=l||"bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&Nn(t,e,o+O),t.beginPath(),t.arc(s,n,h,o+O,o,!0),c=0;c=O||G(n,a,l),g=Q(o,h+u,c+u);return f&&g}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>O?Math.floor(i/O):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let a=0;if(s){a=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*a,Math.sin(e)*a),this.circumference>=D&&(a=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const r=function(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){Hn(t,e,i,s,a+O,n);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[x(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,f=g=i),p=i}_()}function Zn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Gn:Kn}Yn.id="arc",Yn.defaults={borderAlign:"center",borderColor:"#fff",borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0},Yn.defaultRoutes={backgroundColor:"backgroundColor"};const Jn="function"==typeof Path2D;function Qn(t,e,i,s){Jn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Un(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Zn(e);for(const r of n)Un(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class to extends Es{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Qe(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Di(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=Pi(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?oi:t.tension||"monotone"===t.cubicInterpolationMode?ai:ni}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class io extends Es{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2){uo(t)}))}var go={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,s)=>{if(!s.enabled)return void fo(t);const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:a,indexAxis:r}=e,l=t.getDatasetMeta(o),h=a||e.data;if("y"===bi([r,t.options.indexAxis]))return;if(!l.controller.supportsDecimation)return;const c=t.scales[l.xAxisID];if("linear"!==c.type&&"time"!==c.type)return;if(t.options.parsing)return;let{start:d,count:u}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=Z(et(e,o.axis,a).lo,0,i-1)),s=h?Z(et(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}(l,h);if(u<=(s.threshold||4*n))return void uo(e);let f;switch(i(a)&&(e._data=h,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),s.algorithm){case"lttb":f=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(h,d,u,n,s);break;case"min-max":f=function(t,e,s,n){let o,a,r,l,h,c,d,u,f,g,p=0,m=0;const b=[],x=e+s-1,_=t[e].x,y=t[x].x-_;for(o=e;og&&(g=l,d=o),p=(m*p+a.x)/++m;else{const s=o-1;if(!i(c)&&!i(d)){const e=Math.min(c,d),i=Math.max(c,d);e!==u&&e!==s&&b.push({...t[e],x:p}),i!==u&&i!==s&&b.push({...t[i],x:p})}o>0&&s!==u&&b.push(t[s]),b.push(a),h=e,m=0,f=g=l,c=d=u=o}}return b}(h,d,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${s.algorithm}'`)}e._decimated=f}))},destroy(t){fo(t)}};function po(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=K(n),o=K(o)),{property:t,start:n,end:o}}function mo(t,e,i){for(;e>t;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function bo(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function xo(t,e){let i=[],n=!1;return s(t)?(n=!0,i=t):i=function(t,e){const{x:i=null,y:s=null}=t||{},n=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=mo(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}(t,e),i.length?new to({points:i,options:{tension:0},_loop:n,_fullLoop:n}):null}function _o(t){return t&&!1!==t.fill}function yo(t,e,i){let s=t[e].fill;const n=[e];let a;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!o(s))return s;if(a=t[s],!a)return!1;if(a.visible)return s;n.push(s),s=a.fill}return!1}function vo(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=r(i&&i.target,i);void 0===s&&(s=!!e.backgroundColor);if(!1===s||null===s)return!1;if(!0===s)return"origin";return s}(t);if(n(s))return!isNaN(s.value)&&s;let a=parseFloat(s);return o(a)&&Math.floor(a)===a?function(t,e,i,s){"-"!==t&&"+"!==t||(i=e+i);if(i===e||i<0||i>=s)return!1;return i}(s[0],e,a,i):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function wo(t,e,i){const s=[];for(let n=0;n=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&i.fill&&Po(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;_o(i)&&Po(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;_o(s)&&"beforeDatasetDraw"===i.drawTime&&Po(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Lo=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}};class Eo extends Es{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=c(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=mi(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=Lo(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach(((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:n}}=this,o=yi(n,this.left,this.width);if(this.isHorizontal()){let n=0,a=ut(i,this.left+s,this.right-this.lineWidths[n]);for(const r of e)n!==r.row&&(n=r.row,a=ut(i,this.left+s,this.right-this.lineWidths[n])),r.top+=this.top+t+s,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+s}else{let n=0,a=ut(i,this.top+t+s,this.bottom-this.columnSizes[n].height);for(const r of e)r.col!==n&&(n=r.col,a=ut(i,this.top+t+s,this.bottom-this.columnSizes[n].height)),r.top=a,r.left+=this.left+s,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Pe(t,this),this._draw(),De(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:n,labels:o}=t,a=ne.color,l=yi(t.rtl,this.left,this.width),h=mi(o.font),{color:c,padding:d}=o,u=h.size,f=u/2;let g;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=h.string;const{boxWidth:p,boxHeight:m,itemHeight:b}=Lo(o,u),x=this.isHorizontal(),_=this._computeTitleHeight();g=x?{x:ut(n,this.left+d,this.right-i[0]),y:this.top+d+_,line:0}:{x:this.left+d,y:ut(n,this.top+_+d,this.bottom-e[0].height),line:0},vi(this.ctx,t.textDirection);const y=b+d;this.legendItems.forEach(((v,w)=>{s.strokeStyle=v.fontColor||c,s.fillStyle=v.fontColor||c;const M=s.measureText(v.text).width,k=l.textAlign(v.textAlign||(v.textAlign=o.textAlign)),S=p+f+M;let P=g.x,D=g.y;l.setWidth(this.width),x?w>0&&P+S+d>this.right&&(D=g.y+=y,g.line++,P=g.x=ut(n,this.left+d,this.right-i[g.line])):w>0&&D+y>this.bottom&&(P=g.x=P+e[g.line].width+d,g.line++,D=g.y=ut(n,this.top+_+d,this.bottom-e[g.line].height));!function(t,e,i){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;s.save();const n=r(i.lineWidth,1);if(s.fillStyle=r(i.fillStyle,a),s.lineCap=r(i.lineCap,"butt"),s.lineDashOffset=r(i.lineDashOffset,0),s.lineJoin=r(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=r(i.strokeStyle,a),s.setLineDash(r(i.lineDash,[])),o.usePointStyle){const a={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},r=l.xPlus(t,p/2);ke(s,a,r,e+f,o.pointStyleWidth&&p)}else{const o=e+Math.max((u-m)/2,0),a=l.leftForLtr(t,p),r=gi(i.borderRadius);s.beginPath(),Object.values(r).some((t=>0!==t))?Le(s,{x:a,y:o,w:p,h:m,radius:r}):s.rect(a,o,p,m),s.fill(),0!==n&&s.stroke()}s.restore()}(l.x(P),D,v),P=ft(k,P+p+f,x?P+S:this.right,t.rtl),function(t,e,i){Ae(s,i.text,t,e+b/2,h,{strikethrough:i.hidden,textAlign:l.textAlign(i.textAlign)})}(l.x(P),D,v),x?g.x+=S+d:g.y+=y})),wi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=mi(e.font),s=pi(e.padding);if(!e.display)return;const n=yi(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=i.size/2,l=s.top+r;let h,c=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),h=this.top+l,c=ut(t.align,c,this.right-d);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);h=l+ut(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=ut(a,c,c+d);o.textAlign=n.textAlign(dt(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=i.string,Ae(o,e.text,u,h,i)}_computeTitleHeight(){const t=this.options.title,e=mi(t.font),i=pi(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(Q(t,this.left,this.right)&&Q(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;it.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const a=t.controller.getStyle(i?0:void 0),r=pi(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Io extends Es{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const n=s(i.text)?i.text.length:1;this._padding=pi(i.padding);const o=n*mi(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:n,options:o}=this,a=o.align;let r,l,h,c=0;return this.isHorizontal()?(l=ut(a,i,n),h=e+t,r=n-i):("left"===o.position?(l=i+t,h=ut(a,s,e),c=-.5*D):(l=n-t,h=ut(a,e,s),c=.5*D),r=s-e),{titleX:l,titleY:h,maxWidth:r,rotation:c}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=mi(e.font),s=i.lineHeight/2+this._padding.top,{titleX:n,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(s);Ae(t,e.text,0,0,i,{color:e.color,maxWidth:a,rotation:r,textAlign:dt(e.align),textBaseline:"middle",translation:[n,o]})}}var zo={id:"title",_element:Io,start(t,e,i){!function(t,e){const i=new Io({ctx:t.ctx,options:e,chart:t});Zi.configure(t,i,e),Zi.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;Zi.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;Zi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Fo=new WeakMap;var Vo={id:"subtitle",start(t,e,i){const s=new Io({ctx:t.ctx,options:i,chart:t});Zi.configure(t,s,i),Zi.addBox(t,s),Fo.set(t,s)},stop(t){Zi.removeBox(t,Fo.get(t)),Fo.delete(t)},beforeUpdate(t,e,i){const s=Fo.get(t);Zi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Bo={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function jo(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Ho(t,e){const i=t.chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=mi(e.bodyFont),h=mi(e.titleFont),c=mi(e.footerFont),u=o.length,f=n.length,g=s.length,p=pi(e.padding);let m=p.height,b=0,x=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(x+=t.beforeBody.length+t.afterBody.length,u&&(m+=u*h.lineHeight+(u-1)*e.titleSpacing+e.titleMarginBottom),x){m+=g*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(x-g)*l.lineHeight+(x-1)*e.bodySpacing}f&&(m+=e.footerMarginTop+f*c.lineHeight+(f-1)*e.footerSpacing);let _=0;const y=function(t){b=Math.max(b,i.measureText(t).width+_)};return i.save(),i.font=h.string,d(t.title,y),i.font=l.string,d(t.beforeBody.concat(t.afterBody),y),_=e.displayColors?a+2+e.boxPadding:0,d(s,(t=>{d(t.before,y),d(t.lines,y),d(t.after,y)})),_=0,i.font=c.string,d(t.footer,y),i.restore(),b+=p.width,{width:b,height:m}}function $o(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Yo(t,e,i){const s=i.yAlign||e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:i.xAlign||e.xAlign||$o(t,e,i,s),yAlign:s}}function Uo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=gi(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+n:"right"===r&&(g+=Math.max(d,f)+n),{x:Z(g,0,s.width-e.width),y:Z(p,0,s.height-e.height)}}function Xo(t,e,i){const s=pi(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function qo(t){return No([],Wo(t))}function Ko(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Go extends Es{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart||t._chart,this._chart=this.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new ys(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this.chart.getContext(),e=this,i=this._tooltipItems,_i(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=No(a,Wo(s)),a=No(a,Wo(n)),a=No(a,Wo(o)),a}getBeforeBody(t,e){return qo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return d(t,(t=>{const e={before:[],lines:[],after:[]},n=Ko(i,t);No(e.before,Wo(n.beforeLabel.call(this,t))),No(e.lines,n.label.call(this,t)),No(e.after,Wo(n.afterLabel.call(this,t))),s.push(e)})),s}getAfterBody(t,e){return qo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=No(a,Wo(s)),a=No(a,Wo(n)),a=No(a,Wo(o)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),d(l,(e=>{const i=Ko(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Bo[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Ho(this,i),a=Object.assign({},t,e),r=Yo(this.chart,i,a),l=Uo(i,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=gi(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,b,x,_,y;return"center"===n?(_=u+g/2,"left"===s?(p=d,m=p-o,x=_+o,y=_-o):(p=d+f,m=p+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(x=u,_=x-o,p=m-o,b=m+o):(x=u+g,_=x+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=yi(i.rtl,this.x,this.width);for(t.x=Xo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=mi(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t))?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Le(t,{x:e,y:p,w:h,h:l,radius:r}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),Le(t,{x:i,y:p+1,w:h-2,h:l-2,radius:r}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(e,p,h,l),t.strokeRect(e,p,h,l),t.fillStyle=a.backgroundColor,t.fillRect(i,p+1,h-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=mi(i.bodyFont);let u=c.lineHeight,f=0;const g=yi(i.rtl,this.x,this.width),p=function(i){e.fillText(i,g.x(t.x+f),t.y+u/2),t.y+=u+n},m=g.textAlign(o);let b,x,_,y,v,w,M;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Xo(this,m,i),e.fillStyle=i.bodyColor,d(this.beforeBody,p),f=a&&"right"!==m?"center"===o?l/2+h:l+2+h:0,y=0,w=s.length;y0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Bo[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Ho(this,t),a=Object.assign({},i,this._size),r=Yo(e,t,a),l=Uo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=pi(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),vi(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),wi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this.chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!u(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,n=this._active||[],o=this._getActiveElements(t,n,e,i),a=this._positionChanged(o,t),r=e||!u(o,n)||a;return r&&(this._active=o,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,i,s){const n=this.options;if("mouseout"===t.type)return[];if(!s)return e;const o=this.chart.getElementsAtEventForMode(t,n.mode,n,i);return n.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Bo[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Go.positioners=Bo;var Zo={id:"tooltip",_element:Go,positioners:Bo,afterInit(t,e,i){i&&(t.tooltip=new Go({chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const i={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",i))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i)}},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:t,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Jo=Object.freeze({__proto__:null,Decimation:go,Filler:To,Legend:Ro,SubTitle:Vo,Title:zo,Tooltip:Zo});function Qo(t,e,i,s){const n=t.indexOf(e);if(-1===n)return((t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i))(t,e,i,s);return n!==t.lastIndexOf(e)?i:n}class ta extends $s{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(i(t))return null;const s=this.getLabels();return((t,e)=>null===t?null:Z(Math.round(t),0,e))(e=isFinite(e)&&s[e]===t?e:Qo(s,t,r(e,t),this._addedLabels),s.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function ea(t,e,{horizontal:i,minRotation:s}){const n=H(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}ta.id="category",ta.defaults={ticks:{callback:ta.prototype.getLabelForValue}};class ia extends $s{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return i(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=z(s),e=z(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const n=function(t,e){const s=[],{bounds:n,step:o,min:a,max:r,precision:l,count:h,maxTicks:c,maxDigits:d,includeBounds:u}=t,f=o||1,g=c-1,{min:p,max:m}=e,b=!i(a),x=!i(r),_=!i(h),y=(m-p)/(d+1);let v,w,M,k,S=F((m-p)/g/f)*f;if(S<1e-14&&!b&&!x)return[{value:p},{value:m}];k=Math.ceil(m/S)-Math.floor(p/S),k>g&&(S=F(k*S/g/f)*f),i(l)||(v=Math.pow(10,l),S=Math.ceil(S*v)/v),"ticks"===n?(w=Math.floor(p/S)*S,M=Math.ceil(m/S)*S):(w=p,M=m),b&&x&&o&&W((r-a)/o,S/1e3)?(k=Math.round(Math.min((r-a)/S,c)),S=(r-a)/k,w=a,M=r):_?(w=b?a:w,M=x?r:M,k=h-1,S=(M-w)/k):(k=(M-w)/S,k=N(k,Math.round(k),S/1e3)?Math.round(k):Math.ceil(k));const P=Math.max(Y(S),Y(w));v=Math.pow(10,i(l)?P:l),w=Math.round(w*v)/v,M=Math.round(M*v)/v;let D=0;for(b&&(u&&w!==a?(s.push({value:a}),w0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=o(t)?Math.max(0,t):null,this.max=o(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(I(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(I(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=a(t.min,Math.pow(10,Math.floor(I(e.min)))),r=Math.floor(I(o)),l=Math.floor(o/Math.pow(10,r)),h=r<0?Math.pow(10,Math.abs(r)):1;do{n.push({value:o,major:na(o)}),++l,10===l&&(l=1,++r,h=r>=0?1:h),o=Math.round(l*Math.pow(10,r)*h)/h}while(rn?{start:e-i,end:e}:{start:e,end:e+i}}function la(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},i=Object.assign({},e),n=[],o=[],a=t._pointLabels.length,r=t.options.pointLabels,l=r.centerPointLabels?D/a:0;for(let u=0;ue.r&&(r=(s.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),n.starte.b&&(l=(n.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function ca(t){return 0===t||180===t?"center":t<180?"left":"right"}function da(t,e,i){return"right"===i?t-=e:"center"===i&&(t-=e/2),t}function ua(t,e,i){return 90===i||270===i?t-=e/2:(i>270||i<90)&&(t-=e),t}function fa(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,O);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=c(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?la(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){return K(t*(O/(this._pointLabels.length||1))+H(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(i(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(i(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;o--){const e=n.setContext(t.getPointLabelContext(o)),a=mi(e.font),{x:r,y:l,textAlign:h,left:c,top:d,right:u,bottom:f}=t._pointLabelItems[o],{backdropColor:g}=e;if(!i(g)){const t=gi(e.borderRadius),i=pi(e.backdropPadding);s.fillStyle=g;const n=c-i.left,o=d-i.top,a=u-c+i.width,r=f-d+i.height;Object.values(t).some((t=>0!==t))?(s.beginPath(),Le(s,{x:n,y:o,w:a,h:r,radius:t}),s.fill()):s.fillRect(n,o,a,r)}Ae(s,t._pointLabels[o],r,l+a.lineHeight/2,a,{color:e.color,textAlign:h,textBaseline:"middle"})}}(this,o),n.display&&this.ticks.forEach(((t,e)=>{if(0!==e){r=this.getDistanceFromCenterForValue(t.value);!function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),fa(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,n.setContext(this.getContext(e-1)),r,o)}})),s.display){for(t.save(),a=o-1;a>=0;a--){const i=s.setContext(this.getPointLabelContext(a)),{color:n,lineWidth:o}=i;o&&n&&(t.lineWidth=o,t.strokeStyle=n,t.setLineDash(i.borderDash),t.lineDashOffset=i.borderDashOffset,r=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),l=this.getPointPosition(a,r),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(l.x,l.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=mi(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=pi(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}Ae(t,s.label,0,-n,l,{color:r.color})})),t.restore()}drawTitle(){}}ga.id="radialLinear",ga.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Is.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5,centerPointLabels:!1}},ga.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},ga.descriptors={angleLines:{_fallback:"grid"}};const pa={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ma=Object.keys(pa);function ba(t,e){return t-e}function xa(t,e){if(i(e))return null;const s=t._adapter,{parser:n,round:a,isoWeekday:r}=t._parseOpts;let l=e;return"function"==typeof n&&(l=n(l)),o(l)||(l="string"==typeof n?s.parse(l,n):s.parse(l)),null===l?null:(a&&(l="week"!==a||!B(r)&&!0!==r?s.startOf(l,a):s.startOf(l,"isoWeek",r)),+l)}function _a(t,e,i,s){const n=ma.length;for(let o=ma.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function va(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class wa extends $s{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new wn._date(t.adapters.date);s.init(e),b(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:xa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:a,maxDefined:r}=this.getUserBounds();function l(t){a||isNaN(t.min)||(s=Math.min(s,t.min)),r||isNaN(t.max)||(n=Math.max(n,t.max))}a&&r||(l(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||l(this.getMinMax(!1))),s=o(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=o(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=st(s,n,this.max);return this._unit=e.unit||(i.autoSkip?_a(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=ma.length-1;o>=ma.indexOf(i);o--){const i=ma[o];if(pa[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return ma[i?ma.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=ma.indexOf(t)+1,i=ma.length;e+t.value)))}initOffsets(t){let e,i,s=0,n=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),s=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),n=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;s=Z(s,0,o),n=Z(n,0,o),this._offsets={start:s,end:n,factor:1/(s+1+n)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,n=s.time,o=n.unit||_a(n.minUnit,e,i,this._getLabelCapacity(e)),a=r(n.stepSize,1),l="week"===o&&n.isoWeekday,h=B(l)||!0===l,c={};let d,u,f=e;if(h&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,h?"day":o),t.diff(i,e,o)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const g="data"===s.ticks.source&&this.getDataTimestamps();for(d=f,u=0;dt-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],d=i[e],u=r&&h&&d&&d.major,f=this._adapter.format(t,s||(u?h:l)),g=n.ticks.callback;return g?c(g,[f,e,i],this):f}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=et(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=et(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}wa.id="time",wa.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class ka extends wa{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Ma(e,this.min),this._tableRange=Ma(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o asyncMermaidRender(event)); + +async function asyncMermaidRender(event) { + var graphs = document.querySelectorAll(".mermaid"); + graphs.forEach((item, index) => { + let graphCode = item.textContent.trim(); // trim() becase of gantt, class and git diagram + let mermaidDiv = document.createElement("div"); + mermaidDiv.classList.add("mermaid"); + mermaidDiv.setAttribute("data-processed", "true"); + + try { + // item.innerText ignores html elements added by revealjs highlight plugin. + mermaid.mermaidAPI.render("theGraph" + index, graphCode, function(svgCode) { + mermaidDiv.innerHTML = svgCode; + }); + + let parentDiv = document.createElement("div"); + parentDiv.appendChild(mermaidDiv); + parentDiv.style.width = "100%"; + parentDiv.style.height = "100%"; + item.parentNode.parentNode.insertBefore(parentDiv, item.parentNode); + item.parentNode.remove(); + } catch (err) { + console.log("Cannot render mermaid diagram " + index + "\n" + graphCode); + console.log(err.message); + } + }); +} diff --git a/tools/plugin/mermaid.js b/tools/plugin/mermaid.js new file mode 100644 index 0000000..3e3404a --- /dev/null +++ b/tools/plugin/mermaid.js @@ -0,0 +1,13 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).RevealMermaid=e()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t={exports:{}};!function(t,e){t.exports=function(){var e;function n(){return e.apply(null,arguments)}function i(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function r(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function s(t){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(t).length;for(var e in t)if(a(t,e))return;return 1}function o(t){return void 0===t}function l(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function c(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function h(t,e){for(var n=[],i=t.length,r=0;r>>0,i=0;i$t(t)?(a=t+1,e-$t(t)):(a=t,e),{year:a,dayOfYear:n}}function Wt(t,e,n){var i,r,a=zt(t.year(),e,n);return(a=Math.floor((t.dayOfYear()-a-1)/7)+1)<1?i=a+Ht(r=t.year()-1,e,n):a>Ht(t.year(),e,n)?(i=a-Ht(t.year(),e,n),r=t.year()+1):(r=t.year(),i=a),{week:i,year:r}}function Ht(t,e,n){var i=zt(t,e,n);return e=zt(t+1,e,n),($t(t)-i+e)/7}function qt(t,e){return t.slice(e,7).concat(t.slice(0,e))}I("w",["ww",2],"wo","week"),I("W",["WW",2],"Wo","isoWeek"),P("week","w"),P("isoWeek","W"),U("week",5),U("isoWeek",5),dt("w",et),dt("ww",et,Q),dt("W",et),dt("WW",et,Q),bt(["w","ww","W","WW"],(function(t,e,n,i){e[i.substr(0,1)]=q(t)})),I("d",0,"do","day"),I("dd",0,0,(function(t){return this.localeData().weekdaysMin(this,t)})),I("ddd",0,0,(function(t){return this.localeData().weekdaysShort(this,t)})),I("dddd",0,0,(function(t){return this.localeData().weekdays(this,t)})),I("e",0,0,"weekday"),I("E",0,0,"isoWeekday"),P("day","d"),P("weekday","e"),P("isoWeekday","E"),U("day",11),U("weekday",11),U("isoWeekday",11),dt("d",et),dt("e",et),dt("E",et),dt("dd",(function(t,e){return e.weekdaysMinRegex(t)})),dt("ddd",(function(t,e){return e.weekdaysShortRegex(t)})),dt("dddd",(function(t,e){return e.weekdaysRegex(t)})),bt(["dd","ddd","dddd"],(function(t,e,n,i){null!=(i=n._locale.weekdaysParse(t,i,n._strict))?e.d=i:p(n).invalidWeekday=t})),bt(["d","e","E"],(function(t,e,n,i){e[i]=q(t)}));var Vt="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Gt="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Xt="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Zt=ut,Qt=ut,Kt=ut;function Jt(){function t(t,e){return e.length-t.length}for(var e,n,i,r=[],a=[],s=[],o=[],l=0;l<7;l++)i=d([2e3,1]).day(l),e=ft(this.weekdaysMin(i,"")),n=ft(this.weekdaysShort(i,"")),i=ft(this.weekdays(i,"")),r.push(e),a.push(n),s.push(i),o.push(e),o.push(n),o.push(i);r.sort(t),a.sort(t),s.sort(t),o.sort(t),this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+r.join("|")+")","i")}function te(){return this.hours()%12||12}function ee(t,e){I(t,0,0,(function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)}))}function ne(t,e){return e._meridiemParse}I("H",["HH",2],0,"hour"),I("h",["hh",2],0,te),I("k",["kk",2],0,(function(){return this.hours()||24})),I("hmm",0,0,(function(){return""+te.apply(this)+L(this.minutes(),2)})),I("hmmss",0,0,(function(){return""+te.apply(this)+L(this.minutes(),2)+L(this.seconds(),2)})),I("Hmm",0,0,(function(){return""+this.hours()+L(this.minutes(),2)})),I("Hmmss",0,0,(function(){return""+this.hours()+L(this.minutes(),2)+L(this.seconds(),2)})),ee("a",!0),ee("A",!1),P("hour","h"),U("hour",13),dt("a",ne),dt("A",ne),dt("H",et),dt("h",et),dt("k",et),dt("HH",et,Q),dt("hh",et,Q),dt("kk",et,Q),dt("hmm",nt),dt("hmmss",it),dt("Hmm",nt),dt("Hmmss",it),mt(["H","HH"],wt),mt(["k","kk"],(function(t,e,n){t=q(t),e[wt]=24===t?0:t})),mt(["a","A"],(function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t})),mt(["h","hh"],(function(t,e,n){e[wt]=q(t),p(n).bigHour=!0})),mt("hmm",(function(t,e,n){var i=t.length-2;e[wt]=q(t.substr(0,i)),e[Tt]=q(t.substr(i)),p(n).bigHour=!0})),mt("hmmss",(function(t,e,n){var i=t.length-4,r=t.length-2;e[wt]=q(t.substr(0,i)),e[Tt]=q(t.substr(i,2)),e[Ct]=q(t.substr(r)),p(n).bigHour=!0})),mt("Hmm",(function(t,e,n){var i=t.length-2;e[wt]=q(t.substr(0,i)),e[Tt]=q(t.substr(i))})),mt("Hmmss",(function(t,e,n){var i=t.length-4,r=t.length-2;e[wt]=q(t.substr(0,i)),e[Tt]=q(t.substr(i,2)),e[Ct]=q(t.substr(r))})),ut=V("Hours",!0);var ie,re={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Lt,monthsShort:Ot,week:{dow:0,doy:6},weekdays:Vt,weekdaysMin:Xt,weekdaysShort:Gt,meridiemParse:/[ap]\.?m?\.?/i},ae={},se={};function oe(t){return t&&t.toLowerCase().replace("_","-")}function le(t){for(var e,n,i,r,a=0;a=e&&function(t,e){for(var n=Math.min(t.length,e.length),i=0;i=e-1)break;e--}a++}return ie}function ce(e){var n;if(void 0===ae[e]&&t&&t.exports&&null!=e.match("^[^/\\\\]*$"))try{n=ie._abbr,function(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}("./locale/"+e),he(n)}catch(n){ae[e]=null}return ae[e]}function he(t,e){return t&&((e=o(e)?de(t):ue(t,e))?ie=e:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+t+" not found. Did you forget to load it?")),ie._abbr}function ue(t,e){if(null===e)return delete ae[t],null;var n,i=re;if(e.abbr=t,null!=ae[t])C("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),i=ae[t]._config;else if(null!=e.parentLocale)if(null!=ae[e.parentLocale])i=ae[e.parentLocale]._config;else{if(null==(n=ce(e.parentLocale)))return se[e.parentLocale]||(se[e.parentLocale]=[]),se[e.parentLocale].push({name:t,config:e}),null;i=n._config}return ae[t]=new A(S(i,e)),se[t]&&se[t].forEach((function(t){ue(t.name,t.config)})),he(t),ae[t]}function de(t){var e;if(!(t=t&&t._locale&&t._locale._abbr?t._locale._abbr:t))return ie;if(!i(t)){if(e=ce(t))return e;t=[t]}return le(t)}function pe(t){var e=t._a;return e&&-2===p(t).overflow&&(e=e[vt]<0||11Dt(e[xt],e[vt])?kt:e[wt]<0||24Ht(s,c,h)?p(r)._overflowWeeks=!0:null!=u?p(r)._overflowWeekday=!0:(d=Ut(s,o,l,c,h),r._a[xt]=d.year,r._dayOfYear=d.dayOfYear)),null!=t._dayOfYear&&(a=Ce(t._a[xt],i[xt]),(t._dayOfYear>$t(a)||0===t._dayOfYear)&&(p(t)._overflowDayOfYear=!0),u=jt(a,0,t._dayOfYear),t._a[vt]=u.getUTCMonth(),t._a[kt]=u.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=f[e]=i[e];for(;e<7;e++)t._a[e]=f[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[wt]&&0===t._a[Tt]&&0===t._a[Ct]&&0===t._a[Et]&&(t._nextDay=!0,t._a[wt]=0),t._d=(t._useUTC?jt:Yt).apply(null,f),s=t._useUTC?t._d.getUTCDay():t._d.getDay(),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[wt]=24),t._w&&void 0!==t._w.d&&t._w.d!==s&&(p(t).weekdayMismatch=!0)}}function Se(t){if(t._f===n.ISO_8601)ke(t);else if(t._f===n.RFC_2822)Te(t);else{t._a=[],p(t).empty=!0;for(var e,i,r,s,o,l=""+t._i,c=l.length,h=0,u=R(t._f,t._locale).match(O)||[],d=u.length,f=0;ft.valueOf():t.valueOf()"}),Z.toJSON=function(){return this.isValid()?this.toISOString():null},Z.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},Z.unix=function(){return Math.floor(this.valueOf()/1e3)},Z.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},Z.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},Z.eraName=function(){for(var t,e=this.localeData().eras(),n=0,i=e.length;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Z.isLocal=function(){return!!this.isValid()&&!this._isUTC},Z.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Z.isUtc=je,Z.isUTC=je,Z.zoneAbbr=function(){return this._isUTC?"UTC":""},Z.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Z.dates=w("dates accessor is deprecated. Use date instead.",at),Z.months=w("months accessor is deprecated. Use month instead",Ft),Z.years=w("years accessor is deprecated. Use year instead",Pt),Z.zone=w("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",(function(t,e){return null!=t?(this.utcOffset(t="string"!=typeof t?-t:t,e),this):-this.utcOffset()})),Z.isDSTShifted=w("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",(function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var t,e={};return _(e,this),(e=Ae(e))._a?(t=(e._isUTC?d:Le)(e._a),this._isDSTShifted=this.isValid()&&0e?1:t>=e?0:NaN}function d(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function p(t){let e,n,i;function r(t,i,r=0,a=t.length){if(r>>1;n(t[e],i)<0?r=e+1:a=e}while(ru(t(e),n),i=(e,n)=>t(e)-n):(e=t===u||t===d?t:f,n=t,i=t),{left:r,center:function(t,e,n=0,a=t.length){const s=r(t,e,n,a-1);return s>n&&i(t[s-1],e)>-i(t[s],e)?s-1:s},right:function(t,i,r=0,a=t.length){if(r>>1;n(t[e],i)<=0?r=e+1:a=e}while(r-1}(e))return e;var n=e.match(l);if(!n)return e;var i=n[0];return r.test(i)?"about:blank":e};const g=p(u).right;p((function(t){return null===t?NaN:+t})).center;var y=g;class m extends Map{constructor(t,e=_){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(b(this,t))}has(t){return super.has(b(this,t))}set(t,e){return super.set(function({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):(t.set(i,n),n)}(this,t),e)}delete(t){return super.delete(function({_intern:t,_key:e},n){const i=e(n);t.has(i)&&(n=t.get(i),t.delete(i));return n}(this,t))}}function b({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):n}function _(t){return null!==t&&"object"==typeof t?t.valueOf():t}const x=Math.sqrt(50),v=Math.sqrt(10),k=Math.sqrt(2);function w(t,e,n){const i=(e-t)/Math.max(0,n),r=Math.floor(Math.log10(i)),a=i/Math.pow(10,r),s=a>=x?10:a>=v?5:a>=k?2:1;let o,l,c;return r<0?(c=Math.pow(10,-r)/s,o=Math.round(t*c),l=Math.round(e*c),o/ce&&--l,c=-c):(c=Math.pow(10,r)*s,o=Math.round(t/c),l=Math.round(e/c),o*ce&&--l),l=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n=r)&&(n=r)}return n}function S(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function A(t){return t}var D=1,L=2,O=3,N=4,M=1e-6;function B(t){return"translate("+t+",0)"}function I(t){return"translate(0,"+t+")"}function F(t){return e=>+t(e)}function R(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function $(){return!this.__axis}function P(t,e){var n=[],i=null,r=null,a=6,s=6,o=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=t===D||t===N?-1:1,h=t===N||t===L?"x":"y",u=t===D||t===O?B:I;function d(d){var p=null==i?e.ticks?e.ticks.apply(e,n):e.domain():i,f=null==r?e.tickFormat?e.tickFormat.apply(e,n):A:r,g=Math.max(a,0)+o,y=e.range(),m=+y[0]+l,b=+y[y.length-1]+l,_=(e.bandwidth?R:F)(e.copy(),l),x=d.selection?d.selection():d,v=x.selectAll(".domain").data([null]),k=x.selectAll(".tick").data(p,e).order(),w=k.exit(),T=k.enter().append("g").attr("class","tick"),C=k.select("line"),E=k.select("text");v=v.merge(v.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),k=k.merge(T),C=C.merge(T.append("line").attr("stroke","currentColor").attr(h+"2",c*a)),E=E.merge(T.append("text").attr("fill","currentColor").attr(h,c*g).attr("dy",t===D?"0em":t===O?"0.71em":"0.32em")),d!==x&&(v=v.transition(d),k=k.transition(d),C=C.transition(d),E=E.transition(d),w=w.transition(d).attr("opacity",M).attr("transform",(function(t){return isFinite(t=_(t))?u(t+l):this.getAttribute("transform")})),T.attr("opacity",M).attr("transform",(function(t){var e=this.parentNode.__axis;return u((e&&isFinite(e=e(t))?e:_(t))+l)}))),w.remove(),v.attr("d",t===N||t===L?s?"M"+c*s+","+m+"H"+l+"V"+b+"H"+c*s:"M"+l+","+m+"V"+b:s?"M"+m+","+c*s+"V"+l+"H"+b+"V"+c*s:"M"+m+","+l+"H"+b),k.attr("opacity",1).attr("transform",(function(t){return u(_(t)+l)})),C.attr(h+"2",c*a),E.attr(h,c*g).text(f),x.filter($).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===L?"start":t===N?"end":"middle"),x.each((function(){this.__axis=_}))}return d.scale=function(t){return arguments.length?(e=t,d):e},d.ticks=function(){return n=Array.from(arguments),d},d.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),d):n.slice()},d.tickValues=function(t){return arguments.length?(i=null==t?null:Array.from(t),d):i&&i.slice()},d.tickFormat=function(t){return arguments.length?(r=t,d):r},d.tickSize=function(t){return arguments.length?(a=s=+t,d):a},d.tickSizeInner=function(t){return arguments.length?(a=+t,d):a},d.tickSizeOuter=function(t){return arguments.length?(s=+t,d):s},d.tickPadding=function(t){return arguments.length?(o=+t,d):o},d.offset=function(t){return arguments.length?(l=+t,d):l},d}var Y={value:()=>{}};function j(){for(var t,e=0,n=arguments.length,i={};e=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}(t+"",i),a=-1,s=r.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a0)for(var n,i,r=new Array(n),a=0;a=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),q.hasOwnProperty(e)?{space:q[e],local:t}:t}function G(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===H&&e.documentElement.namespaceURI===H?e.createElement(t):e.createElementNS(n,t)}}function X(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Z(t){var e=V(t);return(e.local?X:G)(e)}function Q(){}function K(t){return null==t?Q:function(){return this.querySelector(t)}}function J(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function tt(){return[]}function et(t){return null==t?tt:function(){return this.querySelectorAll(t)}}function nt(t){return function(){return this.matches(t)}}function it(t){return function(e){return e.matches(t)}}var rt=Array.prototype.find;function at(){return this.firstElementChild}var st=Array.prototype.filter;function ot(){return Array.from(this.children)}function lt(t){return new Array(t.length)}function ct(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ht(t,e,n,i,r,a){for(var s,o=0,l=e.length,c=a.length;oe?1:t>=e?0:NaN}function gt(t){return function(){this.removeAttribute(t)}}function yt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function mt(t,e){return function(){this.setAttribute(t,e)}}function bt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function _t(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function xt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function vt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function kt(t){return function(){this.style.removeProperty(t)}}function wt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Tt(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function Ct(t,e){return t.style.getPropertyValue(e)||vt(t).getComputedStyle(t,null).getPropertyValue(e)}function Et(t){return function(){delete this[t]}}function St(t,e){return function(){this[t]=e}}function At(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Dt(t){return t.trim().split(/^|\s+/)}function Lt(t){return t.classList||new Ot(t)}function Ot(t){this._node=t,this._names=Dt(t.getAttribute("class")||"")}function Nt(t,e){for(var n=Lt(t),i=-1,r=e.length;++i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var te=[null];function ee(t,e){this._groups=t,this._parents=e}function ne(){return new ee([[document.documentElement]],te)}function ie(t){return"string"==typeof t?new ee([[document.querySelector(t)]],[document.documentElement]):new ee([[t]],te)}function re(t){return"string"==typeof t?new ee([document.querySelectorAll(t)],[document.documentElement]):new ee([J(t)],te)}function ae(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function se(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function oe(){}ee.prototype=ne.prototype={constructor:ee,select:function(t){"function"!=typeof t&&(t=K(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=x&&(x=_+1);!(b=y[x])&&++x=0;)(i=r[a])&&(s&&4^i.compareDocumentPosition(s)&&s.parentNode.insertBefore(i,s),s=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=ft);for(var n=this._groups,i=n.length,r=new Array(i),a=0;a1?this.each((null==e?kt:"function"==typeof e?Tt:wt)(t,e,null==n?"":n)):Ct(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Et:"function"==typeof e?At:St)(t,e)):this.node()[t]},classed:function(t,e){var n=Dt(t+"");if(arguments.length<2){for(var i=Lt(this.node()),r=-1,a=n.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),s=a.length;if(!(arguments.length<2)){for(o=e?Zt:Xt,i=0;i>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Ce(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Ce(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=fe.exec(t))?new Ae(e[1],e[2],e[3],1):(e=ge.exec(t))?new Ae(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ye.exec(t))?Ce(e[1],e[2],e[3],e[4]):(e=me.exec(t))?Ce(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=be.exec(t))?Be(e[1],e[2]/100,e[3]/100,1):(e=_e.exec(t))?Be(e[1],e[2]/100,e[3]/100,e[4]):xe.hasOwnProperty(t)?Te(xe[t]):"transparent"===t?new Ae(NaN,NaN,NaN,0):null}function Te(t){return new Ae(t>>16&255,t>>8&255,255&t,1)}function Ce(t,e,n,i){return i<=0&&(t=e=n=NaN),new Ae(t,e,n,i)}function Ee(t){return t instanceof oe||(t=we(t)),t?new Ae((t=t.rgb()).r,t.g,t.b,t.opacity):new Ae}function Se(t,e,n,i){return 1===arguments.length?Ee(t):new Ae(t,e,n,null==i?1:i)}function Ae(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function De(){return`#${Me(this.r)}${Me(this.g)}${Me(this.b)}`}function Le(){const t=Oe(this.opacity);return`${1===t?"rgb(":"rgba("}${Ne(this.r)}, ${Ne(this.g)}, ${Ne(this.b)}${1===t?")":`, ${t})`}`}function Oe(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ne(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Me(t){return((t=Ne(t))<16?"0":"")+t.toString(16)}function Be(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Fe(t,e,n,i)}function Ie(t){if(t instanceof Fe)return new Fe(t.h,t.s,t.l,t.opacity);if(t instanceof oe||(t=we(t)),!t)return new Fe;if(t instanceof Fe)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),a=Math.max(e,n,i),s=NaN,o=a-r,l=(a+r)/2;return o?(s=e===a?(n-i)/o+6*(n0&&l<1?0:s,new Fe(s,o,l,t.opacity)}function Fe(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Re(t){return(t=(t||0)%360)<0?t+360:t}function $e(t){return Math.max(0,Math.min(1,t||0))}function Pe(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}ae(oe,we,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ve,formatHex:ve,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ie(this).formatHsl()},formatRgb:ke,toString:ke}),ae(Ae,Se,se(oe,{brighter(t){return t=null==t?ce:Math.pow(ce,t),new Ae(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?le:Math.pow(le,t),new Ae(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ae(Ne(this.r),Ne(this.g),Ne(this.b),Oe(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:De,formatHex:De,formatHex8:function(){return`#${Me(this.r)}${Me(this.g)}${Me(this.b)}${Me(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Le,toString:Le})),ae(Fe,(function(t,e,n,i){return 1===arguments.length?Ie(t):new Fe(t,e,n,null==i?1:i)}),se(oe,{brighter(t){return t=null==t?ce:Math.pow(ce,t),new Fe(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?le:Math.pow(le,t),new Fe(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Ae(Pe(t>=240?t-240:t+120,r,i),Pe(t,r,i),Pe(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new Fe(Re(this.h),$e(this.s),$e(this.l),Oe(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Oe(this.opacity);return`${1===t?"hsl(":"hsla("}${Re(this.h)}, ${100*$e(this.s)}%, ${100*$e(this.l)}%${1===t?")":`, ${t})`}`}}));const Ye=Math.PI/180,je=180/Math.PI,ze=.96422,Ue=1,We=.82521,He=4/29,qe=6/29,Ve=3*qe*qe,Ge=qe*qe*qe;function Xe(t){if(t instanceof Ze)return new Ze(t.l,t.a,t.b,t.opacity);if(t instanceof nn)return rn(t);t instanceof Ae||(t=Ee(t));var e,n,i=tn(t.r),r=tn(t.g),a=tn(t.b),s=Qe((.2225045*i+.7168786*r+.0606169*a)/Ue);return i===r&&r===a?e=n=s:(e=Qe((.4360747*i+.3850649*r+.1430804*a)/ze),n=Qe((.0139322*i+.0971045*r+.7141733*a)/We)),new Ze(116*s-16,500*(e-s),200*(s-n),t.opacity)}function Ze(t,e,n,i){this.l=+t,this.a=+e,this.b=+n,this.opacity=+i}function Qe(t){return t>Ge?Math.pow(t,1/3):t/Ve+He}function Ke(t){return t>qe?t*t*t:Ve*(t-He)}function Je(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function tn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function en(t,e,n,i){return 1===arguments.length?function(t){if(t instanceof nn)return new nn(t.h,t.c,t.l,t.opacity);if(t instanceof Ze||(t=Xe(t)),0===t.a&&0===t.b)return new nn(NaN,0()=>t;function sn(t,e){return function(n){return t+n*e}}function on(t){return 1==(t=+t)?ln:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):an(isNaN(e)?n:e)}}function ln(t,e){var n=e-t;return n?sn(t,n):an(isNaN(t)?e:t)}var cn=function t(e){var n=on(e);function i(t,e){var i=n((t=Se(t)).r,(e=Se(e)).r),r=n(t.g,e.g),a=n(t.b,e.b),s=ln(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=a(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function hn(t,e){e||(e=[]);var n,i=t?Math.min(e.length,t.length):0,r=e.slice();return function(a){for(n=0;na&&(r=e.slice(a,r),o[s]?o[s]+=r:o[++s]=r),(n=n[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,l.push({i:s,x:pn(n,i)})),a=yn.lastIndex;return a180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(r(n)+"rotate(",null,i)-2,x:pn(t,e)})):e&&n.push(r(n)+"rotate("+e+i)}(a.rotate,s.rotate,o,l),function(t,e,n,a){t!==e?a.push({i:n.push(r(n)+"skewX(",null,i)-2,x:pn(t,e)}):e&&n.push(r(n)+"skewX("+e+i)}(a.skewX,s.skewX,o,l),function(t,e,n,i,a,s){if(t!==n||e!==i){var o=a.push(r(a)+"scale(",null,",",null,")");s.push({i:o-4,x:pn(t,n)},{i:o-2,x:pn(e,i)})}else 1===n&&1===i||a.push(r(a)+"scale("+n+","+i+")")}(a.scaleX,a.scaleY,s.scaleX,s.scaleY,o,l),a=s=null,function(t){for(var e,n=-1,i=l.length;++n180||n<-180?n-360*Math.round(n/360):n):an(isNaN(t)?e:t)})),Ln=0,On=0,Nn=0,Mn=1e3,Bn=0,In=0,Fn=0,Rn="object"==typeof performance&&performance.now?performance:Date,$n="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Pn(){return In||($n(Yn),In=Rn.now()+Fn)}function Yn(){In=0}function jn(){this._call=this._time=this._next=null}function zn(t,e,n){var i=new jn;return i.restart(t,e,n),i}function Un(){In=(Bn=Rn.now())+Fn,Ln=On=0;try{!function(){Pn(),++Ln;for(var t,e=Sn;e;)(t=In-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ln}()}finally{Ln=0,function(){var t,e,n=Sn,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Sn=e);An=t,Hn(i)}(),In=0}}function Wn(){var t=Rn.now(),e=t-Bn;e>Mn&&(Fn-=e,Bn=t)}function Hn(t){Ln||(On&&(On=clearTimeout(On)),t-In>24?(t<1/0&&(On=setTimeout(Un,t-Rn.now()-Fn)),Nn&&(Nn=clearInterval(Nn))):(Nn||(Bn=Rn.now(),Nn=setInterval(Wn,Mn)),Ln=1,$n(Un)))}function qn(t,e,n){var i=new jn;return e=null==e?0:+e,i.restart((n=>{i.stop(),t(n+e)}),e,n),i}jn.prototype=zn.prototype={constructor:jn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Pn():+n)+(null==e?0:+e),this._next||An===this||(An?An._next=this:Sn=this,An=this),this._call=t,this._time=n,Hn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hn())}};var Vn=j("start","end","cancel","interrupt"),Gn=[],Xn=0,Zn=1,Qn=2,Kn=3,Jn=4,ti=5,ei=6;function ni(t,e,n,i,r,a){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var i,r=t.__transition;function a(t){n.state=Zn,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)}function s(a){var c,h,u,d;if(n.state!==Zn)return l();for(c in r)if((d=r[c]).name===n.name){if(d.state===Kn)return qn(s);d.state===Jn?(d.state=ei,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[c]):+cXn)throw new Error("too late; already scheduled");return n}function ri(t,e){var n=ai(t,e);if(n.state>Kn)throw new Error("too late; already running");return n}function ai(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function si(t,e){var n,i;return function(){var r=ri(this,t),a=r.tween;if(a!==n)for(var s=0,o=(i=n=a).length;s=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?ii:ri;return function(){var s=a(this,t),o=s.on;o!==i&&(r=(i=o).copy()).on(e,n),s.on=r}}(n,t,e))},attr:function(t,e){var n=V(t),i="transform"===n?En:ci;return this.attrTween(t,"function"==typeof e?(n.local?gi:fi)(n,i,li(this,"attr."+t,e)):null==e?(n.local?ui:hi)(n):(n.local?pi:di)(n,i,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var i=V(t);return this.tween(n,(i.local?yi:mi)(i,e))},style:function(t,e,n){var i="transform"==(t+="")?Cn:ci;return null==e?this.styleTween(t,function(t,e){var n,i,r;return function(){var a=Ct(this,t),s=(this.style.removeProperty(t),Ct(this,t));return a===s?null:a===n&&s===i?r:r=e(n=a,i=s)}}(t,i)).on("end.style."+t,wi(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var i,r,a;return function(){var s=Ct(this,t),o=n(this),l=o+"";return null==o&&(this.style.removeProperty(t),l=o=Ct(this,t)),s===l?null:s===i&&l===r?a:(r=l,a=e(i=s,o))}}(t,i,li(this,"style."+t,e))).each(function(t,e){var n,i,r,a,s="style."+e,o="end."+s;return function(){var l=ri(this,t),c=l.on,h=null==l.value[s]?a||(a=wi(e)):void 0;c===n&&r===h||(i=(n=c).copy()).on(o,r=h),l.on=i}}(this._id,t)):this.styleTween(t,function(t,e,n){var i,r,a=n+"";return function(){var s=Ct(this,t);return s===a?null:s===i?r:r=e(i=s,n)}}(t,i,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;return this.tween(i,function(t,e,n){var i,r;function a(){var a=e.apply(this,arguments);return a!==r&&(i=(r=a)&&function(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}(t,a,n)),i}return a._value=e,a}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(li(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function i(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&function(t){return function(e){this.textContent=t.call(this,e)}}(i)),e}return i._value=t,i}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i,r=ai(this.node(),n).tween,a=0,s=r.length;aQn&&n.state=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Bi;const n=10**e;return function(t){this._+=t[0];for(let e=1,i=t.length;eNi)if(Math.abs(h*o-l*c)>Ni&&r){let d=n-a,p=i-s,f=o*o+l*l,g=d*d+p*p,y=Math.sqrt(f),m=Math.sqrt(u),b=r*Math.tan((Li-Math.acos((f+u-g)/(2*y*m)))/2),_=b/m,x=b/y;Math.abs(_-1)>Ni&&this._append`L${t+_*c},${e+_*h}`,this._append`A${r},${r},0,0,${+(h*d>c*p)},${this._x1=t+x*o},${this._y1=e+x*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,i,r,a){if(t=+t,e=+e,a=!!a,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(i),o=n*Math.sin(i),l=t+s,c=e+o,h=1^a,u=a?i-r:r-i;null===this._x1?this._append`M${l},${c}`:(Math.abs(this._x1-l)>Ni||Math.abs(this._y1-c)>Ni)&&this._append`L${l},${c}`,n&&(u<0&&(u=u%Oi+Oi),u>Mi?this._append`A${n},${n},0,1,${h},${t-s},${e-o}A${n},${n},0,1,${h},${this._x1=l},${this._y1=c}`:u>Ni&&this._append`A${n},${n},0,${+(u>=Li)},${h},${this._x1=t+n*Math.cos(r)},${this._y1=e+n*Math.sin(r)}`)}rect(t,e,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}}function Fi(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}function Ri(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function $i(t){return(t=Ri(Math.abs(t)))?t[1]:NaN}var Pi,Yi=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ji(t){if(!(e=Yi.exec(t)))throw new Error("invalid format: "+t);var e;return new zi({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function zi(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Ui(t,e){var n=Ri(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}ji.prototype=zi.prototype,zi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Wi={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Ui(100*t,e),r:Ui,s:function(t,e){var n=Ri(t,e);if(!n)return t+"";var i=n[0],r=n[1],a=r-(Pi=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,s=i.length;return a===s?i:a>s?i+new Array(a-s+1).join("0"):a>0?i.slice(0,a)+"."+i.slice(a):"0."+new Array(1-a).join("0")+Ri(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Hi(t){return t}var qi,Vi,Gi,Xi=Array.prototype.map,Zi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Qi(t){var e,n,i=void 0===t.grouping||void 0===t.thousands?Hi:(e=Xi.call(t.grouping,Number),n=t.thousands+"",function(t,i){for(var r=t.length,a=[],s=0,o=e[0],l=0;r>0&&o>0&&(l+o+1>i&&(o=Math.max(1,i-l)),a.push(t.substring(r-=o,r+o)),!((l+=o+1)>i));)o=e[s=(s+1)%e.length];return a.reverse().join(n)}),r=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",o=void 0===t.numerals?Hi:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Xi.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",h=void 0===t.nan?"NaN":t.nan+"";function u(t){var e=(t=ji(t)).fill,n=t.align,u=t.sign,d=t.symbol,p=t.zero,f=t.width,g=t.comma,y=t.precision,m=t.trim,b=t.type;"n"===b?(g=!0,b="g"):Wi[b]||(void 0===y&&(y=12),m=!0,b="g"),(p||"0"===e&&"="===n)&&(p=!0,e="0",n="=");var _="$"===d?r:"#"===d&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",x="$"===d?a:/[%p]/.test(b)?l:"",v=Wi[b],k=/[defgprs%]/.test(b);function w(t){var r,a,l,d=_,w=x;if("c"===b)w=v(t)+w,t="";else{var T=(t=+t)<0||1/t<0;if(t=isNaN(t)?h:v(Math.abs(t),y),m&&(t=function(t){t:for(var e,n=t.length,i=1,r=-1;i0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),T&&0==+t&&"+"!==u&&(T=!1),d=(T?"("===u?u:c:"-"===u||"("===u?"":u)+d,w=("s"===b?Zi[8+Pi/3]:"")+w+(T&&"("===u?")":""),k)for(r=-1,a=t.length;++r(l=t.charCodeAt(r))||l>57){w=(46===l?s+t.slice(r+1):t.slice(r))+w,t=t.slice(0,r);break}}g&&!p&&(t=i(t,1/0));var C=d.length+t.length+w.length,E=C>1)+d+t+w+E.slice(C);break;default:t=E+d+t+w}return o(t)}return y=void 0===y?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),w.toString=function(){return t+""},w}return{format:u,formatPrefix:function(t,e){var n=u(((t=ji(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor($i(e)/3))),r=Math.pow(10,-i),a=Zi[8+i/3];return function(t){return n(r*t)+a}}}}function Ki(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}qi=Qi({thousands:",",grouping:[3],currency:["$",""]}),Vi=qi.format,Gi=qi.formatPrefix;const Ji=Symbol("implicit");function tr(){var t=new m,e=[],n=[],i=Ji;function r(r){let a=t.get(r);if(void 0===a){if(i!==Ji)return i;t.set(r,a=e.push(r)-1)}return n[a%n.length]}return r.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new m;for(const i of n)t.has(i)||t.set(i,e.push(i)-1);return r},r.range=function(t){return arguments.length?(n=Array.from(t),r):n.slice()},r.unknown=function(t){return arguments.length?(i=t,r):i},r.copy=function(){return tr(e,n).unknown(i)},Ki.apply(r,arguments),r}function er(t){return+t}var nr=[0,1];function ir(t){return t}function rr(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function ar(t,e,n){var i=t[0],r=t[1],a=e[0],s=e[1];return re&&(n=t,t=e,e=n),c=function(n){return Math.max(t,Math.min(e,n))}),i=l>2?sr:ar,r=a=null,u}function u(e){return null==e||isNaN(e=+e)?n:(r||(r=i(s.map(t),o,l)))(t(c(e)))}return u.invert=function(n){return c(e((a||(a=i(o,s.map(t),pn)))(n)))},u.domain=function(t){return arguments.length?(s=Array.from(t,er),h()):s.slice()},u.range=function(t){return arguments.length?(o=Array.from(t),h()):o.slice()},u.rangeRound=function(t){return o=Array.from(t),l=_n,h()},u.clamp=function(t){return arguments.length?(c=!!t||ir,h()):c!==ir},u.interpolate=function(t){return arguments.length?(l=t,h()):l},u.unknown=function(t){return arguments.length?(n=t,u):n},function(n,i){return t=n,e=i,h()}}function cr(){return lr()(ir,ir)}function hr(t,e,n,i){var r,a=C(t,e,n);switch((i=ji(null==i?",f":i)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(e));return null!=i.precision||isNaN(r=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor($i(e)/3)))-$i(Math.abs(t)))}(a,s))||(i.precision=r),Gi(i,s);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,$i(e)-$i(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=function(t){return Math.max(0,-$i(Math.abs(t)))}(a))||(i.precision=r-2*("%"===i.type))}return Vi(i)}function ur(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)==(e=+e))return[t];const i=e=r))return[];const o=a-r+1,l=new Array(o);if(i)if(s<0)for(let t=0;t0;){if((r=T(l,c,n))===i)return a[s]=l,a[o]=c,e(a);if(r>0)l=Math.floor(l/r)*r,c=Math.ceil(c/r)*r;else{if(!(r<0))break;l=Math.ceil(l*r)/r,c=Math.floor(c*r)/r}i=r}return t},t}function dr(){var t=cr();return t.copy=function(){return or(t,dr())},Ki.apply(t,arguments),ur(t)}const pr=new Date,fr=new Date;function gr(t,e,n,i){function r(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return r.floor=e=>(t(e=new Date(+e)),e),r.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),r.round=t=>{const e=r(t),n=r.ceil(t);return t-e(e(t=new Date(+t),null==n?1:Math.floor(n)),t),r.range=(n,i,a)=>{const s=[];if(n=r.ceil(n),a=null==a?1:Math.floor(a),!(n0))return s;let o;do{s.push(o=new Date(+n)),e(n,a),t(n)}while(ogr((e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)}),((t,i)=>{if(t>=t)if(i<0)for(;++i<=0;)for(;e(t,-1),!n(t););else for(;--i>=0;)for(;e(t,1),!n(t););})),n&&(r.count=(e,i)=>(pr.setTime(+e),fr.setTime(+i),t(pr),t(fr),Math.floor(n(pr,fr))),r.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?r.filter(i?e=>i(e)%t==0:e=>r.count(0,e)%t==0):r:null)),r}const yr=gr((()=>{}),((t,e)=>{t.setTime(+t+e)}),((t,e)=>e-t));yr.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?gr((e=>{e.setTime(Math.floor(e/t)*t)}),((e,n)=>{e.setTime(+e+n*t)}),((e,n)=>(n-e)/t)):yr:null),yr.range;const mr=1e3,br=60*mr,_r=60*br,xr=24*_r,vr=7*xr,kr=30*xr,wr=365*xr,Tr=gr((t=>{t.setTime(t-t.getMilliseconds())}),((t,e)=>{t.setTime(+t+e*mr)}),((t,e)=>(e-t)/mr),(t=>t.getUTCSeconds()));Tr.range;const Cr=gr((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*mr)}),((t,e)=>{t.setTime(+t+e*br)}),((t,e)=>(e-t)/br),(t=>t.getMinutes()));Cr.range;const Er=gr((t=>{t.setUTCSeconds(0,0)}),((t,e)=>{t.setTime(+t+e*br)}),((t,e)=>(e-t)/br),(t=>t.getUTCMinutes()));Er.range;const Sr=gr((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*mr-t.getMinutes()*br)}),((t,e)=>{t.setTime(+t+e*_r)}),((t,e)=>(e-t)/_r),(t=>t.getHours()));Sr.range;const Ar=gr((t=>{t.setUTCMinutes(0,0,0)}),((t,e)=>{t.setTime(+t+e*_r)}),((t,e)=>(e-t)/_r),(t=>t.getUTCHours()));Ar.range;const Dr=gr((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*br)/xr),(t=>t.getDate()-1));Dr.range;const Lr=gr((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/xr),(t=>t.getUTCDate()-1));Lr.range;const Or=gr((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/xr),(t=>Math.floor(t/xr)));function Nr(t){return gr((e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),((t,e)=>{t.setDate(t.getDate()+7*e)}),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*br)/vr))}Or.range;const Mr=Nr(0),Br=Nr(1),Ir=Nr(2),Fr=Nr(3),Rr=Nr(4),$r=Nr(5),Pr=Nr(6);function Yr(t){return gr((e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)}),((t,e)=>(e-t)/vr))}Mr.range,Br.range,Ir.range,Fr.range,Rr.range,$r.range,Pr.range;const jr=Yr(0),zr=Yr(1),Ur=Yr(2),Wr=Yr(3),Hr=Yr(4),qr=Yr(5),Vr=Yr(6);jr.range,zr.range,Ur.range,Wr.range,Hr.range,qr.range,Vr.range;const Gr=gr((t=>{t.setDate(1),t.setHours(0,0,0,0)}),((t,e)=>{t.setMonth(t.getMonth()+e)}),((t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())),(t=>t.getMonth()));Gr.range;const Xr=gr((t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)}),((t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())),(t=>t.getUTCMonth()));Xr.range;const Zr=gr((t=>{t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,e)=>{t.setFullYear(t.getFullYear()+e)}),((t,e)=>e.getFullYear()-t.getFullYear()),(t=>t.getFullYear()));Zr.every=t=>isFinite(t=Math.floor(t))&&t>0?gr((e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,n)=>{e.setFullYear(e.getFullYear()+n*t)})):null,Zr.range;const Qr=gr((t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)}),((t,e)=>e.getUTCFullYear()-t.getUTCFullYear()),(t=>t.getUTCFullYear()));function Kr(t,e,n,i,r,a){const s=[[Tr,1,mr],[Tr,5,5*mr],[Tr,15,15*mr],[Tr,30,30*mr],[a,1,br],[a,5,5*br],[a,15,15*br],[a,30,30*br],[r,1,_r],[r,3,3*_r],[r,6,6*_r],[r,12,12*_r],[i,1,xr],[i,2,2*xr],[n,1,vr],[e,1,kr],[e,3,3*kr],[t,1,wr]];function o(e,n,i){const r=Math.abs(n-e)/i,a=p((([,,t])=>t)).right(s,r);if(a===s.length)return t.every(C(e/wr,n/wr,i));if(0===a)return yr.every(Math.max(C(e,n,i),1));const[o,l]=s[r/s[a-1][2]isFinite(t=Math.floor(t))&&t>0?gr((e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null,Qr.range,Kr(Qr,Xr,jr,Or,Ar,Er);const[Jr,ta]=Kr(Zr,Gr,Mr,Dr,Sr,Cr);function ea(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function na(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function ia(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}var ra,aa,sa={"-":"",_:" ",0:"0"},oa=/^\s*\d+/,la=/^%/,ca=/[\\^$*+?|[\]().{}]/g;function ha(t,e,n){var i=t<0?"-":"",r=(i?-t:t)+"",a=r.length;return i+(a[t.toLowerCase(),e])))}function fa(t,e,n){var i=oa.exec(e.slice(n,n+1));return i?(t.w=+i[0],n+i[0].length):-1}function ga(t,e,n){var i=oa.exec(e.slice(n,n+1));return i?(t.u=+i[0],n+i[0].length):-1}function ya(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.U=+i[0],n+i[0].length):-1}function ma(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.V=+i[0],n+i[0].length):-1}function ba(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.W=+i[0],n+i[0].length):-1}function _a(t,e,n){var i=oa.exec(e.slice(n,n+4));return i?(t.y=+i[0],n+i[0].length):-1}function xa(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function va(t,e,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function ka(t,e,n){var i=oa.exec(e.slice(n,n+1));return i?(t.q=3*i[0]-3,n+i[0].length):-1}function wa(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.m=i[0]-1,n+i[0].length):-1}function Ta(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.d=+i[0],n+i[0].length):-1}function Ca(t,e,n){var i=oa.exec(e.slice(n,n+3));return i?(t.m=0,t.d=+i[0],n+i[0].length):-1}function Ea(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.H=+i[0],n+i[0].length):-1}function Sa(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.M=+i[0],n+i[0].length):-1}function Aa(t,e,n){var i=oa.exec(e.slice(n,n+2));return i?(t.S=+i[0],n+i[0].length):-1}function Da(t,e,n){var i=oa.exec(e.slice(n,n+3));return i?(t.L=+i[0],n+i[0].length):-1}function La(t,e,n){var i=oa.exec(e.slice(n,n+6));return i?(t.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function Oa(t,e,n){var i=la.exec(e.slice(n,n+1));return i?n+i[0].length:-1}function Na(t,e,n){var i=oa.exec(e.slice(n));return i?(t.Q=+i[0],n+i[0].length):-1}function Ma(t,e,n){var i=oa.exec(e.slice(n));return i?(t.s=+i[0],n+i[0].length):-1}function Ba(t,e){return ha(t.getDate(),e,2)}function Ia(t,e){return ha(t.getHours(),e,2)}function Fa(t,e){return ha(t.getHours()%12||12,e,2)}function Ra(t,e){return ha(1+Dr.count(Zr(t),t),e,3)}function $a(t,e){return ha(t.getMilliseconds(),e,3)}function Pa(t,e){return $a(t,e)+"000"}function Ya(t,e){return ha(t.getMonth()+1,e,2)}function ja(t,e){return ha(t.getMinutes(),e,2)}function za(t,e){return ha(t.getSeconds(),e,2)}function Ua(t){var e=t.getDay();return 0===e?7:e}function Wa(t,e){return ha(Mr.count(Zr(t)-1,t),e,2)}function Ha(t){var e=t.getDay();return e>=4||0===e?Rr(t):Rr.ceil(t)}function qa(t,e){return t=Ha(t),ha(Rr.count(Zr(t),t)+(4===Zr(t).getDay()),e,2)}function Va(t){return t.getDay()}function Ga(t,e){return ha(Br.count(Zr(t)-1,t),e,2)}function Xa(t,e){return ha(t.getFullYear()%100,e,2)}function Za(t,e){return ha((t=Ha(t)).getFullYear()%100,e,2)}function Qa(t,e){return ha(t.getFullYear()%1e4,e,4)}function Ka(t,e){var n=t.getDay();return ha((t=n>=4||0===n?Rr(t):Rr.ceil(t)).getFullYear()%1e4,e,4)}function Ja(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ha(e/60|0,"0",2)+ha(e%60,"0",2)}function ts(t,e){return ha(t.getUTCDate(),e,2)}function es(t,e){return ha(t.getUTCHours(),e,2)}function ns(t,e){return ha(t.getUTCHours()%12||12,e,2)}function is(t,e){return ha(1+Lr.count(Qr(t),t),e,3)}function rs(t,e){return ha(t.getUTCMilliseconds(),e,3)}function as(t,e){return rs(t,e)+"000"}function ss(t,e){return ha(t.getUTCMonth()+1,e,2)}function os(t,e){return ha(t.getUTCMinutes(),e,2)}function ls(t,e){return ha(t.getUTCSeconds(),e,2)}function cs(t){var e=t.getUTCDay();return 0===e?7:e}function hs(t,e){return ha(jr.count(Qr(t)-1,t),e,2)}function us(t){var e=t.getUTCDay();return e>=4||0===e?Hr(t):Hr.ceil(t)}function ds(t,e){return t=us(t),ha(Hr.count(Qr(t),t)+(4===Qr(t).getUTCDay()),e,2)}function ps(t){return t.getUTCDay()}function fs(t,e){return ha(zr.count(Qr(t)-1,t),e,2)}function gs(t,e){return ha(t.getUTCFullYear()%100,e,2)}function ys(t,e){return ha((t=us(t)).getUTCFullYear()%100,e,2)}function ms(t,e){return ha(t.getUTCFullYear()%1e4,e,4)}function bs(t,e){var n=t.getUTCDay();return ha((t=n>=4||0===n?Hr(t):Hr.ceil(t)).getUTCFullYear()%1e4,e,4)}function _s(){return"+0000"}function xs(){return"%"}function vs(t){return+t}function ks(t){return Math.floor(+t/1e3)}function ws(t){return new Date(t)}function Ts(t){return t instanceof Date?+t:+new Date(+t)}function Cs(t,e,n,i,r,a,s,o,l,c){var h=cr(),u=h.invert,d=h.domain,p=c(".%L"),f=c(":%S"),g=c("%I:%M"),y=c("%I %p"),m=c("%a %d"),b=c("%b %d"),_=c("%B"),x=c("%Y");function v(t){return(l(t)=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:vs,s:ks,S:za,u:Ua,U:Wa,V:qa,w:Va,W:Ga,x:null,X:null,y:Xa,Y:Qa,Z:Ja,"%":xs},x={a:function(t){return s[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return o[t.getUTCMonth()]},c:null,d:ts,e:ts,f:as,g:ys,G:bs,H:es,I:ns,j:is,L:rs,m:ss,M:os,p:function(t){return r[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:vs,s:ks,S:ls,u:cs,U:hs,V:ds,w:ps,W:fs,x:null,X:null,y:gs,Y:ms,Z:_s,"%":xs},v={a:function(t,e,n){var i=p.exec(e.slice(n));return i?(t.w=f.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(t,e,n){var i=u.exec(e.slice(n));return i?(t.w=d.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(t,e,n){var i=m.exec(e.slice(n));return i?(t.m=b.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(t,e,n){var i=g.exec(e.slice(n));return i?(t.m=y.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(t,n,i){return T(t,e,n,i)},d:Ta,e:Ta,f:La,g:xa,G:_a,H:Ea,I:Ea,j:Ca,L:Da,m:wa,M:Sa,p:function(t,e,n){var i=c.exec(e.slice(n));return i?(t.p=h.get(i[0].toLowerCase()),n+i[0].length):-1},q:ka,Q:Na,s:Ma,S:Aa,u:ga,U:ya,V:ma,w:fa,W:ba,x:function(t,e,i){return T(t,n,e,i)},X:function(t,e,n){return T(t,i,e,n)},y:xa,Y:_a,Z:va,"%":Oa};function k(t,e){return function(n){var i,r,a,s=[],o=-1,l=0,c=t.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in a||(a.w=1),"Z"in a?(r=(i=na(ia(a.y,0,1))).getUTCDay(),i=r>4||0===r?zr.ceil(i):zr(i),i=Lr.offset(i,7*(a.V-1)),a.y=i.getUTCFullYear(),a.m=i.getUTCMonth(),a.d=i.getUTCDate()+(a.w+6)%7):(r=(i=ea(ia(a.y,0,1))).getDay(),i=r>4||0===r?Br.ceil(i):Br(i),i=Dr.offset(i,7*(a.V-1)),a.y=i.getFullYear(),a.m=i.getMonth(),a.d=i.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),r="Z"in a?na(ia(a.y,0,1)).getUTCDay():ea(ia(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(r+5)%7:a.w+7*a.U-(r+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,na(a)):ea(a)}}function T(t,e,n,i){for(var r,a,s=0,o=e.length,l=n.length;s=l)return-1;if(37===(r=e.charCodeAt(s++))){if(r=e.charAt(s++),!(a=v[r in sa?e.charAt(s++):r])||(i=a(t,n,i))<0)return-1}else if(r!=n.charCodeAt(i++))return-1}return i}return _.x=k(n,_),_.X=k(i,_),_.c=k(e,_),x.x=k(n,x),x.X=k(i,x),x.c=k(e,x),{format:function(t){var e=k(t+="",_);return e.toString=function(){return t},e},parse:function(t){var e=w(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=k(t+="",x);return e.toString=function(){return t},e},utcParse:function(t){var e=w(t+="",!0);return e.toString=function(){return t},e}}}(t),aa=ra.format,ra.parse,ra.utcFormat,ra.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});const As=Math.abs,Ds=Math.atan2,Ls=Math.cos,Os=Math.max,Ns=Math.min,Ms=Math.sin,Bs=Math.sqrt,Is=1e-12,Fs=Math.PI,Rs=Fs/2,$s=2*Fs;function Ps(t){return t>=1?Rs:t<=-1?-Rs:Math.asin(t)}function Ys(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Ii(e)}function js(t){return t.innerRadius}function zs(t){return t.outerRadius}function Us(t){return t.startAngle}function Ws(t){return t.endAngle}function Hs(t){return t&&t.padAngle}function qs(t,e,n,i,r,a,s){var o=t-n,l=e-i,c=(s?a:-a)/Bs(o*o+l*l),h=c*l,u=-c*o,d=t+h,p=e+u,f=n+h,g=i+u,y=(d+f)/2,m=(p+g)/2,b=f-d,_=g-p,x=b*b+_*_,v=r-a,k=d*g-f*p,w=(_<0?-1:1)*Bs(Os(0,v*v*x-k*k)),T=(k*_-b*w)/x,C=(-k*b-_*w)/x,E=(k*_+b*w)/x,S=(-k*b+_*w)/x,A=T-y,D=C-m,L=E-y,O=S-m;return A*A+D*D>L*L+O*O&&(T=E,C=S),{cx:T,cy:C,x01:-h,y01:-u,x11:T*(r/v-1),y11:C*(r/v-1)}}function Vs(){var t=js,e=zs,n=Ss(0),i=null,r=Us,a=Ws,s=Hs,o=null,l=Ys(c);function c(){var c,h,u=+t.apply(this,arguments),d=+e.apply(this,arguments),p=r.apply(this,arguments)-Rs,f=a.apply(this,arguments)-Rs,g=As(f-p),y=f>p;if(o||(o=c=l()),dIs)if(g>$s-Is)o.moveTo(d*Ls(p),d*Ms(p)),o.arc(0,0,d,p,f,!y),u>Is&&(o.moveTo(u*Ls(f),u*Ms(f)),o.arc(0,0,u,f,p,y));else{var m,b,_=p,x=f,v=p,k=f,w=g,T=g,C=s.apply(this,arguments)/2,E=C>Is&&(i?+i.apply(this,arguments):Bs(u*u+d*d)),S=Ns(As(d-u)/2,+n.apply(this,arguments)),A=S,D=S;if(E>Is){var L=Ps(E/u*Ms(C)),O=Ps(E/d*Ms(C));(w-=2*L)>Is?(v+=L*=y?1:-1,k-=L):(w=0,v=k=(p+f)/2),(T-=2*O)>Is?(_+=O*=y?1:-1,x-=O):(T=0,_=x=(p+f)/2)}var N=d*Ls(_),M=d*Ms(_),B=u*Ls(k),I=u*Ms(k);if(S>Is){var F,R=d*Ls(x),$=d*Ms(x),P=u*Ls(v),Y=u*Ms(v);if(g1?0:t<-1?Fs:Math.acos(t)}((j*U+z*W)/(Bs(j*j+z*z)*Bs(U*U+W*W)))/2),q=Bs(F[0]*F[0]+F[1]*F[1]);A=Ns(S,(u-q)/(H-1)),D=Ns(S,(d-q)/(H+1))}else A=D=0}T>Is?D>Is?(m=qs(P,Y,N,M,d,D,y),b=qs(R,$,B,I,d,D,y),o.moveTo(m.cx+m.x01,m.cy+m.y01),DIs&&w>Is?A>Is?(m=qs(B,I,R,$,u,-A,y),b=qs(N,M,P,Y,u,-A,y),o.lineTo(m.cx+m.x01,m.cy+m.y01),At?1:e>=t?0:NaN}function eo(t){return t}function no(){}function io(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function ro(t){this._context=t}function ao(t){return new ro(t)}function so(t){this._context=t}function oo(t){this._context=t}function lo(t){this._context=t}function co(t){return t<0?-1:1}function ho(t,e,n){var i=t._x1-t._x0,r=e-t._x1,a=(t._y1-t._y0)/(i||r<0&&-0),s=(n-t._y1)/(r||i<0&&-0),o=(a*r+s*i)/(i+r);return(co(a)+co(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function uo(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function po(t,e,n){var i=t._x0,r=t._y0,a=t._x1,s=t._y1,o=(a-i)/3;t._context.bezierCurveTo(i+o,r+o*e,a-o,s-o*n,a,s)}function fo(t){this._context=t}function go(t){this._context=new yo(t)}function yo(t){this._context=t}function mo(t){this._context=t}function bo(t){var e,n,i=t.length-1,r=new Array(i),a=new Array(i),s=new Array(i);for(r[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e=0;--e)r[e]=(s[e]-r[e+1])/a[e];for(a[i-1]=(t[i]+r[i-1])/2,e=0;et.length)&&(e=t.length);for(var n=0,i=new Array(e);n=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}},xo.prototype={constructor:xo,scale:function(t){return 1===t?this:new xo(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new xo(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},new xo(1,0,0),xo.prototype;var Eo=Object.hasOwnProperty,So=Object.setPrototypeOf,Ao=Object.isFrozen,Do=Object.getPrototypeOf,Lo=Object.getOwnPropertyDescriptor,Oo=Object.freeze,No=Object.seal,Mo=Object.create,Bo="undefined"!=typeof Reflect&&Reflect,Io=Bo.apply,Fo=Bo.construct;Io||(Io=function(t,e,n){return t.apply(e,n)}),Oo||(Oo=function(t){return t}),No||(No=function(t){return t}),Fo||(Fo=function(t,e){return wo(t,To(e))});var Ro,$o=Xo(Array.prototype.forEach),Po=Xo(Array.prototype.pop),Yo=Xo(Array.prototype.push),jo=Xo(String.prototype.toLowerCase),zo=Xo(String.prototype.toString),Uo=Xo(String.prototype.match),Wo=Xo(String.prototype.replace),Ho=Xo(String.prototype.indexOf),qo=Xo(String.prototype.trim),Vo=Xo(RegExp.prototype.test),Go=(Ro=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n1?n-1:0),r=1;r/gm),dl=No(/\${[\w\W]*}/gm),pl=No(/^data-[\-\w.\u00B7-\uFFFF]/),fl=No(/^aria-[\-\w]+$/),gl=No(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),yl=No(/^(?:\w+script|data):/i),ml=No(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bl=No(/^html$/i),_l=function(){return"undefined"==typeof window?null:window},xl=function(t,e){if("object"!==vo(t)||"function"!=typeof t.createPolicy)return null;var n=null,i="data-tt-policy-suffix";e.currentScript&&e.currentScript.hasAttribute(i)&&(n=e.currentScript.getAttribute(i));var r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:function(t){return t},createScriptURL:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};var vl=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_l(),n=function(e){return t(e)};if(n.version="2.4.1",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var i=e.document,r=e.document,a=e.DocumentFragment,s=e.HTMLTemplateElement,o=e.Node,l=e.Element,c=e.NodeFilter,h=e.NamedNodeMap,u=void 0===h?e.NamedNodeMap||e.MozNamedAttrMap:h,d=e.HTMLFormElement,p=e.DOMParser,f=e.trustedTypes,g=l.prototype,y=Ko(g,"cloneNode"),m=Ko(g,"nextSibling"),b=Ko(g,"childNodes"),_=Ko(g,"parentNode");if("function"==typeof s){var x=r.createElement("template");x.content&&x.content.ownerDocument&&(r=x.content.ownerDocument)}var v=xl(f,i),k=v?v.createHTML(""):"",w=r,T=w.implementation,C=w.createNodeIterator,E=w.createDocumentFragment,S=w.getElementsByTagName,A=i.importNode,D={};try{D=Qo(r).documentMode?r.documentMode:{}}catch(t){}var L={};n.isSupported="function"==typeof _&&T&&void 0!==T.createHTMLDocument&&9!==D;var O,N,M=hl,B=ul,I=dl,F=pl,R=fl,$=yl,P=ml,Y=gl,j=null,z=Zo({},[].concat(To(Jo),To(tl),To(el),To(il),To(al))),U=null,W=Zo({},[].concat(To(sl),To(ol),To(ll),To(cl))),H=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,V=null,G=!0,X=!0,Z=!1,Q=!1,K=!1,J=!1,tt=!1,et=!1,nt=!1,it=!1,rt=!0,at=!1,st=!0,ot=!1,lt={},ct=null,ht=Zo({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ut=null,dt=Zo({},["audio","video","img","source","image","track"]),pt=null,ft=Zo({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",yt="http://www.w3.org/2000/svg",mt="http://www.w3.org/1999/xhtml",bt=mt,_t=!1,xt=null,vt=Zo({},[gt,yt,mt],zo),kt=["application/xhtml+xml","text/html"],wt=null,Tt=r.createElement("form"),Ct=function(t){return t instanceof RegExp||t instanceof Function},Et=function(t){wt&&wt===t||(t&&"object"===vo(t)||(t={}),t=Qo(t),O=O=-1===kt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,N="application/xhtml+xml"===O?zo:jo,j="ALLOWED_TAGS"in t?Zo({},t.ALLOWED_TAGS,N):z,U="ALLOWED_ATTR"in t?Zo({},t.ALLOWED_ATTR,N):W,xt="ALLOWED_NAMESPACES"in t?Zo({},t.ALLOWED_NAMESPACES,zo):vt,pt="ADD_URI_SAFE_ATTR"in t?Zo(Qo(ft),t.ADD_URI_SAFE_ATTR,N):ft,ut="ADD_DATA_URI_TAGS"in t?Zo(Qo(dt),t.ADD_DATA_URI_TAGS,N):dt,ct="FORBID_CONTENTS"in t?Zo({},t.FORBID_CONTENTS,N):ht,q="FORBID_TAGS"in t?Zo({},t.FORBID_TAGS,N):{},V="FORBID_ATTR"in t?Zo({},t.FORBID_ATTR,N):{},lt="USE_PROFILES"in t&&t.USE_PROFILES,G=!1!==t.ALLOW_ARIA_ATTR,X=!1!==t.ALLOW_DATA_ATTR,Z=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Q=t.SAFE_FOR_TEMPLATES||!1,K=t.WHOLE_DOCUMENT||!1,et=t.RETURN_DOM||!1,nt=t.RETURN_DOM_FRAGMENT||!1,it=t.RETURN_TRUSTED_TYPE||!1,tt=t.FORCE_BODY||!1,rt=!1!==t.SANITIZE_DOM,at=t.SANITIZE_NAMED_PROPS||!1,st=!1!==t.KEEP_CONTENT,ot=t.IN_PLACE||!1,Y=t.ALLOWED_URI_REGEXP||Y,bt=t.NAMESPACE||mt,t.CUSTOM_ELEMENT_HANDLING&&Ct(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&Ct(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(H.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Q&&(X=!1),nt&&(et=!0),lt&&(j=Zo({},To(al)),U=[],!0===lt.html&&(Zo(j,Jo),Zo(U,sl)),!0===lt.svg&&(Zo(j,tl),Zo(U,ol),Zo(U,cl)),!0===lt.svgFilters&&(Zo(j,el),Zo(U,ol),Zo(U,cl)),!0===lt.mathMl&&(Zo(j,il),Zo(U,ll),Zo(U,cl))),t.ADD_TAGS&&(j===z&&(j=Qo(j)),Zo(j,t.ADD_TAGS,N)),t.ADD_ATTR&&(U===W&&(U=Qo(U)),Zo(U,t.ADD_ATTR,N)),t.ADD_URI_SAFE_ATTR&&Zo(pt,t.ADD_URI_SAFE_ATTR,N),t.FORBID_CONTENTS&&(ct===ht&&(ct=Qo(ct)),Zo(ct,t.FORBID_CONTENTS,N)),st&&(j["#text"]=!0),K&&Zo(j,["html","head","body"]),j.table&&(Zo(j,["tbody"]),delete q.tbody),Oo&&Oo(t),wt=t)},St=Zo({},["mi","mo","mn","ms","mtext"]),At=Zo({},["foreignobject","desc","title","annotation-xml"]),Dt=Zo({},["title","style","font","a","script"]),Lt=Zo({},tl);Zo(Lt,el),Zo(Lt,nl);var Ot=Zo({},il);Zo(Ot,rl);var Nt=function(t){Yo(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=k}catch(e){t.remove()}}},Mt=function(t,e){try{Yo(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Yo(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!U[t])if(et||nt)try{Nt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Bt=function(t){var e,n;if(tt)t=""+t;else{var i=Uo(t,/^[\r\n\t ]+/);n=i&&i[0]}"application/xhtml+xml"===O&&bt===mt&&(t=''+t+"");var a=v?v.createHTML(t):t;if(bt===mt)try{e=(new p).parseFromString(a,O)}catch(t){}if(!e||!e.documentElement){e=T.createDocument(bt,"template",null);try{e.documentElement.innerHTML=_t?"":a}catch(t){}}var s=e.body||e.documentElement;return t&&n&&s.insertBefore(r.createTextNode(n),s.childNodes[0]||null),bt===mt?S.call(e,K?"html":"body")[0]:K?e.documentElement:s},It=function(t){return C.call(t.ownerDocument||t,t,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Ft=function(t){return"object"===vo(o)?t instanceof o:t&&"object"===vo(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Rt=function(t,e,i){L[t]&&$o(L[t],(function(t){t.call(n,e,i,wt)}))},$t=function(t){var e,i;if(Rt("beforeSanitizeElements",t,null),(i=t)instanceof d&&("string"!=typeof i.nodeName||"string"!=typeof i.textContent||"function"!=typeof i.removeChild||!(i.attributes instanceof u)||"function"!=typeof i.removeAttribute||"function"!=typeof i.setAttribute||"string"!=typeof i.namespaceURI||"function"!=typeof i.insertBefore||"function"!=typeof i.hasChildNodes))return Nt(t),!0;if(Vo(/[\u0080-\uFFFF]/,t.nodeName))return Nt(t),!0;var r=N(t.nodeName);if(Rt("uponSanitizeElement",t,{tagName:r,allowedTags:j}),t.hasChildNodes()&&!Ft(t.firstElementChild)&&(!Ft(t.content)||!Ft(t.content.firstElementChild))&&Vo(/<[/\w]/g,t.innerHTML)&&Vo(/<[/\w]/g,t.textContent))return Nt(t),!0;if("select"===r&&Vo(/