From 8e9ef5ba62b8bee028428384ad5666e245eb854c Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sun, 17 Feb 2019 21:53:36 +0100 Subject: content update --- .gitignore | 5 +- .jekyll-metadata | Bin 44770 -> 0 bytes Gemfile | 2 - Gemfile.lock | 248 ----- _config.yml | 38 - _includes/footer.html | 77 -- _includes/header.html | 11 - _includes/highlight.css | 131 --- _includes/highlight.min.css | 1 - _includes/site.css | 270 ----- _includes/site.min.css | 1 - _layouts/index.html | 59 -- _layouts/page.html | 50 - _layouts/post.html | 88 -- _posts/2015-11-10-software-development-pitfalls.md | 85 -- ...lly-destroyed-the-joy-of-product-development.md | 39 - ...nd-why-i-choose-classic-vms-and-digitalocean.md | 50 - _posts/2017-03-07-golang-profiling-simplified.md | 121 --- ...-10-what-its-like-to-be-a-software-developer.md | 33 - ...04-17-what-i-ve-learned-developing-ad-server.md | 144 --- ...ng-python-web-applications-with-visual-tools.md | 192 ---- _posts/2017-08-11-simple-iot-application.md | 499 --------- ...digitalocean-spaces-object-storage-with-fuse.md | 271 ----- ...2018-08-05-the-bullshit-web-developments-pov.md | 113 --- ...01-03-encoding-binary-data-into-dna-sequence.md | 415 -------- assets/avatar.gif | Bin 708987 -> 0 bytes assets/avatar.png | Bin 22107 -> 0 bytes assets/cache-polyfill.js | 102 -- assets/manifest.json | 22 - assets/plotly-latest.min.js | 7 - assets/site.min.css | 1 - .../2015-11-10-software-development-pitfalls.md | 86 ++ content/2016-10-14-how-we-destroyed-development.md | 39 + content/2017-01-12-gce-aws-docker-digitalocean.md | 50 + content/2017-03-07-golang-profiling-simplified.md | 121 +++ ...-10-what-its-like-to-be-a-software-developer.md | 33 + ...04-17-what-i-ve-learned-developing-ad-server.md | 144 +++ ...ng-python-web-applications-with-visual-tools.md | 192 ++++ content/2017-08-11-simple-iot.md | 499 +++++++++ ...digitalocean-spaces-object-storage-with-fuse.md | 271 +++++ ...2018-08-05-the-bullshit-web-developments-pov.md | 93 ++ ...01-03-encoding-binary-data-into-dna-sequence.md | 415 ++++++++ content/cv.md | 64 ++ curriculum-vitae.md | 63 -- developers-mantra.md | 12 - files/copy-benchmarks.tsv | 101 -- files/dev101-git-topics-1.png | Bin 13317 -> 0 bytes files/dev101-git-topics-2.png | Bin 12260 -> 0 bytes files/dna-sequence/benchmarks.ods | Bin 21911 -> 0 bytes files/dna-sequence/chart-encoding-speed.png | Bin 14201 -> 0 bytes files/dna-sequence/chart-file-sizes.png | Bin 12391 -> 0 bytes files/dna-sequence/dna-basics.jpg | Bin 165883 -> 0 bytes files/dna-sequence/quote.png | Bin 1068 -> 0 bytes files/dna-sequence/sample-binary-file.png | Bin 66417 -> 0 bytes files/dna-sequence/sample.png | Bin 65930 -> 0 bytes files/fuse-droplets.png | Bin 42891 -> 0 bytes files/fuse-spaces.png | Bin 32450 -> 0 bytes files/golang-profiling-cpu.pdf | Bin 16518 -> 0 bytes files/golang-profiling-mem.pdf | Bin 19221 -> 0 bytes files/iot-app-output.png | Bin 23767 -> 0 bytes files/iot-rest-example.png | Bin 33912 -> 0 bytes files/iot-sqlite-db.png | Bin 199821 -> 0 bytes files/kcachegrind.png | Bin 88486 -> 0 bytes files/profiling-viewer.png | Bin 173672 -> 0 bytes files/simple-iot-application-overview.svg | 2 - files/simple-iot-application.zip | Bin 6406 -> 0 bytes files/snakeviz.png | Bin 59601 -> 0 bytes files/sqlite-benchmarks.tsv | 1001 ------------------ gulpfile.js | 161 +++ index.md | 5 - layouts/footer.njk | 25 + layouts/index.njk | 57 ++ layouts/navigation.njk | 39 + layouts/page.njk | 56 + layouts/post.njk | 59 ++ learn/python-0001.md | 55 - notes.txt | 1 - package.json | 32 + public/curriculum-vitae.html | 27 + public/encoding-binary-data-into-dna-sequence.html | 170 ++++ public/files/copy-benchmarks.tsv | 101 ++ public/files/dev101-git-topics-1.png | Bin 0 -> 13317 bytes public/files/dev101-git-topics-2.png | Bin 0 -> 12260 bytes public/files/dna-sequence/benchmarks.ods | Bin 0 -> 21911 bytes public/files/dna-sequence/chart-encoding-speed.png | Bin 0 -> 14201 bytes public/files/dna-sequence/chart-file-sizes.png | Bin 0 -> 12391 bytes public/files/dna-sequence/dna-basics.jpg | Bin 0 -> 165883 bytes public/files/dna-sequence/quote.png | Bin 0 -> 1068 bytes public/files/dna-sequence/sample-binary-file.png | Bin 0 -> 66417 bytes public/files/dna-sequence/sample.png | Bin 0 -> 65930 bytes public/files/fuse-droplets.png | Bin 0 -> 42891 bytes public/files/fuse-spaces.png | Bin 0 -> 32450 bytes public/files/golang-profiling-cpu.pdf | Bin 0 -> 16518 bytes public/files/golang-profiling-mem.pdf | Bin 0 -> 19221 bytes public/files/iot-app-output.png | Bin 0 -> 23767 bytes public/files/iot-rest-example.png | Bin 0 -> 33912 bytes public/files/iot-sqlite-db.png | Bin 0 -> 199821 bytes public/files/kcachegrind.png | Bin 0 -> 88486 bytes public/files/profiling-viewer.png | Bin 0 -> 173672 bytes public/files/simple-iot-application-overview.svg | 2 + public/files/simple-iot-application.zip | Bin 0 -> 6406 bytes public/files/snakeviz.png | Bin 0 -> 59601 bytes public/files/sqlite-benchmarks.tsv | 1001 ++++++++++++++++++ ...-why-i-choose-classic-vms-and-digitalocean.html | 27 + public/golang-profiling-simplified.html | 94 ++ ...y-destroyed-the-joy-of-product-development.html | 27 + public/index.html | 27 + ...-python-web-applications-with-visual-tools.html | 139 +++ public/simple-iot-application.html | 340 +++++++ public/software-development-pitfalls.html | 27 + public/test.css | 0 public/the-bullshit-web-developments-pov.html | 27 + ...gitalocean-spaces-object-storage-with-fuse.html | 190 ++++ public/what-i-ve-learned-developing-ad-server.html | 78 ++ .../what-its-like-to-be-a-software-developer.html | 27 + robots.txt | 2 - settings.js | 16 + slides/.jsbeautifyrc | 51 - slides/.jshintignore | 9 - slides/.jshintrc | 9 - slides/index.html | 46 - .../cartesian-coordinate-system.svg | 404 -------- .../basic-math-in-programming/default.pug | 206 ---- .../basic-math-in-programming/drawing1.svg | 264 ----- .../basic-math-in-programming/kmplot.fkt | 37 - .../basic-math-in-programming/kmplot.svg | 395 -------- .../levenshtein-distance.svg | 211 ---- .../basic-math-in-programming/meta.json | 3 - .../basic-math-in-programming/test.png | Bin 454303 -> 0 bytes slides/vendor/slides.css | 223 ---- slides/vendor/slides.js | 140 --- source/default.css | 262 +++++ source/default.js | 21 + source/languages/prism-bash.js | 84 ++ source/languages/prism-c.js | 33 + source/languages/prism-css.js | 52 + source/languages/prism-go.js | 12 + source/languages/prism-javascript.js | 56 + source/languages/prism-json.js | 14 + source/languages/prism-nginx.js | 11 + source/languages/prism-pascal.js | 55 + source/languages/prism-python.js | 29 + source/prism.css | 167 +++ source/prism.js | 1071 ++++++++++++++++++++ sw.js | 20 - tools/draw/app.css | 76 -- tools/draw/app.js | 72 -- tools/draw/favicon.png | Bin 5234 -> 0 bytes tools/draw/index.html | 41 - tools/editor/favicon.ico | Bin 1150 -> 0 bytes tools/editor/index.html | 72 -- 151 files changed, 6625 insertions(+), 6594 deletions(-) delete mode 100644 .jekyll-metadata delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100644 _config.yml delete mode 100644 _includes/footer.html delete mode 100644 _includes/header.html delete mode 100644 _includes/highlight.css delete mode 100644 _includes/highlight.min.css delete mode 100644 _includes/site.css delete mode 100644 _includes/site.min.css delete mode 100644 _layouts/index.html delete mode 100644 _layouts/page.html delete mode 100644 _layouts/post.html delete mode 100644 _posts/2015-11-10-software-development-pitfalls.md delete mode 100644 _posts/2016-10-14-how-we-successfully-destroyed-the-joy-of-product-development.md delete mode 100644 _posts/2017-01-12-gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.md delete mode 100644 _posts/2017-03-07-golang-profiling-simplified.md delete mode 100644 _posts/2017-04-10-what-its-like-to-be-a-software-developer.md delete mode 100644 _posts/2017-04-17-what-i-ve-learned-developing-ad-server.md delete mode 100644 _posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md delete mode 100644 _posts/2017-08-11-simple-iot-application.md delete mode 100644 _posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md delete mode 100644 _posts/2018-08-05-the-bullshit-web-developments-pov.md delete mode 100644 _posts/2019-01-03-encoding-binary-data-into-dna-sequence.md delete mode 100644 assets/avatar.gif delete mode 100644 assets/avatar.png delete mode 100644 assets/cache-polyfill.js delete mode 100644 assets/manifest.json delete mode 100644 assets/plotly-latest.min.js delete mode 100644 assets/site.min.css create mode 100644 content/2015-11-10-software-development-pitfalls.md create mode 100644 content/2016-10-14-how-we-destroyed-development.md create mode 100644 content/2017-01-12-gce-aws-docker-digitalocean.md create mode 100644 content/2017-03-07-golang-profiling-simplified.md create mode 100644 content/2017-04-10-what-its-like-to-be-a-software-developer.md create mode 100644 content/2017-04-17-what-i-ve-learned-developing-ad-server.md create mode 100644 content/2017-04-21-profiling-python-web-applications-with-visual-tools.md create mode 100644 content/2017-08-11-simple-iot.md create mode 100644 content/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md create mode 100644 content/2018-08-05-the-bullshit-web-developments-pov.md create mode 100644 content/2019-01-03-encoding-binary-data-into-dna-sequence.md create mode 100644 content/cv.md delete mode 100644 curriculum-vitae.md delete mode 100644 developers-mantra.md delete mode 100644 files/copy-benchmarks.tsv delete mode 100644 files/dev101-git-topics-1.png delete mode 100644 files/dev101-git-topics-2.png delete mode 100644 files/dna-sequence/benchmarks.ods delete mode 100644 files/dna-sequence/chart-encoding-speed.png delete mode 100644 files/dna-sequence/chart-file-sizes.png delete mode 100644 files/dna-sequence/dna-basics.jpg delete mode 100644 files/dna-sequence/quote.png delete mode 100644 files/dna-sequence/sample-binary-file.png delete mode 100644 files/dna-sequence/sample.png delete mode 100644 files/fuse-droplets.png delete mode 100644 files/fuse-spaces.png delete mode 100644 files/golang-profiling-cpu.pdf delete mode 100644 files/golang-profiling-mem.pdf delete mode 100644 files/iot-app-output.png delete mode 100644 files/iot-rest-example.png delete mode 100644 files/iot-sqlite-db.png delete mode 100644 files/kcachegrind.png delete mode 100644 files/profiling-viewer.png delete mode 100644 files/simple-iot-application-overview.svg delete mode 100644 files/simple-iot-application.zip delete mode 100644 files/snakeviz.png delete mode 100644 files/sqlite-benchmarks.tsv create mode 100644 gulpfile.js delete mode 100644 index.md create mode 100644 layouts/footer.njk create mode 100644 layouts/index.njk create mode 100644 layouts/navigation.njk create mode 100644 layouts/page.njk create mode 100644 layouts/post.njk delete mode 100644 learn/python-0001.md delete mode 100644 notes.txt create mode 100644 package.json create mode 100644 public/curriculum-vitae.html create mode 100644 public/encoding-binary-data-into-dna-sequence.html create mode 100644 public/files/copy-benchmarks.tsv create mode 100644 public/files/dev101-git-topics-1.png create mode 100644 public/files/dev101-git-topics-2.png create mode 100644 public/files/dna-sequence/benchmarks.ods create mode 100644 public/files/dna-sequence/chart-encoding-speed.png create mode 100644 public/files/dna-sequence/chart-file-sizes.png create mode 100644 public/files/dna-sequence/dna-basics.jpg create mode 100644 public/files/dna-sequence/quote.png create mode 100644 public/files/dna-sequence/sample-binary-file.png create mode 100644 public/files/dna-sequence/sample.png create mode 100644 public/files/fuse-droplets.png create mode 100644 public/files/fuse-spaces.png create mode 100644 public/files/golang-profiling-cpu.pdf create mode 100644 public/files/golang-profiling-mem.pdf create mode 100644 public/files/iot-app-output.png create mode 100644 public/files/iot-rest-example.png create mode 100644 public/files/iot-sqlite-db.png create mode 100644 public/files/kcachegrind.png create mode 100644 public/files/profiling-viewer.png create mode 100644 public/files/simple-iot-application-overview.svg create mode 100644 public/files/simple-iot-application.zip create mode 100644 public/files/snakeviz.png create mode 100644 public/files/sqlite-benchmarks.tsv create mode 100644 public/gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.html create mode 100644 public/golang-profiling-simplified.html create mode 100644 public/how-we-successfully-destroyed-the-joy-of-product-development.html create mode 100644 public/index.html create mode 100644 public/profiling-python-web-applications-with-visual-tools.html create mode 100644 public/simple-iot-application.html create mode 100644 public/software-development-pitfalls.html create mode 100644 public/test.css create mode 100644 public/the-bullshit-web-developments-pov.html create mode 100644 public/using-digitalocean-spaces-object-storage-with-fuse.html create mode 100644 public/what-i-ve-learned-developing-ad-server.html create mode 100644 public/what-its-like-to-be-a-software-developer.html delete mode 100644 robots.txt create mode 100644 settings.js delete mode 100644 slides/.jsbeautifyrc delete mode 100644 slides/.jshintignore delete mode 100644 slides/.jshintrc delete mode 100644 slides/index.html delete mode 100644 slides/presentations/basic-math-in-programming/cartesian-coordinate-system.svg delete mode 100644 slides/presentations/basic-math-in-programming/default.pug delete mode 100644 slides/presentations/basic-math-in-programming/drawing1.svg delete mode 100644 slides/presentations/basic-math-in-programming/kmplot.fkt delete mode 100644 slides/presentations/basic-math-in-programming/kmplot.svg delete mode 100644 slides/presentations/basic-math-in-programming/levenshtein-distance.svg delete mode 100644 slides/presentations/basic-math-in-programming/meta.json delete mode 100644 slides/presentations/basic-math-in-programming/test.png delete mode 100644 slides/vendor/slides.css delete mode 100644 slides/vendor/slides.js create mode 100644 source/default.css create mode 100644 source/default.js create mode 100644 source/languages/prism-bash.js create mode 100644 source/languages/prism-c.js create mode 100644 source/languages/prism-css.js create mode 100644 source/languages/prism-go.js create mode 100644 source/languages/prism-javascript.js create mode 100644 source/languages/prism-json.js create mode 100644 source/languages/prism-nginx.js create mode 100644 source/languages/prism-pascal.js create mode 100644 source/languages/prism-python.js create mode 100644 source/prism.css create mode 100644 source/prism.js delete mode 100644 sw.js delete mode 100644 tools/draw/app.css delete mode 100644 tools/draw/app.js delete mode 100644 tools/draw/favicon.png delete mode 100644 tools/draw/index.html delete mode 100644 tools/editor/favicon.ico delete mode 100644 tools/editor/index.html diff --git a/.gitignore b/.gitignore index 5af88dc..92b2c45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ - -_site/ -.sass-cache/ +node_modules/ +tmp/ diff --git a/.jekyll-metadata b/.jekyll-metadata deleted file mode 100644 index 32951be..0000000 Binary files a/.jekyll-metadata and /dev/null differ diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 37f5eaa..0000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' -gem 'github-pages', group: :jekyll_plugins diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 8ad4188..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,248 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (4.2.10) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.11.1) - colorator (1.1.0) - commonmarker (0.17.9) - ruby-enum (~> 0.5) - concurrent-ruby (1.0.5) - dnsruby (1.61.2) - addressable (~> 2.5) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - ethon (0.11.0) - ffi (>= 1.3.0) - eventmachine (1.2.7) - execjs (2.7.0) - faraday (0.15.2) - multipart-post (>= 1.2, < 3) - ffi (1.9.25) - forwardable-extended (2.6.0) - gemoji (3.0.0) - github-pages (188) - activesupport (= 4.2.10) - github-pages-health-check (= 1.8.1) - jekyll (= 3.7.3) - jekyll-avatar (= 0.6.0) - jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.1.5) - jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.10.0) - jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.9.4) - jekyll-mentions (= 1.4.0) - jekyll-optional-front-matter (= 0.3.0) - jekyll-paginate (= 1.1.0) - jekyll-readme-index (= 0.2.0) - jekyll-redirect-from (= 0.14.0) - jekyll-relative-links (= 0.5.3) - jekyll-remote-theme (= 0.3.1) - jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.5.0) - jekyll-sitemap (= 1.2.0) - jekyll-swiss (= 0.4.0) - jekyll-theme-architect (= 0.1.1) - jekyll-theme-cayman (= 0.1.1) - jekyll-theme-dinky (= 0.1.1) - jekyll-theme-hacker (= 0.1.1) - jekyll-theme-leap-day (= 0.1.1) - jekyll-theme-merlot (= 0.1.1) - jekyll-theme-midnight (= 0.1.1) - jekyll-theme-minimal (= 0.1.1) - jekyll-theme-modernist (= 0.1.1) - jekyll-theme-primer (= 0.5.3) - jekyll-theme-slate (= 0.1.1) - jekyll-theme-tactile (= 0.1.1) - jekyll-theme-time-machine (= 0.1.1) - jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.10.0) - kramdown (= 1.16.2) - liquid (= 4.0.0) - listen (= 3.1.5) - mercenary (~> 0.3) - minima (= 2.5.0) - nokogiri (>= 1.8.2, < 2.0) - rouge (= 2.2.1) - terminal-table (~> 1.4) - github-pages-health-check (1.8.1) - addressable (~> 2.3) - dnsruby (~> 1.60) - octokit (~> 4.0) - public_suffix (~> 2.0) - typhoeus (~> 1.3) - html-pipeline (2.8.4) - activesupport (>= 2) - nokogiri (>= 1.4) - http_parser.rb (0.6.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - jekyll (3.7.3) - addressable (~> 2.4) - colorator (~> 1.0) - em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 2.0) - kramdown (~> 1.14) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 4) - safe_yaml (~> 1.0) - jekyll-avatar (0.6.0) - jekyll (~> 3.0) - jekyll-coffeescript (1.1.1) - coffee-script (~> 2.2) - coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.2.0) - commonmarker (~> 0.14) - jekyll (>= 3.0, < 4.0) - jekyll-commonmark-ghpages (0.1.5) - commonmarker (~> 0.17.6) - jekyll-commonmark (~> 1) - rouge (~> 2) - jekyll-default-layout (0.1.4) - jekyll (~> 3.0) - jekyll-feed (0.10.0) - jekyll (~> 3.3) - jekyll-gist (1.5.0) - octokit (~> 4.2) - jekyll-github-metadata (2.9.4) - jekyll (~> 3.1) - octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.4.0) - html-pipeline (~> 2.3) - jekyll (~> 3.0) - jekyll-optional-front-matter (0.3.0) - jekyll (~> 3.0) - jekyll-paginate (1.1.0) - jekyll-readme-index (0.2.0) - jekyll (~> 3.0) - jekyll-redirect-from (0.14.0) - jekyll (~> 3.3) - jekyll-relative-links (0.5.3) - jekyll (~> 3.3) - jekyll-remote-theme (0.3.1) - jekyll (~> 3.5) - rubyzip (>= 1.2.1, < 3.0) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-seo-tag (2.5.0) - jekyll (~> 3.3) - jekyll-sitemap (1.2.0) - jekyll (~> 3.3) - jekyll-swiss (0.4.0) - jekyll-theme-architect (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-cayman (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-dinky (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-hacker (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-leap-day (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-merlot (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-midnight (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-minimal (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-modernist (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-primer (0.5.3) - jekyll (~> 3.5) - jekyll-github-metadata (~> 2.9) - jekyll-seo-tag (~> 2.0) - jekyll-theme-slate (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-tactile (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-time-machine (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-titles-from-headings (0.5.1) - jekyll (~> 3.3) - jekyll-watch (2.0.0) - listen (~> 3.0) - jemoji (0.10.0) - gemoji (~> 3.0) - html-pipeline (~> 2.2) - jekyll (~> 3.0) - kramdown (1.16.2) - liquid (4.0.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - mercenary (0.3.6) - mini_portile2 (2.3.0) - minima (2.5.0) - jekyll (~> 3.5) - jekyll-feed (~> 0.9) - jekyll-seo-tag (~> 2.1) - minitest (5.11.3) - multipart-post (2.0.0) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) - octokit (4.9.0) - sawyer (~> 0.8.0, >= 0.5.3) - pathutil (0.16.1) - forwardable-extended (~> 2.6) - public_suffix (2.0.5) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rouge (2.2.1) - ruby-enum (0.7.2) - i18n - ruby_dep (1.5.0) - rubyzip (1.2.1) - safe_yaml (1.0.4) - sass (3.5.7) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thread_safe (0.3.6) - typhoeus (1.3.0) - ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.4.0) - -PLATFORMS - ruby - -DEPENDENCIES - github-pages - -BUNDLED WITH - 1.16.3 diff --git a/_config.yml b/_config.yml deleted file mode 100644 index d11b28b..0000000 --- a/_config.yml +++ /dev/null @@ -1,38 +0,0 @@ -encoding: UTF-8 -exclude: - - Gemfile - - Gemfile.lock - - Makefile - - notes.md - -permalink: /:title -safe: false - -author: Mitja Felicijan -domain: https://mitjafelicijan.com/ -description: Embedded systems developer and fanatical fan of science fiction -twitter: '@mitjafelicijan' -avatar: assets/avatar.gif -cache_version: 20181130 -theme_color: '#ffffff' - -kramdown: - auto_ids: true - entity_output: as_char - toc_levels: 1..6 - smart_quotes: lsquo,rsquo,ldquo,rdquo - input: GFM - hard_wrap: true - footnote_nr: 1 - show_warnings: false - syntax_highlighter: rouge - syntax_highlighter_opts: - css_class: 'highlight' - span: - line_numbers: false - block: - line_numbers: true - start_line: 1 - -plugins: - - jekyll-sitemap diff --git a/_includes/footer.html b/_includes/footer.html deleted file mode 100644 index a23fda5..0000000 --- a/_includes/footer.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/header.html b/_includes/header.html deleted file mode 100644 index 4a26b0e..0000000 --- a/_includes/header.html +++ /dev/null @@ -1,11 +0,0 @@ -
@mitjafelicijan
- - \ No newline at end of file diff --git a/_includes/highlight.css b/_includes/highlight.css deleted file mode 100644 index 5919006..0000000 --- a/_includes/highlight.css +++ /dev/null @@ -1,131 +0,0 @@ -.highlight table td { - padding: 5px; -} - -.highlight table pre { - margin: 0; -} - -.highlight, -.highlight .w { - color: #586e75; -} - -.highlight .err { - color: #002b36; - background-color: #dc322f; -} - -.highlight .c, -.highlight .cd, -.highlight .cm, -.highlight .c1, -.highlight .cs { - color: #657b83; -} - -.highlight .cp { - color: #b58900; -} - -.highlight .nt { - color: #b58900; -} - -.highlight .o, -.highlight .ow { - color: #93a1a1; -} - -.highlight .p, -.highlight .pi { - color: #93a1a1; -} - -.highlight .gi { - color: #859900; -} - -.highlight .gd { - color: #dc322f; -} - -.highlight .gh { - color: #268bd2; - background-color: #002b36; - font-weight: bold; -} - -.highlight .k, -.highlight .kn, -.highlight .kp, -.highlight .kr, -.highlight .kv { - color: #6c71c4; -} - -.highlight .kc { - color: #cb4b16; -} - -.highlight .kt { - color: #cb4b16; -} - -.highlight .kd { - color: #cb4b16; -} - -.highlight .s, -.highlight .sb, -.highlight .sc, -.highlight .sd, -.highlight .s2, -.highlight .sh, -.highlight .sx, -.highlight .s1 { - color: #859900; -} - -.highlight .sr { - color: #2aa198; -} - -.highlight .si { - color: #d33682; -} - -.highlight .se { - color: #d33682; -} - -.highlight .nn { - color: #b58900; -} - -.highlight .nc { - color: #b58900; -} - -.highlight .no { - color: #b58900; -} - -.highlight .na { - color: #268bd2; -} - -.highlight .m, -.highlight .mf, -.highlight .mh, -.highlight .mi, -.highlight .il, -.highlight .mo, -.highlight .mb, -.highlight .mx { - color: #859900; -} - -.highlight .ss { - color: #859900; -} diff --git a/_includes/highlight.min.css b/_includes/highlight.min.css deleted file mode 100644 index 4bc3e68..0000000 --- a/_includes/highlight.min.css +++ /dev/null @@ -1 +0,0 @@ -.highlight table td{padding:5px}.highlight table pre{margin:0}.highlight,.highlight .w{color:#586e75}.highlight .err{color:#002b36;background-color:#dc322f}.highlight .c,.highlight .c1,.highlight .cd,.highlight .cm,.highlight .cs{color:#657b83}.highlight .cp,.highlight .nt{color:#b58900}.highlight .o,.highlight .ow,.highlight .p,.highlight .pi{color:#93a1a1}.highlight .gi{color:#859900}.highlight .gd{color:#dc322f}.highlight .gh{color:#268bd2;background-color:#002b36;font-weight:700}.highlight .k,.highlight .kn,.highlight .kp,.highlight .kr,.highlight .kv{color:#6c71c4}.highlight .kc,.highlight .kd,.highlight .kt{color:#cb4b16}.highlight .s,.highlight .s1,.highlight .s2,.highlight .sb,.highlight .sc,.highlight .sd,.highlight .sh,.highlight .sx{color:#859900}.highlight .sr{color:#2aa198}.highlight .se,.highlight .si{color:#d33682}.highlight .nc,.highlight .nn,.highlight .no{color:#b58900}.highlight .na{color:#268bd2}.highlight .il,.highlight .m,.highlight .mb,.highlight .mf,.highlight .mh,.highlight .mi,.highlight .mo,.highlight .mx,.highlight .ss{color:#859900} \ No newline at end of file diff --git a/_includes/site.css b/_includes/site.css deleted file mode 100644 index 117ad5f..0000000 --- a/_includes/site.css +++ /dev/null @@ -1,270 +0,0 @@ -@import url("https://fonts.googleapis.com/css?family=Yrsa:300,400,500,600,700&subset=latin-ext"); - -* { - box-sizing: border-box; -} - -body { - font-family: 'Yrsa', 'Roboto', 'Times New Roman', Times, serif; - font-size: 22px; - line-height: 1.6; - color: #000; - margin: 0; - padding: 0 0 50px 0; -} - -a { - color: #000; -} - -a:hover { - background: yellow; -} - -article, -main, -footer, -nav, -header { - max-width: 800px; - margin: 0 auto; -} - -header { - margin-top: 30px; -} - -header a, -nav ul li a { - text-decoration: none; -} - -header a { - font-size: 150%; - font-weight: 700; - color: #000; -} - -nav ul { - margin-top: 10px; - padding: 0; -} - -nav ul li { - display: inline-block; -} - -nav ul li a { - color: #444; - font-size: 85%; - margin-right: 20px; -} - -h1 { - font-size: 200%; - line-height: 120%; -} - -h2 { - font-size: 160%; -} - -h3 { - font-size: 140%; -} - -h4 { - font-size: 120%; -} - -article img { - max-width: 100%; - display: block; -} - -article img[src*='#center'] { - display: block; - margin: auto; -} - -time { - display: block; - font-size: 85%; - color: #444; -} - -ul { - list-style-type: square; -} - -main ul { - margin-top: 40px; - padding: 0 20px; -} - -main ul li { - margin-bottom: 25px; - margin-left: -20px; - list-style-type: none; -} - -main ul li a { - font-size: 100%; - font-weight: 600; - text-decoration: none; -} - -main ul div { - font-size: 116%; -} - -blockquote { - margin: 40px 0 40px 20px; - border-left: 5px solid #eee; - padding: 5px 0 10px 20px; -} - -table { - border: 2px solid #f1f1f1; - width: 100%; - border-collapse: collapse; - border-spacing: 0; -} - -table th, -table td { - border: 2px solid #f1f1f1; - text-align: left; - padding: 5px 10px; -} - -summary { - outline: none; - cursor: pointer; - font-weight: 600; - user-select: none; -} - -details .highlighter-rouge { - margin-top: 10px !important; -} - -.highlighter-rouge { - padding: 0 15px; - font-size: 60%; - border: 2px solid #f1f1f1; - overflow: auto; -} - -.highlighter-rouge table, -.highlighter-rouge table td { - border: 0 !important; -} - -::selection { - background: #ff0; - color: #000; -} - -::-moz-selection { - background: #ff0; - color: #000; -} - -ol { - list-style: none; - counter-reset: li; -} - -ol li { - counter-increment: li; -} - -ol li::before { - content: counter(li) "."; - color: #ccc; - font-weight: 500; - display: inline-block; - width: 1em; - margin-left: -1.5em; - margin-right: 0.9em; - text-align: right; -} - -ol li a { - text-decoration: none; -} - -/* footnotes */ -.footnotes p { - padding: 0; - display: inline-block; - margin: 0; -} - -/* commenting */ -#hcb_form_name, -#hcb_form_content { - border: 2px solid #eee; - padding: 10px; - width: 300px; - margin-bottom: 10px; -} - -#hcb_submit { - -webkit-appearance: none; - -moz-appearance: none; - -o-appearance: none; - -ms-appearance: none; - appearance: none; - font-weight: 600; - padding: 7px 15px; - font-size: 85%; - display: inline-block; - cursor: pointer; - border-radius: 3px; - background: #ccc; - border: 2px solid transparent; - width: auto; - user-select: none; - text-align: center; - height: auto; - margin-right: 20px; -} - -@media only screen and (max-width: 768px) { - body { - padding: 0 20px; - } - - footer, - header, - nav { - text-align: center; - } - - .responsive-table { - width: 100%; - overflow: scroll; - } - - h1 { - font-size: 200%; - } - - .footnotes { - overflow: auto; - } -} - -@media print { - @page { - margin: 2cm; - } - - header, - nav, - .comments { - display: none; - } -} diff --git a/_includes/site.min.css b/_includes/site.min.css deleted file mode 100644 index 57c5c7c..0000000 --- a/_includes/site.min.css +++ /dev/null @@ -1 +0,0 @@ -a,body,header a{color:#000}header a,main ul li a,nav ul li a,ol li a{text-decoration:none}#hcb_submit,.footnotes p,nav ul li,ol li::before{display:inline-block}#hcb_submit,summary{cursor:pointer;user-select:none}@font-face{font-family:Yrsa;font-style:normal;font-weight:300;src:local('Yrsa Light'),local('Yrsa-Light'),url(https://fonts.gstatic.com/s/yrsa/v3/wlpxgwnQFlxs3af97I0x2Q.ttf) format('truetype')}@font-face{font-family:Yrsa;font-style:normal;font-weight:400;src:local('Yrsa Regular'),local('Yrsa-Regular'),url(https://fonts.gstatic.com/s/yrsa/v3/wlp-gwnQFlxs1QLf_A.ttf) format('truetype')}@font-face{font-family:Yrsa;font-style:normal;font-weight:500;src:local('Yrsa Medium'),local('Yrsa-Medium'),url(https://fonts.gstatic.com/s/yrsa/v3/wlpxgwnQFlxs3f_87I0x2Q.ttf) format('truetype')}@font-face{font-family:Yrsa;font-style:normal;font-weight:600;src:local('Yrsa SemiBold'),local('Yrsa-SemiBold'),url(https://fonts.gstatic.com/s/yrsa/v3/wlpxgwnQFlxs3dP77I0x2Q.ttf) format('truetype')}@font-face{font-family:Yrsa;font-style:normal;font-weight:700;src:local('Yrsa Bold'),local('Yrsa-Bold'),url(https://fonts.gstatic.com/s/yrsa/v3/wlpxgwnQFlxs3bf67I0x2Q.ttf) format('truetype')}*{box-sizing:border-box}body{font-family:Yrsa,Roboto,'Times New Roman',Times,serif;font-size:22px;line-height:1.6;margin:0;padding:0 0 50px}a:hover{background:#ff0}article,footer,header,main,nav{max-width:800px;margin:0 auto}header{margin-top:30px}header a{font-size:150%;font-weight:700}nav ul{margin-top:10px;padding:0}nav ul li a{color:#444;font-size:85%;margin-right:20px}h1{font-size:200%;line-height:120%}h2{font-size:160%}h3{font-size:140%}h4{font-size:120%}article img{max-width:100%;display:block}article img[src*='#center']{display:block;margin:auto}time{display:block;font-size:85%;color:#444}ul{list-style-type:square}main ul{margin-top:40px;padding:0 20px}main ul li{margin-bottom:25px;margin-left:-20px;list-style-type:none}main ul li a{font-size:100%;font-weight:600}main ul div{font-size:116%}blockquote{margin:40px 0 40px 20px;border-left:5px solid #eee;padding:5px 0 10px 20px}.highlighter-rouge,table,table td,table th{border:2px solid #f1f1f1}table{width:100%;border-collapse:collapse;border-spacing:0}table td,table th{text-align:left;padding:5px 10px}summary{outline:0;font-weight:600}details .highlighter-rouge{margin-top:10px!important}.highlighter-rouge{padding:0 15px;font-size:60%;overflow:auto}.highlighter-rouge table,.highlighter-rouge table td{border:0!important}::selection{background:#ff0;color:#000}::-moz-selection{background:#ff0;color:#000}ol{list-style:none;counter-reset:li}ol li{counter-increment:li}ol li::before{content:counter(li) ".";color:#ccc;font-weight:500;width:1em;margin-left:-1.5em;margin-right:.9em;text-align:right}.footnotes p{padding:0;margin:0}#hcb_form_content,#hcb_form_name{border:2px solid #eee;padding:10px;width:300px;margin-bottom:10px}#hcb_submit{-webkit-appearance:none;-moz-appearance:none;-o-appearance:none;-ms-appearance:none;appearance:none;font-weight:600;padding:7px 15px;font-size:85%;border-radius:3px;background:#ccc;border:2px solid transparent;width:auto;text-align:center;height:auto;margin-right:20px}@media only screen and (max-width:768px){body{padding:0 20px}footer,header,nav{text-align:center}.responsive-table{width:100%;overflow:scroll}h1{font-size:200%}.footnotes{overflow:auto}}@media print{@page{margin:2cm}.comments,header,nav{display:none}} \ No newline at end of file diff --git a/_layouts/index.html b/_layouts/index.html deleted file mode 100644 index af720a9..0000000 --- a/_layouts/index.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - {{ page.title }} - - - - - - - - - - - - - - - - - - - - - - {% include header.html %} - -
- {{ content }} - - -
- - {% include footer.html %} - - diff --git a/_layouts/page.html b/_layouts/page.html deleted file mode 100644 index 68de599..0000000 --- a/_layouts/page.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - {{ page.title }} - - - - - - - - - - - - - - - - - - - - - - {% include header.html %} - -
-

{{ page.title }}

- - {{ content }} -
- - {% include footer.html %} - - diff --git a/_layouts/post.html b/_layouts/post.html deleted file mode 100644 index d0d1319..0000000 --- a/_layouts/post.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - {{ page.title }} - - - - - - - - - - - - - - - - - - - - - - {% include header.html %} - -
- -

{{ page.title }}

- - - - {{ content }} - -
- - {% include footer.html %} - - - - - - \ No newline at end of file diff --git a/_posts/2015-11-10-software-development-pitfalls.md b/_posts/2015-11-10-software-development-pitfalls.md deleted file mode 100644 index ffee159..0000000 --- a/_posts/2015-11-10-software-development-pitfalls.md +++ /dev/null @@ -1,85 +0,0 @@ ---- - -layout: post -title: Software development and my favorite pitfalls -description: Couple of observations regarding project management. - ---- - -**Table of contents** - -1. [Initial thoughts](#initial-thoughts) -2. [Ping emails](#ping-emails) -3. [Everybody is a project manager](#everybody-is-a-project-manager) -4. [We are never wrong](#we-are-never-wrong) -5. [Micromanaging](#micromanaging) -6. [Human contact - no need for it!](#human-contact---no-need-for-it) -7. [MVP is killing innovation](#mvp-is-killing-innovation) -8. [Pressure wasteland](#pressure-wasteland) -9. [Conclusion](#conclusion) - -## Initial thoughts - -Over the years I had privilege to work on some very excited projects both in software development field and also in electronics field and every experience taught me some invaluable lessons about how NOT TO approach development. And through this post I will try to point out some of the absurd outdated techniques I find the most annoying and damaging during a development cycle. There will be swearing because this topic really gets on my nerves and I never coherently tried to explain them in writing. So if I get heated up please bare with me :) - -As new methods of project management are emerging, underlaying processes still stay old and outdated. This is mainly because we as people are unable to completely shift away from this approaches. - -I was always struggling with communication, and many times that cost me a relationship or two because I was not on the ball all the time. Through every experience I became more convinced that I am the problem and never ever doubted that the problem may be that communication never evolved a single step from emails. And if you think for a second, not many thing have changed around this topic. We just have different representations of email (message boards, chats, project management tools). And I believe this is the real problem we are facing now. - -There are many articles written about hyper connectivity and the effects that are a direct result of it. But mainstream does nothing towards it. We are just putting out fires and we do nothing to prevent it. I am certain this will be a major source of grief in coming years. And what we all can do to avoid this is to change our mindset and experiment on our communication skills, development approaches. We need to maximize possible output that a person can give. And to achieve this we need to listen to them, encourage them. I know that not everybody is a naturally born leader, but everybody has an opinion. - -There are many talks right now about methodologies such as Scrum, Kanban, Cleanroom and they all fucking piss me of :). These are all boxes that imprison people and take away their freedom of thought. This is a straight forward mindfuck / amputation of creativity. - -Let me list a couple of things that I find really destructive and bad for a project and in a long run company. - -## Ping emails - -Ping emails are emails you have to write as soon as you receive an email. It’s sole purpose is to inform sender that you received their email and you are working on it. It’s result is only to calm down the sender that their task is being dealt with. It’s intent basically is, I did my job by sending you this email so I am on clear ground. I categorize this email as fuck you email. This is one of the most irritating types of emails I need to write. This is the ultimate control freak show you can experience and it gives sender false feeling of control. Newsflash: We do not live in 1982 where there was a possibility that email never reached destination. I really fucking hate this from the bottom of my heart :) - -They should be like: “Yes, I am fucking alive and I am at your service my leash!”. I guess if I would reply like this, I wouldn’t have to write any more of this kind of messages :) - -## Everybody is a project manager - -Well, this is a tough one. I noticed that as soon as you let people to give their suggestions you are basically fucked. There is a truth in saying: “Give low expectations and deliver little bit more you promised.”. - -People tend to take a role of a manager as soon as they are presented with an opportunity. And by getting angry at them you only provoke yourself. They are not at fault. You just need to tell them they are only giving suggestions and not tasks at the beginning and everything will be alright. But if you give them a feeling that they are in control you will have immense problems explaining why their features are not in current release. - -Project mission must be always on the top of project requirements and any deviation from it will result in major project butchering. And by this I mean that project will get it’s own path and you will be left with half done software that helps nobody. Clear mission goal and clean execution will allow you to develop software will clear intent. - -## We are never wrong - -I find this type of arrogance the worst. We must always conduct ourselves that we are infallible and cannot make mistakes. As soon as procedure or process is established there is no room for changes or improvements. This is the most idiotic thing someone can say of think. If think that processes need to involve and change over time. This is imperative and need to have in your organization if you want to improve and develop company. We all need to grow balls and change everything in order to adapt to current situations. Being a prisoner of predefined processes kills creativity. - -I am constantly trying new software for project managing and communication. I believe every team has it’s own dynamic and it needs to be discovered organically and naturally through many experiments. By putting team in a box you are amputating their creativity and therefore minimizing their potential. But if you talk to an executive you will mainly find archetypical thinking and a strong need to compartmentalize everything from business processes to resource management. And this type of management that often displays micro management technique only works on short periods (couple of years) and then employees either leave company or become basically retarded drones on auto pilot. - -## Micromanaging - -This basically implies that everybody on the team is a fucking idiot that needs to have a todo list that they can not write themselves. How about spoon feeding the team at launch because besides the team leader everybody must be a retarded idiot at best. - -I prefer milestones as they give developers much more freedom and creativity developing and not waste their time checking some bizarre todo list that was not even thought through. Project always changes through development cycle and all you are left at the end is a list of unchecked tasks and the wrath of management why they are not completed. Best WTF moment! - -## Human contact - no need for it! - -We are vigorously trying to eliminate physical contact by replacing short meetings with software with no regards that we are not machines. Many times a simple 5min meeting at morning can solve most of the problems. In rapid development short bursts of man to man communication is possibly the best way to go. - -We now have all this software available and all what we get out of it is a huge clusterfuck. An obstacle and not a solution. So why we still use them? Because we strive to better ourselves. - -## MVP is killing innovation - -Many will disagree with me on this one but I stand strong by this statement. What I noticed in my experience that all this buzz words surrounding us only mislead and capture you in a circle of solving a problem that already has a solution but we are unable to see it without using some fancy word for it. The toughest this to do for a developer is to minimize requirements. Well this is though only for bad developers. Yes, I said is. There are many types of developers out there. And those unable to minimize feature scope are the ones you don’t need on your team. Their only goal is to solve problems that exist only in their fucking heads. And than you have to argue with them and waste energy on them instead of developing your awesome product. They are a cancer and I suggest you cut them off. - -MVP as an idea is great but sadly people don’t understand underlaying philosophy and they spent too much time focusing and fixating on something that every sane person with normal IQ will understand without some made up acronym. And the result is a lot of talking and barely no execution. - -Well MVP is not directly killing innovation but stupid people do when they try to understand it. - -## Pressure wasteland - -You must never allow to be pressured into confirming a deadline if you are not sure. We often feel a need that we are in service of others which is true to some extent. But it is also true that others are in service to us to some extent. And we forget this. We are all pressured all the time to make decisions just to calm other people down. And when they leave your office you experience WTF moment :) How the hell did they manage to fuck me up again :) - -People need to realize that more pressure you put on somebody less they will be able todo. So 5 min update email requests will only resolve in mental breakdown and inability to work that day. Constant poking is probably the only thing I loose my mind instantly. For all you that are doing this: “We are not fucking idiots and stop bothering us with your own insecurities and let us do our job. We will do it quicker and better without you moron breathing on our necks.” - -If this happens to me I end up with no energy at the end. Don’t you get it? You will get much more from and out of me if you ask me like a human person and not your personal butler. On a long run you are destroying your relationships and nobody would want to work with you. Your schizophrenic approach will damage only you in a long run. Nobody is anybody’s property. - -## Conclusion - -I am guilty of many things described in this post. And I find it hard sometimes to acknowledge this. And I lie to myself and try vigorously to find some explanation why I do this things. There is always space for growth. And maybe you will also find some of yourself in this post and realize what needs to change in order to evolve. diff --git a/_posts/2016-10-14-how-we-successfully-destroyed-the-joy-of-product-development.md b/_posts/2016-10-14-how-we-successfully-destroyed-the-joy-of-product-development.md deleted file mode 100644 index 45028ad..0000000 --- a/_posts/2016-10-14-how-we-successfully-destroyed-the-joy-of-product-development.md +++ /dev/null @@ -1,39 +0,0 @@ ---- - -layout: post -title: How we successfully destroyed the joy of product development -description: My take on project development. - ---- - -No matter how hard we try to reinvent processes in software development we still haven’t found perfect solution for this. And to dismiss SDLC just because it’s something old is as ridiculous as the concept of designers being user experience gurus. As I have written couple of times before designers have their place and is not in the UX community. Most of them probably never heard of Jakob Nielsen and this proves a lot. Don’t get me wrong. There are designers out there that are absolutely amazing in what they do, but most of them are not. Good design has little to do with how things look in my opinion. But it has very much to do with how product behaves. And to take a chance on design look only is scary to me. - -I have this huge beef with so called UX “experts”. I really do. From the bottom of my heart. I almost hate them. Well, not the pure ghetto ones. There are many of them out there I am sure of. But I have not had the pleasure to work with such person. - -Good UX expert should have programming background and an eye for design. Being UX expert requires you to be analytical and precise. Not really qualities of designers. Design is much more about the feeling and emotional perception. And this two don’t dance well together. - -Natural progression of project focused on user should be: - -- detailed requirements and fantastic prototypes/wireframes with detailed user journey diagrams, -- design focused and restricted to serve requirements, -- code written just to fulfill design and requirements → nothing more and nothing less → no additional dead code should be allowed, -- testing should be done on all targeted devices → avoid bugs and you will avoid brand failure. - -Designer should never be allowed to have blank canvas. Good software is written because there are many restrictions either in requirements or real world. And most importantly → good software is solving only one problem at the time. I don’t see why this shouldn’t apply to design as well. - -Yes yes we get it, but we don’t have the time or the money to do project development like that. Well, you better find it or you will slowly decline into abyss of mediocre companies that have nothing to show for. Clients are not dumb and are in need of quality products and services. It is not enough anymore for a product that just works. It has to be technically precise and functionally on the spot. - -When developers and designers are forced to think and work from the scratch many new doors open. New ideas are born how to solve problems that were previously not possible because they were living in a box of limited thought and patterns. If you solve problems always only with your knowledge nothing new can be invented. When there is no room for experimentation there is no room for improvement. You want your developers and designers to be this fountain of innovation and you don’t really let them innovate, you are just slowly closing front doors of your company. Good developers and designers are hard to find and even easier to loose. - -Being agile does not mean to be a slave of constant changes. It does not mean that project managers can constantly change requirements at their will. And it sure does not mean that clear vision on product direction should be something we said goodby to. We have perverted initial intention of Manifesto for Agile Software Development as we always do. We have taken it so far and we have all become slaves of advertisement by consulting companies trying to cash in on this “new - but old” concept. - -Manifesto for Agile Software Development states: - -- individuals and interactions over processes and tools, -- working software over comprehensive documentation, -- customer collaboration over contract negotiation, -- responding to change over following a plan. - -This was written in times when software was developed very differently than how we do it now. We have eliminated many of the problems from old age just by listening to reason and not trendy hyped words that are just tools of marketing strategist to avoid the real issues. Being flat, being agile, being stupid is what I say. - -Development and design should be about improving yourself and consequently product you are working on. When this becomes a chore you should probably start thinking about changing companies. People make products not management. diff --git a/_posts/2017-01-12-gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.md b/_posts/2017-01-12-gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.md deleted file mode 100644 index c55af32..0000000 --- a/_posts/2017-01-12-gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.md +++ /dev/null @@ -1,50 +0,0 @@ ---- - -layout: post -title: GCE, AWS, Docker and why I choose classic VM’s and DigitalOcean for my current project -description: Reasons why I choose DigitalOcean for my project - ---- - -**Table of contents** - -1. [Docker tools and complexity that comes with it](#docker-tools-and-complexity-that-comes-with-it) -2. [Lack of real life examples of Docker in action](#lack-of-real-life-examples-of-docker-in-action) -3. [Ease of deployment](#ease-of-deployment) -4. [Where to go from here](#where-to-go-from-here) - -I have been developing a product for the past few months and one of product’s requirement is the ability to automatically scale quickly on system’s demand. - -As most of you probably know system design is much more important then actual code that will drive the product. And this was my main concern when developing this product. I have read anything I could get my hands on about Docker as it was hyped so much in media for the past two years. At a first glance Docker was ideal fit for this platform. But then as I started to seriously experiment with it and developing around it several problems occurred. Well, it would be unfair to call them problems but lets say drawbacks when developing rapidly. - -To put it in perspective: this project is basically MVP that needs to automatically scale when new customers signs up. These customers are sending metrics to my system that is later visualized and analyzed. There were some basic requirements that I needed the answer before I choose technology. - -- Pricing involving hardware and infrastructure. -- Ease of implementation/deployment and scaling. -- How much will this cost me per customer? - -The way I envisioned the architecture was straight forward → simple nodes in cluster that take care of x number of customers (1 node ~ 10 customers). I found that pricing in GCE and AWS is very hard to predict → what the cost will be when system would scale. And this was necessary for me to know in order to make financial projection of costs. This is the most important thing for me at this time as I am deciding on prices we should charge future customers and establish healthy revenue model and subsequently business model. I want this product to organically scale and fuel its future development with money made by product itself → very little startup capital (10 nodes for six months & capital for company expanses). I have made many simulations but could not figure out with at least some certainty what will that cost be. Based on this both of the providers are currently not suited for me. So I choose DigitalOcean. They have really straight forward pricing model and this allowed me to make pretty accurate cost matrix for my infrastructure. - -I love hard metrics. By this I mean metrics I can test now and have trust they will hold in the future. This was the reason I found Docker too volatile as containers are spawned and halted and there is really no way in predicting this numbers. I have no problem with spawning multiple VMs and not using them but having basically limited control over that is at this time unacceptable for me. - -## Docker tools and complexity that comes with it - -Probably some of you will correct me on this one, but I find all this management tools like Kubernetes, Swarm etc a bit overkill for a startup project. All this tools are able to scale really massively but they all require extensive knowledge of DevOps. When you are a one man band trying to push a product out, there just is no time to learn these tools and concepts in depth in order to really take advantage of their features. It is much easier to use internal metrics of your app (uwsgi stats server, golang middleware stats) and simply fetch them to one server and visualize them. That task alone took me couple of hours and I had simple metrics system in place that with collaboration of DigitalOcean API enabled me to auto spawn new VMs on demand when users reached max number of users supported by current number of nodes. There is something to say about simplicity of this solution. And I love simple solutions. - -## Lack of real life examples of Docker in action - -I found many HelloWorld examples and tutorials showing how to spawn containers and deploying simple python apps but I haven’t found really clear example of showing how to battle permanent storage with containers, load balancing, disk management, ip & port management. - -This is not Docker’s nor community’s fault to be absolutely clear. It just shows that it is not that simple to deploy real-world application with Docker. Maybe my software architecture is not designed with Docker in mind. - -## Ease of deployment - -What I really love about Docker is ease of deployment of your application code via container. Multilayered architecture of Docker images also adds to pros list. And the fact that containers sit on top of host OS makes it very intriguing. But if you use container engine from Google you basically spawn VM’s and run containers in this machines and this takes bare-metal approach out of the equation. So at the end you still use hypervisior. I guess if I had my own hardware servers I would be able to fully take advantage of containers. - -Because most of my code in nodes is written in Golang and C++ deployment becomes pretty easy. All I have to do is replace binaries on node and that’s that. To avoid downtime I have two instances of one node and I load balance between them. So when I am updating software I first update on node1.A and then node1.B if first one is successful. - -## Where to go from here - -Docker is amazing technology. But the weird pricing model and steep learning curve for deployment of real live application at this time is too much of a hassle for me. I am sure I could lower costs with Docker approach but it would just took too much time at this stage to implement it properly. - -I am currently trying to adapt my project to fit Docker and I believe this would be an interesting solution. Idea is to use one container for one customer. I would just need to find the solution for auto-spawning containers on demand for a specific customer. I would then need a flexible load balancer to correctly forward traffic to container designated for this customer. The problem I have is that I need very flexible storage solution because the amount of data that will be aggregated will scale exponentially and I need to permanently store this on disk. And VM approach is allowing me to precisely calculate per customer per VM how much disk I need. Maybe one of you may have a better solution. diff --git a/_posts/2017-03-07-golang-profiling-simplified.md b/_posts/2017-03-07-golang-profiling-simplified.md deleted file mode 100644 index 4c7266c..0000000 --- a/_posts/2017-03-07-golang-profiling-simplified.md +++ /dev/null @@ -1,121 +0,0 @@ ---- - -layout: post -title: Golang profiling simplified -description: Golang profiling made easy - ---- - -**Table of contents** - -1. [Where are my pprof files?](#where-are-my-pprof-files) -2. [Why is my cpu profile empty?](#why-is-my-cpu-profile-empty) -3. [Profiling](#profiling) - 1. [Memory profiling](#memory-profiling) - 2. [CPU profiling](#cpu-profiling) - 3. [Generating profiling reports](#generating-profiling-reports) - -Many posts have been written regarding profiling in Golang and I haven’t found proper tutorial regarding this. Almost all of them are missing some part of important information and it gets pretty frustrating when you have a deadline and are not finding simple distilled solution. - -Nevertheless, after searching and experimenting I have found a solution that works for me and probably should also for you. - -## Where are my pprof files? - -By default pprof files are generated in /tmp/ folder. You can override folder where this files are generated programmatically in your golang code as we will see below in example. - -## Why is my cpu profile empty? - -I have found out that sometimes CPU profile is empty because program was not executing long enough. Programs, that execute too quickly don’t produce pprof file in my cases. Well, file is generated but only contains 4KB of information. - -## Profiling - -As you can see from examples we are executing dummy_benchmark functions to ensure some sort of execution. Memory profiling can be done without such a “complex” function. But CPU profiling needs it. - -Both memory and CPU profiling examples are almost the same. Only parameters in main function when calling profile.Start are different. When we set profile.ProfilePath(“.”) we tell profiler to store pprof files in the same folder as our program. - -### Memory profiling - -```go -package main - -import ( - "fmt" - "time" - "github.com/pkg/profile" -) - -func dummy_benchmark() { - - fmt.Println("first set ...") - for i := 0; i < 918231333; i++ { - i *= 2 - i /= 2 - } - - <-time.After(time.Second*3) - - fmt.Println("sencond set ...") - for i := 0; i < 9182312232; i++ { - i *= 2 - i /= 2 - } -} - -func main() { - defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() - dummy_benchmark() -} -``` - -### CPU profiling - -```go -package main - -import ( - "fmt" - "time" - "github.com/pkg/profile" -) - -func dummy_benchmark() { - - fmt.Println("first set ...") - for i := 0; i < 918231333; i++ { - i *= 2 - i /= 2 - } - - <-time.After(time.Second*3) - - fmt.Println("sencond set ...") - for i := 0; i < 9182312232; i++ { - i *= 2 - i /= 2 - } -} - -func main() { - defer profile.Start(profile.CPUProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() - dummy_benchmark() -} -``` - -### Generating profiling reports - -```bash -# memory profiling -go build mem.go -./mem -go tool pprof -pdf ./mem mem.pprof > mem.pdf - -# cpu profiling -go build cpu.go -./cpu -go tool pprof -pdf ./cpu cpu.pprof > cpu.pdf -``` - -This will generate PDF document with visualized profile. - -- [Memory PDF profile example](/files/golang-profiling-mem.pdf) -- [CPU PDF profile example](/files/golang-profiling-cpu.pdf) diff --git a/_posts/2017-04-10-what-its-like-to-be-a-software-developer.md b/_posts/2017-04-10-what-its-like-to-be-a-software-developer.md deleted file mode 100644 index f18f5dd..0000000 --- a/_posts/2017-04-10-what-its-like-to-be-a-software-developer.md +++ /dev/null @@ -1,33 +0,0 @@ ---- - -layout: post -title: What it's like to be a software developer -description: Couple of observations regarding project management - ---- - -I get asked a lot what the hell I actually do. I find it funny but I guess it is my fault in most cases. I try not to be the kind of a man that is always talking about his work. I live in a small village and most of my neighbours probably have no idea what I actually do. And I am ok with that. I prefer this. But on some occasions I find it disturbing how people judge other people just because they don't understand what they are all about. Many of them probably think I am some strange kind of a looser that is awake all the time and works from home. He probably plays games and type on a computer :) What kind of a job is that? That is no job at all! :) You work for eight hours, then you go home and drink a beer and go work in your workshop. This is what real men do! - -Well, you know. It's just the way it is. And it takes time for people to understand. Being home after many years in living elsewhere really grounded me in some cases. Coming back to the place where you grew up brings some sort of a humility back in your life. And this is ok. Nobody want's to be Icarus anyways. - -What I am meaning to say is if you are in a similar situation as me it will take time for people to start understanding you. Don't get discouraged by this. Take it as it is. People judge what they don't understand. - -I have this saying that sleeping is for pussies and we will sleep when we die. I am 32 years old now and I haven't slowed down regarding my work hours. I have steped up the pace. I usually work for about 16-18 hours a day every day. It doesn't matter if it's Monday or Saturday. Work needs to be done. - -I know that there are other ways. But if you want to be good there really is no other way. There are no shortcuts. There is no easier way to get to the point where you really know what the hell you are doing. Myth about this genius programmer truly is one huge bullshit. Without putting in the hours nothing can be achieved. There is no success without dedication. - -My friends and coworkers often ask me how the hell did I learn so much stuff. Where do I find the time to go through all this material. And I have a simple response for them: "When you go to sleep I begin reading and prototyping. When you go on a trip I make prototype projects just for the sake of learning. When you take your time for fucking around I read articles and books hunting that single small piece of information that will help me one day." And often they don't believe me. They think I am just that smart and everything is easy for me. They have this misguided belief that I just had all this knowledge implanted in me at birth. And this is not the case. I have read so much in my lifetime and most of this information was useful to me later in my life. But that didn't stop me even though I had no immediate use of it. This probably is the main difference between me and my friends. I don't learn because I need to but because I am piecing together this huge puzzle and I threat is like a game. This amazing game of enlightenment. - -I had many burn-downs in my career. Most of them come around new years. I guess around this time things slow down a bit and right then when you relax for a minute or two things get real :). They say when you enter your retirment you should never ever park your ass on a couch. You will die there :) When my burndown happens I fall into this huge depression and I start questioning my sanity. I question my decisions. I question my progress in life. I question everything. I try to understand if all this is worth it?! And every time this happens I struggle with this kind of questions. And by the time all this is over I come to the same conclusion every single time. Yes it fucking is worth it. And through the years I have noticed that this is some sort of a reset for me. This helps me maintain my sanity in the long run :) I love it when things get tough. It gets me to the next level. This teaches me progress is life. - -I don't even count anymore how many programming languages I have learned. I even stop noticing projects. They just fly by. It's like I am hunting this revelation that is set for me. And this drives me. This helps me every day to step up my game. Every single problem I solve I come little closer to my goal. My never reaching goal. And it's ok with me if I never reach this goal. - -The only problem I have now is time. There just ain't enough time to learn everything day has to offer. It's like I am on a quest to become this mini search machine :). - -This obsession with learning has come to the point where I stopped watching TV and news all together. I find this as noise that clutters your mind. The whole point about news is to frighten you and put your mind into a dangerous loop where you thinks that nothing matters anyways → world is going to shit. And the truth is so far away from this. We are living in this times where all this amazing possibilities are at hand. We just need to take control of our mindset and everything starts to look possible again. - -What else can say after more than 10 years in this space? What else can be said anyways? I still love what I do as much as I did 10 years ago. I love it even more. And if I would have a single suggestion for all of you is to stop worrying about immediate benefits and focus on the long run. Learn, prototype, experiment and have fun. We all get frustrated at times but that doesn't mean we should stop. Doing this kind of work is a privilege. We are making and creating. In the most pure sense we are creators. And there really is no better way to live your life. - -> A life without challenge, a life without hardship, a life without purpose, seems pale and pointless. With challenge come perseverance and gumption. With hardship come resilience and resolve. With purpose come strength and understanding. -> -> — Terry Fallis, The High Road diff --git a/_posts/2017-04-17-what-i-ve-learned-developing-ad-server.md b/_posts/2017-04-17-what-i-ve-learned-developing-ad-server.md deleted file mode 100644 index bfacd6f..0000000 --- a/_posts/2017-04-17-what-i-ve-learned-developing-ad-server.md +++ /dev/null @@ -1,144 +0,0 @@ ---- - -layout: post -title: What I've learned developing ad server -description: Lessons I learned developing contextual ad server - ---- - -**Table of contents** - -1. [Aggregate everything](#aggregate-everything) -2. [Measure everything](#measure-everything) -3. [Cache control is your friend](#cache-control-is-your-friend) -4. [Learn NGINX](#learn-nginx) -5. [Use Redis/Memcached](#use-redismemcached) -6. [Conclusion](#conclusion) - -For the past year and half I have been developing native advertising server that contextually matches ads and displays them in different template forms on variety of websites. This project grew from serving thousands of ads per day to millions. - -The system is made from couple of core components: - -- API for serving ads, -- Utils - cronjobs and queue management tools, -- Dashboard UI. - -Initial release was using [MongoDB](https://www.mongodb.com/) for full-text search but was later replaced by [Elasticsearch](https://www.elastic.co/) for better CPU utilization and better search performance. This provided us with many amazing functionalities of [Elasticsearch](https://www.elastic.co/). You should check it out if you do any search related operations. - -Because the premise of the server is to provide native ad experience, they are rendered on the client side via simple templating engine. This ensures that ads can be displayed number of different ways based on the visual style of the page. And this makes Javascript client library quite complex. - -So now that you know basic information about the product lets get into the lessons we learned. - -## Aggregate everything - -After beta version was released everything (impressions, clicks, etc) was written in nanosecond resolution in the database. At that time we were using [PostgreSQL](https://www.postgresql.org/) and database quickly grew way above 200GB in disk space. And that was problematic. Statistics took disturbingly long time to aggregate. Also using indexes on stats table in database was no help after we reached 500 million datapoints. - -> There is a marketing product information and there is real life experience. And the tend to be quite the opposite. - -This was the reason that now everything is aggregated on daily basis and this data is then fed to Elastic in form of daily summary. With this we achieved we can now track many more dimensions such as zone, channel and platform information. And with this information we can now adapt occurrences of ads on specific places more precisely. - -We have also adapted [Redis](https://redis.io/) as a full-time citizen in our stack. Because Redis also stores information on a local disk we have some sort of backup if server would accidentally suffer some failure. - -All the real-time statistics for ad serving and redirecting is presented as counters in Redis instance and daily extracted and pushed to Elastic. - -## Measure everything - -The thing about software is that we really don't know how well it is performing under load until such load is presented. When testing locally everything is fine but when on production things tend to fall apart. - -As a solution for this we are measuring everything we can. Function execution time (by encapsulating functions with timers), server performance (cpu, memory, disk, etc), Nginx and [uWSGI](https://uwsgi-docs.readthedocs.io/) performance. We sacrifice a bit of performance for the sake of this information. And we store all this information for later analysis. - -**Example of function execution time** - -```json -{ - "get_final_filtered_ads": { - "counter": 1931250, - "avg": 0.0066143431, - "elapsed": 12773.9500310003 - }, - "store_keywords_statistics": { - "counter": 1931011, - "avg": 0.0004605267, - "elapsed": 889.2821669996 - }, - "match_by_context": { - "counter": 1931011, - "avg": 0.0055960716, - "elapsed": 10806.0758889999 - }, - "match_by_high_performance": { - "counter": 262, - "avg": 0.0152770229, - "elapsed": 4.00258 - }, - "store_impression_stats": { - "counter": 1931250, - "avg": 0.0006189991, - "elapsed": 1195.4419869999 - } -} -``` - -We have also started profiling with [cProfile](https://pymotw.com/2/profile/) and then visualizing with [KCachegrind](http://kcachegrind.sourceforge.net/). This provides much more detailed look into code execution. - -## Cache control is your friend - -Because we use Javascript library for rendering ads we rely on this script extensively and when in need we need to be able to change behavior of the script quickly. - -In our case we can not simply replace javascript url in html code. It usually takes a day or two for the guys who maintain sites to change code or add ?ver=xxx attribute. And this makes rapid deployment and testing very difficult and time consuming. There is a limitation of how much you can test locally. - -We are now in the process of integrating [Google Tag Manager](https://www.google.com/analytics/tag-manager/) but couple of websites are developed on ASP.net platform that have some problems with tag manager. With a solution below we are certain that we are serving latest version of the script. - -And it only takes one mistake and users have the script cached and in case of caching it for 1 year you probably know where the problem is. - -```nginx -# nginx ➜ /etc/nginx/sites-available/default -location /static/ { - alias /path-to-static-content/; - autoindex off; - charset utf-8; - gzip on; - gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; - location ~* \.(ico|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ { - expires 1y; - add_header Pragma public; - add_header Cache-Control "public"; - } - location ~* \.(css|js|txt)$ { - expires 3600s; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate"; - } -} -``` - -Also be careful when redirecting to url in your python code. We noticed that if we didn't precisely setup cache control and expire headers in response we didn't get the request on the server and therefore couldn't measure clicks. So when redirecting do as follows and there will be no problems. - -```python -# python ➜ bottlepy web micro-framework -response = bottle.HTTPResponse(status=302) -response.set_header("Cache-Control", "no-store, no-cache, must-revalidate") -response.set_header("Expires", "Thu, 01 Jan 1970 00:00:00 GMT") -response.set_header("Location", url) -return response -``` - -> Cache control in browsers is quite aggressive and you need to be precise to avoid future problems. We learned that lesson the hard way. - -## Learn NGINX - -When deciding on a web server we went with Nginx as a reverse proxy for our applications. We adapted micro-service oriented architecture early in the project to ensure when we scale we can easily add additional servers to our cluster. And Nginx was crucial to perform load balancing and static content delivery. - -At first our config file was quite simple and later grew larger. After patching and adding new settings I sat down and learned more about the guts of Nginx. This proved to be very useful and we were able to squeeze much more out of our setup. So I advise you to take your time and read through the [documentation](https://nginx.org/en/docs/). This saved us a lot of headache. Googling for solutions only goes so far. - -## Use Redis/Memcached - -As explained above we are using caching basically for everything. It is the corner stone of our services. At first we were very careful about the quantity of things we stored in [Redis](https://redis.io/). But we later found out that the memory footprint is very low even when storing large amount of data in it. - -So we gradually increased our usage to caching whole HTML outputs of dashboard. This improved our performance in order of magnitude. And by using native TTL support this goes hand in hand with our needs. - -The reason why we choose [Redis](https://redis.io/) over [Memcached](https://memcached.org/) was the nature of scalability of Redis out of the box. But all this can be achieved with Memcached. - -## Conclusion - -There are a lot more details that could have been written and every single topic in here deserves it's own post but you probably got the idea about the problems we faced. diff --git a/_posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md b/_posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md deleted file mode 100644 index dcd8ce1..0000000 --- a/_posts/2017-04-21-profiling-python-web-applications-with-visual-tools.md +++ /dev/null @@ -1,192 +0,0 @@ ---- - -layout: post -title: Profiling Python web applications with visual tools -description: Missing link when debugging and profiling python web applications - ---- - -**Table of contents** - -1. [Simple web-service](#simple-web-service) -2. [Visualize profile](#visualize-profile) -3. [Update 2017-04-22](#update-2017-04-22) - -I have been profiling my software with KCachegrind for a long time now and I was missing this option when I am developing API's or other web services. I always knew that this is possible but never really took the time and dive into it. - -Before we begin there are some requirements. We will need to: - -- implement [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) into our web app, -- convert output to [callgrind](http://valgrind.org/docs/manual/cl-manual.html) format with [pyprof2calltree](https://pypi.python.org/pypi/pyprof2calltree/), -- visualize data with [KCachegrind](http://kcachegrind.sourceforge.net/html/Home.html) or [Profiling Viewer](http://www.profilingviewer.com/). - - -If you are using MacOS you should check out [Profiling Viewer](http://www.profilingviewer.com/) or [MacCallGrind](http://www.maccallgrind.com/). - -![KCachegrind](/files/kcachegrind.png) - -We will be dividing this post into two main categories: - -- writing simple web-service, -- visualize profile of this web-service. - -## Simple web-service - -Let's use virtualenv so we won't pollute our base system. If you don't have virtualenv installed on your system you can install it with pip command. - -```bash -# let's install virtualenv globally -$ sudo pip install virtualenv - -# let's also install pyprof2calltree globally -$ sudo pip install pyprof2calltree - -# now we create project -$ mkdir demo-project -$ cd demo-project/ - -# now let's create folder where we will store profiles -$ mkdir prof - -# now we create empty virtualenv in venv/ folder -$ virtualenv --no-site-packages venv - -# we now need to activate virtualenv -$ source venv/bin/activate - -# you can check if virtualenv was correctly initialized by -# checking where your python interpreter is located -# if command bellow points to your created directory and not some -# system dir like /usr/bin/python then everything is fine -$ which python - -# we can check now if all is good ➜ if ok couple of -# lines will be displayed -$ pip freeze -# appdirs==1.4.3 -# packaging==16.8 -# pyparsing==2.2.0 -# six==1.10.0 - -# now we are ready to install bottlepy ➜ web micro-framework -$ pip install bottle - -# you can deactivate virtualenv but you will then go -# under system domain ➜ for now don't deactivate -$ deactivate -``` - -We are now ready to write simple web service. Let's create file app.py and paste code bellow in this newly created file. - -```python -# -*- coding: utf-8 -*- - -import bottle -import random -import cProfile - -app = bottle.Bottle() - -# this function is a decorator and encapsulates function -# and performs profiling and then saves it to subfolder -# prof/function-name.prof -# in our example only awesome_random_number function will -# be profiled because it has do_cprofile defined -def do_cprofile(func): - def profiled_func(*args, **kwargs): - profile = cProfile.Profile() - try: - profile.enable() - result = func(*args, **kwargs) - profile.disable() - return result - finally: - profile.dump_stats("prof/" + str(func.__name__) + ".prof") - return profiled_func - - -# we use profiling over specific function with including -# @do_cprofile above function declaration -@app.route("/") -@do_cprofile -def awesome_random_number(): - awesome_random_number = random.randint(0, 100) - return "awesome random number is " + str(awesome_random_number) - -@app.route("/test") -def test(): - return "dummy test" - -if __name__ == '__main__': - bottle.run( - app = app, - host = "0.0.0.0", - port = 4000 - ) - -# run with 'python app.py' -# open browser 'http://0.0.0.0:4000' -``` - -When browser hits awesome\_random\_number() function profile is created in prof/ subfolder. - -## Visualize profile - -Now let's create callgrind format from this cProfile output. - -```bash -$ cd prof/ -$ pyprof2calltree -i awesome_random_number.prof -# this creates 'awesome_random_number.prof.log' file in the same folder -``` - -This file can be opened with visualizing tools listed above. In this case we will be using Profilling Viewer under MacOS. You can open image in new tab. As you can see from this example there is hierarchy of execution order of your code. - -![Profilling Viewer](/files/profiling-viewer.png) - -> Make sure you convert output of the cProfile output every time you want to refresh and take a look at your possible optimizations because cProfile updates .prof file every time browser hits the function. - -This is just a simple example but when you are developing real-life applications this can be very illuminating, especially to see which parts of your code are bottlenecks and need to be optimized. - -## Update 2017-04-22 - -Reddit user [mvt](https://www.reddit.com/user/mvt) also recommended this awesome web based profile visualizer [SnakeViz](https://jiffyclub.github.io/snakeviz/) that directly takes output from [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) module. - -
Comment from discussion Profiling Python web applications with visual tools.
- -```bash -# let's install it globally as well -$ sudo pip install snakeviz - -# now let's visualize -$ cd prof/ -$ snakeviz awesome_random_number.prof -# this automatically opens browser window and -# shows visualized profile -``` - -![SnakeViz](/files/snakeviz.png) - -Reddit user [ccharles](https://www.reddit.com/user/ccharles) suggested a better way for installing pip software by targeting user level instead of using sudo. - -
Comment from discussion Profiling Python web applications with visual tools.
- -```bash -# now we need to add this path to our $PATH variable -# we do this my adding this line at the end of your -# ~/.bashrc file -PATH=$PATH:$HOME/.local/bin/ - -# in order to use this new configuration you can close -# and reopen terminal or reload .bashrc file -$ source ~/.bashrc - -# now let's test if new directory is present in $PATH -$ echo $PATH - -# now we can install on user level by adding --user -# without use of sudo -$ pip install snakeviz --user -``` - -Or as suggested by [mvt](https://www.reddit.com/user/mvt) you can use [pipsi](https://github.com/mitsuhiko/pipsi). diff --git a/_posts/2017-08-11-simple-iot-application.md b/_posts/2017-08-11-simple-iot-application.md deleted file mode 100644 index cd0179e..0000000 --- a/_posts/2017-08-11-simple-iot-application.md +++ /dev/null @@ -1,499 +0,0 @@ ---- - -layout: post -title: Simple IOT application supported by real-time monitoring and data history -description: Develop simple IOT application with Arduino MKR1000 and Python - ---- - -**Table of contents** - -1. [Initial thoughts](#initial-thoughts) -2. [Simple Python API](#simple-python-api) - 1. [Basic web application](#basic-web-application) - 2. [Web application security](#web-application-security) - 3. [Simple API for writing data-points](#simple-api-for-writing-data-points) -3. [Sending data to API with Arduino MKR1000](#sending-data-to-api-with-arduino-mkr1000) -4. [Data visualization](#data-visualization) -5. [Conclusion](#conclusion) - -## Initial thoughts - -I have been developing these kind of application for the better part of my last 5 years and people keep asking me how to approach developing such application and I will give a try explaining it here. - -IOT applications are really no different than any other kind of applications. We have data that needs to be collected and visualized in some form of tables or charts. The main difference here is that most of the times these data is collected by some kind of device foreign to developer that mainly operates in web domain. But fear not, it's not that different than writing some JavaScript. - -There are many devices able to transmit data via wireless or wired network by default but for the sake of example we will be using commonly known Arduino with wireless module already on the board → [Arduino MKR1000](https://store.arduino.cc/arduino-mkr1000). - -In order to make this little project as accessible to others as possible I will try to make it as inexpensive as possible. And by this I mean that I will avoid using hosted virtual servers and will be using my own laptop as a server. But you must buy Arduino MKR1000 to follow steps below. But if you would want to deploy this software I would suggest using [DigitalOcean](https://www.digitalocean.com) → smallest VPS is only $5 per month making this one of the most affordable option out there. Please notice that this software will not run on stock web hosting that only supports LAMP (Linux, Apache, MySQL, and PHP). - -_But before we begin please take notice that this is strictly experimental code and not well optimized and there are much better ways in handling some aspects of the application but that requires much deeper knowledge of technology that is not needed for an example like this._ - -**Development steps** - -1. Simple Python API that will receive and store incoming data. -2. Prototype C++ code that will read "sensor data" and transmit it to API. -3. Data visualization with charts → extends Python web application. - -Step 1. and 3. will share the same web application. One route will be dedicated to API and another to serving HTML with chart. - -Schema below represents what we will try to achieve and how different parts correlates to each other. - -![Overview](/files/simple-iot-application-overview.svg) - -## Simple Python API - -I have always been a fan of simplicity so we will be using [Bottle: Python Web Framework](https://bottlepy.org/docs/dev/). It is a single file web framework that seriously simplifies working with routes, templating and has built-in web server that satisfies our need in this case. - -First we need to install bottle package. This can be done by downloading ```bottle.py``` and placing it in the root of your application or by using pip software ```pip install bottle --user```. - -If you are using Linux or MacOS then Python is already installed. If you will try to test this on Windows please install [Python for Windows](https://www.python.org/downloads/windows/). There may be some problems with path when you will try to launch ```python webapp.py``` so please take care of this before you continue. - -### Basic web application - -Most basic bottle application is quite simple. Paste code below in ```webapp.py``` file and save. - -```python -# -*- coding: utf-8 -*- - -import bottle - -# initializing bottle app -app = bottle.Bottle() - -# triggered when / is accessed from browser -# only accepts GET → no POST allowed -@app.route("/", method=["GET"]) -def route_default(): - return "howdy from python" - -# starting server on http://0.0.0.0:5000 -if __name__ == "__main__": - bottle.run( - app = app, - host = "0.0.0.0", - port = 5000, - debug = True, - reloader = True, - catchall = True, - ) -``` - -To run this simple application you should open command prompt or terminal on your machine and go to the folder containing your file and type ```python webapp.py```. If everything goes ok then open your web browser and point it to ```http://0.0.0.0:5000```. - -If you would like change the port of your application (like port 80) and not use root to run your app this will present a problem. The TCP/IP port numbers below 1024 are privileged ports → this is a security feature. So in order of simplicity and security use a port number above 1024 like I have used port 5000. - -If this fails at any time please fix it before you continue, because nothing below will work otherwise. - -> We use 0.0.0.0 as default host so that this app is available over your local network. If you find your local ip (```ifconfig```) and try accessing this site with your phone (if on same network/router as your machine) this should work as well (example of such ip ```http://192.168.1.15:5000```). This is a must have because Arduino will be accessing this application to send it's data. - -### Web application security - -There is a lot to be said about security and is a topic of many books. Of course all this can not be written here but to just establish some basic security → you should always use SSL with your application. Some fantastic free certificates are available by [Let's Encrypt - Free SSL/TLS Certificates](https://letsencrypt.org). With SSL certificate installed you should then make use of HTTP headers and send your "API key" via a header. If your key is send via header then this key is encrypted by SSL and send encrypted over the network. Never send your api keys by GET parameter like ```http://example.com/?api_key=somekeyvalue```. The problem that this kind of sending presents is that this key is visible in logs and by network sniffers. - -There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. - -### Simple API for writing data-points - -We will now be using boilerplate code from example above and extend it to be able to write data received by API to local storage. For example use I will use SQLite3 because it plays well with Python and can store quite large amount of data. I have been using it to collect gigabytes of data in a single database without any corruption or problems → your experience may vary. - -To avoid learning SQLite I will be using [Dataset: databases for lazy people](https://dataset.readthedocs.io/en/latest/index.html). This package abstracts SQL and simplifies writing and reading data from database. You should install this package with pip software ```pip install dataset --user```. - -Because API will use POST method I will be testing if code works correctly by using [Restlet Client for Google Chrome](https://chrome.google.com/webstore/detail/restlet-client-rest-api-t/aejoelaoggembcahagimdiliamlcdmfm). This software also allows you to set headers → for basic security with API_KEY. - -To quickly generate passwords or API keys I usually use this nifty website [RandomKeygen](https://randomkeygen.com/). - -Copy and paste code below over your previous code in file ```webapp.py```. - -```python -# -*- coding: utf-8 -*- - -import time -import bottle -import random -import dataset - -# initializing bottle app -app = bottle.Bottle() - -# connects to sqlite database -# check_same_thread=False allows using it in multi-threaded mode -app.config["dsn"] = dataset.connect("sqlite:///data.db?check_same_thread=False") - -# api key that will be used in Arduino code -app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH" - -# triggered when /api is accessed from browser -# only accepts POST → no GET allowed -@app.route("/api", method=["POST"]) -def route_default(): - status = 400 - ts = int(time.time()) # current timestamp - value = bottle.request.body.read() # data from device - api_key = bottle.request.get_header("Api_Key") # api key from header - - # outputs to console received data for debug reason - print ">>> {} :: {}".format(value, api_key) - - # if api_key is correct and value is present - # then writes attribute to point table - if api_key == app.config["api_key"] and value: - app.config["dsn"]["point"].insert(dict(ts=ts, value=value)) - status = 200 - - # we only need to return status - return bottle.HTTPResponse(status=status, body="") - -# starting server on http://0.0.0.0:5000 -if __name__ == "__main__": - bottle.run( - app = app, - host = "0.0.0.0", - port = 5000, - debug = True, - reloader = True, - catchall = True, - ) -``` - -To run this simply go to folder containing python file and run ```python webapp.py``` from terminal. If everything goes ok you should have simple API available via POST method on /api route. - -After testing the service with Restlet Client you should be able to view your data in a database file ```data.db```. - -![REST settings example](/files/iot-rest-example.png) - -You can also check the contents of new database file by using desktop client for SQLite → [DB Browser for SQLite](http://sqlitebrowser.org/). - -![SQLite database example](/files/iot-sqlite-db.png) - -Table structure is as simple as it can be. We have ts (timestamp) and value (value from Arduino). As you can see timestamp is generated on API side. If you would happen to have atomic clock on Arduino it would be then better to generate and send timestamp with the value. This would be particularity useful if we would be collecting sensor data at a higher frequency and then sending this data in bulk to API. - -> If you will deploy this app with uWSGI and multi-threaded, use DSN (Data Source Name) url with ```?check_same_thread=False```. - -Ok, now that we have some sort of a working API with some basic security so unwanted people can not post data to your database can we proceed further and try to program Arduino to send data to API. - -## Sending data to API with Arduino MKR1000 - -First of all you should have MKR1000 module and microUSB cable to proceed. If you have ever done any work with Arduino you should know that you also need [Arduino IDE](https://www.arduino.cc/en/Main/Software). On provided link you should be able to download and install IDE. Once that task is completed and you have successfully run blink example you should proceed to the next step. - -In order to use wireless capabilities of MKR1000 you need to first install [WiFi101 library](https://www.arduino.cc/en/Reference/WiFi101) in Arduino IDE. Please check before you install, you may already have it installed. - -Code below is a working example that sends data to API. Before you try to test your code make sure you have run Python web application. Then change settings for wifi, api endpoint and api_key. If by some reason code bellow doesn't work for you please leave a comment and I'll try to help. - -Once you have opened IDE and copied this code try to compile and upload it. Then open "Serial monitor" to see if any output is presented by Arduino. - -```c -#include - -// wifi settings -char ssid[] = "ssid-name"; -char pass[] = "ssid-password"; - -// api server enpoint -char server[] = "192.168.6.22"; -int port = 5000; - -// api key that must be the same as the one in Python code -String api_key = "JtF2aUE5SGHfVJBCG5SH"; - -// frequency data is sent in ms - every 5 seconds -int timeout = 1000 * 5; - -int status = WL_IDLE_STATUS; - -void setup() { - - // initialize serial and wait for port to open: - Serial.begin(9600); - delay(1000); - - // check for the presence of the shield - if (WiFi.status() == WL_NO_SHIELD) { - Serial.println("WiFi shield not present"); - while (true); - } - - // attempt to connect to wifi network - while (status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - status = WiFi.begin(ssid, pass); - // wait 10 seconds for connection - delay(10000); - } - - // output wifi status to serial monitor - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); -} - -void loop() { - - WiFiClient client; - - if (client.connect(server, port)) { - - // I use random number generator for this example - // but you can use analog or digital inputs from arduino - String content = String(random(1000)); - - client.println("POST /api HTTP/1.1"); - client.println("Connection: close"); - client.println("Api-Key: " + api_key); - client.println("Content-Length: " + String(content.length())); - client.println(); - client.println(content); - - delay(100); - client.stop(); - Serial.println("Data sent successfully ..."); - - } else { - Serial.println("Problem sending data ..."); - } - - // waits for x seconds and continue looping - delay(timeout); - -} -``` - -As seen from example you can notice that Arduino is generating random integer between [ 0 .. 1000 ]. You can easily replace this with a temperature sensor or any other kind of sensor. - -Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. - -## Data visualization - -Before we continue we should examine our project folder structure. Currently we only have two files in our project: - -_simple-iot-app/_ - -* _webapp.py_ -* _data.db_ - -We will now add HTML template that will contain CSS and JavaScript code inline for the simplicity reason. And for the bottle framework to be able to scan root application folder for templates we will add ```bottle.TEMPLATE_PATH.insert(0, "./")``` in ```webapp.py```. By default bottle framework uses ```views/``` subfolder to store templates. This is not the ideal situation and if you will use bottle to develop web applications you should use native behavior and store templates in it's predefined folder. But for the sake of example we will over-ride this. Be careful to fully replace your code with new code that is provided below. Avoid partially replacing code in file :) Also new code for reading data-points is provided in Python example below. - -First we add new route to our web application. It should be trigger when browser hits root of application ```http://0.0.0.0:5000/```. This route will do nothing more than render ```frontend.html``` template. This is done by ```return bottle.template("frontend.html")```. Check code below to further examine how exactly this is done. - -Now we will expand ```/api``` route and use different methods to write or read data-points. For writing data-point we will use POST method and for reading points we will use GET method. GET method will return JSON object with latest readings and historical data. - -There is a fantastic JavaScript library for plotting time-series charts called [MetricsGraphics.js](https://www.metricsgraphicsjs.org) that is based on [D3.js](https://d3js.org/) library for visualizing data. - -Data schema required by MetricsGraphics.js → to achieve this we need to transform data from database into this format: - -```json -[ - { - "date": "2017-08-11 01:07:20", - "value": 933 - }, - { - "date": "2017-08-11 01:07:30", - "value": 743 - } -] -``` - -Web application is now complete and we only need ```frontend.html``` that we will develop now. If you would try to start web app now and go to root app this will return error because we don't have frontend.html yet. - -```python -# -*- coding: utf-8 -*- - -import time -import bottle -import json -import datetime -import random -import dataset - -# initializing bottle app -app = bottle.Bottle() - -# adds root directory as template folder -bottle.TEMPLATE_PATH.insert(0, "./") - -# connects to sqlite database -# check_same_thread=False allows using it in multi-threaded mode -app.config["db"] = dataset.connect("sqlite:///data.db?check_same_thread=False") - -# api key that will be used in Arduino code -app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH" - -# triggered when / is accessed from browser -# only accepts GET → no POST allowed -@app.route("/", method=["GET"]) -def route_default(): - return bottle.template("frontend.html") - -# triggered when /api is accessed from browser -# accepts POST and GET -@app.route("/api", method=["GET", "POST"]) -def route_default(): - - # if method is POST then we write datapoint - if bottle.request.method == "POST": - status = 400 - ts = int(time.time()) # current timestamp - value = bottle.request.body.read() # data from device - api_key = bottle.request.get_header("Api-Key") # api key from header - - # outputs to console recieved data for debug reason - print ">>> {} :: {}".format(value, api_key) - - # if api_key is correct and value is present - # then writes attribute to point table - if api_key == app.config["api_key"] and value: - app.config["db"]["point"].insert(dict(ts=ts, value=value)) - status = 200 - - # we only need to return status - return bottle.HTTPResponse(status=status, body="") - - # if method is GET then we read datapoint - else: - response = [] - datapoints = app.config["db"]["point"].all() - - for point in datapoints: - response.append({ - "date": datetime.datetime.fromtimestamp(int(point["ts"])).strftime("%Y-%m-%d %H:%M:%S"), - "value": point["value"] - }) - - bottle.response.content_type = "application/json" - return json.dumps(response) - -# starting server on http://0.0.0.0:5000 -if __name__ == "__main__": - bottle.run( - app = app, - host = "0.0.0.0", - port = 5000, - debug = True, - reloader = True, - catchall = True, - ) -``` - -And now finally we can implement ```frontend.html```. Create file with this name and copy code below. When you are done you can start web application. Steps for this part are listed below the code. - -```html - - - - - - Simple IOT application - - - - -

Simple IOT application

- -
-
-
- - - - - - - - - - - - - -``` - -Now the folder structure should look like: - -_simple-iot-app/_ - -* _webapp.py_ -* _data.db_ -* _frontend.html_ - -Ok, lets now start application and start feeding it data. - -1. ```python webapp.py``` -2. connect Arduino MKR1000 to power source -3. open browser and go to ```http://0.0.0.0:5000``` - -If everything goes well you should be seeing new data-points rendered on chart every 5 seconds. - -If you navigate to ```http://0.0.0.0:5000``` you should see rendered chart as shown on picture below. - -![Application output](/files/iot-app-output.png) - -Complete application with all the code is available for [download](/files/simple-iot-application.zip). - -## Conclusion - -I hope this clarifies some aspects of IOT application development. Of course this is a minimal example and is far from what can be done in real life with some further dive into other technologies. - -If you would like to continue exploring IOT world here are some interesting resources for you to examine: - -* [Reading Sensors with an Arduino](https://www.allaboutcircuits.com/projects/reading-sensors-with-an-arduino/) -* [MQTT 101 – How to Get Started with the lightweight IoT Protocol](http://www.hivemq.com/blog/how-to-get-started-with-mqtt) -* [Stream Updates with Server-Sent Events](https://www.html5rocks.com/en/tutorials/eventsource/basics/) -* [Internet of Things (IoT) Tutorials](http://www.tutorialspoint.com/internet_of_things/) - -Any comment or additional ideas are welcomed in comments below. diff --git a/_posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md b/_posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md deleted file mode 100644 index 4eccd25..0000000 --- a/_posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md +++ /dev/null @@ -1,271 +0,0 @@ ---- - -layout: post -title: Using DigitalOcean Spaces Object Storage with FUSE -description: Using DigitalOcean Spaces Object Storage with FUSE - ---- - -**Table of contents** - -1. [Is it possible to use them as a mounted drive with FUSE?](#is-it-possible-to-use-them-as-a-mounted-drive-with-fuse) -2. [Will the performance degrade over time and over different sizes of objects?](#will-the-performance-degrade-over-time-and-over-different-sizes-of-objects) - 1. [Measurement experiment 1: File copy](#measurement-experiment-1-file-copy) - 2. [Measurement experiment 2: SQLite performanse](#measurement-experiment-2-sqlite-performanse) -3. [Can storage be mounted on multiple machines at the same time and be writable?](#can-storage-be-mounted-on-multiple-machines-at-the-same-time-and-be-writable) -4. [Observations and conslusion](#observations-and-conslusion) - -Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) which is Object Storage very similar to Amazon's S3. This really peaked my interest, because this was something I was missing and even the thought of going over the internet for such functionality was in no interest to me. Also in fashion with their previous pricing this also is very cheap and pricing page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). You must love them for that :) - -### Initial requirements - -* Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) -* Will the performance degrade over time and over different sizes of objects? (tl;dr NO&YES) -* Can storage be mounted on multiple machines at the same time and be writable? (tl;dr YES) - -> Let me be clear. This scripts I use are made just for benchmarking and are not intended to be used in real-life situations. Besides that, I am looking into using this approaches but adding caching service in front of it and then dumping everything as an object to storage. This could potentially be some interesting post of itself. But in case you would need real-time data without eventual consistency please take this scripts as they are: not usable in such situations. - -## Is it possible to use them as a mounted drive with FUSE? - -Well, actually they can be used in such manor. Because they are similar to [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). - -To make this work you will need DigitalOcean account. If you don't have one you will not be able to test this code. But if you have an account then you go and [create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). If you click on this link you will already have preselected Debian 9 with smallest VM option. - -* Please be sure to add you SSH key, because we will login to this machine remotely. -* If you change your region please remember which one you choose because we will need this information when we try to mount space to our machine. - -Instuctions on how to use SSH keys and how to setup them are available in article [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). - -![DigitalOcean Droplets](/files/fuse-droplets.png) - -After we created Droplet it's time to create new Space. This is done by clicking on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we will use it in examples below. You can either choose Private or Public, it doesn't matter in our case. And you can always change that in the future. - -When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). This link will guide to the page when you can generate this key. After you create new one, please save provided Key and Secret because Secret will not be shown again. - -![DigitalOcean Spaces](/files/fuse-spaces.png) - -Now that we have new Space and Access key we should SSH into our machine. - -```bash -# replace IP with the ip of your newly created droplet -ssh root@IP - -# this will install utilities for mounting storage objects as FUSE -apt install s3fs - -# we now need to provide credentials (access key we created earlier) -# replace KEY and SECRET with your own credentials but leave the colon between them -# we also need to set proper permissions -echo "KEY:SECRET" > .passwd-s3fs -chmod 600 .passwd-s3fs - -# now we mount space to our machine -# replace UNIQUE-NAME with the name you choose earlier -# if you choose different region for your space be careful about -ourl option (ams3) -s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tmp - -# now we try to create a file -# once you mount it may take a couple of seconds to retrieve data -echo "Hello cruel world" > /mnt/hello.txt -``` - -After all this you can return to your browser and go to [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your created space. If file hello.txt is present you have successfully mounted space to your machine and wrote data to it. - -I choose the same region for my Droplet and my Space but you don't have to. You can have different regions. What this actually does to performance I don't know. - -Additional information on FUSE: - -* [Github project page for s3fs](https://github.com/s3fs-fuse/s3fs-fuse) -* [FUSE - Filesystem in Userspace](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) - -## Will the performance degrade over time and over different sizes of objects? - -For this task I didn't want to just read and write text files or uploading images. I actually wanted to figure out if using something like SQlite is viable in this case. - -### Measurement experiment 1: File copy - -```bash -# first we create some dummy files at different sizes -dd if=/dev/zero of=10KB.dat bs=1024 count=10 #10KB -dd if=/dev/zero of=100KB.dat bs=1024 count=100 #100KB -dd if=/dev/zero of=1MB.dat bs=1024 count=1024 #1MB -dd if=/dev/zero of=10MB.dat bs=1024 count=10240 #10MB - -# now we set time command to only return real -TIMEFORMAT=%R - -# now lets test it -(time cp 10KB.dat /mnt/) |& tee -a 10KB.results.txt - -# and now we automate -# this will perform the same operation 100 times -# this will output results into separated files based on objecty size -n=0; while (( n++ < 100 )); do (time cp 10KB.dat /mnt/10KB.$n.dat) |& tee -a 10KB.results.txt; done -n=0; while (( n++ < 100 )); do (time cp 100KB.dat /mnt/100KB.$n.dat) |& tee -a 100KB.results.txt; done -n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.results.txt; done -n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done -``` - -Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). - -As I suspected, object size is not really that important. Sadly I don't have the time to test performance over periods of time. But if some of you would do it please send me your data. I would be interested in seeing results. - -**Here are plotted results** - -You can download [raw result here](/files/copy-benchmarks.tsv). Measurements are in seconds. - - -
- - -As far as these tests show, performance is quite stable and can be predicted which is fantastic. But this is a small test and spans only over couple of hours. So you should not completely trust them. - -### Measurement experiment 2: SQLite performanse - -I was unable to use database file directly from mounted drive so this is a no-go as I suspected. So I executed code below on a local disk just to get some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can see performance of SQLite is quite amazing. You could then potentially just copy file to mounted drive and be done with it. - -```python -import time -import sqlite3 -import sys - -if len(sys.argv) < 3: - print("usage: python sqlite-benchmark.py DB_PATH NUM_RECORDS REPEAT") - exit() - -def data_iter(x): - for i in range(x): - yield "m" + str(i), "f" + str(i*i) - -header_line = "%s\t%s\t%s\t%s\t%s\n" % ("DROPTABLE", "CREATETABLE", "INSERTMANY", "FETCHALL", "COMMIT") -with open("sqlite-benchmarks.tsv", "w") as fp: - fp.write(header_line) - -start_time = time.time() -conn = sqlite3.connect(sys.argv[1]) -c = conn.cursor() -end_time = time.time() -result_time = CONNECT = end_time - start_time -print("CONNECT: %g seconds" % (result_time)) - -start_time = time.time() -c.execute("PRAGMA journal_mode=WAL") -c.execute("PRAGMA temp_store=MEMORY") -c.execute("PRAGMA synchronous=OFF") -result_time = PRAGMA = end_time - start_time -print("PRAGMA: %g seconds" % (result_time)) - -for i in range(int(sys.argv[3])): - print("#%i" % (i)) - - start_time = time.time() - c.execute("drop table if exists test") - end_time = time.time() - result_time = DROPTABLE = end_time - start_time - print("DROPTABLE: %g seconds" % (result_time)) - - start_time = time.time() - c.execute("create table if not exists test(a,b)") - end_time = time.time() - result_time = CREATETABLE = end_time - start_time - print("CREATETABLE: %g seconds" % (result_time)) - - start_time = time.time() - c.executemany("INSERT INTO test VALUES (?, ?)", data_iter(int(sys.argv[2]))) - end_time = time.time() - result_time = INSERTMANY = end_time - start_time - print("INSERTMANY: %g seconds" % (result_time)) - - start_time = time.time() - c.execute("select count(*) from test") - res = c.fetchall() - end_time = time.time() - result_time = FETCHALL = end_time - start_time - print("FETCHALL: %g seconds" % (result_time)) - - start_time = time.time() - conn.commit() - end_time = time.time() - result_time = COMMIT = end_time - start_time - print("COMMIT: %g seconds" % (result_time)) - - print - log_line = "%f\t%f\t%f\t%f\t%f\n" % (DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT) - with open("sqlite-benchmarks.tsv", "a") as fp: - fp.write(log_line) - -start_time = time.time() -conn.close() -end_time = time.time() -result_time = CLOSE = end_time - start_time -print("CLOSE: %g seconds" % (result_time)) -``` - -You can download [raw result here](/files/sqlite-benchmarks.tsv). And again, these results are done on a local block storage and do not represent capabilities of object storage. With my current approach and state of the test code these can not be done. I would need to make Python code much more robust and check locking etc. - -
- - -## Can storage be mounted on multiple machines at the same time and be writable? - -Well, this one didn't take long to test. And the answer is **YES**. I mounted space on both machines and measured same performance on both machines. But because file is downloaded before write and then uploaded on complete there could potentially be problems is another process is trying to access the same file. - -## Observations and conslusion - -Using Spaces in this way makes it easier to access and manage files. But besides that you would need to write additional code to make this one play nice with you applications. - -Nevertheless, this was extremely simple to setup and use and this is just another excellent product in DigitalOcean product line. I found this exercise very valuable and am thinking about implementing some sort of mechanism for SQLite, so data can be stored on Spaces and accessed by many VM's. For a project where data doesn't need to be accessible in real-time and can have couple of minutes old data this would be very interesting. If any of you find this proposal interesting please write in a comment box below or shoot me an email and I will keep you posted. diff --git a/_posts/2018-08-05-the-bullshit-web-developments-pov.md b/_posts/2018-08-05-the-bullshit-web-developments-pov.md deleted file mode 100644 index b8346f6..0000000 --- a/_posts/2018-08-05-the-bullshit-web-developments-pov.md +++ /dev/null @@ -1,113 +0,0 @@ ---- - -layout: post -title: The Bullshit Web - Development's Point of View -description: State of front-end development and what this does to the future of web - ---- - -**Table of contents** - -1. [Initial thoughts](#initial-thoughts) -2. [Front-end frameworks](#front-end-frameworks) -3. [Obsolescence to the rescue](#obsolescence-to-the-rescue) -4. [Unnecessary complexity](#unnecessary-complexity) -5. [Speed of development trumps code quality](#speed-of-development-trumps-code-quality) -6. [Load times of most popular websites](#load-times-of-most-popular-websites) - -## Initial thoughts - -I have recently read an amazing essay by Nick Heer on the web called [The Bullshit Web](https://pxlnv.com/blog/bullshit-web/) and it got me thinking about the future of the web as it is today. - -> The average internet connection in the United States is about six times as fast as it was just ten years ago, but instead of making it faster to browse the same types of websites, we’re simply occupying that extra bandwidth with more stuff. -> -> **-- Nick Heer** - -I really try to stray away from frond-end development as much as possible. The reason is nowhere close to me having any bad opinions but having to work with clients on visual stuff drains me to the point of sheer horror. - -I have observed silently the progress that was made in this field because I thought things will get better with time. I was so wrong. So wrong. Not only that things got extremely complicated to work with, the whole stack became so massive even simple pages have insanely large footprint. - -The Bullshit Web essay concentrates mostly on page sizes and AMP but I would like to address tooling and technologies for development in this post. - -Currently we have two types of websites: - -- informational websites, -- web applications. - -The problem that occurs is that more and more websites are treathed as web application where simple web page would suffice. And this in my opinion adds insult to the injury. - -We talk about progressive web applications, AMP, and other technologies that are solving the problems of bandwidth, usability and in general making web faster but in reality this rarely gets applied in real life scenarios. Most of the time this are just demos on conferences. - -## Front-end frameworks - -I am not of those purists that denies usage of JavaScript frameworks or SASS but there are limits to where this obsession should go. In order to use these technologies properly one should ask himself where exactly they are needed and not use them like hammer for nails. - -Whenever I need to do front-end UI I usually check specification before embarking on journey of coding. And most of the times I really don't need frameworks. Most of the code I need to write in JavaScript is done in couple of hundred lines of code and does exactly what specification requires. And developer that will be working on this code after me doesn't need to learn new framework, tooling, etc. Just pure vanilla JavaScript. In all of my years as a developer I can count on fingers on my one hand when I used some sort of a framework. And even in this exceptions we later rewrote code to vanilla JavaScript because maintaining complex code was just to time consuming. - -There is an argument to be made for using frameworks in cases where multiple people are working a project and code must be easily transferable and on-boarding process must be swift. But in reality this is just another bullshit excuse to stick with what is "cool". I stand by Function over Form. And this also conflicts with the notion that frameworks never change. Frameworks evolve and adapt to market needs and most of the times get massive and hard to maintain. And we get stuck with massive codebase that is developed with many hacks and workarounds, because framework didn't support some feature at the time of development. I personally hate workarounds and being a smart-ass that intentionally makes code harder to read. I find frameworks similar to the story about Cain and Abel. Either you get murdered or framework gets. Most of the times framework dies and leaves legacy nobody would want. - -Huge strives have been made to address this problem and many fantastic frameworks emerged and some of theme are absolutely amazing. But there needs to be a strong case for using them in a project. We should never blindly use them regardless of the problem we are trying to solve. - -I must admit that tooling around front-end is getting better and better and we are slowly getting there but there still is a long road ahead. - -## Obsolescence to the rescue - -We can all agree that frameworks or libraries usually are there to fill the gap what currently is widely supported by the standard. Most of this so called frameworks are just libraries that unifies browser compatibility. The prime example of this is jQuery. There was a time almost everybody was using jQuery. But through time HTML5 specs were updated to include ideas from jQuery and this filled the browser compatibility gap. There is this awesome article [The Rise and Fall of jQuery](https://www.evolutionjobs.com/uk/media/the-rise-and-fall-of-jquery-117981/). - -Don't get me wrong. Yes, I dislike jQuery but I find it indispensable and without it our web would be very different. For the worst in my opinion. It was a huge stepping stone for front-end development. But there comes a time where technologies get obsolete and standards catch up with the requirements of the field. - -And because libraries and frameworks have short lifespan I try to stay away from them and if possible use vanilla code. There is a wonderfull article about [The Brutal Lifecycle of JavaScript Frameworks](https://stackoverflow.blog/2018/01/11/brutal-lifecycle-javascript-frameworks/) that explains how quick they popup and become obsolete. - -> JavaScript UI frameworks and libraries work in cycles. Every six months or so, a new one pops up, claiming that it has revolutionized UI development. Thousands of developers adopt it into their new projects, blog posts are written, Stack Overflow questions are asked and answered, and then a newer (and even more revolutionary) framework pops up to usurp the throne. -> -> **-- Ian Allen** - -## Unnecessary complexity - -Libraries have a tendency to speed up development which is ok but there are a huge drawbacks in the future. Most of the times we work on simple projects. Not everybody is working on Facebook, Google or that kind of mamuth apps and by using libraries provided to us by these companies we introduce complexity these companies need in order to make their apps. And usually these libraries include edge case functionalities that only apply to them and by providing simpler way to use libraries very complex approaches get implemented. - -Another reason for me to not use frameworks and libraries is that there usually is a team behind a project and by working on a feature by your own it takes too much time to read through the documentation and properly understand what the reasoning was behind a feature in a library. Most of the stuff (dashboarding, tables, widgets) that I work on are done much faster by pure using JS. Codebase footprint is smaller and doesn't require other developers to learn a completly new framework. - -This freameworks are heavily opinionated. No question about it. And by using them you accept their dogma. And by doing so you put yourself in a wierd position when new "disruptive" framework comes to life. If we think about it these frameworks should rather be called "approaches". - -> *Just to be completely honest* -> -> There are use-cases for such frameworks. And there are situations where they are indispensable. I am not saying that they don't make sense. All I am saying that in my line of work I noticed that not every project is fit for a framework and it's better to not use them in such cases. - -An awesome talk about [Learning from JavaScript Libraries by Trevor Landau](https://www.youtube.com/watch?v=u2PgPWj8KrM). - -## Speed of development trumps code quality - -I have found out that most of these frameworks or libraries have become very difficult to undestand in a matter of hours. In the past this was diifferent somehow. You could learn jQuery in a matter of hours and use it the next day like you were a pro. I know that it's not fair to compare framework and library but for our case this is acceptable. - -Every developer should have the knowledge and experience when selecting or not selection framework. I always stay true to [Occam's razor](https://en.wikipedia.org/wiki/Occam%27s_razor). And when prototyping I always use as barebone setup as I can. I see no problem with completly dumping a block of code and replacing it with something more complex if this makes sense. But there needs to be a huge reason behind this decision. - -Workarounds are one of the nessesary evils perticulary when dealing with frameworks. Either because the lack of time of just plain reason that framework doesn't support something. And this is the my main problem with them. In real life we don't have the time to properly implement ideas behind a framework. And when shit hits the fan we butcher up the code and mix different ideas just to catch a deadline. And this is in contadiction with the whole idea of using a framework. - -The impact that this has on quality and readability of code is massive. And threating this just as a symptom is probably the worst thing you can do. Through time these hacked-up code becomes legacy and additional code is molded to the code that already is in the codebase. And by doing this our code becomes more and more foregin of the initial concept. - -Code quality and readability should come first regardless of frameworks and libraries. Code should be as close to bare-metal as possible so when frameworks change our code is still usable and can be refreshed by any developer with the basic knowledge of desired programming language. - -## Load times of most popular websites - -All this directly impacts performanse. Terabytes of bandwidth wasted because there was a decision made early in the development cycle. Laggy performance, slow loading, bad experience just because development team was not cautious enough. - -Here are some examples of loading times. It's up to you to decide if this really is the best way to do web. - -| URL | # req | Transfered | Finish | DOM Content Loaded | Load | -| ------------------ | ----- | ---------- | ------- | ------------------ | ------ | -| cnn.com | 134 | 3.22 MB | 4.7 s | 575 ms | 3.60 s | -| youtube.com | 61 | 1.8 MB | 5.13 s | 1.78 s | 1.97 s | -| wikipedia.com | 11 | 64.5 KB | 642 ms | 531 ms | 573 ms | -| reddit.com | 177 | 12.9 MB | 7.65 s | 2.03 s | 3.74 s | -| amazon.com | 278 | 8.0 MB | 5.20 s | 1.15s | 2.99 s | -| twitter.com | 202 | 5.1 MB | 23.48 s | 3.20 s | 4.55 s | -| twitch.tv | 177 | 4.4 MB | 5.08 s | 579 ms | 798 ms | -| microsoft.com | 77 | 1.1 MB | 3.96 s | 1.01 s | 1.26 s | -| huffingtonpost.com | 134 | 2.9 MB | 2.30 s | 789 ms | 1.47 s | -| nytimes.com | 240 | 2.9 MB | 4.64 s | 1.30 s | 4.29 s | -| foxnews.com | 195 | 1.7 MB | 4.42 s | 1.25 s | 3.86 s | -| theguardian.com | 203 | 2.8 MB | 2.75 s | 784 ms | 2.43 s | -| bbc.com | 127 | 1.3 MB | 3.44 s | 1.24 s | 2.65 s | - -Chrome Browser Developer tools was used to measure load times. diff --git a/_posts/2019-01-03-encoding-binary-data-into-dna-sequence.md b/_posts/2019-01-03-encoding-binary-data-into-dna-sequence.md deleted file mode 100644 index 56e96dd..0000000 --- a/_posts/2019-01-03-encoding-binary-data-into-dna-sequence.md +++ /dev/null @@ -1,415 +0,0 @@ ---- - -layout: post -title: Encoding binary data into DNA sequence -description: Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. - ---- - -**Table of contents** - -1. [Initial thoughts](#initial-thoughts) -2. [Glossary](#glossary) -3. [Data encoding](#data-encoding) -4. [Quick history of DNA](#quick-history-of-dna) -5. [What is DNA?](#what-is-dna) -6. [Encode binary data into DNA sequence](#encode-binary-data-into-dna-sequence) - 1. [Basic Encoding](#basic-encoding) - 2. [FASTA file format](#fasta-file-format) - 3. [PNG encoded DNA sequence](#png-encoded-dna-sequence) -7. [Encoding text file in practice](#encoding-text-file-in-practice) -8. [Toolkit for encoding data](#toolkit-for-encoding-data) - 1. [dnae-encode](#dnae-encode) - 2. [dnae-png](#dnae-png) -9. [Benchmarks](#benchmarks) -10. [References](#references) - -## Initial thoughts - -Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. Well, this is all possible now. It was not done on a large scale because it is quite expensive to create DNA strands but it's possible. - -Encoding data into DNA sequence is relatively simple process once you understand the relationship between binary data and nucleotides and scientists have been making large leaps in this field in order to provide viable long-term storage solution for our data that would potentially survive our specie if case of global disaster. We could imprint all the world's knowledge into plants and ensure the survival of our knowledge. - -More optimistic usage for this technology would be easier storage of ever growing data we produce every day. Once machines for sequencing DNA become fast enough and cheaper this could mean the next evolution of storing data and abandoning classical hard and solid state drives in data warehouses. - -As we currently stand this is still not viable but it is quite an amazing and cool technology. - -My interests in this field are purely in encoding processes and experimental testing mainly because I don't have the access to this expensive machines. My initial goal was to create a toolkit that can be used by everybody to encode their data into a proper DNA sequence. - -## Glossary - -**deoxyribose** -: A five-carbon sugar molecule with a hydrogen atom rather than a hydroxyl group in the 2′ position; the sugar component of DNA nucleotides. - -**double helix** -: The molecular shape of DNA in which two strands of nucleotides wind around each other in a spiral shape. - -**nitrogenous base** -: A nitrogen-containing molecule that acts as a base; often referring to one of the purine or pyrimidine components of nucleic acids. - -**phosphate group** -: A molecular group consisting of a central phosphorus atom bound to four oxygen atoms. - -**RGB** -: The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. - -**GCC** -: The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. - -## Data encoding - -**TL;DR:** Encoding involves the use of a code to change original data into a form that can be used by an external process [^1]. - -Encoding is the process of converting data into a format required for a number of information processing needs, including: - -- Program compiling and execution -- Data transmission, storage and compression/decompression -- Application data processing, such as file conversion - -Encoding can have two meanings[^1]: - -- In computer technology, encoding is the process of applying a specific code, such as letters, symbols and numbers, to data for conversion into an equivalent cipher. -- In electronics, encoding refers to analog to digital conversion. - -## Quick history of DNA - -- **1869** - Friedrich Miescher identifies "nuclein". -- **1900s** - The Eugenics Movement. -- **1900** – Mendel's theories are rediscovered by researchers. -- **1944** - Oswald Avery identifies DNA as the 'transforming principle'. -- **1952** - Rosalind Franklin photographs crystallized DNA fibres. -- **1953** - James Watson and Francis Crick discover the double helix structure of DNA. -- **1965** - Marshall Nirenberg is the first person to sequence the bases in each codon. -- **1983** - Huntington's disease is the first mapped genetic disease. -- **1990** - The Human Genome Project begins. -- **1995** - Haemophilus Influenzae is the first bacterium genome sequenced. -- **1996** - Dolly the sheep is cloned. -- **1999** - First human chromosome is decoded. -- **2000** – Genetic code of the fruit fly is decoded. -- **2002** – Mouse is the first mammal to have its genome decoded. -- **2003** – The Human Genome Project is completed. -- **2013** – DNA Worldwide and Eurofins Forensic discover identical twins have differences in their genetic makeup [^2]. - -## What is DNA? - -Deoxyribonucleic acid, a self-replicating material which is **present in nearly all living organisms** as the main constituent of chromosomes. It is the **carrier of genetic information**. - -> The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars. We are made of starstuff. -> -> **-- Carl Sagan, Cosmos** - -The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases (cytosine (C), thymine (T), adenine (A), guanine (G)), and a phosphate. Cytosine and thymine are pyrimidine bases, while adenine and guanine are purine bases. The sugar and the base together are called a nucleoside. - -![DNA](/files/dna-sequence/dna-basics.jpg#center) - -*DNA (a) forms a double stranded helix, and (b) adenine pairs with thymine and cytosine pairs with guanine. (credit a: modification of work by Jerome Walker, Dennis Myts) [^3]* - -## Encode binary data into DNA sequence - -As an input file you can use any file you want: -- ASCII files, -- Compiled programs, -- Multimedia files (MP3, MP4, MVK, etc), -- Images, -- Database files, -- etc. - -Note: If you would copy all the bytes from RAM to file or pipe data to file you could encode also this data as long as you provide file pointer to the encoder. - -### Basic Encoding - -As already mentioned, the Basic Encoding is based on a simple mapping. Since DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually referred using the first letter). Using this technique we can encode - -$$ log_2(4) = log_2(2^2) = 2 bits $$ - -using a single nucleotide. In this way, we are able to use the 4 bases that compose the DNA strand to encode each byte of data. [^4] - -| Two bits | Nucleotides | -| -------- | ---------------- | -| 00 | **A** (Adenine) | -| 10 | **G** (Guanine) | -| 01 | **C** (Cytosine) | -| 11 | **T** (Thymine) | - -With this in mind we can simply encode any data by using two-bit to Nucleotides conversion - -```pascal -{ Algorithm 1: Naive byte array to DNA encode } -procedure EncodeToDNASequence(f) string -begin - enc string - while not eof(f) do - c byte := buffer[0] { Read 1 byte from buffer } - bin integer := sprintf('08b', c) { Convert to string binary } - for e in range[0, 2, 4, 6] do - if e[0] == 48 and e[1] == 48 then { 0x00 - A (Adenine) } - enc += 'A' - else if e[0] == 48 and e[1] == 49 then { 0x01 - G (Guanine) } - enc += 'G' - else if e[0] == 49 and e[1] == 48 then { 0x10 - C (Cytosine) } - enc += 'C' - else if e[0] == 49 and e[1] == 49 then { 0x11 - T (Thymine) } - enc += 'T' - return enc { Return DNA sequence } -end -``` - -Another encoding would be **Goldman encoding**. Using this encoding helps with Nonsense mutation (amino acids replaced by a stop codon) that occurs and is the most problematic during translation because it leads to truncated amino acid sequences, which in turn results in truncated proteins. [^4] - -[Where to store big data? In DNA: Nick Goldman at TEDxPrague](https://www.youtube.com/watch?v=a4PiGWNsIEU) - -### FASTA file format - -In bioinformatics, FASTA format is a text-based format for representing either nucleotide sequences or peptide sequences, in which nucleotides or amino acids are represented using single-letter codes. The format also allows for sequence names and comments to precede the sequences. The format originates from the FASTA software package, but has now become a standard in the field of bioinformatics. [^5] - -The first line in a FASTA file started either with a ">" (greater-than) symbol or, less frequently, a ";" (semicolon) was taken as a comment. Subsequent lines starting with a semicolon would be ignored by software. Since the only comment used was the first, it quickly became used to hold a summary description of the sequence, often starting with a unique library accession number, and with time it has become commonplace to always use ">" for the first line and to not use ";" comments (which would otherwise be ignored). - -``` -;LCBO - Prolactin precursor - Bovine -; a sample sequence in FASTA format -MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS -EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL -VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED -ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC* - ->MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken -ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID -FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA -DIDGDGQVNYEEFVQMMTAK* - ->gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus] -LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV -EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG -LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL -GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX -IENY -``` - -FASTA format was extended by [FASTQ](https://en.wikipedia.org/wiki/FASTQ_format) format from the [Sanger Centre](https://www.sanger.ac.uk/) in Cambridge. - -### PNG encoded DNA sequence - -| Nucleotides | RGB | Color name | -| ------------ | ----------- | ---------- | -| A (Adenine) | (0,0,255) | Blue | -| G (Guanine) | (0,100,0) | Green | -| C (Cytosine) | (255,0,0) | Red | -| T (Thymine) | (255,255,0) | Yellow | - -With this in mind we can create a simple algorithm to create PNG representation of a DNA sequence. - -```pascal -{ Algorithm 2: Naive DNA to PNG encode from FASTA file } -procedure EncodeDNASequenceToPNG(f) -begin - i image - while not eof(f) do - c char := buffer[0] { Read 1 char from buffer } - case c of - 'A': color := RGB(0, 0, 255) { Blue } - 'G': color := RGB(0, 100, 0) { Green } - 'C': color := RGB(255, 0, 0) { Red } - 'T': color := RGB(255, 255, 0) { Yellow } - drawRect(i, [x, y], color) - save(i) { Save PNG image } -end -``` - -## Encoding text file in practice - -In this example we will take a simple text file as our input stream for encoding. This file will have a quote from Niels Bohr and saved as txt file. - -> How wonderful that we have met with a paradox. Now we have some hope of making progress. -> ― Niels Bohr - -First we encode text file into FASTA file. - -```bash -./dnae-encode -i quote.txt -o quote.fa -2019/01/10 00:38:29 Gathering input file stats -2019/01/10 00:38:29 Starting encoding ... - 106 B / 106 B [==================================] 100.00% 0s -2019/01/10 00:38:29 Saving to FASTA file ... -2019/01/10 00:38:29 Output FASTA file length is 438 B -2019/01/10 00:38:29 Process took 987.263µs -2019/01/10 00:38:29 Done ... -``` - -Output of `quote.fa` file contains the encoded DNA sequence in ASCII format. - -``` ->SEQ1 -GACAGCTTGTGTACAAGTGTGCTTGCTCGCGAGCGGGTACGCGCGTGGGCTAACAAGTGA -GCCAGCAGGTGAACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGCTGGCGGGTGA -ACAAGTGTGCCGGTGAGCCAACAAGCAGACAAGTAAGCAGGTACGCAGGCGAGCTTGTCA -ACTCACAAGATCGCTTGTGTACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGTAT -GCTTGCTGGCGGACAAGCCAGCTTGTAAGCGGACAAGCTTGCGCACAAGCTGGCAGGCCT -GCCGGCTCGCGTACAAATTCACAAGTAAGTACGCTTGCGTGTACGCGGGTATGTATACTC -AACCTCACCAAACGGGACAAGATCGCCGGCGGGCTAGTATACAAGAACGCTTGCCAGTAC -AACC -``` - -Then we encode FASTA file from previous operation to encode this data into PNG. - -```bash -./dnae-png -i quote.fa -o quote.png -2019/01/10 00:40:09 Gathering input file stats ... -2019/01/10 00:40:09 Deconstructing FASTA file ... -2019/01/10 00:40:09 Compositing image file ... - 424 / 424 [==================================] 100.00% 0s -2019/01/10 00:40:09 Saving output file ... -2019/01/10 00:40:09 Output image file length is 1.1 kB -2019/01/10 00:40:09 Process took 19.036117ms -2019/01/10 00:40:09 Done ... -``` - -After encoding into PNG format this file looks like this. - -![Encoded Quote in PNG format](/files/dna-sequence/quote.png) - -The larger the input stream is the larger the PNG file would be. - -Compiled basic Hello World C program with [GCC](https://www.gnu.org/software/gcc/) would [look like](/files/dna-sequence/sample.png). - -```c -// gcc -O3 -o sample sample.c -#include - -main() { - printf("Hello, world!\n"); - return 0; -} -``` - -## Toolkit for encoding data - -I have created a toolkit with two main programs: -- dnae-encode (encodes file into FASTA file) -- dnae-png (encodes FASTA file into PNG) - -Toolkit with full source code is available on [github.com/mitjafelicijan/dna-encoding](https://github.com/mitjafelicijan/dna-encoding). - -### dnae-encode - -```bash -> ./dnae-encode --help -usage: dnae-encode --input=INPUT [] - -A command-line application that encodes file into DNA sequence. - -Flags: - --help Show context-sensitive help (also try --help-long and --help-man). - -i, --input=INPUT Input file (ASCII or binary) which will be encoded into DNA sequence. - -o, --output="out.fa" Output file which stores DNA sequence in FASTA format. - -s, --sequence=SEQ1 The description line (defline) or header/identifier line, gives a name and/or a unique identifier for the sequence. - -c, --columns=60 Row characters length (no more than 120 characters). Devices preallocate fixed line sizes in software. - --version Show application version. -``` - -### dnae-png - -```bash -> ./dnae-png --help -usage: dnae-png --input=INPUT [] - -A command-line application that encodes FASTA file into PNG image. - -Flags: - --help Show context-sensitive help (also try --help-long and --help-man). - -i, --input=INPUT Input FASTA file which will be encoded into PNG image. - -o, --output="out.png" Output file in PNG format that represents DNA sequence in graphical way. - -s, --size=10 Size of pairings of DNA bases on image in pixels (lower resolution lower file size). - --version Show application version. -``` - -## Benchmarks - -First we generate some binary sample data with dd. - -```bash -dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) of=1KB.bin bs=1KB count=1 iflag=fullblock -``` - -Our freshly generated 1KB file looks something like this (its full of garbage data as intended). - -![Sample binary file 1KB](/files/dna-sequence/sample-binary-file.png) - -We create following binary files: -- 1KB.bin -- 10KB.bin -- 100KB.bin -- 1MB.bin -- 10MB.bin -- 100MB.bin - -After this we create FASTA files for all the binary files by encoding them into DNA sequence. - -```bash -./dnae-encode -i 100MB.bin -o 100MB.fa -``` - -Then we GZIP all the FASTA files to see how much the can be compressed. - -```bash -gzip -9 < 10MB.fa > 10MB.fa.gz -``` - - - -**Speed of encoding binary file into FASTA format.** - -
- - -**File sizes of encoded files and also GZIP-ed variations.** - -
- - -[Download ODS file with benchmarks.](/files/dna-sequence/benchmarks.ods). - -## References - -[^1]: https://www.techopedia.com/definition/948/encoding -[^2]: https://www.dna-worldwide.com/resource/160/history-dna-timeline -[^3]: https://opentextbc.ca/biology/chapter/9-1-the-structure-of-dna/ -[^4]: https://arxiv.org/abs/1801.04774 -[^5]: https://en.wikipedia.org/wiki/FASTA_format diff --git a/assets/avatar.gif b/assets/avatar.gif deleted file mode 100644 index 5bc6e90..0000000 Binary files a/assets/avatar.gif and /dev/null differ diff --git a/assets/avatar.png b/assets/avatar.png deleted file mode 100644 index 0148769..0000000 Binary files a/assets/avatar.png and /dev/null differ diff --git a/assets/cache-polyfill.js b/assets/cache-polyfill.js deleted file mode 100644 index 1449734..0000000 --- a/assets/cache-polyfill.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -(function() { - var nativeAddAll = Cache.prototype.addAll; - var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/); - - // Has nice behavior of `var` which everyone hates - if (userAgent) { - var agent = userAgent[1]; - var version = parseInt(userAgent[2]); - } - - if (nativeAddAll && (!userAgent || (agent === 'Firefox' && version >= 46) || (agent === 'Chrome' && version >= 50))) { - return; - } - - Cache.prototype.addAll = function addAll(requests) { - var cache = this; - - // Since DOMExceptions are not constructable: - function NetworkError(message) { - this.name = 'NetworkError'; - this.code = 19; - this.message = message; - } - - NetworkError.prototype = Object.create(Error.prototype); - - return Promise.resolve() - .then(function() { - if (arguments.length < 1) throw new TypeError(); - - // Simulate sequence<(Request or USVString)> binding: - var sequence = []; - - requests = requests.map(function(request) { - if (request instanceof Request) { - return request; - } else { - return String(request); // may throw TypeError - } - }); - - return Promise.all( - requests.map(function(request) { - if (typeof request === 'string') { - request = new Request(request); - } - - var scheme = new URL(request.url).protocol; - - if (scheme !== 'http:' && scheme !== 'https:') { - throw new NetworkError('Invalid scheme'); - } - - return fetch(request.clone()); - }) - ); - }) - .then(function(responses) { - // If some of the responses has not OK-eish status, - // then whole operation should reject - if ( - responses.some(function(response) { - return !response.ok; - }) - ) { - throw new NetworkError('Incorrect response status'); - } - - // TODO: check that requests don't overwrite one another - // (don't think this is possible to polyfill due to opaque responses) - return Promise.all( - responses.map(function(response, i) { - return cache.put(requests[i], response); - }) - ); - }) - .then(function() { - return undefined; - }); - }; - - Cache.prototype.add = function add(request) { - return this.addAll([request]); - }; -})(); diff --git a/assets/manifest.json b/assets/manifest.json deleted file mode 100644 index d150c67..0000000 --- a/assets/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "short_name": "MF", - "name": "Mitja Felicijan", - "author": "Mitja Felicijan", - "icons": [ - { - "src": "/assets/avatar.png", - "sizes": "512x512", - "type": "image/png" - }, - { - "src": "/assets/avatar.gif", - "sizes": "512x512", - "type": "image/gif" - } - ], - "start_url": "/", - "scope": "/", - "display": "standalone", - "theme_color": "#ffffff", - "background_color": "#ffffff" -} diff --git a/assets/plotly-latest.min.js b/assets/plotly-latest.min.js deleted file mode 100644 index 676213b..0000000 --- a/assets/plotly-latest.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/** -* plotly.js v1.32.0 -* Copyright 2012-2018, Plotly, Inc. -* All rights reserved. -* Licensed under the MIT license -*/ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){var r=e[o][1][t];return i(r||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oMath.abs(e))c.rotate(o,0,0,-t*i*Math.PI*p.rotateSpeed/window.innerWidth);else{var s=p.zoomSpeed*a*e/window.innerHeight*(o-c.lastT())/100;c.pan(o,0,0,h*(Math.exp(s)-1))}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset")},{"3d-view":38,"mouse-change":453,"mouse-event-offset":454,"mouse-wheel":456,"right-now":511}],38:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=i(),h=a(),f=o();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),new n({turntable:u,orbit:h,matrix:f},c)};var i=t("turntable-camera-controller"),a=t("orbit-camera-controller"),o=t("matrix-camera-controller"),s=n.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;n0&&(e.y+=r),a=e.y+e.dy+u;if((r=a-u-h[1])>0)for(a=e.y-=r,n=o-2;n>=0;--n)(r=(e=t[n]).y+e.dy+u-a)>0&&(e.y-=r),a=e.y})}function i(t,e){return t.y-e.y}var a=r.nest().key(function(t){return t.x}).sortKeys(e.ascending).entries(f).map(function(t){return t.values});!function(){var t=e.min(a,function(t){return(h[1]-(t.length-1)*u)/e.sum(t,s)});a.forEach(function(e){e.forEach(function(e,r){e.y=r,e.dy=e.value*t})}),d.forEach(function(e){e.dy=e.value*t})}(),n();for(var l=1;t>0;--t)!function(t){function r(t){return o(t.target)*t.value}a.slice().reverse().forEach(function(n){n.forEach(function(n){if(n.sourceLinks.length){var i=e.sum(n.sourceLinks,r)/e.sum(n.sourceLinks,s);n.y+=(i-o(n))*t}})})}(l*=.99),n(),function(t){function r(t){return o(t.source)*t.value}a.forEach(function(n){n.forEach(function(n){if(n.targetLinks.length){var i=e.sum(n.targetLinks,r)/e.sum(n.targetLinks,s);n.y+=(i-o(n))*t}})})}(l),n()}function a(){function t(t,e){return t.source.y-e.source.y||t.originalIndex-e.originalIndex}function e(t,e){return t.target.y-e.target.y||t.originalIndex-e.originalIndex}f.forEach(function(r){r.sourceLinks.sort(e),r.targetLinks.sort(t)}),f.forEach(function(t){var e=0,r=0;t.sourceLinks.forEach(function(t){t.sy=e,e+=t.dy}),t.targetLinks.forEach(function(t){t.ty=r,r+=t.dy})})}function o(t){return t.y+t.dy/2}function s(t){return t.value}var l={},c=24,u=8,h=[1,1],f=[],d=[];return l.nodeWidth=function(t){return arguments.length?(c=+t,l):c},l.nodePadding=function(t){return arguments.length?(u=+t,l):u},l.nodes=function(t){return arguments.length?(f=t,l):f},l.links=function(t){return arguments.length?(d=t,l):d},l.size=function(t){return arguments.length?(h=t,l):h},l.layout=function(r){return f.forEach(function(t){t.sourceLinks=[],t.targetLinks=[]}),d.forEach(function(t,e){var r=t.source,n=t.target;"number"==typeof r&&(r=t.source=f[t.source]),"number"==typeof n&&(n=t.target=f[t.target]),t.originalIndex=e,r.sourceLinks.push(t),n.targetLinks.push(t)}),f.forEach(function(t){t.value=Math.max(e.sum(t.sourceLinks,s),e.sum(t.targetLinks,s))}),t(),i(r),a(),l},l.relayout=function(){return a(),l},l.link=function(){function t(t){var r=t.source.x+t.source.dx,i=t.target.x,a=n.interpolateNumber(r,i),o=a(e),s=a(1-e),l=t.source.y+t.sy,c=l+t.dy,u=t.target.y+t.ty,h=u+t.dy;return"M"+r+","+l+"C"+o+","+l+" "+s+","+u+" "+i+","+u+"L"+i+","+h+"C"+s+","+h+" "+o+","+c+" "+r+","+c+"Z"}var e=.5;return t.curvature=function(r){return arguments.length?(e=+r,t):e},t},l},Object.defineProperty(t,"__esModule",{value:!0})})},{"d3-array":115,"d3-collection":116,"d3-interpolate":120}],40:[function(t,e,r){"use strict";var n="undefined"==typeof WeakMap?t("weak-map"):WeakMap,i=t("gl-buffer"),a=t("gl-vao"),o=new n;e.exports=function(t){var e=o.get(t),r=e&&(e._triangleBuffer.handle||e._triangleBuffer.buffer);if(!r||!t.isBuffer(r)){var n=i(t,new Float32Array([-1,-1,-1,4,4,-1]));(e=a(t,[{buffer:n,type:t.FLOAT,size:2}]))._triangleBuffer=n,o.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}},{"gl-buffer":157,"gl-vao":272,"weak-map":568}],41:[function(t,e,r){var n=t("pad-left");e.exports=function(t,e,r){e="number"==typeof e?e:1,r=r||": ";var i=t.split(/\r?\n/),a=String(i.length+e-1).length;return i.map(function(t,i){var o=i+e,s=String(o).length;return n(o,a-s)+r+t}).join("\n")}},{"pad-left":475}],42:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;ni&&(i=t[o]),t[o]>16&255,i[1]=a>>8&255,i[2]=255&a):e.test(t)&&(a=t.match(r),i[0]=parseInt(a[1]),i[1]=parseInt(a[2]),i[2]=parseInt(a[3])),!n)for(var o=0;o<3;++o)i[o]=i[o]/255;return i},t.str2RgbaArray=function(t,n){var i,a;if("string"!=typeof t)return t;if(i=[],"#"===t[0]?(3===(t=t.substr(1)).length&&(t+=t),a=parseInt(t,16),i[0]=a>>16&255,i[1]=a>>8&255,i[2]=255&a):e.test(t)&&(a=t.match(r),i[0]=parseInt(a[1]),i[1]=parseInt(a[2]),i[2]=parseInt(a[3]),a[4]?i[3]=parseFloat(a[4]):i[3]=1),!n)for(var o=0;o<3;++o)i[o]=i[o]/255;return i},t}()},{}],48:[function(t,e,r){(function(r){"use strict";function n(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,a=Math.min(r,n);i=0;s--)if(l[s]!==c[s])return!1;for(s=l.length-1;s>=0;s--)if(o=l[s],!f(t[o],e[o],r,n))return!1;return!0}(t,e,r,s))}return r?t===e:t==e}function d(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function p(t,e,r){f(t,e,!0)&&u(t,e,r,"notDeepStrictEqual",p)}function m(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function g(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&u(i,r,"Missing expected exception"+n);var a="string"==typeof n,o=!t&&v.isError(i),s=!t&&i&&!r;if((o&&a&&m(i,r)||s)&&u(i,r,"Got unwanted exception"+n),t&&i&&r&&!m(i,r)||!t&&i)throw i}var v=t("util/"),y=Object.prototype.hasOwnProperty,b=Array.prototype.slice,x="foo"===function(){}.name,_=e.exports=h,w=/\s*function\s+([^\(\s]*)\s*/;_.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return l(c(t.actual),128)+" "+t.operator+" "+l(c(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||u;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=s(e),a=n.indexOf("\n"+i);if(a>=0){var o=n.indexOf("\n",a+1);n=n.substring(o+1)}this.stack=n}}},v.inherits(_.AssertionError,Error),_.fail=u,_.ok=h,_.equal=function(t,e,r){t!=e&&u(t,e,r,"==",_.equal)},_.notEqual=function(t,e,r){t==e&&u(t,e,r,"!=",_.notEqual)},_.deepEqual=function(t,e,r){f(t,e,!1)||u(t,e,r,"deepEqual",_.deepEqual)},_.deepStrictEqual=function(t,e,r){f(t,e,!0)||u(t,e,r,"deepStrictEqual",_.deepStrictEqual)},_.notDeepEqual=function(t,e,r){f(t,e,!1)&&u(t,e,r,"notDeepEqual",_.notDeepEqual)},_.notDeepStrictEqual=p,_.strictEqual=function(t,e,r){t!==e&&u(t,e,r,"===",_.strictEqual)},_.notStrictEqual=function(t,e,r){t===e&&u(t,e,r,"!==",_.notStrictEqual)},_.throws=function(t,e,r){g(!0,t,e,r)},_.doesNotThrow=function(t,e,r){g(!1,t,e,r)},_.ifError=function(t){if(t)throw t};var M=Object.keys||function(t){var e=[];for(var r in t)y.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":558}],49:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],50:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0;r0?r=r.ushln(h):h<0&&(u=u.ushln(-h)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":53,"./is-rat":55,"./lib/is-bn":59,"./lib/num-to-bn":60,"./lib/rationalize":61,"./lib/str-to-bn":62}],55:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":59}],56:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":69}],57:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20?52:r+32}},{"bit-twiddle":68,"double-bits":125}],59:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":69}],60:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":69,"double-bits":125}],61:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}},{"./bn-sign":56,"./num-to-bn":60}],62:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":69}],63:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":61}],64:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":56}],65:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":61}],66:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,c=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return c*s;if(s){var u=i(s)+4;return c*(s+(f=n(l.ushln(u).divRound(r)))*Math.pow(2,-u))}var h=r.bitLength()-l.bitLength()+53,f=n(l.ushln(h).divRound(r));return h<1023?c*f*Math.pow(2,-h):(f*=Math.pow(2,-1023),c*f*Math.pow(2,1023-h))}},{"./lib/bn-to-num":57,"./lib/ctz":58}],67:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],68:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,(e|=r)|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,16843009*((t=(858993459&t)+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),(t=65535&(t|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),(t=1023&(t|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],69:[function(t,e,r){!function(e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function a(t,e,r){if(a.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}function o(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;a=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function s(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}function l(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&l,f=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=f;d++){var p=c-d|0;u+=(o=(i=0|t.words[p])*(a=0|e.words[d])+h)/67108864|0,h=67108863&o}r.words[c]=0|h,l=0|u}return 0!==l?r.words[c]=0|l:r.length--,r.strip()}function c(t,e,r){return(new u).mulp(t,e,r)}function u(t,e){this.x=t,this.y=e}function h(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function f(){h.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function d(){h.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function p(){h.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function m(){h.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function g(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function v(t){g.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof e?e.exports=a:r.BN=a,a.BN=a,a.wordSize=26;var y;try{y=t("buffer").Buffer}catch(t){}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=o(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=o(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,l=Math.min(a,a-o)+r,c=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var b=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],x=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];a.prototype.toString=function(t,e){t=t||10,e=0|e||1;var r;if(16===t||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?b[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var c=x[t],u=_[t];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var f=h.modn(u).toString(t);r=(h=h.idivn(u)).isZero()?f+r:b[c-f.length]+f+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n(void 0!==y),this.toArrayLike(y,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,c=new t(a),u=this.clone();if(l){for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],x=8191&b,_=b>>>13,w=0|o[4],M=8191&w,k=w>>>13,T=0|o[5],A=8191&T,S=T>>>13,E=0|o[6],L=8191&E,C=E>>>13,I=0|o[7],P=8191&I,D=I>>>13,z=0|o[8],O=8191&z,F=z>>>13,R=0|o[9],j=8191&R,N=R>>>13,B=0|s[0],U=8191&B,V=B>>>13,H=0|s[1],q=8191&H,G=H>>>13,Y=0|s[2],W=8191&Y,X=Y>>>13,Z=0|s[3],J=8191&Z,K=Z>>>13,Q=0|s[4],$=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ct=st>>>13,ut=0|s[8],ht=8191&ut,ft=ut>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(h,U))|0)+((8191&(i=(i=Math.imul(h,V))+Math.imul(f,U)|0))<<13)|0;c=((a=Math.imul(f,V))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,U),i=(i=Math.imul(p,V))+Math.imul(m,U)|0,a=Math.imul(m,V);var vt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(f,q)|0))<<13)|0;c=((a=a+Math.imul(f,G)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,U),i=(i=Math.imul(v,V))+Math.imul(y,U)|0,a=Math.imul(y,V),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,q)|0,a=a+Math.imul(m,G)|0;var yt=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(f,W)|0))<<13)|0;c=((a=a+Math.imul(f,X)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,U),i=(i=Math.imul(x,V))+Math.imul(_,U)|0,a=Math.imul(_,V),n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(y,q)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,X)|0;var bt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(f,J)|0))<<13)|0;c=((a=a+Math.imul(f,K)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(M,U),i=(i=Math.imul(M,V))+Math.imul(k,U)|0,a=Math.imul(k,V),n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(_,q)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(v,W)|0,i=(i=i+Math.imul(v,X)|0)+Math.imul(y,W)|0,a=a+Math.imul(y,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,K)|0;var xt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(f,$)|0))<<13)|0;c=((a=a+Math.imul(f,tt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(A,U),i=(i=Math.imul(A,V))+Math.imul(S,U)|0,a=Math.imul(S,V),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(k,q)|0,a=a+Math.imul(k,G)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(_,W)|0,a=a+Math.imul(_,X)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,K)|0)+Math.imul(y,J)|0,a=a+Math.imul(y,K)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((a=a+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(L,U),i=(i=Math.imul(L,V))+Math.imul(C,U)|0,a=Math.imul(C,V),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,q)|0,a=a+Math.imul(S,G)|0,n=n+Math.imul(M,W)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,X)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,K)|0)+Math.imul(_,J)|0,a=a+Math.imul(_,K)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(y,$)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,nt)|0;var wt=(c+(n=n+Math.imul(h,at)|0)|0)+((8191&(i=(i=i+Math.imul(h,ot)|0)+Math.imul(f,at)|0))<<13)|0;c=((a=a+Math.imul(f,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(P,U),i=(i=Math.imul(P,V))+Math.imul(D,U)|0,a=Math.imul(D,V),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(C,q)|0,a=a+Math.imul(C,G)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,X)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,K)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(_,$)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(p,at)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Mt=(c+(n=n+Math.imul(h,lt)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(f,lt)|0))<<13)|0;c=((a=a+Math.imul(f,ct)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(O,U),i=(i=Math.imul(O,V))+Math.imul(F,U)|0,a=Math.imul(F,V),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,G)|0)+Math.imul(D,q)|0,a=a+Math.imul(D,G)|0,n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(C,W)|0,a=a+Math.imul(C,X)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,K)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,K)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(v,at)|0,i=(i=i+Math.imul(v,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,a=a+Math.imul(m,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,ft)|0)+Math.imul(f,ht)|0))<<13)|0;c=((a=a+Math.imul(f,ft)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(j,U),i=(i=Math.imul(j,V))+Math.imul(N,U)|0,a=Math.imul(N,V),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,q)|0,a=a+Math.imul(F,G)|0,n=n+Math.imul(P,W)|0,i=(i=i+Math.imul(P,X)|0)+Math.imul(D,W)|0,a=a+Math.imul(D,X)|0,n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,K)|0)+Math.imul(C,J)|0,a=a+Math.imul(C,K)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,nt)|0,n=n+Math.imul(x,at)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ft)|0;var Tt=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,mt)|0)+Math.imul(f,pt)|0))<<13)|0;c=((a=a+Math.imul(f,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,G))+Math.imul(N,q)|0,a=Math.imul(N,G),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(F,W)|0,a=a+Math.imul(F,X)|0,n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,K)|0)+Math.imul(D,J)|0,a=a+Math.imul(D,K)|0,n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(C,$)|0,a=a+Math.imul(C,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,nt)|0,n=n+Math.imul(M,at)|0,i=(i=i+Math.imul(M,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,n=n+Math.imul(x,lt)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(y,ht)|0,a=a+Math.imul(y,ft)|0;var At=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;c=((a=a+Math.imul(m,mt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(j,W),i=(i=Math.imul(j,X))+Math.imul(N,W)|0,a=Math.imul(N,X),n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,K)|0)+Math.imul(F,J)|0,a=a+Math.imul(F,K)|0,n=n+Math.imul(P,$)|0,i=(i=i+Math.imul(P,tt)|0)+Math.imul(D,$)|0,a=a+Math.imul(D,tt)|0,n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(C,rt)|0,a=a+Math.imul(C,nt)|0,n=n+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(k,lt)|0,a=a+Math.imul(k,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,ft)|0)+Math.imul(_,ht)|0,a=a+Math.imul(_,ft)|0;var St=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((a=a+Math.imul(y,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(j,J),i=(i=Math.imul(j,K))+Math.imul(N,J)|0,a=Math.imul(N,K),n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,$)|0,a=a+Math.imul(F,tt)|0,n=n+Math.imul(P,rt)|0,i=(i=i+Math.imul(P,nt)|0)+Math.imul(D,rt)|0,a=a+Math.imul(D,nt)|0,n=n+Math.imul(L,at)|0,i=(i=i+Math.imul(L,ot)|0)+Math.imul(C,at)|0,a=a+Math.imul(C,ot)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,lt)|0,a=a+Math.imul(S,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ft)|0;var Et=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,mt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((a=a+Math.imul(_,mt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,tt))+Math.imul(N,$)|0,a=Math.imul(N,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,a=a+Math.imul(F,nt)|0,n=n+Math.imul(P,at)|0,i=(i=i+Math.imul(P,ot)|0)+Math.imul(D,at)|0,a=a+Math.imul(D,ot)|0,n=n+Math.imul(L,lt)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(C,lt)|0,a=a+Math.imul(C,ct)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ft)|0;var Lt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,mt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((a=a+Math.imul(k,mt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(j,rt),i=(i=Math.imul(j,nt))+Math.imul(N,rt)|0,a=Math.imul(N,nt),n=n+Math.imul(O,at)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(F,at)|0,a=a+Math.imul(F,ot)|0,n=n+Math.imul(P,lt)|0,i=(i=i+Math.imul(P,ct)|0)+Math.imul(D,lt)|0,a=a+Math.imul(D,ct)|0,n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,ft)|0)+Math.imul(C,ht)|0,a=a+Math.imul(C,ft)|0;var Ct=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;c=((a=a+Math.imul(S,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(j,at),i=(i=Math.imul(j,ot))+Math.imul(N,at)|0,a=Math.imul(N,ot),n=n+Math.imul(O,lt)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,lt)|0,a=a+Math.imul(F,ct)|0,n=n+Math.imul(P,ht)|0,i=(i=i+Math.imul(P,ft)|0)+Math.imul(D,ht)|0,a=a+Math.imul(D,ft)|0;var It=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,mt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((a=a+Math.imul(C,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(j,lt),i=(i=Math.imul(j,ct))+Math.imul(N,lt)|0,a=Math.imul(N,ct),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,ft)|0)+Math.imul(F,ht)|0,a=a+Math.imul(F,ft)|0;var Pt=(c+(n=n+Math.imul(P,pt)|0)|0)+((8191&(i=(i=i+Math.imul(P,mt)|0)+Math.imul(D,pt)|0))<<13)|0;c=((a=a+Math.imul(D,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(j,ht),i=(i=Math.imul(j,ft))+Math.imul(N,ht)|0,a=Math.imul(N,ft);var Dt=(c+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;c=((a=a+Math.imul(F,mt)|0)+(i>>>13)|0)+(Dt>>>26)|0,Dt&=67108863;var zt=(c+(n=Math.imul(j,pt))|0)+((8191&(i=(i=Math.imul(j,mt))+Math.imul(N,pt)|0))<<13)|0;return c=((a=Math.imul(N,mt))+(i>>>13)|0)+(zt>>>26)|0,zt&=67108863,l[0]=gt,l[1]=vt,l[2]=yt,l[3]=bt,l[4]=xt,l[5]=_t,l[6]=wt,l[7]=Mt,l[8]=kt,l[9]=Tt,l[10]=At,l[11]=St,l[12]=Et,l[13]=Lt,l[14]=Ct,l[15]=It,l[16]=Pt,l[17]=Dt,l[18]=zt,0!==c&&(l[19]=c,r.length++),r};Math.imul||(w=l),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?w(this,t,e):r<63?l(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):c(this,t,e)},u.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},u.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,c=0;c=0&&(0!==u||c>=i);c--){var h=0|this.words[c];this.words[c]=u<<26-a|h>>>a,u=h&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var f=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(f=Math.min(f/o|0,67108863),n._ishlnsubmul(i,f,h);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=f)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){if(n(!t.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var i,o,s;return 0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e)},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),h=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(u),l.isub(h)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(c)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)i.isOdd()&&i.iadd(s),i.iushrn(1);for(var u=0,h=1;0==(r.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(o)):(r.isub(e),o.isub(i))}var f;return(f=0===e.cmpn(1)?i:o).cmpn(0)<0&&f.iadd(t),f},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e=t<0;if(0!==this.negative&&!e)return-1;if(0===this.negative&&e)return 1;this.strip();var r;if(this.length>1)r=1;else{e&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];r=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new g(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};h.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},h.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},h.prototype.split=function(t,e){t.iushrn(this.n,0,e)},h.prototype.imulK=function(t){return t.imul(this.k)},i(f,h),f.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},f.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(M[t])return M[t];var e;if("k256"===t)e=new f;else if("p224"===t)e=new d;else if("p192"===t)e=new p;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new m}return M[t]=e,e},g.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},g.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},g.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},g.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},g.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},g.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},g.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},g.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},g.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},g.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},g.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},g.prototype.isqr=function(t){return this.imul(t,t.clone())},g.prototype.sqr=function(t){return this.mul(t,t)},g.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,c).cmp(l);)u.redIAdd(l);for(var h=this.pow(u,i),f=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;n--){for(var c=e.words[n],u=l-1;u>=0;u--){var h=c>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==o?(o<<=1,o|=h,(4===++s||0===n&&0===u)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},g.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},g.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new v(t)},i(v,g),v.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},v.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},v.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},v.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},v.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{}],70:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(s<=0)){var h,f=l.mallocDouble(2*s*a),d=l.mallocInt32(a);if((a=i(t,s,f,d))>0){if(1===s&&n)c.init(a),h=c.sweepComplete(s,r,0,a,f,d,0,a,f,d);else{var p=l.mallocDouble(2*s*o),m=l.mallocInt32(o);(o=i(e,s,p,m))>0&&(c.init(a+o),h=1===s?c.sweepBipartite(s,r,0,a,f,d,0,o,p,m):u(s,r,n,a,f,d,o,p,m),l.free(p),l.free(m))}l.free(f),l.free(d)}return h}}}function o(t,e){s.push([t,e])}e.exports=function(t,e,r){switch(arguments.length){case 1:return function(t){return s=[],a(t,t,o,!0),s}(t);case 2:return"function"==typeof e?a(t,t,e,!0):function(t,e){return s=[],a(t,e,o,!1),s}(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}};var s,l=t("typedarray-pool"),c=t("./lib/sweep"),u=t("./lib/intersect")},{"./lib/intersect":73,"./lib/sweep":77,"typedarray-pool":550}],72:[function(t,e,r){"use strict";function n(t){function e(e,r){var s=function(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),s=["function ",n,"(",_.join(),"){","var ",l,"=2*",i,";"],w="for(var i="+c+","+d+"="+l+"*"+c+";i<"+u+";++i,"+d+"+="+l+"){var x0="+h+"["+a+"+"+d+"],x1="+h+"["+a+"+"+d+"+"+i+"],xi="+f+"[i];",M="for(var j="+p+","+y+"="+l+"*"+p+";j<"+m+";++j,"+y+"+="+l+"){var y0="+g+"["+a+"+"+y+"],"+(r?"y1="+g+"["+a+"+"+y+"+"+i+"],":"")+"yi="+v+"[j];";return t?s.push(w,x,":",M):s.push(M,x,":",w),r?s.push("if(y1"+m+"-"+p+"){"),t?(e(!0,!1),M.push("}else{"),e(!1,!1)):(M.push("if("+s+"){"),e(!0,!0),M.push("}else{"),e(!0,!1),M.push("}}else{if("+s+"){"),e(!1,!0),M.push("}else{"),e(!1,!1),M.push("}")),M.push("}}return "+r);var k=n.join("")+M.join("");return new Function(k)()}var i="d",a="ax",o="vv",s="fp",l="es",c="rs",u="re",h="rb",f="ri",d="rp",p="bs",m="be",g="bb",v="bi",y="bp",b="rv",x="Q",_=[i,a,o,c,u,h,f,p,m,g,v];r.partial=n(!1),r.full=n(!0)},{}],73:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l){var c=M*t;T[c]=e,T[c+1]=r,T[c+2]=n,T[c+3]=i,T[c+4]=a,T[c+5]=o;var u=k*t;A[u]=s,A[u+1]=l}function i(t,e,r,n,i,a,o,s,l,c,u){var h=2*t,f=l*h,d=c[f+e];t:for(var p=i,m=i*h;p0;){var z=(P-=1)*M,O=T[z],F=T[z+1],R=T[z+2],j=T[z+3],N=T[z+4],B=T[z+5],U=P*k,V=A[U],H=A[U+1],q=1&B,G=!!(16&B),Y=d,W=S,X=L,Z=C;if(q&&(Y=L,W=C,X=d,Z=S),!(2&B&&(R=b(t,O,F,R,Y,W,H),F>=R)||4&B&&(F=x(t,O,F,R,Y,W,V))>=R)){var J=R-F,K=N-j;if(G){if(t*J*(J+K)=p0)&&!(p1>=hi)",["p0","p1"]),y=d("lo===p0",["p0"]),b=d("lor&&i[h+e]>c;--u,h-=o){for(var f=h,d=h+o,p=0;p>>1,f=2*t,d=h,p=s[f*h+e];c=b?(d=y,p=b):v>=_?(d=g,p=v):(d=x,p=_):b>=_?(d=y,p=b):_>=v?(d=g,p=v):(d=x,p=_);for(var w=f*(u-1),M=f*d,k=0;k=0&&i.push("lo=e[k+n]"),t.indexOf("hi")>=0&&i.push("hi=e[k+o]"),r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],76:[function(t,e,r){"use strict";function n(t,e,r){for(var n=2*(t+1),i=t+1;i<=e;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(cr[e+1])}function c(t,e,r,n){var i=n[t*=2];return i>1,g=m-f,v=m+f,y=d,b=g,x=m,_=v,w=p,M=t+1,k=e-1,T=0;l(y,b,r)&&(T=y,y=b,b=T),l(_,w,r)&&(T=_,_=w,w=T),l(y,x,r)&&(T=y,y=x,x=T),l(b,x,r)&&(T=b,b=x,x=T),l(y,_,r)&&(T=y,y=_,_=T),l(x,_,r)&&(T=x,x=_,_=T),l(b,w,r)&&(T=b,b=w,w=T),l(b,x,r)&&(T=b,b=x,x=T),l(_,w,r)&&(T=_,_=w,w=T);for(var A=r[2*b],S=r[2*b+1],E=r[2*_],L=r[2*_+1],C=2*y,I=2*x,P=2*w,D=2*d,z=2*m,O=2*p,F=0;F<2;++F){var R=r[C+F],j=r[I+F],N=r[P+F];r[D+F]=R,r[z+F]=j,r[O+F]=N}a(g,t,r),a(v,e,r);for(var B=M;B<=k;++B)if(c(B,A,S,r))B!==M&&i(B,M,r),++M;else if(!c(B,E,L,r))for(;;){if(c(k,E,L,r)){c(k,A,S,r)?(o(B,M,k,r),++M,--k):(i(B,k,r),--k);break}if(--k>>1;s(m,S);var E=0,L=0;for(M=0;M=l)n(h,f,L--,C=C-l|0);else if(C>=0)n(c,u,E--,C);else if(C<=-l){C=-C-l|0;for(var I=0;I>>1;s(m,E);var L=0,C=0,I=0;for(k=0;k>1==m[2*k+3]>>1&&(D=2,k+=1),P<0){for(var z=-(P>>1)-1,O=0;O>1)-1,0===D?n(c,u,L--,z):1===D?n(h,f,C--,z):2===D&&n(d,p,I--,z)}},scanBipartite:function(t,e,r,a,o,h,f,d,p,g,v,y){var b=0,x=2*t,_=e,w=e+t,M=1,k=1;a?k=l:M=l;for(var T=o;T>>1;s(m,L);var C=0;for(T=0;T=l?(P=!a,A-=l):(P=!!a,A-=1),P)i(c,u,C++,A);else{var D=y[A],z=x*A,O=v[z+e+1],F=v[z+e+1+t];t:for(var R=0;R>>1;s(m,M);var k=0;for(b=0;b=l)c[k++]=x-l;else{var A=d[x-=1],S=g*x,E=f[S+e+1],L=f[S+e+1+t];t:for(var C=0;C=0;--C)if(c[C]===x){for(z=C+1;zz)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return s(t)}return a(t,e,r)}function a(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return t instanceof ArrayBuffer?function(t,e,r){if(e<0||t.byteLength=z)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z.toString(16)+" bytes");return 0|t}function u(t,e){if(i.isBuffer(t))return t.length;if(C(t)||t instanceof ArrayBuffer)return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return S(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return E(t).length;default:if(n)return S(t).length;e=(""+e).toLowerCase(),n=!0}}function h(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return function(t,e,r){var n=t.length;(!e||e<0)&&(e=0);(!r||r<0||r>n)&&(r=n);for(var i="",a=e;a2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,I(r)&&(r=a?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(a)return-1;r=t.length-1}else if(r<0){if(!a)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,a);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){function a(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}var c;if(i){var u=-1;for(c=r;cs&&(r=s-l),c=r;c>=0;c--){for(var h=!0,f=0;fi&&(n=i):n=i;var a=e.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function _(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:a>223?3:a>191?2:1;if(i+s<=r){var l,c,u,h;switch(s){case 1:a<128&&(o=a);break;case 2:128==(192&(l=t[i+1]))&&(h=(31&a)<<6|63&l)>127&&(o=h);break;case 3:l=t[i+1],c=t[i+2],128==(192&l)&&128==(192&c)&&(h=(15&a)<<12|(63&l)<<6|63&c)>2047&&(h<55296||h>57343)&&(o=h);break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128==(192&l)&&128==(192&c)&&128==(192&u)&&(h=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u)>65535&&h<1114112&&(o=h)}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){var e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nr)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,a,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>a||et.length)throw new RangeError("Index out of range")}function k(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,4),D.write(t,e,r,n,23,4),r+4}function A(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,8),D.write(t,e,r,n,52,8),r+8}function S(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function E(t){return P.toByteArray(function(t){if((t=t.trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function C(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function I(t){return t!=t}var P=t("base64-js"),D=t("ieee754");r.Buffer=i,r.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},r.INSPECT_MAX_BYTES=50;var z=2147483647;r.kMaxLength=z,(i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(t,e,r){return a(t,e,r)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(t,e,r){return function(t,e,r){return o(t),t<=0?n(t):void 0!==e?"string"==typeof r?n(t).fill(e,r):n(t).fill(e):n(t)}(t,e,r)},i.allocUnsafe=function(t){return s(t)},i.allocUnsafeSlow=function(t){return s(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer},i.compare=function(t,e){if(!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,a=0,o=Math.min(r,n);a0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},i.prototype.compare=function(t,e,r,n,a){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===a&&(a=this.length),e<0||r>t.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&e>=r)return 0;if(n>=a)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,a>>>=0,this===t)return 0;for(var o=a-n,s=r-e,l=Math.min(o,s),c=this.slice(n,a),u=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return g(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return b(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var O=4096;i.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||w(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||w(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},i.prototype.readUInt8=function(t,e){return t>>>=0,e||w(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||w(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||w(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||w(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||w(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||w(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||w(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},i.prototype.readInt8=function(t,e){return t>>>=0,e||w(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||w(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||w(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||w(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||w(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||w(t,4,this.length),D.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||w(t,4,this.length),D.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||w(t,8,this.length),D.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||w(t,8,this.length),D.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){M(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,!n){M(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,r){return T(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return T(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return A(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return A(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(a<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return o[t>>18&63]+o[t>>12&63]+o[t>>6&63]+o[63&t]}function a(t,e,r){for(var n,a=[],o=e;o0?u-4:u;var h=0;for(e=0,r=0;e>16&255,c[h++]=a>>8&255,c[h++]=255&a;return 2===o?(a=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,c[h++]=255&a):1===o&&(a=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,c[h++]=a>>8&255,c[h++]=255&a),c},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i="",s=[],l=0,c=r-n;lc?c:l+16383));return 1===n?(e=t[r-1],i+=o[e>>2],i+=o[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=o[e>>10],i+=o[e>>4&63],i+=o[e<<2&63],i+="="),s.push(i),s.join("")};for(var o=[],s=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,h=c.length;u0;){for(var d=r.pop(),p=(u=-1,h=-1,l=o[s=r.pop()],1);p=0||(e.flip(s,d),n(t,e,r,u,s,h),n(t,e,r,s,h,u),n(t,e,r,h,d,u),n(t,e,r,d,u,h))}}},{"binary-search-bounds":85,"robust-in-sphere":515}],82:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}var a=t("binary-search-bounds");e.exports=function(t,e,r){var a=function(t,e){for(var r=t.cells(),a=r.length,o=0;o0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-o){c[d]=o,u[d];for(var p=0;p<3;++p){var m=f[3*d+p];m>=0&&0===c[m]&&(h[3*d+p]?l.push(m):(s.push(m),c[m]=o))}}}var g=l;l=s,s=g,l.length=0,o=-o}var v=function(t,e,r){for(var n=0,i=0;i1&&f(r[u[d-2]],r[u[d-1]],n)>0;)t.push([u[d-1],u[d-2],i]),d-=1;u.length=d,u.push(i);var p=c.upperIds;for(d=p.length;d>1&&f(r[p[d-2]],r[p[d-1]],n)<0;)t.push([p[d-2],p[d-1],i]),d-=1;p.length=d,p.push(i)}}function l(t,e){var r;return(r=t.a[0]v[0]&&l.push(new i(v,g,m,h),new i(g,v,p,h))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],_=(h=0,l.length);h<_;++h){var w=l[h],M=w.type;M===d?s(x,b,t,w.a,w.idx):M===m?c(b,0,w):u(b,0,w)}return x}},{"binary-search-bounds":85,"robust-orientation":517}],84:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;n=0}}(),o.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},o.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},o.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],86:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],90:[function(t,e,r){"use strict";function n(t){var e=m(t);return[v(e,-1/0),v(e,1/0)]}function i(t){for(var e=new Array(t.length),r=0;re[2]?1:0)}function l(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var b=e[o=(S=n[a])[0]],x=b[0],_=b[1],w=t[x],M=t[_];if((w[0]-M[0]||w[1]-M[1])<0){var k=x;x=_,_=k}b[0]=x;var T,A=b[1]=S[1];for(i&&(T=b[2]);a>0&&n[a-1][0]===o;){var S,E=(S=n[--a])[1];i?e.push([A,E,T]):e.push([A,E]),A=E}i?e.push([A,_,T]):e.push([A,_])}return s}(t,e,o,c,r));return l(e,u,r),!!u||(o.length>0||c.length>0)}e.exports=function(t,e,r){var n;if(r){n=e;for(var o=new Array(e.length),s=0;s>>24,n=(16711680&t)>>>16,i=(65280&t)>>>8,a=255&t;return!1===e?[r,n,i,a]:[r/255,n/255,i/255,a/255]}},{clamp:89}],94:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],95:[function(t,e,r){(function(r){"use strict";e.exports=function(t){var e,o,s=[],l=1;if("string"==typeof t)if(n[t])s=n[t].slice(),o="rgb";else if("transparent"===t)l=0,o="rgb",s=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var c=t.slice(1);l=1,(h=c.length)<=4?(s=[parseInt(c[0]+c[0],16),parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16)],4===h&&(l=parseInt(c[3]+c[3],16)/255)):(s=[parseInt(c[0]+c[1],16),parseInt(c[2]+c[3],16),parseInt(c[4]+c[5],16)],8===h&&(l=parseInt(c[6]+c[7],16)/255)),s[0]||(s[0]=0),s[1]||(s[1]=0),s[2]||(s[2]=0),o="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var u=e[1];o=c=u.replace(/a$/,"");var h="cmyk"===c?4:"gray"===c?1:3;s=e[2].trim().split(/\s*,\s*/).map(function(t,e){if(/%$/.test(t))return e===h?parseFloat(t)/100:"rgb"===c?255*parseFloat(t)/100:parseFloat(t);if("h"===c[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==a[t])return a[t]}return parseFloat(t)}),u===c&&s.push(1),l=void 0===s[h]?1:s[h],s=s.slice(0,h)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(s=t.match(/([0-9]+)/g).map(function(t){return parseFloat(t)}),o=t.match(/([a-z])/gi).join("").toLowerCase());else"number"==typeof t?(o="rgb",s=[t>>>16,(65280&t)>>>8,255&t]):i(t)?(null!=t.r?(s=[t.r,t.g,t.b],o="rgb"):null!=t.red?(s=[t.red,t.green,t.blue],o="rgb"):null!=t.h?(s=[t.h,t.s,t.l],o="hsl"):null!=t.hue&&(s=[t.hue,t.saturation,t.lightness],o="hsl"),null!=t.a?l=t.a:null!=t.alpha?l=t.alpha:null!=t.opacity&&(l=t.opacity/100)):(Array.isArray(t)||r.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(s=[t[0],t[1],t[2]],o="rgb",l=4===t.length?t[3]:1);return{space:o,values:s,alpha:l}};var n=t("color-name"),i=t("is-plain-obj"),a={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":94,"is-plain-obj":298}],96:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t,e){if(Array.isArray(t))return t;null==e&&(e=!0);var r=n(t);if(!r.space)return[];var o,s=r.values,l=s.length;for(o=0;o1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[c]=255*a;return i}},n.hsl=function(t){var e,r,n,i=t[0]/255,a=t[1]/255,o=t[2]/255,s=Math.min(i,a,o),l=Math.max(i,a,o),c=l-s;return l===s?e=0:i===l?e=(a-o)/c:a===l?e=2+(o-i)/c:o===l&&(e=4+(i-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(s+l)/2,r=l===s?0:n<=.5?c/(l+s):c/(2-l-s),[e,100*r,100*n]}},{"./rgb":98}],98:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],99:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:0,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],100:[function(t,e,r){"use strict";function n(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,h,f,d,p,m,g,v,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",(f=t.colormap)||(f="jet"),"string"==typeof f){if(f=f.toLowerCase(),!s[f])throw Error(f+" not a supported colorscale");h=o(s[f])}else{if(!Array.isArray(f))throw Error("unsupported colormap option",f);h=o(f)}if(h.length>p)throw new Error(f+" map requires nshades to be at least size "+h.length);for(g=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=h.map(function(t){return Math.round(t.index*p)}),g[0]<0&&(g[0]=0),g[1]<0&&(g[0]=0),g[0]>1&&(g[0]=1),g[1]>1&&(g[0]=1),y=0;y=0&&r[3]<=1||(r[3]=g[0]+(g[1]-g[0])*v);for(y=0;y=0}e.exports=function(t,e,r,o){var s=i(e,r,o);if(0===s){var l=a(i(t,e,r)),c=a(i(t,e,o));if(l===c){if(0===l){var u=n(t,e,r);return u===n(t,e,o)?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,o)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:a(c-l)}var h=i(t,e,r);return h>0?s>0&&i(t,e,o)>0?1:-1:h<0?s>0||i(t,e,o)>0?1:-1:i(t,e,o)>0?1:n(t,e,r)?1:-1};var i=t("robust-orientation"),a=t("signum"),o=t("two-sum"),s=t("robust-product"),l=t("robust-sum")},{"robust-orientation":517,"robust-product":518,"robust-sum":522,signum:524,"two-sum":549}],102:[function(t,e,r){function n(t,e){return t-e}e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]);return i(l,t[2])-i(c,e[2])||i(l+t[2],o)-i(c+e[2],s);case 4:var u=t[0],h=t[1],f=t[2],d=t[3],p=e[0],m=e[1],g=e[2],v=e[3];return u+h+f+d-(p+m+g+v)||i(u,h,f,d)-i(p,m,g,v,p)||i(u+h,u+f,u+d,h+f,h+d,f+d)-i(p+m,p+g,p+v,m+g,m+v,g+v)||i(u+h+f,u+h+d,u+f+d,h+f+d)-i(p+m+g,p+m+v,p+g+v,m+g+v);default:for(var y=t.slice().sort(n),b=e.slice().sort(n),x=0;xt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],106:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(n(a,!0),r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":42,"incremental-convex-hull":291}],108:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],109:[function(t,e,r){function n(t){return(t=Math.round(t))<0?0:t>255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?n(parseFloat(t)/100*255):n(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function l(t){var e=t.replace(/ /g,"").toLowerCase();if(e in c)return c[e].slice();if("#"===e[0]){if(4===e.length){return(r=parseInt(e.substr(1),16))>=0&&r<=4095?[(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1]:null}if(7===e.length){var r;return(r=parseInt(e.substr(1),16))>=0&&r<=16777215?[(16711680&r)>>16,(65280&r)>>8,255&r,1]:null}return null}var i=e.indexOf("("),l=e.indexOf(")");if(-1!==i&&l+1===e.length){var u=e.substr(0,i),h=e.substr(i+1,l-(i+1)).split(","),f=1;switch(u){case"rgba":if(4!==h.length)return null;f=o(h.pop());case"rgb":return 3!==h.length?null:[a(h[0]),a(h[1]),a(h[2]),f];case"hsla":if(4!==h.length)return null;f=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,p=o(h[1]),m=o(h[2]),g=m<=.5?m*(p+1):m+p-m*p,v=2*m-g;return[n(255*s(v,g,d+1/3)),n(255*s(v,g,d)),n(255*s(v,g,d-1/3)),f];default:return null}}return null}var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};try{r.parseCSSColor=l}catch(t){}},{}],110:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,h=s*(3-2*i),f=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+h*r[d]+f*n[d];return a}return c*t+u*e+h*r+f*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}},{}],111:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");e.exports=function(t){var e=new function(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1};e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===a){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":113}],112:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,h=0;for(n=0;n0&&l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",h,"]-=s",h].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(l=0;l0&&v.push("var "+y.join(",")),l=0;l3&&v.push(i(t.pre,t,s));var M=i(t.body,t,s),k=function(t){for(var e=0,r=t[0].length;e0,c=[],u=0;u0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(u=0;u3&&v.push(i(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+v.join("\n")+"\n----------");var T=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",k,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",T,"(",g.join(","),"){",v.join("\n"),"} return ",T].join(""))()}},{uniq:552}],113:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+h+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+h+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),u=0;u=0?(a>=x?10:a>=_?5:a>=w?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=x?10:a>=_?5:a>=w?2:1)}function n(t,e,r){var n=Math.abs(e-t)/Math.max(0,r),i=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),a=n/i;return a>=x?i*=10:a>=_?i*=5:a>=w&&(i*=2),ee?1:t>=e?0:NaN},o=function(t){return 1===t.length&&(t=function(t){return function(e,r){return a(t(e),r)}}(t)),{left:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}},s=o(a),l=s.right,c=s.left,u=function(t){return null===t?NaN:+t},h=function(t,e){var r,n,i=t.length,a=0,o=-1,s=0,l=0;if(null==e)for(;++o1)return l/(a-1)},f=function(t,e){var r=h(t,e);return r?Math.sqrt(r):r},d=function(t,e){var r,n,i,a=t.length,o=-1;if(null==e){for(;++o=r)for(n=i=r;++or&&(n=r),i=r)for(n=i=r;++or&&(n=r),i=1)return+r(t[n-1],n-1,t);var n,i=(n-1)*e,a=Math.floor(i),o=+r(t[a],a,t);return o+(+r(t[a+1],a+1,t)-o)*(i-a)}},T=function(t,e){var r,n,i=t.length,a=-1;if(null==e){for(;++a=r)for(n=r;++ar&&(n=r)}else for(;++a=r)for(n=r;++ar&&(n=r);return n},A=function(t){if(!(a=t.length))return[];for(var e=-1,r=T(t,i),n=new Array(r);++et?1:e>=t?0:NaN},t.deviation=f,t.extent=d,t.histogram=function(){function t(t){var a,o,s=t.length,c=new Array(s);for(a=0;af;)d.pop(),--p;var m,g=new Array(p+1);for(a=0;a<=p;++a)(m=g[a]=[]).x0=a>0?d[a-1]:h,m.x1=a=r)for(n=r;++an&&(n=r)}else for(;++a=r)for(n=r;++an&&(n=r);return n},t.mean=function(t,e){var r,n=t.length,i=n,a=-1,o=0;if(null==e)for(;++a=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r},t.min=T,t.pairs=function(t,r){null==r&&(r=e);for(var n=0,i=t.length-1,a=t[0],o=new Array(i<0?0:i);n0)for(t=Math.ceil(t/o),e=Math.floor(e/o),a=new Array(i=Math.ceil(e-t+1));++l=u.length)return null!=l?l(e):null!=s?e.sort(s):e;for(var o,c,h,f=-1,d=e.length,p=u[n++],m=r(),g=i();++fu.length)return t;var n,i=h[r-1];return null!=l&&r>=u.length?n=t.entries():(n=[],t.each(function(t,i){n.push({key:i,values:e(t,r)})})),null!=i?n.sort(function(t,e){return i(t.key,e.key)}):n}var s,l,c,u=[],h=[];return c={object:function(e){return t(e,0,n,i)},map:function(e){return t(e,0,a,o)},entries:function(r){return e(t(r,0,a,o),0)},key:function(t){return u.push(t),c},sortKeys:function(t){return h[u.length-1]=t,c},sortValues:function(t){return s=t,c},rollup:function(t){return l=t,c}}},t.set=l,t.map=r,t.keys=function(t){var e=[];for(var r in t)e.push(r);return e},t.values=function(t){var e=[];for(var r in t)e.push(t[r]);return e},t.entries=function(t){var e=[];for(var r in t)e.push({key:r,value:t[r]});return e},Object.defineProperty(t,"__esModule",{value:!0})})},{}],117:[function(t,e,r){!function(t,n){n("object"==typeof r&&void 0!==e?r:t.d3=t.d3||{})}(this,function(t){"use strict";function e(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function r(){}function n(t){var e;return t=(t+"").trim().toLowerCase(),(e=E.exec(t))?(e=parseInt(e[1],16),new l(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1)):(e=L.exec(t))?i(parseInt(e[1],16)):(e=C.exec(t))?new l(e[1],e[2],e[3],1):(e=I.exec(t))?new l(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=P.exec(t))?a(e[1],e[2],e[3],e[4]):(e=D.exec(t))?a(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=z.exec(t))?c(e[1],e[2]/100,e[3]/100,1):(e=O.exec(t))?c(e[1],e[2]/100,e[3]/100,e[4]):F.hasOwnProperty(t)?i(F[t]):"transparent"===t?new l(NaN,NaN,NaN,0):null}function i(t){return new l(t>>16&255,t>>8&255,255&t,1)}function a(t,e,r,n){return n<=0&&(t=e=r=NaN),new l(t,e,r,n)}function o(t){return t instanceof r||(t=n(t)),t?(t=t.rgb(),new l(t.r,t.g,t.b,t.opacity)):new l}function s(t,e,r,n){return 1===arguments.length?o(t):new l(t,e,r,null==n?1:n)}function l(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function c(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new h(t,e,r,n)}function u(t,e,i,a){return 1===arguments.length?function(t){if(t instanceof h)return new h(t.h,t.s,t.l,t.opacity);if(t instanceof r||(t=n(t)),!t)return new h;if(t instanceof h)return t;var e=(t=t.rgb()).r/255,i=t.g/255,a=t.b/255,o=Math.min(e,i,a),s=Math.max(e,i,a),l=NaN,c=s-o,u=(s+o)/2;return c?(l=e===s?(i-a)/c+6*(i0&&u<1?0:l,new h(l,c,u,t.opacity)}(t):new h(t,e,i,null==a?1:a)}function h(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function f(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}function d(t){if(t instanceof m)return new m(t.l,t.a,t.b,t.opacity);if(t instanceof _){var e=t.h*R;return new m(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof l||(t=o(t));var r=b(t.r),n=b(t.g),i=b(t.b),a=g((.4124564*r+.3575761*n+.1804375*i)/N),s=g((.2126729*r+.7151522*n+.072175*i)/B);return new m(116*s-16,500*(a-s),200*(s-g((.0193339*r+.119192*n+.9503041*i)/U)),t.opacity)}function p(t,e,r,n){return 1===arguments.length?d(t):new m(t,e,r,null==n?1:n)}function m(t,e,r,n){this.l=+t,this.a=+e,this.b=+r,this.opacity=+n}function g(t){return t>G?Math.pow(t,1/3):t/q+V}function v(t){return t>H?t*t*t:q*(t-V)}function y(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function b(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function x(t,e,r,n){return 1===arguments.length?function(t){if(t instanceof _)return new _(t.h,t.c,t.l,t.opacity);t instanceof m||(t=d(t));var e=Math.atan2(t.b,t.a)*j;return new _(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}(t):new _(t,e,r,null==n?1:n)}function _(t,e,r,n){this.h=+t,this.c=+e,this.l=+r,this.opacity=+n}function w(t,e,r,n){return 1===arguments.length?function(t){if(t instanceof M)return new M(t.h,t.s,t.l,t.opacity);t instanceof l||(t=o(t));var e=t.r/255,r=t.g/255,n=t.b/255,i=(K*n+Z*e-J*r)/(K+Z-J),a=n-i,s=(X*(r-i)-Y*a)/W,c=Math.sqrt(s*s+a*a)/(X*i*(1-i)),u=c?Math.atan2(s,a)*j-120:NaN;return new M(u<0?u+360:u,c,i,t.opacity)}(t):new M(t,e,r,null==n?1:n)}function M(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}var k=function(t,e,r){t.prototype=e.prototype=r,r.constructor=t},T="\\s*([+-]?\\d+)\\s*",A="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",S="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",E=/^#([0-9a-f]{3})$/,L=/^#([0-9a-f]{6})$/,C=new RegExp("^rgb\\("+[T,T,T]+"\\)$"),I=new RegExp("^rgb\\("+[S,S,S]+"\\)$"),P=new RegExp("^rgba\\("+[T,T,T,A]+"\\)$"),D=new RegExp("^rgba\\("+[S,S,S,A]+"\\)$"),z=new RegExp("^hsl\\("+[A,S,S]+"\\)$"),O=new RegExp("^hsla\\("+[A,S,S,A]+"\\)$"),F={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};k(r,n,{displayable:function(){return this.rgb().displayable()},toString:function(){return this.rgb()+""}}),k(l,s,e(r,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new l(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new l(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),k(h,u,e(r,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new h(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new h(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new l(f(t>=240?t-240:t+120,i,n),f(t,i,n),f(t<120?t+240:t-120,i,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var R=Math.PI/180,j=180/Math.PI,N=.95047,B=1,U=1.08883,V=4/29,H=6/29,q=3*H*H,G=H*H*H;k(m,p,e(r,{brighter:function(t){return new m(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new m(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,r=isNaN(this.b)?t:t-this.b/200;return t=B*v(t),e=N*v(e),r=U*v(r),new l(y(3.2404542*e-1.5371385*t-.4985314*r),y(-.969266*e+1.8760108*t+.041556*r),y(.0556434*e-.2040259*t+1.0572252*r),this.opacity)}})),k(_,x,e(r,{brighter:function(t){return new _(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new _(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return d(this).rgb()}}));var Y=-.29227,W=-.90649,X=1.97294,Z=X*W,J=1.78277*X,K=1.78277*Y- -.14861*W;k(M,w,e(r,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new M(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new M(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*R,e=+this.l,r=isNaN(this.s)?0:this.s*e*(1-e),n=Math.cos(t),i=Math.sin(t);return new l(255*(e+r*(-.14861*n+1.78277*i)),255*(e+r*(Y*n+W*i)),255*(e+r*(X*n)),this.opacity)}})),t.color=n,t.rgb=s,t.hsl=u,t.lab=p,t.hcl=x,t.cubehelix=w,Object.defineProperty(t,"__esModule",{value:!0})})},{}],118:[function(t,e,r){!function(t,n){n("object"==typeof r&&void 0!==e?r:t.d3=t.d3||{})}(this,function(t){"use strict";function e(){for(var t,e=0,n=arguments.length,i={};e=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}})}(t+"",i),o=-1,s=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o0)for(var r,n,i=new Array(r),a=0;ad+s||np+s||ih.index){var l=d-a.x-a.vx,u=p-a.y-a.vy,v=l*l+u*u;vt.r&&(t.r=t[e].r)}function i(){if(s){var e,r,n=s.length;for(l=new Array(n),e=0;e=m)){(t.data!==o||t.next)&&(0===i&&(i=f(),u+=i*i),0===a&&(a=f(),u+=a*a),u1?(null==e?g.remove(t):g.set(t,s(e)),l):g.get(t)},find:function(e,r,n){var i,a,o,s,l,c=0,u=t.length;for(null==n?n=1/0:n*=n,c=0;c1?(y.on(t,e),l):y.on(t)}}},t.forceX=function(t){function e(t){for(var e,r=0,o=n.length;r180||r<-180?r-360*Math.round(r/360):r):b(isNaN(t)?e:t)}function a(t){return 1==(t=+t)?o:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):b(isNaN(e)?r:e)}}function o(t,e){var r=e-t;return r?n(t,r):b(isNaN(t)?e:t)}function s(t){return function(r){var n,i,a=r.length,o=new Array(a),s=new Array(a),l=new Array(a);for(n=0;n180?e+=360:e-t>180&&(t+=360),a.push({i:r.push(i(r)+"rotate(",null,n)-2,x:T(t,e)})):e&&r.push(i(r)+"rotate("+e+n)}(a.rotate,o.rotate,s,l),function(t,e,r,a){t!==e?a.push({i:r.push(i(r)+"skewX(",null,n)-2,x:T(t,e)}):e&&r.push(i(r)+"skewX("+e+n)}(a.skewX,o.skewX,s,l),function(t,e,r,n,a,o){if(t!==r||e!==n){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:T(t,r)},{i:s-2,x:T(e,n)})}else 1===r&&1===n||a.push(i(a)+"scale("+r+","+n+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,r=-1,n=l.length;++r=1?(n=1,e-1):Math.floor(n*e),a=t[i],o=t[i+1],s=i>0?t[i-1]:2*a-o,l=ia&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:T(r,n)})),a=E.lastIndex;return a=(a=(m+v)/2))?m=a:v=a,(u=r>=(o=(g+y)/2))?g=o:y=o,i=d,!(d=d[h=u<<1|c]))return i[h]=p,t;if(s=+t._x.call(null,d.data),l=+t._y.call(null,d.data),e===s&&r===l)return p.next=d,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(a=(m+v)/2))?m=a:v=a,(u=r>=(o=(g+y)/2))?g=o:y=o}while((h=u<<1|c)==(f=(l>=o)<<1|s>=a));return i[f]=d,i[h]=p,t}function r(t){return t[0]}function n(t){return t[1]}function i(t,e,i){var o=new a(null==e?r:e,null==i?n:i,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function a(t,e,r,n,i,a){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=a,this._root=void 0}function o(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var s=function(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i},l=i.prototype=a.prototype;l.copy=function(){var t,e,r=new a(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=o(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var i=0;i<4;++i)(e=n.source[i])&&(e.length?t.push({source:e,target:n.target[i]=new Array(4)}):n.target[i]=o(e));return r},l.add=function(t){var r=+this._x.call(null,t),n=+this._y.call(null,t);return e(this.cover(r,n),r,n,t)},l.addAll=function(t){var r,n,i,a,o=t.length,s=new Array(o),l=new Array(o),c=1/0,u=1/0,h=-1/0,f=-1/0;for(n=0;nh&&(h=i),af&&(f=a));for(ht||t>i||n>e||e>a))return this;var o,s,l=i-r,c=this._root;switch(s=(e<(n+a)/2)<<1|t<(r+i)/2){case 0:do{o=new Array(4),o[s]=c,c=o}while(l*=2,i=r+l,a=n+l,t>i||e>a);break;case 1:do{o=new Array(4),o[s]=c,c=o}while(l*=2,r=i-l,a=n+l,r>t||e>a);break;case 2:do{o=new Array(4),o[s]=c,c=o}while(l*=2,i=r+l,n=a-l,t>i||n>e);break;case 3:do{o=new Array(4),o[s]=c,c=o}while(l*=2,r=i-l,n=a-l,r>t||n>e)}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=n,this._x1=i,this._y1=a,this},l.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},l.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},l.find=function(t,e,r){var n,i,a,o,l,c,u,h=this._x0,f=this._y0,d=this._x1,p=this._y1,m=[],g=this._root;for(g&&m.push(new s(g,h,f,d,p)),null==r?r=1/0:(h=t-r,f=e-r,d=t+r,p=e+r,r*=r);c=m.pop();)if(!(!(g=c.node)||(i=c.x0)>d||(a=c.y0)>p||(o=c.x1)=y)<<1|t>=v)&&(c=m[m.length-1],m[m.length-1]=m[m.length-1-u],m[m.length-1-u]=c)}else{var b=t-+this._x.call(null,g.data),x=e-+this._y.call(null,g.data),_=b*b+x*x;if(_=(s=(p+g)/2))?p=s:g=s,(u=o>=(l=(m+v)/2))?m=l:v=l,e=d,!(d=d[h=u<<1|c]))return this;if(!d.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(r=e,f=h)}for(;d.data!==t;)if(n=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,n?(i?n.next=i:delete n.next,this):e?(i?e[h]=i:delete e[h],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(r?r[f]=d:this._root=d),this):(this._root=i,this)},l.removeAll=function(t){for(var e=0,r=t.length;e=0&&r._call.call(null,t),r=r._next;--h}function o(){g=(m=y.now())+v,h=f=0;try{a()}finally{h=0,function(){var t,e,r=c,n=1/0;for(;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:c=e);u=t,l(n)}(),g=0}}function s(){var t=y.now(),e=t-m;e>p&&(v-=e,m=t)}function l(t){if(!h){f&&(f=clearTimeout(f));var e=t-g;e>24?(t<1/0&&(f=setTimeout(o,e)),d&&(d=clearInterval(d))):(d||(m=g,d=setInterval(s,p)),h=1,b(o))}}var c,u,h=0,f=0,d=0,p=1e3,m=0,g=0,v=0,y="object"==typeof performance&&performance.now?performance:Date,b="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){setTimeout(t,17)};n.prototype=i.prototype={constructor:n,restart:function(t,r,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?e():+n)+(null==r?0:+r),this._next||u===this||(u?u._next=this:c=this,u=this),this._call=t,this._time=n,l()},stop:function(){this._call&&(this._call=null,this._time=1/0,l())}};t.now=e,t.timer=i,t.timerFlush=a,t.timeout=function(t,e,r){var i=new n;return e=null==e?0:+e,i.restart(function(r){i.stop(),t(r+e)},e,r),i},t.interval=function(t,r,i){var a=new n,o=r;return null==r?(a.restart(t,r,i),a):(r=+r,i=null==i?e():+i,a.restart(function e(n){n+=o,a.restart(e,o+=r,i),t(n)},r,i),a)},Object.defineProperty(t,"__esModule",{value:!0})})},{}],123:[function(t,e,r){!function(){function t(t){return t&&(t.ownerDocument||t.document||t).documentElement}function r(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function n(t,e){return te?1:t>=e?0:NaN}function i(t){return null===t?NaN:+t}function a(t){return!isNaN(t)}function o(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function s(t){return t.length}function l(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function c(){this._=Object.create(null)}function u(t){return(t+="")===ua||t[0]===ha?ha+t:t}function h(t){return(t+="")[0]===ha?t.slice(1):t}function f(t){return u(t)in this._}function d(t){return(t=u(t))in this._&&delete this._[t]}function p(){var t=[];for(var e in this._)t.push(h(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function g(){for(var t in this._)return!1;return!0}function v(){this._=Object.create(null)}function y(t){return t}function b(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=fa.length;r0&&(t=t.slice(0,a));var s=wa.get(t);return s&&(t=s,o=G),a?e?function(){var a=o(e,ea(arguments));n.call(this),this.addEventListener(t,this[i]=a,a.$=r),a._=e}:n:e?x:function(){var e,r=new RegExp("^__on([^.]+)"+$i.requote(t)+"$");for(var n in this)if(e=n.match(r)){var i=this[n];this.removeEventListener(e[1],i,i.$),delete this[n]}}}function q(t,e){return function(r){var n=$i.event;$i.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{$i.event=n}}}function G(t,e){var r=q(t,e);return function(t){var e=t.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||r.call(this,t)}}function Y(e){var n=".dragsuppress-"+ ++ka,i="click"+n,a=$i.select(r(e)).on("touchmove"+n,M).on("dragstart"+n,M).on("selectstart"+n,M);if(null==Ma&&(Ma=!("onselectstart"in e)&&b(e.style,"userSelect")),Ma){var o=t(e).style,s=o[Ma];o[Ma]="none"}return function(t){if(a.on(n,null),Ma&&(o[Ma]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){M(),e()},!0),setTimeout(e,0)}}}function W(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();if(Ta<0){var a=r(t);if(a.scrollX||a.scrollY){var o=(n=$i.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important"))[0][0].getScreenCTM();Ta=!(o.f||o.e),n.remove()}}return Ta?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function X(){return $i.event.changedTouches[0].identifier}function Z(t){return t>0?1:t<0?-1:0}function J(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function K(t){return t>1?0:t<-1?Ea:Math.acos(t)}function Q(t){return t>1?Ia:t<-1?-Ia:Math.asin(t)}function $(t){return((t=Math.exp(t))+1/t)/2}function tt(t){return(t=Math.sin(t/2))*t}function et(){}function rt(t,e,r){return this instanceof rt?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof rt?new rt(t.h,t.s,t.l):gt(""+t,vt,rt):new rt(t,e,r)}function nt(t,e,r){function n(t){return Math.round(255*function(t){return t>360?t-=360:t<0&&(t+=360),t<60?i+(a-i)*t/60:t<180?a:t<240?i+(a-i)*(240-t)/60:i}(t))}var i,a;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=r<0?0:r>1?1:r,a=r<=.5?r*(1+e):r+e-r*e,i=2*r-a,new ft(n(t+120),n(t),n(t-120))}function it(t,e,r){return this instanceof it?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof it?new it(t.h,t.c,t.l):lt(t instanceof ot?t.l:(t=yt((t=$i.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new it(t,e,r)}function at(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ot(r,Math.cos(t*=Pa)*e,Math.sin(t)*e)}function ot(t,e,r){return this instanceof ot?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof ot?new ot(t.l,t.a,t.b):t instanceof it?at(t.h,t.c,t.l):yt((t=ft(t)).r,t.g,t.b):new ot(t,e,r)}function st(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=ct(i)*Ua,n=ct(n)*Va,a=ct(a)*Ha,new ft(ht(3.2404542*i-1.5371385*n-.4985314*a),ht(-.969266*i+1.8760108*n+.041556*a),ht(.0556434*i-.2040259*n+1.0572252*a))}function lt(t,e,r){return t>0?new it(Math.atan2(r,e)*Da,Math.sqrt(e*e+r*r),t):new it(NaN,NaN,t)}function ct(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function ut(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function ht(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function ft(t,e,r){return this instanceof ft?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof ft?new ft(t.r,t.g,t.b):gt(""+t,ft,nt):new ft(t,e,r)}function dt(t){return new ft(t>>16,t>>8&255,255&t)}function pt(t){return dt(t)+""}function mt(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function gt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(xt(i[0]),xt(i[1]),xt(i[2]))}return(a=Ya.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function vt(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new rt(n,i,l)}function yt(t,e,r){var n=ut((.4124564*(t=bt(t))+.3575761*(e=bt(e))+.1804375*(r=bt(r)))/Ua),i=ut((.2126729*t+.7151522*e+.072175*r)/Va);return ot(116*i-16,500*(n-i),200*(i-ut((.0193339*t+.119192*e+.9503041*r)/Ha)))}function bt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function xt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function _t(t){return"function"==typeof t?t:function(){return t}}function wt(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Mt(e,r,t,n)}}function Mt(t,e,r,n){function i(){var t,e=l.status;if(!e&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(l)||e>=200&&e<300||304===e){try{t=r.call(a,l)}catch(t){return void o.error.call(a,t)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=$i.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=$i.event;$i.event=t;try{o.progress.call(a,l)}finally{$i.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(ea(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},$i.rebind(a,o,"on"),null==n?a:a.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(n))}function kt(t,e,r){var n=arguments.length;n<2&&(e=0),n<3&&(r=Date.now());var i={c:t,t:r+e,n:null};return Xa?Xa.n=i:Wa=i,Xa=i,Za||(Ja=clearTimeout(Ja),Za=1,Ka(Tt)),i}function Tt(){var t=At(),e=St()-t;e>24?(isFinite(e)&&(clearTimeout(Ja),Ja=setTimeout(Tt,e)),Za=0):(Za=1,Ka(Tt))}function At(){for(var t=Date.now(),e=Wa;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function St(){for(var t,e=Wa,r=1/0;e;)e.c?(e.t1?Date.UTC.apply(this,arguments):arguments[0])}function Ct(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o68?1900:2e3)}(+n[0]),r+n[0].length):-1}function Bt(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function Ut(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Vt(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ht(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function qt(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Gt(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Yt(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Wt(t,e,r){ao.lastIndex=0;var n=ao.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Xt(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=ca(e)/60|0,i=ca(e)%60;return r+Pt(n,"0",2)+Pt(i,"0",2)}function Zt(t,e,r){oo.lastIndex=0;var n=oo.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function Jt(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,h=i*l+u*Math.cos(s),f=u*o*Math.sin(s);fo.add(Math.atan2(f,h)),n=t,i=l,a=c}var e,r,n,i,a;po.point=function(o,s){po.point=t,n=(e=o)*Pa,i=Math.cos(s=(r=s)*Pa/2+Ea/4),a=Math.sin(s)},po.lineEnd=function(){t(e,r)}}function ne(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ie(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ae(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function oe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function se(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function le(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ce(t){return[Math.atan2(t[1],t[0]),Q(t[2])]}function ue(t,e){return ca(t[0]-e[0])=0;--s)i.point((h=u[s])[0],h[1]);else n(d.x,d.p.x,-1,i);d=d.p}u=(d=d.o).z,p=!p}while(!d.v);i.lineEnd()}}}function be(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(we))}var d,p,m,g=e(a),v=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=h,y.lineEnd=f,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=$i.merge(d);var t=function(t,e){var r=t[0],n=t[1],i=[Math.sin(r),-Math.cos(r),0],a=0,o=0;fo.reset();for(var s=0,l=e.length;s=0?1:-1,M=w*_,k=M>Ea,T=p*b;if(fo.add(Math.atan2(T*w*Math.sin(M),m*x+T*Math.cos(M))),a+=k?_+w*La:_,k^f>=r^v>=r){var A=ae(ne(h),ne(t));le(A);var S=ae(i,A);le(S);var E=(k^_>=0?-1:1)*Q(S[2]);(n>E||n===E&&(A[0]||A[1]))&&(o+=k^_>=0?1:-1)}if(!g++)break;f=v,p=b,m=x,h=t}}return(a<-Aa||a1}function Me(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:x,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function ke(t,e){return((t=t.x)[0]<0?t[1]-Ia-Aa:Ia-t[1])-((e=e.x)[0]<0?e[1]-Ia-Aa:Ia-e[1])}function Te(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=0,h=1,f=s.x-l,d=s.y-c;if(a=t-l,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>h)return;a>u&&(u=a)}if(a=r-l,f||!(a<0)){if(a/=f,f<0){if(a>h)return;a>u&&(u=a)}else if(f>0){if(a0)){if(a/=d,d<0){if(a0){if(a>h)return;a>u&&(u=a)}if(a=n-c,d||!(a<0)){if(a/=d,d<0){if(a>h)return;a>u&&(u=a)}else if(d>0){if(a0&&(i.a={x:l+u*f,y:c+u*d}),h<1&&(i.b={x:l+h*f,y:c+h*d}),i}}}}}}function Ae(t,e,r,n){function i(n,i){return ca(n[0]-t)0?0:3:ca(n[0]-r)0?2:1:ca(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(a,s,l,c){var u=0,h=0;if(null==a||(u=i(a,l))!==(h=i(s,l))||o(a,s)<0^l>0)do{c.point(0===u||3===u?t:r,u>1?n:e)}while((u=(u+l+4)%4)!==h);else c.point(s[0],s[1])}function c(i,a){return t<=i&&i<=r&&e<=a&&a<=n}function u(t,e){c(t,e)&&s.point(t,e)}function h(t,e){var r=c(t=Math.max(-Eo,Math.min(Eo,t)),e=Math.max(-Eo,Math.min(Eo,e)));if(d&&p.push([t,e]),_)m=t,g=e,v=r,_=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&x)s.point(t,e);else{var n={a:{x:y,y:b},b:{x:t,y:e}};T(n)?(x||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),w=!1):r&&(s.lineStart(),s.point(t,e),w=!1)}y=t,b=e,x=r}var f,d,p,m,g,v,y,b,x,_,w,M=s,k=Me(),T=Te(t,e,r,n),A={point:u,lineStart:function(){A.point=h,d&&d.push(p=[]),_=!0,x=!1,y=b=NaN},lineEnd:function(){f&&(h(m,g),v&&x&&k.rejoin(),f.push(k.buffer())),A.point=u,x&&s.lineEnd()},polygonStart:function(){s=k,f=[],d=[],w=!0},polygonEnd:function(){s=M,f=$i.merge(f);var e=function(t){for(var e=0,r=d.length,n=t[1],i=0;in&&J(c,a,t)>0&&++e:a[1]<=n&&J(c,a,t)<0&&--e,c=a;return 0!==e}([t,n]),r=w&&e,i=f.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),l(null,null,1,s),s.lineEnd()),i&&ye(f,a,e,l,s),s.polygonEnd()),f=d=p=null}};return A}}function Se(t){var e=0,r=Ea/3,n=Ne(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Ea/180,r=t[1]*Ea/180):[e/Ea*180,r/Ea*180]},i}function Ee(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,Q((a-(t*t+r*r)*i*i)/(2*i))]},r}function Le(){function t(t,e){Co+=i*t-n*e,n=t,i=e}var e,r,n,i;Oo.point=function(a,o){Oo.point=t,e=n=a,r=i=o},Oo.lineEnd=function(){t(e,r)}}function Ce(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Ie(t,e){vo+=t,yo+=e,++bo}function Pe(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);xo+=o*(e+t)/2,_o+=o*(r+n)/2,wo+=o,Ie(e=t,r=n)}var e,r;Ro.point=function(n,i){Ro.point=t,Ie(e=n,r=i)}}function De(){Ro.point=Ie}function ze(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);xo+=o*(n+t)/2,_o+=o*(i+e)/2,wo+=o,Mo+=(o=i*t-n*e)*(n+t),ko+=o*(i+e),To+=3*o,Ie(n=t,i=e)}var e,r,n,i;Ro.point=function(a,o){Ro.point=t,Ie(e=n=a,r=i=o)},Ro.lineEnd=function(){t(e,r)}}function Oe(t){function e(e){return(a?function(e){function n(r,n){r=t(r,n),e.point(r[0],r[1])}function i(){y=NaN,M.point=o,e.lineStart()}function o(n,i){var o=ne([n,i]),s=t(n,i);r(y,b,v,x,_,w,y=s[0],b=s[1],v=n,x=o[0],_=o[1],w=o[2],a,e),e.point(y,b)}function s(){M.point=n,e.lineEnd()}function l(){i(),M.point=c,M.lineEnd=u}function c(t,e){o(h=t,e),f=y,d=b,p=x,m=_,g=w,M.point=o}function u(){r(y,b,v,x,_,w,f,d,h,p,m,g,a,e),M.lineEnd=s,s()}var h,f,d,p,m,g,v,y,b,x,_,w,M={point:n,lineStart:i,lineEnd:s,polygonStart:function(){e.polygonStart(),M.lineStart=l},polygonEnd:function(){e.polygonEnd(),M.lineStart=i}};return M}:function(e){return Re(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})})(e)}function r(e,a,o,s,l,c,u,h,f,d,p,m,g,v){var y=u-e,b=h-a,x=y*y+b*b;if(x>4*n&&g--){var _=s+d,w=l+p,M=c+m,k=Math.sqrt(_*_+w*w+M*M),T=Math.asin(M/=k),A=ca(ca(M)-1)n||ca((y*C+b*I)/x-.5)>.3||s*d+l*p+c*m0&&16,e):Math.sqrt(n)},e}function Fe(t){this.stream=t}function Re(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function je(t){return Ne(function(){return t})()}function Ne(t){function e(t){return t=o(t[0]*Pa,t[1]*Pa),[t[0]*h+s,l-t[1]*h]}function r(){o=ge(a=He(g,v,b),i);var t=i(p,m);return s=f-t[0]*h,l=d+t[1]*h,n()}function n(){return c&&(c.valid=!1,c=null),e}var i,a,o,s,l,c,u=Oe(function(t,e){return t=i(t,e),[t[0]*h+s,l-t[1]*h]}),h=150,f=480,d=250,p=0,m=0,g=0,v=0,b=0,x=So,_=y,w=null,M=null;return e.stream=function(t){return c&&(c.valid=!1),c=Be(x(a,u(_(t)))),c.valid=!0,c},e.clipAngle=function(t){return arguments.length?(x=null==t?(w=t,So):function(t){function e(t,e){return Math.cos(t)*Math.cos(e)>i}function r(t,e,r){var n=[1,0,0],a=ae(ne(t),ne(e)),o=ie(a,a),s=a[0],l=o-s*s;if(!l)return!r&&t;var c=i*o/l,u=-i*s/l,h=ae(n,a),f=se(n,c);oe(f,se(a,u));var d=h,p=ie(f,d),m=ie(d,d),g=p*p-m*(ie(f,f)-1);if(!(g<0)){var v=Math.sqrt(g),y=se(d,(-p-v)/m);if(oe(y,f),y=ce(y),!r)return y;var b,x=t[0],_=e[0],w=t[1],M=e[1];_0^y[1]<(ca(y[0]-x)Ea^(x<=y[0]&&y[0]<=_)){var A=se(d,(-p+v)/m);return oe(A,f),[y,ce(A)]}}}function n(e,r){var n=a?t:Ea-t,i=0;return e<-n?i|=1:e>n&&(i|=2),r<-n?i|=4:r>n&&(i|=8),i}var i=Math.cos(t),a=i>0,o=ca(i)>Aa;return _e(e,function(t){var i,s,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,f){var d,p=[h,f],m=e(h,f),g=a?m?0:n(h,f):m?n(h+(h<0?Ea:-Ea),f):0;if(!i&&(c=l=m)&&t.lineStart(),m!==l&&(d=r(i,p),(ue(i,d)||ue(p,d))&&(p[0]+=Aa,p[1]+=Aa,m=e(p[0],p[1]))),m!==l)u=0,m?(t.lineStart(),d=r(p,i),t.point(d[0],d[1])):(d=r(i,p),t.point(d[0],d[1]),t.lineEnd()),i=d;else if(o&&i&&a^m){var v;g&s||!(v=r(p,i,!0))||(u=0,a?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!m||i&&ue(i,p)||t.point(p[0],p[1]),i=p,l=m,s=g},lineEnd:function(){l&&t.lineEnd(),i=null},clean:function(){return u|(c&&l)<<1}}},We(t,6*Pa),a?[0,-t]:[-Ea,t-Ea])}((w=+t)*Pa),n()):w},e.clipExtent=function(t){return arguments.length?(M=t,_=t?Ae(t[0][0],t[0][1],t[1][0],t[1][1]):y,n()):M},e.scale=function(t){return arguments.length?(h=+t,r()):h},e.translate=function(t){return arguments.length?(f=+t[0],d=+t[1],r()):[f,d]},e.center=function(t){return arguments.length?(p=t[0]%360*Pa,m=t[1]%360*Pa,r()):[p*Da,m*Da]},e.rotate=function(t){return arguments.length?(g=t[0]%360*Pa,v=t[1]%360*Pa,b=t.length>2?t[2]%360*Pa:0,r()):[g*Da,v*Da,b*Da]},$i.rebind(e,u,"precision"),function(){return i=t.apply(this,arguments),e.invert=i.invert&&function(t){return(t=o.invert((t[0]-s)/h,(l-t[1])/h))&&[t[0]*Da,t[1]*Da]},r()}}function Be(t){return Re(t,function(e,r){t.point(e*Pa,r*Pa)})}function Ue(t,e){return[t,e]}function Ve(t,e){return[t>Ea?t-La:t<-Ea?t+La:t,e]}function He(t,e,r){return t?e||r?ge(Ge(t),Ye(e,r)):Ge(t):e||r?Ye(e,r):Ve}function qe(t){return function(e,r){return e+=t,[e>Ea?e-La:e<-Ea?e+La:e,r]}}function Ge(t){var e=qe(t);return e.invert=qe(-t),e}function Ye(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),Q(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),Q(u*n-s*i)]},r}function We(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Xe(r,i),a=Xe(r,a),(o>0?ia)&&(i+=o*La)):(i=t+o*La,a=t-.5*l);for(var c,u=i;o>0?u>a:u0?e<-Ia+Aa&&(e=-Ia+Aa):e>Ia-Aa&&(e=Ia-Aa);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Ea/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=Z(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ia]},r):rr}function er(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return ca(i)1&&J(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function lr(t,e){return t[0]-e[0]||t[1]-e[1]}function cr(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function ur(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,h=n[1]-c,f=(s*(l-c)-h*(i-a))/(h*o-s*u);return[i+f*o,l+f*u]}function hr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function fr(t){var e=Ko.pop()||new function(){Sr(this),this.edge=this.site=this.circle=null};return e.site=t,e}function dr(t){_r(t),Xo.remove(t),Ko.push(t),Sr(t)}function pr(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];dr(t);for(var l=a;l.circle&&ca(r-l.circle.x)Aa)s=s.L;else{if(!((i=a-function(t,e){var r=t.N;if(r)return gr(r,e);var n=t.site;return n.y===e?n.x:1/0}(s,o))>Aa)){n>-Aa?(e=s.P,r=s):i>-Aa?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=fr(t);if(Xo.insert(e,l),e||r){if(e===r)return _r(e),r=fr(e.site),Xo.insert(l,r),l.edge=r.edge=Mr(e.site,l.site),xr(e),void xr(r);if(r){_r(e),_r(r);var c=e.site,u=c.x,h=c.y,f=t.x-u,d=t.y-h,p=r.site,m=p.x-u,g=p.y-h,v=2*(f*g-d*m),y=f*f+d*d,b=m*m+g*g,x={x:(g*y-d*b)/v+u,y:(f*b-m*y)/v+h};kr(r.edge,c,p,x),l.edge=Mr(c,t,null,x),r.edge=Mr(t,p,null,x),xr(e),xr(r)}else l.edge=Mr(e.site,l.site)}}function gr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,c=l-e;if(!c)return s;var u=s-n,h=1/a-1/c,f=u/c;return h?(-f+Math.sqrt(f*f-2*h*(u*u/(-2*c)-l+c/2+i-a/2)))/h+n:(n+s)/2}function vr(t){this.site=t,this.edges=[]}function yr(t){for(var e,r,n,i,a,o,s,l,c,u,h=t[0][0],f=t[1][0],d=t[0][1],p=t[1][1],m=Wo,g=m.length;g--;)if((a=m[g])&&a.prepare())for(l=(s=a.edges).length,o=0;oAa||ca(i-r)>Aa)&&(s.splice(o,0,new Tr(function(t,e,r){var n=new wr(t,null);return n.a=e,n.b=r,Yo.push(n),n}(a.site,u,ca(n-h)Aa?{x:h,y:ca(e-h)Aa?{x:ca(r-p)Aa?{x:f,y:ca(e-f)Aa?{x:ca(r-d)=-Sa)){var f=l*l+c*c,d=u*u+g*g,p=(g*f-c*d)/h,m=(l*d-u*f)/h,g=m+s,v=Qo.pop()||new function(){Sr(this),this.x=this.y=this.arc=this.site=this.cy=null};v.arc=t,v.site=i,v.x=p+o,v.y=g+Math.sqrt(p*p+m*m),v.cy=g,t.circle=v;for(var y=null,b=Jo._;b;)if(v.y=s)return;if(f>p){if(a){if(a.y>=c)return}else a={x:g,y:l};r={x:g,y:c}}else{if(a){if(a.y1)if(f>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:jr(r,n)})),a=es.lastIndex;return a=0&&!(r=$i.interpolators[n](t,e)););return r}function Ur(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(tn(r)+"rotate(",null,")")-2,x:jr(t,e)})):e&&r.push(tn(r)+"rotate("+e+")")}(t.rotate,e.rotate,r,n),function(t,e,r,n){t!==e?n.push({i:r.push(tn(r)+"skewX(",null,")")-2,x:jr(t,e)}):e&&r.push(tn(r)+"skewX("+e+")")}(t.skew,e.skew,r,n),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(tn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:jr(t[0],e[0])},{i:i-2,x:jr(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(tn(r)+"scale("+e+")")}(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function pn(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++oi&&(n=r,i=e);return n}function Tn(t){return t.reduce(An,0)}function An(t,e){return t+e[1]}function Sn(t,e){return En(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function En(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Ln(t){return[$i.min(t),$i.max(t)]}function Cn(t,e){return t.value-e.value}function In(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Pn(t,e){t._pack_next=e,e._pack_prev=t}function Dn(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function zn(t){function e(t){u=Math.min(t.x-t.r,u),h=Math.max(t.x+t.r,h),f=Math.min(t.y-t.r,f),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,h=-1/0,f=1/0,d=-1/0;if(r.forEach(On),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(jn(n,i,a=r[2]),e(a),In(n,a),n._pack_prev=a,In(a,i),i=n._pack_next,o=3;o2?Kn:Xn,l=n?nn:rn;return o=i(t,e,l,r),s=i(e,t,l,Br),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Jr)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ri(t,e)},a.tickFormat=function(e,r){return ni(t,e,r)},a.nice=function(e){return ti(t,e),i()},a.copy=function(){return Qn(t,e,r,n)},i()}function $n(t,e){return $i.rebind(t,e,"range","rangeRound","interpolate","clamp")}function ti(t,e){return Zn(t,Jn(ei(t,e)[2])),Zn(t,Jn(ei(t,e)[2])),t}function ei(t,e){null==e&&(e=10);var r=Yn(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return a<=.15?i*=10:a<=.35?i*=5:a<=.75&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ri(t,e){return $i.range.apply($i,ei(t,e))}function ni(t,e,r){var n=ei(t,e);if(r){var i=$a.exec(r);if(i.shift(),"s"===i[8]){var a=$i.formatPrefix(Math.max(ca(n[0]),ca(n[1])));return i[7]||(i[7]="."+ii(a.scale(n[2]))),i[8]="f",r=$i.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+function(t,e){var r=ii(e[2]);return t in ds?Math.abs(r-ii(Math.max(ca(e[0]),ca(e[1]))))+ +("e"!==t):r-2*("%"===t)}(i[8],n)),r=i.join("")}else r=",."+ii(n[2])+"f";return $i.format(r)}function ii(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ai(t,e,r,n){function i(t){return(r?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Zn(n.map(i),r?Math:ms);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Yn(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),h=e%1?2:e;if(isFinite(u-c)){if(r){for(;c0;f--)o.push(a(c)*f);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return ps;arguments.length<2?r=ps:"function"!=typeof r&&(r=$i.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return o*e0?s[r-1]:t[0],r0?0:1}function xi(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,h=t[1]+c,f=e[0]+l,d=e[1]+c,p=(u+f)/2,m=(h+d)/2,g=f-u,v=d-h,y=g*g+v*v,b=r-n,x=u*d-f*h,_=(v<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*v-g*_)/y,M=(-x*g-v*_)/y,k=(x*v+g*_)/y,T=(-x*g+v*_)/y,A=w-p,S=M-m,E=k-p,L=T-m;return A*A+S*S>E*E+L*L&&(w=k,M=T),[[w-l,M-c],[w*r/b,M*r/b]]}function _i(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],h=-1,f=e.length,d=_t(r),p=_t(n);++h1?t.join("L"):t+"Z"}function Mi(t){return t.join("L")+"Z"}function ki(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n);for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Di(t){for(var e,r,n,i=-1,a=t.length;++i0;)d[--s].call(t,o);if(a>=1)return m.event&&m.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1}var l,u,h,f,d,p=t[r]||(t[r]={active:0,count:0}),m=p[n];m||(l=i.time,u=kt(a,0,l),m=p[n]={tween:new c,time:l,timer:u,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function Yi(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function Wi(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function Xi(t){return t.toISOString()}function Zi(t,e,r){function n(e){return t(e)}function i(t,r){var n=(t[1]-t[0])/r,i=$i.bisect(Bs,n);return i==Bs.length?[e.year,ei(t.map(function(t){return t/31536e6}),r)[2]]:i?e[n/Bs[i-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=Ji(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=Ji(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Yn(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],Ji(+r[1]+1),e<1?1:e)},n.tickFormat=function(){return r},n.copy=function(){return Zi(t.copy(),e,r)},$n(n,t)}function Ji(t){return new Date(t)}function Ki(t){return JSON.parse(t.responseText)}function Qi(t){var e=ra.createRange();return e.selectNode(ra.body),e.createContextualFragment(t.responseText)}var $i={version:"3.5.17"},ta=[].slice,ea=function(t){return ta.call(t)},ra=this.document;if(ra)try{ea(ra.documentElement.childNodes)[0].nodeType}catch(t){ea=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ra)try{ra.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var na=this.Element.prototype,ia=na.setAttribute,aa=na.setAttributeNS,oa=this.CSSStyleDeclaration.prototype,sa=oa.setProperty;na.setAttribute=function(t,e){ia.call(this,t,e+"")},na.setAttributeNS=function(t,e,r){aa.call(this,t,e,r+"")},oa.setProperty=function(t,e,r){sa.call(this,t,e+"",r)}}$i.ascending=n,$i.descending=function(t,e){return et?1:e>=t?0:NaN},$i.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},$i.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},$i.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return l/(u-1)},$i.deviation=function(){var t=$i.variance.apply(this,arguments);return t?Math.sqrt(t):t};var la=o(n);$i.bisectLeft=la.left,$i.bisect=$i.bisectRight=la.right,$i.bisector=function(t){return o(1===t.length?function(e,r){return n(t(e),r)}:t)},$i.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},$i.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},$i.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var ca=Math.abs;$i.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=function(t){for(var e=1;t*e%1;)e*=10;return e}(ca(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,u,h,f,d=-1,p=o.length,m=a[s++],g=new c;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t($i.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},$i.set=function(t){var e=new v;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},$i.event=null,$i.requote=function(t){return t.replace(da,"\\$&")};var da=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,pa={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},ma=function(t,e){return e.querySelector(t)},ga=function(t,e){return e.querySelectorAll(t)},va=function(t,e){var r=t.matches||t[b(t,"matchesSelector")];return(va=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(ma=function(t,e){return Sizzle(t,e)[0]||null},ga=Sizzle,va=Sizzle.matchesSelector),$i.selection=function(){return $i.select(ra.documentElement)};var ya=$i.selection.prototype=[];ya.select=function(t){var e,r,n,i,a=[];t=S(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),xa.hasOwnProperty(r)?{space:xa[r],local:t}:t}},ya.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return(t=$i.ns.qualify(t)).local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(L(e,t[e]));return this}return this.each(L(t,e))},ya.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=P(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},ya.sort=function(t){t=function(t){return arguments.length||(t=n),function(e,r){return e&&r?t(e.__data__,r.__data__):!e-!r}}.apply(this,arguments);for(var e=-1,r=this.length;++e=e&&(e=i+1);!(o=s[e])&&++e0&&(e=e.transition().duration(E)),e.call(t.event)}function o(){x&&x.domain(b.range().map(function(t){return(t-k.x)/k.k}).map(b.invert)),w&&w.domain(_.range().map(function(t){return(t-k.y)/k.k}).map(_.invert))}function s(t){L++||t({type:"zoomstart"})}function l(t){o(),t({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function c(t){--L||(t({type:"zoomend"}),m=null)}function u(){var t=this,n=z.of(t,arguments),a=0,o=$i.select(r(t)).on(I,function(){a=1,i($i.mouse(t),u),l(n)}).on(P,function(){o.on(I,null).on(P,null),h(a),c(n)}),u=e($i.mouse(t)),h=Y(t);Cs.call(t),s(n)}function h(){function t(){var t=$i.touches(p);return d=k.k,t.forEach(function(t){t.identifier in g&&(g[t.identifier]=e(t))}),t}function r(){var e=$i.event.target;$i.select(e).on(x,o).on(_,f),w.push(e);for(var r=$i.event.changedTouches,n=0,i=r.length;n1){c=s[0];var u=s[1],h=c[0]-u[0],d=c[1]-u[1];v=h*h+d*d}}function o(){var t,e,r,a,o=$i.touches(p);Cs.call(p);for(var s=0,c=o.length;s=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++8?function(t){return t/r}:function(t){return t*r},symbol:t}});$i.formatPrefix=function(t,e){var r=0;return(t=+t)&&(t<0&&(t*=-1),e&&(t=$i.round(t,Et(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),Qa[8+r/3]};var $a=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,to=$i.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=$i.round(t,Et(t,e))).toFixed(Math.max(0,Math.min(20,Et(t*(1+1e-15),e))))}}),eo=$i.time={},ro=Date;Lt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){no.setUTCDate.apply(this._,arguments)},setDay:function(){no.setUTCDay.apply(this._,arguments)},setFullYear:function(){no.setUTCFullYear.apply(this._,arguments)},setHours:function(){no.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){no.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){no.setUTCMinutes.apply(this._,arguments)},setMonth:function(){no.setUTCMonth.apply(this._,arguments)},setSeconds:function(){no.setUTCSeconds.apply(this._,arguments)},setTime:function(){no.setTime.apply(this._,arguments)}};var no=Date.prototype;eo.year=Ct(function(t){return(t=eo.day(t)).setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),eo.years=eo.year.range,eo.years.utc=eo.year.utc.range,eo.day=Ct(function(t){var e=new ro(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),eo.days=eo.day.range,eo.days.utc=eo.day.utc.range,eo.dayOfYear=function(t){var e=eo.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=eo[t]=Ct(function(t){return(t=eo.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=eo.year(t).getDay();return Math.floor((eo.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});eo[t+"s"]=r.range,eo[t+"s"].utc=r.utc.range,eo[t+"OfYear"]=function(t){var r=eo.year(t).getDay();return Math.floor((eo.dayOfYear(t)+(r+e)%7)/7)}}),eo.week=eo.sunday,eo.weeks=eo.sunday.range,eo.weeks.utc=eo.sunday.utc.range,eo.weekOfYear=eo.sundayOfYear;var io={"-":"",_:" ",0:"0"},ao=/^\s*\d+/,oo=/^%/;$i.locale=function(t){return{numberFormat:function(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:y;return function(t){var r=$a.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],h=r[7],f=r[8],d=r[9],p=1,m="",g="",v=!1,y=!0;switch(f&&(f=+f.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":h=!0,d="g";break;case"%":p=100,g="%",d="f";break;case"p":p=100,g="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(m="0"+d.toLowerCase());case"c":y=!1;case"d":v=!0,f=0;break;case"s":p=-1,d="r"}"$"===l&&(m=i[0],g=i[1]),"r"!=d||f||(d="g"),null!=f&&("g"==d?f=Math.max(1,Math.min(21,f)):"e"!=d&&"f"!=d||(f=Math.max(0,Math.min(20,f)))),d=to.get(d)||function(t){return t+""};var b=c&&h;return function(t){var r=g;if(v&&t%1)return"";var i=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===s?"":s;if(p<0){var l=$i.formatPrefix(t,f);t=l.scale(t),r=l.symbol+g}else t*=p;var x,_,w=(t=d(t,f)).lastIndexOf(".");if(w<0){var M=y?t.lastIndexOf("e"):-1;M<0?(x=t,_=""):(x=t.substring(0,M),_=t.substring(M))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&h&&(x=a(x,1/0));var k=m.length+x.length+_.length+(b?0:i.length),T=k"===o?T+i+t:"^"===o?T.substring(0,k>>=1)+i+t+T.substring(k):i+(b?t:T+t))+r}}}(t),timeFormat:function(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++s=c)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=_[o in io?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}var n=t.dateTime,i=t.date,a=t.time,o=t.periods,s=t.days,l=t.shortDays,c=t.months,u=t.shortMonths;e.multi=(e.utc=function(t){function r(t){try{var e=new(ro=Lt);return e._=t,n(e)}finally{ro=Date}}var n=e(t);return r.parse=function(t){try{ro=Lt;var e=n.parse(t);return e&&e._}finally{ro=Date}},r.toString=n.toString,r}).multi=Jt;var h=$i.map(),f=Dt(s),d=zt(s),p=Dt(l),m=zt(l),g=Dt(c),v=zt(c),y=Dt(u),b=zt(u);o.forEach(function(t,e){h.set(t.toLowerCase(),e)});var x={a:function(t){return l[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return c[t.getMonth()]},c:e(n),d:function(t,e){return Pt(t.getDate(),e,2)},e:function(t,e){return Pt(t.getDate(),e,2)},H:function(t,e){return Pt(t.getHours(),e,2)},I:function(t,e){return Pt(t.getHours()%12||12,e,2)},j:function(t,e){return Pt(1+eo.dayOfYear(t),e,3)},L:function(t,e){return Pt(t.getMilliseconds(),e,3)},m:function(t,e){return Pt(t.getMonth()+1,e,2)},M:function(t,e){return Pt(t.getMinutes(),e,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,e){return Pt(t.getSeconds(),e,2)},U:function(t,e){return Pt(eo.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Pt(eo.mondayOfYear(t),e,2)},x:e(i),X:e(a),y:function(t,e){return Pt(t.getFullYear()%100,e,2)},Y:function(t,e){return Pt(t.getFullYear()%1e4,e,4)},Z:Xt,"%":function(){return"%"}},_={a:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=m.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){f.lastIndex=0;var n=f.exec(e.slice(r));return n?(t.w=d.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){y.lastIndex=0;var n=y.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.m=v.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,n){return r(t,x.c.toString(),e,n)},d:Vt,e:Vt,H:qt,I:qt,j:Ht,L:Wt,m:Ut,M:Gt,p:function(t,e,r){var n=h.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:Yt,U:Ft,w:Ot,W:Rt,x:function(t,e,n){return r(t,x.x.toString(),e,n)},X:function(t,e,n){return r(t,x.X.toString(),e,n)},y:Nt,Y:jt,Z:Bt,"%":Zt};return e}(t)}};var so=$i.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",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"]});$i.format=so.numberFormat,$i.geo={},Kt.prototype={s:0,t:0,add:function(t){Qt(t,this.t,lo),Qt(lo.s,this.s,this),this.s?this.t+=lo.t:this.s=lo.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var lo=new Kt;$i.geo.stream=function(t,e){t&&co.hasOwnProperty(t.type)?co[t.type](t,e):$t(t,e)};var co={Feature:function(t,e){$t(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nd&&(d=e)}function e(e,r){var n=ne([e*Pa,r*Pa]);if(v){var i=ae(v,n),a=ae([i[1],-i[0],0],i);le(a),a=ce(a);var o=e-p,l=o>0?1:-1,c=a[0]*Da*l,m=ca(o)>180;if(m^(l*pd&&(d=g)}else if(c=(c+360)%360-180,m^(l*pd&&(d=r);m?es(u,f)&&(f=e):s(e,f)>s(u,f)&&(u=e):f>=u?(ef&&(f=e)):e>p?s(u,e)>s(u,f)&&(f=e):s(e,f)>s(u,f)&&(u=e)}else t(e,r);v=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=f,_.point=t,v=null}function i(t,r){if(v){var n=t-p;y+=ca(n)>180?n+(n>0?360:-360):n}else m=t,g=r;po.point(t,r),e(t,r)}function a(){po.lineStart()}function o(){i(m,g),po.lineEnd(),ca(y)>Aa&&(u=-(f=180)),x[0]=u,x[1]=f,v=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tAa?d=90:y<-Aa&&(h=-90),x[0]=u,x[1]=f}};return function(t){d=f=-(u=h=1/0),b=[],$i.geo.stream(t,_);if(i=b.length){b.sort(l);for(var e=1,r=[p=b[0]];es(p[0],p[1])&&(p[1]=a[1]),s(a[0],p[1])>s(p[0],p[1])&&(p[0]=a[0])):r.push(p=a);for(var n,i,a,o=-1/0,p=(e=0,r[i=r.length-1]);e<=i;p=a,++e)a=r[e],(n=s(p[1],a[0]))>o&&(o=n,u=a[0],f=p[1])}return b=x=null,u===1/0||h===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,h],[f,d]]}}(),$i.geo.centroid=function(t){mo=go=vo=yo=bo=xo=_o=wo=Mo=ko=To=0,$i.geo.stream(t,Ao);var e=Mo,r=ko,n=To,i=e*e+r*r+n*n;return i0?Ea:-Ea,l=ca(a-r);ca(l-Ea)0?Ia:-Ia),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Ea&&(ca(r-i)Aa?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}},function(t,e,r,n){var i;if(null==t)i=r*Ia,n.point(-Ea,i),n.point(0,i),n.point(Ea,i),n.point(Ea,0),n.point(Ea,-i),n.point(0,-i),n.point(-Ea,-i),n.point(-Ea,0),n.point(-Ea,i);else if(ca(t[0]-e[0])>Aa){var a=t[0]=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],h=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,h-.238*c],[u+.455*c,h+.238*c]]).stream(l).point,n=o.translate([u-.307*c,h+.201*c]).clipExtent([[u-.425*c+Aa,h+.12*c+Aa],[u-.214*c-Aa,h+.234*c-Aa]]).stream(l).point,i=s.translate([u-.205*c,h+.212*c]).clipExtent([[u-.214*c+Aa,h+.166*c+Aa],[u-.115*c-Aa,h+.234*c-Aa]]).stream(l).point,t},t.scale(1070)};var Lo,Co,Io,Po,Do,zo,Oo={point:x,lineStart:x,lineEnd:x,polygonStart:function(){Co=0,Oo.lineStart=Le},polygonEnd:function(){Oo.lineStart=Oo.lineEnd=Oo.point=x,Lo+=ca(Co/2)}},Fo={point:function(t,e){tDo&&(Do=t),ezo&&(zo=e)},lineStart:x,lineEnd:x,polygonStart:x,polygonEnd:x},Ro={point:Ie,lineStart:Pe,lineEnd:De,polygonStart:function(){Ro.lineStart=ze},polygonEnd:function(){Ro.point=Ie,Ro.lineStart=Pe,Ro.lineEnd=De}};$i.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),$i.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return Lo=0,$i.geo.stream(t,i(Oo)),Lo},t.centroid=function(t){return vo=yo=bo=xo=_o=wo=Mo=ko=To=0,$i.geo.stream(t,i(Ro)),To?[Mo/To,ko/To]:wo?[xo/wo,_o/wo]:bo?[vo/bo,yo/bo]:[NaN,NaN]},t.bounds=function(t){return Do=zo=-(Io=Po=1/0),$i.geo.stream(t,i(Fo)),[[Io,Po],[Do,zo]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||function(t){var e=Oe(function(e,r){return t([e*Da,r*Da])});return function(t){return Be(e(t))}}(t):y,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new function(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=Ce(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=Ce(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}:new function(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,La)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:x};return s}(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection($i.geo.albersUsa()).context(null)},$i.geo.transform=function(t){return{stream:function(e){var r=new Fe(e);for(var n in t)r[n]=t[n];return r}}},Fe.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},$i.geo.projection=je,$i.geo.projectionMutator=Ne,($i.geo.equirectangular=function(){return je(Ue)}).raw=Ue.invert=Ue,$i.geo.rotation=function(t){function e(e){return e=t(e[0]*Pa,e[1]*Pa),e[0]*=Da,e[1]*=Da,e}return t=He(t[0]%360*Pa,t[1]*Pa,t.length>2?t[2]*Pa:0),e.invert=function(e){return e=t.invert(e[0]*Pa,e[1]*Pa),e[0]*=Da,e[1]*=Da,e},e},Ve.invert=Ue,$i.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=He(-t[0]*Pa,-t[1]*Pa,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Da,t[1]*=Da}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=We((e=+n)*Pa,i*Pa),t):e},t.precision=function(n){return arguments.length?(r=We(e*Pa,(i=+n)*Pa),t):i},t.angle(90)},$i.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Pa,i=t[1]*Pa,a=e[1]*Pa,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),h=Math.cos(a);return Math.atan2(Math.sqrt((r=h*o)*r+(r=c*u-l*h*s)*r),l*u+c*h*s)},$i.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return $i.range(Math.ceil(a/g)*g,i,g).map(f).concat($i.range(Math.ceil(c/v)*v,l,v).map(d)).concat($i.range(Math.ceil(n/p)*p,r,p).filter(function(t){return ca(t%g)>Aa}).map(u)).concat($i.range(Math.ceil(s/m)*m,o,m).filter(function(t){return ca(t%v)>Aa}).map(h))}var r,n,i,a,o,s,l,c,u,h,f,d,p=10,m=p,g=90,v=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[f(a).concat(d(l).slice(1),f(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(g=+e[0],v=+e[1],t):[g,v]},t.minorStep=function(e){return arguments.length?(p=+e[0],m=+e[1],t):[p,m]},t.precision=function(e){return arguments.length?(y=+e,u=Ze(s,o,90),h=Je(n,r,y),f=Ze(c,l,90),d=Je(a,i,y),t):y},t.majorExtent([[-180,-90+Aa],[180,90-Aa]]).minorExtent([[-180,-80-Aa],[180,80+Aa]])},$i.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=Ke,i=Qe;return t.distance=function(){return $i.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},$i.geo.interpolate=function(t,e){return function(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),h=o*Math.sin(r),f=2*Math.asin(Math.sqrt(tt(n-e)+i*o*tt(r-t))),d=1/Math.sin(f),p=f?function(t){var e=Math.sin(t*=f)*d,r=Math.sin(f-t)*d,n=r*l+e*u,i=r*c+e*h,o=r*a+e*s;return[Math.atan2(i,n)*Da,Math.atan2(o,Math.sqrt(n*n+i*i))*Da]}:function(){return[t*Da,e*Da]};return p.distance=f,p}(t[0]*Pa,t[1]*Pa,e[0]*Pa,e[1]*Pa)},$i.geo.length=function(t){return jo=0,$i.geo.stream(t,No),jo};var jo,No={sphere:x,point:x,lineStart:function(){function t(t,i){var a=Math.sin(i*=Pa),o=Math.cos(i),s=ca((t*=Pa)-e),l=Math.cos(s);jo+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;No.point=function(i,a){e=i*Pa,r=Math.sin(a*=Pa),n=Math.cos(a),No.point=t},No.lineEnd=function(){No.point=No.lineEnd=x}},lineEnd:x,polygonStart:x,polygonEnd:x},Bo=$e(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});($i.geo.azimuthalEqualArea=function(){return je(Bo)}).raw=Bo;var Uo=$e(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},y);($i.geo.azimuthalEquidistant=function(){return je(Uo)}).raw=Uo,($i.geo.conicConformal=function(){return Se(tr)}).raw=tr,($i.geo.conicEquidistant=function(){return Se(er)}).raw=er;var Vo=$e(function(t){return 1/t},Math.atan);($i.geo.gnomonic=function(){return je(Vo)}).raw=Vo,rr.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ia]},($i.geo.mercator=function(){return nr(rr)}).raw=rr;var Ho=$e(function(){return 1},Math.asin);($i.geo.orthographic=function(){return je(Ho)}).raw=Ho;var qo=$e(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});($i.geo.stereographic=function(){return je(qo)}).raw=qo,ir.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ia]},($i.geo.transverseMercator=function(){var t=nr(ir),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=ir,$i.geom={},$i.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=_t(r),a=_t(n),o=t.length,s=[],l=[];for(e=0;e=0;--e)d.push(t[s[c[e]][2]]);for(e=+h;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[]).point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Aa)*Aa,y:Math.round(o(t,e)/Aa)*Aa,i:e}})}var n=ar,i=or,a=n,o=i,s=$o;return t?e(t):(e.links=function(t){return Ir(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return Ir(r(t)).cells.forEach(function(r,n){for(var i,a=r.site,o=r.edges.sort(br),s=-1,l=o.length,c=o[l-1].edge,u=c.l===a?c.r:c.l;++s=c,f=n>=u,d=f<<1|h;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]={leaf:!0,nodes:[],point:null,x:null,y:null}),h?i=c:s=c,f?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,h,f,d,p,m,g,v,y,b=_t(s),x=_t(l);if(null!=e)m=e,g=r,v=n,y=i;else if(v=y=-(m=g=1/0),h=[],f=[],p=t.length,o)for(d=0;dv&&(v=u.x),u.y>y&&(y=u.y),h.push(u.x),f.push(u.y);else for(d=0;dv&&(v=_),w>y&&(y=w),h.push(_),f.push(w)}var M=v-m,k=y-g;M>k?y=g+M:v=m+k;var T={leaf:!0,nodes:[],point:null,x:null,y:null};if(T.add=function(t){a(T,t,+b(t,++d),+x(t,d),m,g,v,y)},T.visit=function(t){Or(t,T,m,g,v,y)},T.find=function(t){return function(t,e,r,n,i,a,o){var s,l=1/0;return function t(c,u,h,f,d){if(!(u>a||h>o||f=_)<<1|e>=x,M=w+4;w=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ns.get(r)||rs,n=is.get(n)||y,function(t){return function(e){return e<=0?0:e>=1?1:t(e)}}(n(r.apply(null,ta.call(arguments,1))))},$i.interpolateHcl=function(t,e){t=$i.hcl(t),e=$i.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return at(r+a*t,n+o*t,i+s*t)+""}},$i.interpolateHsl=function(t,e){t=$i.hsl(t),e=$i.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return nt(r+a*t,n+o*t,i+s*t)+""}},$i.interpolateLab=function(t,e){t=$i.lab(t),e=$i.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return st(r+a*t,n+o*t,i+s*t)+""}},$i.interpolateRound=Jr,$i.transform=function(t){var e=ra.createElementNS($i.ns.prefix.svg,"g");return($i.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Kr(r?r.matrix:as)})(t)},Kr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var as={a:1,b:0,c:0,d:1,e:0,f:0};$i.interpolateTransform=en,$i.layout={},$i.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++r0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=kt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;l=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return pn(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=vn,r=mn,n=gn;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(dn(e,function(t){t.children&&(t.value=0)}),pn(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},$i.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cs&&(s=n),o.push(n)}for(r=0;r0)for(a=-1;++a=u[0]&&s<=u[1]&&((o=l[$i.bisect(h,s,1,d)-1]).y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=Ln,i=Sn;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=_t(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return En(t,e)}:_t(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},$i.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,pn(s,function(t){t.r=+u(t.value)}),pn(s,zn),n){var h=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;pn(s,function(t){t.r+=h}),pn(s,zn),pn(s,function(t){t.r-=h})}return Rn(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=$i.layout.hierarchy().sort(Cn),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},fn(t,r)},$i.layout.tree=function(){function t(t,l){var c=i.call(this,t,l),u=c[0],h=function(t){var e,r={A:null,children:[t]},n=[r];for(;null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;od.x&&(d=t),t.depth>p.depth&&(p=t)});var m=a(f,d)/2-f.x,g=o[0]/(d.x+a(d,f)/2+m),v=o[1]/(p.depth||1);dn(u,function(t){t.x=(t.x+m)*g,t.y=t.depth*v})}return c}function e(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){!function(t){for(var e,r=0,n=0,i=t.children,a=i.length;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var i=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+a(t._,n._),t.m=t.z-i):t.z=i}else n&&(t.z=n.z+a(t._,n._));t.parent.A=function(t,e,r){if(e){for(var n,i=t,o=t,s=e,l=i.parent.children[0],c=i.m,u=o.m,h=s.m,f=l.m;s=Un(s),i=Bn(i),s&&i;)l=Bn(l),(o=Un(o)).a=t,(n=s.z+h-i.z-c+a(s._,i._))>0&&(!function(t,e,r){var n=r/(e.i-t.i);e.c-=n,e.s+=r,t.c+=n,e.z+=r,e.m+=r}(function(t,e,r){return t.a.parent===e.parent?t.a:r}(s,t,r),t,n),c+=n,u+=n),h+=s.m,c+=i.m,f+=l.m,u+=o.m;s&&!Un(o)&&(o.t=s,o.m+=h-u),i&&!Bn(l)&&(l.t=i,l.m+=c-f,r=t)}return r}(t,n,t.parent.A||r[0])}function r(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function n(t){t.x*=o[0],t.y=t.depth*o[1]}var i=$i.layout.hierarchy().sort(null).value(null),a=Nn,o=[1,1],s=null;return t.separation=function(e){return arguments.length?(a=e,t):a},t.size=function(e){return arguments.length?(s=null==(o=e)?n:null,t):s?null:o},t.nodeSize=function(e){return arguments.length?(s=null==(o=e)?null:n,t):s?o:null},fn(t,i)},$i.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;pn(l,function(t){var e=t.children;e&&e.length?(t.x=function(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}(e),t.y=function(t){return 1+$i.max(t,function(t){return t.y})}(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Vn(l),h=Hn(l),f=u.x-r(u,h)/2,d=h.x+r(h,u)/2;return pn(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-f)/(d-f)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=$i.layout.hierarchy().sort(null).value(null),r=Nn,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},fn(t,e)},$i.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++i0;)c.push(a=h[s-1]),c.area+=a.area,"squarify"!==f||(o=function(t,e){var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;for(;++oi&&(i=r));return n*=n,e*=e,n?Math.max(e*i*d/n,n/(e*a*d)):1/0}(c,m))<=p?(h.pop(),p=o):(c.area-=c.pop().area,n(c,m,l,!1),m=Math.min(l.dx,l.dy),c.length=c.area=0,p=1/0);c.length&&(n(c,m,l,!0),c.length=c.area=0),i.forEach(e)}}function r(e){var i=e.children;if(i&&i.length){var a,o=u(e),s=i.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(n(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);i.forEach(r)}}function n(t,e,r,n){var i,a=-1,o=t.length,l=r.x,c=r.y,u=e?s(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++a1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=$i.random.normal.apply($i,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=$i.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;rh?0:1;if(c=Ca)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,m,g,v,y,b,x,_,w,M,k,T,A=0,S=0,E=[];if((v=(+l.apply(this,arguments)||0)/2)&&(g=a===xs?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(S*=-1),c&&(S=Q(g/c*Math.sin(v))),t&&(A=Q(g/t*Math.sin(v)))),c){y=c*Math.cos(u+S),b=c*Math.sin(u+S),x=c*Math.cos(h-S),_=c*Math.sin(h-S);var L=Math.abs(h-u-2*S)<=Ea?0:1;if(S&&bi(y,b,x,_)===d^L){var C=(u+h)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(h-A),M=t*Math.sin(h-A),k=t*Math.cos(u+A),T=t*Math.sin(u+A);var I=Math.abs(u-h+2*A)<=Ea?0:1;if(A&&bi(w,M,k,T)===1-d^I){var P=(u+h)/2;w=t*Math.cos(P),M=t*Math.sin(P),k=T=null}}else w=M=0;if(f>Aa&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){m=t1&&i.push("H",n[0]),i.join("")},"step-before":ki,"step-after":Ti,basis:Ei,"basis-open":function(t){if(t.length<4)return wi(t);for(var e,r=[],n=-1,i=t.length,a=[0],o=[0];++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);for(r.push(Li(ks,a)+","+Li(ks,o)),--n;++nEa)+",1 "+e}function n(t,e,r,n){return"Q 0,0 "+n}var i=Ke,a=Qe,o=Oi,s=gi,l=vi;return t.radius=function(e){return arguments.length?(o=_t(e),t):o},t.source=function(e){return arguments.length?(i=_t(e),t):i},t.target=function(e){return arguments.length?(a=_t(e),t):a},t.startAngle=function(e){return arguments.length?(s=_t(e),t):s},t.endAngle=function(e){return arguments.length?(l=_t(e),t):l},t},$i.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(n))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=Ke,r=Qe,n=Fi;return t.source=function(r){return arguments.length?(e=_t(r),t):e},t.target=function(e){return arguments.length?(r=_t(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},$i.svg.diagonal.radial=function(){var t=$i.svg.diagonal(),e=Fi,r=t.projection;return t.projection=function(t){return arguments.length?r(function(t){return function(){var e=t.apply(this,arguments),r=e[0],n=e[1]-Ia;return[r*Math.cos(n),r*Math.sin(n)]}}(e=t)):e},t},$i.svg.symbol=function(){function t(t,n){return(Ts.get(e.call(this,t,n))||Ni)(r.call(this,t,n))}var e=ji,r=Ri;return t.type=function(r){return arguments.length?(e=_t(r),t):e},t.size=function(e){return arguments.length?(r=_t(e),t):r},t};var Ts=$i.map({circle:Ni,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ss)),r=e*Ss;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/As),r=e*As/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/As),r=e*As/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});$i.svg.symbolTypes=Ts.keys();var As=Math.sqrt(3),Ss=Math.tan(30*Pa);ya.transition=function(t){for(var e,r,n=Es||++Ps,i=qi(t),a=[],o=Ls||{time:Date.now(),ease:function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)},delay:0,duration:250},s=-1,l=this.length;++srect,.s>rect").attr("width",h[1]-h[0])}function i(t){t.select(".extent").attr("y",f[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function a(){function a(){var t=$i.mouse(b),r=!1;y&&(t[0]+=y[0],t[1]+=y[1]),S||($i.event.altKey?(v||(v=[(h[0]+h[1])/2,(f[0]+f[1])/2]),L[0]=h[+(t[0]=2)return!1;t[r]=n}return!0}):_.filter(function(t){for(var e=0;e<=s;++e){var r=v[t[e]];if(r<0)return!1;t[e]=r}return!0}),1&s)for(u=0;u<_.length;++u)f=(x=_[u])[0],x[0]=x[1],x[1]=f;return _}},{"incremental-convex-hull":291,uniq:552}],125:[function(t,e,r){(function(t){var r=!1;if("undefined"!=typeof Float64Array){var n=new Float64Array(1),i=new Uint32Array(n.buffer);if(n[0]=1,r=!0,1072693248===i[1]){e.exports=function(t){return n[0]=t,[i[0],i[1]]};function a(t,e){return i[0]=t,i[1]=e,n[0]}e.exports.pack=a;function o(t){return n[0]=t,i[0]}e.exports.lo=o;function s(t){return n[0]=t,i[1]}e.exports.hi=s}else if(1072693248===i[0]){e.exports=function(t){return n[0]=t,[i[1],i[0]]};function l(t,e){return i[1]=t,i[0]=e,n[0]}e.exports.pack=l;function c(t){return n[0]=t,i[1]}e.exports.lo=c;function u(t){return n[0]=t,i[0]}e.exports.hi=u}else r=!1}if(!r){var h=new t(8);e.exports=function(t){return h.writeDoubleLE(t,0,!0),[h.readUInt32LE(0,!0),h.readUInt32LE(4,!0)]};function f(t,e){return h.writeUInt32LE(t,0,!0),h.writeUInt32LE(e,4,!0),h.readDoubleLE(0,!0)}e.exports.pack=f;function d(t){return h.writeDoubleLE(t,0,!0),h.readUInt32LE(0,!0)}e.exports.lo=d;function p(t){return h.writeDoubleLE(t,0,!0),h.readUInt32LE(4,!0)}e.exports.hi=p}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:78}],126:[function(t,e,r){"use strict";function n(t,e,r){var i=0|t[r];if(i<=0)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;a0)return function(t,e){var r,n;for(r=new Array(t),n=0;n=n.next.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=h&&c(ar.x)&&d(n,t)&&(r=n,p=l),n=n.next;return r}(t,e)){var r=p(e,t);a(r,r.next)}}(m[o],r),r=a(r,r.next);return r}(t,e,u,r)),t.length>80*r){f=g=t[0],m=v=t[1];for(var _=r;_g&&(g=y),b>v&&(v=b);x=Math.max(g-f,v-m)}return o(u,h,r,f,m,x),h}function i(t,e,r,n,i){var a,o;if(i===y(t,e,r,n)>0)for(a=e;a=e;a-=n)o=m(a,t[a],t[a+1],o);return o&&h(o,o.next)&&(g(o),o=o.next),o}function a(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!h(n,n.next)&&0!==u(n.prev,n,n.next))n=n.next;else{if(g(n),(n=e=n.prev)===n.next)return null;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,i,s,m){if(t){!m&&s&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=l(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0===s?(i=n,n=n.nextZ,l--):0!==l&&n?r.z<=n.z?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,s--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,s);for(var v,y,b=t;t.prev!==t.next;)if(v=t.prev,y=t.next,s?function(t,e,r,n){var i=t.prev,a=t,o=t.next;if(u(i,a,o)>=0)return!1;var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,d=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,p=l(s,h,e,r,n),m=l(f,d,e,r,n),g=t.nextZ;for(;g&&g.z<=m;){if(g!==t.prev&&g!==t.next&&c(i.x,i.y,a.x,a.y,o.x,o.y,g.x,g.y)&&u(g.prev,g,g.next)>=0)return!1;g=g.nextZ}g=t.prevZ;for(;g&&g.z>=p;){if(g!==t.prev&&g!==t.next&&c(i.x,i.y,a.x,a.y,o.x,o.y,g.x,g.y)&&u(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}(t,n,i,s):function(t){var e=t.prev,r=t,n=t.next;if(u(e,r,n)>=0)return!1;var i=t.next.next;for(;i!==t.prev;){if(c(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&u(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}(t))e.push(v.i/r),e.push(t.i/r),e.push(y.i/r),g(t),t=y.next,b=y.next;else if((t=y)===b){m?1===m?o(t=function(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!h(i,a)&&f(i,n,n.next,a)&&d(i,a)&&d(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),g(n),g(n.next),n=t=a),n=n.next}while(n!==t);return n}(t,e,r),e,r,n,i,s,2):2===m&&function(t,e,r,n,i,s){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&f(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&d(t,e)&&d(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}(l,c)){var u=p(l,c);return l=a(l,l.next),u=a(u,u.next),o(l,e,r,n,i,s),void o(u,e,r,n,i,s)}c=c.next}l=l.next}while(l!==t)}(t,e,r,n,i,s):o(a(t),e,r,n,i,s,1);break}}}function s(t,e){return t.x-e.x}function l(t,e,r,n,i){return t=32767*(t-r)/i,e=32767*(e-n)/i,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function c(t,e,r,n,i,a,o,s){return(i-o)*(e-s)-(t-o)*(a-s)>=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function u(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function h(t,e){return t.x===e.x&&t.y===e.y}function f(t,e,r,n){return!!(h(t,e)&&h(r,n)||h(t,n)&&h(r,e))||u(t,e,r)>0!=u(t,e,n)>0&&u(r,n,t)>0!=u(r,n,e)>0}function d(t,e){return u(t.prev,t,t.next)<0?u(t,e,t.next)>=0&&u(t,t.prev,e)>=0:u(t,e,t.prev)<0||u(t,t.next,e)<0}function p(t,e){var r=new v(t.i,t.x,t.y),n=new v(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function m(t,e,r,n){var i=new v(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function g(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function v(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function y(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r}},{}],128:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var i=0;i0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(a(r)){for(s=o;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],131:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=e||0,i=r||1;return[[t[12]+t[0],t[13]+t[1],t[14]+t[2],t[15]+t[3]],[t[12]-t[0],t[13]-t[1],t[14]-t[2],t[15]-t[3]],[t[12]+t[4],t[13]+t[5],t[14]+t[6],t[15]+t[7]],[t[12]-t[4],t[13]-t[5],t[14]-t[6],t[15]-t[7]],[n*t[12]+t[8],n*t[13]+t[9],n*t[14]+t[10],n*t[15]+t[11]],[i*t[12]-t[8],i*t[13]-t[9],i*t[14]-t[10],i*t[15]-t[11]]]}},{}],132:[function(t,e,r){"use strict";e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(0===(t=+t)&&function(t){for(var e,r=t.length,n=0;n13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}(r))return!1}else if("number"!==e)return!1;return t-t<1}},{}],133:[function(t,e,r){"use strict";function n(t){if(!t)return"true";var e=t[0];if(t.length<=1)return"any"===e?"false":"true";return"("+("=="===e?a(t[1],t[2],"===",!1):"!="===e?a(t[1],t[2],"!==",!1):"<"===e||">"===e||"<="===e||">="===e?a(t[1],t[2],e,!0):"any"===e?o(t.slice(1),"||"):"all"===e?o(t.slice(1),"&&"):"none"===e?c(o(t.slice(1),"||")):"in"===e?s(t[1],t.slice(2)):"!in"===e?c(s(t[1],t.slice(2))):"has"===e?l(t[1]):"!has"===e?c(l([t[1]])):"true")+")"}function i(t){return"$type"===t?"f.type":"$id"===t?"f.id":"p["+JSON.stringify(t)+"]"}function a(t,e,r,n){var a=i(t),o="$type"===t?h.indexOf(e):JSON.stringify(e);return(n?"typeof "+a+"=== typeof "+o+"&&":"")+a+r+o}function o(t,e){return t.map(n).join(e)}function s(t,e){"$type"===t&&(e=e.map(function(t){return h.indexOf(t)}));var r=JSON.stringify(e.sort(u)),n=i(t);return e.length<=200?r+".indexOf("+n+") !== -1":"function(v, a, i, j) {while (i <= j) { var m = (i + j) >> 1; if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;}return false; }("+n+", "+r+",0,"+(e.length-1)+")"}function l(t){return JSON.stringify(t)+" in p"}function c(t){return"!("+t+")"}function u(t,e){return te?1:0}e.exports=function(t){return new Function("f","var p = (f && f.properties || {}); return "+n(t))};var h=["Unknown","Point","LineString","Polygon"]},{}],134:[function(t,e,r){"use strict";function n(t,e,r){return Math.min(e,Math.max(t,r))}function i(t,e,r){this.dimension=t.length,this.bounds=[new Array(this.dimension),new Array(this.dimension)];for(var n=0;n=r-1){f=l.length-1;var p=t-e[r-1];for(d=0;d=r-1)for(var u=a.length-1,h=(e[r-1],0);h=0;--r)if(t[--e])return!1;return!0},l.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--h)i.push(n(l[h-1],c[h-1],arguments[h])),a.push(0)}},l.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var f=r;f>0;--f){var d=n(c[f-1],u[f-1],arguments[f]);i.push(d),a.push((d-i[o++])*h)}}},l.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},l.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,h=u>1e-6?1/u:0;this._time.push(t);for(var f=r;f>0;--f){var d=arguments[f];i.push(n(l[f-1],c[f-1],i[o++]+d)),a.push(d*h)}}},l.idle=function(t){var e=this.lastT();if(!(t=0;--h)i.push(n(l[h],c[h],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":67,"cubic-hermite":110}],135:[function(t,e,r){"use strict";var n=t("tiny-sdf"),i=t("optical-properties");e.exports=function(t){var e,r,o=(t=t||{}).canvas||document.createElement("canvas"),s=t.family||"sans-serif",l=t.shape||[512,512],c=t.step||[32,32],u=parseFloat(t.size)||16,h=t.chars||[32,126],f=Math.floor((c[0]-u)/2),d=t.radius||1.5*f,p=new n(u,f,d,0,s),m=null==t.align?"optical":t.align,g=null==t.fit||1==t.fit?.5:t.fit;if(Array.isArray(h)){if(2===h.length&&"number"==typeof h[0]&&"number"==typeof h[1]){var v=[];for(e=h[0],r=0;e<=h[1];e++)v[r++]=String.fromCharCode(e);h=v}}else h=String(h).split("");l=l.slice(),o.width=l[0],o.height=l[1];var y=o.getContext("2d");y.fillStyle="#000",y.fillRect(0,0,o.width,o.height),y.textBaseline="middle";var b=c[0],x=c[1],_=0,w=0,M=u/x,k=Math.min(h.length,Math.floor(l[0]/b)*Math.ceil(l[1]/x)),T=p.ctx.textAlign,A=p.buffer,S=p.middle;for(p.ctx.textAlign="center",p.buffer=p.size/2,e=0;el[0]-c[0]&&(_=0,w+=c[1])}return p.ctx.textAlign=T,p.buffer=A,p.middle=S,o};var a={}},{"optical-properties":472,"tiny-sdf":542}],136:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){if(r=l(t,e.left))return r}var r;return(r=t(e.key,e.value))||(e.right?l(t,e.right):void 0)}function c(t,e,r,n){if(e(t,n.key)<=0){if(n.left){if(i=c(t,e,r,n.left))return i}var i;if(i=r(n.key,n.value))return i}if(n.right)return c(t,e,r,n.right)}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(o<=0){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}if(s>0&&i.right)return u(t,e,r,n,i.right)}function h(t,e){this.tree=t,this._stack=e}function f(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}e.exports=function(t){return new s(t||function(t,e){return te?1:0},null)};var d=0,p=1,m=s.prototype;Object.defineProperty(m,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(m,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(m,"length",{get:function(){return this.root?this.root._count:0}}),m.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=u<=0?i.left:i.right}l.push(new n(d,t,e,null,null,1));for(var h=l.length-2;h>=0;--h){i=l[h];c[h]<=0?l[h]=new n(i._color,i.key,i.value,l[h+1],i.right,i._count+1):l[h]=new n(i._color,i.key,i.value,i.left,l[h+1],i._count+1)}for(h=l.length-1;h>1;--h){var f=l[h-1];i=l[h];if(f._color===p||i._color===p)break;var m=l[h-2];if(m.left===f)if(f.left===i){if(!(g=m.right)||g._color!==d){if(m._color=d,m.left=f.right,f._color=p,f.right=m,l[h-2]=f,l[h-1]=i,o(m),o(f),h>=3){(v=l[h-3]).left===m?v.left=f:v.right=f}break}f._color=p,m.right=a(p,g),m._color=d,h-=1}else{if(!(g=m.right)||g._color!==d){if(f.right=i.left,m._color=d,m.left=i.right,i._color=p,i.left=f,i.right=m,l[h-2]=i,l[h-1]=f,o(m),o(f),o(i),h>=3){(v=l[h-3]).left===m?v.left=i:v.right=i}break}f._color=p,m.right=a(p,g),m._color=d,h-=1}else if(f.right===i){if(!(g=m.left)||g._color!==d){if(m._color=d,m.right=f.left,f._color=p,f.left=m,l[h-2]=f,l[h-1]=i,o(m),o(f),h>=3){(v=l[h-3]).right===m?v.right=f:v.left=f}break}f._color=p,m.left=a(p,g),m._color=d,h-=1}else{var g;if(!(g=m.left)||g._color!==d){if(f.left=i.right,m._color=d,m.right=i.left,i._color=p,i.right=f,i.left=m,l[h-2]=i,l[h-1]=f,o(m),o(f),o(i),h>=3){var v;(v=l[h-3]).right===m?v.right=i:v.left=i}break}f._color=p,m.left=a(p,g),m._color=d,h-=1}}return l[0]._color=p,new s(r,l[0])},m.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(m,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new h(this,t)}}),Object.defineProperty(m,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new h(this,t)}}),m.at=function(t){if(t<0)return new h(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new h(this,[])},m.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new h(this,n)},m.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new h(this,n)},m.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new h(this,n)},m.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new h(this,n)},m.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new h(this,n);r=i<=0?r.left:r.right}return new h(this,[])},m.remove=function(t){var e=this.find(t);return e?e.remove():this},m.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var g=h.prototype;Object.defineProperty(g,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(g,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),g.clone=function(){return new h(this.tree,this._stack.slice())},g.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var l=t.length-2;l>=0;--l){(r=t[l]).left===t[l+1]?e[l]=new n(r._color,r.key,r.value,e[l+1],r.right,r._count):e[l]=new n(r._color,r.key,r.value,r.left,e[l+1],r._count)}if((r=e[e.length-1]).left&&r.right){var c=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var u=e[c-1];e.push(new n(r._color,u.key,u.value,r.left,r.right,r._count)),e[c-1].key=r.key,e[c-1].value=r.value;for(l=e.length-2;l>=c;--l)r=e[l],e[l]=new n(r._color,r.key,r.value,r.left,e[l+1],r._count);e[c-1].left=e[c]}if((r=e[e.length-1])._color===d){var h=e[e.length-2];h.left===r?h.left=null:h.right===r&&(h.right=null),e.pop();for(l=0;l=0;--l){if(e=t[l],0===l)return void(e._color=p);if((r=t[l-1]).left===e){if((n=r.right).right&&n.right._color===d)return n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=p,r._color=p,s._color=p,o(r),o(n),l>1&&((c=t[l-2]).left===r?c.left=n:c.right=n),void(t[l-1]=n);if(n.left&&n.left._color===d)return n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=p,n._color=p,e._color=p,o(r),o(n),o(s),l>1&&((c=t[l-2]).left===r?c.left=s:c.right=s),void(t[l-1]=s);if(n._color===p){if(r._color===d)return r._color=p,void(r.right=a(d,n));r.right=a(d,n);continue}n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=d,o(r),o(n),l>1&&((c=t[l-2]).left===r?c.left=n:c.right=n),t[l-1]=n,t[l]=r,l+11&&((c=t[l-2]).right===r?c.right=n:c.left=n),void(t[l-1]=n);if(n.right&&n.right._color===d)return n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=p,n._color=p,e._color=p,o(r),o(n),o(s),l>1&&((c=t[l-2]).right===r?c.right=s:c.left=s),void(t[l-1]=s);if(n._color===p){if(r._color===d)return r._color=p,void(r.left=a(d,n));r.left=a(d,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=d,o(r),o(n),l>1){var c;(c=t[l-2]).right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(g,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(g,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),g.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(g,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),g.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)(i=e[a]).left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},g.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(g,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],137:[function(t,e,r){function n(t){if(t<0)return Number("0/0");for(var e=o[0],r=o.length-1;r>0;--r)e+=o[r]/(t+r);var n=t+a+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],a=607/128,o=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(n(e));e-=1;for(var r=i[0],a=1;a<9;a++)r+=i[a]/(e+a);var o=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,e+.5)*Math.exp(-o)*r},e.exports.log=n},{}],138:[function(t,e,r){function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(i(t[0]));for(var r=1;r2){for(var r,n,i=0;i=0}(t)===e?t:t.reverse()}var s=t("geojson-area");e.exports=n},{"geojson-area":138}],140:[function(t,e,r){"use strict";function n(t,e,r,n,i){return e.length&&(e.area=r,e.dist=n,void 0!==i&&(e.outer=i),t.push(e)),[]}e.exports=function(t,e,r,a,o,s,l,c){if(r/=e,a/=e,l>=r&&c<=a)return t;if(l>a||c=r&&d<=a)u.push(p);else if(!(f>a||d=e&&s<=r&&i.push(o)}return i}(m,r,a,o):function(t,e,r,i,a,o){for(var s=[],l=0;lr?(x.push(a(c,p,e),a(c,p,r)),o||(x=n(s,x,g,v,y))):d>=e&&x.push(a(c,p,e)):f>r?dr&&(x.push(a(c,p,r)),o||(x=n(s,x,g,v,y))));c=m[b-1],(f=c[i])>=e&&f<=r&&x.push(c),h=x[x.length-1],o&&h&&(x[0][0]!==h[0]||x[0][1]!==h[1])&&x.push(x[0]),n(s,x,g,v,y)}return s}(m,r,a,o,s,3===g);v.length&&u.push(i(p.tags,g,v,p.id))}}return u.length?u:null};var i=t("./feature")},{"./feature":142}],141:[function(t,e,r){"use strict";function n(t,e,r){if(null!==e.geometry){var o,l,c,u,h=e.geometry,f=h.type,d=h.coordinates,p=e.properties,m=e.id;if("Point"===f)t.push(s(p,1,[a(d)],m));else if("MultiPoint"===f)t.push(s(p,1,i(d),m));else if("LineString"===f)t.push(s(p,2,[i(d,r)],m));else if("MultiLineString"===f||"Polygon"===f){for(c=[],o=0;o1?1:n,[r,n,0]}e.exports=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var i=0;i1)return!1;var a=i.geometry[0].length;if(5!==a)return!1;for(var o=0;o1&&console.time("creation"),b=this.tiles[y]=f(t,v,r,n,x,e===p.maxZoom),this.tileCoords.push({z:e,x:r,y:n}),m)){m>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,b.numFeatures,b.numPoints,b.numSimplified),console.timeEnd("creation"));var _="z"+e;this.stats[_]=(this.stats[_]||0)+1,this.total++}if(b.source=t,l){if(e===p.maxZoom||e===l)continue;var w=1<1&&console.time("clipping");var M,k,T,A,S,E,L=.5*p.buffer/p.extent,C=.5-L,I=.5+L,P=1+L;M=k=T=A=null,S=u(t,v,r-L,r+I,0,a,b.min[0],b.max[0]),E=u(t,v,r+C,r+P,0,a,b.min[0],b.max[0]),S&&(M=u(S,v,n-L,n+I,1,o,b.min[1],b.max[1]),k=u(S,v,n+C,n+P,1,o,b.min[1],b.max[1])),E&&(T=u(E,v,n-L,n+I,1,o,b.min[1],b.max[1]),A=u(E,v,n+C,n+P,1,o,b.min[1],b.max[1])),m>1&&console.timeEnd("clipping"),t.length&&(d.push(M||[],e+1,2*r,2*n),d.push(k||[],e+1,2*r,2*n+1),d.push(T||[],e+1,2*r+1,2*n),d.push(A||[],e+1,2*r+1,2*n+1))}else l&&(g=e)}return g},n.prototype.getTile=function(t,e,r){var n=this.options,a=n.extent,o=n.debug,l=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var h,f=t,d=e,p=r;!h&&f>0;)f--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[i(f,d,p)];if(!h||!h.source)return null;if(o>1&&console.log("found parent tile z%d-%d-%d",f,d,p),s(h,a,n.buffer))return c.tile(h,a);o>1&&console.time("drilling down");var m=this.splitTile(h.source,f,d,p,t,e,r);if(o>1&&console.timeEnd("drilling down"),null!==m){var g=1<1?(n=a,i=o):h>0&&(n+=c*h,i+=u*h)}return c=s-n,u=l-i,c*c+u*u}(t[r],t[s],t[l]))>n&&(a=r,n=i);n>o?(t[a][2]=n,c.push(s),c.push(a),s=a):(l=c.pop(),s=c.pop())}}},{}],145:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a){for(var o={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:n,z2:e,transformed:!1,min:[2,1],max:[-1,0]},s=0;sh)&&(f.push(s),t.numSimplified++),t.numPoints++;3===c&&function(t,e){(function(t){for(var e,r,n=0,i=0,a=t.length,o=a-1;io.max[0]&&(o.max[0]=c[0]),c[1]>o.max[1]&&(o.max[1]=c[1])}return o}},{}],146:[function(t,e,r){"use strict";function n(t,e,r,n,i){return[Math.round(e*(t[0]*r-n)),Math.round(e*(t[1]*r-i))]}r.tile=function(t,e){if(t.transformed)return t;var r,i,a,o=t.z2,s=t.x,l=t.y;for(r=0;r0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}e.exports=function(t,e){var r=new i(t);return r.update(e),r};var s=t("./lib/text.js"),l=t("./lib/lines.js"),c=t("./lib/background.js"),u=t("./lib/cube.js"),h=t("./lib/ticks.js"),f=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=i.prototype;d.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;s<3;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),c=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;d<2;++d)for(var p=0;p<3;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,c=!0,this.autoTicks=!1;for(d=0;d<3;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,c=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),c=!0),c){for(d=0;d<3;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?c=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(c=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var m=a("labels");a("labelFont")&&(m=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(m||c)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=s(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&c&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=l(this.gl,this.bounds,this.ticks))};var p=[new a,new a,new a],m=[0,0,0],g={model:f,view:f,projection:f};d.isOpaque=function(){return!0},d.isTransparent=function(){return!1},d.drawTransparent=function(t){};var v=[0,0,0],y=[0,0,0],b=[0,0,0];d.draw=function(t){t=t||g;for(var e=this.gl,r=t.model||f,i=t.view||f,a=t.projection||f,s=this.bounds,l=u(r,i,a,s),c=l.cubeEdges,h=l.axis,d=i[12],x=i[13],_=i[14],w=i[15],M=this.pixelRatio*(a[3]*d+a[7]*x+a[11]*_+a[15]*w)/e.drawingBufferHeight,k=0;k<3;++k)this.lastCubeProps.cubeEdges[k]=c[k],this.lastCubeProps.axis[k]=h[k];var T=p;for(k=0;k<3;++k)o(p[k],k,this.bounds,c,h);e=this.gl;var A=m;for(k=0;k<3;++k)this.backgroundEnable[k]?A[k]=h[k]:A[k]=0;this._background.draw(r,i,a,s,A,this.backgroundColor),this._lines.bind(r,i,a,this);for(k=0;k<3;++k){var S=[0,0,0];h[k]>0?S[k]=s[1][k]:S[k]=s[0][k];for(var E=0;E<2;++E){var L=(k+1+E)%3,C=(k+1+(1^E))%3;this.gridEnable[L]&&this._lines.drawGrid(L,C,this.bounds,S,this.gridColor[L],this.gridWidth[L]*this.pixelRatio)}for(E=0;E<2;++E){L=(k+1+E)%3,C=(k+1+(1^E))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(L,C,this.bounds,S,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(k=0;k<3;++k){this.lineEnable[k]&&this._lines.drawAxisLine(k,this.bounds,T[k].primalOffset,this.lineColor[k],this.lineWidth[k]*this.pixelRatio),this.lineMirror[k]&&this._lines.drawAxisLine(k,this.bounds,T[k].mirrorOffset,this.lineColor[k],this.lineWidth[k]*this.pixelRatio);var I=n(v,T[k].primalMinor),P=n(y,T[k].mirrorMinor),D=this.lineTickLength;for(E=0;E<3;++E){var z=M/r[5*E];I[E]*=D[E]*z,P[E]*=D[E]*z}this.lineTickEnable[k]&&this._lines.drawAxisTicks(k,T[k].primalOffset,I,this.lineTickColor[k],this.lineTickWidth[k]*this.pixelRatio),this.lineTickMirror[k]&&this._lines.drawAxisTicks(k,T[k].mirrorOffset,P,this.lineTickColor[k],this.lineTickWidth[k]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(k=0;k<3;++k){var O=T[k].primalMinor,F=n(b,T[k].primalOffset);for(E=0;E<3;++E)this.lineTickEnable[k]&&(F[E]+=M*O[E]*Math.max(this.lineTickLength[E],0)/r[5*E]);if(this.tickEnable[k]){for(E=0;E<3;++E)F[E]+=M*O[E]*this.tickPad[E]/r[5*E];this._text.drawTicks(k,this.tickSize[k],this.tickAngle[k],F,this.tickColor[k])}if(this.labelEnable[k]){for(E=0;E<3;++E)F[E]+=M*O[E]*this.labelPad[E]/r[5*E];F[k]+=.5*(s[0][k]+s[1][k]),this._text.drawLabel(k,this.labelSize[k],this.labelAngle[k],F,this.labelColor[k])}}},d.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":150,"./lib/cube.js":151,"./lib/lines.js":152,"./lib/text.js":154,"./lib/ticks.js":155}],150:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var c=(l+1)%3,u=(l+2)%3,h=[0,0,0],f=[0,0,0],d=-1;d<=1;d+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),h[l]=d,f[l]=d;for(var p=-1;p<=1;p+=2){h[c]=p;for(var m=-1;m<=1;m+=2)h[u]=m,e.push(h[0],h[1],h[2],f[0],f[1],f[2]),s+=1}var g=c;c=u,u=g}var v=i(t,new Float32Array(e)),y=i(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=a(t,[{buffer:v,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:v,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=o(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,v,b,x)};var i=t("gl-buffer"),a=t("gl-vao"),o=t("./shaders").bg,s=n.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":153,"gl-buffer":157,"gl-vao":272}],151:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;n<4;++n){t[n]=r[12+n];for(var i=0;i<3;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eS&&(_|=1<S&&(_|=1<h[y][1]&&(O=y));var F=-1;for(y=0;y<3;++y)(j=O^1<h[R][0]&&(R=j))}var N=m;N[0]=N[1]=N[2]=0,N[a.log2(F^O)]=O&F,N[a.log2(O^R)]=O&R;var B=7^R;B===_||B===z?(B=7^F,N[a.log2(R^B)]=B&R):N[a.log2(F^B)]=B&F;var U=g,V=_;for(k=0;k<3;++k)U[k]=V&1< 0.0) {\n vec3 nPosition = mix(bounds[0], bounds[1], 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n colorChannel = abs(normal);\n}","precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] + \n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}",null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":256}],154:[function(t,e,r){(function(r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}e.exports=function(t,e,r,o,l,c){var u=i(t),h=a(t,[{buffer:u,size:3}]),f=s(t);f.attributes.position.location=0;var d=new n(t,f,u,h);return d.update(e,r,o,l,c),d};var i=t("gl-buffer"),a=t("gl-vao"),o=t("vectorize-text"),s=t("./shaders").text,l=window||r.global||{},c=l.__TEXT_CACHE||{};l.__TEXT_CACHE={};var u=n.prototype,h=[0,0];u.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,h[0]=this.gl.drawingBufferWidth,h[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=h},u.update=function(t,e,r,n,i){function a(t,e,r,n){var i=c[r];i||(i=c[r]={});var a=i[e];a||(a=i[e]=function(t,e){try{return o(t,e)}catch(t){return console.warn("error vectorizing text:",t),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle"}));for(var l=(n||12)/12,u=a.positions,h=a.cells,f=0,d=h.length;f=0;--m){var g=u[p[m]];s.push(l*g[0],-l*g[1],t)}}this.gl;for(var s=[],l=[0,0,0],u=[0,0,0],h=[0,0,0],f=[0,0,0],d=0;d<3;++d){h[d]=s.length/3|0,a(.5*(t[0][d]+t[1][d]),e[d],r),f[d]=(s.length/3|0)-h[d],l[d]=s.length/3|0;for(var p=0;p=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;o<0?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c|=0);var u=""+l;if(o<0&&(u="-"+u),i){for(var h=""+c;h.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=o.malloc(t.length,e),n=t.length,i=0;i=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var n=o.malloc(t.size,r),u=l(n,t.shape);s.assign(u,t),this.length=i(this.gl,this.type,this.length,this.usage,e<0?n:n.subarray(0,t.size),e),o.free(n)}}else if(Array.isArray(t)){var h;h=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),this.length=i(this.gl,this.type,this.length,this.usage,e<0?h:h.subarray(0,t.length),e),o.free(h)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=new n(t,r,t.createBuffer(),0,i);return a.update(e),a}},{ndarray:468,"ndarray-ops":462,"typedarray-pool":550}],158:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34e3:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],159:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":158}],160:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.shader=e,this.bufferHi=r,this.bufferLo=n,this.bounds=[1/0,1/0,-1/0,-1/0],this.numPoints=0,this.color=[0,0,0,1]}var i=t("gl-shader"),a=t("gl-buffer"),o=t("typedarray-pool"),s=t("./lib/shaders");e.exports=function(t,e){var r=new n(t,i(t.gl,s.vertex,s.fragment),a(t.gl),a(t.gl));return r.update(e),t.addObject(r),r};var l=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],c=n.prototype;c.draw=function(){var t=new Float32Array([0,0]),e=new Float32Array([0,0]),r=new Float32Array([0,0]),n=new Float32Array([0,0]),i=[1,1];return function(){var a=this.plot,o=this.shader,s=this.bounds,c=this.numPoints;if(c){var u=a.gl,h=a.dataBox,f=a.viewBox,d=a.pixelRatio,p=s[2]-s[0],m=s[3]-s[1],g=h[2]-h[0],v=h[3]-h[1],y=2*p/g,b=2*m/v,x=(s[0]-h[0]-.5*g)/p,_=(s[1]-h[1]-.5*v)/m;t[0]=y,t[1]=b,e[0]=y-t[0],e[1]=b-t[1],r[0]=x,r[1]=_,n[0]=x-r[0],n[1]=_-r[1];var w=f[2]-f[0],M=f[3]-f[1];i[0]=2*d/w,i[1]=2*d/M,o.bind(),o.uniforms.scaleHi=t,o.uniforms.scaleLo=e,o.uniforms.translateHi=r,o.uniforms.translateLo=n,o.uniforms.pixelScale=i,o.uniforms.color=this.color,this.bufferLo.bind(),o.attributes.positionLo.pointer(u.FLOAT,!1,16,0),this.bufferHi.bind(),o.attributes.positionHi.pointer(u.FLOAT,!1,16,0),o.attributes.pixelOffset.pointer(u.FLOAT,!1,16,8),u.drawArrays(u.TRIANGLES,0,c*l.length)}}}(),c.drawPick=function(t){return t},c.pick=function(){return null},c.update=function(t){var e,r,n,i=(t=t||{}).positions||[],a=t.errors||[],s=1;"lineWidth"in t&&(s=+t.lineWidth);var c=5;"capSize"in t&&(c=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-1/0,-1/0],h=this.numPoints=i.length>>1;for(e=0;e0&&(A*=_),S<0?S*=w:S>0&&(S*=M),g[b++]=f*(r-p+A),g[b++]=d*(n-m+S),g[b++]=s*T[2]+(c+s)*T[4],g[b++]=s*T[3]+(c+s)*T[5]}}for(e=0;e=1},u.isTransparent=function(){return this.opacity<1},u.drawTransparent=u.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||c,i=r.projection=t.projection||c;r.model=t.model||c,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],u=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var h=0;h<3;++h)e.lineWidth(this.lineWidth[h]),r.capSize=this.capSize[h]*u,this.lineCount[h]&&e.drawArrays(e.LINES,this.lineOffset[h],this.lineCount[h]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();u.update=function(t){"lineWidth"in(t=t||{})&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.lineCount=[0,0,0];for(var c=0;c<3;++c){this.lineOffset[c]=l;t:for(var u=0;u0){var m;(m=h.slice())[c]+=d[1][c],o.push(h[0],h[1],h[2],p[0],p[1],p[2],p[3],0,0,0,m[0],m[1],m[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,m),l+=2+a(o,m,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},u.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":164,"gl-buffer":157,"gl-vao":272}],163:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n1&&f.drawBuffersWEBGL(m[h]);var y=r.getExtension("WEBGL_depth_texture");y?d?t.depth=o(r,c,u,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=o(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=s(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=s(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=s(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),v=0;vs||r<0||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(o),c=0;ca||r<0||r>a)throw new Error("gl-fbo: Parameters are too large for FBO");var o=1;if("color"in(n=n||{})){if((o=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(o>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(o>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+o+" draw buffers")}}var s=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&o>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");s=t.FLOAT}else n.preferFloat&&o>0&&c&&(s=t.FLOAT);var u=!0;"depth"in n&&(u=!!n.depth);var g=!1;return"stencil"in n&&(g=!!n.stencil),new l(t,e,r,s,o,u,g,i)};var h,f,d,p,m=null,g=l.prototype;Object.defineProperties(g,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return c(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t|=0,c(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t|=0,c(this,this._shape[0],t),t},enumerable:!1}}),g.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},g.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e>8*d&255;this.pickOffset=r,i.bind();var p=i.uniforms;p.viewTransform=t,p.pickOffset=e,p.shape=this.shape;var m=i.attributes;return this.positionBuffer.bind(),m.position.pointer(),this.weightBuffer.bind(),m.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),m.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),u.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(r=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},u.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||a(e[0]),n=t.y||a(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=n;var l=t.colorLevels||[0],c=t.colorValues||[0,0,0,1],u=l.length,f=this.bounds,d=f[0]=r[0],p=f[1]=n[0],m=1/((f[2]=r[r.length-1])-d),g=1/((f[3]=n[n.length-1])-p),v=e[0],y=e[1];this.shape=[v,y];var b=(v-1)*(y-1)*(h.length>>>1);this.numVertices=b;for(var x=o.mallocUint8(4*b),_=o.mallocFloat32(2*b),w=o.mallocUint8(2*b),M=o.mallocUint32(b),k=0,T=0;T2&&!this.usingDashes){var b=this.mitreShader;this.lineBufferLo.bind(),b.attributes.aLo.pointer(l.FLOAT,!1,48,0),this.lineBufferHi.bind(),b.bind();var x=b.uniforms;this.setProjectionUniforms(x,a),x.color=u,x.radius=s*c,b.attributes.aHi.pointer(l.FLOAT,!1,48,0),l.drawArrays(l.POINTS,0,i/3|0)}}}}(),u.drawPick=function(){var t=[0,0,0,0];return function(e){var r=this.vertCount,n=this.numPoints;if(this.pickOffset=e,!r)return e+n;var i=this.setProjectionModel(),a=this.plot,o=this.width,s=a.gl,l=a.pickPixelRatio,c=this.pickShader,u=this.pickBuffer;t[0]=255&e,t[1]=e>>>8&255,t[2]=e>>>16&255,t[3]=e>>>24,c.bind();var h=c.uniforms;this.setProjectionUniforms(h,i),h.width=o*l,h.pickOffset=t;var f=c.attributes;return this.lineBufferHi.bind(),f.aHi.pointer(s.FLOAT,!1,16,0),f.dHi.pointer(s.FLOAT,!1,16,8),this.lineBufferLo.bind(),f.aLo.pointer(s.FLOAT,!1,16,0),u.bind(),f.pick0.pointer(s.UNSIGNED_BYTE,!1,8,0),f.pick1.pointer(s.UNSIGNED_BYTE,!1,8,4),s.drawArrays(s.TRIANGLES,0,r),e+n}}(),u.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(r=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},u.update=function(t){t=t||{};var e,r,n,i,a,c=this.plot.gl;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=function(t){return t.map(function(t){return t.slice()})}(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);var u=t.dashes||[1],h=0;for(e=0;e1,this.dashPattern=o(c,s(f,[h,1,4],[1,0,0])),this.dashPattern.minFilter=c.NEAREST,this.dashPattern.magFilter=c.NEAREST,this.dashLength=h,l.free(f);var p=t.positions;this.data=p;var m=this.bounds;m[0]=m[1]=1/0,m[2]=m[3]=-1/0;var g=this.numPoints=p.length>>>1;if(0!==g){for(e=0;e1;){var k=--n;i=p[2*n],a=p[2*n+1];var T=k-1,A=p[2*T],S=p[2*T+1];if(!(isNaN(i)||isNaN(a)||isNaN(A)||isNaN(S))){M+=1,i=(i-m[0])/(m[2]-m[0]),a=(a-m[1])/(m[3]-m[1]);var E=(A=(A-m[0])/(m[2]-m[0]))-i,L=(S=(S-m[1])/(m[3]-m[1]))-a,C=k|1<<24,I=k-1,P=k,D=k-1|1<<24;v[--_]=-L,v[--_]=-E,v[--_]=a,v[--_]=i,x[--w]=C,x[--w]=I,v[--_]=L,v[--_]=E,v[--_]=S,v[--_]=A,x[--w]=P,x[--w]=D,v[--_]=-L,v[--_]=-E,v[--_]=S,v[--_]=A,x[--w]=P,x[--w]=D,v[--_]=L,v[--_]=E,v[--_]=S,v[--_]=A,x[--w]=P,x[--w]=D,v[--_]=-L,v[--_]=-E,v[--_]=a,v[--_]=i,x[--w]=C,x[--w]=I,v[--_]=L,v[--_]=E,v[--_]=a,v[--_]=i,x[--w]=C,x[--w]=I}}for(e=0;e FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",null,a)}},{"gl-shader":256}],173:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=p(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=m(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=s(e),a=l(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),u=f(new Array(1024),[256,1,4]),h=0;h<1024;++h)u.data[h]=255;var d=c(e,u);d.wrap=e.REPEAT;var g=new o(e,r,n,i,a,d);return g.update(t),g};var s=t("gl-buffer"),l=t("gl-vao"),c=t("gl-texture2d"),u=t("glsl-read-float"),h=t("binary-search-bounds"),f=t("ndarray"),d=t("./lib/shaders"),p=d.createShader,m=d.createPickShader,g=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],v=o.prototype;v.isTransparent=function(){return this.opacity<1},v.isOpaque=function(){return this.opacity>=1},v.pickSlots=1,v.setPickBase=function(t){this.pickId=t},v.drawTransparent=v.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||g,view:t.view||g,projection:t.projection||g,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},v.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||g,view:t.view||g,projection:t.projection||g,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},v.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],d=0,p=0,m=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],g=!1;t:for(e=1;e0){for(var b=0;b<24;++b)l.push(l[l.length-12]);p+=2,g=!0}continue t}m[0][r]=Math.min(m[0][r],v[r],y[r]),m[1][r]=Math.max(m[1][r],v[r],y[r])}var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var M=d;if(d+=n(v,y),g){for(r=0;r<2;++r)l.push(v[0],v[1],v[2],y[0],y[1],y[2],M,w,x[0],x[1],x[2],x[3]);p+=2,g=!1}l.push(v[0],v[1],v[2],y[0],y[1],y[2],M,w,x[0],x[1],x[2],x[3],v[0],v[1],v[2],y[0],y[1],y[2],M,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],v[0],v[1],v[2],d,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],v[0],v[1],v[2],d,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(d),u.push(a[a.length-1].slice()),this.bounds=m,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var k=t.dashes.slice();for(k.unshift(0),e=1;e0?(n=2*Math.sqrt(r+1),t[3]=.25*n,t[0]=(e[6]-e[9])/n,t[1]=(e[8]-e[2])/n,t[2]=(e[1]-e[4])/n):e[0]>e[5]&e[0]>e[10]?(n=2*Math.sqrt(1+e[0]-e[5]-e[10]),t[3]=(e[6]-e[9])/n,t[0]=.25*n,t[1]=(e[1]+e[4])/n,t[2]=(e[8]+e[2])/n):e[5]>e[10]?(n=2*Math.sqrt(1+e[5]-e[0]-e[10]),t[3]=(e[8]-e[2])/n,t[0]=(e[1]+e[4])/n,t[1]=.25*n,t[2]=(e[6]+e[9])/n):(n=2*Math.sqrt(1+e[10]-e[0]-e[5]),t[3]=(e[1]-e[4])/n,t[0]=(e[8]+e[2])/n,t[1]=(e[6]+e[9])/n,t[2]=.25*n),t},i.fromRotationTranslationScale=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3],l=i+i,c=a+a,u=o+o,h=i*l,f=i*c,d=i*u,p=a*c,m=a*u,g=o*u,v=s*l,y=s*c,b=s*u,x=n[0],_=n[1],w=n[2];return t[0]=(1-(p+g))*x,t[1]=(f+b)*x,t[2]=(d-y)*x,t[3]=0,t[4]=(f-b)*_,t[5]=(1-(h+g))*_,t[6]=(m+v)*_,t[7]=0,t[8]=(d+y)*w,t[9]=(m-v)*w,t[10]=(1-(h+p))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},i.fromRotationTranslationScaleOrigin=function(t,e,r,n,i){var a=e[0],o=e[1],s=e[2],l=e[3],c=a+a,u=o+o,h=s+s,f=a*c,d=a*u,p=a*h,m=o*u,g=o*h,v=s*h,y=l*c,b=l*u,x=l*h,_=n[0],w=n[1],M=n[2],k=i[0],T=i[1],A=i[2];return t[0]=(1-(m+v))*_,t[1]=(d+x)*_,t[2]=(p-b)*_,t[3]=0,t[4]=(d-x)*w,t[5]=(1-(f+v))*w,t[6]=(g+y)*w,t[7]=0,t[8]=(p+b)*M,t[9]=(g-y)*M,t[10]=(1-(f+m))*M,t[11]=0,t[12]=r[0]+k-(t[0]*k+t[4]*T+t[8]*A),t[13]=r[1]+T-(t[1]*k+t[5]*T+t[9]*A),t[14]=r[2]+A-(t[2]*k+t[6]*T+t[10]*A),t[15]=1,t},i.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,h=n*s,f=i*o,d=i*s,p=i*l,m=a*o,g=a*s,v=a*l;return t[0]=1-h-p,t[1]=u+v,t[2]=f-g,t[3]=0,t[4]=u-v,t[5]=1-c-p,t[6]=d+m,t[7]=0,t[8]=f+g,t[9]=d-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},i.frustum=function(t,e,r,n,i,a,o){var s=1/(r-e),l=1/(i-n),c=1/(a-o);return t[0]=2*a*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*l,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*l,t[10]=(o+a)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*a*2*c,t[15]=0,t},i.perspective=function(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t},i.perspectiveFromFieldOfView=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),l=2/(o+s),c=2/(i+a);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(o-s)*l*.5,t[9]=(i-a)*c*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},i.ortho=function(t,e,r,n,i,a,o){var s=1/(e-r),l=1/(n-i),c=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*l,t[14]=(o+a)*c,t[15]=1,t},i.lookAt=function(t,e,r,a){var o,s,l,c,u,h,f,d,p,m,g=e[0],v=e[1],y=e[2],b=a[0],x=a[1],_=a[2],w=r[0],M=r[1],k=r[2];return Math.abs(g-w).999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(t,i,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+l,s.normalize(n,n))}}(),s.setAxes=function(){var t=i.create();return function(e,r,n,i){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],s.normalize(e,s.fromMat3(e,t))}}(),s.clone=o.clone,s.fromValues=o.fromValues,s.copy=o.copy,s.set=o.set,s.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},s.setAxisAngle=function(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},s.getAxisAngle=function(t,e){var r=2*Math.acos(e[3]),n=Math.sin(r/2);return 0!=n?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r},s.add=o.add,s.multiply=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=r[0],l=r[1],c=r[2],u=r[3];return t[0]=n*u+o*s+i*c-a*l,t[1]=i*u+o*l+a*s-n*c,t[2]=a*u+o*c+n*l-i*s,t[3]=o*u-n*s-i*l-a*c,t},s.mul=s.multiply,s.scale=o.scale,s.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+o*s,t[1]=i*l+a*s,t[2]=a*l-i*s,t[3]=o*l-n*s,t},s.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l-a*s,t[1]=i*l+o*s,t[2]=a*l+n*s,t[3]=o*l-i*s,t},s.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*s,t[1]=i*l-n*s,t[2]=a*l+o*s,t[3]=o*l-a*s,t},s.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},s.dot=o.dot,s.lerp=o.lerp,s.slerp=function(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],h=e[2],f=e[3],d=r[0],p=r[1],m=r[2],g=r[3];return(a=c*d+u*p+h*m+f*g)<0&&(a=-a,d=-d,p=-p,m=-m,g=-g),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*h+l*m,t[3]=s*f+l*g,t},s.sqlerp=function(){var t=s.create(),e=s.create();return function(r,n,i,a,o,l){return s.slerp(t,n,o,l),s.slerp(e,i,a,l),s.slerp(r,t,e,2*l*(1-l)),r}}(),s.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-n*s,t[2]=-i*s,t[3]=a*s,t},s.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},s.length=o.length,s.len=s.length,s.squaredLength=o.squaredLength,s.sqrLen=s.squaredLength,s.normalize=o.normalize,s.fromMat3=function(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*o+o]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*a+o]-e[3*o+a])*r,t[a]=(e[3*a+i]+e[3*i+a])*r,t[o]=(e[3*o+i]+e[3*i+o])*r}return t},s.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},s.exactEquals=o.exactEquals,s.equals=o.equals,e.exports=s},{"./common.js":195,"./mat3.js":198,"./vec3.js":202,"./vec4.js":203}],201:[function(t,e,r){var n=t("./common.js"),i={};i.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},i.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},i.fromValues=function(t,e){var r=new n.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r},i.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},i.set=function(t,e,r){return t[0]=e,t[1]=r,t},i.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},i.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},i.sub=i.subtract,i.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},i.mul=i.multiply,i.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},i.div=i.divide,i.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},i.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},i.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},i.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},i.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},i.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},i.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},i.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)},i.dist=i.distance,i.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n},i.sqrDist=i.squaredDistance,i.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},i.len=i.length,i.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},i.sqrLen=i.squaredLength,i.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},i.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},i.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t},i.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},i.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},i.lerp=function(t,e,r,n){var i=e[0],a=e[1];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t},i.random=function(t,e){e=e||1;var r=2*n.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},i.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},i.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},i.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},i.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},i.forEach=function(){var t=i.create();return function(e,r,n,i,a,o){var s,l;for(r||(r=2),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,s=n;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},i.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.cross=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t},i.lerp=function(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t},i.hermite=function(t,e,r,n,i,a){var o=a*a,s=o*(2*a-3)+1,l=o*(a-2)+a,c=o*(a-1),u=o*(3-2*a);return t[0]=e[0]*s+r[0]*l+n[0]*c+i[0]*u,t[1]=e[1]*s+r[1]*l+n[1]*c+i[1]*u,t[2]=e[2]*s+r[2]*l+n[2]*c+i[2]*u,t},i.bezier=function(t,e,r,n,i,a){var o=1-a,s=o*o,l=a*a,c=s*o,u=3*a*s,h=3*l*o,f=l*a;return t[0]=e[0]*c+r[0]*u+n[0]*h+i[0]*f,t[1]=e[1]*c+r[1]*u+n[1]*h+i[1]*f,t[2]=e[2]*c+r[2]*u+n[2]*h+i[2]*f,t},i.random=function(t,e){e=e||1;var r=2*n.RANDOM()*Math.PI,i=2*n.RANDOM()-1,a=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*a,t[1]=Math.sin(r)*a,t[2]=i*e,t},i.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t},i.transformMat3=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t},i.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,h=c*i+l*n-o*a,f=c*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=u*c+d*-o+h*-l-f*-s,t[1]=h*c+d*-s+f*-o-u*-l,t[2]=f*c+d*-l+u*-s-h*-o,t},i.rotateX=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},i.rotateY=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},i.rotateZ=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},i.forEach=function(){var t=i.create();return function(e,r,n,i,a,o){var s,l;for(r||(r=3),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,s=n;s1?0:Math.acos(a)},i.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},i.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},i.equals=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))},e.exports=i},{"./common.js":195}],203:[function(t,e,r){var n=t("./common.js"),i={};i.create=function(){var t=new n.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},i.clone=function(t){var e=new n.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},i.fromValues=function(t,e,r,i){var a=new n.ARRAY_TYPE(4);return a[0]=t,a[1]=e,a[2]=r,a[3]=i,a},i.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},i.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},i.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},i.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t},i.sub=i.subtract,i.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},i.mul=i.multiply,i.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},i.div=i.divide,i.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},i.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},i.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},i.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},i.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},i.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},i.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},i.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)},i.dist=i.distance,i.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a},i.sqrDist=i.squaredDistance,i.length=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)},i.len=i.length,i.squaredLength=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i},i.sqrLen=i.squaredLength,i.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},i.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},i.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o),t},i.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},i.lerp=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t},i.random=function(t,e){return e=e||1,t[0]=n.RANDOM(),t[1]=n.RANDOM(),t[2]=n.RANDOM(),t[3]=n.RANDOM(),i.normalize(t,t),i.scale(t,t,e),t},i.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t},i.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,h=c*i+l*n-o*a,f=c*a+o*i-s*n,d=-o*n-s*i-l*a;return t[0]=u*c+d*-o+h*-l-f*-s,t[1]=h*c+d*-s+f*-o-u*-l,t[2]=f*c+d*-l+u*-s-h*-o,t[3]=e[3],t},i.forEach=function(){var t=i.create();return function(e,r,n,i,a,o){var s,l;for(r||(r=4),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,s=n;s1.0001)return null;g+=m[u]}return Math.abs(g-1)>.001?null:[h,function(t,e){for(var r=[0,0,0],n=0;n 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}",fragment:n,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}",fragment:n,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n",attributes:[{name:"position",type:"vec3"}]}},{}],206:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,h,f,d,p,m,g,v,y,b,x,_,w,k,T,A,S){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=f,this.triangleUVs=h,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=g,this.edgeUVs=v,this.edgeIds=m,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=T,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=A,this.contourVAO=S,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=M,this._view=M,this._projection=M,this._resolution=[1,1]}var i=t("gl-shader"),a=t("gl-buffer"),o=t("gl-vao"),s=t("gl-texture2d"),l=t("normals"),c=t("gl-mat4/multiply"),u=t("gl-mat4/invert"),h=t("ndarray"),f=t("colormap"),d=t("simplicial-complex-contour"),p=t("typedarray-pool"),m=t("./lib/shaders"),g=t("./lib/closest-point"),v=m.meshShader,y=m.wireShader,b=m.pointShader,x=m.pickShader,_=m.pointPickShader,w=m.contourShader,M=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],k=n.prototype;k.isOpaque=function(){return this.opacity>=1},k.isTransparent=function(){return this.opacity<1},k.pickSlots=1,k.setPickBase=function(t){this.pickId=t},k.highlight=function(t){if(t&&this.contourEnable){for(var e=d(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0){(p=this.triShader).bind(),p.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){(p=this.lineShader).bind(),p.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){(p=this.pointShader).bind(),p.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var p;(p=this.contourShader).bind(),p.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},k.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||M,n=t.view||M,i=t.projection||M,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};if((l=this.pickShader).bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l;(l=this.pointPickShader).bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},k.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;al[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=g[n],a.uniforms.angle=v[n],c.drawArrays(c.TRIANGLES,l[k],l[T]-l[k]))),y[n]&&M&&(e[1^n]-=A*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,M)),e[1^n]=A*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=A*d*m[n+2],kl[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=g[n+2],a.uniforms.angle=v[n+2],c.drawArrays(c.TRIANGLES,l[k],l[T]-l[k]))),y[n+2]&&M&&(e[1^n]+=A*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,M))}}(),c.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,c=r.pixelRatio;if(this.titleCount){for(var u=0;u<2;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),c.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;c<2;++c){var u=a[c],h=a[c+2]-u,f=.5*(o[c+2]+o[c]),d=o[c+2]-o[c],p=l[c],m=l[c+2]-p,g=s[c],v=s[c+2]-g;e[c]=2*h/d*m/v,t[c]=2*(u-f)/d*m/v}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),c.update=function(t){var e,r,n,i,a,s=[],l=t.ticks,c=t.bounds;for(a=0;a<2;++a){var u=[Math.floor(s.length/3)],h=[-1/0],f=l[a];for(e=0;er)for(t=r;te)for(t=e;t=0){for(var k=0|M.type.charAt(M.type.length-1),T=new Array(k),A=0;A=0;)S+=1;w[b]=S}var E=new Array(r.length);h(),d._relink=h,d.types={uniforms:s(r),attributes:s(n)},d.attributes=o(p,d,x,w),Object.defineProperty(d,"uniforms",a(p,d,r,E))},e.exports=function(t,e,r,i,a){var o=new n(t);return o.update(e,r,i,a),o}},{"./lib/GLError":214,"./lib/create-attributes":215,"./lib/create-uniforms":216,"./lib/reflect":217,"./lib/runtime-reflect":218,"./lib/shader-cache":219}],214:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}(n.prototype=new Error).name="GLError",n.prototype.constructor=n,e.exports=n},{}],215:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;u=0){if((p=f.charCodeAt(f.length-1)-48)<2||p>4)throw new o("","Invalid data type for attribute "+h+": "+f);i(t,e,d[0],n,p,s,h)}else{if(!(f.indexOf("mat")>=0))throw new o("","Unknown data type for attribute "+h+": "+f);var p;if((p=f.charCodeAt(f.length-1)-48)<2||p>4)throw new o("","Invalid data type for attribute "+h+": "+f);a(t,e,d,n,p,s,h)}}}return s};var o=t("./GLError"),s=n.prototype;s.pointer=function(t,e,r,n){var i=this._gl,a=this._locations[this._index];i.vertexAttribPointer(a,this._dimension,t||i.FLOAT,!!e,r||0,n||0),i.enableVertexAttribArray(a)},s.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(s,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":214}],216:[function(t,e,r){"use strict";function n(t){return new Function("y","return function(){return y}")(t)}function i(t,e){for(var r=new Array(t),n=0;n4)throw new o("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new o("","Unknown uniform data type for "+name+": "+r)}var i;if((i=r.charCodeAt(r.length-1)-48)<2||i>4)throw new o("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new o("","Unrecognized data type for vector "+name+": "+r)}}}function c(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;parseInt(n)+""===n?a+="["+n+"]":a+="."+n,"object"==typeof i?r.push.apply(r,c(a,i)):r.push([a,i])}return r}function u(e){for(var n=["return function updateProperty(obj){"],i=c("",e),a=0;a4)throw new o("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r;if((r=t.charCodeAt(t.length-1)-48)<2||r>4)throw new o("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new o("","Unknown uniform data type for "+name+": "+t)}}(r[c].type)}function f(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){s[0]in a||(a[s[0]]=[]),a=a[s[0]];for(var l=1;l1)for(var l=0;l=0){var m=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(m,e[1],m,e[3],d[p],f[p]):o.drawLine(e[0],m,e[2],m,d[p],f[p])}}for(p=0;p=0;--t)this.objects[t].dispose();this.objects.length=0;for(t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;r0){r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function i(t){return"boolean"!=typeof t||t}e.exports=function(t){function e(){if(!b&&U.autoResize){var t=x.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*U.pixelRatio),i=0|Math.ceil(r*U.pixelRatio);if(n!==x.width||i!==x.height){x.width=n,x.height=i;var a=x.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",O=!0}}}function r(){for(var t=I.length,e=z.length,r=0;r0&&0===D[e-1];)D.pop(),z.pop().dispose()}function g(){if(U.contextLost)return!0;_.isContextLost()&&(U.contextLost=!0,U.mouseListener.enabled=!1,U.selection.object=null,U.oncontextloss&&U.oncontextloss())}function v(){if(!g()){e();var t=U.camera.tick();N.view=U.camera.matrix,O=O||t,F=F||t,E.pixelRatio=U.pixelRatio,C.pixelRatio=U.pixelRatio;var r=I.length,i=G[0],a=G[1];i[0]=i[1]=i[2]=1/0,a[0]=a[1]=a[2]=-1/0;for(var o=0;oM.distance)continue;for(var c=0;c>>1,i=t.positions instanceof Float32Array,a=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=i?s:o.mallocFloat32(s.length),c=a?t.idToIndex:o.mallocInt32(n);if(i||l.set(s),!a)for(l.set(s),r=0;r>>1;for(r=0;r=e[0]&&a<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,o),u=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(c,.33333)));t[0]=2/s,t[4]=2/l,t[6]=-2*o[0]/s-1,t[7]=-2*o[1]/l-1,this.offsetBuffer.bind(),i.bind(),i.attributes.position.pointer(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointCloud=u<5,i.uniforms.pointSize=u,i.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),n&&(e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,this.pickBuffer.bind(),i.attributes.pickId.pointer(a.UNSIGNED_BYTE),i.uniforms.pickOffset=e,this.pickOffset=r);var h=a.getParameter(a.BLEND),f=a.getParameter(a.DITHER);return h&&!this.blend&&a.disable(a.BLEND),f&&a.disable(a.DITHER),a.drawArrays(a.POINTS,0,this.pointCount),h&&!this.blend&&a.enable(a.BLEND),f&&a.enable(a.DITHER),r+this.pointCount}}(),l.draw=l.unifiedDraw,l.drawPick=l.unifiedDraw,l.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":223,"gl-buffer":157,"gl-shader":224,"typedarray-pool":550}],232:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],h=e[2],f=e[3],d=r[0],p=r[1],m=r[2],g=r[3];return(a=c*d+u*p+h*m+f*g)<0&&(a=-a,d=-d,p=-p,m=-m,g=-g),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*h+l*m,t[3]=s*f+l*g,t}},{}],233:[function(t,e,r){"use strict";e.exports={vertex:"precision highp float;\n#define GLSLIFY 1\n\n\nvec4 computePosition_1_0(vec2 posHi, vec2 posLo, vec2 scHi, vec2 scLo, vec2 trHi, vec2 trLo) {\n return vec4((posHi + trHi) * scHi\n \t\t\t//FIXME: this thingy does not give noticeable precision gain, need test\n + (posLo + trLo) * scHi\n + (posHi + trHi) * scLo\n + (posLo + trLo) * scLo\n , 0, 1);\n}\n\n\nattribute vec2 positionHi, positionLo;\nattribute float size, border;\nattribute vec2 char, color;\n\n//this is 64-bit form of scale and translate\nuniform vec2 scaleHi, scaleLo, translateHi, translateLo;\nuniform float pixelRatio;\nuniform vec4 viewBox;\nuniform sampler2D palette;\n\nvarying vec4 charColor, borderColor;\nvarying vec2 charId;\nvarying vec2 pointCoord;\nvarying float pointSize;\nvarying float borderWidth;\n\n\nvoid main() {\n charColor = texture2D(palette, vec2(color.x / 255., 0));\n borderColor = texture2D(palette, vec2(color.y / 255., 0));\n\n gl_PointSize = size * pixelRatio;\n pointSize = size * pixelRatio;\n\n charId = char;\n borderWidth = border;\n\n gl_Position = computePosition_1_0(\n positionHi, positionLo,\n scaleHi, scaleLo,\n translateHi, translateLo);\n\n pointCoord = viewBox.xy + (viewBox.zw - viewBox.xy) * (gl_Position.xy * .5 + .5);\n}\n",fragment:"precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D chars;\nuniform vec2 charsShape;\nuniform float charsStep, pixelRatio, charOffset;\n\nvarying vec4 borderColor;\nvarying vec4 charColor;\nvarying vec2 charId;\nvarying vec2 pointCoord;\nvarying float pointSize;\nvarying float borderWidth;\n\nvoid main() {\n\tvec2 pointUV = (pointCoord - gl_FragCoord.xy + pointSize * .5) / pointSize;\n\tpointUV.x = 1. - pointUV.x;\n\tvec2 texCoord = ((charId + pointUV) * charsStep) / charsShape;\n\tfloat dist = texture2D(chars, texCoord).r;\n\n\t//max-distance alpha\n\tif (dist < 1e-2)\n\t\tdiscard;\n\n\tfloat gamma = .0045 * charsStep / pointSize;\n\n //null-border case\n \tif (borderWidth * borderColor.a == 0.) {\n\t\tfloat charAmt = smoothstep(.748 - gamma, .748 + gamma, dist);\n\t\tgl_FragColor = vec4(charColor.rgb, charAmt*charColor.a);\n\t\treturn;\n\t}\n\n\tfloat dif = 5. * pixelRatio * borderWidth / pointSize;\n\tfloat borderLevel = .748 - dif * .5;\n\tfloat charLevel = .748 + dif * .5;\n\n\tfloat borderAmt = smoothstep(borderLevel - gamma, borderLevel + gamma, dist);\n\tfloat charAmt = smoothstep(charLevel - gamma, charLevel + gamma, dist);\n\n\tvec4 color = borderColor;\n\tcolor.a *= borderAmt;\n\n\tgl_FragColor = mix(color, charColor, charAmt);\n}\n",pickVertex:"precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 positionHi, positionLo;\nattribute vec4 id;\nattribute float size;\n\nuniform vec2 scaleHi, scaleLo, translateHi, translateLo;\nuniform vec4 pickOffset;\nuniform float pixelRatio;\n\nvarying vec4 fragColor;\n\n\nvec4 computePosition_1_0(vec2 posHi, vec2 posLo, vec2 scHi, vec2 scLo, vec2 trHi, vec2 trLo) {\n return vec4((posHi + trHi) * scHi\n \t\t\t//FIXME: this thingy does not give noticeable precision gain, need test\n + (posLo + trLo) * scHi\n + (posHi + trHi) * scLo\n + (posLo + trLo) * scLo\n , 0, 1);\n}\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_PointSize = size * .25 * pixelRatio;\n\n gl_Position = computePosition_1_0(\n positionHi, positionLo,\n scaleHi, scaleLo,\n translateHi, translateLo);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],234:[function(t,e,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],235:[function(t,e,r){arguments[4][213][0].apply(r,arguments)},{"./lib/GLError":236,"./lib/create-attributes":237,"./lib/create-uniforms":238,"./lib/reflect":239,"./lib/runtime-reflect":240,"./lib/shader-cache":241,dup:213}],236:[function(t,e,r){arguments[4][214][0].apply(r,arguments)},{dup:214}],237:[function(t,e,r){arguments[4][215][0].apply(r,arguments)},{"./GLError":236,dup:215}],238:[function(t,e,r){arguments[4][216][0].apply(r,arguments)},{"./GLError":236,"./reflect":239,dup:216}],239:[function(t,e,r){arguments[4][217][0].apply(r,arguments)},{dup:217}],240:[function(t,e,r){arguments[4][218][0].apply(r,arguments)},{dup:218}],241:[function(t,e,r){arguments[4][219][0].apply(r,arguments)},{"./GLError":236,dup:219,"gl-format-compiler-error":166,"weakmap-shim":571}],242:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){for(var o=t+1;o<=e;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],h=a[o],f=o;f>t;){var d=r[f-1],p=n[2*(f-1)];if((d-s||l-p)>=0)break;r[f]=d,n[2*f]=p,n[2*f+1]=n[2*f-1],i[f]=i[f-1],a[f]=a[f-1],f-=1}r[f]=s,n[2*f]=l,n[2*f+1]=c,i[f]=u,a[f]=h}}function i(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function a(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function o(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],h=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=h}function s(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function l(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function c(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function u(t,e,r,f,d,p){var m=(e-t+1)/6|0,g=t+m,v=e-m,y=t+e>>1,b=y-m,x=y+m,_=g,w=b,M=y,k=x,T=v,A=t+1,S=e-1,E=0;l(_,w,r,f,d)&&(E=_,_=w,w=E),l(k,T,r,f,d)&&(E=k,k=T,T=E),l(_,M,r,f,d)&&(E=_,_=M,M=E),l(w,M,r,f,d)&&(E=w,w=M,M=E),l(_,k,r,f,d)&&(E=_,_=k,k=E),l(M,k,r,f,d)&&(E=M,M=k,k=E),l(w,T,r,f,d)&&(E=w,w=T,T=E),l(w,M,r,f,d)&&(E=w,w=M,M=E),l(k,T,r,f,d)&&(E=k,k=T,T=E);var L=r[w],C=f[2*w],I=f[2*w+1],P=d[w],D=p[w],z=r[k],O=f[2*k],F=f[2*k+1],R=d[k],j=p[k],N=_,B=M,U=T,V=g,H=y,q=v,G=r[N],Y=r[B],W=r[U];r[V]=G,r[H]=Y,r[q]=W;for(var X=0;X<2;++X){var Z=f[2*N+X],J=f[2*B+X],K=f[2*U+X];f[2*V+X]=Z,f[2*H+X]=J,f[2*q+X]=K}var Q=d[N],$=d[B],tt=d[U];d[V]=Q,d[H]=$,d[q]=tt;var et=p[N],rt=p[B],nt=p[U];p[V]=et,p[H]=rt,p[q]=nt,a(b,t,r,f,d,p),a(x,e,r,f,d,p);for(var it=A;it<=S;++it)if(c(it,L,C,0,P,r,f,d))it!==A&&i(it,A,r,f,d,p),++A;else if(!c(it,z,O,0,R,r,f,d))for(;;){if(c(S,z,O,0,R,r,f,d)){c(S,L,C,0,P,r,f,d)?(o(it,A,S,r,f,d,p),++A,--S):(i(it,S,r,f,d,p),--S);break}if(--S=Math.max(.9*d,32)){var b=c+s>>>1;l(g,v,h,f,b,u+1),f=b}l(g,v,h,f,y,u+1),f=y}}}var c=t.length>>>1;if(c<1)return[];for(var u=1/0,h=1/0,f=-1/0,d=-1/0,p=0;p=0;--_){t[2*_]=(t[2*_]-u)*v,t[2*_+1]=(t[2*_+1]-h)*y;var T=x[_];T!==M&&(w.push(new i(b*Math.pow(.5,T),_+1,k-(_+1))),k=_+1,M=T)}return w.push(new i(b*Math.pow(.5,T+1),0,k)),a.free(x),w}},{"./lib/sort":242,"typedarray-pool":550}],244:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.sizeBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.charBuffer=s,this.pointCount=0,this.pickOffset=0,this.points=null,this.scales=[],this.xCoords=[],this.charCanvas=document.createElement("canvas"),this.charTexture=d(this.plot.gl,this.charCanvas),this.charStep=400,this.charFit=.255,this.snapThreshold=1e4,this.paletteTexture=d(this.plot.gl,[256,1])}e.exports=function(t,e){var r=t.gl,i=new n(t,s(r,u.vertex,u.fragment),s(r,u.pickVertex,u.pickFragment),l(r),l(r),l(r),l(r),l(r));return i.update(e),t.addObject(i),i};var i,a,o,s=t("gl-shader"),l=t("gl-buffer"),c=t("typedarray-pool"),u=t("./lib/shaders"),h=t("snap-points-2d"),f=t("font-atlas-sdf"),d=t("gl-texture2d"),p=t("color-id"),m=t("ndarray"),g=t("clamp"),v=t("binary-search-bounds"),y=n.prototype,b=new Float32Array([0,0]),x=new Float32Array([0,0]),_=new Float32Array([0,0]),w=new Float32Array([0,0]),M=[0,0],k=[0,0,0,0];y.drawPick=function(t){var e=void 0!==t,r=this.plot,n=this.pointCount,s=n>this.snapThreshold;if(!n)return t;(function(){var t=this.plot,e=t.viewBox,r=t.dataBox,n=t.pixelRatio,s=r[2]-r[0],l=r[3]-r[1],c=2/s,u=2/l,h=-r[0]-.5*s,f=-r[1]-.5*l;b[0]=c,x[0]=c-b[0],b[1]=u,x[1]=u-b[1],_[0]=h,w[0]=h-_[0],_[1]=f,w[1]=f-_[1];var d=e[2]-e[0],p=e[3]-e[1];i=Math.min(s/d,l/p),M[0]=2*n/d,M[1]=2*n/p,a=r[0],o=r[2]}).call(this);var l=r.gl,c=e?this.pickShader:this.shader,u=l.isEnabled(l.BLEND);if(c.bind(),e){this.pickOffset=t;for(var h=0;h<4;++h)k[h]=t>>8*h&255;c.uniforms.pickOffset=k,this.idBuffer.bind(),c.attributes.id.pointer(l.UNSIGNED_BYTE,!1)}else l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA),l.blendColor(0,0,0,1),u||l.enable(l.BLEND),this.colorBuffer.bind(),c.attributes.color.pointer(l.UNSIGNED_BYTE,!1),this.charBuffer.bind(),c.attributes.char.pointer(l.UNSIGNED_BYTE,!1),c.uniforms.chars=this.charTexture.bind(0),c.uniforms.charsShape=[this.charCanvas.width,this.charCanvas.height],c.uniforms.charsStep=this.charStep,c.uniforms.palette=this.paletteTexture.bind(1);this.sizeBuffer.bind(),c.attributes.size.pointer(l.FLOAT,!1,8,0),e||c.attributes.border.pointer(l.FLOAT,!1,8,4),this.positionBuffer.bind(),c.attributes.positionHi.pointer(l.FLOAT,!1,16,0),c.attributes.positionLo.pointer(l.FLOAT,!1,16,8),c.uniforms.pixelRatio=r.pixelRatio,c.uniforms.scaleHi=b,c.uniforms.scaleLo=x,c.uniforms.translateHi=_,c.uniforms.translateLo=w,c.uniforms.viewBox=r.viewBox;var f=this.scales;if(s)for(var d=f.length-1;d>=0;d--){var p=f[d];if(!(p.pixelSize&&p.pixelSize<1.25*i&&d>1)){var m=p.offset,g=p.count+m,y=v.ge(this.xCoords,a,m,g-1),T=v.lt(this.xCoords,o,y,g-1)+1;T>y&&l.drawArrays(l.POINTS,y,T-y)}}else l.drawArrays(l.POINTS,0,n);if(e)return t+n;u?l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA):l.disable(l.BLEND)},y.draw=y.drawPick,y.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},y.update=function(t){var e=(t=t||{}).positions||[],r=t.colors||[],n=t.glyphs||[],i=t.sizes||[],a=t.borderWidths||[],o=t.borderColors||[],s=this.plot.gl,l=this.pointCount,u=l>this.snapThreshold;if(null!=t.positions){this.points=e,u=(l=this.points.length/2)>this.snapThreshold;var d=c.mallocFloat32(2*l),v=c.mallocFloat64(2*l),y=c.mallocUint32(l),b=c.mallocFloat32(4*l);v.set(this.points),u&&(this.i2idx&&c.free(this.i2idx),this.i2idx=c.mallocInt32(l),this.scales=h(v,this.i2idx,d)),this.pointCount=l;for(var x=0;xO&&(O=i[x]);var F=this.charStep;this.charStep=g(Math.ceil(4*O),128,768);var R=Object.keys(z),j=this.charStep,N=Math.floor(j/2),B=s.getParameter(s.MAX_TEXTURE_SIZE),U=B/j*(B/j),V=Math.min(B,j*R.length),H=Math.min(B,j*Math.ceil(j*R.length/B)),q=Math.floor(V/j);R.length>U&&console.warn("gl-scatter2d-fancy: number of characters is more than maximum texture size. Try reducing it."),this.chars&&this.chars+""==R+""&&this.charStep==F||(this.charCanvas=f({canvas:this.charCanvas,family:"sans-serif",size:N,shape:[V,H],step:[j,j],chars:R,align:!0,fit:this.charFit}),this.chars=R);for(x=0;x>>1,n=l.mallocInt32(r),i=l.mallocFloat32(r),a=l.mallocFloat64(2*r);if(a.set(this.points),this.snapPoints)this.scales=s(a,n,i,this.bounds);else{this.bounds=h(a,2),u(a,2,this.bounds);for(var o=0;o>8&255,v[2]=t>>16&255,v[3]=t>>24&255,n.uniforms.pickOffset=v,s.bind(),n.attributes.pickId.pointer(h.UNSIGNED_BYTE)):(n.uniforms.useWeight=1,this.weightBuffer.bind(),n.attributes.weight.pointer());var I=!0;if(this.snapPoints)for(var P=i.length-1;P>=0;P--){var D=i[P];if(!(D.pixelSize1)){var z=this.getVisibleRange(D),O=z[0],F=z[1];F>O&&h.drawArrays(h.POINTS,O,F-O),!e&&I&&(I=!1,n.uniforms.useWeight=0)}}else h.drawArrays(h.POINTS,0,this.pointCount);return t+this.pointCount},f.getVisibleRange=function(t){var e=this.plot.dataBox,r=this.bounds,n=this.pixelSize,i=this.size,a=this.plot.pixelRatio,s=r[2]-r[0];r[3],r[1];if(!t)for(var l=this.scales.length-1;l>=0&&((t=this.scales[l]).pixelSize1);l--);var c=this.xCoords,u=(e[0]-r[0]-n*i*a)/s,h=(e[2]-r[0]+n*i*a)/s,f=t.offset,d=t.count+f,p=o.ge(c,u,f,d-1);return[p,o.lt(c,h,p,d-1)+1]},f.drawPick=f.draw,f.pick=function(t,e,r){var n=r-this.pickOffset;return n<0||n>=this.pointCount?null:{object:this,pointId:n,dataCoord:[this.points[2*n],this.points[2*n+1]]}}},{"./lib/shader":245,"array-bounds":45,"array-normalize":46,"binary-search-bounds":246,"gl-buffer":157,"gl-shader":256,"snap-points-2d":248,"typedarray-pool":550}],250:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e){var r=i[e];if(r||(r=i[e]={}),t in r)return r[t];for(var a=n(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=n(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-1/0,-1/0]],l=0;lMath.abs(F[1])){var R=O;O=F,F=R,R=D,D=z,z=R;var j=I;I=P,P=j}O[0]<0&&(D[I]=-1),F[1]>0&&(z[P]=-1);var N=0,B=0;for(C=0;C<4;++C)N+=Math.pow(d[4*I+C],2),B+=Math.pow(d[4*P+C],2);D[I]/=Math.sqrt(N),z[P]/=Math.sqrt(B),f.axes[0]=D,f.axes[1]=z,f.fragClipBounds[0]=l(T,S[0],E,-1e8),f.fragClipBounds[1]=l(T,S[1],E,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function u(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||v,s.view=n.view||v,s.projection=n.projection||v,b[0]=2/o.drawingBufferWidth,b[1]=2/o.drawingBufferHeight,s.screenSize=b,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=S,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}c(e,r,n,i),r.vao.unbind()}var h=t("gl-buffer"),f=t("gl-vao"),d=t("typedarray-pool"),p=t("gl-mat4/multiply"),m=t("./lib/shaders"),g=t("./lib/glyphs"),v=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=function(t){var e=t.gl,r=m.createPerspective(e),n=m.createOrtho(e),i=m.createProject(e),o=m.createPickPerspective(e),s=m.createPickOrtho(e),l=m.createPickProject(e),c=h(e),u=h(e),d=h(e),p=h(e),g=new a(e,r,n,i,c,u,d,p,f(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:d,size:2,type:e.FLOAT},{buffer:p,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),o,s,l);return g.update(t),g};var y=a.prototype;y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},y.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var b=[0,0],x=[0,0,0],_=[0,0,0],w=[0,0,0,1],M=[0,0,0,1],k=v.slice(),T=[0,0,0],A=[[0,0,0],[0,0,0]],S=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];y.draw=function(t){u(this.useOrtho?this.orthoShader:this.shader,this.projectShader,this,t,!1,!1)},y.drawTransparent=function(t){u(this.useOrtho?this.orthoShader:this.shader,this.projectShader,this,t,!0,!1)},y.drawPick=function(t){u(this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader,this.pickProjectShader,this,t,!1,!0)},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},y.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},y.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],l=t.glyph,c=t.color,u=t.size,h=t.angle,f=t.lineColor,p=0,m=0,v=0,y=n.length;t:for(var b=0;b0&&(C[0]=-a[0]*(1+k[0][0]));var H=w.cells,q=w.positions;for(_=0;_0){var v=r*u;o.drawBox(h-v,f-v,d+v,f+v,a),o.drawBox(h-v,p-v,d+v,p+v,a),o.drawBox(h-v,f-v,h+v,p+v,a),o.drawBox(d-v,f-v,d+v,p+v,a)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":253,"gl-buffer":157,"gl-shader":256}],255:[function(t,e,r){"use strict";function n(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}e.exports=function(t,e){return new n(t,i(t,e),a.mallocUint8(e[0]*e[1]*4))};var i=t("gl-fbo"),a=t("typedarray-pool"),o=t("ndarray"),s=t("bit-twiddle").nextPow2,l=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_46_arg0_<255||_inline_46_arg1_<255||_inline_46_arg2_<255||_inline_46_arg3_<255){var _inline_46_l=_inline_46_arg4_-_inline_46_arg6_[0],_inline_46_a=_inline_46_arg5_-_inline_46_arg6_[1],_inline_46_f=_inline_46_l*_inline_46_l+_inline_46_a*_inline_46_a;_inline_46_fthis.buffer.length){a.free(this.buffer);for(var n=this.buffer=a.mallocUint8(s(r*e*4)),i=0;i=0){for(var k=0|M.type.charAt(M.type.length-1),T=new Array(k),A=0;A=0;)S+=1;_[w]=S}var E=new Array(r.length);h(),d._relink=h,d.types={uniforms:s(r),attributes:s(n)},d.attributes=o(p,d,b,_),Object.defineProperty(d,"uniforms",a(p,d,r,E))},e.exports=function(t,e,r,i,a){var o=new n(t);return o.update(e,r,i,a),o}},{"./lib/GLError":257,"./lib/create-attributes":258,"./lib/create-uniforms":259,"./lib/reflect":260,"./lib/runtime-reflect":261,"./lib/shader-cache":262}],257:[function(t,e,r){arguments[4][214][0].apply(r,arguments)},{dup:214}],258:[function(t,e,r){arguments[4][215][0].apply(r,arguments)},{"./GLError":257,dup:215}],259:[function(t,e,r){arguments[4][216][0].apply(r,arguments)},{"./GLError":257,"./reflect":260,dup:216}],260:[function(t,e,r){arguments[4][217][0].apply(r,arguments)},{dup:217}],261:[function(t,e,r){arguments[4][218][0].apply(r,arguments)},{dup:218}],262:[function(t,e,r){arguments[4][219][0].apply(r,arguments)},{"./GLError":257,dup:219,"gl-format-compiler-error":166,"weakmap-shim":571}],263:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}e.exports=function(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r};var i=n.prototype;i.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},i.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},i.dispose=function(){this.plot.removeOverlay(this)}},{}],264:[function(t,e,r){"use strict";var n=t("gl-shader");e.exports=function(t){return n(t,"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n","precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}",null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":256}],265:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}var i=t("gl-buffer"),a=t("gl-vao"),o=t("./shaders/index");e.exports=function(t,e){function r(t,e,r,n,i,a){var o=[t,e,r,0,0,0,1];o[n+3]=1,o[n]=i,s.push.apply(s,o),o[6]=-1,s.push.apply(s,o),o[n]=a,s.push.apply(s,o),s.push.apply(s,o),o[6]=1,s.push.apply(s,o),o[n]=i,s.push.apply(s,o)}var s=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=i(t,s),c=a(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=o(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var h=new n(t,l,c,u);return h.update(e),h};var s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],l=n.prototype,c=[0,0,0],u=[0,0,0],h=[0,0];l.isTransparent=function(){return!1},l.drawTransparent=function(t){},l.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||s,o=t.view||s,l=t.projection||s;this.axes&&(i=this.axes.lastCubeProps.axis);for(var f=c,d=u,p=0;p<3;++p)i&&i[p]<0?(f[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(f[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=l,n.uniforms.coordinates=[this.position,f,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(p=0;p<3;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},l.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":264,"gl-buffer":157,"gl-vao":272}],266:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n vec4 clipPosition = projection * view * worldPosition;\n gl_Position = clipPosition;\n kill = f.y;\n value = f.z;\n planeCoordinate = uv.xy;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * worldPosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n lightDirection = lightPosition - cameraCoordinate.xyz;\n eyeDirection = eyePosition - cameraCoordinate.xyz;\n surfaceNormal = normalize((vec4(normal,0) * inverseModel).xyz);\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\n\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if (kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular_1_1(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color \u2014 in vertex or in fragment\n vec4 surfaceColor = step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) + step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n",s="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":256}],267:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,h,f,d){this.gl=t,this.shape=e,this.bounds=r,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=s,this._contourShader=l,this._contourPickShader=c,this._contourBuffer=u,this._contourVAO=h,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new function(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=f,this._dynamicVAO=d,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[y(p.mallocFloat(1024),[0,0]),y(p.mallocFloat(1024),[0,0]),y(p.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}function i(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||O,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=F.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],x(l,t.model,l);var c=F.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return F.showSurface=o,F.showContour=s,F}function a(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=R;n.model=t.model||C,n.view=t.view||C,n.projection=t.projection||C,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=_(n.inverseModel,n.model);for(var a=0;a<2;++a)for(var o=n.clipBounds[a],s=0;s<3;++s)o[s]=Math.min(Math.max(this.clipBounds[a][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=N,n.vertexColor=this.vertexColor;var l=j;for(x(l,n.view,n.model),x(l,n.projection,l),_(l,l),a=0;a<3;++a)n.eyePosition[a]=l[12+a]/l[15];var c=l[15];for(a=0;a<3;++a)c+=this.lightPosition[a]*l[4*a+3];for(a=0;a<3;++a){var u=l[12+a];for(s=0;s<3;++s)u+=l[4*s+a]*this.lightPosition[s];n.lightPosition[a]=u/c}var h=i(n,this);if(h.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),a=0;a<3;++a)this.surfaceProject[a]&&this.vertexCount&&(this._shader.uniforms.model=h.projections[a],this._shader.uniforms.clipBounds=h.clipBounds[a],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(h.showContour&&!e){var f=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,f.bind(),f.uniforms=n;var d=this._contourVAO;for(d.bind(),a=0;a<3;++a)for(f.uniforms.permutation=P[a],r.lineWidth(this.contourWidth[a]),s=0;s=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},z.pickSlots=1,z.setPickBase=function(t){this.pickId=t};var O=[0,0,0],F={showSurface:!1,showContour:!1,projections:[C.slice(),C.slice(),C.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},R={model:C,view:C,projection:C,inverseModel:C.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},j=C.slice(),N=[1,0,0,0,1,0,0,0,1];z.draw=function(t){return a.call(this,t,!1)},z.drawTransparent=function(t){return a.call(this,t,!0)};var B={model:C,view:C,projection:C,inverseModel:C,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};z.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=B;r.model=t.model||C,r.view=t.view||C,r.projection=t.projection||C,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=N;for(var n=0;n<2;++n)for(var a=r.clipBounds[n],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[n][o],-1e8),1e8);var s=i(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;n<3;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),o=0;o<3;++o)for(e.lineWidth(this.contourWidth[o]),l.uniforms.permutation=P[o],n=0;n>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;u<2;++u)for(var h=u?a:1-a,f=0;f<2;++f)for(var d=i+u,p=s+f,m=h*(f?l:1-l),g=0;g<3;++g)c[g]+=this._field[g].get(d,p)*m;for(var v=this._pickResult.level,y=0;y<3;++y)if(v[y]=w.le(this.contourLevels[y],c[y]),v[y]<0)this.contourLevels[y].length>0&&(v[y]=0);else if(v[y]Math.abs(x-c[y])&&(v[y]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],g=0;g<3;++g)r.dataCoordinate[g]=this._field[g].get(r.index[0],r.index[1]);return r},z.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=s(t.contourWidth,Number)),"showContour"in t&&(this.showContour=s(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=s(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=c(t.contourColor)),"contourProject"in t&&(this.contourProject=s(t.contourProject,function(t){return s(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=c(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=s(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=s(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(p.freeFloat(this._field[2].data),this._field[2].data=p.mallocFloat(u.nextPow2(n))),this._field[2]=y(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),o(this._field[2],e),this.shape=e.shape.slice();for(var i=this.shape,a=0;a<2;++a)this._field[2].size>this._field[a].data.length&&(p.freeFloat(this._field[a].data),this._field[a].data=p.mallocFloat(this._field[2].size)),this._field[a]=y(this._field[a].data,[i[0]+2,i[1]+2]);if(t.coords){var l=t.coords;if(!Array.isArray(l)||3!==l.length)throw new Error("gl-surface: invalid coordinates for x/y");for(a=0;a<2;++a){var h=l[a];for(w=0;w<2;++w)if(h.shape[w]!==i[w])throw new Error("gl-surface: coords have incorrect shape");o(this._field[a],h)}}else if(t.ticks){var f=t.ticks;if(!Array.isArray(f)||2!==f.length)throw new Error("gl-surface: invalid ticks");for(a=0;a<2;++a){var d=f[a];if((Array.isArray(d)||d.length)&&(d=y(d)),d.shape[0]!==i[a])throw new Error("gl-surface: invalid tick length");var x=y(d.data,i);x.stride[a]=d.stride[0],x.stride[1^a]=0,o(this._field[a],x)}}else{for(a=0;a<2;++a){var _=[0,0];_[a]=1,this._field[a]=y(this._field[a].data,[i[0]+2,i[1]+2],_,0)}this._field[0].set(0,0,0);for(var w=0;w0){for(var Mt=0;Mt<5;++Mt)nt.pop();Y-=1}continue t}nt.push(st[0],st[1],ut[0],ut[1],st[2]),Y+=1}}ot.push(Y)}this._contourOffsets[it]=at,this._contourCounts[it]=ot}var kt=p.mallocFloat(nt.length);for(a=0;ai||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function l(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>o||r<0||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var l=s(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,l,e,r,n,i)}var c=t("ndarray"),u=t("ndarray-ops"),h=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(f||function(t){f=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],d=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],p=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t),"number"==typeof arguments[1])return l(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return l(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=n(e)?e:e.raw;if(r)return function(t,e,r,n,i,o){var l=s(t);return t.texImage2D(t.TEXTURE_2D,0,i,i,o,e),new a(t,l,r,n,i,o)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var l=o(n,e.stride.slice()),f=0;"float32"===r?f=t.FLOAT:"float64"===r?(f=t.FLOAT,l=!1,r="float32"):"uint8"===r?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,l=!1,r="uint8");var d=0;if(2===n.length)d=t.LUMINANCE,n=[n[0],n[1],1],e=c(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])d=t.ALPHA;else if(2===n[2])d=t.LUMINANCE_ALPHA;else if(3===n[2])d=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");d=t.RGBA}}f!==t.FLOAT||t.getExtension("OES_texture_float")||(f=t.UNSIGNED_BYTE,l=!1);var p,g,v=e.size;if(l)p=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var y=[n[2],n[2]*n[0],1];g=h.malloc(v,r);var b=c(g,n,y,0);"float32"!==r&&"float64"!==r||f!==t.UNSIGNED_BYTE?u.assign(b,e):m(b,e),p=g.subarray(0,v)}var x=s(t);return t.texImage2D(t.TEXTURE_2D,0,d,n[0],n[1],0,d,f,p),l||h.free(g),new a(t,x,n[0],n[1],d,f)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var f=null,d=null,p=null,m=function(t,e){u.muls(t,e,255)},g=a.prototype;Object.defineProperties(g,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&f.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),d.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&f.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),d.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),p.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),p.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(p.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t|=0,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,i(this,this._shape[0],t),t}}}),g.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},g.dispose=function(){this.gl.deleteTexture(this.handle)},g.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},g.setPixels=function(t,e,r,i){var a=this.gl;this.bind(),Array.isArray(e)?(i=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),i=i||0;var s=n(t)?t:t.raw;if(s){this._mipLevels.indexOf(i)<0?(a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,this.type,s),this._mipLevels.push(i)):a.texSubImage2D(a.TEXTURE_2D,i,e,r,this.format,this.type,s)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>i||r+t.shape[0]>this._shape[0]>>>i||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,n,i,a,s,l){var f=l.dtype,d=l.shape.slice();if(d.length<2||d.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var p=0,g=0,v=o(d,l.stride.slice());if("float32"===f?p=t.FLOAT:"float64"===f?(p=t.FLOAT,v=!1,f="float32"):"uint8"===f?p=t.UNSIGNED_BYTE:(p=t.UNSIGNED_BYTE,v=!1,f="uint8"),2===d.length)g=t.LUMINANCE,d=[d[0],d[1],1],l=c(l.data,d,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==d.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===d[2])g=t.ALPHA;else if(2===d[2])g=t.LUMINANCE_ALPHA;else if(3===d[2])g=t.RGB;else{if(4!==d[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");g=t.RGBA}d[2]}if(g!==t.LUMINANCE&&g!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(g=i),g!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,b=s.indexOf(n)<0;if(b&&s.push(n),p===a&&v)0===l.offset&&l.data.length===y?b?t.texImage2D(t.TEXTURE_2D,n,i,d[0],d[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,d[0],d[1],i,a,l.data):b?t.texImage2D(t.TEXTURE_2D,n,i,d[0],d[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,d[0],d[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var x;x=a===t.FLOAT?h.mallocFloat32(y):h.mallocUint8(y);var _=c(x,d,[d[2],d[2]*d[0],1]);p===t.FLOAT&&a===t.UNSIGNED_BYTE?m(_,l):u.assign(_,l),b?t.texImage2D(t.TEXTURE_2D,n,i,d[0],d[1],0,i,a,x.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,d[0],d[1],i,a,x.subarray(0,y)),a===t.FLOAT?h.freeFloat32(x):h.freeUint8(x)}}(a,e,r,i,this.format,this.type,this._mipLevels,t)}}},{ndarray:468,"ndarray-ops":462,"typedarray-pool":550}],269:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}},{}],278:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],279:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],280:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r-1?y:N.indexOf(t)>-1?v:g,e(I.join("")),C=l,E}return I.push(T),A=T,E+1}();break;case b:E=/[^\s]/g.test(T)?(e(I.join("")),C=l,E):(I.push(T),A=T,E+1);break;case l:I=I.length?[]:I,E="/"===A&&"*"===T?(O=L+E-1,C=u,A=T,E+1):"/"===A&&"/"===T?(O=L+E-1,C=h,A=T,E+1):"#"===T?(C=f,O=L+E,E):/\s/.test(T)?(C=b,O=L+E,E):(F=/\d/.test(T),R=/[^\w_]/.test(T),O=L+E,C=F?p:R?d:c,E)}if(r!==E)switch(j[r]){case"\n":z=0,++D;break;default:++z}}return L+=E,j=j.slice(E),P}function M(){return"\r"!==T&&"\n"!==T||"\\"===A?(I.push(T),A=T,E+1):(e(I.join("")),C=l,E)}function k(t){for(var r,n,a=0;;){if(r=i.indexOf(t.slice(0,t.length+a).join("")),n=i[r],-1===r){if(a--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),O+=n.length,(I=I.slice(n.length)).length}}var T,A,S,E=0,L=0,C=l,I=[],P=[],D=1,z=0,O=0,F=!1,R=!1,j="",N=a,B=n;return"300 es"===(t=t||{}).version&&(N=s,B=o),function(t){return P=[],null!==t?r(t.replace?t.replace(/\r\n/g,"\n"):t):(I.length&&e(I.join("")),C=x,e("(eof)"),P)}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,c=9999,u=0,h=1,f=2,d=3,p=4,m=5,g=6,v=7,y=8,b=9,x=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":283,"./lib/builtins-300es":282,"./lib/literals":285,"./lib/literals-300es":284,"./lib/operators":286}],282:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":283}],283:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],284:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":285}],285:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],286:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],287:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=i.concat(r(t)),i=i.concat(r(null))}},{"./index":281}],288:[function(t,e,r){"use strict";function n(t,e,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var a=new Int32Array(this.arrayBuffer);t=a[0],e=a[1],r=a[2],this.d=e+2*r;for(var o=0;o=c[f+0]&&n>=c[f+1]?(o[h]=!0,a.push(l[h])):o[h]=!1}}},n.prototype._forEachCell=function(t,e,r,n,i,a,o){for(var s=this._convertToCellCoord(t),l=this._convertToCellCoord(e),c=this._convertToCellCoord(r),u=this._convertToCellCoord(n),h=s;h<=c;h++)for(var f=l;f<=u;f++){var d=this.d*f+h;if(i.call(this,t,e,r,n,d,a,o))return}},n.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},n.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=i+this.cells.length+1+1,r=0,n=0;n>1,u=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+h],h+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+h],h+=f,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*m}},{}],291:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return l(t.vertices,e.vertices)}function o(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;n<=t;++n)this.tuple[n]=this.vertices[n];var i=c[t];i||(i=c[t]=function(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;r<=t;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=s[t+1];return i||(i=s),n(i)}(t)),this.orient=i}e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),l=s.apply(void 0,a);if(0===l)throw new Error("Input not in general position");for(var c=new Array(i+1),u=0;u<=i;++u)c[u]=u;l<0&&(c[0]=1,c[1]=0);var h=new n(c,new Array(i+1),!1),f=h.adjacent,d=new Array(i+2);for(u=0;u<=i;++u){for(var p=c.slice(),m=0;m<=i;++m)m===u&&(p[m]=-1);var g=p[0];p[0]=p[1],p[1]=g;var v=new n(p,new Array(i+1),!0);f[u]=v,d[u]=v}for(d[i+1]=h,u=0;u<=i;++u){p=f[u].vertices;var y=f[u].adjacent;for(m=0;m<=i;++m){var b=p[m];if(b<0)y[m]=h;else for(var x=0;x<=i;++x)f[x].vertices.indexOf(b)<0&&(y[m]=f[x])}}var _=new o(i,a,d),w=!!e;for(u=i+1;u0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,h=0;h<=r;++h){var f=u[h];i[h]=f<0?e:a[f]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},u.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;u<=n;++u)a[u]=i[l[u]];s.lastVisited=r;for(u=0;u<=n;++u){var h=c[u];if(!(h.lastVisited>=r)){var f=a[u];a[u]=t;var d=this.orient();if(a[u]=f,d<0){s=h;continue t}h.boundary?h.lastVisited=-r:h.lastVisited=r}}return}return s},u.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,h=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var f=[];h.length>0;){var d=(e=h.pop()).vertices,p=e.adjacent,m=d.indexOf(r);if(!(m<0))for(var g=0;g<=o;++g)if(g!==m){var v=p[g];if(v.boundary&&!(v.lastVisited>=r)){var y=v.vertices;if(v.lastVisited!==-r){for(var b=0,x=0;x<=o;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];if(this.orient()>0){y[b]=r,v.boundary=!1,c.push(v),h.push(v),v.lastVisited=r;continue}v.lastVisited=-r}var _=v.adjacent,w=d.slice(),M=p.slice(),k=new n(w,M,!0);u.push(k);var T=_.indexOf(e);if(!(T<0)){_[T]=k,M[m]=v,w[g]=-1,M[g]=e,p[g]=k,k.flip();for(x=0;x<=o;++x){var A=w[x];if(!(A<0||A===r)){for(var S=new Array(o-1),E=0,L=0;L<=o;++L){var C=w[L];C<0||L===x||(S[E++]=C)}f.push(new i(S,k,x))}}}}}}f.sort(a);for(g=0;g+1=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var h=o[0];o[0]=o[1],o[1]=h}e.push(o)}}return e}},{"robust-orientation":517,"simplicial-complex":528}],292:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?v:(r.splice(n,1),a(t,r),y)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[];for(r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=g.ge(this.leftPoints,t,f),n=g.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},b.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);return 2===(o=this.left.remove(t))?(this.left=null,this.count-=1,y):(o===y&&(this.count-=1),o)}if(t[0]>this.mid){if(!this.right)return v;if(4*(this.left?this.left.count:0)>3*(e-1))return s(this,t);return 2===(o=this.right.remove(t))?(this.right=null,this.count-=1,y):(o===y&&(this.count-=1),o)}if(1===this.count)return this.leftPoints[0]===t?2:v;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,n=this.left;n.right;)r=n,n=n.right;if(r===this)n.right=this.right;else{var a=this.left,o=this.right;r.count-=n.count,r.right=n.left,n.left=a,n.right=o}i(this,n),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return y}for(a=g.ge(this.leftPoints,t,f);athis.mid){if(this.right){var r;if(r=this.right.queryPoint(t,e))return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},b.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n;if(n=this.right.queryInterval(t,e,r))return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var x=m.prototype;x.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},x.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==v}return!1},x.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},x.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(x,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(x,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":67}],293:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r=r&&s<=i&&l>=n&&l<=a&&u.push(t[p]);else{var m=Math.floor((d+f)/2);s=e[2*m],l=e[2*m+1],s>=r&&s<=i&&l>=n&&l<=a&&u.push(t[m]);var g=(h+1)%2;(0===h?r<=s:n<=l)&&(c.push(d),c.push(m-1),c.push(g)),(0===h?i>=s:a>=l)&&(c.push(m+1),c.push(f),c.push(g))}}return u}},{}],301:[function(t,e,r){"use strict";function n(t,e,r,a,o,s){if(!(o-a<=r)){var l=Math.floor((a+o)/2);i(t,e,l,a,o,s%2),n(t,e,r,a,l-1,s+1),n(t,e,r,l+1,o,s+1)}}function i(t,e,r,n,o,s){for(;o>n;){if(o-n>600){var l=o-n+1,c=r-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1);i(t,e,r,Math.max(n,Math.floor(r-c*h/l+f)),Math.min(o,Math.floor(r+(l-c)*h/l+f)),s)}var d=e[2*r+s],p=n,m=o;for(a(t,e,n,r),e[2*o+s]>d&&a(t,e,n,o);pd;)m--}e[2*n+s]===d?a(t,e,n,m):a(t,e,++m,o),m<=r&&(n=m+1),r<=m&&(o=m-1)}}function a(t,e,r,n){o(t,r,n),o(e,2*r,2*n),o(e,2*r+1,2*n+1)}function o(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}e.exports=n},{}],302:[function(t,e,r){"use strict";function n(t,e,r,n){var i=t-r,a=e-n;return i*i+a*a}e.exports=function(t,e,r,i,a,o){for(var s=[0,t.length-1,0],l=[],c=a*a;s.length;){var u=s.pop(),h=s.pop(),f=s.pop();if(h-f<=o)for(var d=f;d<=h;d++)n(e[2*d],e[2*d+1],r,i)<=c&&l.push(t[d]);else{var p=Math.floor((f+h)/2),m=e[2*p],g=e[2*p+1];n(m,g,r,i)<=c&&l.push(t[p]);var v=(u+1)%2;(0===u?r-a<=m:i-a<=g)&&(s.push(f),s.push(p-1),s.push(v)),(0===u?r+a>=m:i+a>=g)&&(s.push(p+1),s.push(h),s.push(v))}}return l}},{}],303:[function(t,e,r){"use strict";function n(t,e){var r;if(u(t)){var l,c=t.stops&&"object"==typeof t.stops[0][0],h=c||void 0!==t.property,f=c||!h,d=t.type||e||"exponential";if("exponential"===d)l=o;else if("interval"===d)l=a;else if("categorical"===d)l=i;else{if("identity"!==d)throw new Error('Unknown function type "'+d+'"');l=s}if(c){for(var p={},m=[],g=0;g=t.stops.length||e<=t.stops[n][0]);)n++;return 0===n?t.stops[n][1]:n===t.stops.length?t.stops[n-1][1]:l(e,r,t.stops[n-1][0],t.stops[n][0],t.stops[n-1][1],t.stops[n][1])}function s(t,e){return e}function l(t,e,r,n,i,a){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),s=a.apply(void 0,arguments);return l(t,e,r,n,o,s)}:i.length?function(t,e,r,n,i,a){for(var o=[],s=0;s -1 and 1 => 1\n // In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = mod(a_pos, 2.0);\n normal.y = sign(normal.y - 0.5);\n v_normal = normal;\n\n float inset = u_gapwidth + (u_gapwidth > 0.0 ? u_antialiasing : 0.0);\n float outset = u_gapwidth + u_linewidth * (u_gapwidth > 0.0 ? 2.0 : 1.0) + u_antialiasing;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n // Remove the texture normal bit of the position before scaling it with the\n // model/view matrix.\n gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + (offset + dist) / u_ratio, 0.0, 1.0);\n\n // position of y on the screen\n float y = gl_Position.y / gl_Position.w;\n\n // how much features are squished in the y direction by the tilt\n float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);\n\n // how much features are squished in all directions by the perspectiveness\n float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.9));\n\n v_linewidth = vec2(outset, inset);\n v_gamma_scale = perspective_scale * squish_scale;\n}\n"},linepattern:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform float u_blur;\n\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform float u_fade;\nuniform float u_opacity;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_normal;\nvarying vec2 v_linewidth;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\nvoid main() {\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_linewidth.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_linewidth.t) or when fading out\n // (v_linewidth.s)\n float blur = u_blur * v_gamma_scale;\n float alpha = clamp(min(dist - (v_linewidth.t - blur), v_linewidth.s - dist) / blur, 0.0, 1.0);\n\n float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);\n float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);\n float y_a = 0.5 + (v_normal.y * v_linewidth.s / u_pattern_size_a.y);\n float y_b = 0.5 + (v_normal.y * v_linewidth.s / u_pattern_size_b.y);\n vec2 pos_a = mix(u_pattern_tl_a, u_pattern_br_a, vec2(x_a, y_a));\n vec2 pos_b = mix(u_pattern_tl_b, u_pattern_br_b, vec2(x_b, y_b));\n\n vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);\n\n alpha *= u_opacity;\n\n gl_FragColor = color * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\nattribute vec2 a_pos;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform mediump float u_linewidth;\nuniform mediump float u_gapwidth;\nuniform mediump float u_antialiasing;\nuniform mediump float u_extra;\nuniform mat2 u_antialiasingmatrix;\nuniform mediump float u_offset;\n\nvarying vec2 v_normal;\nvarying vec2 v_linewidth;\nvarying float v_linesofar;\nvarying float v_gamma_scale;\n\nvoid main() {\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n // We store the texture normals in the most insignificant bit\n // transform y so that 0 => -1 and 1 => 1\n // In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = mod(a_pos, 2.0);\n normal.y = sign(normal.y - 0.5);\n v_normal = normal;\n\n float inset = u_gapwidth + (u_gapwidth > 0.0 ? u_antialiasing : 0.0);\n float outset = u_gapwidth + u_linewidth * (u_gapwidth > 0.0 ? 2.0 : 1.0) + u_antialiasing;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n // Remove the texture normal bit of the position before scaling it with the\n // model/view matrix.\n gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + (offset + dist) / u_ratio, 0.0, 1.0);\n v_linesofar = a_linesofar;\n\n // position of y on the screen\n float y = gl_Position.y / gl_Position.w;\n\n // how much features are squished in the y direction by the tilt\n float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);\n\n // how much features are squished in all directions by the perspectiveness\n float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.9));\n\n v_linewidth = vec2(outset, inset);\n v_gamma_scale = perspective_scale * squish_scale;\n}\n"},linesdfpattern:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform lowp vec4 u_color;\nuniform lowp float u_opacity;\n\nuniform float u_blur;\nuniform sampler2D u_image;\nuniform float u_sdfgamma;\nuniform float u_mix;\n\nvarying vec2 v_normal;\nvarying vec2 v_linewidth;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\nvoid main() {\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * v_linewidth.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_linewidth.t) or when fading out\n // (v_linewidth.s)\n float blur = u_blur * v_gamma_scale;\n float alpha = clamp(min(dist - (v_linewidth.t - blur), v_linewidth.s - dist) / blur, 0.0, 1.0);\n\n float sdfdist_a = texture2D(u_image, v_tex_a).a;\n float sdfdist_b = texture2D(u_image, v_tex_b).a;\n float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);\n alpha *= smoothstep(0.5 - u_sdfgamma, 0.5 + u_sdfgamma, sdfdist);\n\n gl_FragColor = u_color * (alpha * u_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n// #define scale 63.0\n#define scale 0.015873016\n\n// We scale the distance before adding it to the buffers so that we can store\n// long distances for long segments. Use this value to unscale the distance.\n#define LINE_DISTANCE_SCALE 2.0\n\nattribute vec2 a_pos;\nattribute vec4 a_data;\n\nuniform mat4 u_matrix;\nuniform mediump float u_ratio;\nuniform mediump float u_linewidth;\nuniform mediump float u_gapwidth;\nuniform mediump float u_antialiasing;\nuniform vec2 u_patternscale_a;\nuniform float u_tex_y_a;\nuniform vec2 u_patternscale_b;\nuniform float u_tex_y_b;\nuniform float u_extra;\nuniform mat2 u_antialiasingmatrix;\nuniform mediump float u_offset;\n\nvarying vec2 v_normal;\nvarying vec2 v_linewidth;\nvarying vec2 v_tex_a;\nvarying vec2 v_tex_b;\nvarying float v_gamma_scale;\n\nvoid main() {\n vec2 a_extrude = a_data.xy - 128.0;\n float a_direction = mod(a_data.z, 4.0) - 1.0;\n float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;\n\n // We store the texture normals in the most insignificant bit\n // transform y so that 0 => -1 and 1 => 1\n // In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap\n // y is 1 if the normal points up, and -1 if it points down\n mediump vec2 normal = mod(a_pos, 2.0);\n normal.y = sign(normal.y - 0.5);\n v_normal = normal;\n\n float inset = u_gapwidth + (u_gapwidth > 0.0 ? u_antialiasing : 0.0);\n float outset = u_gapwidth + u_linewidth * (u_gapwidth > 0.0 ? 2.0 : 1.0) + u_antialiasing;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n mediump vec2 dist = outset * a_extrude * scale;\n\n // Calculate the offset when drawing a line that is to the side of the actual line.\n // We do this by creating a vector that points towards the extrude, but rotate\n // it when we're drawing round end points (a_direction = -1 or 1) since their\n // extrude vector points in another direction.\n mediump float u = 0.5 * a_direction;\n mediump float t = 1.0 - abs(u);\n mediump vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);\n\n // Remove the texture normal bit of the position before scaling it with the\n // model/view matrix.\n gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + (offset + dist) / u_ratio, 0.0, 1.0);\n\n v_tex_a = vec2(a_linesofar * u_patternscale_a.x, normal.y * u_patternscale_a.y + u_tex_y_a);\n v_tex_b = vec2(a_linesofar * u_patternscale_b.x, normal.y * u_patternscale_b.y + u_tex_y_b);\n\n // position of y on the screen\n float y = gl_Position.y / gl_Position.w;\n\n // how much features are squished in the y direction by the tilt\n float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);\n\n // how much features are squished in all directions by the perspectiveness\n float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.9));\n\n v_linewidth = vec2(outset, inset);\n v_gamma_scale = perspective_scale * squish_scale;\n}\n"},outline:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\n#pragma mapbox: define lowp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvarying vec2 v_pos;\n\nvoid main() {\n #pragma mapbox: initialize lowp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = smoothstep(1.0, 0.0, dist);\n gl_FragColor = outline_color * (alpha * opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nattribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\n#pragma mapbox: define lowp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n\nvoid main() {\n #pragma mapbox: initialize lowp vec4 outline_color\n #pragma mapbox: initialize lowp float opacity\n\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},outlinepattern:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform float u_opacity;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\nvoid main() {\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a, u_pattern_br_a, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b, u_pattern_br_b, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n // find distance to outline for alpha interpolation\n\n float dist = length(v_pos - gl_FragCoord.xy);\n float alpha = smoothstep(1.0, 0.0, dist);\n \n\n gl_FragColor = mix(color1, color2, u_mix) * alpha * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n vec2 scaled_size_a = u_scale_a * u_pattern_size_a;\n vec2 scaled_size_b = u_scale_b * u_pattern_size_b;\n\n // the correct offset needs to be calculated.\n //\n // The offset depends on how many pixels are between the world origin and\n // the edge of the tile:\n // vec2 offset = mod(pixel_coord, size)\n //\n // At high zoom levels there are a ton of pixels between the world origin\n // and the edge of the tile. The glsl spec only guarantees 16 bits of\n // precision for highp floats. We need more than that.\n //\n // The pixel_coord is passed in as two 16 bit values:\n // pixel_coord_upper = floor(pixel_coord / 2^16)\n // pixel_coord_lower = mod(pixel_coord, 2^16)\n //\n // The offset is calculated in a series of steps that should preserve this precision:\n vec2 offset_a = mod(mod(mod(u_pixel_coord_upper, scaled_size_a) * 256.0, scaled_size_a) * 256.0 + u_pixel_coord_lower, scaled_size_a);\n vec2 offset_b = mod(mod(mod(u_pixel_coord_upper, scaled_size_b) * 256.0, scaled_size_b) * 256.0 + u_pixel_coord_lower, scaled_size_b);\n\n v_pos_a = (u_tile_units_to_pixels * a_pos + offset_a) / scaled_size_a;\n v_pos_b = (u_tile_units_to_pixels * a_pos + offset_b) / scaled_size_b;\n\n v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;\n}\n"},pattern:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform float u_opacity;\nuniform vec2 u_pattern_tl_a;\nuniform vec2 u_pattern_br_a;\nuniform vec2 u_pattern_tl_b;\nuniform vec2 u_pattern_br_b;\nuniform float u_mix;\n\nuniform sampler2D u_image;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\nvoid main() {\n\n vec2 imagecoord = mod(v_pos_a, 1.0);\n vec2 pos = mix(u_pattern_tl_a, u_pattern_br_a, imagecoord);\n vec4 color1 = texture2D(u_image, pos);\n\n vec2 imagecoord_b = mod(v_pos_b, 1.0);\n vec2 pos2 = mix(u_pattern_tl_b, u_pattern_br_b, imagecoord_b);\n vec4 color2 = texture2D(u_image, pos2);\n\n gl_FragColor = mix(color1, color2, u_mix) * u_opacity;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform mat4 u_matrix;\nuniform vec2 u_pattern_size_a;\nuniform vec2 u_pattern_size_b;\nuniform vec2 u_pixel_coord_upper;\nuniform vec2 u_pixel_coord_lower;\nuniform float u_scale_a;\nuniform float u_scale_b;\nuniform float u_tile_units_to_pixels;\n\nattribute vec2 a_pos;\n\nvarying vec2 v_pos_a;\nvarying vec2 v_pos_b;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n vec2 scaled_size_a = u_scale_a * u_pattern_size_a;\n vec2 scaled_size_b = u_scale_b * u_pattern_size_b;\n\n // the correct offset needs to be calculated.\n //\n // The offset depends on how many pixels are between the world origin and\n // the edge of the tile:\n // vec2 offset = mod(pixel_coord, size)\n //\n // At high zoom levels there are a ton of pixels between the world origin\n // and the edge of the tile. The glsl spec only guarantees 16 bits of\n // precision for highp floats. We need more than that.\n //\n // The pixel_coord is passed in as two 16 bit values:\n // pixel_coord_upper = floor(pixel_coord / 2^16)\n // pixel_coord_lower = mod(pixel_coord, 2^16)\n //\n // The offset is calculated in a series of steps that should preserve this precision:\n vec2 offset_a = mod(mod(mod(u_pixel_coord_upper, scaled_size_a) * 256.0, scaled_size_a) * 256.0 + u_pixel_coord_lower, scaled_size_a);\n vec2 offset_b = mod(mod(mod(u_pixel_coord_upper, scaled_size_b) * 256.0, scaled_size_b) * 256.0 + u_pixel_coord_lower, scaled_size_b);\n\n v_pos_a = (u_tile_units_to_pixels * a_pos + offset_a) / scaled_size_a;\n v_pos_b = (u_tile_units_to_pixels * a_pos + offset_b) / scaled_size_b;\n}\n"},raster:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform float u_opacity0;\nuniform float u_opacity1;\nuniform sampler2D u_image0;\nuniform sampler2D u_image1;\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nuniform float u_brightness_low;\nuniform float u_brightness_high;\n\nuniform float u_saturation_factor;\nuniform float u_contrast_factor;\nuniform vec3 u_spin_weights;\n\nvoid main() {\n\n // read and cross-fade colors from the main and parent tiles\n vec4 color0 = texture2D(u_image0, v_pos0);\n vec4 color1 = texture2D(u_image1, v_pos1);\n vec4 color = color0 * u_opacity0 + color1 * u_opacity1;\n vec3 rgb = color.rgb;\n\n // spin\n rgb = vec3(\n dot(rgb, u_spin_weights.xyz),\n dot(rgb, u_spin_weights.zxy),\n dot(rgb, u_spin_weights.yzx));\n\n // saturation\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * u_saturation_factor;\n\n // contrast\n rgb = (rgb - 0.5) * u_contrast_factor + 0.5;\n\n // brightness\n vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);\n vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);\n\n gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb), color.a);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform mat4 u_matrix;\nuniform vec2 u_tl_parent;\nuniform float u_scale_parent;\nuniform float u_buffer_scale;\n\nattribute vec2 a_pos;\nattribute vec2 a_texture_pos;\n\nvarying vec2 v_pos0;\nvarying vec2 v_pos1;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n v_pos0 = (((a_texture_pos / 32767.0) - 0.5) / u_buffer_scale ) + 0.5;\n v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;\n}\n"},icon:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform sampler2D u_texture;\nuniform sampler2D u_fadetexture;\nuniform lowp float u_opacity;\n\nvarying vec2 v_tex;\nvarying vec2 v_fade_tex;\n\nvoid main() {\n lowp float alpha = texture2D(u_fadetexture, v_fade_tex).a * u_opacity;\n gl_FragColor = texture2D(u_texture, v_tex) * alpha;\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nattribute vec2 a_pos;\nattribute vec2 a_offset;\nattribute vec2 a_texture_pos;\nattribute vec4 a_data;\n\n\n// matrix is for the vertex position.\nuniform mat4 u_matrix;\n\nuniform mediump float u_zoom;\nuniform bool u_rotate_with_map;\nuniform vec2 u_extrude_scale;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying vec2 v_fade_tex;\n\nvoid main() {\n vec2 a_tex = a_texture_pos.xy;\n mediump float a_labelminzoom = a_data[0];\n mediump vec2 a_zoom = a_data.pq;\n mediump float a_minzoom = a_zoom[0];\n mediump float a_maxzoom = a_zoom[1];\n\n // u_zoom is the current zoom level adjusted for the change in font size\n mediump float z = 2.0 - step(a_minzoom, u_zoom) - (1.0 - step(a_maxzoom, u_zoom));\n\n vec2 extrude = u_extrude_scale * (a_offset / 64.0);\n if (u_rotate_with_map) {\n gl_Position = u_matrix * vec4(a_pos + extrude, 0, 1);\n gl_Position.z += z * gl_Position.w;\n } else {\n gl_Position = u_matrix * vec4(a_pos, 0, 1) + vec4(extrude, 0, 0);\n }\n\n v_tex = a_tex / u_texsize;\n v_fade_tex = vec2(a_labelminzoom / 255.0, 0.0);\n}\n"},sdf:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform sampler2D u_texture;\nuniform sampler2D u_fadetexture;\nuniform lowp vec4 u_color;\nuniform lowp float u_opacity;\nuniform lowp float u_buffer;\nuniform lowp float u_gamma;\n\nvarying vec2 v_tex;\nvarying vec2 v_fade_tex;\nvarying float v_gamma_scale;\n\nvoid main() {\n lowp float dist = texture2D(u_texture, v_tex).a;\n lowp float fade_alpha = texture2D(u_fadetexture, v_fade_tex).a;\n lowp float gamma = u_gamma * v_gamma_scale;\n lowp float alpha = smoothstep(u_buffer - gamma, u_buffer + gamma, dist) * fade_alpha;\n\n gl_FragColor = u_color * (alpha * u_opacity);\n\n#ifdef OVERDRAW_INSPECTOR\n gl_FragColor = vec4(1.0);\n#endif\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nconst float PI = 3.141592653589793;\n\nattribute vec2 a_pos;\nattribute vec2 a_offset;\nattribute vec2 a_texture_pos;\nattribute vec4 a_data;\n\n\n// matrix is for the vertex position.\nuniform mat4 u_matrix;\n\nuniform mediump float u_zoom;\nuniform bool u_rotate_with_map;\nuniform bool u_pitch_with_map;\nuniform mediump float u_pitch;\nuniform mediump float u_bearing;\nuniform mediump float u_aspect_ratio;\nuniform vec2 u_extrude_scale;\n\nuniform vec2 u_texsize;\n\nvarying vec2 v_tex;\nvarying vec2 v_fade_tex;\nvarying float v_gamma_scale;\n\nvoid main() {\n vec2 a_tex = a_texture_pos.xy;\n mediump float a_labelminzoom = a_data[0];\n mediump vec2 a_zoom = a_data.pq;\n mediump float a_minzoom = a_zoom[0];\n mediump float a_maxzoom = a_zoom[1];\n\n // u_zoom is the current zoom level adjusted for the change in font size\n mediump float z = 2.0 - step(a_minzoom, u_zoom) - (1.0 - step(a_maxzoom, u_zoom));\n\n // pitch-alignment: map\n // rotation-alignment: map | viewport\n if (u_pitch_with_map) {\n lowp float angle = u_rotate_with_map ? (a_data[1] / 256.0 * 2.0 * PI) : u_bearing;\n lowp float asin = sin(angle);\n lowp float acos = cos(angle);\n mat2 RotationMatrix = mat2(acos, asin, -1.0 * asin, acos);\n vec2 offset = RotationMatrix * a_offset;\n vec2 extrude = u_extrude_scale * (offset / 64.0);\n gl_Position = u_matrix * vec4(a_pos + extrude, 0, 1);\n gl_Position.z += z * gl_Position.w;\n // pitch-alignment: viewport\n // rotation-alignment: map\n } else if (u_rotate_with_map) {\n // foreshortening factor to apply on pitched maps\n // as a label goes from horizontal <=> vertical in angle\n // it goes from 0% foreshortening to up to around 70% foreshortening\n lowp float pitchfactor = 1.0 - cos(u_pitch * sin(u_pitch * 0.75));\n\n lowp float lineangle = a_data[1] / 256.0 * 2.0 * PI;\n\n // use the lineangle to position points a,b along the line\n // project the points and calculate the label angle in projected space\n // this calculation allows labels to be rendered unskewed on pitched maps\n vec4 a = u_matrix * vec4(a_pos, 0, 1);\n vec4 b = u_matrix * vec4(a_pos + vec2(cos(lineangle),sin(lineangle)), 0, 1);\n lowp float angle = atan((b[1]/b[3] - a[1]/a[3])/u_aspect_ratio, b[0]/b[3] - a[0]/a[3]);\n lowp float asin = sin(angle);\n lowp float acos = cos(angle);\n mat2 RotationMatrix = mat2(acos, -1.0 * asin, asin, acos);\n\n vec2 offset = RotationMatrix * (vec2((1.0-pitchfactor)+(pitchfactor*cos(angle*2.0)), 1.0) * a_offset);\n vec2 extrude = u_extrude_scale * (offset / 64.0);\n gl_Position = u_matrix * vec4(a_pos, 0, 1) + vec4(extrude, 0, 0);\n gl_Position.z += z * gl_Position.w;\n // pitch-alignment: viewport\n // rotation-alignment: viewport\n } else {\n vec2 extrude = u_extrude_scale * (a_offset / 64.0);\n gl_Position = u_matrix * vec4(a_pos, 0, 1) + vec4(extrude, 0, 0);\n }\n\n v_gamma_scale = (gl_Position.w - 0.5);\n\n v_tex = a_tex / u_texsize;\n v_fade_tex = vec2(a_labelminzoom / 255.0, 0.0);\n}\n"},collisionbox:{fragmentSource:"#ifdef GL_ES\nprecision mediump float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nuniform float u_zoom;\nuniform float u_maxzoom;\n\nvarying float v_max_zoom;\nvarying float v_placement_zoom;\n\nvoid main() {\n\n float alpha = 0.5;\n\n gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0) * alpha;\n\n if (v_placement_zoom > u_zoom) {\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha;\n }\n\n if (u_zoom >= v_max_zoom) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0) * alpha * 0.25;\n }\n\n if (v_placement_zoom >= u_maxzoom) {\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0) * alpha * 0.2;\n }\n}\n",vertexSource:"#ifdef GL_ES\nprecision highp float;\n#else\n#define lowp\n#define mediump\n#define highp\n#endif\n\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute vec2 a_data;\n\nuniform mat4 u_matrix;\nuniform float u_scale;\n\nvarying float v_max_zoom;\nvarying float v_placement_zoom;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos + a_extrude / u_scale, 0.0, 1.0);\n\n v_max_zoom = a_data.x;\n v_placement_zoom = a_data.y;\n}\n"}},e.exports.util="float evaluate_zoom_function_1(const vec4 values, const float t) {\n if (t < 1.0) {\n return mix(values[0], values[1], t);\n } else if (t < 2.0) {\n return mix(values[1], values[2], t - 1.0);\n } else {\n return mix(values[2], values[3], t - 2.0);\n }\n}\nvec4 evaluate_zoom_function_4(const vec4 value0, const vec4 value1, const vec4 value2, const vec4 value3, const float t) {\n if (t < 1.0) {\n return mix(value0, value1, t);\n } else if (t < 2.0) {\n return mix(value1, value2, t - 1.0);\n } else {\n return mix(value2, value3, t - 2.0);\n }\n}\n"},{path:477}],305:[function(t,e,r){"use strict";var n=t("util").format;e.exports=function(t,e){this.message=(t?t+": ":"")+n.apply(n,Array.prototype.slice.call(arguments,2)),null!==e&&void 0!==e&&e.__line__&&(this.line=e.__line__)}},{util:558}],306:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1;e7)return[new n(u,l,"constants have been deprecated as of v8")];if(!(l in f.constants))return[new n(u,l,'constant "%s" not found',l)];e=a({},e,{value:f.constants[l]})}return c.function&&"object"===i(l)?r(e):c.type&&s[c.type]?s[c.type](e):o(a({},e,{valueSpec:c.type?h[c.type]:c}))}},{"../error/validation_error":305,"../util/extend":306,"../util/get_type":307,"./validate_array":310,"./validate_boolean":311,"./validate_color":312,"./validate_constants":313,"./validate_enum":314,"./validate_filter":315,"./validate_function":316,"./validate_layer":318,"./validate_number":320,"./validate_object":321,"./validate_source":323,"./validate_string":324}],310:[function(t,e,r){"use strict";var n=t("../util/get_type"),i=t("./validate"),a=t("../error/validation_error");e.exports=function(t){var e=t.value,r=t.valueSpec,o=t.style,s=t.styleSpec,l=t.key,c=t.arrayElementValidator||i;if("array"!==n(e))return[new a(l,e,"array expected, %s found",n(e))];if(r.length&&e.length!==r.length)return[new a(l,e,"array length %d expected, length %d found",r.length,e.length)];if(r["min-length"]&&e.length7)return r?[new n(e,r,"constants have been deprecated as of v8")]:[];var a=i(r);if("object"!==a)return[new n(e,r,"object expected, %s found",a)];var o=[];for(var s in r)"@"!==s[0]&&o.push(new n(e+"."+s,r[s],'constants must start with "@"'));return o}},{"../error/validation_error":305,"../util/get_type":307}],314:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("../util/unbundle_jsonlint");e.exports=function(t){var e=t.key,r=t.value,a=t.valueSpec,o=[];return-1===a.values.indexOf(i(r))&&o.push(new n(e,r,"expected one of [%s], %s found",a.values.join(", "),r)),o}},{"../error/validation_error":305,"../util/unbundle_jsonlint":308}],315:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("./validate_enum"),a=t("../util/get_type"),o=t("../util/unbundle_jsonlint");e.exports=function t(e){var r,s=e.value,l=e.key,c=e.styleSpec,u=[];if("array"!==a(s))return[new n(l,s,"array expected, %s found",a(s))];if(s.length<1)return[new n(l,s,"filter array must have at least 1 element")];switch(u=u.concat(i({key:l+"[0]",value:s[0],valueSpec:c.filter_operator,style:e.style,styleSpec:e.styleSpec})),o(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"==s[1]&&u.push(new n(l,s,'"$type" cannot be use with operator "%s"',s[0]));case"==":case"!=":3!=s.length&&u.push(new n(l,s,'filter array for operator "%s" must have 3 elements',s[0]));case"in":case"!in":s.length>=2&&("string"!==(r=a(s[1]))?u.push(new n(l+"[1]",s[1],"string expected, %s found",r)):"@"===s[1][0]&&u.push(new n(l+"[1]",s[1],"filter key cannot be a constant")));for(var h=2;h=8&&(h&&!t.valueSpec["property-function"]?d.push(new n(t.key,t.value,"property functions not supported")):f&&!t.valueSpec["zoom-function"]&&d.push(new n(t.key,t.value,"zoom functions not supported"))),d}},{"../error/validation_error":305,"../util/get_type":307,"./validate":309,"./validate_array":310,"./validate_number":320,"./validate_object":321}],317:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("./validate_string");e.exports=function(t){var e=t.value,r=t.key,a=i(t);return a.length?a:(-1===e.indexOf("{fontstack}")&&a.push(new n(r,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&a.push(new n(r,e,'"glyphs" url must include a "{range}" token')),a)}},{"../error/validation_error":305,"./validate_string":324}],318:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("../util/unbundle_jsonlint"),a=t("./validate_object"),o=t("./validate_filter"),s=t("./validate_paint_property"),l=t("./validate_layout_property"),c=t("../util/extend");e.exports=function(t){var e=[],r=t.value,u=t.key,h=t.style,f=t.styleSpec;r.type||r.ref||e.push(new n(u,r,'either "type" or "ref" is required'));var d=i(r.type),p=i(r.ref);if(r.id)for(var m=0;ma.maximum?[new i(e,r,"%s is greater than the maximum value %s",r,a.maximum)]:[]}},{"../error/validation_error":305,"../util/get_type":307}],321:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("../util/get_type"),a=t("./validate");e.exports=function(t){var e=t.key,r=t.value,o=t.valueSpec,s=t.objectElementValidators||{},l=t.style,c=t.styleSpec,u=[],h=i(r);if("object"!==h)return[new n(e,r,"object expected, %s found",h)];for(var f in r){var d=f.split(".")[0],p=o&&(o[d]||o["*"]),m=s[d]||s["*"];p||m?u=u.concat((m||a)({key:(e?e+".":e)+f,value:r[f],valueSpec:p,style:l,styleSpec:c,object:r,objectKey:f})):""!==e&&1!==e.split(".").length&&u.push(new n(e,r[f],'unknown property "%s"',f))}for(d in o)o[d].required&&void 0===o[d].default&&void 0===r[d]&&u.push(new n(e,r,'missing required property "%s"',d));return u}},{"../error/validation_error":305,"../util/get_type":307,"./validate":309}],322:[function(t,e,r){"use strict";var n=t("./validate"),i=t("../error/validation_error");e.exports=function(t){var e=t.key,r=t.style,a=t.styleSpec,o=t.value,s=t.objectKey,l=a["paint_"+t.layerType],c=s.match(/^(.*)-transition$/);return c&&l[c[1]]&&l[c[1]].transition?n({key:e,value:o,valueSpec:a.transition,style:r,styleSpec:a}):t.valueSpec||l[s]?n({key:t.key,value:o,valueSpec:t.valueSpec||l[s],style:r,styleSpec:a}):[new i(e,o,'unknown property "%s"',s)]}},{"../error/validation_error":305,"./validate":309}],323:[function(t,e,r){"use strict";var n=t("../error/validation_error"),i=t("../util/unbundle_jsonlint"),a=t("./validate_object"),o=t("./validate_enum");e.exports=function(t){var e=t.value,r=t.key,s=t.styleSpec,l=t.style;if(!e.type)return[new n(r,e,'"type" is required')];switch(i(e.type)){case"vector":case"raster":var c=[];if(c=c.concat(a({key:r,value:e,valueSpec:s.source_tile,style:t.style,styleSpec:s})),"url"in e)for(var u in e)["type","url","tileSize"].indexOf(u)<0&&c.push(new n(r+"."+u,e[u],'a source with a "url" property may not include a "%s" property',u));return c;case"geojson":return a({key:r,value:e,valueSpec:s.source_geojson,style:l,styleSpec:s});case"video":return a({key:r,value:e,valueSpec:s.source_video,style:l,styleSpec:s});case"image":return a({key:r,value:e,valueSpec:s.source_image,style:l,styleSpec:s});default:return o({key:r+".type",value:e.type,valueSpec:{values:["vector","raster","geojson","video","image"]},style:l,styleSpec:s})}}},{"../error/validation_error":305,"../util/unbundle_jsonlint":308,"./validate_enum":314,"./validate_object":321}],324:[function(t,e,r){"use strict";var n=t("../util/get_type"),i=t("../error/validation_error");e.exports=function(t){var e=t.value,r=t.key,a=n(e);return"string"!==a?[new i(r,e,"string expected, %s found",a)]:[]}},{"../error/validation_error":305,"../util/get_type":307}],325:[function(t,e,r){"use strict";function n(t,e){e=e||l;var r=[];return r=r.concat(s({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:c}})),e.$version>7&&t.constants&&(r=r.concat(o({key:"constants",value:t.constants,style:t,styleSpec:e}))),i(r)}function i(t){return[].concat(t).sort(function(t,e){return t.line-e.line})}function a(t){return function(){return i(t.apply(this,arguments))}}var o=t("./validate/validate_constants"),s=t("./validate/validate"),l=t("../reference/latest.min"),c=t("./validate/validate_glyphs_url");n.source=a(t("./validate/validate_source")),n.layer=a(t("./validate/validate_layer")),n.filter=a(t("./validate/validate_filter")),n.paintProperty=a(t("./validate/validate_paint_property")),n.layoutProperty=a(t("./validate/validate_layout_property")),e.exports=n},{"../reference/latest.min":326,"./validate/validate":309,"./validate/validate_constants":313,"./validate/validate_filter":315,"./validate/validate_glyphs_url":317,"./validate/validate_layer":318,"./validate/validate_layout_property":319,"./validate/validate_paint_property":322,"./validate/validate_source":323}],326:[function(t,e,r){e.exports=t("./v8.min.json")},{"./v8.min.json":327}],327:[function(t,e,r){e.exports={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_tile","source_geojson","source_video","source_image"],source_tile:{type:{required:!0,type:"enum",values:["vector","raster"]},url:{type:"string"},tiles:{type:"array",value:"string"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:["geojson"]},data:{type:"*"},maxzoom:{type:"number",default:14},buffer:{type:"number",default:64},tolerance:{type:"number",default:3},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:400},clusterMaxZoom:{type:"number"}},source_video:{type:{required:!0,type:"enum",values:["video"]},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:["image"]},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:["fill","line","symbol","circle","raster","background"]},metadata:{type:"*"},ref:{type:"string"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:22},maxzoom:{type:"number",minimum:0,maximum:22},interactive:{type:"boolean",default:!1},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"},"paint.*":{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_symbol","layout_raster","layout_background"],layout_background:{visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},layout_fill:{visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},layout_circle:{visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},layout_line:{"line-cap":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["butt","round","square"],default:"butt"},"line-join":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["bevel","round","miter"],default:"miter"},"line-miter-limit":{type:"number",default:2,function:"interpolated","zoom-function":!0,"property-function":!0,requires:[{"line-join":"miter"}]},"line-round-limit":{type:"number",default:1.05,function:"interpolated","zoom-function":!0,"property-function":!0,requires:[{"line-join":"round"}]},visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},layout_symbol:{"symbol-placement":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["point","line"],default:"point"},"symbol-spacing":{type:"number",default:250,minimum:1,function:"interpolated","zoom-function":!0,"property-function":!0,units:"pixels",requires:[{"symbol-placement":"line"}]},"symbol-avoid-edges":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1},"icon-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["icon-image"]},"icon-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["icon-image"]},"icon-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["icon-image","text-field"]},"icon-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"viewport",requires:["icon-image"]},"icon-size":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"icon-text-fit":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!1,values:["none","both","width","height"],default:"none",requires:["icon-image","text-field"]},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image","icon-text-fit","text-field"]},"icon-image":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,tokens:!0},"icon-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,"property-function":!0,units:"degrees",requires:["icon-image"]},"icon-padding":{type:"number",default:2,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,units:"pixels",requires:["icon-image"]},"icon-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":"line"}]},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,requires:["icon-image"]},"text-pitch-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],requires:["text-field"]},"text-rotation-alignment":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"viewport",requires:["text-field"]},"text-field":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:"",tokens:!0},"text-font":{type:"array",value:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"]},"text-size":{type:"number",default:16,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-max-width":{type:"number",default:10,minimum:0,units:"em",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-line-height":{type:"number",default:1.2,units:"em",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-letter-spacing":{type:"number",default:0,units:"em",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-justify":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["left","center","right"],default:"center",requires:["text-field"]},"text-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"],default:"center",requires:["text-field"]},"text-max-angle":{type:"number",default:45,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field",{"symbol-placement":"line"}]},"text-rotate":{type:"number",default:0,period:360,units:"degrees",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",function:"interpolated","zoom-function":!0,"property-function":!0,requires:["text-field"]},"text-keep-upright":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":"line"}]},"text-transform":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["none","uppercase","lowercase"],default:"none",requires:["text-field"]},"text-offset":{type:"array",value:"number",units:"ems",function:"interpolated","zoom-function":!0,"property-function":!0,length:2,default:[0,0],requires:["text-field"]},"text-allow-overlap":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["text-field"]},"text-ignore-placement":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["text-field"]},"text-optional":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!1,requires:["text-field","icon-image"]},visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},layout_raster:{visibility:{type:"enum",function:"piecewise-constant","zoom-function":!0,values:["visible","none"],default:"visible"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:["==","!=",">",">=","<","<=","in","!in","all","any","none","has","!has"]},geometry_type:{type:"enum",values:["Point","LineString","Polygon"]},color_operation:{type:"enum",values:["lighten","saturate","spin","fade","mix"]},function:{stops:{type:"array",required:!0,value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:["exponential","interval","categorical"],default:"exponential"}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},paint:["paint_fill","paint_line","paint_circle","paint_symbol","paint_raster","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",function:"piecewise-constant","zoom-function":!0,"property-function":!0,default:!0},"fill-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"fill-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"}]},"fill-outline-color":{type:"color",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}]},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"fill-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map",requires:["fill-translate"]},"fill-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,transition:!0}},paint_line:{"line-opacity":{type:"number",function:"interpolated","zoom-function":!0,"property-function":!0,default:1,minimum:0,maximum:1,transition:!0},"line-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:[{"!":"line-pattern"}]},"line-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map",requires:["line-translate"]},"line-width":{type:"number",default:1,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-gap-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-offset":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"line-dasharray":{type:"array",value:"number",function:"piecewise-constant","zoom-function":!0,"property-function":!0,minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}]},"line-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,"property-function":!0,transition:!0}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-blur":{type:"number",default:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels"},"circle-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map",requires:["circle-translate"]},"circle-pitch-scale":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["icon-image"]},"icon-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["icon-image"]},"icon-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map",requires:["icon-image","icon-translate"]},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,requires:["text-field"]},"text-halo-width":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-halo-blur":{type:"number",default:0,minimum:0,function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate":{type:"array",value:"number",length:2,default:[0,0],function:"interpolated","zoom-function":!0,"property-function":!0,transition:!0,units:"pixels",requires:["text-field"]},"text-translate-anchor":{type:"enum",function:"piecewise-constant","zoom-function":!0,"property-function":!0,values:["map","viewport"],default:"map",requires:["text-field","text-translate"]}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-hue-rotate":{type:"number",default:0,period:360,function:"interpolated","zoom-function":!0,transition:!0,units:"degrees"},"raster-brightness-min":{type:"number",function:"interpolated","zoom-function":!0,default:0,minimum:0,maximum:1,transition:!0},"raster-brightness-max":{type:"number",function:"interpolated","zoom-function":!0,default:1,minimum:0,maximum:1,transition:!0},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,function:"interpolated","zoom-function":!0,transition:!0},"raster-fade-duration":{type:"number",default:300,minimum:0,function:"interpolated","zoom-function":!0,transition:!0,units:"milliseconds"}},paint_background:{"background-color":{type:"color",default:"#000000",function:"interpolated","zoom-function":!0,transition:!0,requires:[{"!":"background-pattern"}]},"background-pattern":{type:"string",function:"piecewise-constant","zoom-function":!0,transition:!0},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,function:"interpolated","zoom-function":!0,transition:!0}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}}}},{}],328:[function(t,e,r){"use strict";function n(t){return!!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&"Worker"in window&&"Uint8ClampedArray"in window&&function(t){void 0===i[t]&&(i[t]=function(t){var e=document.createElement("canvas"),r=Object.create(n.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,e.probablySupportsContext?e.probablySupportsContext("webgl",r)||e.probablySupportsContext("experimental-webgl",r):e.supportsContext?e.supportsContext("webgl",r)||e.supportsContext("experimental-webgl",r):e.getContext("webgl",r)||e.getContext("experimental-webgl",r)}(t));return i[t]}(t&&t.failIfMajorPerformanceCaveat))}void 0!==e&&e.exports?e.exports=n:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=n);var i={};n.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}},{}],329:[function(t,e,r){"use strict";function n(t){var e=t.layoutVertexArrayType;this.layoutVertexArray=new e;var r=t.elementArrayType;r&&(this.elementArray=new r);var n=t.elementArrayType2;n&&(this.elementArray2=new n),this.paintVertexArrays=i.mapObject(t.paintVertexArrayTypes,function(t){return new t})}var i=t("../util/util");e.exports=n,n.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,n.prototype.hasCapacityFor=function(t){return this.layoutVertexArray.length+t<=n.MAX_VERTEX_ARRAY_LENGTH},n.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},n.prototype.trim=function(){this.layoutVertexArray.trim(),this.elementArray&&this.elementArray.trim(),this.elementArray2&&this.elementArray2.trim();for(var t in this.paintVertexArrays)this.paintVertexArrays[t].trim()},n.prototype.serialize=function(){return{layoutVertexArray:this.layoutVertexArray.serialize(),elementArray:this.elementArray&&this.elementArray.serialize(),elementArray2:this.elementArray2&&this.elementArray2.serialize(),paintVertexArrays:i.mapObject(this.paintVertexArrays,function(t){return t.serialize()})}},n.prototype.getTransferables=function(t){t.push(this.layoutVertexArray.arrayBuffer),this.elementArray&&t.push(this.elementArray.arrayBuffer),this.elementArray2&&t.push(this.elementArray2.arrayBuffer);for(var e in this.paintVertexArrays)t.push(this.paintVertexArrays[e].arrayBuffer)}},{"../util/util":443}],330:[function(t,e,r){"use strict";function n(t){if(this.zoom=t.zoom,this.overscaling=t.overscaling,this.layer=t.layer,this.childLayers=t.childLayers,this.type=this.layer.type,this.features=[],this.id=this.layer.id,this.index=t.index,this.sourceLayer=this.layer.sourceLayer,this.sourceLayerIndex=t.sourceLayerIndex,this.minZoom=this.layer.minzoom,this.maxZoom=this.layer.maxzoom,this.paintAttributes=function(t){var e={};for(var r in t.programInterfaces){for(var n=e[r]={},a=0;a1?p.name+x:p.name]=m[x]*g}}},n.VertexArrayType=function(t){return new c({members:t,alignment:4})},n.ElementArrayType=function(t){return new c({members:[{type:"Uint16",name:"vertices",components:t||3}]})}},{"../util/struct_array":441,"../util/util":443,"./array_group":329,"./bucket/circle_bucket":331,"./bucket/fill_bucket":332,"./bucket/line_bucket":333,"./bucket/symbol_bucket":334,"./buffer_group":336,assert:48,"feature-filter":133}],331:[function(t,e,r){"use strict";function n(){i.apply(this,arguments)}var i=t("../bucket"),a=t("../../util/util"),o=t("../load_geometry"),s=i.EXTENT;e.exports=n,(n.prototype=a.inherit(i,{})).addCircleVertex=function(t,e,r,n,i){return t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)},n.prototype.programInterfaces={circle:{layoutVertexArrayType:new i.VertexArrayType([{name:"a_pos",components:2,type:"Int16"}]),elementArrayType:new i.ElementArrayType,paintAttributes:[{name:"a_color",components:4,type:"Uint8",getValue:function(t,e,r){return t.getPaintValue("circle-color",e,r)},multiplier:255,paintProperty:"circle-color"},{name:"a_radius",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(t,e,r){return[t.getPaintValue("circle-radius",e,r)]},multiplier:10,paintProperty:"circle-radius"},{name:"a_blur",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(t,e,r){return[t.getPaintValue("circle-blur",e,r)]},multiplier:10,paintProperty:"circle-blur"},{name:"a_opacity",components:1,type:"Uint16",isLayerConstant:!1,getValue:function(t,e,r){return[t.getPaintValue("circle-opacity",e,r)]},multiplier:255,paintProperty:"circle-opacity"}]}},n.prototype.addFeature=function(t){for(var e={zoom:this.zoom},r=o(t),n=this.prepareArrayGroup("circle",0),i=n.layoutVertexArray.length,a=0;a=s||u<0||u>=s)){var h=this.prepareArrayGroup("circle",4),f=h.layoutVertexArray,d=this.addCircleVertex(f,c,u,-1,-1);this.addCircleVertex(f,c,u,1,-1),this.addCircleVertex(f,c,u,1,1),this.addCircleVertex(f,c,u,-1,1),h.elementArray.emplaceBack(d,d+1,d+2),h.elementArray.emplaceBack(d,d+3,d+2)}}this.populatePaintArrays("circle",e,t.properties,n,i)}},{"../../util/util":443,"../bucket":330,"../load_geometry":338}],332:[function(t,e,r){"use strict";function n(){i.apply(this,arguments)}var i=t("../bucket"),a=t("../../util/util"),o=t("../load_geometry"),s=t("earcut"),l=t("../../util/classify_rings");e.exports=n,(n.prototype=a.inherit(i,{})).programInterfaces={fill:{layoutVertexArrayType:new i.VertexArrayType([{name:"a_pos",components:2,type:"Int16"}]),elementArrayType:new i.ElementArrayType(1),elementArrayType2:new i.ElementArrayType(2),paintAttributes:[{name:"a_color",components:4,type:"Uint8",getValue:function(t,e,r){return t.getPaintValue("fill-color",e,r)},multiplier:255,paintProperty:"fill-color"},{name:"a_outline_color",components:4,type:"Uint8",getValue:function(t,e,r){return t.getPaintValue("fill-outline-color",e,r)},multiplier:255,paintProperty:"fill-outline-color"},{name:"a_opacity",components:1,type:"Uint8",getValue:function(t,e,r){return[t.getPaintValue("fill-opacity",e,r)]},multiplier:255,paintProperty:"fill-opacity"}]}},n.prototype.addFeature=function(t){for(var e=o(t),r=l(e,500),n=this.prepareArrayGroup("fill",0),i=n.layoutVertexArray.length,a=0;a0&&a.push(i.length/2);for(var u=0;u=1&&n.elementArray2.emplaceBack(f-1,f),i.push(h.x),i.push(h.y)}}for(var d=s(i,a),p=0;p>6)},n.prototype.programInterfaces={line:{layoutVertexArrayType:new i.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}]),elementArrayType:new i.ElementArrayType}},n.prototype.addFeature=function(t){for(var e=o(t,15),r=0;r2&&t[a-1].equals(t[a-2]);)a--;if(!(t.length<2)){"bevel"===e&&(n=1.05);var o=s/(512*this.overscaling)*15,c=t[0],u=t[a-1],h=c.equals(u);if(this.prepareArrayGroup("line",10*a),2!==a||!h){this.distance=0;var f,d,p,m,g,v,y,b=r,x=h?"butt":r,_=!0;this.e1=this.e2=this.e3=-1,h&&(f=t[a-2],g=c.sub(f)._unit()._perp());for(var w=0;w0){var S=f.dist(d);if(S>2*o){var E=f.sub(f.sub(d)._mult(o/S)._round());this.distance+=E.dist(d),this.addCurrentVertex(E,this.distance,m.mult(1),0,0,!1),d=E}}var L=d&&p,C=L?e:p?b:x;if(L&&"round"===C&&(Tn&&(C="bevel"),"bevel"===C&&(T>2&&(C="flipbevel"),T100)M=g.clone();else{var I=m.x*g.y-m.y*g.x>0?-1:1,P=T*m.add(g).mag()/m.sub(g).mag();M._perp()._mult(P*I)}this.addCurrentVertex(f,this.distance,M,0,0,!1),this.addCurrentVertex(f,this.distance,M.mult(-1),0,0,!1)}else if("bevel"===C||"fakeround"===C){var D=m.x*g.y-m.y*g.x>0,z=-Math.sqrt(T*T-1);if(D?(y=0,v=z):(v=0,y=z),_||this.addCurrentVertex(f,this.distance,m,v,y,!1),"fakeround"===C){for(var O,F=Math.floor(8*(.5-(k-.5))),R=0;R=0;j--)O=m.mult((j+1)/(F+1))._add(g)._unit(),this.addPieSliceVertex(f,this.distance,O,D)}p&&this.addCurrentVertex(f,this.distance,g,-v,-y,!1)}else"butt"===C?(_||this.addCurrentVertex(f,this.distance,m,0,0,!1),p&&this.addCurrentVertex(f,this.distance,g,0,0,!1)):"square"===C?(_||(this.addCurrentVertex(f,this.distance,m,1,1,!1),this.e1=this.e2=-1),p&&this.addCurrentVertex(f,this.distance,g,-1,-1,!1)):"round"===C&&(_||(this.addCurrentVertex(f,this.distance,m,0,0,!1),this.addCurrentVertex(f,this.distance,m,1,1,!0),this.e1=this.e2=-1),p&&(this.addCurrentVertex(f,this.distance,g,-1,-1,!0),this.addCurrentVertex(f,this.distance,g,0,0,!1)));if(A&&w2*o){var B=f.add(p.sub(f)._mult(o/N)._round());this.distance+=B.dist(f),this.addCurrentVertex(B,this.distance,g.mult(1),0,0,!1),f=B}}_=!1}}}},n.prototype.addCurrentVertex=function(t,e,r,n,i,a){var o,s=a?1:0,l=this.arrayGroups.line[this.arrayGroups.line.length-1],u=l.layoutVertexArray,h=l.elementArray;o=r.clone(),n&&o._sub(r.perp()._mult(n)),this.e3=this.addLineVertex(u,t,o,s,0,n,e),this.e1>=0&&this.e2>=0&&h.emplaceBack(this.e1,this.e2,this.e3),this.e1=this.e2,this.e2=this.e3,o=r.mult(-1),i&&o._sub(r.perp()._mult(i)),this.e3=this.addLineVertex(u,t,o,s,1,-i,e),this.e1>=0&&this.e2>=0&&h.emplaceBack(this.e1,this.e2,this.e3),this.e1=this.e2,this.e2=this.e3,e>c/2&&(this.distance=0,this.addCurrentVertex(t,this.distance,r,n,i,a))},n.prototype.addPieSliceVertex=function(t,e,r,n){var i=n?1:0;r=r.mult(n?-1:1);var a=this.arrayGroups.line[this.arrayGroups.line.length-1],o=a.layoutVertexArray,s=a.elementArray;this.e3=this.addLineVertex(o,t,r,0,i,0,e),this.e1>=0&&this.e2>=0&&s.emplaceBack(this.e1,this.e2,this.e3),n?this.e2=this.e3:this.e1=this.e3}},{"../../util/util":443,"../bucket":330,"../load_geometry":338}],334:[function(t,e,r){"use strict";function n(t){o.apply(this,arguments),this.showCollisionBoxes=t.showCollisionBoxes,this.overscaling=t.overscaling,this.collisionBoxArray=t.collisionBoxArray,this.symbolQuadsArray=t.symbolQuadsArray,this.symbolInstancesArray=t.symbolInstancesArray,this.sdfIcons=t.sdfIcons,this.iconsNeedLinear=t.iconsNeedLinear,this.adjustedTextSize=t.adjustedTextSize,this.adjustedIconSize=t.adjustedIconSize,this.fontstack=t.fontstack}function i(t,e,r,n,i,a,o,s,l,c,u){return t.emplaceBack(e,r,Math.round(64*n),Math.round(64*i),a/4,o/4,10*(c||0),u,10*(s||0),10*Math.min(l||25,25))}var a=t("point-geometry"),o=t("../bucket"),s=t("../../symbol/anchor"),l=t("../../symbol/get_anchors"),c=t("../../util/token"),u=t("../../symbol/quads"),h=t("../../symbol/shaping"),f=t("../../symbol/resolve_text"),d=t("../../symbol/mergelines"),p=t("../../symbol/clip_line"),m=t("../../util/util"),g=t("../load_geometry"),v=t("../../symbol/collision_feature"),y=h.shapeText,b=h.shapeIcon,x=u.getGlyphQuads,_=u.getIconQuads,w=o.EXTENT;e.exports=n,n.MAX_QUADS=65535,(n.prototype=m.inherit(o,{})).serialize=function(){var t=o.prototype.serialize.apply(this);return t.sdfIcons=this.sdfIcons,t.iconsNeedLinear=this.iconsNeedLinear,t.adjustedTextSize=this.adjustedTextSize,t.adjustedIconSize=this.adjustedIconSize,t.fontstack=this.fontstack,t};var M=new o.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_offset",components:2,type:"Int16"},{name:"a_texture_pos",components:2,type:"Uint16"},{name:"a_data",components:4,type:"Uint8"}]),k=new o.ElementArrayType;n.prototype.addCollisionBoxVertex=function(t,e,r,n,i){return t.emplaceBack(e.x,e.y,Math.round(r.x),Math.round(r.y),10*n,10*i)},n.prototype.programInterfaces={glyph:{layoutVertexArrayType:M,elementArrayType:k},icon:{layoutVertexArrayType:M,elementArrayType:k},collisionBox:{layoutVertexArrayType:new o.VertexArrayType([{name:"a_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},{name:"a_data",components:2,type:"Uint8"}])}},n.prototype.populateArrays=function(t,e,r){var n={lastIntegerZoom:1/0,lastIntegerZoomTime:0,lastZoom:0};this.adjustedTextMaxSize=this.layer.getLayoutValue("text-size",{zoom:18,zoomHistory:n}),this.adjustedTextSize=this.layer.getLayoutValue("text-size",{zoom:this.zoom+1,zoomHistory:n}),this.adjustedIconMaxSize=this.layer.getLayoutValue("icon-size",{zoom:18,zoomHistory:n}),this.adjustedIconSize=this.layer.getLayoutValue("icon-size",{zoom:this.zoom+1,zoomHistory:n});var i=512*this.overscaling;this.tilePixelRatio=w/i,this.compareText={},this.iconsNeedLinear=!1,this.symbolInstancesStartIndex=this.symbolInstancesArray.length;var a=this.layer.layout,o=this.features,s=this.textFeatures,l=.5,u=.5;switch(a["text-anchor"]){case"right":case"top-right":case"bottom-right":l=1;break;case"left":case"top-left":case"bottom-left":l=0}switch(a["text-anchor"]){case"bottom":case"bottom-right":case"bottom-left":u=1;break;case"top":case"top-right":case"top-left":u=0}for(var h="right"===a["text-justify"]?1:"left"===a["text-justify"]?0:.5,f=24*a["text-line-height"],p="line"!==a["symbol-placement"]?24*a["text-max-width"]:0,v=24*a["text-letter-spacing"],x=[24*a["text-offset"][0],24*a["text-offset"][1]],_=this.fontstack=a["text-font"].join(","),M=[],k=0;kw||L.y<0||L.y>w);if(!d||C){var I=C||x;this.addSymbolInstance(L,A,e,r,this.layer,I,this.symbolInstancesArray.length,this.collisionBoxArray,n.index,this.sourceLayerIndex,this.index,c,m,y,h,g,b,{zoom:this.zoom},n.properties)}}}},n.prototype.anchorIsTooClose=function(t,e,r){var n=this.compareText;if(t in n){for(var i=n[t],a=i.length-1;a>=0;a--)if(r.dist(i[a])3*Math.PI/2))){var g=p.tl,v=p.tr,y=p.bl,b=p.br,x=p.tex,_=p.anchorPoint,w=Math.max(h+Math.log(p.minScale)/Math.LN2,f),M=Math.min(h+Math.log(p.maxScale)/Math.LN2,25);if(!(M<=w)){w===f&&(w=0);var k=Math.round(p.glyphAngle/(2*Math.PI)*256),T=i(u,_.x,_.y,g.x,g.y,x.x,x.y,w,M,f,k);i(u,_.x,_.y,v.x,v.y,x.x+x.w,x.y,w,M,f,k),i(u,_.x,_.y,y.x,y.y,x.x,x.y+x.h,w,M,f,k),i(u,_.x,_.y,b.x,b.y,x.x+x.w,x.y+x.h,w,M,f,k),c.emplaceBack(T,T+1,T+2),c.emplaceBack(T+1,T+2,T+3)}}}},n.prototype.updateIcons=function(t){this.recalculateStyleLayers();var e=this.layer.layout["icon-image"];if(e)for(var r=0;rn.MAX_QUADS&&m.warnOnce("Too many symbols being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),T>n.MAX_QUADS&&m.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),this.symbolInstancesArray.emplaceBack(D,z,O,F,k,T,A,S,t.x,t.y,s)},n.prototype.addSymbolQuad=function(t){return this.symbolQuadsArray.emplaceBack(t.anchorPoint.x,t.anchorPoint.y,t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y,t.tex.h,t.tex.w,t.tex.x,t.tex.y,t.anchorAngle,t.glyphAngle,t.maxScale,t.minScale)}},{"../../symbol/anchor":392,"../../symbol/clip_line":394,"../../symbol/collision_feature":396,"../../symbol/get_anchors":398,"../../symbol/mergelines":401,"../../symbol/quads":402,"../../symbol/resolve_text":403,"../../symbol/shaping":404,"../../util/token":442,"../../util/util":443,"../bucket":330,"../load_geometry":338,"point-geometry":485}],335:[function(t,e,r){"use strict";function n(t,e,r){this.arrayBuffer=t.arrayBuffer,this.length=t.length,this.attributes=e.members,this.itemSize=e.bytesPerElement,this.type=r,this.arrayType=e}e.exports=n,n.prototype.bind=function(t){var e=t[this.type];this.buffer?t.bindBuffer(e,this.buffer):(this.buffer=t.createBuffer(),t.bindBuffer(e,this.buffer),t.bufferData(e,this.arrayBuffer,t.STATIC_DRAW),this.arrayBuffer=null)};var i={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT"};n.prototype.setVertexAttribPointers=function(t,e){for(var r=0;r0?t["line-gap-width"]+2*t["line-width"]:t["line-width"]}function s(t,e,r,n,i){if(!e[0]&&!e[1])return t;e=l.convert(e),"viewport"===r&&e._rotate(-n);for(var a=[],o=0;or.max||f.yr.max)&&i.warnOnce("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return l}},{"../util/util":443,"./bucket":330,assert:48}],339:[function(t,e,r){"use strict";function n(t,e,r){this.column=t,this.row=e,this.zoom=r}e.exports=n,n.prototype={clone:function(){return new n(this.column,this.row,this.zoom)},zoomTo:function(t){return this.clone()._zoomTo(t)},sub:function(t){return this.clone()._sub(t)},_zoomTo:function(t){var e=Math.pow(2,t-this.zoom);return this.column*=e,this.row*=e,this.zoom=t,this},_sub:function(t){return t=t.zoomTo(this.zoom),this.column-=t.column,this.row-=t.row,this}}},{}],340:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}e.exports=n;var i=t("../util/util").wrap;n.prototype.wrap=function(){return new n(i(this.lng,-180,180),this.lat)},n.prototype.toArray=function(){return[this.lng,this.lat]},n.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},n.convert=function(t){return t instanceof n?t:Array.isArray(t)?new n(t[0],t[1]):t}},{"../util/util":443}],341:[function(t,e,r){"use strict";function n(t,e){t&&(e?this.extend(t).extend(e):4===t.length?this.extend([t[0],t[1]]).extend([t[2],t[3]]):this.extend(t[0]).extend(t[1]))}e.exports=n;var i=t("./lng_lat");n.prototype={extend:function(t){var e,r,a=this._sw,o=this._ne;if(t instanceof i)e=t,r=t;else{if(!(t instanceof n))return t?this.extend(i.convert(t)||n.convert(t)):this;if(e=t._sw,r=t._ne,!e||!r)return this}return a||o?(a.lng=Math.min(e.lng,a.lng),a.lat=Math.min(e.lat,a.lat),o.lng=Math.max(r.lng,o.lng),o.lat=Math.max(r.lat,o.lat)):(this._sw=new i(e.lng,e.lat),this._ne=new i(r.lng,r.lat)),this},getCenter:function(){return new i((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},getSouthWest:function(){return this._sw},getNorthEast:function(){return this._ne},getNorthWest:function(){return new i(this.getWest(),this.getNorth())},getSouthEast:function(){return new i(this.getEast(),this.getSouth())},getWest:function(){return this._sw.lng},getSouth:function(){return this._sw.lat},getEast:function(){return this._ne.lng},getNorth:function(){return this._ne.lat},toArray:function(){return[this._sw.toArray(),this._ne.toArray()]},toString:function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"}},n.convert=function(t){return!t||t instanceof n?t:new n(t)}},{"./lng_lat":340}],342:[function(t,e,r){"use strict";function n(t,e){this.tileSize=512,this._minZoom=t||0,this._maxZoom=e||22,this.latRange=[-85.05113,85.05113],this.width=0,this.height=0,this._center=new i(0,0),this.zoom=0,this.angle=0,this._altitude=1.5,this._pitch=0,this._unmodified=!0}var i=t("./lng_lat"),a=t("point-geometry"),o=t("./coordinate"),s=t("../util/util").wrap,l=t("../util/interpolate"),c=t("../source/tile_coord"),u=t("../data/bucket").EXTENT,h=t("gl-matrix"),f=h.vec4,d=h.mat4,p=h.mat2;e.exports=n,n.prototype={get minZoom(){return this._minZoom},set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},get maxZoom(){return this._maxZoom},set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},get worldSize(){return this.tileSize*this.scale},get centerPoint(){return this.size._div(2)},get size(){return new a(this.width,this.height)},get bearing(){return-this.angle/Math.PI*180},set bearing(t){var e=-s(t,-180,180)*Math.PI/180;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=p.create(),p.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},get pitch(){return this._pitch/Math.PI*180},set pitch(t){var e=Math.min(60,t)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,this._calcMatrices())},get altitude(){return this._altitude},set altitude(t){var e=Math.max(.75,t);this._altitude!==e&&(this._unmodified=!1,this._altitude=e,this._calcMatrices())},get zoom(){return this._zoom},set zoom(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._calcMatrices(),this._constrain())},get center(){return this._center},set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._calcMatrices(),this._constrain())},coveringZoomLevel:function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},coveringTiles:function(t){var e=this.coveringZoomLevel(t),r=e;if(et.maxzoom&&(e=t.maxzoom);var n=this.locationCoordinate(this.center)._zoomTo(e),i=new a(n.column-.5,n.row-.5);return c.cover(e,[this.pointCoordinate(new a(0,0))._zoomTo(e),this.pointCoordinate(new a(this.width,0))._zoomTo(e),this.pointCoordinate(new a(this.width,this.height))._zoomTo(e),this.pointCoordinate(new a(0,this.height))._zoomTo(e)],t.reparseOverscaled?r:e).sort(function(t,e){return i.dist(t)-i.dist(e)})},resize:function(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._calcMatrices(),this._constrain()},get unmodified(){return this._unmodified},zoomScale:function(t){return Math.pow(2,t)},scaleZoom:function(t){return Math.log(t)/Math.LN2},project:function(t,e){return new a(this.lngX(t.lng,e),this.latY(t.lat,e))},unproject:function(t,e){return new i(this.xLng(t.x,e),this.yLat(t.y,e))},get x(){return this.lngX(this.center.lng)},get y(){return this.latY(this.center.lat)},get point(){return new a(this.x,this.y)},lngX:function(t,e){return(180+t)*(e||this.worldSize)/360},latY:function(t,e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))*(e||this.worldSize)/360},xLng:function(t,e){return 360*t/(e||this.worldSize)-180},yLat:function(t,e){var r=180-360*t/(e||this.worldSize);return 360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90},panBy:function(t){var e=this.centerPoint._add(t);this.center=this.pointLocation(e)},setLocationAtPoint:function(t,e){var r=this.locationCoordinate(t),n=this.pointCoordinate(e),i=this.pointCoordinate(this.centerPoint),a=n._sub(r);this._unmodified=!1,this.center=this.coordinateLocation(i._sub(a))},locationPoint:function(t){return this.coordinatePoint(this.locationCoordinate(t))},pointLocation:function(t){return this.coordinateLocation(this.pointCoordinate(t))},locationCoordinate:function(t){var e=this.zoomScale(this.tileZoom)/this.worldSize,r=i.convert(t);return new o(this.lngX(r.lng)*e,this.latY(r.lat)*e,this.tileZoom)},coordinateLocation:function(t){var e=this.zoomScale(t.zoom);return new i(this.xLng(t.column,e),this.yLat(t.row,e))},pointCoordinate:function(t){var e=[t.x,t.y,0,1],r=[t.x,t.y,1,1];f.transformMat4(e,e,this.pixelMatrixInverse),f.transformMat4(r,r,this.pixelMatrixInverse);var n=e[3],i=r[3],a=e[0]/n,s=r[0]/i,c=e[1]/n,u=r[1]/i,h=e[2]/n,d=r[2]/i,p=h===d?0:(0-h)/(d-h),m=this.worldSize/this.zoomScale(this.tileZoom);return new o(l(a,s,p)/m,l(c,u,p)/m,this.tileZoom)},coordinatePoint:function(t){var e=this.worldSize/this.zoomScale(t.zoom),r=[t.column*e,t.row*e,0,1];return f.transformMat4(r,r,this.pixelMatrix),new a(r[0]/r[3],r[1]/r[3])},calculatePosMatrix:function(t,e){void 0===e&&(e=1/0),t instanceof c&&(t=t.toCoordinate(e));var r=Math.min(t.zoom,e),n=this.worldSize/Math.pow(2,r),i=new Float64Array(16);return d.identity(i),d.translate(i,i,[t.column*n,t.row*n,0]),d.scale(i,i,[n/u,n/u,1]),d.multiply(i,this.projMatrix,i),new Float32Array(i)},_constrain:function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var t,e,r,n,i,o,s,l,c=this.size,u=this._unmodified;this.latRange&&(t=this.latY(this.latRange[1]),i=(e=this.latY(this.latRange[0]))-te&&(l=e-d)}if(this.lngRange){var p=this.x,m=c.x/2;p-mn&&(s=n-m)}void 0===s&&void 0===l||(this.center=this.unproject(new a(void 0!==s?s:this.x,void 0!==l?l:this.y))),this._unmodified=u,this._constraining=!1}},_calcMatrices:function(){if(this.height){var t=Math.atan(.5/this.altitude),e=Math.sin(t)*this.altitude/Math.sin(Math.PI/2-this._pitch-t),r=Math.cos(Math.PI/2-this._pitch)*e+this.altitude,n=new Float64Array(16);if(d.perspective(n,2*Math.atan(this.height/2/this.altitude),this.width/this.height,.1,r),d.translate(n,n,[0,0,-this.altitude]),d.scale(n,n,[1,-1,1/this.height]),d.rotateX(n,n,this._pitch),d.rotateZ(n,n,this.angle),d.translate(n,n,[-this.x,-this.y,0]),this.projMatrix=n,n=d.create(),d.scale(n,n,[this.width/2,-this.height/2,1]),d.translate(n,n,[1,-1,0]),this.pixelMatrix=d.multiply(new Float64Array(16),n,this.projMatrix),!(n=d.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=n}}}},{"../data/bucket":330,"../source/tile_coord":370,"../util/interpolate":437,"../util/util":443,"./coordinate":339,"./lng_lat":340,"gl-matrix":194,"point-geometry":485}],343:[function(t,e,r){"use strict";var n={" ":[16,[]],"!":[10,[5,21,5,7,-1,-1,5,2,4,1,5,0,6,1,5,2]],'"':[16,[4,21,4,14,-1,-1,12,21,12,14]],"#":[21,[11,25,4,-7,-1,-1,17,25,10,-7,-1,-1,4,12,18,12,-1,-1,3,6,17,6]],$:[20,[8,25,8,-4,-1,-1,12,25,12,-4,-1,-1,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],"%":[24,[21,21,3,0,-1,-1,8,21,10,19,10,17,9,15,7,14,5,14,3,16,3,18,4,20,6,21,8,21,10,20,13,19,16,19,19,20,21,21,-1,-1,17,7,15,6,14,4,14,2,16,0,18,0,20,1,21,3,21,5,19,7,17,7]],"&":[26,[23,12,23,13,22,14,21,14,20,13,19,11,17,6,15,3,13,1,11,0,7,0,5,1,4,2,3,4,3,6,4,8,5,9,12,13,13,14,14,16,14,18,13,20,11,21,9,20,8,18,8,16,9,13,11,10,16,3,18,1,20,0,22,0,23,1,23,2]],"'":[10,[5,19,4,20,5,21,6,20,6,18,5,16,4,15]],"(":[14,[11,25,9,23,7,20,5,16,4,11,4,7,5,2,7,-2,9,-5,11,-7]],")":[14,[3,25,5,23,7,20,9,16,10,11,10,7,9,2,7,-2,5,-5,3,-7]],"*":[16,[8,21,8,9,-1,-1,3,18,13,12,-1,-1,13,18,3,12]],"+":[26,[13,18,13,0,-1,-1,4,9,22,9]],",":[10,[6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4]],"-":[26,[4,9,22,9]],".":[10,[5,2,4,1,5,0,6,1,5,2]],"/":[22,[20,25,2,-7]],0:[20,[9,21,6,20,4,17,3,12,3,9,4,4,6,1,9,0,11,0,14,1,16,4,17,9,17,12,16,17,14,20,11,21,9,21]],1:[20,[6,17,8,18,11,21,11,0]],2:[20,[4,16,4,17,5,19,6,20,8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,10,3,0,17,0]],3:[20,[5,21,16,21,10,13,13,13,15,12,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4]],4:[20,[13,21,3,7,18,7,-1,-1,13,21,13,0]],5:[20,[15,21,5,21,4,12,5,13,8,14,11,14,14,13,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4]],6:[20,[16,18,15,20,12,21,10,21,7,20,5,17,4,12,4,7,5,3,7,1,10,0,11,0,14,1,16,3,17,6,17,7,16,10,14,12,11,13,10,13,7,12,5,10,4,7]],7:[20,[17,21,7,0,-1,-1,3,21,17,21]],8:[20,[8,21,5,20,4,18,4,16,5,14,7,13,11,12,14,11,16,9,17,7,17,4,16,2,15,1,12,0,8,0,5,1,4,2,3,4,3,7,4,9,6,11,9,12,13,13,15,14,16,16,16,18,15,20,12,21,8,21]],9:[20,[16,14,15,11,13,9,10,8,9,8,6,9,4,11,3,14,3,15,4,18,6,20,9,21,10,21,13,20,15,18,16,14,16,9,15,4,13,1,10,0,8,0,5,1,4,3]],":":[10,[5,14,4,13,5,12,6,13,5,14,-1,-1,5,2,4,1,5,0,6,1,5,2]],";":[10,[5,14,4,13,5,12,6,13,5,14,-1,-1,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4]],"<":[24,[20,18,4,9,20,0]],"=":[26,[4,12,22,12,-1,-1,4,6,22,6]],">":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]};e.exports=function(t,e,r,i){i=i||1;var a,o,s,l,c,u,h,f,d=[];for(a=0,o=t.length;a>16,_>>16),s.uniform2f(o.u_pixel_coord_lower,65535&x,65535&_)}s.uniformMatrix4fv(o.u_matrix,!1,t.transform.calculatePosMatrix(v)),s.drawArrays(s.TRIANGLE_STRIP,0,t.tileExtentBuffer.length)}s.stencilMask(0),s.stencilFunc(s.EQUAL,128,128)}},{"../source/pixels_to_tile_units":364,"./create_uniform_pragmas":345}],347:[function(t,e,r){"use strict";var n=t("../util/browser");e.exports=function(t,e,r,i){if(!t.isOpaquePass){var a=t.gl;t.setDepthSublayer(0),t.depthMask(!1),a.disable(a.STENCIL_TEST);for(var o=0;o>16,f>>16),s.uniform2f(o.u_pixel_coord_lower,65535&h,65535&f),s.activeTexture(s.TEXTURE0),a.spriteAtlas.bind(s,!0)}}var i=t("../source/pixels_to_tile_units");e.exports=function(t,e,r,i){var a=t.gl;a.enable(a.STENCIL_TEST);var o;if(o=!r.paint["fill-pattern"]&&r.isPaintValueFeatureConstant("fill-color")&&r.isPaintValueFeatureConstant("fill-opacity")&&1===r.paint["fill-color"][3]&&1===r.paint["fill-opacity"],t.isOpaquePass===o){t.setDepthSublayer(1);for(var s=0;s0?1-1/(1.001-t):-t}(r.paint["raster-saturation"])),a.uniform1f(l.u_contrast_factor,function(t){return t>0?1/(1-t):1+t}(r.paint["raster-contrast"])),a.uniform3fv(l.u_spin_weights,function(t){t*=Math.PI/180;var e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}(r.paint["raster-hue-rotate"]));var c,u,h=o.source&&o.source.findLoadedParent(n,0,{}),f=function(t,e,r,n){var a=[1,0],o=r.paint["raster-fade-duration"];if(t.source&&o>0){var s=(new Date).getTime(),l=(s-t.timeAdded)/o,c=e?(s-e.timeAdded)/o:-1,u=n.coveringZoomLevel(t.source),h=!!e&&Math.abs(e.coord.z-u)>Math.abs(t.coord.z-u);!e||h?(a[0]=i.clamp(l,0,1),a[1]=1-a[0]):(a[0]=i.clamp(1-c,0,1),a[1]=1-a[0])}var f=r.paint["raster-opacity"];return a[0]*=f,a[1]*=f,a}(o,h,r,t.transform);a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,o.texture),a.activeTexture(a.TEXTURE1),h?(a.bindTexture(a.TEXTURE_2D,h.texture),c=Math.pow(2,h.coord.z-o.coord.z),u=[o.coord.x*c%1,o.coord.y*c%1]):(a.bindTexture(a.TEXTURE_2D,o.texture),f[1]=0);a.uniform2fv(l.u_tl_parent,u||[0,0]),a.uniform1f(l.u_scale_parent,c||1),a.uniform1f(l.u_buffer_scale,1),a.uniform1f(l.u_opacity0,f[0]),a.uniform1f(l.u_opacity1,f[1]),a.uniform1i(l.u_image0,0),a.uniform1i(l.u_image1,1);var d=o.boundsBuffer||t.rasterBoundsBuffer;(o.boundsVAO||t.rasterBoundsVAO).bind(a,l,d),a.drawArrays(a.TRIANGLE_STRIP,0,d.length)}(t,e,r,l)}a.depthFunc(a.LEQUAL)}}var i=t("../util/util"),a=t("../util/struct_array");e.exports=n,n.RasterBoundsArray=new a({members:[{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]})},{"../util/struct_array":441,"../util/util":443}],353:[function(t,e,r){"use strict";function n(t,e,r,n,a,s,l,c,u,h,f,d,p,m,g){for(var v=0;vthis.previousZoom;r--)this.changeTimes[r]=e,this.changeOpacities[r]=this.opacities[r];for(r=0;r<256;r++){var n=(e-this.changeTimes[r])/this.fadeDuration*255;this.opacities[r]=r<=t?this.changeOpacities[r]+n:this.changeOpacities[r]-n}this.changed=!0,this.previousZoom=t},n.prototype.bind=function(t){this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.changed&&(t.texSubImage2D(t.TEXTURE_2D,0,0,0,256,1,t.ALPHA,t.UNSIGNED_BYTE,this.array),this.changed=!1)):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,256,1,0,t.ALPHA,t.UNSIGNED_BYTE,this.array))}},{}],355:[function(t,e,r){"use strict";function n(t,e){this.width=t,this.height=e,this.nextRow=0,this.bytes=4,this.data=new Uint8Array(this.width*this.height*this.bytes),this.positions={}}var i=t("../util/util");e.exports=n,n.prototype.setSprite=function(t){this.sprite=t},n.prototype.getDash=function(t,e){var r=t.join(",")+e;return this.positions[r]||(this.positions[r]=this.addDash(t,e)),this.positions[r]},n.prototype.addDash=function(t,e){var r=e?7:0,n=2*r+1;if(this.nextRow+n>this.height)return i.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o0?e.pop():null},n.prototype.lineWidth=function(t){this.gl.lineWidth(u.clamp(t,this.lineWidthRange[0],this.lineWidthRange[1]))},n.prototype.showOverdrawInspector=function(t){if(t||this._showOverdrawInspector){this._showOverdrawInspector=t;var e=this.gl;if(t){e.blendFunc(e.CONSTANT_COLOR,e.ONE);e.blendColor(1/8,1/8,1/8,0),e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT)}else e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}}},{"../data/bucket":330,"../data/buffer":335,"../source/pixels_to_tile_units":364,"../source/source_cache":368,"../util/browser":427,"../util/struct_array":441,"../util/util":443,"./create_uniform_pragmas":345,"./draw_background":346,"./draw_circle":347,"./draw_debug":349,"./draw_fill":350,"./draw_line":351,"./draw_raster":352,"./draw_symbol":353,"./frame_history":354,"./painter/use_program":357,"./vertex_array_object":358,"gl-matrix":194}],357:[function(t,e,r){"use strict";function n(t,e){return t.replace(/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,function(t,r,n,i,a){return e[r][a].replace(/{type}/g,i).replace(/{precision}/g,n)})}var i=t("assert"),a=t("../../util/util"),o=t("mapbox-gl-shaders"),s=o.util;e.exports._createProgram=function(t,e,r,l){for(var c=this.gl,u=c.createProgram(),h=o[t],f="#define MAPBOX_GL_JS;\n",d=0;dthis.maxzoom?Math.pow(2,t.coord.z-this.maxzoom):1,n={type:this.type,uid:t.uid,coord:t.coord,zoom:t.coord.z,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,overscaling:r,angle:this.map.transform.angle,pitch:this.map.transform.pitch,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID=this.dispatcher.send("load tile",n,function(r,n){if(t.unloadVectorData(this.map.painter),!t.aborted)return r?e(r):(t.loadVectorData(n,this.map.style),t.redoWhenDone&&(t.redoWhenDone=!1,t.redoPlacement(this)),e(null))}.bind(this),this.workerID)},abortTile:function(t){t.aborted=!0},unloadTile:function(t){t.unloadVectorData(this.map.painter),this.dispatcher.send("remove tile",{uid:t.uid,source:this.id},function(){},t.workerID)},serialize:function(){return{type:this.type,data:this._data}}})},{"../data/bucket":330,"../util/evented":435,"../util/util":443,"resolve-url":510}],360:[function(t,e,r){"use strict";function n(t,e,r){r&&(this.loadGeoJSON=r),h.call(this,t,e)}var i=t("../util/util"),a=t("../util/ajax"),o=t("geojson-rewind"),s=t("./geojson_wrapper"),l=t("vt-pbf"),c=t("supercluster"),u=t("geojson-vt"),h=t("./vector_tile_worker_source");e.exports=n,n.prototype=i.inherit(h,{_geoJSONIndexes:{},loadVectorData:function(t,e){var r=t.source,n=t.coord;if(!this._geoJSONIndexes[r])return e(null,null);var i=this._geoJSONIndexes[r].getTile(Math.min(n.z,t.maxZoom),n.x,n.y);if(!i)return e(null,null);var a=new s(i.features);a.name="_geojsonTileLayer";var o=l({layers:{_geojsonTileLayer:a}});0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),e(null,{tile:a,rawTileData:o.buffer})},loadData:function(t,e){var r=function(r,n){return r?e(r):"object"!=typeof n?e(new Error("Input data is not a valid GeoJSON object.")):(o(n,!0),void this._indexData(n,t,function(r,n){if(r)return e(r);this._geoJSONIndexes[t.source]=n,e(null)}.bind(this)))}.bind(this);this.loadGeoJSON(t,r)},loadGeoJSON:function(t,e){if(t.url)a.getJSON(t.url,e);else{if("string"!=typeof t.data)return e(new Error("Input data is not a valid GeoJSON object."));try{return e(null,JSON.parse(t.data))}catch(t){return e(new Error("Input data is not a valid GeoJSON object."))}}},_indexData:function(t,e,r){try{e.cluster?r(null,c(e.superclusterOptions).load(t.features)):r(null,u(t,e.geojsonVtOptions))}catch(t){return r(t)}}})},{"../util/ajax":426,"../util/util":443,"./geojson_wrapper":361,"./vector_tile_worker_source":372,"geojson-rewind":139,"geojson-vt":143,supercluster:538,"vt-pbf":565}],361:[function(t,e,r){"use strict";function n(t){this.features=t,this.length=t.length,this.extent=s}function i(t){if(this.type=t.type,1===t.type){this.rawGeometry=[];for(var e=0;ee)){var o=Math.pow(2,Math.min(a.coord.z,this.maxzoom)-Math.min(t.z,this.maxzoom));if(Math.floor(a.coord.x/o)===t.x&&Math.floor(a.coord.y/o)===t.y)for(r[i]=!0,n=!0;a&&a.coord.z-1>t.z;){var s=a.coord.parent(this.maxzoom).id;(a=this._tiles[s])&&a.isRenderable()&&(delete r[i],r[s]=!0)}}}return n},findLoadedParent:function(t,e,r){for(var n=t.z-1;n>=e;n--){t=t.parent(this.maxzoom);var i=this._tiles[t.id];if(i&&i.isRenderable())return r[t.id]=!0,i;if(this._cache.has(t.id))return this.addTile(t),r[t.id]=!0,this._tiles[t.id]}},updateCacheSize:function(t){var e=(Math.ceil(t.width/t.tileSize)+1)*(Math.ceil(t.height/t.tileSize)+1);this._cache.setMaxSize(Math.floor(5*e))},update:function(t,e){if(this._sourceLoaded){var r,i,a;this.updateCacheSize(t);var o=(this.roundZoom?Math.round:Math.floor)(this.getZoom(t)),s=Math.max(o-n.maxOverzooming,this.minzoom),l=Math.max(o+n.maxUnderzooming,this.minzoom),u={},h=(new Date).getTime();this._coveredTiles={};var d=this.used?t.coveringTiles(this._source):[];for(r=0;rh-(e||0)&&(this.findLoadedChildren(i,l,u)&&(u[v]=!0),this.findLoadedParent(i,s,p))}var y;for(y in p)u[y]||(this._coveredTiles[y]=!0);for(y in p)u[y]=!0;var b=f.keysDifference(this._tiles,u);for(r=0;rthis.maxzoom?Math.pow(2,n-this.maxzoom):1;e=new s(r,this.tileSize*i,this.maxzoom),this.loadTile(e,this._tileLoaded.bind(this,e))}return e.uses++,this._tiles[t.id]=e,this.fire("tile.add",{tile:e}),this._source.fire("tile.add",{tile:e}),e},removeTile:function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this.fire("tile.remove",{tile:e}),this._source.fire("tile.remove",{tile:e}),e.uses>0||(e.isRenderable()?this._cache.add(e.coord.wrapped().id,e):(e.aborted=!0,this.abortTile(e),this.unloadTile(e))))},clearTiles:function(){for(var t in this._tiles)this.removeTile(t);this._cache.reset()},tilesIn:function(t){for(var e={},r=this.getIds(),n=1/0,a=1/0,o=-1/0,s=-1/0,l=t[0].zoom,u=0;u=0&&v[1].y>=0){for(var y=[],b=0;b=0&&t%1==0),s(!isNaN(e)&&e>=0&&e%1==0),s(!isNaN(r)&&r>=0&&r%1==0),isNaN(n)&&(n=0),this.z=+t,this.x=+e,this.y=+r,this.w=+n,(n*=2)<0&&(n=-1*n-1);var i=1<e.row){var r=t;t=e,e=r}return{x0:t.column,y0:t.row,x1:e.column,y1:e.row,dx:e.column-t.column,dy:e.row-t.row}}function a(t,e,r,n,i){var a=Math.max(r,Math.floor(e.y0)),o=Math.min(n,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,h=e.dx<0,f=a;fu.dy&&(l=c,c=u,u=l),c.dy>h.dy&&(l=c,c=h,h=l),u.dy>h.dy&&(l=u,u=h,h=l),c.dy&&a(h,c,n,o,s),u.dy&&a(h,u,n,o,s)}var s=t("assert"),l=t("whoots-js"),c=t("../geo/coordinate");e.exports=n,n.prototype.toString=function(){return this.z+"/"+this.x+"/"+this.y},n.prototype.toCoordinate=function(t){var e=Math.min(this.z,t),r=Math.pow(2,e),n=this.y,i=this.x+r*this.w;return new c(i,n,e)},n.fromID=function(t){var e=t%32,r=1<0;a--)i+=(e&(n=1<t?new n(this.z-1,this.x,this.y,this.w):new n(this.z-1,Math.floor(this.x/2),Math.floor(this.y/2),this.w)},n.prototype.wrapped=function(){return new n(this.z,this.x,this.y,0)},n.prototype.children=function(t){if(this.z>=t)return[new n(this.z+1,this.x,this.y,this.w)];var e=this.z+1,r=2*this.x,i=2*this.y;return[new n(e,r,i,this.w),new n(e,r+1,i,this.w),new n(e,r,i+1,this.w),new n(e,r+1,i+1,this.w)]},n.cover=function(t,e,r){function i(t,e,i){var o,l;if(i>=0&&i<=a)for(o=t;othis.maxzoom?Math.pow(2,t.coord.z-this.maxzoom):1,i={url:s(t.coord.url(this.tiles,this.maxzoom,this.scheme),this.url),uid:t.uid,coord:t.coord,zoom:t.coord.z,tileSize:this.tileSize*n,source:this.id,overscaling:n,angle:this.map.transform.angle,pitch:this.map.transform.pitch,showCollisionBoxes:this.map.showCollisionBoxes};t.workerID?"loading"===t.state?t.reloadCallback=e:(i.rawTileData=t.rawTileData,this.dispatcher.send("reload tile",i,r.bind(this),t.workerID)):t.workerID=this.dispatcher.send("load tile",i,r.bind(this))},abortTile:function(t){this.dispatcher.send("abort tile",{uid:t.uid,source:this.id},null,t.workerID)},unloadTile:function(t){t.unloadVectorData(this.map.painter),this.dispatcher.send("remove tile",{uid:t.uid,source:this.id},null,t.workerID)}})},{"../util/evented":435,"../util/mapbox":440,"../util/util":443,"./load_tilejson":363}],372:[function(t,e,r){"use strict";function n(t,e,r){this.actor=t,this.styleLayers=e,r&&(this.loadVectorData=r),this.loading={},this.loaded={}}var i=t("../util/ajax"),a=t("vector-tile"),o=t("pbf"),s=t("./worker_tile");e.exports=n,n.prototype={loadTile:function(t,e){var r=t.source,n=t.uid;this.loading[r]||(this.loading[r]={});var i=this.loading[r][n]=new s(t);i.abort=this.loadVectorData(t,function(t,a){return delete this.loading[r][n],t?e(t):a?(i.data=a.tile,i.parse(i.data,this.styleLayers.getLayerFamilies(),this.actor,a.rawTileData,e),this.loaded[r]=this.loaded[r]||{},void(this.loaded[r][n]=i)):e(null,null)}.bind(this))},reloadTile:function(t,e){var r=this.loaded[t.source],n=t.uid;if(r&&r[n]){var i=r[n];i.parse(i.data,this.styleLayers.getLayerFamilies(),this.actor,t.rawTileData,e)}},abortTile:function(t){var e=this.loading[t.source],r=t.uid;e&&e[r]&&e[r].abort&&(e[r].abort(),delete e[r])},removeTile:function(t){var e=this.loaded[t.source],r=t.uid;e&&e[r]&&delete e[r]},loadVectorData:function(t,e){var r=i.getArrayBuffer(t.url,function(t,r){if(t)return e(t);var n=new a.VectorTile(new o(new Uint8Array(r)));e(t,{tile:n,rawTileData:r})}.bind(this));return function(){r.abort()}},redoPlacement:function(t,e){var r=this.loaded[t.source],n=this.loading[t.source],i=t.uid;if(r&&r[i]){var a=r[i].redoPlacement(t.angle,t.pitch,t.showCollisionBoxes);a.result&&e(null,a.result,a.transferables)}else n&&n[i]&&(n[i].angle=t.angle)}}},{"../util/ajax":426,"./worker_tile":375,pbf:479,"vector-tile":559}],373:[function(t,e,r){"use strict";function n(t,e){this.id=t,this.urls=e.urls,this.coordinates=e.coordinates,c.getVideo(e.urls,function(t,r){if(t)return this.fire("error",{error:t});this.video=r,this.video.loop=!0;var n;this.video.addEventListener("playing",function(){n=this.map.style.animationLoop.set(1/0),this.map._rerender()}.bind(this)),this.video.addEventListener("pause",function(){this.map.style.animationLoop.cancel(n)}.bind(this)),this.map&&(this.video.play(),this.setCoordinates(e.coordinates)),this.fire("load")}.bind(this))}var i=t("../util/util"),a=t("./tile_coord"),o=t("../geo/lng_lat"),s=t("point-geometry"),l=t("../util/evented"),c=t("../util/ajax"),u=t("../data/bucket").EXTENT,h=t("../render/draw_raster").RasterBoundsArray,f=t("../data/buffer"),d=t("../render/vertex_array_object");e.exports=n,n.prototype=i.inherit(l,{minzoom:0,maxzoom:22,tileSize:512,roundZoom:!0,getVideo:function(){return this.video},onAdd:function(t){this.map||(this.map=t,this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))},setCoordinates:function(t){this.coordinates=t;var e=this.map,r=t.map(function(t){return e.transform.locationCoordinate(o.convert(t)).zoomTo(0)}),n=this.centerCoord=i.getCoordinatesCenter(r);return n.column=Math.round(n.column),n.row=Math.round(n.row),this.minzoom=this.maxzoom=n.zoom,this._coord=new a(n.zoom,n.column,n.row),this._tileCoords=r.map(function(t){var e=t.zoomTo(n.zoom);return new s(Math.round((e.column-n.column)*u),Math.round((e.row-n.row)*u))}),this.fire("change"),this},_setTile:function(t){this._prepared=!1,this.tile=t;var e=new h;e.emplaceBack(this._tileCoords[0].x,this._tileCoords[0].y,0,0),e.emplaceBack(this._tileCoords[1].x,this._tileCoords[1].y,32767,0),e.emplaceBack(this._tileCoords[3].x,this._tileCoords[3].y,0,32767),e.emplaceBack(this._tileCoords[2].x,this._tileCoords[2].y,32767,32767),this.tile.buckets={},this.tile.boundsBuffer=new f(e.serialize(),h.serialize(),f.BufferType.VERTEX),this.tile.boundsVAO=new d,this.tile.state="loaded"},prepare:function(){if(!(this.video.readyState<2)&&this.tile){var t=this.map.painter.gl;this._prepared?(t.bindTexture(t.TEXTURE_2D,this.tile.texture),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this._prepared=!0,this.tile.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.tile.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video)),this._currentTime=this.video.currentTime}},loadTile:function(t,e){this._coord&&this._coord.toString()===t.coord.toString()?(this._setTile(t),e(null)):(t.state="errored",e(null))},serialize:function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}})},{"../data/bucket":330,"../data/buffer":335,"../geo/lng_lat":340,"../render/draw_raster":352,"../render/vertex_array_object":358,"../util/ajax":426,"../util/evented":435,"../util/util":443,"./tile_coord":370,"point-geometry":485}],374:[function(t,e,r){"use strict";function n(t){this.self=t,this.actor=new a(t,this);var e={getLayers:function(){return this.layers}.bind(this),getLayerFamilies:function(){return this.layerFamilies}.bind(this)};this.workerSources={vector:new l(this.actor,e),geojson:new c(this.actor,e)},this.self.registerWorkerSource=function(t,r){if(this.workerSources[t])throw new Error('Worker source with name "'+t+'" already registered.');this.workerSources[t]=new r(this.actor,e)}.bind(this)}function i(t){var e={};for(var r in t){var n=t[r],i=n.ref||n.id,a=t[i];a.layout&&"none"===a.layout.visibility||(e[i]=e[i]||[],r===i?e[i].unshift(n):e[i].push(n))}return e}var a=t("../util/actor"),o=t("../style/style_layer"),s=t("../util/util"),l=t("./vector_tile_worker_source"),c=t("./geojson_worker_source");e.exports=function(t){return new n(t)},s.extend(n.prototype,{"set layers":function(t){function e(t){var e=o.create(t,t.ref&&r.layers[t.ref]);e.updatePaintTransitions({},{transition:!1}),r.layers[e.id]=e}this.layers={};for(var r=this,n=[],a=0;a=0;e--)b(E,z[e]);x()}}function b(t,e){if(e.populateArrays(T,j,R),"symbol"!==e.type)for(var r=0;r=w.maxzoom||w.layout&&"none"===w.layout.visibility||t.layers&&!t.layers[w.sourceLayer]||((k=u.create({layer:w,index:I++,childLayers:e[P],zoom:this.zoom,overscaling:this.overscaling,showCollisionBoxes:this.showCollisionBoxes,collisionBoxArray:this.collisionBoxArray,symbolQuadsArray:this.symbolQuadsArray,symbolInstancesArray:this.symbolInstancesArray,sourceLayerIndex:S.encode(w.sourceLayer||"_geojsonTileLayer")})).createFilter(),L[w.id]=k,t.layers&&(C[M=w.sourceLayer]=C[M]||{},C[M][w.id]=k)));if(t.layers)for(M in C)1===w.version&&d.warnOnce('Vector tile source "'+this.source+'" layer "'+M+'" does not use vector tile spec v2 and therefore may have some rendering errors.'),(w=t.layers[M])&&v(w,C[M]);else v(t,L);var D=[],z=this.symbolBuckets=[],O=[];A.bucketLayerIDs={};for(var F in L)0!==(k=L[F]).features.length&&(A.bucketLayerIDs[k.index]=k.childLayers.map(s),D.push(k),"symbol"===k.type?z.push(k):O.push(k));var R={},j={},N=0;if(z.length>0){for(_=z.length-1;_>=0;_--)z[_].updateIcons(R),z[_].updateFont(j);for(var B in j)j[B]=Object.keys(j[B]).map(Number);R=Object.keys(R),r.send("get glyphs",{uid:this.uid,stacks:j},function(t,e){j=e,y(t)}),R.length?r.send("get icons",{icons:R},function(t,e){R=e,y(t)}):y()}for(_=O.length-1;_>=0;_--)b(0,O[_]);if(0===z.length)return x()},n.prototype.redoPlacement=function(t,e,r){if("done"!==this.status)return this.redoPlacementAfterDone=!0,this.angle=t,{};for(var n=new c(t,e,this.collisionBoxArray),s=this.symbolBuckets,l=s.length-1;l>=0;l--)s[l].placeFeatures(n,r);var u=n.serialize(),h=s.filter(i);return{result:{buckets:h.map(a),collisionTile:u.data},transferables:o(h).concat(u.transferables)}}},{"../data/bucket":330,"../data/feature_index":337,"../symbol/collision_box":395,"../symbol/collision_tile":397,"../symbol/symbol_instances":406,"../symbol/symbol_quads":407,"../util/dictionary_coder":433,"../util/util":443}],376:[function(t,e,r){"use strict";function n(){this.n=0,this.times=[]}e.exports=n,n.prototype.stopped=function(){return this.times=this.times.filter(function(t){return t.time>=(new Date).getTime()}),!this.times.length},n.prototype.set=function(t){return this.times.push({id:this.n,time:t+(new Date).getTime()}),this.n++},n.prototype.cancel=function(t){this.times=this.times.filter(function(e){return e.id!==t})}},{}],377:[function(t,e,r){"use strict";function n(t){this.base=t,this.retina=s.devicePixelRatio>1;var e=this.retina?"@2x":"";o.getJSON(l(t,e,".json"),function(t,e){t?this.fire("error",{error:t}):(this.data=e,this.img&&this.fire("load"))}.bind(this)),o.getImage(l(t,e,".png"),function(t,e){if(t)this.fire("error",{error:t});else{for(var r=e.getData(),n=e.data=new Uint8Array(r.length),i=0;i1!==this.retina){var t=new n(this.base);t.on("load",function(){this.img=t.img,this.data=t.data,this.retina=t.retina}.bind(this))}},i.prototype={x:0,y:0,width:0,height:0,pixelRatio:1,sdf:!1},n.prototype.getSpritePosition=function(t){if(!this.loaded())return new i;var e=this.data&&this.data[t];return e&&this.img?e:new i}},{"../util/ajax":426,"../util/browser":427,"../util/evented":435,"../util/mapbox":440}],378:[function(t,e,r){"use strict";var n=t("csscolorparser").parseCSSColor,i=t("../util/util"),a=t("./style_function"),o={};e.exports=function t(e){if(a.isFunctionDefinition(e))return i.extend({},e,{stops:e.stops.map(function(e){return[e[0],t(e[1])]})});if("string"==typeof e){if(!o[e]){var r=n(e);if(!r)throw new Error("Invalid color "+e);o[e]=[r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]]}return o[e]}throw new Error("Invalid color "+e)}},{"../util/util":443,"./style_function":381,csscolorparser:109}],379:[function(t,e,r){"use strict";function n(t,e,r){this.animationLoop=e||new m,this.dispatcher=new p(r||1,this),this.spriteAtlas=new l(1024,1024),this.lineAtlas=new c(256,512),this._layers={},this._order=[],this._groups=[],this.sources={},this.zoomHistory={},u.bindAll(["_forwardSourceEvent","_forwardTileEvent","_forwardLayerEvent","_redoPlacement"],this),this._resetUpdates();var n=function(t,e){if(t)this.fire("error",{error:t});else if(!g.emitErrors(this,g(e))){this._loaded=!0,this.stylesheet=e,this.updateClasses();var r=e.sources;for(var n in r)this.addSource(n,r[n]);e.sprite&&(this.sprite=new o(e.sprite),this.sprite.on("load",this.fire.bind(this,"change"))),this.glyphSource=new s(e.glyphs),this._resolve(),this.fire("load")}}.bind(this);"string"==typeof t?h.getJSON(f(t),n):d.frame(n.bind(this,null,t)),this.on("source.load",function(t){var e=t.source;if(e&&e.vectorLayerIds)for(var r in this._layers){var n=this._layers[r];n.source===e.id&&this._validateLayer(n)}})}var i=t("../util/evented"),a=t("./style_layer"),o=t("./image_sprite"),s=t("../symbol/glyph_source"),l=t("../symbol/sprite_atlas"),c=t("../render/line_atlas"),u=t("../util/util"),h=t("../util/ajax"),f=t("../util/mapbox").normalizeStyleURL,d=t("../util/browser"),p=t("../util/dispatcher"),m=t("./animation_loop"),g=t("./validate_style"),v=t("../source/source"),y=t("../source/query_features"),b=t("../source/source_cache"),x=t("./style_spec"),_=t("./style_function");e.exports=n,n.prototype=u.inherit(i,{_loaded:!1,_validateLayer:function(t){var e=this.sources[t.source];t.sourceLayer&&e&&e.vectorLayerIds&&-1===e.vectorLayerIds.indexOf(t.sourceLayer)&&this.fire("error",{error:new Error('Source layer "'+t.sourceLayer+'" does not exist on source "'+e.id+'" as specified by style layer "'+t.id+'"')})},loaded:function(){if(!this._loaded)return!1;if(Object.keys(this._updates.sources).length)return!1;for(var t in this.sources)if(!this.sources[t].loaded())return!1;return!(this.sprite&&!this.sprite.loaded())},_resolve:function(){var t,e;this._layers={},this._order=this.stylesheet.layers.map(function(t){return t.id});for(var r=0;rMath.floor(t)&&(e.lastIntegerZoom=Math.floor(t+1),e.lastIntegerZoomTime=Date.now()),e.lastZoom=t},_checkLoaded:function(){if(!this._loaded)throw new Error("Style is not done loading")},update:function(t,e){if(!this._updates.changed)return this;if(this._updates.allLayers)this._groupLayers(),this._updateWorkerLayers();else{var r=Object.keys(this._updates.layers);r.length&&this._updateWorkerLayers(r)}var n,i=Object.keys(this._updates.sources);for(n=0;n=0&&this._handleErrors(g.source,"sources."+t,e)?this:(e=new b(t,e,this.dispatcher),this.sources[t]=e,e.style=this,e.on("load",this._forwardSourceEvent).on("error",this._forwardSourceEvent).on("change",this._forwardSourceEvent).on("tile.add",this._forwardTileEvent).on("tile.load",this._forwardTileEvent).on("tile.error",this._forwardTileEvent).on("tile.remove",this._forwardTileEvent).on("tile.stats",this._forwardTileEvent),this._updates.events.push(["source.add",{source:e}]),this._updates.changed=!0,this)},removeSource:function(t){if(this._checkLoaded(),void 0===this.sources[t])throw new Error("There is no source with this ID");var e=this.sources[t];return delete this.sources[t],delete this._updates.sources[t],e.off("load",this._forwardSourceEvent).off("error",this._forwardSourceEvent).off("change",this._forwardSourceEvent).off("tile.add",this._forwardTileEvent).off("tile.load",this._forwardTileEvent).off("tile.error",this._forwardTileEvent).off("tile.remove",this._forwardTileEvent).off("tile.stats",this._forwardTileEvent),this._updates.events.push(["source.remove",{source:e}]),this._updates.changed=!0,this},getSource:function(t){return this.sources[t]&&this.sources[t].getSource()},addLayer:function(t,e){if(this._checkLoaded(),!(t instanceof a)){if(this._handleErrors(g.layer,"layers."+t.id,t,!1,{arrayIndex:-1}))return this;var r=t.ref&&this.getLayer(t.ref);t=a.create(t,r)}return this._validateLayer(t),t.on("error",this._forwardLayerEvent),this._layers[t.id]=t,this._order.splice(e?this._order.indexOf(e):1/0,0,t.id),this._updates.allLayers=!0,t.source&&(this._updates.sources[t.source]=!0),this._updates.events.push(["layer.add",{layer:t}]),this.updateClasses(t.id)},removeLayer:function(t){this._checkLoaded();var e=this._layers[t];if(void 0===e)throw new Error("There is no layer with this ID");for(var r in this._layers)this._layers[r].ref===t&&this.removeLayer(r);return e.off("error",this._forwardLayerEvent),delete this._layers[t],delete this._updates.layers[t],delete this._updates.paintProps[t],this._order.splice(this._order.indexOf(t),1),this._updates.allLayers=!0,this._updates.events.push(["layer.remove",{layer:e}]),this._updates.changed=!0,this},getLayer:function(t){return this._layers[t]},getReferentLayer:function(t){var e=this.getLayer(t);return e.ref&&(e=this.getLayer(e.ref)),e},setLayerZoomRange:function(t,e,r){this._checkLoaded();var n=this.getReferentLayer(t);return n.minzoom===e&&n.maxzoom===r?this:(null!=e&&(n.minzoom=e),null!=r&&(n.maxzoom=r),this._updateLayer(n))},setFilter:function(t,e){this._checkLoaded();var r=this.getReferentLayer(t);return null!==e&&this._handleErrors(g.filter,"layers."+r.id+".filter",e)?this:u.deepEqual(r.filter,e)?this:(r.filter=u.clone(e),this._updateLayer(r))},getFilter:function(t){return this.getReferentLayer(t).filter},setLayoutProperty:function(t,e,r){this._checkLoaded();var n=this.getReferentLayer(t);return u.deepEqual(n.getLayoutProperty(e),r)?this:(n.setLayoutProperty(e,r),this._updateLayer(n))},getLayoutProperty:function(t,e){return this.getReferentLayer(t).getLayoutProperty(e)},setPaintProperty:function(t,e,r,n){this._checkLoaded();var i=this.getLayer(t);if(u.deepEqual(i.getPaintProperty(e,n),r))return this;var a=i.isPaintValueFeatureConstant(e);i.setPaintProperty(e,r,n);return!(r&&_.isFunctionDefinition(r)&&"$zoom"!==r.property&&void 0!==r.property)&&a||(this._updates.layers[t]=!0,i.source&&(this._updates.sources[i.source]=!0)),this.updateClasses(t,e)},getPaintProperty:function(t,e,r){return this.getLayer(t).getPaintProperty(e,r)},updateClasses:function(t,e){if(this._updates.changed=!0,t){var r=this._updates.paintProps;r[t]||(r[t]={}),r[t][e||"all"]=!0}else this._updates.allPaintProps=!0;return this},serialize:function(){return u.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:u.mapObject(this.sources,function(t){return t.serialize()}),layers:this._order.map(function(t){return this._layers[t].serialize()},this)},function(t){return void 0!==t})},_updateLayer:function(t){return this._updates.layers[t.id]=!0,t.source&&(this._updates.sources[t.source]=!0),this._updates.changed=!0,this},_flattenRenderedFeatures:function(t){for(var e=[],r=this._order.length-1;r>=0;r--)for(var n=this._order[r],i=0;is.lastIntegerZoom?(n=c+(1-c)*u,h*=2,i=t({zoom:o-1},r),a=t({zoom:o},r)):(n=1-(1-u)*c,a=t({zoom:o},r),i=t({zoom:o+1},r),h/=2),void 0===i||void 0===a?void 0:{from:i,fromScale:h,to:a,toScale:1,t:n}}}(this.calculate)),!this.isFeatureConstant&&!this.isZoomConstant){this.stopZoomLevels=[];for(var o=[],s=this.value.stops,l=0;l=this.maxzoom)||("none"===this.layout.visibility||0===this.paint[this.type+"-opacity"]))},updatePaintTransitions:function(t,e,r,n){for(var i=a.extend({},this._paintDeclarations[""]),o=0;o-r/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],c=0;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=h.dist(f)}return!0}},{}],394:[function(t,e,r){"use strict";var n=t("point-geometry");e.exports=function(t,e,r,i,a){for(var o=[],s=0;s=i&&f.x>=i||(h.x>=i?h=new n(i,h.y+(f.y-h.y)*((i-h.x)/(f.x-h.x)))._round():f.x>=i&&(f=new n(i,h.y+(f.y-h.y)*((i-h.x)/(f.x-h.x)))._round()),h.y>=a&&f.y>=a||(h.y>=a?h=new n(h.x+(f.x-h.x)*((a-h.y)/(f.y-h.y)),a)._round():f.y>=a&&(f=new n(h.x+(f.x-h.x)*((a-h.y)/(f.y-h.y)),a)._round()),l&&h.equals(l[l.length-1])||(l=[h],o.push(l)),l.push(f)))))}return o}},{"point-geometry":485}],395:[function(t,e,r){"use strict";var n=t("../util/struct_array"),i=t("../util/util"),a=t("point-geometry"),o=e.exports=new n({members:[{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Float32",name:"maxScale"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"bbox0"},{type:"Int16",name:"bbox1"},{type:"Int16",name:"bbox2"},{type:"Int16",name:"bbox3"},{type:"Float32",name:"placementScale"}]});i.extendAll(o.prototype.StructType.prototype,{get anchorPoint(){return new a(this.anchorPointX,this.anchorPointY)}})},{"../util/struct_array":441,"../util/util":443,"point-geometry":485}],396:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u){var h=o.top*s-l,f=o.bottom*s+l,d=o.left*s-l,p=o.right*s+l;if(this.boxStartIndex=t.length,c){var m=f-h,g=p-d;if(m>0)if(m=Math.max(10*s,m),u){var v=e[r.segment+1].sub(e[r.segment])._unit()._mult(g),y=[r.sub(v),r.add(v)];this._addLineCollisionBoxes(t,y,r,0,g,m,n,i,a)}else this._addLineCollisionBoxes(t,e,r,r.segment,g,m,n,i,a)}else t.emplaceBack(r.x,r.y,d,h,p,f,1/0,n,i,a,0,0,0,0,0);this.boxEndIndex=t.length}e.exports=n,n.prototype._addLineCollisionBoxes=function(t,e,r,n,i,a,o,s,l){var c=a/2,u=Math.floor(i/c),h=-a/2,f=this.boxes,d=r,p=n+1,m=h;do{if(--p<0)return f;m-=e[p].dist(d),d=e[p]}while(m>-i/2);for(var g=e[p].dist(e[p+1]),v=0;v=e.length)return f;g=e[p].dist(e[p+1])}var b=y-m,x=e[p],_=e[p+1].sub(x)._unit()._mult(b)._add(x)._round(),w=i/2/Math.max(Math.abs(y-h)-c/2,0);t.emplaceBack(_.x,_.y,-a/2,-a/2,a/2,a/2,w,o,s,l,0,0,0,0,0)}return f}},{}],397:[function(t,e,r){"use strict";function n(t,e,r){if("object"==typeof t){var n=t;r=e,t=n.angle,e=n.pitch,this.grid=new o(n.grid),this.ignoredGrid=new o(n.ignoredGrid)}else this.grid=new o(a,12,6),this.ignoredGrid=new o(a,12,0);this.angle=t,this.pitch=e;var i=Math.sin(t),s=Math.cos(t);if(this.rotationMatrix=[s,-i,i,s],this.reverseRotationMatrix=[s,i,-i,s],this.yStretch=1/Math.cos(e/180*Math.PI),this.yStretch=Math.pow(this.yStretch,1.3),this.collisionBoxArray=r,0===r.length){r.emplaceBack();r.emplaceBack(0,0,0,-32767,0,32767,32767,0,0,0,0,0,0,0,0,0),r.emplaceBack(a,0,0,-32767,0,32767,32767,0,0,0,0,0,0,0,0,0),r.emplaceBack(0,0,-32767,0,32767,0,32767,0,0,0,0,0,0,0,0,0),r.emplaceBack(0,a,-32767,0,32767,0,32767,0,0,0,0,0,0,0,0,0)}this.tempCollisionBox=r.get(0),this.edges=[r.get(1),r.get(2),r.get(3),r.get(4)]}var i=t("point-geometry"),a=t("../data/bucket").EXTENT,o=t("grid-index");e.exports=n,n.prototype.serialize=function(){var t={angle:this.angle,pitch:this.pitch,grid:this.grid.toArrayBuffer(),ignoredGrid:this.ignoredGrid.toArrayBuffer()};return{data:t,transferables:[t.grid,t.ignoredGrid]}},n.prototype.minScale=.25,n.prototype.maxScale=2,n.prototype.placeCollisionFeature=function(t,e,r){for(var n=this.collisionBoxArray,a=this.minScale,o=this.rotationMatrix,s=this.yStretch,l=t.boxStartIndex;l=this.maxScale)return a}if(r){var _;if(this.angle){var w=this.reverseRotationMatrix,M=new i(c.x1,c.y1).matMult(w),k=new i(c.x2,c.y1).matMult(w),T=new i(c.x1,c.y2).matMult(w),A=new i(c.x2,c.y2).matMult(w);(_=this.tempCollisionBox).anchorPointX=c.anchorPoint.x,_.anchorPointY=c.anchorPoint.y,_.x1=Math.min(M.x,k.x,T.x,A.x),_.y1=Math.min(M.y,k.x,T.x,A.x),_.x2=Math.max(M.x,k.x,T.x,A.x),_.y2=Math.max(M.y,k.x,T.x,A.x),_.maxScale=c.maxScale}else _=c;for(var S=0;S=this.maxScale)return a}}}return a},n.prototype.queryRenderedSymbols=function(t,e,r,n,a){var o={},s=[],l=this.collisionBoxArray,c=this.rotationMatrix,u=new i(t,e)._matMult(c),h=this.tempCollisionBox;h.anchorX=u.x,h.anchorY=u.y,h.x1=0,h.y1=0,h.x2=r-t,h.y2=n-e,h.maxScale=a,a=h.maxScale;for(var f=[u.x+h.x1/a,u.y+h.y1/a*this.yStretch,u.x+h.x2/a,u.y+h.y2/a*this.yStretch],d=this.grid.query(f[0],f[1],f[2],f[3]),p=this.ignoredGrid.query(f[0],f[1],f[2],f[3]),m=0;m=a&&(o[y][b]=!0,s.push(d[g]))}}return s},n.prototype.getPlacementScale=function(t,e,r,n,i){var a=e.x-n.x,o=e.y-n.y,s=(i.x1-r.x2)/a,l=(i.x2-r.x1)/a,c=(i.y1-r.y2)*this.yStretch/o,u=(i.y2-r.y1)*this.yStretch/o;(isNaN(s)||isNaN(l))&&(s=l=1),(isNaN(c)||isNaN(u))&&(c=u=1);var h=Math.min(Math.max(s,l),Math.max(c,u)),f=i.maxScale,d=r.maxScale;return h>f&&(h=f),h>d&&(h=d),h>t&&h>=i.placementScale&&(t=h),t},n.prototype.insertCollisionFeature=function(t,e,r){for(var n=r?this.ignoredGrid:this.grid,i=this.collisionBoxArray,a=t.boxStartIndex;a=0&&T=0&&A=0&&v+d<=p){var S=new a(T,A,M,b)._round();s&&!o(t,S,c,s,l)||y.push(S)}}g+=w}return h||y.length||u||(y=n(t,g/2,r,s,l,c,u,!0,f)),y}var i=t("../util/interpolate"),a=t("../symbol/anchor"),o=t("./check_max_angle");e.exports=function(t,e,r,i,a,o,s,l,c){var u=i?.6*o*s:0,h=Math.max(i?i.right-i.left:0,a?a.right-a.left:0),f=0===t[0].x||t[0].x===c||0===t[0].y||t[0].y===c;return e-h*s=2048||e>=2048)){this.texture&&(this.gl&&this.gl.deleteTexture(this.texture),this.texture=null),this.width*=4,this.height*=4,this.bin.resize(this.width,this.height);for(var r=new ArrayBuffer(this.width*this.height),n=0;n65535)return r("glyphs > 65535 not supported");void 0===this.loading[t]&&(this.loading[t]={});var n=this.loading[t];if(n[e])n[e].push(r);else{n[e]=[r];var i=function(t,e,r,n){return n=n||"abc",r.replace("{s}",n[t.length%n.length]).replace("{fontstack}",t).replace("{range}",e)}(t,256*e+"-"+(256*e+255),this.url);o(i,function(t,r){for(var i=!t&&new s(new c(new Uint8Array(r))),a=0;an&&null!==h){var b=g[h+1].x;m=Math.max(b,m);for(var x=h+1;x<=v;x++)g[x].y+=r,g[x].x-=b;if(c){var _=h;a[g[h].codePoint]&&_--,i(g,e,d,_,c)}d=h+1,h=null,f+=b,p++}o[y.codePoint]&&(h=v)}var w=g[g.length-1],M=w.x+e[w.codePoint].advance;m=Math.max(m,M);var k=(p+1)*r;i(g,e,d,g.length-1,c),function(t,e,r,n,i,a,o,s){for(var l=(e-r)*i+s[0],c=(-n*(o+1)+.5)*a+s[1],u=0;u1?2:1,this.canvas&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio)),this.sprite=t},n.prototype.addIcons=function(t,e){for(var r=0;r1||(h?(clearTimeout(h),h=null,o("dblclick",e)):h=setTimeout(r,300))},!1),l.addEventListener("touchend",function(t){s("touchend",t)},!1),l.addEventListener("touchmove",function(t){s("touchmove",t)},!1),l.addEventListener("touchcancel",function(t){s("touchcancel",t)},!1),l.addEventListener("click",function(t){n.mousePos(l,t).equals(u)&&o("click",t)},!1),l.addEventListener("dblclick",function(t){o("dblclick",t),t.preventDefault()},!1),l.addEventListener("contextmenu",function(t){c=t,t.preventDefault()},!1)}},{"../util/dom":429,"./handler/box_zoom":414,"./handler/dblclick_zoom":415,"./handler/drag_pan":416,"./handler/drag_rotate":417,"./handler/keyboard":418,"./handler/scroll_zoom":419,"./handler/touch_zoom_rotate":420,"point-geometry":485}],409:[function(t,e,r){"use strict";var n=t("../util/util"),i=t("../util/interpolate"),a=t("../util/browser"),o=t("../geo/lng_lat"),s=t("../geo/lng_lat_bounds"),l=t("point-geometry"),c=e.exports=function(){};n.extend(c.prototype,{getCenter:function(){return this.transform.center},setCenter:function(t,e){return this.jumpTo({center:t},e),this},panBy:function(t,e,r){return this.panTo(this.transform.center,n.extend({offset:l.convert(t).mult(-1)},e),r),this},panTo:function(t,e,r){return this.easeTo(n.extend({center:t},e),r)},getZoom:function(){return this.transform.zoom},setZoom:function(t,e){return this.jumpTo({zoom:t},e),this},zoomTo:function(t,e,r){return this.easeTo(n.extend({zoom:t},e),r)},zoomIn:function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},zoomOut:function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},getBearing:function(){return this.transform.bearing},setBearing:function(t,e){return this.jumpTo({bearing:t},e),this},rotateTo:function(t,e,r){return this.easeTo(n.extend({bearing:t},e),r)},resetNorth:function(t,e){return this.rotateTo(0,n.extend({duration:1e3},t),e),this},snapToNorth:function(t,e){return Math.abs(this.getBearing())180&&(c.center.lng>0&&p.lng<0?p.lng+=360:c.center.lng<0&&p.lng>0&&(p.lng-=360));var y=c.zoomScale(m-h),b=c.point,x="center"in t?c.project(p).sub(u.div(y)):b,_=c.worldSize,w=t.curve,M=Math.max(c.width,c.height),k=M/y,T=x.sub(b).mag();if("minZoom"in t){var A=n.clamp(Math.min(t.minZoom,h,m),c.minZoom,c.maxZoom),S=M/c.zoomScale(A-h);w=Math.sqrt(S/T*2)}var E=w*w,L=r(0),C=function(t){return s(L)/s(L+w*t)},I=function(t){return M*((s(L)*function(t){return a(t)/s(t)}(L+w*t)-a(L))/E)/T},P=(r(1)-L)/w;if(Math.abs(T)<1e-6){if(Math.abs(M-k)<1e-6)return this.easeTo(t);var D=k=0)return!1;return!0})).join(" | ")},n.prototype=o.inherit(i,{options:{position:"bottom-right"},onAdd:function(t){var e=this._container=a.create("div","mapboxgl-ctrl-attrib",t.getContainer());return this._update(),t.on("source.load",this._update.bind(this)),t.on("source.change",this._update.bind(this)),t.on("source.remove",this._update.bind(this)),t.on("moveend",this._updateEditLink.bind(this)),e},_update:function(){this._map.style&&(this._container.innerHTML=n.createAttributionString(this._map.style.sources)),this._editLink=this._container.getElementsByClassName("mapbox-improve-map")[0],this._updateEditLink()},_updateEditLink:function(){if(this._editLink){var t=this._map.getCenter();this._editLink.href="https://www.mapbox.com/map-feedback/#/"+t.lng+"/"+t.lat+"/"+Math.round(this._map.getZoom()+1)}}})},{"../../util/dom":429,"../../util/util":443,"./control":411}],411:[function(t,e,r){"use strict";function n(){}var i=t("../../util/util"),a=t("../../util/evented");e.exports=n,n.prototype={addTo:function(t){this._map=t;var e=this._container=this.onAdd(t);if(this.options&&this.options.position){var r=this.options.position,n=t._controlCorners[r];e.className+=" mapboxgl-ctrl",-1!==r.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e)}return this},remove:function(){return this._container.parentNode.removeChild(this._container),this.onRemove&&this.onRemove(this._map),this._map=null,this}},i.extend(n.prototype,a)},{"../../util/evented":435,"../../util/util":443}],412:[function(t,e,r){"use strict";function n(t){s.setOptions(this,t)}var i=t("./control"),a=t("../../util/browser"),o=t("../../util/dom"),s=t("../../util/util");e.exports=n;var l={enableHighAccuracy:!1,timeout:6e3};n.prototype=s.inherit(i,{options:{position:"top-right"},onAdd:function(t){var e=this._container=o.create("div","mapboxgl-ctrl-group",t.getContainer());return a.supportsGeolocation?(this._container.addEventListener("contextmenu",this._onContextMenu.bind(this)),this._geolocateButton=o.create("button","mapboxgl-ctrl-icon mapboxgl-ctrl-geolocate",this._container),this._geolocateButton.type="button",this._geolocateButton.addEventListener("click",this._onClickGeolocate.bind(this)),e):e},_onContextMenu:function(t){t.preventDefault()},_onClickGeolocate:function(){navigator.geolocation.getCurrentPosition(this._success.bind(this),this._error.bind(this),l),this._timeoutId=setTimeout(this._finish.bind(this),1e4)},_success:function(t){this._map.jumpTo({center:[t.coords.longitude,t.coords.latitude],zoom:17,bearing:0,pitch:0}),this.fire("geolocate",t),this._finish()},_error:function(t){this.fire("error",t),this._finish()},_finish:function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}})},{"../../util/browser":427,"../../util/dom":429,"../../util/util":443,"./control":411}],413:[function(t,e,r){"use strict";function n(t){s.setOptions(this,t)}function i(t){return new MouseEvent(t.type,{button:2,buttons:2,bubbles:!0,cancelable:!0,detail:t.detail,view:t.view,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,movementX:t.movementX,movementY:t.movementY,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey})}var a=t("./control"),o=t("../../util/dom"),s=t("../../util/util");e.exports=n,n.prototype=s.inherit(a,{options:{position:"top-right"},onAdd:function(t){var e="mapboxgl-ctrl",r=this._container=o.create("div",e+"-group",t.getContainer());return this._container.addEventListener("contextmenu",this._onContextMenu.bind(this)),this._zoomInButton=this._createButton(e+"-icon "+e+"-zoom-in",t.zoomIn.bind(t)),this._zoomOutButton=this._createButton(e+"-icon "+e+"-zoom-out",t.zoomOut.bind(t)),this._compass=this._createButton(e+"-icon "+e+"-compass",t.resetNorth.bind(t)),this._compassArrow=o.create("div","arrow",this._compass),this._compass.addEventListener("mousedown",this._onCompassDown.bind(this)),this._onCompassMove=this._onCompassMove.bind(this),this._onCompassUp=this._onCompassUp.bind(this),t.on("rotate",this._rotateCompassArrow.bind(this)),this._rotateCompassArrow(),this._el=t.getCanvasContainer(),r},_onContextMenu:function(t){t.preventDefault()},_onCompassDown:function(t){0===t.button&&(o.disableDrag(),document.addEventListener("mousemove",this._onCompassMove),document.addEventListener("mouseup",this._onCompassUp),this._el.dispatchEvent(i(t)),t.stopPropagation())},_onCompassMove:function(t){0===t.button&&(this._el.dispatchEvent(i(t)),t.stopPropagation())},_onCompassUp:function(t){0===t.button&&(document.removeEventListener("mousemove",this._onCompassMove),document.removeEventListener("mouseup",this._onCompassUp),o.enableDrag(),this._el.dispatchEvent(i(t)),t.stopPropagation())},_createButton:function(t,e){var r=o.create("button",t,this._container);return r.type="button",r.addEventListener("click",function(){e()}),r},_rotateCompassArrow:function(){var t="rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t}})},{"../../util/dom":429,"../../util/util":443,"./control":411}],414:[function(t,e,r){"use strict";function n(t){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),o.bindHandlers(this)}var i=t("../../util/dom"),a=t("../../geo/lng_lat_bounds"),o=t("../../util/util");e.exports=n,n.prototype={_enabled:!1,_active:!1,isEnabled:function(){return this._enabled},isActive:function(){return this._active},enable:function(){this.isEnabled()||(this._el.addEventListener("mousedown",this._onMouseDown,!1),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("mousedown",this._onMouseDown),this._enabled=!1)},_onMouseDown:function(t){t.shiftKey&&0===t.button&&(document.addEventListener("mousemove",this._onMouseMove,!1),document.addEventListener("keydown",this._onKeyDown,!1),document.addEventListener("mouseup",this._onMouseUp,!1),i.disableDrag(),this._startPos=i.mousePos(this._el,t),this._active=!0)},_onMouseMove:function(t){var e=this._startPos,r=i.mousePos(this._el,t);this._box||(this._box=i.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var n=Math.min(e.x,r.x),a=Math.max(e.x,r.x),o=Math.min(e.y,r.y),s=Math.max(e.y,r.y);i.setTransform(this._box,"translate("+n+"px,"+o+"px)"),this._box.style.width=a-n+"px",this._box.style.height=s-o+"px"},_onMouseUp:function(t){if(0===t.button){var e=this._startPos,r=i.mousePos(this._el,t),n=new a(this._map.unproject(e),this._map.unproject(r));this._finish(),e.x===r.x&&e.y===r.y?this._fireEvent("boxzoomcancel",t):this._map.fitBounds(n,{linear:!0}).fire("boxzoomend",{originalEvent:t,boxZoomBounds:n})}},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._fireEvent("boxzoomcancel",t))},_finish:function(){this._active=!1,document.removeEventListener("mousemove",this._onMouseMove,!1),document.removeEventListener("keydown",this._onKeyDown,!1),document.removeEventListener("mouseup",this._onMouseUp,!1),this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.parentNode.removeChild(this._box),this._box=null),i.enableDrag()},_fireEvent:function(t,e){return this._map.fire(t,{originalEvent:e})}}},{"../../geo/lng_lat_bounds":341,"../../util/dom":429,"../../util/util":443}],415:[function(t,e,r){"use strict";function n(t){this._map=t,this._onDblClick=this._onDblClick.bind(this)}e.exports=n,n.prototype={_enabled:!1,isEnabled:function(){return this._enabled},enable:function(){this.isEnabled()||(this._map.on("dblclick",this._onDblClick),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._map.off("dblclick",this._onDblClick),this._enabled=!1)},_onDblClick:function(t){this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)}}},{}],416:[function(t,e,r){"use strict";function n(t){this._map=t,this._el=t.getCanvasContainer(),a.bindHandlers(this)}var i=t("../../util/dom"),a=t("../../util/util");e.exports=n;var o=a.bezier(0,0,.3,1);n.prototype={_enabled:!1,_active:!1,isEnabled:function(){return this._enabled},isActive:function(){return this._active},enable:function(){this.isEnabled()||(this._el.addEventListener("mousedown",this._onDown),this._el.addEventListener("touchstart",this._onDown),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("mousedown",this._onDown),this._el.removeEventListener("touchstart",this._onDown),this._enabled=!1)},_onDown:function(t){this._ignoreEvent(t)||this.isActive()||(t.touches?(document.addEventListener("touchmove",this._onMove),document.addEventListener("touchend",this._onTouchEnd)):(document.addEventListener("mousemove",this._onMove),document.addEventListener("mouseup",this._onMouseUp)),this._active=!1,this._startPos=this._pos=i.mousePos(this._el,t),this._inertia=[[Date.now(),this._pos]])},_onMove:function(t){if(!this._ignoreEvent(t)){this.isActive()||(this._active=!0,this._fireEvent("dragstart",t),this._fireEvent("movestart",t));var e=i.mousePos(this._el,t),r=this._map;r.stop(),this._drainInertiaBuffer(),this._inertia.push([Date.now(),e]),r.transform.setLocationAtPoint(r.transform.pointLocation(this._pos),e),this._fireEvent("drag",t),this._fireEvent("move",t),this._pos=e,t.preventDefault()}},_onUp:function(t){if(this.isActive()){this._active=!1,this._fireEvent("dragend",t),this._drainInertiaBuffer();var e=function(){this._fireEvent("moveend",t)}.bind(this),r=this._inertia;if(r.length<2)e();else{var n=r[r.length-1],i=r[0],a=n[1].sub(i[1]),s=(n[0]-i[0])/1e3;if(0===s||n[1].equals(i[1]))e();else{var l=a.mult(.3/s),c=l.mag();c>1400&&(c=1400,l._unit()._mult(c));var u=c/750,h=l.mult(-u/2);this._map.panBy(h,{duration:1e3*u,easing:o,noMoveStart:!0},{originalEvent:t})}}}},_onMouseUp:function(t){this._ignoreEvent(t)||(this._onUp(t),document.removeEventListener("mousemove",this._onMove),document.removeEventListener("mouseup",this._onMouseUp))},_onTouchEnd:function(t){this._ignoreEvent(t)||(this._onUp(t),document.removeEventListener("touchmove",this._onMove),document.removeEventListener("touchend",this._onTouchEnd))},_fireEvent:function(t,e){return this._map.fire(t,{originalEvent:e})},_ignoreEvent:function(t){var e=this._map;if(e.boxZoom&&e.boxZoom.isActive())return!0;if(e.dragRotate&&e.dragRotate.isActive())return!0;if(t.touches)return t.touches.length>1;if(t.ctrlKey)return!0;return"mousemove"===t.type?!1&t.buttons:0!==t.button},_drainInertiaBuffer:function(){for(var t=this._inertia,e=Date.now();t.length>0&&e-t[0][0]>160;)t.shift()}}},{"../../util/dom":429,"../../util/util":443}],417:[function(t,e,r){"use strict";function n(t,e){this._map=t,this._el=t.getCanvasContainer(),this._bearingSnap=e.bearingSnap,o.bindHandlers(this)}var i=t("../../util/dom"),a=t("point-geometry"),o=t("../../util/util");e.exports=n;var s=o.bezier(0,0,.25,1);n.prototype={_enabled:!1,_active:!1,isEnabled:function(){return this._enabled},isActive:function(){return this._active},enable:function(){this.isEnabled()||(this._el.addEventListener("mousedown",this._onDown),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("mousedown",this._onDown),this._enabled=!1)},_onDown:function(t){if(!this._ignoreEvent(t)&&!this.isActive()){document.addEventListener("mousemove",this._onMove),document.addEventListener("mouseup",this._onUp),this._active=!1,this._inertia=[[Date.now(),this._map.getBearing()]],this._startPos=this._pos=i.mousePos(this._el,t),this._center=this._map.transform.centerPoint;var e=this._startPos.sub(this._center);e.mag()<200&&(this._center=this._startPos.add(new a(-200,0)._rotate(e.angle()))),t.preventDefault()}},_onMove:function(t){if(!this._ignoreEvent(t)){this.isActive()||(this._active=!0,this._fireEvent("rotatestart",t),this._fireEvent("movestart",t));var e=this._map;e.stop();var r=this._pos,n=i.mousePos(this._el,t),a=this._center,o=r.sub(a).angleWith(n.sub(a))/Math.PI*180,s=e.getBearing()-o,l=this._inertia,c=l[l.length-1];this._drainInertiaBuffer(),l.push([Date.now(),e._normalizeBearing(s,c[1])]),e.transform.bearing=s,this._fireEvent("rotate",t),this._fireEvent("move",t),this._pos=n}},_onUp:function(t){if(!this._ignoreEvent(t)&&(document.removeEventListener("mousemove",this._onMove),document.removeEventListener("mouseup",this._onUp),this.isActive())){this._active=!1,this._fireEvent("rotateend",t),this._drainInertiaBuffer();var e=this._map,r=e.getBearing(),n=this._inertia,i=function(){Math.abs(r)180&&(d=180);var p=d/180;c+=h*d*(p/2),Math.abs(e._normalizeBearing(c,0))1;var r=t.ctrlKey?1:2,n=t.ctrlKey?0:2;return"mousemove"===t.type?t.buttons&0===r:t.button!==n},_drainInertiaBuffer:function(){for(var t=this._inertia,e=Date.now();t.length>0&&e-t[0][0]>160;)t.shift()}}},{"../../util/dom":429,"../../util/util":443,"point-geometry":485}],418:[function(t,e,r){"use strict";function n(t){this._map=t,this._el=t.getCanvasContainer(),this._onKeyDown=this._onKeyDown.bind(this)}e.exports=n;n.prototype={_enabled:!1,isEnabled:function(){return this._enabled},enable:function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},_onKeyDown:function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=this._map,r={originalEvent:t};if(!e.isEasing())switch(t.keyCode){case 61:case 107:case 171:case 187:e.zoomTo(Math.round(e.getZoom())+(t.shiftKey?2:1),r);break;case 189:case 109:case 173:e.zoomTo(Math.round(e.getZoom())-(t.shiftKey?2:1),r);break;case 37:t.shiftKey?e.easeTo({bearing:e.getBearing()-2},r):(t.preventDefault(),e.panBy([-80,0],r));break;case 39:t.shiftKey?e.easeTo({bearing:e.getBearing()+2},r):(t.preventDefault(),e.panBy([80,0],r));break;case 38:t.shiftKey?e.easeTo({pitch:e.getPitch()+5},r):(t.preventDefault(),e.panBy([0,-80],r));break;case 40:t.shiftKey?e.easeTo({pitch:Math.max(e.getPitch()-5,0)},r):(t.preventDefault(),e.panBy([0,80],r))}}}}},{}],419:[function(t,e,r){"use strict";function n(t){this._map=t,this._el=t.getCanvasContainer(),o.bindHandlers(this)}var i=t("../../util/dom"),a=t("../../util/browser"),o=t("../../util/util");e.exports=n;var s="undefined"!=typeof navigator?navigator.userAgent.toLowerCase():"",l=-1!==s.indexOf("firefox"),c=-1!==s.indexOf("safari")&&-1===s.indexOf("chrom");n.prototype={_enabled:!1,isEnabled:function(){return this._enabled},enable:function(){this.isEnabled()||(this._el.addEventListener("wheel",this._onWheel,!1),this._el.addEventListener("mousewheel",this._onWheel,!1),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("wheel",this._onWheel),this._el.removeEventListener("mousewheel",this._onWheel),this._enabled=!1)},_onWheel:function(t){var e;"wheel"===t.type?(e=t.deltaY,l&&t.deltaMode===window.WheelEvent.DOM_DELTA_PIXEL&&(e/=a.devicePixelRatio),t.deltaMode===window.WheelEvent.DOM_DELTA_LINE&&(e*=40)):"mousewheel"===t.type&&(e=-t.wheelDeltaY,c&&(e/=3));var r=a.now(),n=r-(this._time||0);this._pos=i.mousePos(this._el,t),this._time=r,0!==e&&e%4.000244140625==0?(this._type="wheel",e=Math.floor(e/4)):0!==e&&Math.abs(e)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40)):this._type||(this._type=Math.abs(n*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&this._zoom(-e,t),t.preventDefault()},_onTimeout:function(){this._type="wheel",this._zoom(-this._lastValue)},_zoom:function(t,e){if(0!==t){var r=this._map,n=2/(1+Math.exp(-Math.abs(t/100)));t<0&&0!==n&&(n=1/n);var i=r.ease?r.ease.to:r.transform.scale,a=r.transform.scaleZoom(i*n);r.zoomTo(a,{duration:0,around:r.unproject(this._pos),delayEndEvents:200},{originalEvent:e})}}}},{"../../util/browser":427,"../../util/dom":429,"../../util/util":443}],420:[function(t,e,r){"use strict";function n(t){this._map=t,this._el=t.getCanvasContainer(),a.bindHandlers(this)}var i=t("../../util/dom"),a=t("../../util/util");e.exports=n;var o=a.bezier(0,0,.15,1);n.prototype={_enabled:!1,isEnabled:function(){return this._enabled},enable:function(){this.isEnabled()||(this._el.addEventListener("touchstart",this._onStart,!1),this._enabled=!0)},disable:function(){this.isEnabled()&&(this._el.removeEventListener("touchstart",this._onStart),this._enabled=!1)},disableRotation:function(){this._rotationDisabled=!0},enableRotation:function(){this._rotationDisabled=!1},_onStart:function(t){if(2===t.touches.length){var e=i.mousePos(this._el,t.touches[0]),r=i.mousePos(this._el,t.touches[1]);this._startVec=e.sub(r),this._startScale=this._map.transform.scale,this._startBearing=this._map.transform.bearing,this._gestureIntent=void 0,this._inertia=[],document.addEventListener("touchmove",this._onMove,!1),document.addEventListener("touchend",this._onEnd,!1)}},_onMove:function(t){if(2===t.touches.length){var e=i.mousePos(this._el,t.touches[0]),r=i.mousePos(this._el,t.touches[1]),n=e.add(r).div(2),a=e.sub(r),o=a.mag()/this._startVec.mag(),s=this._rotationDisabled?0:180*a.angleWith(this._startVec)/Math.PI,l=this._map;if(this._gestureIntent){var c={duration:0,around:l.unproject(n)};"rotate"===this._gestureIntent&&(c.bearing=this._startBearing+s),"zoom"!==this._gestureIntent&&"rotate"!==this._gestureIntent||(c.zoom=l.transform.scaleZoom(this._startScale*o)),l.stop(),this._drainInertiaBuffer(),this._inertia.push([Date.now(),o,n]),l.easeTo(c,{originalEvent:t})}else{var u=Math.abs(1-o)>.15;Math.abs(s)>4?this._gestureIntent="rotate":u&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._startVec=a,this._startScale=l.transform.scale,this._startBearing=l.transform.bearing)}t.preventDefault()}},_onEnd:function(t){document.removeEventListener("touchmove",this._onMove),document.removeEventListener("touchend",this._onEnd),this._drainInertiaBuffer();var e=this._inertia,r=this._map;if(e.length<2)r.snapToNorth({},{originalEvent:t});else{var n=e[e.length-1],i=e[0],a=r.transform.scaleZoom(this._startScale*n[1]),s=r.transform.scaleZoom(this._startScale*i[1]),l=a-s,c=(n[0]-i[0])/1e3,u=n[2];if(0!==c&&a!==s){var h=.15*l/c;Math.abs(h)>2.5&&(h=h>0?2.5:-2.5);var f=1e3*Math.abs(h/(12*.15)),d=a+h*f/2e3;d<0&&(d=0),r.easeTo({zoom:d,duration:f,easing:o,around:r.unproject(u)},{originalEvent:t})}else r.snapToNorth({},{originalEvent:t})}},_drainInertiaBuffer:function(){for(var t=this._inertia,e=Date.now();t.length>2&&e-t[0][0]>160;)t.shift()}}},{"../../util/dom":429,"../../util/util":443}],421:[function(t,e,r){"use strict";function n(){i.bindAll(["_onHashChange","_updateHash"],this)}e.exports=n;var i=t("../util/util");n.prototype={addTo:function(t){return this._map=t,window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},remove:function(){return window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),delete this._map,this},_onHashChange:function(){var t=location.hash.replace("#","").split("/");return t.length>=3&&(this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:+(t[3]||0)}),!0)},_updateHash:function(){var t=this._map.getCenter(),e=this._map.getZoom(),r=this._map.getBearing(),n=Math.max(0,Math.ceil(Math.log(e)/Math.LN2)),i="#"+Math.round(100*e)/100+"/"+t.lat.toFixed(n)+"/"+t.lng.toFixed(n)+(r?"/"+Math.round(10*r)/10:"");window.history.replaceState("","",i)}}},{"../util/util":443}],422:[function(t,e,r){"use strict";function n(t){t.parentNode&&t.parentNode.removeChild(t)}var i=t("../util/canvas"),a=t("../util/util"),o=t("../util/browser"),s=t("../util/browser").window,l=t("../util/evented"),c=t("../util/dom"),u=t("../style/style"),h=t("../style/animation_loop"),f=t("../render/painter"),d=t("../geo/transform"),p=t("./hash"),m=t("./bind_handlers"),g=t("./camera"),v=t("../geo/lng_lat"),y=t("../geo/lng_lat_bounds"),b=t("point-geometry"),x=t("./control/attribution"),_={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:0,maxZoom:20,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,bearingSnap:7,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,workerCount:Math.max(o.hardwareConcurrency-1,1)},w=e.exports=function(t){if((t=a.extend({},_,t)).workerCount<1)throw new Error("workerCount must an integer greater than or equal to 1.");this._interactive=t.interactive,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._trackResize=t.trackResize,this._workerCount=t.workerCount,this._bearingSnap=t.bearingSnap,"string"==typeof t.container?this._container=document.getElementById(t.container):this._container=t.container,this.animationLoop=new h,this.transform=new d(t.minZoom,t.maxZoom),t.maxBounds&&this.setMaxBounds(t.maxBounds),a.bindAll(["_forwardStyleEvent","_forwardSourceEvent","_forwardLayerEvent","_forwardTileEvent","_onStyleLoad","_onStyleChange","_onSourceAdd","_onSourceRemove","_onSourceUpdate","_onWindowOnline","_onWindowResize","_update","_render"],this),this._setupContainer(),this._setupPainter(),this.on("move",this._update.bind(this,!1)),this.on("zoom",this._update.bind(this,!0)),this.on("moveend",function(){this.animationLoop.set(300),this._rerender()}.bind(this)),void 0!==s&&(s.addEventListener("online",this._onWindowOnline,!1),s.addEventListener("resize",this._onWindowResize,!1)),m(this,t),this._hash=t.hash&&(new p).addTo(this),this._hash&&this._hash._onHashChange()||this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),this.stacks={},this._classes=[],this.resize(),t.classes&&this.setClasses(t.classes),t.style&&this.setStyle(t.style),t.attributionControl&&this.addControl(new x(t.attributionControl));var e=this.fire.bind(this,"error");this.on("style.error",e),this.on("source.error",e),this.on("tile.error",e),this.on("layer.error",e)};a.extend(w.prototype,l),a.extend(w.prototype,g.prototype),a.extend(w.prototype,{addControl:function(t){return t.addTo(this),this},addClass:function(t,e){return this._classes.indexOf(t)>=0||""===t?this:(this._classes.push(t),this._classOptions=e,this.style&&this.style.updateClasses(),this._update(!0))},removeClass:function(t,e){var r=this._classes.indexOf(t);return r<0||""===t?this:(this._classes.splice(r,1),this._classOptions=e,this.style&&this.style.updateClasses(),this._update(!0))},setClasses:function(t,e){for(var r={},n=0;n=0},getClasses:function(){return this._classes},resize:function(){var t=0,e=0;return this._container&&(t=this._container.offsetWidth||400,e=this._container.offsetHeight||300),this._canvas.resize(t,e),this.transform.resize(t,e),this.painter.resize(t,e),this.fire("movestart").fire("move").fire("resize").fire("moveend")},getBounds:function(){var t=new y(this.transform.pointLocation(new b(0,0)),this.transform.pointLocation(this.transform.size));return(this.transform.angle||this.transform.pitch)&&(t.extend(this.transform.pointLocation(new b(this.transform.size.x,0))),t.extend(this.transform.pointLocation(new b(0,this.transform.size.y)))),t},setMaxBounds:function(t){if(t){var e=y.convert(t);this.transform.lngRange=[e.getWest(),e.getEast()],this.transform.latRange=[e.getSouth(),e.getNorth()],this.transform._constrain(),this._update()}else null!==t&&void 0!==t||(this.transform.lngRange=[],this.transform.latRange=[],this._update());return this},setMinZoom:function(t){if((t=null===t||void 0===t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom&&t<=20)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be between the current minZoom and 20, inclusive")},project:function(t){return this.transform.locationPoint(v.convert(t))},unproject:function(t){return this.transform.pointLocation(b.convert(t))},queryRenderedFeatures:function(){var t,e={};return 2===arguments.length?(t=arguments[0],e=arguments[1]):1===arguments.length&&function(t){return t instanceof b||Array.isArray(t)}(arguments[0])?t=arguments[0]:1===arguments.length&&(e=arguments[0]),this.style.queryRenderedFeatures(this._makeQueryGeometry(t),e,this.transform.zoom,this.transform.angle)},_makeQueryGeometry:function(t){void 0===t&&(t=[b.convert([0,0]),b.convert([this.transform.width,this.transform.height])]);var e;if(t instanceof b||"number"==typeof t[0]){e=[b.convert(t)]}else{var r=[b.convert(t[0]),b.convert(t[1])];e=[r[0],new b(r[1].x,r[0].y),r[1],new b(r[0].x,r[1].y),r[0]]}return e=e.map(function(t){return this.transform.pointCoordinate(t)}.bind(this))},querySourceFeatures:function(t,e){return this.style.querySourceFeatures(t,e)},setStyle:function(t){return this.style&&(this.style.off("load",this._onStyleLoad).off("error",this._forwardStyleEvent).off("change",this._onStyleChange).off("source.add",this._onSourceAdd).off("source.remove",this._onSourceRemove).off("source.load",this._onSourceUpdate).off("source.error",this._forwardSourceEvent).off("source.change",this._onSourceUpdate).off("layer.add",this._forwardLayerEvent).off("layer.remove",this._forwardLayerEvent).off("layer.error",this._forwardLayerEvent).off("tile.add",this._forwardTileEvent).off("tile.remove",this._forwardTileEvent).off("tile.load",this._update).off("tile.error",this._forwardTileEvent).off("tile.stats",this._forwardTileEvent)._remove(),this.off("rotate",this.style._redoPlacement),this.off("pitch",this.style._redoPlacement)),t?(this.style=t instanceof u?t:new u(t,this.animationLoop,this._workerCount),this.style.on("load",this._onStyleLoad).on("error",this._forwardStyleEvent).on("change",this._onStyleChange).on("source.add",this._onSourceAdd).on("source.remove",this._onSourceRemove).on("source.load",this._onSourceUpdate).on("source.error",this._forwardSourceEvent).on("source.change",this._onSourceUpdate).on("layer.add",this._forwardLayerEvent).on("layer.remove",this._forwardLayerEvent).on("layer.error",this._forwardLayerEvent).on("tile.add",this._forwardTileEvent).on("tile.remove",this._forwardTileEvent).on("tile.load",this._update).on("tile.error",this._forwardTileEvent).on("tile.stats",this._forwardTileEvent),this.on("rotate",this.style._redoPlacement),this.on("pitch",this.style._redoPlacement),this):(this.style=null,this)},getStyle:function(){if(this.style)return this.style.serialize()},addSource:function(t,e){return this.style.addSource(t,e),this._update(!0),this},addSourceType:function(t,e,r){return this.style.addSourceType(t,e,r)},removeSource:function(t){return this.style.removeSource(t),this._update(!0),this},getSource:function(t){return this.style.getSource(t)},addLayer:function(t,e){return this.style.addLayer(t,e),this._update(!0),this},removeLayer:function(t){return this.style.removeLayer(t),this._update(!0),this},getLayer:function(t){return this.style.getLayer(t)},setFilter:function(t,e){return this.style.setFilter(t,e),this._update(!0),this},setLayerZoomRange:function(t,e,r){return this.style.setLayerZoomRange(t,e,r),this._update(!0),this},getFilter:function(t){return this.style.getFilter(t)},setPaintProperty:function(t,e,r,n){return this.style.setPaintProperty(t,e,r,n),this._update(!0),this},getPaintProperty:function(t,e,r){return this.style.getPaintProperty(t,e,r)},setLayoutProperty:function(t,e,r){return this.style.setLayoutProperty(t,e,r),this._update(!0),this},getLayoutProperty:function(t,e){return this.style.getLayoutProperty(t,e)},getContainer:function(){return this._container},getCanvasContainer:function(){return this._canvasContainer},getCanvas:function(){return this._canvas.getElement()},_setupContainer:function(){var t=this._container;t.classList.add("mapboxgl-map");var e=this._canvasContainer=c.create("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=new i(this,e);var r=this._controlContainer=c.create("div","mapboxgl-control-container",t),n=this._controlCorners={};["top-left","top-right","bottom-left","bottom-right"].forEach(function(t){n[t]=c.create("div","mapboxgl-ctrl-"+t,r)})},_setupPainter:function(){var t=this._canvas.getWebGLContext({failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer});t?this.painter=new f(t,this.transform):this.fire("error",{error:new Error("Failed to initialize WebGL")})},_contextLost:function(t){t.preventDefault(),this._frameId&&o.cancelFrame(this._frameId),this.fire("webglcontextlost",{originalEvent:t})},_contextRestored:function(t){this._setupPainter(),this.resize(),this._update(),this.fire("webglcontextrestored",{originalEvent:t})},loaded:function(){return!this._styleDirty&&!this._sourcesDirty&&!(!this.style||!this.style.loaded())},_update:function(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this._rerender(),this):this},_render:function(){try{this.style&&this._styleDirty&&(this._styleDirty=!1,this.style.update(this._classes,this._classOptions),this._classOptions=null,this.style._recalculate(this.transform.zoom)),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.painter.render(this.style,{debug:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,vertices:this.vertices,rotating:this.rotating,zooming:this.zooming}),this.fire("render"),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire("load")),this._frameId=null,this.animationLoop.stopped()||(this._styleDirty=!0),(this._sourcesDirty||this._repaint||this._styleDirty)&&this._rerender()}catch(t){this.fire("error",{error:t})}return this},remove:function(){this._hash&&this._hash.remove(),o.cancelFrame(this._frameId),this.setStyle(null),void 0!==s&&s.removeEventListener("resize",this._onWindowResize,!1);var t=this.painter.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),n(this._canvasContainer),n(this._controlContainer),this._container.classList.remove("mapboxgl-map")},_rerender:function(){this.style&&!this._frameId&&(this._frameId=o.frame(this._render))},_forwardStyleEvent:function(t){this.fire("style."+t.type,a.extend({style:t.target},t))},_forwardSourceEvent:function(t){this.fire(t.type,a.extend({style:t.target},t))},_forwardLayerEvent:function(t){this.fire(t.type,a.extend({style:t.target},t))},_forwardTileEvent:function(t){this.fire(t.type,a.extend({style:t.target},t))},_onStyleLoad:function(t){this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this.style.update(this._classes,{transition:!1}),this._forwardStyleEvent(t)},_onStyleChange:function(t){this._update(!0),this._forwardStyleEvent(t)},_onSourceAdd:function(t){var e=t.source;e.onAdd&&e.onAdd(this),this._forwardSourceEvent(t)},_onSourceRemove:function(t){var e=t.source;e.onRemove&&e.onRemove(this),this._forwardSourceEvent(t)},_onSourceUpdate:function(t){this._update(),this._forwardSourceEvent(t)},_onWindowOnline:function(){this._update()},_onWindowResize:function(){this._trackResize&&this.stop().resize()._update()}}),a.extendAll(w.prototype,{_showTileBoundaries:!1,get showTileBoundaries(){return this._showTileBoundaries},set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())},_showCollisionBoxes:!1,get showCollisionBoxes(){return this._showCollisionBoxes},set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,this.style._redoPlacement())},_showOverdrawInspector:!1,get showOverdrawInspector(){return this._showOverdrawInspector},set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())},_repaint:!1,get repaint(){return this._repaint},set repaint(t){this._repaint=t,this._update()},_vertices:!1,get vertices(){return this._vertices},set vertices(t){this._vertices=t,this._update()}})},{"../geo/lng_lat":340,"../geo/lng_lat_bounds":341,"../geo/transform":342,"../render/painter":356,"../style/animation_loop":376,"../style/style":379,"../util/browser":427,"../util/canvas":428,"../util/dom":429,"../util/evented":435,"../util/util":443,"./bind_handlers":408,"./camera":409,"./control/attribution":410,"./hash":421,"point-geometry":485}],423:[function(t,e,r){"use strict";function n(t,e){t||(t=i.create("div")),t.classList.add("mapboxgl-marker"),this._el=t,this._offset=o.convert(e&&e.offset||[0,0]),this._update=this._update.bind(this)}e.exports=n;var i=t("../util/dom"),a=t("../geo/lng_lat"),o=t("point-geometry");n.prototype={addTo:function(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._el),t.on("move",this._update),this._update(),this},remove:function(){this._map&&(this._map.off("move",this._update),this._map=null);var t=this._el.parentNode;return t&&t.removeChild(this._el),this},getLngLat:function(){return this._lngLat},setLngLat:function(t){return this._lngLat=a.convert(t),this._update(),this},getElement:function(){return this._el},_update:function(){if(this._map){var t=this._map.project(this._lngLat)._add(this._offset);i.setTransform(this._el,"translate("+t.x+"px,"+t.y+"px)")}}}},{"../geo/lng_lat":340,"../util/dom":429,"point-geometry":485}],424:[function(t,e,r){"use strict";function n(t){i.setOptions(this,t),i.bindAll(["_update","_onClickClose"],this)}e.exports=n;var i=t("../util/util"),a=t("../util/evented"),o=t("../util/dom"),s=t("../geo/lng_lat");n.prototype=i.inherit(a,{options:{closeButton:!0,closeOnClick:!0},addTo:function(t){return this._map=t,this._map.on("move",this._update),this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._update(),this},remove:function(){return this._content&&this._content.parentNode&&this._content.parentNode.removeChild(this._content),this._container&&(this._container.parentNode.removeChild(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),delete this._map),this.fire("close"),this},getLngLat:function(){return this._lngLat},setLngLat:function(t){return this._lngLat=s.convert(t),this._update(),this},setText:function(t){return this.setDOMContent(document.createTextNode(t))},setHTML:function(t){var e,r=document.createDocumentFragment(),n=document.createElement("body");for(n.innerHTML=t;e=n.firstChild;)r.appendChild(e);return this.setDOMContent(r)},setDOMContent:function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},_createContent:function(){this._content&&this._content.parentNode&&this._content.parentNode.removeChild(this._content),this._content=o.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=o.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},_update:function(){if(this._map&&this._lngLat&&this._content){this._container||(this._container=o.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=o.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content));var t=this._map.project(this._lngLat).round(),e=this.options.anchor;if(!e){var r=this._container.offsetWidth,n=this._container.offsetHeight;e=t.ythis._map.transform.height-n?["bottom"]:[],t.xthis._map.transform.width-r/2&&e.push("right"),e=0===e.length?"bottom":e.join("-")}var i={top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},a=this._container.classList;for(var s in i)a.remove("mapboxgl-popup-anchor-"+s);a.add("mapboxgl-popup-anchor-"+e),o.setTransform(this._container,i[e]+" translate("+t.x+"px,"+t.y+"px)")}},_onClickClose:function(){this.remove()}})},{"../geo/lng_lat":340,"../util/dom":429,"../util/evented":435,"../util/util":443}],425:[function(t,e,r){"use strict";function n(t,e){this.target=t,this.parent=e,this.callbacks={},this.callbackID=0,this.receive=this.receive.bind(this),this.target.addEventListener("message",this.receive,!1)}e.exports=n,n.prototype.receive=function(t){function e(t,e,r){this.postMessage({type:"",id:String(i),error:t?String(t):null,data:e},r)}var r,n=t.data,i=n.id;if(""===n.type)r=this.callbacks[n.id],delete this.callbacks[n.id],r&&r(n.error||null,n.data);else if(void 0!==n.id&&this.parent[n.type])this.parent[n.type](n.data,e.bind(this));else if(void 0!==n.id&&this.parent.workerSources){var a=n.type.split(".");this.parent.workerSources[a[0]][a[1]](n.data,e.bind(this))}else this.parent[n.type](n.data)},n.prototype.send=function(t,e,r,n){var i=null;r&&(this.callbacks[i=this.callbackID++]=r),this.postMessage({type:t,id:String(i),data:e},n)},n.prototype.postMessage=function(t,e){this.target.postMessage(t,e)}},{}],426:[function(t,e,r){"use strict";function n(t){var e=document.createElement("a");return e.href=t,e.protocol===document.location.protocol&&e.host===document.location.host}r.getJSON=function(t,e){var r=new XMLHttpRequest;return r.open("GET",t,!0),r.setRequestHeader("Accept","application/json"),r.onerror=function(t){e(t)},r.onload=function(){if(r.status>=200&&r.status<300&&r.response){var t;try{t=JSON.parse(r.response)}catch(t){return e(t)}e(null,t)}else e(new Error(r.statusText))},r.send(),r},r.getArrayBuffer=function(t,e){var r=new XMLHttpRequest;return r.open("GET",t,!0),r.responseType="arraybuffer",r.onerror=function(t){e(t)},r.onload=function(){r.status>=200&&r.status<300&&r.response?e(null,r.response):e(new Error(r.statusText))},r.send(),r},r.getImage=function(t,e){return r.getArrayBuffer(t,function(t,r){if(t)return e(t);var n=new Image;n.onload=function(){e(null,n),(window.URL||window.webkitURL).revokeObjectURL(n.src)};var i=new Blob([new Uint8Array(r)],{type:"image/png"});return n.src=(window.URL||window.webkitURL).createObjectURL(i),n.getData=function(){var t=document.createElement("canvas"),e=t.getContext("2d");return t.width=n.width,t.height=n.height,e.drawImage(n,0,0),e.getImageData(0,0,n.width,n.height).data},n})},r.getVideo=function(t,e){var r=document.createElement("video");r.onloadstart=function(){e(null,r)};for(var i=0;i=s+n?t.call(i,1):(t.call(i,(l-s)/n),r.frame(a)))}if(!n)return t.call(i,1),null;var o=!1,s=e.exports.now();return r.frame(a),function(){o=!0}},r.supported=t("mapbox-gl-supported"),r.hardwareConcurrency=navigator.hardwareConcurrency||4,Object.defineProperty(r,"devicePixelRatio",{get:function(){return window.devicePixelRatio}}),r.supportsWebp=!1;var a=document.createElement("img");a.onload=function(){r.supportsWebp=!0},a.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=",r.supportsGeolocation=!!navigator.geolocation},{"mapbox-gl-supported":328}],428:[function(t,e,r){"use strict";function n(t,e){this.canvas=document.createElement("canvas"),t&&e&&(this.canvas.style.position="absolute",this.canvas.classList.add("mapboxgl-canvas"),this.canvas.addEventListener("webglcontextlost",t._contextLost.bind(t),!1),this.canvas.addEventListener("webglcontextrestored",t._contextRestored.bind(t),!1),this.canvas.setAttribute("tabindex",0),e.appendChild(this.canvas))}var i=t("../util"),a=t("mapbox-gl-supported");e.exports=n,n.prototype.resize=function(t,e){var r=window.devicePixelRatio||1;this.canvas.width=r*t,this.canvas.height=r*e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px"},n.prototype.getWebGLContext=function(t){return t=i.extend({},t,a.webGLContextAttributes),this.canvas.getContext("webgl",t)||this.canvas.getContext("experimental-webgl",t)},n.prototype.getElement=function(){return this.canvas}},{"../util":443,"mapbox-gl-supported":328}],429:[function(t,e,r){"use strict";function n(t){for(var e=0;e1)for(var u=0;u=0&&this._events[t].splice(r,1),this._events[t].length||delete this._events[t]}else delete this._events[t];return this},once:function(t,e){var r=function(n){this.off(t,r),e.call(this,n)}.bind(this);return this.on(t,r),this},fire:function(t,e){if(!this.listens(t))return n.endsWith(t,"error")&&console.error(e&&e.error||e||"Empty error event"),this;e=n.extend({},e),n.extend(e,{type:t,target:this});for(var r=this._events[t].slice(),i=0;i(e.y-t.y)*(r.x-t.x)}function a(t,e,r){var n=r*r;if(1===e.length)return t.distSqr(e[0])1?t.distSqr(r):t.distSqr(r.sub(e)._mult(i)._add(e))}(t,e[i-1],e[i])e.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);return a}function s(t,e){for(var r=!1,n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}e.exports={multiPolygonIntersectsBufferedMultiPoint:function(t,e,r){for(var n=0;n=3)for(var u=0;u1){if(n(t,e))return!0;for(var i=0;ithis.max){var r=this.get(this.order[0]);r&&this.onRemove(r)}return this},n.prototype.has=function(t){return t in this.data},n.prototype.keys=function(){return this.order},n.prototype.get=function(t){if(!this.has(t))return null;var e=this.data[t];return delete this.data[t],this.order.splice(this.order.indexOf(t),1),e},n.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this.get(this.order[0]);e&&this.onRemove(e)}return this}},{}],440:[function(t,e,r){"use strict";function n(t,e,r){if(!(r=r||a.ACCESS_TOKEN)&&a.REQUIRE_ACCESS_TOKEN)throw new Error("An API access token is required to use Mapbox GL. See https://www.mapbox.com/developers/api/#access-tokens");if(t=t.replace(/^mapbox:\/\//,a.API_URL+e),t+=-1!==t.indexOf("?")?"&access_token=":"?access_token=",a.REQUIRE_ACCESS_TOKEN){if("s"===r[0])throw new Error("Use a public access token (pk.*) with Mapbox GL JS, not a secret access token (sk.*). See https://www.mapbox.com/developers/api/#access-tokens");t+=r}return t}function i(t){return t?"?"+t:""}var a=t("./config"),o=t("./browser"),s=t("url"),l=t("./util");e.exports.normalizeStyleURL=function(t,e){var r=s.parse(t);return"mapbox:"!==r.protocol?t:n("mapbox:/"+r.pathname+i(r.query),"/styles/v1/",e)},e.exports.normalizeSourceURL=function(t,e){return"mapbox:"!==s.parse(t).protocol?t:n(t+".json","/v4/",e)+"&secure"},e.exports.normalizeGlyphsURL=function(t,e){var r=s.parse(t);if("mapbox:"!==r.protocol)return t;return n("mapbox://"+r.pathname.split("/")[1]+"/{fontstack}/{range}.pbf"+i(r.query),"/fonts/v1/",e)},e.exports.normalizeSpriteURL=function(t,e,r,a){var o=s.parse(t);return"mapbox:"!==o.protocol?(o.pathname+=e+r,s.format(o)):n("mapbox:/"+o.pathname+"/sprite"+e+r+i(o.query),"/styles/v1/",a)},e.exports.normalizeTileURL=function(t,e,r){var n=s.parse(t,!0);if(!e)return t;if("mapbox:"!==s.parse(e).protocol)return t;var i=o.supportsWebp?".webp":"$1",c=o.devicePixelRatio>=2||512===r?"@2x":"";return s.format({protocol:n.protocol,hostname:n.hostname,pathname:n.pathname.replace(/(\.(?:png|jpg)\d*)/,c+i),query:function(t){return t.access_token&&"tk."===t.access_token.slice(0,3)?l.extend({},t,{access_token:a.ACCESS_TOKEN}):t}(n.query)})}},{"./browser":427,"./config":432,"./util":443,url:554}],441:[function(t,e,r){"use strict";function n(){return{members:this.prototype.StructType.prototype.members,alignment:this.prototype.StructType.prototype.alignment,bytesPerElement:this.prototype.bytesPerElement}}function i(t,e){return Math.ceil(t/e)*e}function a(t){return h[t].BYTES_PER_ELEMENT}function o(t){return t.toLowerCase()}function s(t,e){var r="this._pos"+a(t.type).toFixed(0)+" + "+(t.offset/a(t.type)+e).toFixed(0);return"this._structArray."+o(t.type)+"["+r+"]"}function l(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}function c(t){void 0!==t?(this.arrayBuffer=t.arrayBuffer,this.length=t.length,this.capacity=this.arrayBuffer.byteLength/this.bytesPerElement,this._refreshViews()):(this.capacity=-1,this.resize(0))}var u=t("assert");e.exports=function(t){function e(){l.apply(this,arguments)}function r(){c.apply(this,arguments),this.members=e.prototype.members}var d=JSON.stringify(t);if(f[d])return f[d];void 0===t.alignment&&(t.alignment=1);var p=0,m=0,g=["Uint8"];return(e.prototype=Object.create(l.prototype)).members=t.members.map(function(r){r={name:r.name,type:r.type,components:r.components||1},u(r.name.length),u(r.type in h),g.indexOf(r.type)<0&&g.push(r.type);var n=a(r.type);m=Math.max(m,n),r.offset=p=i(p,Math.max(t.alignment,n));for(var o=0;othis.capacity){this.capacity=Math.max(t,Math.floor(this.capacity*this.RESIZE_MULTIPLIER),this.DEFAULT_CAPACITY),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},c.prototype._refreshViews=function(){for(var t=0;t=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)},r.bezier=function(t,e,r,i){var a=new n(t,e,r,i);return function(t){return a.solve(t)}},r.ease=r.bezier(.25,.1,.25,1),r.clamp=function(t,e,r){return Math.min(r,Math.max(e,t))},r.wrap=function(t,e,r){var n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i},r.coalesce=function(){for(var t=0;t=0)return!0;return!1};var o={};r.warnOnce=function(t){o[t]||("undefined"!=typeof console&&console.warn(t),o[t]=!0)}},{"../geo/coordinate":339,unitbezier:553}],444:[function(t,e,r){"use strict";function n(t,e,r,n){this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,null!=t.id&&(this.id=t.id)}e.exports=n,n.prototype={type:"Feature",get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry},set geometry(t){this._geometry=t},toJSON:function(){var t={};for(var e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"toJSON"!==e&&(t[e]=this[e]);return t}}},{}],445:[function(t,e,r){e.exports={_args:[[{raw:"mapbox-gl@^0.22.0",scope:null,escapedName:"mapbox-gl",name:"mapbox-gl",rawSpec:"^0.22.0",spec:">=0.22.0 <0.23.0",type:"range"},"/home/etienne/Documents/plotly/plotly.js"]],_from:"mapbox-gl@>=0.22.0 <0.23.0",_id:"mapbox-gl@0.22.1",_inCache:!0,_location:"/mapbox-gl",_nodeVersion:"4.4.5",_npmOperationalInternal:{host:"packages-12-west.internal.npmjs.com",tmp:"tmp/mapbox-gl-0.22.1.tgz_1471549891670_0.8762630566488951"},_npmUser:{name:"lucaswoj",email:"lucas@lucaswoj.com"},_npmVersion:"2.15.5",_phantomChildren:{},_requested:{raw:"mapbox-gl@^0.22.0",scope:null,escapedName:"mapbox-gl",name:"mapbox-gl",rawSpec:"^0.22.0",spec:">=0.22.0 <0.23.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.22.1.tgz",_shasum:"92a965547d4c2f24c22cbc487eeda48694cb627a",_shrinkwrap:null,_spec:"mapbox-gl@^0.22.0",_where:"/home/etienne/Documents/plotly/plotly.js",browser:{"./js/util/ajax.js":"./js/util/browser/ajax.js","./js/util/browser.js":"./js/util/browser/browser.js","./js/util/canvas.js":"./js/util/browser/canvas.js","./js/util/dom.js":"./js/util/browser/dom.js","./js/util/web_worker.js":"./js/util/browser/web_worker.js"},bugs:{url:"https://github.com/mapbox/mapbox-gl-js/issues"},dependencies:{csscolorparser:"^1.0.2",earcut:"^2.0.3","feature-filter":"^2.2.0","geojson-rewind":"^0.1.0","geojson-vt":"^2.4.0","gl-matrix":"^2.3.1","grid-index":"^1.0.0","mapbox-gl-function":"^1.2.1","mapbox-gl-shaders":"github:mapbox/mapbox-gl-shaders#de2ab007455aa2587c552694c68583f94c9f2747","mapbox-gl-style-spec":"github:mapbox/mapbox-gl-style-spec#83b1a3e5837d785af582efd5ed1a212f2df6a4ae","mapbox-gl-supported":"^1.2.0",pbf:"^1.3.2",pngjs:"^2.2.0","point-geometry":"^0.0.0",quickselect:"^1.0.0",request:"^2.39.0","resolve-url":"^0.2.1","shelf-pack":"^1.0.0",supercluster:"^2.0.1",unassertify:"^2.0.0",unitbezier:"^0.0.0","vector-tile":"^1.3.0","vt-pbf":"^2.0.2",webworkify:"^1.3.0","whoots-js":"^2.0.0"},description:"A WebGL interactive maps library",devDependencies:{"babel-preset-react":"^6.11.1",babelify:"^7.3.0",benchmark:"~2.1.0",browserify:"^13.0.0",clipboard:"^1.5.12","concat-stream":"1.5.1",coveralls:"^2.11.8",doctrine:"^1.2.1",documentation:"https://github.com/documentationjs/documentation/archive/bb41619c734e59ef3fbc3648610032efcfdaaace.tar.gz","documentation-theme-utils":"3.0.0",envify:"^3.4.0",eslint:"^2.5.3","eslint-config-mourner":"^2.0.0","eslint-plugin-html":"^1.5.1",gl:"^4.0.1",handlebars:"4.0.5","highlight.js":"9.3.0",istanbul:"^0.4.2","json-loader":"^0.5.4",lodash:"^4.13.1","mapbox-gl-test-suite":"github:mapbox/mapbox-gl-test-suite#7babab52fb02788ebbc38384139bf350e8e38552","memory-fs":"^0.3.0",minifyify:"^7.0.1","npm-run-all":"^3.0.0",nyc:"6.4.0",proxyquire:"^1.7.9",remark:"4.2.2","remark-html":"3.0.0",sinon:"^1.15.4",st:"^1.2.0",tap:"^5.7.0","transform-loader":"^0.2.3","unist-util-visit":"1.1.0",vinyl:"1.1.1","vinyl-fs":"2.4.3",watchify:"^3.7.0",webpack:"^1.13.1","webworkify-webpack":"^1.1.3"},directories:{},dist:{shasum:"92a965547d4c2f24c22cbc487eeda48694cb627a",tarball:"https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.22.1.tgz"},engines:{node:">=4.0.0"},gitHead:"13a9015341f0602ccb55c98c53079838ad4b70b5",homepage:"https://github.com/mapbox/mapbox-gl-js#readme",license:"BSD-3-Clause",main:"js/mapbox-gl.js",maintainers:[{name:"aaronlidman",email:"aaronlidman@gmail.com"},{name:"ajashton",email:"aj.ashton@gmail.com"},{name:"ansis",email:"ansis.brammanis@gmail.com"},{name:"bergwerkgis",email:"wb@bergwerk-gis.at"},{name:"bhousel",email:"bryan@mapbox.com"},{name:"bsudekum",email:"bobby@mapbox.com"},{name:"camilleanne",email:"camille@mapbox.com"},{name:"dnomadb",email:"damon@mapbox.com"},{name:"dthompson",email:"dthompson@gmail.com"},{name:"emilymcafee",email:"emily@mapbox.com"},{name:"flippmoke",email:"flippmoke@gmail.com"},{name:"freenerd",email:"spam@freenerd.de"},{name:"gretacb",email:"carol@mapbox.com"},{name:"ian29",email:"ian.villeda@gmail.com"},{name:"ianshward",email:"ian@mapbox.com"},{name:"ingalls",email:"nicholas.ingalls@gmail.com"},{name:"jfirebaugh",email:"john.firebaugh@gmail.com"},{name:"jrpruit1",email:"jake@jakepruitt.com"},{name:"karenzshea",email:"karen@mapbox.com"},{name:"kkaefer",email:"kkaefer@gmail.com"},{name:"lbud",email:"lauren@mapbox.com"},{name:"lucaswoj",email:"lucas@lucaswoj.com"},{name:"lxbarth",email:"alex@mapbox.com"},{name:"lyzidiamond",email:"lyzi@mapbox.com"},{name:"mapbox-admin",email:"accounts@mapbox.com"},{name:"mateov",email:"matt@mapbox.com"},{name:"mcwhittemore",email:"mcwhittemore@gmail.com"},{name:"miccolis",email:"jeff@miccolis.net"},{name:"mikemorris",email:"michael.patrick.morris@gmail.com"},{name:"morganherlocker",email:"morgan.herlocker@gmail.com"},{name:"mourner",email:"agafonkin@gmail.com"},{name:"nickidlugash",email:"nicki@mapbox.com"},{name:"rclark",email:"ryan.clark.j@gmail.com"},{name:"samanbb",email:"saman@mapbox.com"},{name:"sbma44",email:"tlee@mapbox.com"},{name:"scothis",email:"scothis@gmail.com"},{name:"sgillies",email:"sean@mapbox.com"},{name:"springmeyer",email:"dane@mapbox.com"},{name:"themarex",email:"patrick@mapbox.com"},{name:"tmcw",email:"tom@macwright.org"},{name:"tristen",email:"tristen.brown@gmail.com"},{name:"willwhite",email:"will@mapbox.com"},{name:"yhahn",email:"young@mapbox.com"}],name:"mapbox-gl",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git://github.com/mapbox/mapbox-gl-js.git"},scripts:{build:"npm run build-docs # invoked by publisher when publishing docs on the mb-pages branch","build-dev":"browserify js/mapbox-gl.js --debug --standalone mapboxgl > dist/mapbox-gl-dev.js && tap --no-coverage test/build/dev.test.js","build-docs":"documentation build --github --format html -c documentation.yml --theme ./docs/_theme --output docs/api/","build-min":"browserify js/mapbox-gl.js --debug -t unassertify --plugin [minifyify --map mapbox-gl.js.map --output dist/mapbox-gl.js.map] --standalone mapboxgl > dist/mapbox-gl.js && tap --no-coverage test/build/min.test.js","build-token":"browserify debug/access-token-src.js --debug -t envify > debug/access-token.js",lint:"eslint --ignore-path .gitignore js test bench docs/_posts/examples/*.html","open-changed-examples":"git diff --name-only mb-pages HEAD -- docs/_posts/examples/*.html | awk '{print \"http://127.0.0.1:4000/mapbox-gl-js/example/\" substr($0,33,length($0)-37)}' | xargs open",start:"run-p build-token watch-dev watch-bench start-server","start-bench":"run-p build-token watch-bench start-server","start-debug":"run-p build-token watch-dev start-server","start-docs":"npm run build-min && npm run build-docs && jekyll serve -w","start-server":"st --no-cache --localhost --port 9966 --index index.html .",test:"npm run lint && tap --reporter dot test/js/*/*.js test/build/webpack.test.js","test-suite":"node test/render.test.js && node test/query.test.js","watch-bench":"node bench/download-data.js && watchify bench/index.js --plugin [minifyify --no-map] -t [babelify --presets react] -t unassertify -t envify -o bench/bench.js -v","watch-dev":"watchify js/mapbox-gl.js --debug --standalone mapboxgl -o dist/mapbox-gl-dev.js -v"},version:"0.22.1"}},{}],446:[function(t,e,r){"use strict";function n(t,e,r){for(var n=new Array(t),i=0;ip[1][2]&&(v[0]=-v[0]),p[0][2]>p[2][0]&&(v[1]=-v[1]),p[1][0]>p[0][1]&&(v[2]=-v[2]),!0}},{"./normalize":448,"gl-mat4/clone":176,"gl-mat4/create":177,"gl-mat4/determinant":178,"gl-mat4/invert":182,"gl-mat4/transpose":192,"gl-vec3/cross":273,"gl-vec3/dot":274,"gl-vec3/length":275,"gl-vec3/normalize":277}],448:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],449:[function(t,e,r){function n(){return{translate:i(),scale:i(1),skew:i(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function i(t){return[t||0,t||0,t||0]}var a=t("gl-vec3/lerp"),o=t("mat4-recompose"),s=t("mat4-decompose"),l=t("gl-mat4/determinant"),c=t("quat-slerp"),u=n(),h=n(),f=n();e.exports=function(t,e,r,n){if(0===l(e)||0===l(r))return!1;var i=s(e,u.translate,u.scale,u.skew,u.perspective,u.quaternion),d=s(r,h.translate,h.scale,h.skew,h.perspective,h.quaternion);return!(!i||!d||(a(f.translate,u.translate,h.translate,n),a(f.skew,u.skew,h.skew,n),a(f.scale,u.scale,h.scale,n),a(f.perspective,u.perspective,h.perspective,n),c(f.quaternion,u.quaternion,h.quaternion,n),o(t,f.translate,f.scale,f.skew,f.perspective,f.quaternion),0))}},{"gl-mat4/determinant":178,"gl-vec3/lerp":276,"mat4-decompose":447,"mat4-recompose":450,"quat-slerp":498}],450:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":177,"gl-mat4/fromRotationTranslation":180,"gl-mat4/identity":181,"gl-mat4/multiply":184,"gl-mat4/scale":190,"gl-mat4/translate":191}],451:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}var i=t("binary-search-bounds"),a=t("mat4-interpolate"),o=t("gl-mat4/invert"),s=t("gl-mat4/rotateX"),l=t("gl-mat4/rotateY"),c=t("gl-mat4/rotateZ"),u=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),f=(t("gl-mat4/scale"),t("gl-vec3/normalize")),d=[0,0,0];e.exports=function(t){return new n((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var p=n.prototype;p.recalcMatrix=function(t){var e=this._time,r=i.le(e,t),n=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,c=0;c<16;++c)n[c]=s[l++];else{var u=e[r+1]-e[r],h=(l=16*r,this.prevMatrix),d=!0;for(c=0;c<16;++c)h[c]=s[l++];var p=this.nextMatrix;for(c=0;c<16;++c)p[c]=s[l++],d=d&&h[c]===p[c];if(u<1e-6||d)for(c=0;c<16;++c)n[c]=h[c];else a(n,h,p,(t-e[r])/u)}var m=this.computedUp;m[0]=n[1],m[1]=n[5],m[2]=n[9],f(m,m);var g=this.computedInverse;o(g,n);var v=this.computedEye,y=g[15];v[0]=g[12]/y,v[1]=g[13]/y,v[2]=g[14]/y;var b=this.computedCenter,x=Math.exp(this.computedRadius[0]);for(c=0;c<3;++c)b[c]=v[c]-n[2+4*c]*x}},p.idle=function(t){if(!(t1&&n(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&n(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}r=new Array(s.length+o.length-2);for(var h=0,f=(i=0,o.length);i0;--d)r[h++]=s[d];return r};var n=t("robust-orientation")[3]},{"robust-orientation":517}],453:[function(t,e,r){"use strict";e.exports=function(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==m.alt,m.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==m.shift,m.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==m.control,m.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==m.meta,m.meta=!!t.metaKey),e}function i(t,i){var a=n.x(i),o=n.y(i);"buttons"in i&&(t=0|i.buttons),(t!==f||a!==d||o!==p||r(i))&&(f=0|t,d=a||0,p=o||0,e&&e(f,d,p,m))}function a(t){i(0,t)}function o(){(f||d||p||m.shift||m.alt||m.meta||m.control)&&(d=p=0,f=0,m.shift=m.alt=m.control=m.meta=!1,e&&e(0,0,0,m))}function s(t){r(t)&&e&&e(f,d,p,m)}function l(t){0===n.buttons(t)?i(0,t):i(f,t)}function c(t){i(f|n.buttons(t),t)}function u(t){i(f&~n.buttons(t),t)}function h(){g||(g=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var f=0,d=0,p=0,m={shift:!1,alt:!1,control:!1,meta:!1},g=!1;h();var v={element:t};return Object.defineProperties(v,{enabled:{get:function(){return g},set:function(e){e?h():g&&(g=!1,t.removeEventListener("mousemove",l),t.removeEventListener("mousedown",c),t.removeEventListener("mouseup",u),t.removeEventListener("mouseleave",a),t.removeEventListener("mouseenter",a),t.removeEventListener("mouseout",a),t.removeEventListener("mouseover",a),t.removeEventListener("blur",o),t.removeEventListener("keyup",s),t.removeEventListener("keydown",s),t.removeEventListener("keypress",s),t!==window&&(window.removeEventListener("blur",o),window.removeEventListener("keyup",s),window.removeEventListener("keydown",s),window.removeEventListener("keypress",s)))},enumerable:!0},buttons:{get:function(){return f},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return m},enumerable:!0}}),v};var n=t("mouse-event")},{"mouse-event":455}],454:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i=t.clientX||0,a=t.clientY||0,o=function(t){return t===window||t===document||t===document.body?n:t.getBoundingClientRect()}(e);return r[0]=i-o.left,r[1]=a-o.top,r}},{}],455:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<0;k=k-1&m)x.push(_+"["+T+"+"+g(k)+"]");for(x.push(v(0)),k=0;k=0;--e)L(e,0);var r=[];for(e=0;e0){",f(S[t]),"=1;"),P(t-1,e|1<0&&H.push(s(N,S[B-1])+"*"+o(S[B-1])),R.push(d(N,S[B])+"=("+H.join("-")+")|0")}for(N=0;N=0;--N)q.push(o(S[N]));R.push(k+"=("+q.join("*")+")|0",w+"=mallocUint32("+k+")",_+"=mallocUint32("+k+")",T+"=0"),R.push(p(0)+"=0");for(B=1;B<1< 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;s=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)};var _="V",w="P",M="N",k="Q",T="X",A="T"},{"typedarray-pool":550}],458:[function(t,e,r){"use strict";var n=t("cwise/lib/wrapper")({args:["index","array","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_1_arg1_=_inline_1_arg2_.apply(void 0,_inline_1_arg0_)}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64});e.exports=function(t,e){return n(t,e),t}},{"cwise/lib/wrapper":114}],459:[function(t,e,r){"use strict";function n(t){if(t in o)return o[t];for(var e=[],r=0;r=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),o.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+o.join()+")";if(0===n.length&&(c=""),r>0){for(a.push("if(1"),l=0;l=0||e.indexOf(-(l+1))>=0||a.push("&&s[",l,"]>2");for(a.push("){grad",r,"(src.pick(",s.join(),")",c),l=0;l=0||e.indexOf(-(l+1))>=0||a.push(",dst.pick(",s.join(),",",l,")",c);a.push(");")}for(l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",f.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):a.push("if(s[",u,"]>1){diff(",h,",src.pick(",f.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",h,");};");break;case"mirror":0===r?a.push("dst.set(",s.join(),",",u,",0);"):a.push("zero(",h,");");break;case"wrap":var p=s.slice(),m=s.slice();e[l]<0?(p[u]="s["+u+"]-2",m[u]="0"):(p[u]="s["+u+"]-1",m[u]="1"),0===r?a.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",m.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):a.push("if(s[",u,"]>2){diff(",h,",src.pick(",p.join(),")",c,",src.pick(",m.join(),")",c,");}else{zero(",h,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&a.push("};")}var r=t.join();if(v=s[r])return v;for(var i=t.length,a=["function gradient(dst,src){var s=src.shape.slice();"],l=0;l<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=i({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=i({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=a({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=a({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=a({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=i({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=i({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=i({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=a({args:["array","array"],pre:o,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":111}],463:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":464,ndarray:468}],464:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":111}],465:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[a.mallocUint8,a.freeUint8];case"uint16":return[a.mallocUint16,a.freeUint16];case"uint32":return[a.mallocUint32,a.freeUint32];case"int8":return[a.mallocInt8,a.freeInt8];case"int16":return[a.mallocInt16,a.freeInt16];case"int32":return[a.mallocInt32,a.freeInt32];case"float32":return[a.mallocFloat,a.freeFloat];case"float64":return[a.mallocDouble,a.freeDouble];default:return null}}function i(t){for(var e=[],r=0;r0?s.push(["d",d,"=s",d,"-d",h,"*n",h].join("")):s.push(["d",d,"=s",d].join("")),h=d);var p;0!=(p=t.length-1-l)&&(f>0?s.push(["e",p,"=s",p,"-e",f,"*n",f,",f",p,"=",c[p],"-f",f,"*n",f].join("")):s.push(["e",p,"=s",p,",f",p,"=",c[p]].join("")),f=p)}r.push("var "+s.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",o,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+a);var g=new Function("insertionSort","quickSort",r.join("\n")),v=function(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var h=[],f=1;f1){for(o.push("dptr=0;sptr=ptr"),f=t.length-1;f>=0;--f)0!==(d=t[f])&&o.push(["for(i",d,"=0;i",d,"b){break __l}"].join("")),f=t.length-1;f>=1;--f)o.push("sptr+=e"+f,"dptr+=f"+f,"}");for(o.push("dptr=cptr;sptr=cptr-s0"),f=t.length-1;f>=0;--f)0!==(d=t[f])&&o.push(["for(i",d,"=0;i",d,"=0;--f)0!==(d=t[f])&&o.push(["for(i",d,"=0;i",d,"scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));return o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c?new Function("malloc","free",o.join("\n"))(c[0],c[1]):new Function(o.join("\n"))()}(t,e);return g(v,function(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function s(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function l(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function c(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i)0!==(o=t[i])&&_.push(["for(i",o,"=0;i",o,"1)for(i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function h(){t.length>1&&k&&_.push("free(pivot1)","free(pivot2)")}function f(e,r){var n="el"+e,i="el"+r;if(t.length>1){var o="__l"+ ++T;u(o,[n,i],!1,["comp=",s("ptr0"),"-",s("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else _.push(["if(",s(a(n)),">",s(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?c([e,r],!1,l("ptr0",s("ptr1"))):_.push(l(a(e),s(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++T;u(i,[r],!0,[e,"=",s("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",s(a(r)),"-pivot",n].join(""))}function m(e,r){t.length>1?c([e,r],!1,["tmp=",s("ptr0"),"\n",l("ptr0",s("ptr1")),"\n",l("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",s("ptr0"),"\n",l("ptr0",s("ptr1")),"\n",l("ptr1","tmp")].join(""))}function g(e,r,n){t.length>1?(c([e,r,n],!1,["tmp=",s("ptr0"),"\n",l("ptr0",s("ptr1")),"\n",l("ptr1",s("ptr2")),"\n",l("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",s("ptr0"),"\n",l("ptr0",s("ptr1")),"\n",l("ptr1",s("ptr2")),"\n",l("ptr2","tmp")].join(""))}function v(t,e){m(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?c([e,r],!0,[l("ptr0",s("ptr1")),"\n",l("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(l(a(e),s(a(r))),l(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",o,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++T,":while(true){"].join("")),c([e],!0,["if(",s("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",T,"}"].join("")),_.push(n,"}")):_.push(["while(",s(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),M=["left","right","data","offset"].concat(i(t.length)),k=n(e),T=0;_.push(["function ",w,"(",M.join(","),"){"].join(""));var A=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var S=[],E=1;E1?c(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",s("ptr1"),"\n","pivot2[pivot_ptr]=",s("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",s("ptr0"),"\n","y=",s("ptr2"),"\n","z=",s("ptr4"),"\n",l("ptr5","x"),"\n",l("ptr6","y"),"\n",l("ptr7","z")].join("")):_.push(["pivot1=",s(a("el2")),"\n","pivot2=",s(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",s(a("el1")),"\n","y=",s(a("el3")),"\n","z=",s(a("el5")),"\n",l(a("index1"),"x"),"\n",l(a("index3"),"y"),"\n",l(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),m("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),g("k","less","great"),_.push("break"),_.push("}else{"),v("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),m("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),m("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&k?new Function("insertionSort","malloc","free",_.join("\n"))(r,k[0],k[1]):new Function("insertionSort",_.join("\n"))(r)}(t,e,v))}},{"typedarray-pool":550}],466:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":465}],467:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_9_arg4_)}",args:[{name:"_inline_9_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_9_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_9_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_9_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_9_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_10_arg2_(this_warped,_inline_10_arg0_),_inline_10_arg1_=_inline_10_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_10_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_10_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_13_arg2_(this_warped,_inline_13_arg0_),_inline_13_arg1_=_inline_13_arg3_(_inline_13_arg4_,this_warped[0])}",args:[{name:"_inline_13_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_13_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_16_arg2_(this_warped,_inline_16_arg0_),_inline_16_arg1_=_inline_16_arg3_(_inline_16_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_16_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_16_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_16_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_16_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_16_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_19_arg2_(this_warped,_inline_19_arg0_),_inline_19_arg1_=_inline_19_arg3_(_inline_19_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_19_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_19_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":114,"ndarray-linear-interpolate":461}],468:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var d=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),p=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+p.join(","));for(var m=0;m=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");return new Function("CTOR_LIST","ORDER",a.join("\n"))(c[t],i)}var o=t("iota-array"),s=t("is-buffer"),l="undefined"!=typeof Float64Array,c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var i=e.length;if(void 0===r){r=new Array(i);for(var o=i-1,u=1;o>=0;--o)r[o]=u,u*=e[o]}if(void 0===n)for(n=0,o=0;o>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);return e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1,n.pack(o,r)}},{"double-bits":125}],470:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var x=i[c],_=1/Math.sqrt(g*y);for(b=0;b<3;++b){var w=(b+1)%3,M=(b+2)%3;x[b]+=_*(v[w]*m[M]-v[M]*m[w])}}}for(o=0;oa)for(_=1/Math.sqrt(k),b=0;b<3;++b)x[b]*=_;else for(b=0;b<3;++b)x[b]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(d):0;for(c=0;c<3;++c)f[c]*=d;i[o]=f}return i}},{}],471:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,s=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;lr;)i-=e;return n=i,[r/e,n/e]}(p.subarray(a,a+4*m),4))[0]!==h[1]){for(b||(b=r),x=r,e=h[0];ew&&(w=h[1]),k[r]=h}for(o=0,l=0,s=0,r=0;rM&&(M=d);return{center:[c,u],bounds:[_,b,w,x+1],radius:Math.sqrt(M)}}(r)}function i(t,e){return t*t+e*e}e.exports=n;var a=document.createElement("canvas"),o=a.getContext("2d");a.width=200,a.height=200,n.canvas=a},{}],473:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(h>0){var h=Math.sqrt(u+1);t[0]=.5*(o-l)/h,t[1]=.5*(s-n)/h,t[2]=.5*(r-a)/h,t[3]=.5*h}else{var f=Math.max(e,a,c);h=Math.sqrt(2*f-u+1),e>=f?(t[0]=.5*h,t[1]=.5*(i+r)/h,t[2]=.5*(s+n)/h,t[3]=.5*(o-l)/h):a>=f?(t[0]=.5*(r+i)/h,t[1]=.5*h,t[2]=.5*(l+o)/h,t[3]=.5*(s-n)/h):(t[0]=.5*(n+s)/h,t[1]=.5*(o+l)/h,t[2]=.5*h,t[3]=.5*(r-i)/h)}return t}},{}],474:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=s([r]),this.center=s(e),this.rotation=s(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),a(r=[].slice.call(r,0,4),r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i};var s=t("filtered-vector"),l=t("gl-mat4/lookAt"),c=t("gl-mat4/fromQuat"),u=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),f=o.prototype;f.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},f.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;c(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var u=0,h=0;h<3;++h)u+=r[l+4*h]*i[h];r[12+l]=-u}},f.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},f.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},f.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},f.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],h=a[4],f=a[8],d=u*o+h*s+f*l,p=n(u-=o*d,h-=s*d,f-=l*d);u/=p,h/=p,f/=p;var m=a[2],g=a[6],v=a[10],y=m*o+g*s+v*l,b=m*u+g*h+v*f,x=n(m-=y*o+b*u,g-=y*s+b*h,v-=y*l+b*f);m/=x,g/=x,v/=x;var _=u*e+o*r,w=h*e+s*r,M=f*e+l*r;this.center.move(t,_,w,M);var k=Math.exp(this.computedRadius[0]);k=Math.max(1e-4,k+i),this.radius.set(t,Math.log(k))},f.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],h=o[5],f=o[9],d=o[2],p=o[6],m=o[10],g=e*s+r*u,v=e*l+r*h,y=e*c+r*f,b=-(p*y-m*v),x=-(m*g-d*y),_=-(d*v-p*g),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),M=i(b,x,_,w);M>1e-6?(b/=M,x/=M,_/=M,w/=M):(b=x=_=0,w=1);var k=this.computedRotation,T=k[0],A=k[1],S=k[2],E=k[3],L=T*w+E*b+A*_-S*x,C=A*w+E*x+S*b-T*_,I=S*w+E*_+T*x-A*b,P=E*w-T*b-A*x-S*_;if(a){b=d,x=p,_=m;var D=Math.sin(a)/n(b,x,_);b*=D,x*=D,_*=D,P=P*(w=Math.cos(e))-(L=L*w+P*b+C*_-I*x)*b-(C=C*w+P*x+I*b-L*_)*x-(I=I*w+P*_+L*x-C*b)*_}var z=i(L,C,I,P);z>1e-6?(L/=z,C/=z,I/=z,P/=z):(L=C=I=0,P=1),this.rotation.set(t,L,C,I,P)},f.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;l(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,c=0;c<3;++c)s+=Math.pow(r[c]-e[c],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},f.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},f.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;u(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},f.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},f.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},f.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},f.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},f.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":473,"filtered-vector":134,"gl-mat4/fromQuat":179,"gl-mat4/invert":182,"gl-mat4/lookAt":183}],475:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return r=void 0!==r?r+"":" ",n(r,e)+t}},{"repeat-string":509}],476:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],477:[function(t,e,r){(function(t){function e(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n=-1&&!i;a--){var o=a>=0?arguments[a]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(r=o+"/"+r,i="/"===o.charAt(0))}return r=e(n(r.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+r||"."},r.normalize=function(t){var i=r.isAbsolute(t),a="/"===o(t,-1);return(t=e(n(t.split("/"),function(t){return!!t}),!i).join("/"))||i||(t="."),t&&a&&(t+="/"),(i?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(n(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function n(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var i=n(t.split("/")),a=n(e.split("/")),o=Math.min(i.length,a.length),s=o,l=0;l55295&&e<57344){if(!r){e>56319||a+1===n?i.push(239,191,189):r=e;continue}if(e<56320){i.push(239,191,189),r=e;continue}e=r-55296<<10|e-56320|65536,r=null}else r&&(i.push(239,191,189),r=null);e<128?i.push(e):e<2048?i.push(e>>6|192,63&e|128):e<65536?i.push(e>>12|224,e>>6&63|128,63&e|128):i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}return i}e.exports=n;var a,o,s,l=t("ieee754");(a={readUInt32LE:function(t){return(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},writeUInt32LE:function(t,e){this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24},readInt32LE:function(t){return(this[t]|this[t+1]<<8|this[t+2]<<16)+(this[t+3]<<24)},readFloatLE:function(t){return l.read(this,t,!0,23,4)},readDoubleLE:function(t){return l.read(this,t,!0,52,8)},writeFloatLE:function(t,e){return l.write(this,t,e,!0,23,4)},writeDoubleLE:function(t,e){return l.write(this,t,e,!0,52,8)},toString:function(t,e,r){var n="",i="";e=e||0,r=Math.min(this.length,r||this.length);for(var a=e;a>3,a=this.pos;t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t},readSFixed32:function(){var t=this.buf.readInt32LE(this.pos);return this.pos+=4,t},readFixed64:function(){var t=this.buf.readUInt32LE(this.pos)+4294967296*this.buf.readUInt32LE(this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=this.buf.readUInt32LE(this.pos)+4294967296*this.buf.readInt32LE(this.pos+4);return this.pos+=8,t},readFloat:function(){var t=this.buf.readFloatLE(this.pos);return this.pos+=4,t},readDouble:function(){var t=this.buf.readDoubleLE(this.pos);return this.pos+=8,t},readVarint:function(){var t,e,r=this.buf;return e=r[this.pos++],t=127&e,e<128?t:(e=r[this.pos++],t|=(127&e)<<7,e<128?t:(e=r[this.pos++],t|=(127&e)<<14,e<128?t:(e=r[this.pos++],t|=(127&e)<<21,e<128?t:function(t,e){var r,n=e.buf;if(r=n[e.pos++],t+=268435456*(127&r),r<128)return t;if(r=n[e.pos++],t+=34359738368*(127&r),r<128)return t;if(r=n[e.pos++],t+=4398046511104*(127&r),r<128)return t;if(r=n[e.pos++],t+=562949953421312*(127&r),r<128)return t;if(r=n[e.pos++],t+=72057594037927940*(127&r),r<128)return t;if(r=n[e.pos++],t+=0x8000000000000000*(127&r),r<128)return t;throw new Error("Expected varint not more than 10 bytes")}(t,this))))},readVarint64:function(){var t=this.pos,e=this.readVarint();if(e127;);else if(e===n.Bytes)this.pos=this.readVarint()+this.pos;else if(e===n.Fixed32)this.pos+=4;else{if(e!==n.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455?function(t,e){e.realloc(10);for(var r=e.pos+10;t>=1;){if(e.pos>=r)throw new Error("Given varint doesn't fit into 10 bytes");var n=255&t;e.buf[e.pos++]=n|(t>=128?128:0),t/=128}}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t);var e=d.byteLength(t);this.writeVarint(e),this.realloc(e),this.buf.write(t,this.pos),this.pos+=e},writeFloat:function(t){this.realloc(4),this.buf.writeFloatLE(t,this.pos),this.pos+=4},writeDouble:function(t){this.realloc(8),this.buf.writeDoubleLE(t,this.pos),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&function(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,n.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,i,e)},writePackedSVarint:function(t,e){this.writeMessage(t,a,e)},writePackedBoolean:function(t,e){this.writeMessage(t,l,e)},writePackedFloat:function(t,e){this.writeMessage(t,o,e)},writePackedDouble:function(t,e){this.writeMessage(t,s,e)},writePackedFixed32:function(t,e){this.writeMessage(t,c,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,u,e)},writePackedFixed64:function(t,e){this.writeMessage(t,h,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,f,e)},writeBytesField:function(t,e){this.writeTag(t,n.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,n.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,n.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,n.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,n.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,n.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,n.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,n.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,n.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,n.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./buffer":478}],480:[function(t,e,r){"use strict";e.exports=function(t){var e=t.length;if(e0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,c=(c+r)*o;return n.freeUint32(l),n.freeUint32(s),c},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":293,"typedarray-pool":550}],482:[function(t,e,r){"use strict";e.exports=function(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function i(t,i,a){for(var o,s,l,u=0;u<2;++u)if(c[u][i].length>0){o=c[u][i][0],l=u;break}s=o[1^l];for(var h=0;h<2;++h)for(var f=c[h][i],d=0;d0&&(o=p,s=m,l=h)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=i(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],h=t,f=s[1],d=i(u,h,!0);if(n(e[u],e[h],e[f],e[d])<0)break;s.push(t),l=i(u,h)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;u0;){c[0][u].length;var m=a(u,d);o(0,m)?p.push.apply(p,m):(p.length>0&&f.push(p),p=m)}p.length>0&&f.push(p)}return f};var n=t("compare-angle")},{"compare-angle":101}],483:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){i[d=o.pop()]=!1;var c=r[d];for(s=0;s0})).length,g=new Array(m),v=new Array(m);for(d=0;d0;){var j=O.pop(),N=E[j];c(N,function(t,e){return t-e});var B,U=N.length,V=F[j];for(0===V&&(B=[q=p[j]]),d=0;d=0)&&(F[H]=1^V,O.push(H),0===V)){var q;r(q=p[H])||(q.reverse(),B.push(q))}}0===V&&R.push(B)}return R};var i=t("edges-to-adjacency-list"),a=t("planar-dual"),o=t("point-in-big-polygon"),s=t("two-product"),l=t("robust-sum"),c=t("uniq"),u=t("./lib/trim-leaves")},{"./lib/trim-leaves":483,"edges-to-adjacency-list":128,"planar-dual":482,"point-in-big-polygon":486,"robust-sum":522,"two-product":548,uniq:552}],485:[function(t,e,r){"use strict";function n(t,e){this.x=t,this.y=e}e.exports=n,n.prototype={clone:function(){return new n(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(t){return t instanceof n?t:Array.isArray(t)?new n(t[0],t[1]):t}},{}],486:[function(t,e,r){function n(){return!0}function i(t){for(var e={},r=0;r0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var s=i.key,l=o(r,s[0],s[1]);if(s[0][0]0))return 0;a=-1,i=i.right}else if(l>0)i=i.left;else{if(!(l<0))return 0;a=1,i=i.right}}return a}}(g.slabs,g.coordinates);return 0===n.length?v:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(i(n),v)};var o=t("robust-orientation")[3],s=t("slab-decomposition"),l=t("interval-tree-1d"),c=t("binary-search-bounds")},{"binary-search-bounds":67,"interval-tree-1d":292,"robust-orientation":517,"slab-decomposition":534}],487:[function(t,e,r){function n(t,e,r){var n=i.segments(t),a=i.segments(e),o=r(i.combine(n,a));return i.polygon(o)}var i,a=t("./lib/build-log"),o=t("./lib/epsilon"),s=t("./lib/intersecter"),l=t("./lib/segment-chainer"),c=t("./lib/segment-selector"),u=t("./lib/geojson"),h=!1,f=o();i={buildLog:function(t){return!0===t?h=a():!1===t&&(h=!1),!1!==h&&h.list},epsilon:function(t){return f.epsilon(t)},segments:function(t){var e=s(!0,f,h);return t.regions.forEach(e.addRegion),{segments:e.calculate(t.inverted),inverted:t.inverted}},combine:function(t,e){return{combined:s(!1,f,h).calculate(t.segments,t.inverted,e.segments,e.inverted),inverted1:t.inverted,inverted2:e.inverted}},selectUnion:function(t){return{segments:c.union(t.combined,h),inverted:t.inverted1||t.inverted2}},selectIntersect:function(t){return{segments:c.intersect(t.combined,h),inverted:t.inverted1&&t.inverted2}},selectDifference:function(t){return{segments:c.difference(t.combined,h),inverted:t.inverted1&&!t.inverted2}},selectDifferenceRev:function(t){return{segments:c.differenceRev(t.combined,h),inverted:!t.inverted1&&t.inverted2}},selectXor:function(t){return{segments:c.xor(t.combined,h),inverted:t.inverted1!==t.inverted2}},polygon:function(t){return{regions:l(t.segments,f,h),inverted:t.inverted}},polygonFromGeoJSON:function(t){return u.toPolygon(i,t)},polygonToGeoJSON:function(t){return u.fromPolygon(i,f,t)},union:function(t,e){return n(t,e,i.selectUnion)},intersect:function(t,e){return n(t,e,i.selectIntersect)},difference:function(t,e){return n(t,e,i.selectDifference)},differenceRev:function(t,e){return n(t,e,i.selectDifferenceRev)},xor:function(t,e){return n(t,e,i.selectXor)}},"object"==typeof window&&(window.PolyBool=i),e.exports=i},{"./lib/build-log":488,"./lib/epsilon":489,"./lib/geojson":490,"./lib/intersecter":491,"./lib/segment-chainer":493,"./lib/segment-selector":494}],488:[function(t,e,r){e.exports=function(){function t(t,r){return e.list.push({type:t,data:r?JSON.parse(JSON.stringify(r)):void 0}),e}var e,r=0,n=!1;return e={list:[],segmentId:function(){return r++},checkIntersection:function(e,r){return t("check",{seg1:e,seg2:r})},segmentChop:function(e,r){return t("div_seg",{seg:e,pt:r}),t("chop",{seg:e,pt:r})},statusRemove:function(e){return t("pop_seg",{seg:e})},segmentUpdate:function(e){return t("seg_update",{seg:e})},segmentNew:function(e,r){return t("new_seg",{seg:e,primary:r})},segmentRemove:function(e){return t("rem_seg",{seg:e})},tempStatus:function(e,r,n){return t("temp_status",{seg:e,above:r,below:n})},rewind:function(e){return t("rewind",{seg:e})},status:function(e,r,n){return t("status",{seg:e,above:r,below:n})},vert:function(r){return r===n?e:(n=r,t("vert",{x:r}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),t("log",{txt:e})},reset:function(){return t("reset")},selected:function(e){return t("selected",{segs:e})},chainStart:function(e){return t("chain_start",{seg:e})},chainRemoveHead:function(e,r){return t("chain_rem_head",{index:e,pt:r})},chainRemoveTail:function(e,r){return t("chain_rem_tail",{index:e,pt:r})},chainNew:function(e,r){return t("chain_new",{pt1:e,pt2:r})},chainMatch:function(e){return t("chain_match",{index:e})},chainClose:function(e){return t("chain_close",{index:e})},chainAddHead:function(e,r){return t("chain_add_head",{index:e,pt:r})},chainAddTail:function(e,r){return t("chain_add_tail",{index:e,pt:r})},chainConnect:function(e,r){return t("chain_con",{index1:e,index2:r})},chainReverse:function(e){return t("chain_rev",{index:e})},chainJoin:function(e,r){return t("chain_join",{index1:e,index2:r})},done:function(){return t("done")}}}},{}],489:[function(t,e,r){e.exports=function(t){"number"!=typeof t&&(t=1e-10);var e={epsilon:function(e){return"number"==typeof e&&(t=e),t},pointAboveOrOnLine:function(e,r,n){var i=r[0],a=r[1],o=n[0],s=n[1],l=e[0];return(o-i)*(e[1]-a)-(s-a)*(l-i)>=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-c)*(i-u)/(o-u)+c-n>t&&(s=!s),a=c,o=u}return s}};return e}},{}],490:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}if(e.length<=0)return t.segments({inverted:!1,regions:[]});for(var n=r(e[0]),i=1;i0})}function s(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,c=a.start,u=a.end;r&&r.checkIntersection(i,a);var h=e.linesIntersect(o,s,c,u);if(!1===h){if(!e.pointsCollinear(o,s,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(s,c))return!1;var f=e.pointsSame(o,c),d=e.pointsSame(s,u);if(f&&d)return n;var p=!f&&e.pointBetween(o,c,u),m=!d&&e.pointBetween(s,c,u);if(f)return m?l(n,s):l(t,u),n;p&&(d||(m?l(n,s):l(t,u)),l(n,o))}else 0===h.alongA&&(-1===h.alongB?l(t,c):0===h.alongB?l(t,h.pt):1===h.alongB&&l(t,u)),0===h.alongB&&(-1===h.alongA?l(n,o):0===h.alongA?l(n,h.pt):1===h.alongA&&l(n,s));return!1}for(var c=n.create(),h=[];!u.isEmpty();){var f=u.getHead();if(r&&r.vert(f.pt[0]),f.isStart){r&&r.segmentNew(f.seg,f.primary);var d=o(f),p=d.before?d.before.ev:null,m=d.after?d.after.ev:null;r&&r.tempStatus(f.seg,!!p&&p.seg,!!m&&m.seg);var g=function(){if(p){var t=s(f,p);if(t)return t}return!!m&&s(f,m)}();if(g&&(t?(v=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below)&&(g.seg.myFill.above=!g.seg.myFill.above):g.seg.otherFill=f.seg.myFill,r&&r.segmentUpdate(g.seg),f.other.remove(),f.remove()),u.getHead()!==f){r&&r.rewind(f.seg);continue}if(t){var v;v=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below,f.seg.myFill.below=m?m.seg.myFill.above:i,f.seg.myFill.above=v?!f.seg.myFill.below:f.seg.myFill.below}else if(null===f.seg.otherFill){var y;y=m?f.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:f.primary?a:i,f.seg.otherFill={above:y,below:y}}r&&r.status(f.seg,!!p&&p.seg,!!m&&m.seg),f.other.status=d.insert(n.node({ev:f}))}else{var b=f.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(c.exists(b.prev)&&c.exists(b.next)&&s(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!f.primary){var x=f.seg.myFill;f.seg.myFill=f.seg.otherFill,f.seg.otherFill=x}h.push(f.seg)}u.getHead().remove()}return r&&r.done(),h}var u=n.create();return t?{addRegion:function(t){for(var r,n=t[t.length-1],a=0;a=c?(x=1,y=c+2*f+p):y=f*(x=-f/c)+p):(x=0,d>=0?(_=0,y=p):-d>=h?(_=1,y=h+2*d+p):y=d*(_=-d/h)+p);else if(_<0)_=0,f>=0?(x=0,y=p):-f>=c?(x=1,y=c+2*f+p):y=f*(x=-f/c)+p;else{var w=1/b;y=(x*=w)*(c*x+u*(_*=w)+2*f)+_*(u*x+h*_+2*d)+p}else{var M,k,T,A;x<0?(k=h+d)>(M=u+f)?(T=k-M)>=(A=c-2*u+h)?(x=1,_=0,y=c+2*f+p):y=(x=T/A)*(c*x+u*(_=1-x)+2*f)+_*(u*x+h*_+2*d)+p:(x=0,k<=0?(_=1,y=h+2*d+p):d>=0?(_=0,y=p):y=d*(_=-d/h)+p):_<0?(k=c+f)>(M=u+d)?(T=k-M)>=(A=c-2*u+h)?(_=1,x=0,y=h+2*d+p):y=(x=1-(_=T/A))*(c*x+u*_+2*f)+_*(u*x+h*_+2*d)+p:(_=0,k<=0?(x=1,y=c+2*f+p):f>=0?(x=0,y=p):y=f*(x=-f/c)+p):(T=h+d-u-f)<=0?(x=0,_=1,y=h+2*d+p):T>=(A=c-2*u+h)?(x=1,_=0,y=c+2*f+p):y=(x=T/A)*(c*x+u*(_=1-x)+2*f)+_*(u*x+h*_+2*d)+p}var S=1-x-_;for(l=0;l1)for(var r=1;r1&&(n=r[0]+"@",t=r[1]);return n+a((t=t.replace(C,".")).split("."),e).join(".")}function s(t){for(var e,r,n=[],i=0,a=t.length;i=55296&&e<=56319&&i65535&&(e+=z((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=z(t)}).join("")}function c(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:x}function u(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?D(t/k):t>>1,t+=D(t/e);t>P*w>>1;n+=x)t=D(t/P);return D(n+(P+1)*t/(t+M))}function f(t){var e,r,n,a,o,s,u,f,d,p,m=[],g=t.length,v=0,y=A,M=T;for((r=t.lastIndexOf(S))<0&&(r=0),n=0;n=128&&i("not-basic"),m.push(t.charCodeAt(n));for(a=r>0?r+1:0;a=g&&i("invalid-input"),((f=c(t.charCodeAt(a++)))>=x||f>D((b-v)/s))&&i("overflow"),v+=f*s,d=u<=M?_:u>=M+w?w:u-M,!(fD(b/(p=x-d))&&i("overflow"),s*=p;M=h(v-o,e=m.length+1,0==o),D(v/e)>b-y&&i("overflow"),y+=D(v/e),v%=e,m.splice(v++,0,y)}return l(m)}function d(t){var e,r,n,a,o,l,c,f,d,p,m,g,v,y,M,k=[];for(g=(t=s(t)).length,e=A,r=0,o=T,l=0;l=e&&mD((b-r)/(v=n+1))&&i("overflow"),r+=(c-e)*v,e=c,l=0;lb&&i("overflow"),m==e){for(f=r,d=x;p=d<=o?_:d>=o+w?w:d-o,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},P=x-_,D=Math.floor,z=String.fromCharCode;if(v={version:"1.4.1",ucs2:{decode:s,encode:l},decode:f,encode:d,toASCII:function(t){return o(t,function(t){return L.test(t)?"xn--"+d(t):t})},toUnicode:function(t){return o(t,function(t){return E.test(t)?f(t.slice(4).toLowerCase()):t})}},p&&m)if(e.exports==p)m.exports=v;else for(y in v)v.hasOwnProperty(y)&&(p[y]=v[y]);else n.punycode=v}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],498:[function(t,e,r){e.exports=t("gl-quat/slerp")},{"gl-quat/slerp":232}],499:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,a){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var s=/\+/g;t=t.split(e);var l=1e3;a&&"number"==typeof a.maxKeys&&(l=a.maxKeys);var c=t.length;l>0&&c>l&&(c=l);for(var u=0;u=0?(h=m.substr(0,g),f=m.substr(g+1)):(h=m,f=""),d=decodeURIComponent(h),p=decodeURIComponent(f),n(o,d)?i(o[d])?o[d].push(p):o[d]=[o[d],p]:o[d]=p}return o};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],500:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;ne?1:0};a>r;){if(a-r>600){var s=a-r+1,l=e-r+1,c=Math.log(s),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);n(t,e,Math.max(r,Math.floor(e-l*u/s+h)),Math.min(a,Math.floor(e+(s-l)*u/s+h)),o)}var f=t[e],d=r,p=a;for(i(t,r,e),o(t[a],f)>0&&i(t,r,a);d0;)p--}0===o(t[r],f)?i(t,r,p):i(t,++p,a),p<=e&&(r=p+1),e<=p&&(a=p-1)}}function i(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}e.exports=n},{}],503:[function(t,e,r){"use strict";var n=t("big-rat/add");e.exports=function(t,e){for(var r=t.length,i=new Array(r),a=0;a0){var c=t[r-1];if(0===n(s,c)&&a(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":86,"compare-cell":102,"compare-oriented-cell":103}],508:[function(t,e,r){!function(t,n){"object"==typeof r&&void 0!==e?e.exports=n():t.createREGL=n()}(this,function(){"use strict";function t(t){return"undefined"!=typeof btoa?btoa(t):"base64:"+t}function e(t){var e=new Error("(regl) "+t);throw console.error(e),e}function r(t,r){t||e(r)}function n(t){return t?": "+t:""}function i(t,r,i){r.indexOf(t)<0&&e("invalid value"+n(i)+". must be one of: "+r)}function a(t,e){for(t+="";t.length1&&e===r&&('"'===e||"'"===e))return['"'+y(t.substr(1,t.length-2))+'"'];var n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(n)return b(t.substr(0,n.index)).concat(b(n[1])).concat(b(t.substr(n.index+n[0].length)));var i=t.split(".");if(1===i.length)return['"'+y(t)+'"'];for(var a=[],o=0;o0,"invalid pixel ratio")):n=(i=a).canvas:e=a:Mt.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?n=e:r=e),!i){if(!n){Mt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var d=function(t,e,r){function n(){var e=window.innerWidth,n=window.innerHeight;if(t!==document.body){var a=t.getBoundingClientRect();e=a.right-a.left,n=a.bottom-a.top}i.width=r*e,i.height=r*n,ct(i.style,{width:e+"px",height:n+"px"})}var i=document.createElement("canvas");return ct(i.style,{border:0,margin:0,padding:0,top:0,left:0}),t.appendChild(i),t===document.body&&(i.style.position="absolute",ct(t.style,{margin:0,padding:0})),window.addEventListener("resize",n,!1),n(),{canvas:i,onDestroy:function(){window.removeEventListener("resize",n),t.removeChild(i)}}}(r||document.body,0,c);if(!d)return null;n=d.canvas,f=d.onDestroy}i=function(t,e){function r(r){try{return t.getContext(r,e)}catch(t){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(n,o)}return i?{gl:i,canvas:n,container:r,extensions:s,optionalExtensions:l,pixelRatio:c,profile:u,onDone:h,onDestroy:f}:(f(),h("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function k(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||lt(t.data))}function T(t,e){for(var r=Array(t),n=0;n65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,(e|=r)|t>>1}function S(t){var e=function(t){for(var e=16;e<=1<<28;e*=16)if(t<=e)return e;return 0}(t),r=jt[A(e)>>2];return r.length>0?r.pop():new ArrayBuffer(e)}function E(t){jt[A(t.byteLength)>>2].push(t)}function L(t,e,r,n,i,a){for(var o=a,s=0;s>>31<<15,a=(n<<1>>>24)-127,o=n>>13&1023;if(a<-24)e[r]=i;else if(a<-14){var s=-14-a;e[r]=i+(o+1024>>s)}else e[r]=a>15?i+31744:i+(a+15<<10)+o}return e}function O(t){return Array.isArray(t)||lt(t)}function F(t){return"[object "+t+"]"}function R(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function j(t){if(!Array.isArray(t))return!1;return!(0===t.length||!O(t[0]))}function N(t){return Object.prototype.toString.call(t)}function B(t){return N(t)===wr}function U(t){if(!t)return!1;var e=N(t);return Ar.indexOf(e)>=0||(R(t)||j(t)||k(t))}function V(t){return 0|st[Object.prototype.toString.call(t)]}function H(t,e){return Nt.allocType(t.type===Pe?Xe:t.type,e)}function q(t,e){t.type===Pe?(t.data=z(e),Nt.freeType(e)):t.data=e}function G(t,e,r,n,i,a){var o;if(o=void 0!==Er[t]?Er[t]:_r[t]*Sr[e],a&&(o*=6),i){for(var s=0,l=r;l>=1;)s+=o*l*l,l/=2;return s}return o*r*n}function Y(t,e,r,n,i,a,o){function s(){this.internalformat=ge,this.format=ge,this.type=Ge,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=0,this.width=0,this.height=0,this.channels=0}function l(t,e){t.internalformat=e.internalformat,t.format=e.format,t.type=e.type,t.compressed=e.compressed,t.premultiplyAlpha=e.premultiplyAlpha,t.flipY=e.flipY,t.unpackAlignment=e.unpackAlignment,t.colorSpace=e.colorSpace,t.width=e.width,t.height=e.height,t.channels=e.channels}function c(t,n){if("object"==typeof n&&n){if("premultiplyAlpha"in n&&(Mt.type(n.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),t.premultiplyAlpha=n.premultiplyAlpha),"flipY"in n&&(Mt.type(n.flipY,"boolean","invalid texture flip"),t.flipY=n.flipY),"alignment"in n&&(Mt.oneOf(n.alignment,[1,2,4,8],"invalid texture unpack alignment"),t.unpackAlignment=n.alignment),"colorSpace"in n&&(Mt.parameter(n.colorSpace,F,"invalid colorSpace"),t.colorSpace=F[n.colorSpace]),"type"in n){var i=n.type;Mt(e.oes_texture_float||!("float"===i||"float32"===i),"you must enable the OES_texture_float extension in order to use floating point textures."),Mt(e.oes_texture_half_float||!("half float"===i||"float16"===i),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),Mt(e.webgl_depth_texture||!("uint16"===i||"uint32"===i||"depth stencil"===i),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Mt.parameter(i,Y,"invalid texture type"),t.type=Y[i]}var a=t.width,o=t.height,s=t.channels,l=!1;"shape"in n?(Mt(Array.isArray(n.shape)&&n.shape.length>=2,"shape must be an array"),a=n.shape[0],o=n.shape[1],3===n.shape.length&&(s=n.shape[2],Mt(s>0&&s<=4,"invalid number of channels"),l=!0),Mt(a>=0&&a<=r.maxTextureSize,"invalid width"),Mt(o>=0&&o<=r.maxTextureSize,"invalid height")):("radius"in n&&(a=o=n.radius,Mt(a>=0&&a<=r.maxTextureSize,"invalid radius")),"width"in n&&(a=n.width,Mt(a>=0&&a<=r.maxTextureSize,"invalid width")),"height"in n&&(o=n.height,Mt(o>=0&&o<=r.maxTextureSize,"invalid height")),"channels"in n&&(s=n.channels,Mt(s>0&&s<=4,"invalid number of channels"),l=!0)),t.width=0|a,t.height=0|o,t.channels=0|s;var c=!1;if("format"in n){var u=n.format;Mt(e.webgl_depth_texture||!("depth"===u||"depth stencil"===u),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Mt.parameter(u,W,"invalid texture format");var h=t.internalformat=W[u];t.format=rt[h],u in Y&&("type"in n||(t.type=Y[u])),u in X&&(t.compressed=!0),c=!0}!l&&c?t.channels=_r[t.format]:l&&!c?t.channels!==xr[t.format]&&(t.format=t.internalformat=xr[t.channels]):c&&l&&Mt(t.channels===_r[t.format],"number of channels inconsistent with specified format")}}function u(e){t.pixelStorei(pr,e.flipY),t.pixelStorei(mr,e.premultiplyAlpha),t.pixelStorei(gr,e.colorSpace),t.pixelStorei(dr,e.unpackAlignment)}function h(){s.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function f(t,e){var n=null;if(U(e)?n=e:e&&(Mt.type(e,"object","invalid pixel data type"),c(t,e),"x"in e&&(t.xOffset=0|e.x),"y"in e&&(t.yOffset=0|e.y),U(e.data)&&(n=e.data)),Mt(!t.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),e.copy){Mt(!n,"can not specify copy and data field for the same texture");var a=i.viewportWidth,o=i.viewportHeight;t.width=t.width||a-t.xOffset,t.height=t.height||o-t.yOffset,t.needsCopy=!0,Mt(t.xOffset>=0&&t.xOffset=0&&t.yOffset0&&t.width<=a&&t.height>0&&t.height<=o,"copy texture read out of bounds")}else if(n){if(lt(n))t.channels=t.channels||4,t.data=n,"type"in e||t.type!==Ge||(t.type=V(n));else if(R(n))t.channels=t.channels||4,function(t,e){var r=e.length;switch(t.type){case Ge:case Ye:case We:case Xe:var n=Nt.allocType(t.type,r);n.set(e),t.data=n;break;case Pe:t.data=z(e);break;default:Mt.raise("unsupported texture type, must specify a typed array")}}(t,n),t.alignment=1,t.needsFree=!0;else if(k(n)){var s=n.data;Array.isArray(s)||t.type!==Ge||(t.type=V(s));var l,u,h,f,d,p,m=n.shape,g=n.stride;3===m.length?(h=m[2],p=g[2]):(Mt(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),h=1,p=1),l=m[0],u=m[1],f=g[0],d=g[1],t.alignment=1,t.width=l,t.height=u,t.channels=h,t.format=t.internalformat=xr[h],t.needsFree=!0,function(t,e,r,n,i,a){for(var o=t.width,s=t.height,l=t.channels,c=H(t,o*s*l),u=0,h=0;h=0,"oes_texture_float extension not enabled"):t.type===Pe&&Mt(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function d(e,r,i){var a=e.element,o=e.data,s=e.internalformat,l=e.format,c=e.type,h=e.width,f=e.height;u(e),a?t.texImage2D(r,i,l,l,c,a):e.compressed?t.compressedTexImage2D(r,i,s,h,f,0,o):e.needsCopy?(n(),t.copyTexImage2D(r,i,l,e.xOffset,e.yOffset,h,f,0)):t.texImage2D(r,i,l,h,f,0,l,c,o)}function p(e,r,i,a,o){var s=e.element,l=e.data,c=e.internalformat,h=e.format,f=e.type,d=e.width,p=e.height;u(e),s?t.texSubImage2D(r,o,i,a,h,f,s):e.compressed?t.compressedTexSubImage2D(r,o,i,a,c,d,p,l):e.needsCopy?(n(),t.copyTexSubImage2D(r,o,i,a,e.xOffset,e.yOffset,d,p)):t.texSubImage2D(r,o,i,a,d,p,h,f,l)}function m(){return nt.pop()||new h}function g(t){t.needsFree&&Nt.freeType(t.data),h.call(t),nt.push(t)}function v(t,e,r){var n=t.images[0]=m();t.mipmask=1,n.width=t.width=e,n.height=t.height=r,n.channels=t.channels=4}function y(t,e){var r=null;if(U(e))l(r=t.images[0]=m(),t),f(r,e),t.mipmask=1;else if(c(t,e),Array.isArray(e.mipmap))for(var n=e.mipmap,i=0;i>=i,r.height>>=i,f(r,n[i]),t.mipmask|=1<=0&&(t.genMipmaps=!0)}if("mag"in e){var i=e.mag;Mt.parameter(i,P),t.magFilter=P[i]}var a=t.wrapS,o=t.wrapT;if("wrap"in e){var s=e.wrap;"string"==typeof s?(Mt.parameter(s,I),a=o=I[s]):Array.isArray(s)&&(Mt.parameter(s[0],I),Mt.parameter(s[1],I),a=I[s[0]],o=I[s[1]])}else{if("wrapS"in e){var l=e.wrapS;Mt.parameter(l,I),a=I[l]}if("wrapT"in e){var c=e.wrapT;Mt.parameter(c,I),o=I[c]}}if(t.wrapS=a,t.wrapT=o,"anisotropic"in e){var u=e.anisotropic;Mt("number"==typeof u&&u>=1&&u<=r.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=e.anisotropic}if("mipmap"in e){var h=!1;switch(typeof e.mipmap){case"string":Mt.parameter(e.mipmap,C,"invalid mipmap hint"),t.mipmapHint=C[e.mipmap],t.genMipmaps=!0,h=!0;break;case"boolean":h=t.genMipmaps=e.mipmap;break;case"object":Mt(Array.isArray(e.mipmap),"invalid mipmap type"),t.genMipmaps=!1,h=!0;break;default:Mt.raise("invalid mipmap type")}!h||"min"in e||(t.minFilter=ir)}}function T(r,n){t.texParameteri(n,er,r.minFilter),t.texParameteri(n,tr,r.magFilter),t.texParameteri(n,Ze,r.wrapS),t.texParameteri(n,Je,r.wrapT),e.ext_texture_filter_anisotropic&&t.texParameteri(n,fr,r.anisotropic),r.genMipmaps&&(t.hint(lr,r.mipmapHint),t.generateMipmap(n))}function A(e){s.call(this),this.mipmask=0,this.internalformat=ge,this.id=at++,this.refCount=1,this.target=e,this.texture=t.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new w,o.profile&&(this.stats={size:0})}function S(e){t.activeTexture(yr),t.bindTexture(e.target,e.texture)}function E(){var e=ut[0];e?t.bindTexture(e.target,e.texture):t.bindTexture(de,null)}function L(e){var r=e.texture;Mt(r,"must not double destroy texture");var n=e.unit,i=e.target;n>=0&&(t.activeTexture(yr+n),t.bindTexture(i,null),ut[n]=null),t.deleteTexture(r),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete ot[e.id],a.textureCount--}var C={"don't care":cr,"dont care":cr,nice:hr,fast:ur},I={repeat:Ke,clamp:Qe,mirror:$e},P={nearest:rr,linear:nr},D=ct({mipmap:sr,"nearest mipmap nearest":ir,"linear mipmap nearest":ar,"nearest mipmap linear":or,"linear mipmap linear":sr},P),F={none:0,browser:vr},Y={uint8:Ge,rgba4:ke,rgb565:Ae,"rgb5 a1":Te},W={alpha:ve,luminance:be,"luminance alpha":xe,rgb:ye,rgba:ge,rgba4:_e,"rgb5 a1":we,rgb565:Me},X={};e.ext_srgb&&(W.srgb=Ce,W.srgba=Ie),e.oes_texture_float&&(Y.float32=Y.float=Xe),e.oes_texture_half_float&&(Y.float16=Y["half float"]=Pe),e.webgl_depth_texture&&(ct(W,{depth:Ee,"depth stencil":Le}),ct(Y,{uint16:Ye,uint32:We,"depth stencil":Se})),e.webgl_compressed_texture_s3tc&&ct(X,{"rgb s3tc dxt1":De,"rgba s3tc dxt1":ze,"rgba s3tc dxt3":Oe,"rgba s3tc dxt5":Fe}),e.webgl_compressed_texture_atc&&ct(X,{"rgb atc":Re,"rgba atc explicit alpha":je,"rgba atc interpolated alpha":Ne}),e.webgl_compressed_texture_pvrtc&&ct(X,{"rgb pvrtc 4bppv1":Be,"rgb pvrtc 2bppv1":Ue,"rgba pvrtc 4bppv1":Ve,"rgba pvrtc 2bppv1":He}),e.webgl_compressed_texture_etc1&&(X["rgb etc1"]=qe);var Z=Array.prototype.slice.call(t.getParameter(fe));Object.keys(X).forEach(function(t){var e=X[t];Z.indexOf(e)>=0&&(W[t]=e)});var J=Object.keys(W);r.textureFormats=J;var K=[];Object.keys(W).forEach(function(t){var e=W[t];K[e]=t});var Q=[];Object.keys(Y).forEach(function(t){var e=Y[t];Q[e]=t});var $=[];Object.keys(P).forEach(function(t){var e=P[t];$[e]=t});var tt=[];Object.keys(D).forEach(function(t){var e=D[t];tt[e]=t});var et=[];Object.keys(I).forEach(function(t){var e=I[t];et[e]=t});var rt=J.reduce(function(t,e){var r=W[e];return r===be||r===ve||r===be||r===xe||r===Ee||r===Le?t[r]=r:r===we||e.indexOf("rgba")>=0?t[r]=ge:t[r]=ye,t},{}),nt=[],it=[],at=0,ot={},st=r.maxTextureUnits,ut=Array(st).map(function(){return null});return ct(A.prototype,{bind:function(){this.bindCount+=1;var e=this.unit;if(e<0){for(var r=0;r0)continue;n.unit=-1}ut[r]=this,e=r;break}e>=st&&Mt.raise("insufficient number of texture units"),o.profile&&a.maxTextureUnits>c)-a,u.height=u.height||(s.height>>c)-o,Mt(s.type===u.type&&s.format===u.format&&s.internalformat===u.internalformat,"incompatible format for texture.subimage"),Mt(a>=0&&o>=0&&a+u.width<=s.width&&o+u.height<=s.height,"texture.subimage write out of bounds"),Mt(s.mipmask&1<>l;++l)t.texImage2D(de,l,s.format,n>>l,a>>l,0,s.format,s.type,null);return E(),o.profile&&(s.stats.size=G(s.internalformat,s.type,n,a,!1,!1)),i},i._reglType="texture2d",i._texture=s,o.profile&&(i.stats=s.stats),i.destroy=function(){s.decRef()},i},createCube:function(e,n,i,s,u,h){function d(t,e,n,i,a,s){var u,h=k.texInfo;for(w.call(h),u=0;u<6;++u)L[u]=x();if("number"!=typeof t&&t)if("object"==typeof t)if(e)y(L[0],t),y(L[1],e),y(L[2],n),y(L[3],i),y(L[4],a),y(L[5],s);else if(M(h,t),c(k,t),"faces"in t){var f=t.faces;for(Mt(Array.isArray(f)&&6===f.length,"cube faces must be a length 6 array"),u=0;u<6;++u)Mt("object"==typeof f[u]&&!!f[u],"invalid input for cube map face"),l(L[u],k),y(L[u],f[u])}else for(u=0;u<6;++u)y(L[u],t);else Mt.raise("invalid arguments to cube map");else{var p=0|t||1;for(u=0;u<6;++u)v(L[u],p,p)}for(l(k,L[0]),h.genMipmaps?k.mipmask=(L[0].width<<1)-1:k.mipmask=L[0].mipmask,Mt.textureCube(k,h,L,r),k.internalformat=L[0].internalformat,d.width=L[0].width,d.height=L[0].height,S(k),u=0;u<6;++u)b(L[u],me+u);for(T(h,pe),E(),o.profile&&(k.stats.size=G(k.internalformat,k.type,d.width,d.height,h.genMipmaps,!0)),d.format=K[k.internalformat],d.type=Q[k.type],d.mag=$[h.magFilter],d.min=tt[h.minFilter],d.wrapS=et[h.wrapS],d.wrapT=et[h.wrapT],u=0;u<6;++u)_(L[u]);return d}var k=new A(pe);ot[k.id]=k,a.cubeCount++;var L=new Array(6);return d(e,n,i,s,u,h),d.subimage=function(t,e,r,n,i){Mt(!!e,"must specify image data"),Mt("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var a=0|r,o=0|n,s=0|i,c=m();return l(c,k),c.width=0,c.height=0,f(c,e),c.width=c.width||(k.width>>s)-a,c.height=c.height||(k.height>>s)-o,Mt(k.type===c.type&&k.format===c.format&&k.internalformat===c.internalformat,"incompatible format for texture.subimage"),Mt(a>=0&&o>=0&&a+c.width<=k.width&&o+c.height<=k.height,"texture.subimage write out of bounds"),Mt(k.mipmask&1<>i;++i)t.texImage2D(me+n,i,k.format,r>>i,r>>i,0,k.format,k.type,null);return E(),o.profile&&(k.stats.size=G(k.internalformat,k.type,d.width,d.height,!1,!0)),d}},d._reglType="textureCube",d._texture=k,o.profile&&(d.stats=k.stats),d.destroy=function(){k.decRef()},d},clear:function(){for(var e=0;e>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;n<6;++n)t.texImage2D(me+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);T(e.texInfo,e.target)})}}}function W(t,e,r){return Ir[t]*e*r}function X(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Kr,this.offset=0,this.stride=0,this.divisor=0}function Z(t,e,r,n){function i(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function a(t,e){for(var r=0;r1)for(var m=0;mt&&(t=e.stats.uniformsCount)}),t},r.getMaxAttributesCount=function(){var t=0;return h.forEach(function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)}),t}),{clear:function(){var e=t.deleteShader.bind(t);Ct(l).forEach(e),l={},Ct(c).forEach(e),c={},h.forEach(function(e){t.deleteProgram(e.program)}),h.length=0,u={},r.shaderCount=0},program:function(t,e,i){Mt.command(t>=0,"missing vertex shader",i),Mt.command(e>=0,"missing fragment shader",i);var a=u[e];a||(a=u[e]={});var o=a[t];return o||(o=new function(t,e){this.id=f++,this.fragId=t,this.vertId=e,this.program=null,this.uniforms=[],this.attributes=[],n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}(e,t),r.shaderCount++,s(o,i),a[t]=o,h.push(o)),o},restore:function(){l={},c={};for(var t=0;t=0&&l=0&&c0&&u+l<=n.framebufferWidth,"invalid width for read pixels"),Mt(h>0&&h+c<=n.framebufferHeight,"invalid height for read pixels"),r();var d=u*h*4;return f||(s===nn?f=new Uint8Array(d):s===on&&(f=f||new Float32Array(d))),Mt.isTypedArray(f,"data buffer for regl.read() must be a typedarray"),Mt(f.byteLength>=d,"data buffer for regl.read() too small"),t.pixelStorei(an,4),t.readPixels(l,c,u,h,rn,s,f),f}return function(t){return t&&"framebuffer"in t?function(t){var r;return e.setFBO({framebuffer:t.framebuffer},function(){r=o(t)}),r}(t):o(t)}}function K(t){return Array.prototype.slice.call(t)}function Q(t){return K(t).join("")}function $(t){return Array.isArray(t)||lt(t)||k(t)}function tt(t){return t.sort(function(t,e){return t===Vn?-1:e===Vn?1:t=1,n>=2,e)}if(r===mn){var i=t.data;return new et(i.thisDep,i.contextDep,i.propDep,e)}return new et(r===pn,r===dn,r===fn,e)}function at(t,e,r,n,i,a,o,s,l,c,u,h,f,d,p){function m(t){return t.replace(".","_")}function g(t,e,r){var n=m(t);V.push(t),U[n]=B[n]=!!r,H[n]=e}function v(t,e,r){var n=m(t);V.push(t),Array.isArray(r)?(B[n]=r.slice(),U[n]=r.slice()):B[n]=U[n]=r,q[n]=e}function y(){var t=function(){function t(){var t=[],e=[];return ct(function(){t.push.apply(t,K(arguments))},{def:function(){var n="v"+r++;return e.push(n),arguments.length>0&&(t.push(n,"="),t.push.apply(t,K(arguments)),t.push(";")),n},toString:function(){return Q([e.length>0?"var "+e+";":"",Q(t)])}})}function e(){function e(t,e){n(t,e,"=",r.def(t,e),";")}var r=t(),n=t(),i=r.toString,a=n.toString;return ct(function(){r.apply(r,K(arguments))},{def:r.def,entry:r,exit:n,save:e,set:function(t,n,i){e(t,n),r(t,n,"=",i,";")},toString:function(){return i()+a()}})}var r=0,n=[],i=[],a=t(),o={};return{global:a,link:function(t){for(var e=0;e=0,'unknown parameter "'+t+'"',c.commandStr)})}var e=[qn,Gn,Yn,Wn,Xn,Jn,Zn,Kn,Hn].concat(V);t(f),t(d)});var p=function(t,e){var r=t.static,n=t.dynamic;if(qn in r){var i=r[qn];return i?(i=s.getFramebuffer(i),Mt.command(i,"invalid framebuffer object"),nt(function(t,e){var r=t.link(i),n=t.shared;e.set(n.framebuffer,".next",r);var a=n.context;return e.set(a,"."+Qn,r+".width"),e.set(a,"."+$n,r+".height"),r})):nt(function(t,e){var r=t.shared;e.set(r.framebuffer,".next","null");var n=r.context;return e.set(n,"."+Qn,n+"."+ri),e.set(n,"."+$n,n+"."+ni),"null"})}if(qn in n){var a=n[qn];return it(a,function(t,e){var r=t.invoke(e,a),n=t.shared,i=n.framebuffer,o=e.def(i,".getFramebuffer(",r,")");Mt.optional(function(){t.assert(e,"!"+r+"||"+o,"invalid framebuffer object")}),e.set(i,".next",o);var s=n.context;return e.set(s,"."+Qn,o+"?"+o+".width:"+s+"."+ri),e.set(s,"."+$n,o+"?"+o+".height:"+s+"."+ni),o})}return null}(t),g=function(t,e,r){function n(t){if(t in i){var n=i[t];Mt.commandType(n,"object","invalid "+t,r.commandStr);var o,s,l=!0,c=0|n.x,u=0|n.y;return"width"in n?(o=0|n.width,Mt.command(o>=0,"invalid "+t,r.commandStr)):l=!1,"height"in n?(s=0|n.height,Mt.command(s>=0,"invalid "+t,r.commandStr)):l=!1,new et(!l&&e&&e.thisDep,!l&&e&&e.contextDep,!l&&e&&e.propDep,function(t,e){var r=t.shared.context,i=o;"width"in n||(i=e.def(r,".",Qn,"-",c));var a=s;return"height"in n||(a=e.def(r,".",$n,"-",u)),[c,u,i,a]})}if(t in a){var h=a[t],f=it(h,function(e,r){var n=e.invoke(r,h);Mt.optional(function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)});var i=e.shared.context,a=r.def(n,".x|0"),o=r.def(n,".y|0"),s=r.def('"width" in ',n,"?",n,".width|0:","(",i,".",Qn,"-",a,")"),l=r.def('"height" in ',n,"?",n,".height|0:","(",i,".",$n,"-",o,")");return Mt.optional(function(){e.assert(r,s+">=0&&"+l+">=0","invalid "+t)}),[a,o,s,l]});return e&&(f.thisDep=f.thisDep||e.thisDep,f.contextDep=f.contextDep||e.contextDep,f.propDep=f.propDep||e.propDep),f}return e?new et(e.thisDep,e.contextDep,e.propDep,function(t,e){var r=t.shared.context;return[0,0,e.def(r,".",Qn),e.def(r,".",$n)]}):null}var i=t.static,a=t.dynamic,o=n(Vn);if(o){var s=o;o=new et(o.thisDep,o.contextDep,o.propDep,function(t,e){var r=s.append(t,e),n=t.shared.context;return e.set(n,"."+ti,r[2]),e.set(n,"."+ei,r[3]),r})}return{viewport:o,scissor_box:n(Un)}}(t,p,c),v=function(t,e){function r(t,r){if(t in n){var a=0|n[t];return Mt.command(!r||a>=0,"invalid "+t,e.commandStr),nt(function(t,e){return r&&(t.OFFSET=a),a})}if(t in i){var s=i[t];return it(s,function(e,n){var i=e.invoke(n,s);return r&&(e.OFFSET=i,Mt.optional(function(){e.assert(n,i+">=0","invalid "+t)})),i})}return r&&o?nt(function(t,e){return t.OFFSET="0",0}):null}var n=t.static,i=t.dynamic,o=function(){if(Wn in n){var t=n[Wn];$(t)?t=a.getElements(a.create(t,!0)):t&&(t=a.getElements(t),Mt.command(t,"invalid elements",e.commandStr));var r=nt(function(e,r){if(t){var n=e.link(t);return e.ELEMENTS=n,n}return e.ELEMENTS=null,null});return r.value=t,r}if(Wn in i){var o=i[Wn];return it(o,function(t,e){var r=t.shared,n=r.isBufferArgs,i=r.elements,a=t.invoke(e,o),s=e.def("null"),l=e.def(n,"(",a,")"),c=t.cond(l).then(s,"=",i,".createStream(",a,");").else(s,"=",i,".getElements(",a,");");return Mt.optional(function(){t.assert(c.else,"!"+a+"||"+s,"invalid elements")}),e.entry(c),e.exit(t.cond(l).then(i,".destroyStream(",s,");")),t.ELEMENTS=s,s})}return null}(),s=r(Jn,!0);return{elements:o,primitive:function(){if(Xn in n){var t=n[Xn];return Mt.commandParameter(t,Jt,"invalid primitve",e.commandStr),nt(function(e,r){return Jt[t]})}if(Xn in i){var r=i[Xn];return it(r,function(t,e){var n=t.constants.primTypes,i=t.invoke(e,r);return Mt.optional(function(){t.assert(e,i+" in "+n,"invalid primitive, must be one of "+Object.keys(Jt))}),e.def(n,"[",i,"]")})}return o?rt(o)?o.value?nt(function(t,e){return e.def(t.ELEMENTS,".primType")}):nt(function(){return Oi}):new et(o.thisDep,o.contextDep,o.propDep,function(t,e){var r=t.ELEMENTS;return e.def(r,"?",r,".primType:",Oi)}):null}(),count:function(){if(Zn in n){var t=0|n[Zn];return Mt.command("number"==typeof t&&t>=0,"invalid vertex count",e.commandStr),nt(function(){return t})}if(Zn in i){var r=i[Zn];return it(r,function(t,e){var n=t.invoke(e,r);return Mt.optional(function(){t.assert(e,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(o){if(rt(o)){if(o)return s?new et(s.thisDep,s.contextDep,s.propDep,function(t,e){var r=e.def(t.ELEMENTS,".vertCount-",t.OFFSET);return Mt.optional(function(){t.assert(e,r+">=0","invalid vertex offset/element buffer too small")}),r}):nt(function(t,e){return e.def(t.ELEMENTS,".vertCount")});var a=nt(function(){return-1});return Mt.optional(function(){a.MISSING=!0}),a}var l=new et(o.thisDep||s.thisDep,o.contextDep||s.contextDep,o.propDep||s.propDep,function(t,e){var r=t.ELEMENTS;return t.OFFSET?e.def(r,"?",r,".vertCount-",t.OFFSET,":-1"):e.def(r,"?",r,".vertCount:-1")});return Mt.optional(function(){l.DYNAMIC=!0}),l}return null}(),instances:r(Kn,!1),offset:s}}(t,c),y=function(t,e){var r=t.static,i=t.dynamic,a={};return V.forEach(function(t){function o(e,n){if(t in r){var o=e(r[t]);a[s]=nt(function(){return o})}else if(t in i){var l=i[t];a[s]=it(l,function(t,e){return n(t,e,t.invoke(e,l))})}}var s=m(t);switch(t){case An:case vn:case gn:case On:case _n:case Bn:case Cn:case Pn:case Dn:case kn:return o(function(r){return Mt.commandType(r,"boolean",t,e.commandStr),r},function(e,r,n){return Mt.optional(function(){e.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+t,e.commandStr)}),n});case wn:return o(function(r){return Mt.commandParameter(r,Qi,"invalid "+t,e.commandStr),Qi[r]},function(e,r,n){var i=e.constants.compareFuncs;return Mt.optional(function(){e.assert(r,n+" in "+i,"invalid "+t+", must be one of "+Object.keys(Qi))}),r.def(i,"[",n,"]")});case Mn:return o(function(t){return Mt.command(O(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&t[0]<=t[1],"depth range is 2d array",e.commandStr),t},function(t,e,r){return Mt.optional(function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===2&&typeof "+r+'[0]==="number"&&typeof '+r+'[1]==="number"&&'+r+"[0]<="+r+"[1]","depth range must be a 2d array")}),[e.def("+",r,"[0]"),e.def("+",r,"[1]")]});case xn:return o(function(t){Mt.commandType(t,"object","blend.func",e.commandStr);var r="srcRGB"in t?t.srcRGB:t.src,n="srcAlpha"in t?t.srcAlpha:t.src,i="dstRGB"in t?t.dstRGB:t.dst,a="dstAlpha"in t?t.dstAlpha:t.dst;return Mt.commandParameter(r,Ji,s+".srcRGB",e.commandStr),Mt.commandParameter(n,Ji,s+".srcAlpha",e.commandStr),Mt.commandParameter(i,Ji,s+".dstRGB",e.commandStr),Mt.commandParameter(a,Ji,s+".dstAlpha",e.commandStr),Mt.command(-1===Ki.indexOf(r+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+i+")",e.commandStr),[Ji[r],Ji[i],Ji[n],Ji[a]]},function(e,r,n){function i(i,o){var s=r.def('"',i,o,'" in ',n,"?",n,".",i,o,":",n,".",i);return Mt.optional(function(){e.assert(r,s+" in "+a,"invalid "+t+"."+i+o+", must be one of "+Object.keys(Ji))}),s}var a=e.constants.blendFuncs;Mt.optional(function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")});var o=i("src","RGB"),s=i("dst","RGB");Mt.optional(function(){var t=e.constants.invalidBlendCombinations;e.assert(r,t+".indexOf("+o+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var l=r.def(a,"[",o,"]"),c=r.def(a,"[",i("src","Alpha"),"]");return[l,r.def(a,"[",s,"]"),c,r.def(a,"[",i("dst","Alpha"),"]")]});case bn:return o(function(r){return"string"==typeof r?(Mt.commandParameter(r,R,"invalid "+t,e.commandStr),[R[r],R[r]]):"object"==typeof r?(Mt.commandParameter(r.rgb,R,t+".rgb",e.commandStr),Mt.commandParameter(r.alpha,R,t+".alpha",e.commandStr),[R[r.rgb],R[r.alpha]]):void Mt.commandRaise("invalid blend.equation",e.commandStr)},function(e,r,n){var i=e.constants.blendEquations,a=r.def(),o=r.def(),s=e.cond("typeof ",n,'==="string"');return Mt.optional(function(){function r(t,r,n){e.assert(t,n+" in "+i,"invalid "+r+", must be one of "+Object.keys(R))}r(s.then,t,n),e.assert(s.else,n+"&&typeof "+n+'==="object"',"invalid "+t),r(s.else,t+".rgb",n+".rgb"),r(s.else,t+".alpha",n+".alpha")}),s.then(a,"=",o,"=",i,"[",n,"];"),s.else(a,"=",i,"[",n,".rgb];",o,"=",i,"[",n,".alpha];"),r(s),[a,o]});case yn:return o(function(t){return Mt.command(O(t)&&4===t.length,"blend.color must be a 4d array",e.commandStr),T(4,function(e){return+t[e]})},function(t,e,r){return Mt.optional(function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")}),T(4,function(t){return e.def("+",r,"[",t,"]")})});case Fn:return o(function(t){return Mt.commandType(t,"number",s,e.commandStr),0|t},function(t,e,r){return Mt.optional(function(){t.assert(e,"typeof "+r+'==="number"',"invalid stencil.mask")}),e.def(r,"|0")});case Rn:return o(function(r){Mt.commandType(r,"object",s,e.commandStr);var n=r.cmp||"keep",i=r.ref||0,a="mask"in r?r.mask:-1;return Mt.commandParameter(n,Qi,t+".cmp",e.commandStr),Mt.commandType(i,"number",t+".ref",e.commandStr),Mt.commandType(a,"number",t+".mask",e.commandStr),[Qi[n],i,a]},function(t,e,r){var n=t.constants.compareFuncs;return Mt.optional(function(){function i(){t.assert(e,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(r+"&&typeof ",r,'==="object"'),i('!("cmp" in ',r,")||(",r,".cmp in ",n,")")}),[e.def('"cmp" in ',r,"?",n,"[",r,".cmp]",":",Hi),e.def(r,".ref|0"),e.def('"mask" in ',r,"?",r,".mask|0:-1")]});case jn:case Nn:return o(function(r){Mt.commandType(r,"object",s,e.commandStr);var n=r.fail||"keep",i=r.zfail||"keep",a=r.zpass||"keep";return Mt.commandParameter(n,$i,t+".fail",e.commandStr),Mt.commandParameter(i,$i,t+".zfail",e.commandStr),Mt.commandParameter(a,$i,t+".zpass",e.commandStr),[t===Nn?Ri:Fi,$i[n],$i[i],$i[a]]},function(e,r,n){function i(i){return Mt.optional(function(){e.assert(r,'!("'+i+'" in '+n+")||("+n+"."+i+" in "+a+")","invalid "+t+"."+i+", must be one of "+Object.keys($i))}),r.def('"',i,'" in ',n,"?",a,"[",n,".",i,"]:",Hi)}var a=e.constants.stencilOps;return Mt.optional(function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)}),[t===Nn?Ri:Fi,i("fail"),i("zfail"),i("zpass")]});case In:return o(function(t){Mt.commandType(t,"object",s,e.commandStr);var r=0|t.factor,n=0|t.units;return Mt.commandType(r,"number",s+".factor",e.commandStr),Mt.commandType(n,"number",s+".units",e.commandStr),[r,n]},function(e,r,n){return Mt.optional(function(){e.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+t)}),[r.def(n,".factor|0"),r.def(n,".units|0")]});case Sn:return o(function(t){var r=0;return"front"===t?r=Fi:"back"===t&&(r=Ri),Mt.command(!!r,s,e.commandStr),r},function(t,e,r){return Mt.optional(function(){t.assert(e,r+'==="front"||'+r+'==="back"',"invalid cull.face")}),e.def(r,'==="front"?',Fi,":",Ri)});case Ln:return o(function(t){return Mt.command("number"==typeof t&&t>=n.lineWidthDims[0]&&t<=n.lineWidthDims[1],"invalid line width, must positive number between "+n.lineWidthDims[0]+" and "+n.lineWidthDims[1],e.commandStr),t},function(t,e,r){return Mt.optional(function(){t.assert(e,"typeof "+r+'==="number"&&'+r+">="+n.lineWidthDims[0]+"&&"+r+"<="+n.lineWidthDims[1],"invalid line width")}),r});case En:return o(function(t){return Mt.commandParameter(t,ea,s,e.commandStr),ea[t]},function(t,e,r){return Mt.optional(function(){t.assert(e,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),e.def(r+'==="cw"?'+ji+":"+Ni)});case Tn:return o(function(t){return Mt.command(O(t)&&4===t.length,"color.mask must be length 4 array",e.commandStr),t.map(function(t){return!!t})},function(t,e,r){return Mt.optional(function(){t.assert(e,t.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")}),T(4,function(t){return"!!"+r+"["+t+"]"})});case zn:return o(function(t){Mt.command("object"==typeof t&&t,s,e.commandStr);var r="value"in t?t.value:1,n=!!t.invert;return Mt.command("number"==typeof r&&r>=0&&r<=1,"sample.coverage.value must be a number between 0 and 1",e.commandStr),[r,n]},function(t,e,r){return Mt.optional(function(){t.assert(e,r+"&&typeof "+r+'==="object"',"invalid sample.coverage")}),[e.def('"value" in ',r,"?+",r,".value:1"),e.def("!!",r,".invert")]})}}),a}(t,c),b=function(t){function r(t){if(t in i){var r=e.id(i[t]);Mt.optional(function(){u.shader(ta[t],r,Mt.guessCommand())});var n=nt(function(){return r});return n.id=r,n}if(t in a){var o=a[t];return it(o,function(e,r){var n=e.invoke(r,o),i=r.def(e.shared.strings,".id(",n,")");return Mt.optional(function(){r(e.shared.shader,".shader(",ta[t],",",i,",",e.command,");")}),i})}return null}var n,i=t.static,a=t.dynamic,o=r(Yn),s=r(Gn),l=null;return rt(o)&&rt(s)?(l=u.program(s.id,o.id),n=nt(function(t,e){return t.link(l)})):n=new et(o&&o.thisDep||s&&s.thisDep,o&&o.contextDep||s&&s.contextDep,o&&o.propDep||s&&s.propDep,function(t,e){var r,n=t.shared.shader;r=o?o.append(t,e):e.def(n,".",Yn);var i=n+".program("+(s?s.append(t,e):e.def(n,".",Gn))+","+r;return Mt.optional(function(){i+=","+t.command}),e.def(i+")")}),{frag:o,vert:s,progVar:n,program:l}}(t);h(Vn),h(m(Un));var x=Object.keys(y).length>0,_={framebuffer:p,draw:v,shader:b,state:y,dirty:x};return _.profile=function(t){var e,r=t.static,n=t.dynamic;if(Hn in r){var i=!!r[Hn];(e=nt(function(t,e){return i})).enable=i}else if(Hn in n){var a=n[Hn];e=it(a,function(t,e){return t.invoke(e,a)})}return e}(t),_.uniforms=function(t,e){var r=t.static,n=t.dynamic,i={};return Object.keys(r).forEach(function(t){var n,a=r[t];if("number"==typeof a||"boolean"==typeof a)n=nt(function(){return a});else if("function"==typeof a){var o=a._reglType;"texture2d"===o||"textureCube"===o?n=nt(function(t){return t.link(a)}):"framebuffer"===o||"framebufferCube"===o?(Mt.command(a.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',e.commandStr),n=nt(function(t){return t.link(a.color[0])})):Mt.commandRaise('invalid data for uniform "'+t+'"',e.commandStr)}else O(a)?n=nt(function(e){return e.global.def("[",T(a.length,function(r){return Mt.command("number"==typeof a[r]||"boolean"==typeof a[r],"invalid uniform "+t,e.commandStr),a[r]}),"]")}):Mt.commandRaise('invalid or missing data for uniform "'+t+'"',e.commandStr);n.value=a,i[t]=n}),Object.keys(n).forEach(function(t){var e=n[t];i[t]=it(e,function(t,r){return t.invoke(r,e)})}),i}(o,c),_.attributes=function(t,r){var n=t.static,a=t.dynamic,o={};return Object.keys(n).forEach(function(t){var a=n[t],s=e.id(t),l=new F;if($(a))l.state=cn,l.buffer=i.getBuffer(i.create(a,ai,!1,!0)),l.type=0;else{var c=i.getBuffer(a);if(c)l.state=cn,l.buffer=c,l.type=0;else if(Mt.command("object"==typeof a&&a,"invalid data for attribute "+t,r.commandStr),a.constant){var u=a.constant;l.buffer="null",l.state=un,"number"==typeof u?l.x=u:(Mt.command(O(u)&&u.length>0&&u.length<=4,"invalid constant for attribute "+t,r.commandStr),sn.forEach(function(t,e){e=0,'invalid offset for attribute "'+t+'"',r.commandStr);var f=0|a.stride;Mt.command(f>=0&&f<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',r.commandStr);var d=0|a.size;Mt.command(!("size"in a)||d>0&&d<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',r.commandStr);var p=!!a.normalized,m=0;"type"in a&&(Mt.commandParameter(a.type,Ut,"invalid type for attribute "+t,r.commandStr),m=Ut[a.type]);var g=0|a.divisor;"divisor"in a&&(Mt.command(0===g||j,'cannot specify divisor for attribute "'+t+'", instancing not supported',r.commandStr),Mt.command(g>=0,'invalid divisor for attribute "'+t+'"',r.commandStr)),Mt.optional(function(){var e=r.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(a).forEach(function(r){Mt.command(n.indexOf(r)>=0,'unknown parameter "'+r+'" for attribute pointer "'+t+'" (valid parameters are '+n+")",e)})}),l.buffer=c,l.state=cn,l.size=d,l.normalized=p,l.type=m||c.dtype,l.offset=h,l.stride=f,l.divisor=g}}o[t]=nt(function(t,e){var r=t.attribCache;if(s in r)return r[s];var n={isStream:!1};return Object.keys(l).forEach(function(t){n[t]=l[t]}),l.buffer&&(n.buffer=t.link(l.buffer),n.type=n.type||n.buffer+".dtype"),r[s]=n,n})}),Object.keys(a).forEach(function(t){var e=a[t];o[t]=it(e,function(r,n){function i(t){n(c[t],"=",a,".",t,"|0;")}var a=r.invoke(n,e),o=r.shared,s=o.isBufferArgs,l=o.buffer;Mt.optional(function(){r.assert(n,a+"&&(typeof "+a+'==="object"||typeof '+a+'==="function")&&('+s+"("+a+")||"+l+".getBuffer("+a+")||"+l+".getBuffer("+a+".buffer)||"+s+"("+a+'.buffer)||("constant" in '+a+"&&(typeof "+a+'.constant==="number"||'+o.isArrayLike+"("+a+".constant))))",'invalid dynamic attribute "'+t+'"')});var c={isStream:n.def(!1)},u=new F;u.state=cn,Object.keys(u).forEach(function(t){c[t]=n.def(""+u[t])});var h=c.buffer,f=c.type;return n("if(",s,"(",a,")){",c.isStream,"=true;",h,"=",l,".createStream(",ai,",",a,");",f,"=",h,".dtype;","}else{",h,"=",l,".getBuffer(",a,");","if(",h,"){",f,"=",h,".dtype;",'}else if("constant" in ',a,"){",c.state,"=",un,";","if(typeof "+a+'.constant === "number"){',c[sn[0]],"=",a,".constant;",sn.slice(1).map(function(t){return c[t]}).join("="),"=0;","}else{",sn.map(function(t,e){return c[t]+"="+a+".constant.length>="+e+"?"+a+".constant["+e+"]:0;"}).join(""),"}}else{","if(",s,"(",a,".buffer)){",h,"=",l,".createStream(",ai,",",a,".buffer);","}else{",h,"=",l,".getBuffer(",a,".buffer);","}",f,'="type" in ',a,"?",o.glTypes,"[",a,".type]:",h,".dtype;",c.normalized,"=!!",a,".normalized;"),i("size"),i("offset"),i("stride"),i("divisor"),n("}}"),n.exit("if(",c.isStream,"){",l,".destroyStream(",h,");","}"),c})}),o}(r,c),_.context=function(t){var e=t.static,r=t.dynamic,n={};return Object.keys(e).forEach(function(t){var r=e[t];n[t]=nt(function(t,e){return"number"==typeof r||"boolean"==typeof r?""+r:t.link(r)})}),Object.keys(r).forEach(function(t){var e=r[t];n[t]=it(e,function(t,r){return t.invoke(r,e)})}),n}(l),_}function x(t,e,r){var n=t.shared.context,i=t.scope();Object.keys(r).forEach(function(a){e.save(n,"."+a);var o=r[a];i(n,".",a,"=",o.append(t,e),";")}),e(i)}function _(t,e,r,n){var i,a=t.shared,o=a.gl,s=a.framebuffer;N&&(i=e.def(a.extensions,".webgl_draw_buffers"));var l,c=t.constants,u=c.drawBuffer,h=c.backBuffer;l=r?r.append(t,e):e.def(s,".next"),n||e("if(",l,"!==",s,".cur){"),e("if(",l,"){",o,".bindFramebuffer(",Xi,",",l,".framebuffer);"),N&&e(i,".drawBuffersWEBGL(",u,"[",l,".colorAttachments.length]);"),e("}else{",o,".bindFramebuffer(",Xi,",null);"),N&&e(i,".drawBuffersWEBGL(",h,");"),e("}",s,".cur=",l,";"),n||e("}")}function w(t,e,r){var n=t.shared,i=n.gl,a=t.current,o=t.next,s=n.current,l=n.next,c=t.cond(s,".dirty");V.forEach(function(e){var n=m(e);if(!(n in r.state)){var u,h;if(n in o){u=o[n],h=a[n];var f=T(B[n].length,function(t){return c.def(u,"[",t,"]")});c(t.cond(f.map(function(t,e){return t+"!=="+h+"["+e+"]"}).join("||")).then(i,".",q[n],"(",f,");",f.map(function(t,e){return h+"["+e+"]="+t}).join(";"),";"))}else{u=c.def(l,".",n);var d=t.cond(u,"!==",s,".",n);c(d),n in H?d(t.cond(u).then(i,".enable(",H[n],");").else(i,".disable(",H[n],");"),s,".",n,"=",u,";"):d(i,".",q[n],"(",u,");",s,".",n,"=",u,";")}}}),0===Object.keys(r.state).length&&c(s,".dirty=false;"),e(c)}function M(t,e,r,n){var i=t.shared,a=t.current,o=i.current,s=i.gl;tt(Object.keys(r)).forEach(function(i){var l=r[i];if(!n||n(l)){var c=l.append(t,e);if(H[i]){var u=H[i];rt(l)?e(s,c?".enable(":".disable(",u,");"):e(t.cond(c).then(s,".enable(",u,");").else(s,".disable(",u,");")),e(o,".",i,"=",c,";")}else if(O(c)){var h=a[i];e(s,".",q[i],"(",c,");",c.map(function(t,e){return h+"["+e+"]="+t}).join(";"),";")}else e(s,".",q[i],"(",c,");",o,".",i,"=",c,";")}})}function k(t,e){j&&(t.instancing=e.def(t.shared.extensions,".angle_instanced_arrays"))}function A(t,e,r,n,i){function a(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(t){t(c=e.def(),"=",a(),";"),"string"==typeof i?t(p,".count+=",i,";"):t(p,".count++;"),d&&(n?t(u=e.def(),"=",g,".getNumPendingQueries();"):t(g,".beginQuery(",p,");"))}function s(t){t(p,".cpuTime+=",a(),"-",c,";"),d&&(n?t(g,".pushScopeStats(",u,",",g,".getNumPendingQueries(),",p,");"):t(g,".endQuery();"))}function l(t){var r=e.def(m,".profile");e(m,".profile=",t,";"),e.exit(m,".profile=",r,";")}var c,u,h,f=t.shared,p=t.stats,m=f.current,g=f.timer,v=r.profile;if(v){if(rt(v))return void(v.enable?(o(e),s(e.exit),l("true")):l("false"));l(h=v.append(t,e))}else h=e.def(m,".profile");var y=t.block();o(y),e("if(",h,"){",y,"}");var b=t.block();s(b),e.exit("if(",h,"){",b,"}")}function S(t,e,r,n,i){var a=t.shared;n.forEach(function(n){var o,s=n.name,l=r.attributes[s];if(l){if(!i(l))return;o=l.append(t,e)}else{if(!i(ra))return;var c=t.scopeAttrib(s);Mt.optional(function(){t.assert(e,c+".state","missing attribute "+s)}),o={},Object.keys(new F).forEach(function(t){o[t]=e.def(c,".",t)})}!function(r,n,i){function o(){e("if(!",u,".buffer){",l,".enableVertexAttribArray(",c,");}");var r,a=i.type;if(r=i.size?e.def(i.size,"||",n):n,e("if(",u,".type!==",a,"||",u,".size!==",r,"||",p.map(function(t){return u+"."+t+"!=="+i[t]}).join("||"),"){",l,".bindBuffer(",ai,",",f,".buffer);",l,".vertexAttribPointer(",[c,r,a,i.normalized,i.stride,i.offset],");",u,".type=",a,";",u,".size=",r,";",p.map(function(t){return u+"."+t+"="+i[t]+";"}).join(""),"}"),j){var o=i.divisor;e("if(",u,".divisor!==",o,"){",t.instancing,".vertexAttribDivisorANGLE(",[c,o],");",u,".divisor=",o,";}")}}function s(){e("if(",u,".buffer){",l,".disableVertexAttribArray(",c,");","}if(",sn.map(function(t,e){return u+"."+t+"!=="+d[e]}).join("||"),"){",l,".vertexAttrib4f(",c,",",d,");",sn.map(function(t,e){return u+"."+t+"="+d[e]+";"}).join(""),"}")}var l=a.gl,c=e.def(r,".location"),u=e.def(a.attributes,"[",c,"]"),h=i.state,f=i.buffer,d=[i.x,i.y,i.z,i.w],p=["buffer","normalized","offset","stride"];h===cn?o():h===un?s():(e("if(",h,"===",cn,"){"),o(),e("}else{"),s(),e("}"))}(t.link(n),function(t){switch(t){case bi:case Mi:case Si:return 2;case xi:case ki:case Ei:return 3;case _i:case Ti:case Li:return 4;default:return 1}}(n.info.type),o)})}function E(t,r,n,i,a){for(var o,s=t.shared,l=s.gl,c=0;c1?T(x,function(t){return u+"["+t+"]"}):u);r(");")}}function L(t,e,r,n){function i(i){var a=u[i];return a?a.contextDep&&n.contextDynamic||a.propDep?a.append(t,r):a.append(t,e):e.def(c,".",i)}function a(){function t(){r(g,".drawElementsInstancedANGLE(",[f,p,v,d+"<<(("+v+"-"+ln+")>>1)",m],");")}function e(){r(g,".drawArraysInstancedANGLE(",[f,d,p,m],");")}h?y?t():(r("if(",h,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(l+".drawElements("+[f,p,v,d+"<<(("+v+"-"+ln+")>>1)"]+");")}function e(){r(l+".drawArrays("+[f,d,p]+");")}h?y?t():(r("if(",h,"){"),t(),r("}else{"),e(),r("}")):e()}var s=t.shared,l=s.gl,c=s.draw,u=n.draw,h=function(){var i,a=u.elements,o=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(o=r),i=a.append(t,o)):i=o.def(c,".",Wn),i&&o("if("+i+")"+l+".bindBuffer("+oi+","+i+".buffer.buffer);"),i}(),f=i(Xn),d=i(Jn),p=function(){var i,a=u.count,o=e;return a?((a.contextDep&&n.contextDynamic||a.propDep)&&(o=r),i=a.append(t,o),Mt.optional(function(){a.MISSING&&t.assert(e,"false","missing vertex count"),a.DYNAMIC&&t.assert(o,i+">=0","missing vertex count")})):(i=o.def(c,".",Zn),Mt.optional(function(){t.assert(o,i+">=0","missing vertex count")})),i}();if("number"==typeof p){if(0===p)return}else r("if(",p,"){"),r.exit("}");var m,g;j&&(m=i(Kn),g=t.instancing);var v=h+".type",y=u.elements&&rt(u.elements);j&&("number"!=typeof m||m>=0)?"string"==typeof m?(r("if(",m,">0){"),a(),r("}else if(",m,"<0){"),o(),r("}")):a():o()}function C(t,e,r,n,i){var a=y(),o=a.proc("body",i);return Mt.optional(function(){a.commandStr=e.commandStr,a.command=a.link(e.commandStr)}),j&&(a.instancing=o.def(a.shared.extensions,".angle_instanced_arrays")),t(a,o,r,n),a.compile().body}function I(t,e,r,n){k(t,e),S(t,e,r,n.attributes,function(){return!0}),E(t,e,r,n.uniforms,function(){return!0}),L(t,e,e,r)}function P(t,e,r,n){function i(){return!0}t.batchId="a1",k(t,e),S(t,e,r,n.attributes,i),E(t,e,r,n.uniforms,i),L(t,e,e,r)}function D(t,e,r,n){function i(t){return t.contextDep&&o||t.propDep}function a(t){return!i(t)}k(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var c=t.scope(),u=t.scope();if(e(c.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",u,"}",c.exit),r.needsContext&&x(t,u,r.context),r.needsFramebuffer&&_(t,u,r.framebuffer),M(t,u,r.state,i),r.profile&&i(r.profile)&&A(t,u,r,!1,!0),n)S(t,c,r,n.attributes,a),S(t,u,r,n.attributes,i),E(t,c,r,n.uniforms,a),E(t,u,r,n.uniforms,i),L(t,c,u,r);else{var h=t.global.def("{}"),f=r.shader.progVar.append(t,u),d=u.def(f,".id"),p=u.def(h,"[",d,"]");u(t.shared.gl,".useProgram(",f,".program);","if(!",p,"){",p,"=",h,"[",d,"]=",t.link(function(e){return C(P,t,r,e,2)}),"(",f,");}",p,".call(this,a0[",s,"],",s,");")}}function z(t,e,r){var n=e.static[r];if(n&&function(t){if("object"==typeof t&&!O(t)){for(var e=Object.keys(t),r=0;r0&&r(t.shared.current,".dirty=true;")}(o,s),function(t,r){function n(e){var n=r.shader[e];n&&i.set(a.shader,"."+e,n.append(t,i))}var i=t.proc("scope",3);t.batchId="a2";var a=t.shared,o=a.current;x(t,i,r.context),r.framebuffer&&r.framebuffer.append(t,i),tt(Object.keys(r.state)).forEach(function(e){var n=r.state[e].append(t,i);O(n)?n.forEach(function(r,n){i.set(t.next[e],"["+n+"]",r)}):i.set(a.next,"."+e,n)}),A(t,i,r,!0,!0),[Wn,Jn,Zn,Kn,Xn].forEach(function(e){var n=r.draw[e];n&&i.set(a.draw,"."+e,""+n.append(t,i))}),Object.keys(r.uniforms).forEach(function(n){i.set(a.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,i))}),Object.keys(r.attributes).forEach(function(e){var n=r.attributes[e].append(t,i),a=t.scopeAttrib(e);Object.keys(new F).forEach(function(t){i.set(a,"."+t,n[t])})}),n(Gn),n(Yn),Object.keys(r.state).length>0&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",t.shared.context,",a0,",t.batchId,");")}(o,s),function(t,e){function r(t){return t.contextDep&&i||t.propDep}var n=t.proc("batch",2);t.batchId="0",k(t,n);var i=!1,a=!0;Object.keys(e.context).forEach(function(t){i=i||e.context[t].propDep}),i||(x(t,n,e.context),a=!1);var o=e.framebuffer,s=!1;o?(o.propDep?i=s=!0:o.contextDep&&i&&(s=!0),s||_(t,n,o)):_(t,n,null),e.state.viewport&&e.state.viewport.propDep&&(i=!0),w(t,n,e),M(t,n,e.state,function(t){return!r(t)}),e.profile&&r(e.profile)||A(t,n,e,!1,"a1"),e.contextDep=i,e.needsContext=a,e.needsFramebuffer=s;var l=e.shader.progVar;if(l.contextDep&&i||l.propDep)D(t,n,e,null);else{var c=l.append(t,n);if(n(t.shared.gl,".useProgram(",c,".program);"),e.shader.program)D(t,n,e,e.shader.program);else{var u=t.global.def("{}"),h=n.def(c,".id"),f=n.def(u,"[",h,"]");n(t.cond(f).then(f,".call(this,a0,a1);").else(f,"=",u,"[",h,"]=",t.link(function(r){return C(D,t,e,r,2)}),"(",c,");",f,".call(this,a0,a1);"))}}Object.keys(e.state).length>0&&n(t.shared.current,".dirty=true;")}(o,s),o.compile()}}}function ot(t,e){for(var r=0;r=0&&(0|t)===t||e("invalid parameter type, ("+t+")"+n(r)+". must be a nonnegative integer")},oneOf:i,shaderError:function(t,e,n,i,o){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var s=t.getShaderInfoLog(e),c=i===t.FRAGMENT_SHADER?"fragment":"vertex";p(n,"string",c+" shader source must be a string",o);var u=h(n,o),f=function(t){var e=[];return t.split("\n").forEach(function(t){if(!(t.length<5)){var r=/^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(t);r?e.push(new l(0|r[1],0|r[2],r[3].trim())):t.length>0&&e.push(new l("unknown",0,t))}}),e}(s);!function(t,e){e.forEach(function(e){var r=t[e.file];if(r){var n=r.index[e.line];if(n)return n.errors.push(e),void(r.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(e)})}(u,f),Object.keys(u).forEach(function(t){function e(t,e){n.push(t),i.push(e||"")}var r=u[t];if(r.hasErrors){var n=[""],i=[""];e("file number "+t+": "+r.name+"\n","color:red;text-decoration:underline;font-weight:bold"),r.lines.forEach(function(t){if(t.errors.length>0){e(a(t.number,4)+"| ","background-color:yellow; font-weight:bold"),e(t.line+"\n","color:red; background-color:yellow; font-weight:bold");var r=0;t.errors.forEach(function(n){var i=n.message,o=/^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(i);if(o){var s=o[1];switch(i=o[2],s){case"assign":s="="}r=Math.max(t.line.indexOf(s,r),0)}else r=0;e(a("| ",6)),e(a("^^^",r+3)+"\n","font-weight:bold"),e(a("| ",6)),e(i+"\n","font-weight:bold")}),e(a("| ",6)+"\n")}else e(a(t.number,4)+"| "),e(t.line+"\n","color:red")}),"undefined"!=typeof document?(i[0]=n.join("%c"),console.log.apply(console,i)):console.log(n.join(""))}}),r.raise("Error compiling "+c+" shader, "+u[0].name)}},linkError:function(t,e,n,i,a){if(!t.getProgramParameter(e,t.LINK_STATUS)){var o=t.getProgramInfoLog(e),s=h(n,a),l='Error linking program with vertex shader, "'+h(i,a)[0].name+'", and fragment shader "'+s[0].name+'"';"undefined"!=typeof document?console.log("%c"+l+"\n%c"+o,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(l+"\n"+o),r.raise(l)}},callSite:u,saveCommandRef:f,saveDrawInfo:function(t,e,r,n){function i(t){return t?n.id(t):0}function a(t,e){Object.keys(e).forEach(function(e){t[n.id(e)]=!0})}f(t),t._fragId=i(t.static.frag),t._vertId=i(t.static.vert);var o=t._uniformSet={};a(o,e.static),a(o,e.dynamic);var s=t._attributeSet={};a(s,r.static),a(s,r.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic},framebufferFormat:function(t,e,r){t.texture?i(t.texture._texture.internalformat,e,"unsupported texture format for attachment"):i(t.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")},guessCommand:c,texture2D:function(t,e,n){var i,a=e.width,o=e.height,s=e.channels;r(a>0&&a<=n.maxTextureSize&&o>0&&o<=n.maxTextureSize,"invalid texture shape"),t.wrapS===ht&&t.wrapT===ht||r(g(a)&&g(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===e.mipmask?1!==a&&1!==o&&r(t.minFilter!==dt&&t.minFilter!==mt&&t.minFilter!==pt&&t.minFilter!==gt,"min filter requires mipmap"):(r(g(a)&&g(o),"texture must be a square power of 2 to support mipmapping"),r(e.mipmask===(a<<1)-1,"missing or incomplete mipmap data")),e.type===vt&&(n.extensions.indexOf("oes_texture_float_linear")<0&&r(t.minFilter===ft&&t.magFilter===ft,"filter not supported, must enable oes_texture_float_linear"),r(!t.genMipmaps,"mipmap generation not supported with float textures"));var l=e.images;for(i=0;i<16;++i)if(l[i]){var c=a>>i,u=o>>i;r(e.mipmask&1<0&&a<=i.maxTextureSize&&o>0&&o<=i.maxTextureSize,"invalid texture shape"),r(a===o,"cube map must be square"),r(e.wrapS===ht&&e.wrapT===ht,"wrap mode not supported by cube map");for(var l=0;l>h,p=o>>h;r(c.mipmask&1<=2,"invalid renderbuffer shape"),a=0|d[0],o=0|d[1]}else"radius"in f&&(a=o=0|f.radius),"width"in f&&(a=0|f.width),"height"in f&&(o=0|f.height);"format"in f&&(Mt.parameter(f.format,s,"invalid renderbuffer format"),u=s[f.format])}else"number"==typeof e?(a=0|e,o="number"==typeof n?0|n:a):e?Mt.raise("invalid arguments to renderbuffer constructor"):a=o=1;if(Mt(a>0&&o>0&&a<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),a!==h.width||o!==h.height||u!==h.format)return c.width=h.width=a,c.height=h.height=o,h.format=u,t.bindRenderbuffer(Lr,h.renderbuffer),t.renderbufferStorage(Lr,u,a,o),i.profile&&(h.stats.size=W(h.format,h.width,h.height)),c.format=l[h.format],c}var h=new a(t.createRenderbuffer());return u[h.id]=h,n.renderbufferCount++,c(e,o),c.resize=function(e,n){var a=0|e,o=0|n||a;return a===h.width&&o===h.height?c:(Mt(a>0&&o>0&&a<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),c.width=h.width=a,c.height=h.height=o,t.bindRenderbuffer(Lr,h.renderbuffer),t.renderbufferStorage(Lr,h.format,a,o),i.profile&&(h.stats.size=W(h.format,h.width,h.height)),c)},c._reglType="renderbuffer",c._renderbuffer=h,i.profile&&(c.stats=h.stats),c.destroy=function(){h.decRef()},c},clear:function(){Ct(u).forEach(o)},restore:function(){Ct(u).forEach(function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(Lr,e.renderbuffer),t.renderbufferStorage(Lr,e.format,e.width,e.height)}),t.bindRenderbuffer(Lr,null)}}},Dr=36160,zr=36161,Or=3553,Fr=34069,Rr=36064,jr=36096,Nr=36128,Br=33306,Ur=36053,Vr=6402,Hr=[6408],qr=[];qr[6408]=4;var Gr=[];Gr[5121]=1,Gr[5126]=4,Gr[36193]=2;var Yr=33189,Wr=36168,Xr=34041,Zr=[32854,32855,36194,35907,34842,34843,34836],Jr={};Jr[Ur]="complete",Jr[36054]="incomplete attachment",Jr[36057]="incomplete dimensions",Jr[36055]="incomplete, missing attachment",Jr[36061]="unsupported";var Kr=5126,Qr=35632,$r=35633,tn=35718,en=35721,rn=6408,nn=5121,an=3333,on=5126,sn="xyzw".split(""),ln=5121,cn=1,un=2,hn=0,fn=1,dn=2,pn=3,mn=4,gn="dither",vn="blend.enable",yn="blend.color",bn="blend.equation",xn="blend.func",_n="depth.enable",wn="depth.func",Mn="depth.range",kn="depth.mask",Tn="colorMask",An="cull.enable",Sn="cull.face",En="frontFace",Ln="lineWidth",Cn="polygonOffset.enable",In="polygonOffset.offset",Pn="sample.alpha",Dn="sample.enable",zn="sample.coverage",On="stencil.enable",Fn="stencil.mask",Rn="stencil.func",jn="stencil.opFront",Nn="stencil.opBack",Bn="scissor.enable",Un="scissor.box",Vn="viewport",Hn="profile",qn="framebuffer",Gn="vert",Yn="frag",Wn="elements",Xn="primitive",Zn="count",Jn="offset",Kn="instances",Qn=qn+"Width",$n=qn+"Height",ti=Vn+"Width",ei=Vn+"Height",ri="drawingBufferWidth",ni="drawingBufferHeight",ii=[xn,bn,Rn,jn,Nn,zn,Vn,Un,In],ai=34962,oi=34963,si=3553,li=34067,ci=2884,ui=3042,hi=3024,fi=2960,di=2929,pi=3089,mi=32823,gi=32926,vi=32928,yi=5126,bi=35664,xi=35665,_i=35666,wi=5124,Mi=35667,ki=35668,Ti=35669,Ai=35670,Si=35671,Ei=35672,Li=35673,Ci=35674,Ii=35675,Pi=35676,Di=35678,zi=35680,Oi=4,Fi=1028,Ri=1029,ji=2304,Ni=2305,Bi=32775,Ui=32776,Vi=519,Hi=7680,qi=0,Gi=1,Yi=32774,Wi=513,Xi=36160,Zi=36064,Ji={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Ki=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Qi={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},$i={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ta={frag:35632,vert:35633},ea={cw:ji,ccw:Ni},ra=new et(!1,!1,!1,function(){}),na=34918,ia=34919,aa=35007,oa=function(t,e){function r(t){o.push(t)}function n(t){l.push(t)}function i(t,e,r){var n=l.pop()||new function(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null};n.startQueryIndex=t,n.endQueryIndex=e,n.sum=0,n.stats=r,c.push(n)}var a=e.ext_disjoint_timer_query;if(!a)return null;var o=[],s=[],l=[],c=[],u=[],h=[];return{beginQuery:function(t){var e=o.pop()||a.createQueryEXT();a.beginQueryEXT(aa,e),s.push(e),i(s.length-1,s.length,t)},endQuery:function(){a.endQueryEXT(aa)},pushScopeStats:i,update:function(){var t,e,i=s.length;if(0!==i){h.length=Math.max(h.length,i+1),u.length=Math.max(u.length,i+1),u[0]=0,h[0]=0;var o=0;for(t=0,e=0;e=0;--t){var r=H[t];r&&r(S,null,0)}p.flush(),_&&_.update()}function r(){!K&&H.length>0&&(K=St.next(e))}function n(){K&&(St.cancel(e),K=null)}function i(t){t.preventDefault(),g=!0,n(),q.forEach(function(t){t()})}function a(t){p.getError(),g=!1,v.restore(),O.restore(),L.restore(),F.restore(),R.restore(),j.restore(),_&&_.restore(),N.procs.refresh(),r(),G.forEach(function(t){t()})}function o(t){function e(t){var e={},r={};return Object.keys(t).forEach(function(n){var i=t[n];At.isDynamic(i)?r[n]=At.unbox(i,n):e[n]=i}),{dynamic:r,static:e}}Mt(!!t,"invalid args to regl({...})"),Mt.type(t,"object","invalid args to regl({...})");var r=e(t.context||{}),n=e(t.uniforms||{}),i=e(t.attributes||{}),a=e(function(t){function e(t){if(t in r){var e=r[t];delete r[t],Object.keys(e).forEach(function(n){r[t+"."+n]=e[n]})}}var r=ct({},t);return delete r.uniforms,delete r.attributes,delete r.context,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),e("blend"),e("depth"),e("cull"),e("stencil"),e("polygonOffset"),e("scissor"),e("sample"),r}(t)),o={gpuTime:0,cpuTime:0,count:0},s=N.compile(a,i,n,r,o),l=s.draw,c=s.batch,u=s.scope,h=[];return ct(function(t,e){var r;if(g&&Mt.raise("context lost"),"function"==typeof t)return u.call(this,null,t,0);if("function"==typeof e){if("number"==typeof t){for(r=0;r0)return c.call(this,function(t){for(;h.length=0,"cannot cancel a frame twice"),H[r]=e}}}function c(){var t=U.viewport,e=U.scissor_box;t[0]=t[1]=e[0]=e[1]=0,S.viewportWidth=S.framebufferWidth=S.drawingBufferWidth=t[2]=e[2]=p.drawingBufferWidth,S.viewportHeight=S.framebufferHeight=S.drawingBufferHeight=t[3]=e[3]=p.drawingBufferHeight}function u(){S.tick+=1,S.time=f(),c(),N.procs.poll()}function h(){c(),N.procs.refresh(),_&&_.update()}function f(){return(Et()-w)/1e3}var d=M(t);if(!d)return null;var p=d.gl,m=p.getContextAttributes(),g=p.isContextLost(),v=function(t,e){function r(e){Mt.type(e,"string","extension name must be string");var r,i=e.toLowerCase();try{r=n[i]=t.getExtension(i)}catch(t){}return!!r}for(var n={},i=0;i0){var l;if(Array.isArray(e[0])){s=qt(e);for(var c=1,u=1;u0)if("number"==typeof t[0]){var i=Nt.allocType(d.dtype,t.length);P(i,t),f(i,n),Nt.freeType(i)}else if(Array.isArray(t[0])||lt(t[0])){r=qt(t);var a=Ht(t,r,d.dtype);f(a,n),Nt.freeType(a)}else Mt.raise("invalid buffer data")}else if(lt(t))f(t,n);else if(k(t)){r=t.shape;var o=t.stride,s=0,l=0,c=0,u=0;1===r.length?(s=r[0],l=1,c=o[0],u=0):2===r.length?(s=r[0],l=r[1],c=o[0],u=o[1]):Mt.raise("invalid shape");var p=Array.isArray(t.data)?d.dtype:I(t.data),m=Nt.allocType(p,s*l);D(m,t.data,s,l,c,u,t.offset),f(m,n),Nt.freeType(m)}else Mt.raise("invalid data for buffer subdata");return h},r.profile&&(h.stats=d.stats),h.destroy=function(){o(d)},h},createStream:function(t,e){var r=c.pop();return r||(r=new n(t)),r.bind(),a(r,e,Yt,0,1,!1),r},destroyStream:function(t){c.push(t)},clear:function(){Ct(l).forEach(o),c.forEach(o)},getBuffer:function(t){return t&&t._buffer instanceof n?t._buffer:null},restore:function(){Ct(l).forEach(function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)})},_initBuffer:a}}(p,b,d),C=function(t,e,r,n){function i(t){this.id=l++,s[this.id]=this,this.buffer=t,this.primType=$t,this.vertCount=0,this.type=0}function a(n,i,a,o,s,l,c){if(n.buffer.bind(),i){var u=c;c||lt(i)&&(!k(i)||lt(i.data))||(u=e.oes_element_index_uint?ae:ne),r._initBuffer(n.buffer,i,a,u,3)}else t.bufferData(oe,l,a),n.buffer.dtype=h||ee,n.buffer.usage=a,n.buffer.dimension=3,n.buffer.byteLength=l;var h=c;if(!c){switch(n.buffer.dtype){case ee:case te:h=ee;break;case ne:case re:h=ne;break;case ae:case ie:h=ae;break;default:Mt.raise("unsupported type for element array")}n.buffer.dtype=h}n.type=h,Mt(h!==ae||!!e.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var f=s;f<0&&(f=n.buffer.byteLength,h===ne?f>>=1:h===ae&&(f>>=2)),n.vertCount=f;var d=o;if(o<0){d=$t;var p=n.buffer.dimension;1===p&&(d=Kt),2===p&&(d=Qt),3===p&&(d=$t)}n.primType=d}function o(t){n.elementsCount--,Mt(null!==t.buffer,"must not double destroy elements"),delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},l=0,c={uint8:ee,uint16:ne};e.oes_element_index_uint&&(c.uint32=ae),i.prototype.bind=function(){this.buffer.bind()};var u=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)l(t),u.primType=$t,u.vertCount=0|t,u.type=ee;else{var e=null,r=le,n=-1,i=-1,o=0,h=0;Array.isArray(t)||lt(t)||k(t)?e=t:(Mt.type(t,"object","invalid arguments for elements"),"data"in t&&(e=t.data,Mt(Array.isArray(e)||lt(e)||k(e),"invalid data for element buffer")),"usage"in t&&(Mt.parameter(t.usage,Vt,"invalid element buffer usage"),r=Vt[t.usage]),"primitive"in t&&(Mt.parameter(t.primitive,Jt,"invalid element buffer primitive"),n=Jt[t.primitive]),"count"in t&&(Mt("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),i=0|t.count),"type"in t&&(Mt.parameter(t.type,c,"invalid buffer type"),h=c[t.type]),"length"in t?o=0|t.length:(o=i,h===ne||h===re?o*=2:h!==ae&&h!==ie||(o*=4))),a(u,e,r,n,i,o,h)}else l(),u.primType=$t,u.vertCount=0,u.type=ee;return s}var l=r.create(null,oe,!0),u=new i(l._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=u,s.subdata=function(t,e){return l.subdata(t,e),s},s.destroy=function(){o(u)},s},createStream:function(t){var e=u.pop();return e||(e=new i(r.create(null,oe,!0,!1)._buffer)),a(e,t,se,-1,-1,0,0),e},destroyStream:function(t){u.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof i?t._elements:null},clear:function(){Ct(s).forEach(o)}}}(p,x,L,b),z=function(t,e,r,n,i){for(var a=r.maxAttributes,o=new Array(a),s=0;s=Fr&&e=2,"invalid shape for framebuffer"),c=P[0],d=P[1]}else"radius"in I&&(c=d=I.radius),"width"in I&&(c=I.width),"height"in I&&(d=I.height);("color"in I||"colors"in I)&&(y=I.color||I.colors,Array.isArray(y)&&Mt(1===y.length||s,"multiple render targets not supported")),y||("colorCount"in I&&(A=0|I.colorCount,Mt(A>0,"invalid color buffer count")),"colorTexture"in I&&(M=!!I.colorTexture,k="rgba4"),"colorType"in I&&(T=I.colorType,M?(Mt(e.oes_texture_float||!("float"===T||"float32"===T),"you must enable OES_texture_float in order to use floating point framebuffer objects"),Mt(e.oes_texture_half_float||!("half float"===T||"float16"===T),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===T||"float16"===T?(Mt(e.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),k="rgba16f"):"float"!==T&&"float32"!==T||(Mt(e.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),k="rgba32f"),Mt.oneOf(T,w,"invalid color type")),"colorFormat"in I&&(k=I.colorFormat,x.indexOf(k)>=0?M=!0:_.indexOf(k)>=0?M=!1:M?Mt.oneOf(I.colorFormat,x,"invalid color format for texture"):Mt.oneOf(I.colorFormat,_,"invalid color format for renderbuffer"))),("depthTexture"in I||"depthStencilTexture"in I)&&(C=!(!I.depthTexture&&!I.depthStencilTexture),Mt(!C||e.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in I&&("boolean"==typeof I.depth?p=I.depth:(S=I.depth,g=!1)),"stencil"in I&&("boolean"==typeof I.stencil?g=I.stencil:(E=I.stencil,p=!1)),"depthStencil"in I&&("boolean"==typeof I.depthStencil?p=g=I.depthStencil:(L=I.depthStencil,p=!1,g=!1))}else c=d=1;var D=null,z=null,O=null,F=null;if(Array.isArray(y))D=y.map(u);else if(y)D=[u(y)];else for(D=new Array(A),a=0;a=0||D[a].renderbuffer&&Zr.indexOf(D[a].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+a+" is invalid"),D[a]&&D[a].texture){var j=qr[D[a].texture._texture.format]*Gr[D[a].texture._texture.type];null===R?R=j:Mt(R===j,"all color attachments much have the same number of bits per pixel.")}return l(z,c,d),Mt(!z||z.texture&&z.texture._texture.format===Vr||z.renderbuffer&&z.renderbuffer._renderbuffer.format===Yr,"invalid depth attachment for framebuffer object"),l(O,c,d),Mt(!O||O.renderbuffer&&O.renderbuffer._renderbuffer.format===Wr,"invalid stencil attachment for framebuffer object"),l(F,c,d),Mt(!F||F.texture&&F.texture._texture.format===Xr||F.renderbuffer&&F.renderbuffer._renderbuffer.format===Xr,"invalid depth-stencil attachment for framebuffer object"),m(o),o.width=c,o.height=d,o.colorAttachments=D,o.depthAttachment=z,o.stencilAttachment=O,o.depthStencilAttachment=F,i.color=D.map(f),i.depth=f(z),i.stencil=f(O),i.depthStencil=f(F),i.width=o.width,i.height=o.height,v(o),i}var o=new p;return a.framebufferCount++,i(t,n),ct(i,{resize:function(t,e){Mt(b.next!==o,"can not resize a framebuffer which is currently in use");var r=0|t,n=0|e||r;if(r===o.width&&n===o.height)return i;for(var a=o.colorAttachments,s=0;s=2,"invalid shape for framebuffer"),Mt(p[0]===p[1],"cube framebuffer must be square"),l=p[0]}else"radius"in d&&(l=0|d.radius),"width"in d?(l=0|d.width,"height"in d&&Mt(d.height===l,"must be square")):"height"in d&&(l=0|d.height);("color"in d||"colors"in d)&&(c=d.color||d.colors,Array.isArray(c)&&Mt(1===c.length||o,"multiple render targets not supported")),c||("colorCount"in d&&(f=0|d.colorCount,Mt(f>0,"invalid color buffer count")),"colorType"in d&&(Mt.oneOf(d.colorType,w,"invalid color type"),h=d.colorType),"colorFormat"in d&&(u=d.colorFormat,Mt.oneOf(d.colorFormat,x,"invalid color format for texture"))),"depth"in d&&(s.depth=d.depth),"stencil"in d&&(s.stencil=d.stencil),"depthStencil"in d&&(s.depthStencil=d.depthStencil)}else l=1;var m;if(c)if(Array.isArray(c))for(m=[],r=0;r0&&(s.depth=a[0].depth,s.stencil=a[0].stencil,s.depthStencil=a[0].depthStencil),a[r]?a[r](s):a[r]=y(s)}return ct(i,{width:l,height:l,color:m})}var a=Array(6);return i(t),ct(i,{faces:a,resize:function(t){var e,n=0|t;if(Mt(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===i.width)return i;var o=i.color;for(e=0;e=0},read:B,destroy:function(){H.length=0,n(),V&&(V.removeEventListener(ha,i),V.removeEventListener(fa,a)),O.clear(),j.clear(),R.clear(),F.clear(),C.clear(),L.clear(),_&&_.clear(),W.forEach(function(t){t()})},_gl:p,_refresh:h,poll:function(){u(),_&&_.update()},now:f,stats:b});return d.onDone(null,$),$}})},{}],509:[function(t,e,r){"use strict";var n,i="";e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("expected a string");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||void 0===n)n=t,i="";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i+=t,i=i.substr(0,r)}},{}],510:[function(t,e,r){!function(t,n){"object"==typeof r?e.exports=n():t.resolveUrl=n()}(this,function(){return function(){var t=arguments.length;if(0===t)throw new Error("resolveUrl requires at least one argument; got none.");var e=document.createElement("base");if(e.href=arguments[0],1===t)return e.href;var r=document.getElementsByTagName("head")[0];r.insertBefore(e,r.firstChild);for(var n,i=document.createElement("a"),a=1;a=0;--i){var a=r;(l=(s=t[i])-((r=a+s)-a))&&(t[--n]=r,r=l)}var o=0;for(i=n;i>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;r>1;return["sum(",i(t.slice(0,e)),",",i(t.slice(e)),")"].join("")}function a(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return a(e,t)}function o(t){return!0&t?"-":""}function s(t){if(2===t.length)return[["diff(",a(t[0][0],t[1][1]),",",a(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===n?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?i[t]:i)}var i=t("robust-determinant"),a=6,o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=3.3306690738754716e-16*n;return o>=s||o<=-s?o:d(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],h=e[2]-n[2],f=r[2]-n[2],d=a*c,m=o*l,g=o*s,v=i*c,y=i*l,b=a*s,x=u*(d-m)+h*(g-v)+f*(y-b),_=7.771561172376103e-16*((Math.abs(d)+Math.abs(m))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(h)+(Math.abs(y)+Math.abs(b))*Math.abs(f));return x>_||-x>_?x:p(t,e,r,n)}];!function(){for(;m.length<=f;)m.push(s(m.length));for(var t=[],r=["slow"],n=0;n<=f;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=f;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);return!(s>0&&l>0||s<0&&l<0)&&(0!==a||0!==o||0!==s||0!==l||function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],h=Math.min(c,u);if(Math.max(c,u)=n?(i=f,(c+=1)=n?(i=f,(c+=1)0){for(var s=0,l=0,c=0;cn.h||t>n.free||ru)&&(h=2*Math.max(t,u)),(ll)&&(c=2*Math.max(r,l)),this.resize(h,c),this.packOne(t,r)}return null},t.prototype.clear=function(){this.shelves=[],this.stats={}},t.prototype.resize=function(t,e){this.w=t,this.h=e;for(var r=0;rthis.free||e>this.h)return null;var r=this.x;return this.x+=t,this.free-=t,{x:r,y:this.y,w:t,h:e,width:t,height:e}},e.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0},t})},{}],524:[function(t,e,r){"use strict";e.exports=function(t){return t<0?-1:t>0?1:0}},{}],525:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":70,"reduce-simplicial-complex":507}],526:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){if(r=r||0,void 0===s&&(s=function(t){for(var e=t.length,r=0,n=0;n0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,a=new Array(t+1);a[0]=[[]];for(var o=1;o<=t;++o)for(var s=a[o]=i(o),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--o){o>1,s=n(t[o],e);s<=0?(0===s&&(a=o),r=o+1):s>0&&(i=o-1)}return a}function l(t,e){for(var r=new Array(t.length),i=0,a=r.length;i=t.length||0!==n(t[g],o)););}return r}function c(t,e){if(e<0)return[];for(var r=[],n=(1<>>u&1&&c.push(i[u]);e.push(c)}return a(e)},r.skeleton=c,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=l(t);if(!(r>=0&&e0){var t=T[0];return o(0,S-1),S-=1,c(0),t}return-1}function f(t,e){var r=T[t];return b[r]===e?t:(b[r]=-1/0,u(t),h(),b[r]=e,S+=1,u(S-1))}function d(t){if(!x[t]){x[t]=!0;var e=v[t],r=y[t];v[r]>=0&&(v[r]=e),y[e]>=0&&(y[e]=r),A[e]>=0&&f(A[e],a(e)),A[r]>=0&&f(A[r],a(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||i<0||i===n)break;if(n=i,i=t[n],!x[n]||i<0||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var m=e.length,g=t.length,v=new Array(m),y=new Array(m),b=new Array(m),x=new Array(m),_=0;_>1;_>=0;--_)c(_);for(;;){var E=h();if(E<0||b[E]>r)break;d(E)}var L=[];for(_=0;_=0&&r>=0&&e!==r){var n=A[e],i=A[r];n!==i&&C.push([n,i])}}),i.unique(i.normalize(C)),{positions:L,edges:C}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":517,"simplicial-complex":530}],533:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var a=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return ol?a-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],a=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=i(r,a,s),c=i(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=i(s,o,a),c=i(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var i=t("robust-orientation")},{"robust-orientation":517}],534:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=a(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=a(t.right,e))return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}e.exports=function(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;a0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var c=this.horizontal[e];if(c.length>0){var f=l.ge(c,t[1],i);if(f=c.length)return n;d=c[f]}}if(d.start)if(o){var p=u(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":533,"binary-search-bounds":67,"functional-red-black-tree":136,"robust-orientation":517}],535:[function(t,e,r){"use strict";function n(t,e){var r=o(a(t,e),[e[e.length-1]]);return r[r.length-1]}function i(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||o>0&&u<0){var h=i(s,u,l,o);r.push(h),a.push(h.slice())}u<0?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}},e.exports.positive=function(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;l0||a>0&&c<0)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r},e.exports.negative=function(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;l0||a>0&&c<0)&&r.push(i(o,c,s,a)),c<=0&&r.push(s.slice()),a=c}return r}},{"robust-dot-product":514,"robust-sum":522}],536:[function(t,e,r){!function(){"use strict";function t(e){return function(e,r){var i,a,o,s,l,c,u,h,f,d=1,p=e.length,m="";for(a=0;a=0),s[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s[6]?parseInt(s[6]):0);break;case"e":i=s[7]?parseFloat(i).toExponential(s[7]):parseFloat(i).toExponential();break;case"f":i=s[7]?parseFloat(i).toFixed(s[7]):parseFloat(i);break;case"g":i=s[7]?String(Number(i.toPrecision(s[7]))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s[7]?i.substring(0,s[7]):i;break;case"t":i=String(!!i),i=s[7]?i.substring(0,s[7]):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s[7]?i.substring(0,s[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s[7]?i.substring(0,s[7]):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}n.json.test(s[8])?m+=i:(!n.number.test(s[8])||h&&!s[3]?f="":(f=h?"+":"-",i=i.toString().replace(n.sign,"")),c=s[4]?"0"===s[4]?"0":s[4].charAt(1):" ",u=s[6]-(f+i).length,l=s[6]&&u>0?c.repeat(u):"",m+=s[5]?f+i+l:"0"===c?f+l+i:l+f+i)}return m}(function(t){if(i[t])return i[t];var e,r=t,a=[],o=0;for(;r;){if(null!==(e=n.text.exec(r)))a.push(e[0]);else if(null!==(e=n.modulo.exec(r)))a.push("%");else{if(null===(e=n.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){o|=1;var s=[],l=e[2],c=[];if(null===(c=n.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(c[1]);""!==(l=l.substring(c[0].length));)if(null!==(c=n.key_access.exec(l)))s.push(c[1]);else{if(null===(c=n.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(c[1])}e[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push(e)}r=r.substring(e[0].length)}return i[t]=a}(e),arguments)}function e(e,r){return t.apply(null,[e].concat(r||[]))}var n={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/},i=Object.create(null);void 0!==r&&(r.sprintf=t,r.vsprintf=e),"undefined"!=typeof window&&(window.sprintf=t,window.vsprintf=e)}()},{}],537:[function(t,e,r){"use strict";e.exports=function(t){function e(e){var r=[e],c=[e];for(n[e]=i[e]=u,a[e]=!0,u+=1;c.length>0;){e=c[c.length-1];var d=t[e];if(o[e]=0&&l[e].push(s[m])}o[e]=p}else{if(i[e]===n[e]){var g=[],v=[],y=0;for(p=r.length-1;p>=0;--p){var b=r[p];if(a[b]=!1,g.push(b),v.push(l[b]),y+=l[b].length,s[b]=h.length,b===e){r.length=p;break}}h.push(g);var x=new Array(y);for(p=0;p=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return c(c({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:r})}function s(t){return t/360+.5}function l(t){var e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function c(t,e){for(var r in e)t[r]=e[r];return t}function u(t){return t.x}function h(t){return t.y}var f=t("kdbush");e.exports=function(t){return new n(t)},n.prototype={options:{minZoom:0,maxZoom:16,radius:40,extent:512,nodeSize:64,log:!1,reduce:null,initial:function(){return{}},map:function(t){return t}},load:function(t){var e=this.options.log;e&&console.time("total time");var r="prepare "+t.length+" points";e&&console.time(r),this.points=t;var n=t.map(i);e&&console.timeEnd(r);for(var a=this.options.maxZoom;a>=this.options.minZoom;a--){var o=+Date.now();this.trees[a+1]=f(n,u,h,this.options.nodeSize,Float32Array),n=this._cluster(n,a),e&&console.log("z%d: %d clusters in %dms",a,n.length,+Date.now()-o)}return this.trees[this.options.minZoom]=f(n,u,h,this.options.nodeSize,Float32Array),e&&console.timeEnd("total time"),this},getClusters:function(t,e){for(var r=this.trees[this._limitZoom(e)],n=r.range(s(t[0]),l(t[3]),s(t[2]),l(t[1])),i=[],o=0;o c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],c=0;c>>7){"),c=0;c<1<<(1<128&&c%128==0){h.length>0&&f.push("}}");var d="vExtra"+h.length;a.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),f=["function ",d,"(m,",l.join(),"){switch(m){"],h.push(f)}f.push("case ",127&c,":");for(var p=new Array(r),m=new Array(r),g=new Array(r),v=new Array(r),y=0,b=0;bb)&&!(c&1<<_)!=!(c&1<0&&(T="+"+g[x]+"*c");var A=p[x].length/y*.5,S=.5+v[x]/y*.5;k.push("d"+x+"-"+S+"-"+A+"*("+p[x].join("+")+T+")/("+m[x].join("+")+")")}f.push("a.push([",k.join(),"]);","break;")}a.push("}},"),h.length>0&&f.push("}}");var E=[];for(c=0;c<1<0&&(h+=.02);var d=new Float32Array(u),p=0,m=-.5*h;for(f=0;f=0?1.2:1))}function i(t,e,r,n,i,o,s){for(var l=0;l1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}var i,a,o;t=_(t,360),e=_(e,100),r=_(r,100);if(0===e)i=a=o=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}(e.h,i,o),s=!0,l="hsl"),e.hasOwnProperty("a")&&(n=e.a));return n=x(n),{ok:s,format:e.format||l,r:D(255,z(r.r,0)),g:D(255,z(r.g,0)),b:D(255,z(r.b,0)),a:n}}(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=P(100*this._a)/100,this._format=n.format||i.format,this._gradientType=n.gradientType,this._r<1&&(this._r=P(this._r)),this._g<1&&(this._g=P(this._g)),this._b<1&&(this._b=P(this._b)),this._ok=i.ok,this._tc_id=I++}function n(t,e,r){t=_(t,255),e=_(e,255),r=_(r,255);var n,i,a=z(t,e,r),o=D(t,e,r),s=(a+o)/2;if(a==o)n=i=0;else{var l=a-o;switch(i=s>.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(e>1)+720)%360;--e;)i.h=(i.h+a)%360,o.push(r(i));return o}function b(t,e){e=e||6;for(var n=r(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/e;e--;)s.push(r({h:i,s:a,v:o})),o=(o+l)%1;return s}function x(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function _(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=D(r,z(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function w(t){return D(1,z(0,t))}function M(t){return parseInt(t,16)}function k(t){return 1==t.length?"0"+t:""+t}function T(t){return t<=1&&(t=100*t+"%"),t}function A(e){return t.round(255*parseFloat(e)).toString(16)}function S(t){return M(t)/255}function E(t){return!!j.CSS_UNIT.exec(t)}var L=/^\s+/,C=/\s+$/,I=0,P=t.round,D=t.min,z=t.max,O=t.random;r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i,a,o,s=this.toRgb();return e=s.r/255,r=s.g/255,n=s.b/255,i=e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4),a=r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4),o=n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4),.2126*i+.7152*a+.0722*o},setAlpha:function(t){return this._a=x(t),this._roundA=P(100*this._a)/100,this},toHsv:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=i(this._r,this._g,this._b),e=P(360*t.h),r=P(100*t.s),n=P(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=n(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=n(this._r,this._g,this._b),e=P(360*t.h),r=P(100*t.s),i=P(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+i+"%)":"hsla("+e+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return a(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var a=[k(P(t).toString(16)),k(P(e).toString(16)),k(P(r).toString(16)),k(A(n))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:P(this._r),g:P(this._g),b:P(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+P(this._r)+", "+P(this._g)+", "+P(this._b)+")":"rgba("+P(this._r)+", "+P(this._g)+", "+P(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:P(100*_(this._r,255))+"%",g:P(100*_(this._g,255))+"%",b:P(100*_(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+P(100*_(this._r,255))+"%, "+P(100*_(this._g,255))+"%, "+P(100*_(this._b,255))+"%)":"rgba("+P(100*_(this._r,255))+"%, "+P(100*_(this._g,255))+"%, "+P(100*_(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(R[a(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+o(this._r,this._g,this._b,this._a),n=e,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=r(t);n="#"+o(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return r(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(u,arguments)},brighten:function(){return this._applyModification(h,arguments)},darken:function(){return this._applyModification(f,arguments)},desaturate:function(){return this._applyModification(s,arguments)},saturate:function(){return this._applyModification(l,arguments)},greyscale:function(){return this._applyModification(c,arguments)},spin:function(){return this._applyModification(d,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(y,arguments)},complement:function(){return this._applyCombination(p,arguments)},monochromatic:function(){return this._applyCombination(b,arguments)},splitcomplement:function(){return this._applyCombination(v,arguments)},triad:function(){return this._applyCombination(m,arguments)},tetrad:function(){return this._applyCombination(g,arguments)}},r.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]="a"===i?t[i]:T(t[i]));t=n}return r(t,e)},r.equals=function(t,e){return!(!t||!e)&&r(t).toRgbString()==r(e).toRgbString()},r.random=function(){return r.fromRatio({r:O(),g:O(),b:O()})},r.mix=function(t,e,n){n=0===n?0:n||50;var i=r(t).toRgb(),a=r(e).toRgb(),o=n/100;return r({r:(a.r-i.r)*o+i.r,g:(a.g-i.g)*o+i.g,b:(a.b-i.b)*o+i.b,a:(a.a-i.a)*o+i.a})},r.readability=function(e,n){var i=r(e),a=r(n);return(t.max(i.getLuminance(),a.getLuminance())+.05)/(t.min(i.getLuminance(),a.getLuminance())+.05)},r.isReadable=function(t,e,n){var i,a,o=r.readability(t,e);switch(a=!1,(i=function(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}(n)).level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},r.mostReadable=function(t,e,n){var i,a,o,s,l=null,c=0;a=(n=n||{}).includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=r(e[u]));return r.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,r.mostReadable(t,["#fff","#000"],n))};var F=r.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},R=r.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(F),j=function(){var t="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",e="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+e),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+e),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+e),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();void 0!==e&&e.exports?e.exports=r:window.tinycolor=r}(Math)},{}],544:[function(t,e,r){"use strict";function n(t,e){var r=a(getComputedStyle(t).getPropertyValue(e));return r[0]*i(r[1],t)}function i(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return function(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var i=n(r,"font-size")/128;return e.removeChild(r),i}(t,e);case"em":return n(e,"font-size");case"rem":return n(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return o;case"cm":return o/2.54;case"mm":return o/25.4;case"pt":return o/72;case"pc":return o/6}return 1}var a=t("parse-unit");e.exports=i;var o=96},{"parse-unit":476}],545:[function(t,e,r){!function(t,n){n("object"==typeof r&&void 0!==e?r:t.topojson=t.topojson||{})}(this,function(t){"use strict";function e(t,e){var n=e.id,i=e.bbox,a=null==e.properties?{}:e.properties,o=r(t,e);return null==n&&null==i?{type:"Feature",properties:a,geometry:o}:null==i?{type:"Feature",id:n,properties:a,geometry:o}:{type:"Feature",id:n,bbox:i,properties:a,geometry:o}}function r(t,e){function r(t,e){e.length&&e.pop();for(var r=h[t<0?~t:t],n=0,i=r.length;n1)n=function(t,e,r){function n(t){var e=t<0?~t:t;(c[e]||(c[e]=[])).push({i:t,g:s})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){switch(s=t,t.type){case"GeometryCollection":t.geometries.forEach(o);break;case"LineString":i(t.arcs);break;case"MultiLineString":case"Polygon":a(t.arcs);break;case"MultiPolygon":!function(t){t.forEach(a)}(t.arcs)}}var s,l=[],c=[];return o(e),c.forEach(null==r?function(t){l.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&l.push(t[0].i)}),l}(0,e,r);else for(i=0,n=new Array(a=t.arcs.length);i1)for(var i,s,l=1,u=a(n[0]);lu&&(s=n[0],n[0]=n[l],n[l]=s,u=i);return n})}}var a=function(t){return t},o=function(t){if(null==(e=t.transform))return a;var e,r,n,i=e.scale[0],o=e.scale[1],s=e.translate[0],l=e.translate[1];return function(t,e){return e||(r=n=0),t[0]=(r+=t[0])*i+s,t[1]=(n+=t[1])*o+l,t}},s=function(t){function e(t){l[0]=t[0],l[1]=t[1],s(l),l[0]h&&(h=l[0]),l[1]f&&(f=l[1])}function r(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(r);break;case"Point":e(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(e)}}var n=t.bbox;if(!n){var i,a,s=o(t),l=new Array(2),c=1/0,u=c,h=-c,f=-c;t.arcs.forEach(function(t){for(var e=-1,r=t.length;++eh&&(h=l[0]),l[1]f&&(f=l[1])});for(a in t.objects)r(t.objects[a]);n=t.bbox=[c,u,h,f]}return n},l=function(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r},c=function(t,e){function r(t,e){for(var r in t){var i=t[r];delete e[i.start],delete i.start,delete i.end,i.forEach(function(t){n[t<0?~t:t]=1}),o.push(i)}}var n={},i={},a={},o=[],s=-1;return e.forEach(function(r,n){var i,a=t.arcs[r<0?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++s],e[s]=r,e[n]=i)}),e.forEach(function(e){var r,n,o=function(e){var r,n=t.arcs[e<0?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],e<0?[r,i]:[i,r]}(e),s=o[0],l=o[1];if(r=a[s])if(delete a[r.end],r.push(e),r.end=l,n=i[l]){delete i[n.start];var c=n===r?r:r.concat(n);i[c.start=r.start]=a[c.end=n.end]=c}else i[r.start]=a[r.end]=r;else if(r=i[l])if(delete i[r.start],r.unshift(e),r.start=s,n=a[s]){delete a[n.end];var u=n===r?r:n.concat(r);i[u.start=n.start]=a[u.end=r.end]=u}else i[r.start]=a[r.end]=r;else i[(r=[e]).start=s]=a[r.end=l]=r}),r(a,i),r(i,a),e.forEach(function(t){n[t<0?~t:t]||o.push([t])}),o},u=function(t,e){for(var r=0,n=t.length;r>>1;t[i]=2))throw new Error("n must be \u22652");if(t.transform)throw new Error("already quantized");var i,a=s(t),o=a[0],l=(a[2]-o)/(e-1)||1,c=a[1],u=(a[3]-c)/(e-1)||1;t.arcs.forEach(function(t){for(var e,r,n,i=1,a=1,s=t.length,h=t[0],f=h[0]=Math.round((h[0]-o)/l),d=h[1]=Math.round((h[1]-c)/u);iMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;s<3;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(s=0;s<3;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,l){this.center=s(r),this.up=s(n),this.right=s(i),this.radius=s([a]),this.angle=s([o,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var d=t.eye,p=[d[0]-e[0],d[1]-e[1],d[2]-e[2]];u(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var m=f(r,p)/s,g=f(i,p)/s;c=Math.acos(m),l=Math.acos(g)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)};var s=t("filtered-vector"),l=t("gl-mat4/invert"),c=t("gl-mat4/rotate"),u=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),f=t("gl-vec3/dot"),d=o.prototype;d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;o<3;++o)a+=e[o]*r[o],i+=e[o]*e[o];var s=Math.sqrt(i),l=0;for(o=0;o<3;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;var c=Math.sqrt(l);for(o=0;o<3;++o)r[o]/=c;var f=this.computedToward;u(f,e,r),h(f,f);var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],m=this.computedAngle[1],g=Math.cos(p),v=Math.sin(p),y=Math.cos(m),b=Math.sin(m),x=this.computedCenter,_=g*y,w=v*y,M=b,k=-g*b,T=-v*b,A=y,S=this.computedEye,E=this.computedMatrix;for(o=0;o<3;++o){var L=_*r[o]+w*f[o]+M*e[o];E[4*o+1]=k*r[o]+T*f[o]+A*e[o],E[4*o+2]=L,E[4*o+3]=0}var C=E[1],I=E[5],P=E[9],D=E[2],z=E[6],O=E[10],F=I*O-P*z,R=P*D-C*O,j=C*z-I*D,N=n(F,R,j);F/=N,R/=N,j/=N,E[0]=F,E[4]=R,E[8]=j;for(o=0;o<3;++o)S[o]=x[o]+E[2+4*o]*d;for(o=0;o<3;++o){l=0;for(var B=0;B<3;++B)l+=E[o+4*B]*S[B];E[12+o]=-l}E[15]=1},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var p=[0,0,0];d.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;p[0]=i[2],p[1]=i[6],p[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;l<3;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];c(i,i,n,p);for(l=0;l<3;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],h=a[4],f=a[8],d=u*o+h*s+f*l,p=n(u-=o*d,h-=s*d,f-=l*d),m=(u/=p)*e+o*r,g=(h/=p)*e+s*r,v=(f/=p)*e+l*r;this.center.move(t,m,g,v);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(o<0||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var c=e[o],u=e[o+4],h=e[o+8];if(a){var f=Math.abs(c),d=Math.abs(u),p=Math.abs(h),m=Math.max(f,d,p);f===m?(c=c<0?-1:1,u=h=0):p===m?(h=h<0?-1:1,c=u=0):(u=u<0?-1:1,c=h=0)}else{var g=n(c,u,h);c/=g,u/=g,h/=g}var v=e[s],y=e[s+4],b=e[s+8],x=v*c+y*u+b*h,_=n(v-=c*x,y-=u*x,b-=h*x),w=u*(b/=_)-h*(y/=_),M=h*(v/=_)-c*b,k=c*y-u*v,T=n(w,M,k);w/=T,M/=T,k/=T,this.center.jump(t,q,G,Y),this.radius.idle(t),this.up.jump(t,c,u,h),this.right.jump(t,v,y,b);var A,S;if(2===o){var E=e[1],L=e[5],C=e[9],I=E*v+L*y+C*b,P=E*w+L*M+C*k;A=F<0?-Math.PI/2:Math.PI/2,S=Math.atan2(P,I)}else{var D=e[2],z=e[6],O=e[10],F=D*c+z*u+O*h,R=D*v+z*y+O*b,j=D*w+z*M+O*k;A=Math.asin(i(F)),S=Math.atan2(j,R)}this.angle.jump(t,S,A),this.recalcMatrix(t);var N=e[2],B=e[6],U=e[10],V=this.computedMatrix;l(V,e);var H=V[15],q=V[12]/H,G=V[13]/H,Y=V[14]/H,W=Math.exp(this.computedRadius[0]);this.center.jump(t,q-N*W,G-B*W,Y-U*W)},d.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},d.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},d.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var o=(a=a||this.computedUp)[0],s=a[1],l=a[2],c=n(o,s,l);if(!(c<1e-6)){o/=c,s/=c,l/=c;var u=e[0]-r[0],h=e[1]-r[1],f=e[2]-r[2],d=n(u,h,f);if(!(d<1e-6)){u/=d,h/=d,f/=d;var p=this.computedRight,m=p[0],g=p[1],v=p[2],y=o*m+s*g+l*v,b=n(m-=y*o,g-=y*s,v-=y*l);if(!(b<.01&&(m=s*f-l*h,g=l*u-o*f,v=o*h-s*u,(b=n(m,g,v))<1e-6))){m/=b,g/=b,v/=b,this.up.set(t,o,s,l),this.right.set(t,m,g,v),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*v-l*g,_=l*m-o*v,w=o*g-s*m,M=n(x,_,w),k=o*u+s*h+l*f,T=m*u+g*h+v*f,A=(x/=M)*u+(_/=M)*h+(w/=M)*f,S=Math.asin(i(k)),E=Math.atan2(A,T),L=this.angle._state,C=L[L.length-1],I=L[L.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-E),D=Math.abs(C-E),z=Math.abs(C-2*Math.PI-E);P0?r.pop():new ArrayBuffer(t)}function o(t){return new Uint8Array(a(t),0,t)}function s(t){return new Uint16Array(a(2*t),0,t)}function l(t){return new Uint32Array(a(4*t),0,t)}function c(t){return new Int8Array(a(t),0,t)}function u(t){return new Int16Array(a(2*t),0,t)}function h(t){return new Int32Array(a(4*t),0,t)}function f(t){return new Float32Array(a(4*t),0,t)}function d(t){return new Float64Array(a(8*t),0,t)}function p(t){return b?new Uint8ClampedArray(a(t),0,t):o(t)}function m(t){return new DataView(a(t),0,t)}function g(t){t=v.nextPow2(t);var e=v.log2(t),r=w[e];return r.length>0?r.pop():new n(t)}var v=t("bit-twiddle"),y=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:y([32,0]),UINT16:y([32,0]),UINT32:y([32,0]),INT8:y([32,0]),INT16:y([32,0]),INT32:y([32,0]),FLOAT:y([32,0]),DOUBLE:y([32,0]),DATA:y([32,0]),UINT8C:y([32,0]),BUFFER:y([32,0])});var b="undefined"!=typeof Uint8ClampedArray,x=e.__TYPEDARRAY_POOL;x.UINT8C||(x.UINT8C=y([32,0])),x.BUFFER||(x.BUFFER=y([32,0]));var _=x.DATA,w=x.BUFFER;r.free=function(t){if(n.isBuffer(t))w[v.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|v.log2(e);_[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=function(t){i(t.buffer)},r.freeArrayBuffer=i,r.freeBuffer=function(t){w[v.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return a(t);switch(e){case"uint8":return o(t);case"uint16":return s(t);case"uint32":return l(t);case"int8":return c(t);case"int16":return u(t);case"int32":return h(t);case"float":case"float32":return f(t);case"double":case"float64":return d(t);case"uint8_clamped":return p(t);case"buffer":return g(t);case"data":case"dataview":return m(t);default:return null}return null},r.mallocArrayBuffer=a,r.mallocUint8=o,r.mallocUint16=s,r.mallocUint32=l,r.mallocInt8=c,r.mallocInt16=u,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=f,r.mallocFloat64=r.mallocDouble=d,r.mallocUint8Clamped=p,r.mallocDataView=m,r.mallocBuffer=g,r.clearCache=function(){for(var t=0;t<32;++t)x.UINT8[t].length=0,x.UINT16[t].length=0,x.UINT32[t].length=0,x.INT8[t].length=0,x.INT16[t].length=0,x.INT32[t].length=0,x.FLOAT[t].length=0,x.DOUBLE[t].length=0,x.UINT8C[t].length=0,_[t].length=0,w[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":68,buffer:78,dup:126}],551:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;en)return n;for(;ra?r=i:n=i,i=.5*(n-r)+r}return i},n.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},{}],554:[function(t,e,r){"use strict";function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&o.isObject(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}var a=t("punycode"),o=t("./util");r.parse=i,r.resolve=function(t,e){return i(t,!1,!0).resolve(e)},r.resolveObject=function(t,e){return t?i(t,!1,!0).resolveObject(e):e},r.format=function(t){return o.isString(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)},r.Url=n;var s=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(u),f=["%","/","?",";","#"].concat(h),d=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=t("querystring");n.prototype.parse=function(t,e,r){if(!o.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),i=-1!==n&&n127?D+="x":D+=P[z];if(!D.match(p)){var F=C.slice(0,T),R=C.slice(T+1),j=P.match(m);j&&(F.push(j[1]),R.unshift(j[2])),R.length&&(u="/"+R.join(".")+u),this.hostname=F.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),L||(this.hostname=a.toASCII(this.hostname));var N=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+N,this.href+=this.host,L&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==u[0]&&(u="/"+u))}if(!g[w])for(T=0,I=h.length;T0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())}return r.search=t.search,r.query=t.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!M.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=M.slice(-1)[0],A=(r.host||t.host||M.length>1)&&("."===T||".."===T)||""===T,S=0,E=M.length;E>=0;E--)"."===(T=M[E])?M.splice(E,1):".."===T?(M.splice(E,1),S++):S&&(M.splice(E,1),S--);if(!_&&!w)for(;S--;S)M.unshift("..");!_||""===M[0]||M[0]&&"/"===M[0].charAt(0)||M.unshift(""),A&&"/"!==M.join("/").substr(-1)&&M.push("");var L=""===M[0]||M[0]&&"/"===M[0].charAt(0);if(k){r.hostname=r.host=L?"":M.length?M.shift():"";var C;(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())}return(_=_||r.host&&M.length)&&!L&&M.unshift(""),M.length?r.pathname=M.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=l.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":555,punycode:497,querystring:501}],555:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],556:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],557:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],558:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(e)?n.showHidden=e:e&&r._extend(n,e),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),s(n,t,n.depth)}function a(t,e){var r=i.styles[e];return r?"\x1b["+i.colors[r][0]+"m"+t+"\x1b["+i.colors[r][1]+"m":t}function o(t,e){return t}function s(t,e,n){if(t.customInspect&&e&&x(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return p(i)||(i=s(t,i,n)),i}var a=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(p(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(d(e))return t.stylize(""+e,"number");if(h(e))return t.stylize(""+e,"boolean");if(f(e))return t.stylize("null","null")}(t,e);if(a)return a;var o=Object.keys(e),v=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),b(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return l(e);if(0===o.length){if(x(e)){var _=e.name?": "+e.name:"";return t.stylize("[Function"+_+"]","special")}if(g(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(y(e))return t.stylize(Date.prototype.toString.call(e),"date");if(b(e))return l(e)}var w="",k=!1,T=["{","}"];if(u(e)&&(k=!0,T=["[","]"]),x(e)){w=" [Function"+(e.name?": "+e.name:"")+"]"}if(g(e)&&(w=" "+RegExp.prototype.toString.call(e)),y(e)&&(w=" "+Date.prototype.toUTCString.call(e)),b(e)&&(w=" "+l(e)),0===o.length&&(!k||0==e.length))return T[0]+w+T[1];if(n<0)return g(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var A;return A=k?function(t,e,r,n,i){for(var a=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(A,w,T)}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function c(t,e,r,n,i,a){var o,l,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?l=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(l=t.stylize("[Setter]","special")),M(n,i)||(o="["+i+"]"),l||(t.seen.indexOf(c.value)<0?(l=f(r)?s(t,c.value,null):s(t,c.value,r-1)).indexOf("\n")>-1&&(l=a?l.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+l.split("\n").map(function(t){return" "+t}).join("\n")):l=t.stylize("[Circular]","special")),m(o)){if(a&&i.match(/^\d+$/))return l;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+l}function u(t){return Array.isArray(t)}function h(t){return"boolean"==typeof t}function f(t){return null===t}function d(t){return"number"==typeof t}function p(t){return"string"==typeof t}function m(t){return void 0===t}function g(t){return v(t)&&"[object RegExp]"===_(t)}function v(t){return"object"==typeof t&&null!==t}function y(t){return v(t)&&"[object Date]"===_(t)}function b(t){return v(t)&&("[object Error]"===_(t)||t instanceof Error)}function x(t){return"function"==typeof t}function _(t){return Object.prototype.toString.call(t)}function w(t){return t<10?"0"+t.toString(10):t.toString(10)}function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var k=/%[sdj%]/g;r.format=function(t){if(!p(t)){for(var e=[],r=0;r=a)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),s=n[r];r>3}if(i--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&l.push(e),e=[]),e.push(new a(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&l.push(e),l},n.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)i+=t.readSVarint(),a+=t.readSVarint(),is&&(s=i),ac&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,c]},n.prototype.toGeoJSON=function(t,e,r){function i(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}var a=t("./vectortilefeature.js");e.exports=n,n.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new a(this._pbf,e,this.extent,this._keys,this._values)}},{"./vectortilefeature.js":561}],563:[function(t,e,r){"use strict";e.exports=function(t,e){return"object"==typeof e&&null!==e||(e={}),n(t,e.canvas||i,e.context||a,e)};var n=t("./lib/vtext"),i=null,a=null;"undefined"!=typeof document&&((i=document.createElement("canvas")).width=8192,i.height=1024,a=i.getContext("2d"))},{"./lib/vtext":564}],564:[function(t,e,r){"use strict";function n(t,e,r,n){var i=function(t,e){var r=a(t,128);return e?s(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}(t,n),o=function(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height>31}var o=t("pbf"),s=t("./vector-tile-pb"),l=t("./lib/geojson_wrapper");e.exports=n,e.exports.fromVectorTileJs=n,e.exports.fromGeojsonVt=function(t){var e={};for(var r in t)e[r]=new l(t[r].features),e[r].name=r;return n({layers:e})},e.exports.GeoJSONWrapper=l},{"./lib/geojson_wrapper":566,"./vector-tile-pb":567,pbf:479}],566:[function(t,e,r){"use strict";function n(t){this.features=t,this.length=t.length}function i(t){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=4096}var a=t("point-geometry"),o=t("vector-tile").VectorTileFeature;e.exports=n,n.prototype.feature=function(t){return new i(this.features[t])},i.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e=0?e[o]:a})},has___:{value:i(function(e){var i=n(e);return i?r in i:t.indexOf(e)>=0})},set___:{value:i(function(i,a){var o,s=n(i);return s?s[r]=a:(o=t.indexOf(i))>=0?e[o]=a:(o=t.length,e[o]=a,t[o]=i),this})},delete___:{value:i(function(i){var a,o,s=n(i);return s?r in s&&delete s[r]:!((a=t.indexOf(i))<0||(o=t.length-1,t[a]=void 0,e[a]=e[o],t[a]=t[o],t.length=o,e.length=o,0))})}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?function(){function r(){this instanceof x||a();var e,r=new s,n=void 0,l=!1;return e=o?function(t,e){return r.set(t,e),r.has(t)||(n||(n=new x),n.set(t,e)),this}:function(t,e){if(l)try{r.set(t,e)}catch(r){n||(n=new x),n.set___(t,e)}else r.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(function(t,e){return n?r.has(t)?r.get(t):n.get___(t,e):r.get(t,e)})},has___:{value:i(function(t){return r.has(t)||!!n&&n.has___(t)})},set___:{value:i(e)},delete___:{value:i(function(t){var e=!!r.delete(t);return n?n.delete___(t)||e:e})},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");l=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],569:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":570}],570:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],571:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":569}],572:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":148}],573:[function(t,e,r){var n=arguments[3],i=arguments[4],a=arguments[5],o=JSON.stringify;e.exports=function(t,e){function r(t){g[t]=!0;for(var e in i[t][1]){var n=i[t][1][e];g[n]||r(n)}}for(var s,l=Object.keys(a),c=0,u=l.length;c2111)throw e.replace(/\{0\}/,this.local.name);return t},toMonthIndex:function(t,e,r){var n=this.intercalaryMonth(t);if(r&&e!==n||e<1||e>12)throw i.local.invalidMonth.replace(/\{0\}/,this.local.name);return n?!r&&e<=n?e-1:e:e-1},toChineseMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);if(e<0||e>(r?12:11))throw i.local.invalidMonth.replace(/\{0\}/,this.local.name);return r?e>13},isIntercalaryMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);return!!r&&r===e},leapYear:function(t){return 0!==this.intercalaryMonth(t)},weekOfYear:function(t,e,r){var n,a=this._validateYear(t,i.local.invalidyear),s=f[a-f[0]],l=s>>9&4095,c=s>>5&15,u=31&s;(n=o.newDate(l,c,u)).add(4-(n.dayOfWeek()||7),"d");var h=this.toJD(t,e,r)-n.toJD();return 1+Math.floor(h/7)},monthsInYear:function(t){return this.leapYear(t)?13:12},daysInMonth:function(t,e){t.year&&(e=t.month(),t=t.year()),t=this._validateYear(t);var r=h[t-h[0]];if(e>(r>>13?12:11))throw i.local.invalidMonth.replace(/\{0\}/,this.local.name);return r&1<<12-e?30:29},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,s,r,i.local.invalidDate);t=this._validateYear(n.year()),e=n.month(),r=n.day();var a=this.isIntercalaryMonth(t,e),s=this.toChineseMonth(t,e),l=function(t,e,r,n,i){var a,o;if("object"==typeof t)o=t,a=e||{};else{if(!("number"==typeof t&&t>=1888&&t<=2111))throw new Error("Lunar year outside range 1888-2111");if(!("number"==typeof e&&e>=1&&e<=12))throw new Error("Lunar month outside range 1 - 12");if(!("number"==typeof r&&r>=1&&r<=30))throw new Error("Lunar day outside range 1 - 30");var s;"object"==typeof n?(s=!1,a=n):(s=!!n,a=i||{}),o={year:t,month:e,day:r,isIntercalary:s}}var l;l=o.day-1;var c,u=h[o.year-h[0]],d=u>>13;c=d?o.month>d?o.month:o.isIntercalary?o.month:o.month-1:o.month-1;for(var p=0;p>9&4095,v=m>>5&15,y=31&m,b=new Date(g,v-1,y+l);return a.year=b.getFullYear(),a.month=1+b.getMonth(),a.day=b.getDate(),a}(t,s,r,a);return o.toJD(l.year,l.month,l.day)},fromJD:function(t){var e=o.fromJD(t),r=function(t,e,r,n){var i,a;if("object"==typeof t)i=t,a=e||{};else{if(!("number"==typeof t&&t>=1888&&t<=2111))throw new Error("Solar year outside range 1888-2111");if(!("number"==typeof e&&e>=1&&e<=12))throw new Error("Solar month outside range 1 - 12");if(!("number"==typeof r&&r>=1&&r<=31))throw new Error("Solar day outside range 1 - 31");i={year:t,month:e,day:r},a=n||{}}var o=f[i.year-f[0]],s=i.year<<9|i.month<<5|i.day;a.year=s>=o?i.year:i.year-1;var l,c=(o=f[a.year-f[0]])>>9&4095,u=o>>5&15,d=31&o,p=new Date(c,u-1,d),m=new Date(i.year,i.month-1,i.day);l=Math.round((m-p)/864e5);var g,v=h[a.year-h[0]];for(g=0;g<13;g++){var y=v&1<<12-g?30:29;if(l>13;return!b||g=2&&n<=6},extraInfo:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);return{century:a[Math.floor((n.year()-1)/100)+1]||""}},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);return t=n.year()+(n.year()<0?1:0),e=n.month(),(r=n.day())+(e>1?16:0)+(e>2?32*(e-2):0)+400*(t-1)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t+.5)-Math.floor(this.jdEpoch)-1;var e=Math.floor(t/400)+1;t-=400*(e-1),t+=t>15?16:0;var r=Math.floor(t/32)+1,n=t-32*(r-1)+1;return this.newDate(e<=0?e-1:e,r,n)}});var a={20:"Fruitbat",21:"Anchovy"};i.calendars.discworld=n},{"../main":590,"object-assign":471}],579:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main");t("object-assign")(n.prototype=new i.baseCalendar,{name:"Ethiopian",jdEpoch:1724220.5,daysPerMonth:[30,30,30,30,30,30,30,30,30,30,30,30,5],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Ethiopian",epochs:["BEE","EE"],monthNames:["Meskerem","Tikemet","Hidar","Tahesas","Tir","Yekatit","Megabit","Miazia","Genbot","Sene","Hamle","Nehase","Pagume"],monthNamesShort:["Mes","Tik","Hid","Tah","Tir","Yek","Meg","Mia","Gen","Sen","Ham","Neh","Pag"],dayNames:["Ehud","Segno","Maksegno","Irob","Hamus","Arb","Kidame"],dayNamesShort:["Ehu","Seg","Mak","Iro","Ham","Arb","Kid"],dayNamesMin:["Eh","Se","Ma","Ir","Ha","Ar","Ki"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);return(t=e.year()+(e.year()<0?1:0))%4==3||t%4==-1},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,i.local.invalidYear||i.regionalOptions[""].invalidYear),13},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(13===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);return(t=n.year())<0&&t++,n.day()+30*(n.month()-1)+365*(t-1)+Math.floor(t/4)+this.jdEpoch-1},fromJD:function(t){var e=Math.floor(t)+.5-this.jdEpoch,r=Math.floor((e-Math.floor((e+366)/1461))/365)+1;r<=0&&r--,e=Math.floor(t)+.5-this.newDate(r,1,1).toJD();var n=Math.floor(e/30)+1,i=e-30*(n-1)+1;return this.newDate(r,n,i)}}),i.calendars.ethiopian=n},{"../main":590,"object-assign":471}],580:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function i(t,e){return t-e*Math.floor(t/e)}var a=t("../main");t("object-assign")(n.prototype=new a.baseCalendar,{name:"Hebrew",jdEpoch:347995.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29,29],hasYearZero:!1,minMonth:1,firstMonth:7,minDay:1,regionalOptions:{"":{name:"Hebrew",epochs:["BAM","AM"],monthNames:["Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Shevat","Adar","Adar II"],monthNamesShort:["Nis","Iya","Siv","Tam","Av","Elu","Tis","Che","Kis","Tev","She","Ada","Ad2"],dayNames:["Yom Rishon","Yom Sheni","Yom Shlishi","Yom Revi'i","Yom Chamishi","Yom Shishi","Yom Shabbat"],dayNamesShort:["Ris","She","Shl","Rev","Cha","Shi","Sha"],dayNamesMin:["Ri","She","Shl","Re","Ch","Shi","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,a.local.invalidYear);return this._leapYear(e.year())},_leapYear:function(t){return t=t<0?t+1:t,i(7*t+1,19)<7},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,a.local.invalidYear),this._leapYear(t.year?t.year():t)?13:12},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return t=this._validate(t,this.minMonth,this.minDay,a.local.invalidYear).year(),this.toJD(-1===t?1:t+1,7,1)-this.toJD(t,7,1)},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,a.local.invalidMonth),12===e&&this.leapYear(t)?30:8===e&&5===i(this.daysInYear(t),10)?30:9===e&&3===i(this.daysInYear(t),10)?29:this.daysPerMonth[e-1]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},extraInfo:function(t,e,r){var n=this._validate(t,e,r,a.local.invalidDate);return{yearType:(this.leapYear(n)?"embolismic":"common")+" "+["deficient","regular","complete"][this.daysInYear(n)%10-3]}},toJD:function(t,e,r){var n=this._validate(t,e,r,a.local.invalidDate);t=n.year(),e=n.month(),r=n.day();var i=t<=0?t+1:t,o=this.jdEpoch+this._delay1(i)+this._delay2(i)+r+1;if(e<7){for(var s=7;s<=this.monthsInYear(t);s++)o+=this.daysInMonth(t,s);for(s=1;s=this.toJD(-1===e?1:e+1,7,1);)e++;for(var r=tthis.toJD(e,r,this.daysInMonth(e,r));)r++;var n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),a.calendars.hebrew=n},{"../main":590,"object-assign":471}],581:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main");t("object-assign")(n.prototype=new i.baseCalendar,{name:"Islamic",jdEpoch:1948439.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Islamic",epochs:["BH","AH"],monthNames:["Muharram","Safar","Rabi' al-awwal","Rabi' al-thani","Jumada al-awwal","Jumada al-thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-ahad","Yawm al-ithnayn","Yawm ath-thulaathaa'","Yawm al-arbi'aa'","Yawm al-kham\u012bs","Yawm al-jum'a","Yawm as-sabt"],dayNamesShort:["Aha","Ith","Thu","Arb","Kha","Jum","Sab"],dayNamesMin:["Ah","It","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!1}},leapYear:function(t){return(11*this._validate(t,this.minMonth,this.minDay,i.local.invalidYear).year()+14)%30<11},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return this.leapYear(t)?355:354},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);return t=n.year(),e=n.month(),r=n.day(),t=t<=0?t+1:t,r+Math.ceil(29.5*(e-1))+354*(t-1)+Math.floor((3+11*t)/30)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t)+.5;var e=Math.floor((30*(t-this.jdEpoch)+10646)/10631);e=e<=0?e-1:e;var r=Math.min(12,Math.ceil((t-29-this.toJD(e,1,1))/29.5)+1),n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),i.calendars.islamic=n},{"../main":590,"object-assign":471}],582:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main");t("object-assign")(n.prototype=new i.baseCalendar,{name:"Julian",jdEpoch:1721423.5,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Julian",epochs:["BC","AD"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"mm/dd/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);return(t=e.year()<0?e.year()+1:e.year())%4==0},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(4-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);return t=n.year(),e=n.month(),r=n.day(),t<0&&t++,e<=2&&(t--,e+=12),Math.floor(365.25*(t+4716))+Math.floor(30.6001*(e+1))+r-1524.5},fromJD:function(t){var e=Math.floor(t+.5)+1524,r=Math.floor((e-122.1)/365.25),n=Math.floor(365.25*r),i=Math.floor((e-n)/30.6001),a=i-Math.floor(i<14?1:13),o=r-Math.floor(a>2?4716:4715),s=e-n-Math.floor(30.6001*i);return o<=0&&o--,this.newDate(o,a,s)}}),i.calendars.julian=n},{"../main":590,"object-assign":471}],583:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function i(t,e){return t-e*Math.floor(t/e)}function a(t,e){return i(t-1,e)+1}var o=t("../main");t("object-assign")(n.prototype=new o.baseCalendar,{name:"Mayan",jdEpoch:584282.5,hasYearZero:!0,minMonth:0,firstMonth:0,minDay:0,regionalOptions:{"":{name:"Mayan",epochs:["",""],monthNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],monthNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],dayNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesMin:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],digits:null,dateFormat:"YYYY.m.d",firstDay:0,isRTL:!1,haabMonths:["Pop","Uo","Zip","Zotz","Tzec","Xul","Yaxkin","Mol","Chen","Yax","Zac","Ceh","Mac","Kankin","Muan","Pax","Kayab","Cumku","Uayeb"],tzolkinMonths:["Imix","Ik","Akbal","Kan","Chicchan","Cimi","Manik","Lamat","Muluc","Oc","Chuen","Eb","Ben","Ix","Men","Cib","Caban","Etznab","Cauac","Ahau"]}},leapYear:function(t){return this._validate(t,this.minMonth,this.minDay,o.local.invalidYear),!1},formatYear:function(t){t=this._validate(t,this.minMonth,this.minDay,o.local.invalidYear).year();var e=Math.floor(t/400);t%=400,t+=t<0?400:0;return e+"."+Math.floor(t/20)+"."+t%20},forYear:function(t){if((t=t.split(".")).length<3)throw"Invalid Mayan year";for(var e=0,r=0;r19||r>0&&n<0)throw"Invalid Mayan year";e=20*e+n}return e},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,o.local.invalidYear),18},weekOfYear:function(t,e,r){return this._validate(t,e,r,o.local.invalidDate),0},daysInYear:function(t){return this._validate(t,this.minMonth,this.minDay,o.local.invalidYear),360},daysInMonth:function(t,e){return this._validate(t,e,this.minDay,o.local.invalidMonth),20},daysInWeek:function(){return 5},dayOfWeek:function(t,e,r){return this._validate(t,e,r,o.local.invalidDate).day()},weekDay:function(t,e,r){return this._validate(t,e,r,o.local.invalidDate),!0},extraInfo:function(t,e,r){var n=this._validate(t,e,r,o.local.invalidDate).toJD(),i=this._toHaab(n),a=this._toTzolkin(n);return{haabMonthName:this.local.haabMonths[i[0]-1],haabMonth:i[0],haabDay:i[1],tzolkinDayName:this.local.tzolkinMonths[a[0]-1],tzolkinDay:a[0],tzolkinTrecena:a[1]}},_toHaab:function(t){var e=i((t-=this.jdEpoch)+8+340,365);return[Math.floor(e/20)+1,i(e,20)]},_toTzolkin:function(t){return t-=this.jdEpoch,[a(t+20,20),a(t+4,13)]},toJD:function(t,e,r){var n=this._validate(t,e,r,o.local.invalidDate);return n.day()+20*n.month()+360*n.year()+this.jdEpoch},fromJD:function(t){t=Math.floor(t)+.5-this.jdEpoch;var e=Math.floor(t/360);t%=360,t+=t<0?360:0;var r=Math.floor(t/20),n=t%20;return this.newDate(e,r,n)}}),o.calendars.mayan=n},{"../main":590,"object-assign":471}],584:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main"),a=t("object-assign");n.prototype=new i.baseCalendar;var o=i.instance("gregorian");a(n.prototype,{name:"Nanakshahi",jdEpoch:2257673.5,daysPerMonth:[31,31,31,31,31,30,30,30,30,30,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Nanakshahi",epochs:["BN","AN"],monthNames:["Chet","Vaisakh","Jeth","Harh","Sawan","Bhadon","Assu","Katak","Maghar","Poh","Magh","Phagun"],monthNamesShort:["Che","Vai","Jet","Har","Saw","Bha","Ass","Kat","Mgr","Poh","Mgh","Pha"],dayNames:["Somvaar","Mangalvar","Budhvaar","Veervaar","Shukarvaar","Sanicharvaar","Etvaar"],dayNamesShort:["Som","Mangal","Budh","Veer","Shukar","Sanichar","Et"],dayNamesMin:["So","Ma","Bu","Ve","Sh","Sa","Et"],digits:null,dateFormat:"dd-mm-yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear||i.regionalOptions[""].invalidYear);return o.leapYear(e.year()+(e.year()<1?1:0)+1469)},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(1-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidMonth);(t=n.year())<0&&t++;for(var a=n.day(),s=1;s=this.toJD(e+1,1,1);)e++;for(var r=t-Math.floor(this.toJD(e,1,1)+.5)+1,n=1;r>this.daysInMonth(e,n);)r-=this.daysInMonth(e,n),n++;return this.newDate(e,n,r)}}),i.calendars.nanakshahi=n},{"../main":590,"object-assign":471}],585:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main");t("object-assign")(n.prototype=new i.baseCalendar,{name:"Nepali",jdEpoch:1700709.5,daysPerMonth:[31,31,32,32,31,30,30,29,30,29,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,daysPerYear:365,regionalOptions:{"":{name:"Nepali",epochs:["BBS","ABS"],monthNames:["Baisakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Paush","Mangh","Falgun","Chaitra"],monthNamesShort:["Bai","Je","As","Shra","Bha","Ash","Kar","Mang","Pau","Ma","Fal","Chai"],dayNames:["Aaitabaar","Sombaar","Manglbaar","Budhabaar","Bihibaar","Shukrabaar","Shanibaar"],dayNamesShort:["Aaita","Som","Mangl","Budha","Bihi","Shukra","Shani"],dayNamesMin:["Aai","So","Man","Bu","Bi","Shu","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:1,isRTL:!1}},leapYear:function(t){return this.daysInYear(t)!==this.daysPerYear},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){if(t=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear).year(),void 0===this.NEPALI_CALENDAR_DATA[t])return this.daysPerYear;for(var e=0,r=this.minMonth;r<=12;r++)e+=this.NEPALI_CALENDAR_DATA[t][r];return e},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,i.local.invalidMonth),void 0===this.NEPALI_CALENDAR_DATA[t]?this.daysPerMonth[e-1]:this.NEPALI_CALENDAR_DATA[t][e]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);t=n.year(),e=n.month(),r=n.day();var a=i.instance(),o=0,s=e,l=t;this._createMissingCalendarData(t);var c=t-(s>9||9===s&&r>=this.NEPALI_CALENDAR_DATA[l][0]?56:57);for(9!==e&&(o=r,s--);9!==s;)s<=0&&(s=12,l--),o+=this.NEPALI_CALENDAR_DATA[l][s],s--;return 9===e?(o+=r-this.NEPALI_CALENDAR_DATA[l][0])<0&&(o+=a.daysInYear(c)):o+=this.NEPALI_CALENDAR_DATA[l][9]-this.NEPALI_CALENDAR_DATA[l][0],a.newDate(c,1,1).add(o,"d").toJD()},fromJD:function(t){var e=i.instance().fromJD(t),r=e.year(),n=e.dayOfYear(),a=r+56;this._createMissingCalendarData(a);for(var o=9,s=this.NEPALI_CALENDAR_DATA[a][0],l=this.NEPALI_CALENDAR_DATA[a][o]-s+1;n>l;)++o>12&&(o=1,a++),l+=this.NEPALI_CALENDAR_DATA[a][o];var c=this.NEPALI_CALENDAR_DATA[a][o]-(l-n);return this.newDate(a,o,c)},_createMissingCalendarData:function(t){var e=this.daysPerMonth.slice(0);e.unshift(17);for(var r=t-1;r0?474:473))%2820+474+38)%2816<682},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-(n.dayOfWeek()+1)%7,"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,a.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var n=this._validate(t,e,r,a.local.invalidDate);t=n.year(),e=n.month(),r=n.day();var o=t-(t>=0?474:473),s=474+i(o,2820);return r+(e<=7?31*(e-1):30*(e-1)+6)+Math.floor((682*s-110)/2816)+365*(s-1)+1029983*Math.floor(o/2820)+this.jdEpoch-1},fromJD:function(t){var e=(t=Math.floor(t)+.5)-this.toJD(475,1,1),r=Math.floor(e/1029983),n=i(e,1029983),a=2820;if(1029982!==n){var o=Math.floor(n/366),s=i(n,366);a=Math.floor((2134*o+2816*s+2815)/1028522)+o+1}var l=a+2820*r+474;l=l<=0?l-1:l;var c=t-this.toJD(l,1,1)+1,u=c<=186?Math.ceil(c/31):Math.ceil((c-6)/30),h=t-this.toJD(l,u,1)+1;return this.newDate(l,u,h)}}),a.calendars.persian=n,a.calendars.jalali=n},{"../main":590,"object-assign":471}],587:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main"),a=t("object-assign"),o=i.instance();a(n.prototype=new i.baseCalendar,{name:"Taiwan",jdEpoch:2419402.5,yearsOffset:1911,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Taiwan",epochs:["BROC","ROC"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);t=this._t2gYear(e.year());return o.leapYear(t)},weekOfYear:function(t,e,r){var n=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);t=this._t2gYear(n.year());return o.weekOfYear(t,n.month(),n.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);t=this._t2gYear(n.year());return o.toJD(t,n.month(),n.day())},fromJD:function(t){var e=o.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)},_g2tYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)}}),i.calendars.taiwan=n},{"../main":590,"object-assign":471}],588:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main"),a=t("object-assign"),o=i.instance();a(n.prototype=new i.baseCalendar,{name:"Thai",jdEpoch:1523098.5,yearsOffset:543,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Thai",epochs:["BBE","BE"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);t=this._t2gYear(e.year());return o.leapYear(t)},weekOfYear:function(t,e,r){var n=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);t=this._t2gYear(n.year());return o.weekOfYear(t,n.month(),n.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,i.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate);t=this._t2gYear(n.year());return o.toJD(t,n.month(),n.day())},fromJD:function(t){var e=o.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)},_g2tYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)}}),i.calendars.thai=n},{"../main":590,"object-assign":471}],589:[function(t,e,r){function n(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}var i=t("../main");t("object-assign")(n.prototype=new i.baseCalendar,{name:"UmmAlQura",hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Umm al-Qura",epochs:["BH","AH"],monthNames:["Al-Muharram","Safar","Rabi' al-awwal","Rabi' Al-Thani","Jumada Al-Awwal","Jumada Al-Thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-Ahad","Yawm al-Ithnain","Yawm al-Thal\u0101th\u0101\u2019","Yawm al-Arba\u2018\u0101\u2019","Yawm al-Kham\u012bs","Yawm al-Jum\u2018a","Yawm al-Sabt"],dayNamesMin:["Ah","Ith","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!0}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,i.local.invalidYear);return 355===this.daysInYear(e.year())},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){for(var e=0,r=1;r<=12;r++)e+=this.daysInMonth(t,r);return e},daysInMonth:function(t,e){for(var r=this._validate(t,e,this.minDay,i.local.invalidMonth).toJD()-24e5+.5,n=0,o=0;or)return a[n]-a[n-1];n++}return 30},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var n=this._validate(t,e,r,i.local.invalidDate),o=12*(n.year()-1)+n.month()-15292;return n.day()+a[o-1]-1+24e5-.5},fromJD:function(t){for(var e=t-24e5+.5,r=0,n=0;ne);n++)r++;var i=r+15292,o=Math.floor((i-1)/12),s=o+1,l=i-12*o,c=e-a[r-1]+1;return this.newDate(s,l,c)},isValid:function(t,e,r){var n=i.baseCalendar.prototype.isValid.apply(this,arguments);return n&&(n=(t=null!=t.year?t.year:t)>=1276&&t<=1500),n},_validate:function(t,e,r,n){var a=i.baseCalendar.prototype._validate.apply(this,arguments);if(a.year<1276||a.year>1500)throw n.replace(/\{0\}/,this.local.name);return a}}),i.calendars.ummalqura=n;var a=[20,50,79,109,138,168,197,227,256,286,315,345,374,404,433,463,492,522,551,581,611,641,670,700,729,759,788,818,847,877,906,936,965,995,1024,1054,1083,1113,1142,1172,1201,1231,1260,1290,1320,1350,1379,1409,1438,1468,1497,1527,1556,1586,1615,1645,1674,1704,1733,1763,1792,1822,1851,1881,1910,1940,1969,1999,2028,2058,2087,2117,2146,2176,2205,2235,2264,2294,2323,2353,2383,2413,2442,2472,2501,2531,2560,2590,2619,2649,2678,2708,2737,2767,2796,2826,2855,2885,2914,2944,2973,3003,3032,3062,3091,3121,3150,3180,3209,3239,3268,3298,3327,3357,3386,3416,3446,3476,3505,3535,3564,3594,3623,3653,3682,3712,3741,3771,3800,3830,3859,3889,3918,3948,3977,4007,4036,4066,4095,4125,4155,4185,4214,4244,4273,4303,4332,4362,4391,4421,4450,4480,4509,4539,4568,4598,4627,4657,4686,4716,4745,4775,4804,4834,4863,4893,4922,4952,4981,5011,5040,5070,5099,5129,5158,5188,5218,5248,5277,5307,5336,5366,5395,5425,5454,5484,5513,5543,5572,5602,5631,5661,5690,5720,5749,5779,5808,5838,5867,5897,5926,5956,5985,6015,6044,6074,6103,6133,6162,6192,6221,6251,6281,6311,6340,6370,6399,6429,6458,6488,6517,6547,6576,6606,6635,6665,6694,6724,6753,6783,6812,6842,6871,6901,6930,6960,6989,7019,7048,7078,7107,7137,7166,7196,7225,7255,7284,7314,7344,7374,7403,7433,7462,7492,7521,7551,7580,7610,7639,7669,7698,7728,7757,7787,7816,7846,7875,7905,7934,7964,7993,8023,8053,8083,8112,8142,8171,8201,8230,8260,8289,8319,8348,8378,8407,8437,8466,8496,8525,8555,8584,8614,8643,8673,8702,8732,8761,8791,8821,8850,8880,8909,8938,8968,8997,9027,9056,9086,9115,9145,9175,9205,9234,9264,9293,9322,9352,9381,9410,9440,9470,9499,9529,9559,9589,9618,9648,9677,9706,9736,9765,9794,9824,9853,9883,9913,9943,9972,10002,10032,10061,10090,10120,10149,10178,10208,10237,10267,10297,10326,10356,10386,10415,10445,10474,10504,10533,10562,10592,10621,10651,10680,10710,10740,10770,10799,10829,10858,10888,10917,10947,10976,11005,11035,11064,11094,11124,11153,11183,11213,11242,11272,11301,11331,11360,11389,11419,11448,11478,11507,11537,11567,11596,11626,11655,11685,11715,11744,11774,11803,11832,11862,11891,11921,11950,11980,12010,12039,12069,12099,12128,12158,12187,12216,12246,12275,12304,12334,12364,12393,12423,12453,12483,12512,12542,12571,12600,12630,12659,12688,12718,12747,12777,12807,12837,12866,12896,12926,12955,12984,13014,13043,13072,13102,13131,13161,13191,13220,13250,13280,13310,13339,13368,13398,13427,13456,13486,13515,13545,13574,13604,13634,13664,13693,13723,13752,13782,13811,13840,13870,13899,13929,13958,13988,14018,14047,14077,14107,14136,14166,14195,14224,14254,14283,14313,14342,14372,14401,14431,14461,14490,14520,14550,14579,14609,14638,14667,14697,14726,14756,14785,14815,14844,14874,14904,14933,14963,14993,15021,15051,15081,15110,15140,15169,15199,15228,15258,15287,15317,15347,15377,15406,15436,15465,15494,15524,15553,15582,15612,15641,15671,15701,15731,15760,15790,15820,15849,15878,15908,15937,15966,15996,16025,16055,16085,16114,16144,16174,16204,16233,16262,16292,16321,16350,16380,16409,16439,16468,16498,16528,16558,16587,16617,16646,16676,16705,16734,16764,16793,16823,16852,16882,16912,16941,16971,17001,17030,17060,17089,17118,17148,17177,17207,17236,17266,17295,17325,17355,17384,17414,17444,17473,17502,17532,17561,17591,17620,17650,17679,17709,17738,17768,17798,17827,17857,17886,17916,17945,17975,18004,18034,18063,18093,18122,18152,18181,18211,18241,18270,18300,18330,18359,18388,18418,18447,18476,18506,18535,18565,18595,18625,18654,18684,18714,18743,18772,18802,18831,18860,18890,18919,18949,18979,19008,19038,19068,19098,19127,19156,19186,19215,19244,19274,19303,19333,19362,19392,19422,19452,19481,19511,19540,19570,19599,19628,19658,19687,19717,19746,19776,19806,19836,19865,19895,19924,19954,19983,20012,20042,20071,20101,20130,20160,20190,20219,20249,20279,20308,20338,20367,20396,20426,20455,20485,20514,20544,20573,20603,20633,20662,20692,20721,20751,20780,20810,20839,20869,20898,20928,20957,20987,21016,21046,21076,21105,21135,21164,21194,21223,21253,21282,21312,21341,21371,21400,21430,21459,21489,21519,21548,21578,21607,21637,21666,21696,21725,21754,21784,21813,21843,21873,21902,21932,21962,21991,22021,22050,22080,22109,22138,22168,22197,22227,22256,22286,22316,22346,22375,22405,22434,22464,22493,22522,22552,22581,22611,22640,22670,22700,22730,22759,22789,22818,22848,22877,22906,22936,22965,22994,23024,23054,23083,23113,23143,23173,23202,23232,23261,23290,23320,23349,23379,23408,23438,23467,23497,23527,23556,23586,23616,23645,23674,23704,23733,23763,23792,23822,23851,23881,23910,23940,23970,23999,24029,24058,24088,24117,24147,24176,24206,24235,24265,24294,24324,24353,24383,24413,24442,24472,24501,24531,24560,24590,24619,24648,24678,24707,24737,24767,24796,24826,24856,24885,24915,24944,24974,25003,25032,25062,25091,25121,25150,25180,25210,25240,25269,25299,25328,25358,25387,25416,25446,25475,25505,25534,25564,25594,25624,25653,25683,25712,25742,25771,25800,25830,25859,25888,25918,25948,25977,26007,26037,26067,26096,26126,26155,26184,26214,26243,26272,26302,26332,26361,26391,26421,26451,26480,26510,26539,26568,26598,26627,26656,26686,26715,26745,26775,26805,26834,26864,26893,26923,26952,26982,27011,27041,27070,27099,27129,27159,27188,27218,27248,27277,27307,27336,27366,27395,27425,27454,27484,27513,27542,27572,27602,27631,27661,27691,27720,27750,27779,27809,27838,27868,27897,27926,27956,27985,28015,28045,28074,28104,28134,28163,28193,28222,28252,28281,28310,28340,28369,28399,28428,28458,28488,28517,28547,28577,28607,28636,28665,28695,28724,28754,28783,28813,28843,28872,28901,28931,28960,28990,29019,29049,29078,29108,29137,29167,29196,29226,29255,29285,29315,29345,29375,29404,29434,29463,29492,29522,29551,29580,29610,29640,29669,29699,29729,29759,29788,29818,29847,29876,29906,29935,29964,29994,30023,30053,30082,30112,30141,30171,30200,30230,30259,30289,30318,30348,30378,30408,30437,30467,30496,30526,30555,30585,30614,30644,30673,30703,30732,30762,30791,30821,30850,30880,30909,30939,30968,30998,31027,31057,31086,31116,31145,31175,31204,31234,31263,31293,31322,31352,31381,31411,31441,31471,31500,31530,31559,31589,31618,31648,31676,31706,31736,31766,31795,31825,31854,31884,31913,31943,31972,32002,32031,32061,32090,32120,32150,32180,32209,32239,32268,32298,32327,32357,32386,32416,32445,32475,32504,32534,32563,32593,32622,32652,32681,32711,32740,32770,32799,32829,32858,32888,32917,32947,32976,33006,33035,33065,33094,33124,33153,33183,33213,33243,33272,33302,33331,33361,33390,33420,33450,33479,33509,33539,33568,33598,33627,33657,33686,33716,33745,33775,33804,33834,33863,33893,33922,33952,33981,34011,34040,34069,34099,34128,34158,34187,34217,34247,34277,34306,34336,34365,34395,34424,34454,34483,34512,34542,34571,34601,34631,34660,34690,34719,34749,34778,34808,34837,34867,34896,34926,34955,34985,35015,35044,35074,35103,35133,35162,35192,35222,35251,35280,35310,35340,35370,35399,35429,35458,35488,35517,35547,35576,35605,35635,35665,35694,35723,35753,35782,35811,35841,35871,35901,35930,35960,35989,36019,36048,36078,36107,36136,36166,36195,36225,36254,36284,36314,36343,36373,36403,36433,36462,36492,36521,36551,36580,36610,36639,36669,36698,36728,36757,36786,36816,36845,36875,36904,36934,36963,36993,37022,37052,37081,37111,37141,37170,37200,37229,37259,37288,37318,37347,37377,37406,37436,37465,37495,37524,37554,37584,37613,37643,37672,37701,37731,37760,37790,37819,37849,37878,37908,37938,37967,37997,38027,38056,38085,38115,38144,38174,38203,38233,38262,38292,38322,38351,38381,38410,38440,38469,38499,38528,38558,38587,38617,38646,38676,38705,38735,38764,38794,38823,38853,38882,38912,38941,38971,39001,39030,39059,39089,39118,39148,39178,39208,39237,39267,39297,39326,39355,39385,39414,39444,39473,39503,39532,39562,39592,39621,39650,39680,39709,39739,39768,39798,39827,39857,39886,39916,39946,39975,40005,40035,40064,40094,40123,40153,40182,40212,40241,40271,40300,40330,40359,40389,40418,40448,40477,40507,40536,40566,40595,40625,40655,40685,40714,40744,40773,40803,40832,40862,40892,40921,40951,40980,41009,41039,41068,41098,41127,41157,41186,41216,41245,41275,41304,41334,41364,41393,41422,41452,41481,41511,41540,41570,41599,41629,41658,41688,41718,41748,41777,41807,41836,41865,41894,41924,41953,41983,42012,42042,42072,42102,42131,42161,42190,42220,42249,42279,42308,42337,42367,42397,42426,42456,42485,42515,42545,42574,42604,42633,42662,42692,42721,42751,42780,42810,42839,42869,42899,42929,42958,42988,43017,43046,43076,43105,43135,43164,43194,43223,43253,43283,43312,43342,43371,43401,43430,43460,43489,43519,43548,43578,43607,43637,43666,43696,43726,43755,43785,43814,43844,43873,43903,43932,43962,43991,44021,44050,44080,44109,44139,44169,44198,44228,44258,44287,44317,44346,44375,44405,44434,44464,44493,44523,44553,44582,44612,44641,44671,44700,44730,44759,44788,44818,44847,44877,44906,44936,44966,44996,45025,45055,45084,45114,45143,45172,45202,45231,45261,45290,45320,45350,45380,45409,45439,45468,45498,45527,45556,45586,45615,45644,45674,45704,45733,45763,45793,45823,45852,45882,45911,45940,45970,45999,46028,46058,46088,46117,46147,46177,46206,46236,46265,46295,46324,46354,46383,46413,46442,46472,46501,46531,46560,46590,46620,46649,46679,46708,46738,46767,46797,46826,46856,46885,46915,46944,46974,47003,47033,47063,47092,47122,47151,47181,47210,47240,47269,47298,47328,47357,47387,47417,47446,47476,47506,47535,47565,47594,47624,47653,47682,47712,47741,47771,47800,47830,47860,47890,47919,47949,47978,48008,48037,48066,48096,48125,48155,48184,48214,48244,48273,48303,48333,48362,48392,48421,48450,48480,48509,48538,48568,48598,48627,48657,48687,48717,48746,48776,48805,48834,48864,48893,48922,48952,48982,49011,49041,49071,49100,49130,49160,49189,49218,49248,49277,49306,49336,49365,49395,49425,49455,49484,49514,49543,49573,49602,49632,49661,49690,49720,49749,49779,49809,49838,49868,49898,49927,49957,49986,50016,50045,50075,50104,50133,50163,50192,50222,50252,50281,50311,50340,50370,50400,50429,50459,50488,50518,50547,50576,50606,50635,50665,50694,50724,50754,50784,50813,50843,50872,50902,50931,50960,50990,51019,51049,51078,51108,51138,51167,51197,51227,51256,51286,51315,51345,51374,51403,51433,51462,51492,51522,51552,51582,51611,51641,51670,51699,51729,51758,51787,51816,51846,51876,51906,51936,51965,51995,52025,52054,52083,52113,52142,52171,52200,52230,52260,52290,52319,52349,52379,52408,52438,52467,52497,52526,52555,52585,52614,52644,52673,52703,52733,52762,52792,52822,52851,52881,52910,52939,52969,52998,53028,53057,53087,53116,53146,53176,53205,53235,53264,53294,53324,53353,53383,53412,53441,53471,53500,53530,53559,53589,53619,53648,53678,53708,53737,53767,53796,53825,53855,53884,53913,53943,53973,54003,54032,54062,54092,54121,54151,54180,54209,54239,54268,54297,54327,54357,54387,54416,54446,54476,54505,54535,54564,54593,54623,54652,54681,54711,54741,54770,54800,54830,54859,54889,54919,54948,54977,55007,55036,55066,55095,55125,55154,55184,55213,55243,55273,55302,55332,55361,55391,55420,55450,55479,55508,55538,55567,55597,55627,55657,55686,55716,55745,55775,55804,55834,55863,55892,55922,55951,55981,56011,56040,56070,56100,56129,56159,56188,56218,56247,56276,56306,56335,56365,56394,56424,56454,56483,56513,56543,56572,56601,56631,56660,56690,56719,56749,56778,56808,56837,56867,56897,56926,56956,56985,57015,57044,57074,57103,57133,57162,57192,57221,57251,57280,57310,57340,57369,57399,57429,57458,57487,57517,57546,57576,57605,57634,57664,57694,57723,57753,57783,57813,57842,57871,57901,57930,57959,57989,58018,58048,58077,58107,58137,58167,58196,58226,58255,58285,58314,58343,58373,58402,58432,58461,58491,58521,58551,58580,58610,58639,58669,58698,58727,58757,58786,58816,58845,58875,58905,58934,58964,58994,59023,59053,59082,59111,59141,59170,59200,59229,59259,59288,59318,59348,59377,59407,59436,59466,59495,59525,59554,59584,59613,59643,59672,59702,59731,59761,59791,59820,59850,59879,59909,59939,59968,59997,60027,60056,60086,60115,60145,60174,60204,60234,60264,60293,60323,60352,60381,60411,60440,60469,60499,60528,60558,60588,60618,60648,60677,60707,60736,60765,60795,60824,60853,60883,60912,60942,60972,61002,61031,61061,61090,61120,61149,61179,61208,61237,61267,61296,61326,61356,61385,61415,61445,61474,61504,61533,61563,61592,61621,61651,61680,61710,61739,61769,61799,61828,61858,61888,61917,61947,61976,62006,62035,62064,62094,62123,62153,62182,62212,62242,62271,62301,62331,62360,62390,62419,62448,62478,62507,62537,62566,62596,62625,62655,62685,62715,62744,62774,62803,62832,62862,62891,62921,62950,62980,63009,63039,63069,63099,63128,63157,63187,63216,63246,63275,63305,63334,63363,63393,63423,63453,63482,63512,63541,63571,63600,63630,63659,63689,63718,63747,63777,63807,63836,63866,63895,63925,63955,63984,64014,64043,64073,64102,64131,64161,64190,64220,64249,64279,64309,64339,64368,64398,64427,64457,64486,64515,64545,64574,64603,64633,64663,64692,64722,64752,64782,64811,64841,64870,64899,64929,64958,64987,65017,65047,65076,65106,65136,65166,65195,65225,65254,65283,65313,65342,65371,65401,65431,65460,65490,65520,65549,65579,65608,65638,65667,65697,65726,65755,65785,65815,65844,65874,65903,65933,65963,65992,66022,66051,66081,66110,66140,66169,66199,66228,66258,66287,66317,66346,66376,66405,66435,66465,66494,66524,66553,66583,66612,66641,66671,66700,66730,66760,66789,66819,66849,66878,66908,66937,66967,66996,67025,67055,67084,67114,67143,67173,67203,67233,67262,67292,67321,67351,67380,67409,67439,67468,67497,67527,67557,67587,67617,67646,67676,67705,67735,67764,67793,67823,67852,67882,67911,67941,67971,68e3,68030,68060,68089,68119,68148,68177,68207,68236,68266,68295,68325,68354,68384,68414,68443,68473,68502,68532,68561,68591,68620,68650,68679,68708,68738,68768,68797,68827,68857,68886,68916,68946,68975,69004,69034,69063,69092,69122,69152,69181,69211,69240,69270,69300,69330,69359,69388,69418,69447,69476,69506,69535,69565,69595,69624,69654,69684,69713,69743,69772,69802,69831,69861,69890,69919,69949,69978,70008,70038,70067,70097,70126,70156,70186,70215,70245,70274,70303,70333,70362,70392,70421,70451,70481,70510,70540,70570,70599,70629,70658,70687,70717,70746,70776,70805,70835,70864,70894,70924,70954,70983,71013,71042,71071,71101,71130,71159,71189,71218,71248,71278,71308,71337,71367,71397,71426,71455,71485,71514,71543,71573,71602,71632,71662,71691,71721,71751,71781,71810,71839,71869,71898,71927,71957,71986,72016,72046,72075,72105,72135,72164,72194,72223,72253,72282,72311,72341,72370,72400,72429,72459,72489,72518,72548,72577,72607,72637,72666,72695,72725,72754,72784,72813,72843,72872,72902,72931,72961,72991,73020,73050,73080,73109,73139,73168,73197,73227,73256,73286,73315,73345,73375,73404,73434,73464,73493,73523,73552,73581,73611,73640,73669,73699,73729,73758,73788,73818,73848,73877,73907,73936,73965,73995,74024,74053,74083,74113,74142,74172,74202,74231,74261,74291,74320,74349,74379,74408,74437,74467,74497,74526,74556,74586,74615,74645,74675,74704,74733,74763,74792,74822,74851,74881,74910,74940,74969,74999,75029,75058,75088,75117,75147,75176,75206,75235,75264,75294,75323,75353,75383,75412,75442,75472,75501,75531,75560,75590,75619,75648,75678,75707,75737,75766,75796,75826,75856,75885,75915,75944,75974,76003,76032,76062,76091,76121,76150,76180,76210,76239,76269,76299,76328,76358,76387,76416,76446,76475,76505,76534,76564,76593,76623,76653,76682,76712,76741,76771,76801,76830,76859,76889,76918,76948,76977,77007,77036,77066,77096,77125,77155,77185,77214,77243,77273,77302,77332,77361,77390,77420,77450,77479,77509,77539,77569,77598,77627,77657,77686,77715,77745,77774,77804,77833,77863,77893,77923,77952,77982,78011,78041,78070,78099,78129,78158,78188,78217,78247,78277,78307,78336,78366,78395,78425,78454,78483,78513,78542,78572,78601,78631,78661,78690,78720,78750,78779,78808,78838,78867,78897,78926,78956,78985,79015,79044,79074,79104,79133,79163,79192,79222,79251,79281,79310,79340,79369,79399,79428,79458,79487,79517,79546,79576,79606,79635,79665,79695,79724,79753,79783,79812,79841,79871,79900,79930,79960,79990]},{"../main":590,"object-assign":471}],590:[function(t,e,r){function n(){this.regionalOptions=[],this.regionalOptions[""]={invalidCalendar:"Calendar {0} not found",invalidDate:"Invalid {0} date",invalidMonth:"Invalid {0} month",invalidYear:"Invalid {0} year",differentCalendars:"Cannot mix {0} and {1} dates"},this.local=this.regionalOptions[""],this.calendars={},this._localCals={}}function i(t,e,r,n){if(this._calendar=t,this._year=e,this._month=r,this._day=n,0===this._calendar._validateLevel&&!this._calendar.isValid(this._year,this._month,this._day))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name)}function a(t,e){return t=""+t,"000000".substring(0,e-t.length)+t}function o(){this.shortYearCutoff="+10"}function s(t){this.local=this.regionalOptions[t]||this.regionalOptions[""]}var l=t("object-assign");l(n.prototype,{instance:function(t,e){t=(t||"gregorian").toLowerCase(),e=e||"";var r=this._localCals[t+"-"+e];if(!r&&this.calendars[t]&&(r=new this.calendars[t](e),this._localCals[t+"-"+e]=r),!r)throw(this.local.invalidCalendar||this.regionalOptions[""].invalidCalendar).replace(/\{0\}/,t);return r},newDate:function(t,e,r,n,i){return(n=(null!=t&&t.year?t.calendar():"string"==typeof n?this.instance(n,i):n)||this.instance()).newDate(t,e,r)},substituteDigits:function(t){return function(e){return(e+"").replace(/[0-9]/g,function(e){return t[e]})}},substituteChineseDigits:function(t,e){return function(r){for(var n="",i=0;r>0;){var a=r%10;n=(0===a?"":t[a]+e[i])+n,i++,r=Math.floor(r/10)}return 0===n.indexOf(t[1]+e[1])&&(n=n.substr(1)),n||t[0]}}}),l(i.prototype,{newDate:function(t,e,r){return this._calendar.newDate(null==t?this:t,e,r)},year:function(t){return 0===arguments.length?this._year:this.set(t,"y")},month:function(t){return 0===arguments.length?this._month:this.set(t,"m")},day:function(t){return 0===arguments.length?this._day:this.set(t,"d")},date:function(t,e,r){if(!this._calendar.isValid(t,e,r))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name);return this._year=t,this._month=e,this._day=r,this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(t,e){return this._calendar.add(this,t,e)},set:function(t,e){return this._calendar.set(this,t,e)},compareTo:function(t){if(this._calendar.name!==t._calendar.name)throw(c.local.differentCalendars||c.regionalOptions[""].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,t._calendar.local.name);var e=this._year!==t._year?this._year-t._year:this._month!==t._month?this.monthOfYear()-t.monthOfYear():this._day-t._day;return 0===e?0:e<0?-1:1},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(t){return this._calendar.fromJD(t)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(t){return this._calendar.fromJSDate(t)},toString:function(){return(this.year()<0?"-":"")+a(Math.abs(this.year()),4)+"-"+a(this.month(),2)+"-"+a(this.day(),2)}}),l(o.prototype,{_validateLevel:0,newDate:function(t,e,r){return null==t?this.today():(t.year&&(this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),r=t.day(),e=t.month(),t=t.year()),new i(this,t,e,r))},today:function(){return this.fromJSDate(new Date)},epoch:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear).year()<0?this.local.epochs[0]:this.local.epochs[1]},formatYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return(e.year()<0?"-":"")+a(Math.abs(e.year()),4)},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear),12},monthOfYear:function(t,e){var r=this._validate(t,e,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth);return(r.month()+this.monthsInYear(r)-this.firstMonth)%this.monthsInYear(r)+this.minMonth},fromMonthOfYear:function(t,e){var r=(e+this.firstMonth-2*this.minMonth)%this.monthsInYear(t)+this.minMonth;return this._validate(t,r,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth),r},daysInYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return this.leapYear(e)?366:365},dayOfYear:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return n.toJD()-this.newDate(n.year(),this.fromMonthOfYear(n.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return(Math.floor(this.toJD(n))+2)%this.daysInWeek()},extraInfo:function(t,e,r){return this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),{}},add:function(t,e,r){return this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate),this._correctAdd(t,this._add(t,e,r),e,r)},_add:function(t,e,r){if(this._validateLevel++,"d"===r||"w"===r){var n=t.toJD()+e*("w"===r?this.daysInWeek():1),i=t.calendar().fromJD(n);return this._validateLevel--,[i.year(),i.month(),i.day()]}try{var a=t.year()+("y"===r?e:0),o=t.monthOfYear()+("m"===r?e:0);i=t.day();"y"===r?(t.month()!==this.fromMonthOfYear(a,o)&&(o=this.newDate(a,t.month(),this.minDay).monthOfYear()),o=Math.min(o,this.monthsInYear(a)),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o)))):"m"===r&&(!function(t){for(;oe-1+t.minMonth;)a++,o-=e,e=t.monthsInYear(a)}(this),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o))));var s=[a,this.fromMonthOfYear(a,o),i];return this._validateLevel--,s}catch(t){throw this._validateLevel--,t}},_correctAdd:function(t,e,r,n){if(!(this.hasYearZero||"y"!==n&&"m"!==n||0!==e[0]&&t.year()>0==e[0]>0)){var i={y:[1,1,"y"],m:[1,this.monthsInYear(-1),"m"],w:[this.daysInWeek(),this.daysInYear(-1),"d"],d:[1,this.daysInYear(-1),"d"]}[n],a=r<0?-1:1;e=this._add(t,r*i[0]+a*i[1],i[2])}return t.date(e[0],e[1],e[2])},set:function(t,e,r){this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate);var n="y"===r?e:t.year(),i="m"===r?e:t.month(),a="d"===r?e:t.day();return"y"!==r&&"m"!==r||(a=Math.min(a,this.daysInMonth(n,i))),t.date(n,i,a)},isValid:function(t,e,r){this._validateLevel++;var n=this.hasYearZero||0!==t;if(n){var i=this.newDate(t,e,this.minDay);n=e>=this.minMonth&&e-this.minMonth=this.minDay&&r-this.minDay13.5?13:1),c=i-(l>2.5?4716:4715);return c<=0&&c--,this.newDate(c,l,s)},toJSDate:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),i=new Date(n.year(),n.month()-1,n.day());return i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.setHours(i.getHours()>12?i.getHours()+2:0),i},fromJSDate:function(t){return this.newDate(t.getFullYear(),t.getMonth()+1,t.getDate())}});var c=e.exports=new n;c.cdate=i,c.baseCalendar=o,c.calendars.gregorian=s},{"object-assign":471}],591:[function(t,e,r){var n=t("object-assign"),i=t("./main");n(i.regionalOptions[""],{invalidArguments:"Invalid arguments",invalidFormat:"Cannot format a date from another calendar",missingNumberAt:"Missing number at position {0}",unknownNameAt:"Unknown name at position {0}",unexpectedLiteralAt:"Unexpected literal at position {0}",unexpectedText:"Additional text found at end"}),i.local=i.regionalOptions[""],n(i.cdate.prototype,{formatDate:function(t,e){return"string"!=typeof t&&(e=t,t=""),this._calendar.formatDate(t||"",this,e)}}),n(i.baseCalendar.prototype,{UNIX_EPOCH:i.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:86400,TICKS_EPOCH:i.instance().jdEpoch,TICKS_PER_DAY:864e9,ATOM:"yyyy-mm-dd",COOKIE:"D, dd M yyyy",FULL:"DD, MM d, yyyy",ISO_8601:"yyyy-mm-dd",JULIAN:"J",RFC_822:"D, d M yy",RFC_850:"DD, dd-M-yy",RFC_1036:"D, d M yy",RFC_1123:"D, d M yyyy",RFC_2822:"D, d M yyyy",RSS:"D, d M yy",TICKS:"!",TIMESTAMP:"@",W3C:"yyyy-mm-dd",formatDate:function(t,e,r){if("string"!=typeof t&&(r=e,e=t,t=""),!e)return"";if(e.calendar()!==this)throw i.local.invalidFormat||i.regionalOptions[""].invalidFormat;t=t||this.local.dateFormat;for(var n=(r=r||{}).dayNamesShort||this.local.dayNamesShort,a=r.dayNames||this.local.dayNames,o=r.monthNumbers||this.local.monthNumbers,s=r.monthNamesShort||this.local.monthNamesShort,l=r.monthNames||this.local.monthNames,c=(r.calculateWeek||this.local.calculateWeek,function(e,r){for(var n=1;b+n1}),u=function(t,e,r,n){var i=""+e;if(c(t,n))for(;i.length1},b=function(t,r){var n=y(t,r),a=[2,3,n?4:2,n?4:2,10,11,20]["oyYJ@!".indexOf(t)+1],o=new RegExp("^-?\\d{1,"+a+"}"),s=e.substring(T).match(o);if(!s)throw(i.local.missingNumberAt||i.regionalOptions[""].missingNumberAt).replace(/\{0\}/,T);return T+=s[0].length,parseInt(s[0],10)},x=this,_=function(){if("function"==typeof l){y("m");var t=l.call(x,e.substring(T));return T+=t.length,t}return b("m")},w=function(t,r,n,a){for(var o=y(t,a)?n:r,s=0;s-1){d=1,p=m;for(var E=this.daysInMonth(f,d);p>E;E=this.daysInMonth(f,d))d++,p-=E}return h>-1?this.fromJD(h):this.newDate(f,d,p)},determineDate:function(t,e,r,n,i){r&&"object"!=typeof r&&(i=n,n=r,r=null),"string"!=typeof n&&(i=n,n="");var a=this;return e=e?e.newDate():null,t=null==t?e:"string"==typeof t?function(t){try{return a.parseDate(n,t,i)}catch(t){}for(var e=((t=t.toLowerCase()).match(/^c/)&&r?r.newDate():null)||a.today(),o=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,s=o.exec(t);s;)e.add(parseInt(s[1],10),s[2]||"d"),s=o.exec(t);return e}(t):"number"==typeof t?isNaN(t)||t===1/0||t===-1/0?e:a.today().add(t,"d"):a.newDate(t)}})},{"./main":590,"object-assign":471}],592:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":111}],593:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":592}],594:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./common_defaults"),o=t("./attributes");e.exports=function(t,e,r,s,l){function c(r,i){return n.coerce(t,e,o,r,i)}s=s||{};var u=c("visible",!(l=l||{}).itemIsNotPlainObject),h=c("clicktoshow");if(!u&&!h)return e;a(t,e,r,c);for(var f=e.showarrow,d=["x","y"],p=[-10,-30],m={_fullLayout:r},g=0;g<2;g++){var v=d[g],y=i.coerceRef(t,e,m,v,"","paper");if(i.coercePosition(e,m,c,y,v,.5),f){var b="a"+v,x=i.coerceRef(t,e,m,b,"pixel");"pixel"!==x&&x!==y&&(x=e[b]="pixel");var _="pixel"===x?p[g]:.4;i.coercePosition(e,m,c,x,b,_)}c(v+"anchor"),c(v+"shift")}if(n.noneOrAll(t,e,["x","y"]),f&&n.noneOrAll(t,e,["ax","ay"]),h){var w=c("xclick"),M=c("yclick");e._xclick=void 0===w?e.x:i.cleanPosition(w,m,e.xref),e._yclick=void 0===M?e.y:i.cleanPosition(M,m,e.yref)}return e}},{"../../lib":738,"../../plots/cartesian/axes":785,"./attributes":596,"./common_defaults":599}],595:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],596:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:"annotation",visible:{valType:"boolean",dflt:!0,editType:"calcIfAutorange"},text:{valType:"string",editType:"calcIfAutorange"},textangle:{valType:"angle",dflt:0,editType:"calcIfAutorange"},font:i({editType:"calcIfAutorange",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calcIfAutorange"},height:{valType:"number",min:1,dflt:null,editType:"calcIfAutorange"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calcIfAutorange"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calcIfAutorange"},showarrow:{valType:"boolean",dflt:!0,editType:"calcIfAutorange"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calcIfAutorange"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calcIfAutorange"},arrowwidth:{valType:"number",min:.1,editType:"calcIfAutorange"},standoff:{valType:"number",min:0,dflt:0,editType:"calcIfAutorange"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calcIfAutorange"},ax:{valType:"any",editType:"calcIfAutorange"},ay:{valType:"any",editType:"calcIfAutorange"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calcIfAutorange"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calcIfAutorange"},xshift:{valType:"number",dflt:0,editType:"calcIfAutorange"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calcIfAutorange"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calcIfAutorange"},yshift:{valType:"number",dflt:0,editType:"calcIfAutorange"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}}},{"../../plots/cartesian/constants":790,"../../plots/font_attributes":810,"./arrow_paths":595}],597:[function(t,e,r){"use strict";function n(t){var e=t._fullLayout;i.filterVisible(e.annotations).forEach(function(e){var r,n,i,o,s=a.getFromId(t,e.xref),l=a.getFromId(t,e.yref),c=3*e.arrowsize*e.arrowwidth||0,u=3*e.startarrowsize*e.arrowwidth||0;s&&s.autorange&&(r=c+e.xshift,n=c-e.xshift,i=u+e.xshift,o=u-e.xshift,e.axref===e.xref?(a.expand(s,[s.r2c(e.x)],{ppadplus:r,ppadminus:n}),a.expand(s,[s.r2c(e.ax)],{ppadplus:Math.max(e._xpadplus,i),ppadminus:Math.max(e._xpadminus,o)})):(i=e.ax?i+e.ax:i,o=e.ax?o-e.ax:o,a.expand(s,[s.r2c(e.x)],{ppadplus:Math.max(e._xpadplus,r,i),ppadminus:Math.max(e._xpadminus,n,o)}))),l&&l.autorange&&(r=c-e.yshift,n=c+e.yshift,i=u-e.yshift,o=u+e.yshift,e.ayref===e.yref?(a.expand(l,[l.r2c(e.y)],{ppadplus:r,ppadminus:n}),a.expand(l,[l.r2c(e.ay)],{ppadplus:Math.max(e._ypadplus,i),ppadminus:Math.max(e._ypadminus,o)})):(i=e.ay?i+e.ay:i,o=e.ay?o-e.ay:o,a.expand(l,[l.r2c(e.y)],{ppadplus:Math.max(e._ypadplus,r,i),ppadminus:Math.max(e._ypadminus,n,o)})))})}var i=t("../../lib"),a=t("../../plots/cartesian/axes"),o=t("./draw").draw;e.exports=function(t){var e=t._fullLayout,r=i.filterVisible(e.annotations);if(r.length&&t._fullData.length){var s={};r.forEach(function(t){s[t.xref]=1,s[t.yref]=1});for(var l in s){var c=a.getFromId(t,l);if(c&&c.autorange)return i.syncOrAsync([o,n],t)}}}},{"../../lib":738,"../../plots/cartesian/axes":785,"./draw":602}],598:[function(t,e,r){"use strict";function n(t,e){var r,n,a,o,s,l,c,u=t._fullLayout.annotations,h=[],f=[],d=[],p=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,i=n(t,e),o=i.on,s=i.off.concat(i.explicitOff),l={};if(o.length||s.length){for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}var a=j.selectAll("a");if(1===a.size()&&a.text()===j.text()){C.insert("a",":first-child").attr({"xlink:xlink:href":a.attr("xlink:href"),"xlink:xlink:show":a.attr("xlink:show")}).style({cursor:"pointer"}).node().appendChild(z.node())}var c=C.select(".annotation-text-math-group"),f=!c.empty(),v=h.bBox((f?c:j).node()),y=v.width,L=v.height,P=e.width||y,R=e.height||L,N=Math.round(P+2*D),B=Math.round(R+2*D);e._w=P,e._h=R;for(var U=!1,V=["x","y"],H=0;H1)&&(K===J?((ot=Q.r2fraction(e["a"+Z]))<0||ot>1)&&(U=!0):U=!0,U))continue;q=Q._offset+Q.r2p(e[Z]),W=.5}else"x"===Z?(Y=e[Z],q=_.l+_.w*Y):(Y=1-e[Z],q=_.t+_.h*Y),W=e.showarrow?.5:Y;if(e.showarrow){at.head=q;var st=e["a"+Z];X=tt*r(.5,e.xanchor)-et*r(.5,e.yanchor),K===J?(at.tail=Q._offset+Q.r2p(st),G=X):(at.tail=q+st,G=X+st),at.text=at.tail+X;var lt=x["x"===Z?"width":"height"];if("paper"===J&&(at.head=l.constrain(at.head,1,lt-1)),"pixel"===K){var ct=-Math.max(at.tail-3,at.text),ut=Math.min(at.tail+3,at.text)-lt;ct>0?(at.tail+=ct,at.text+=ct):ut>0&&(at.tail-=ut,at.text-=ut)}at.tail+=it,at.head+=it}else G=X=rt*r(W,nt),at.text=q+X;at.text+=it,X+=it,G+=it,e["_"+Z+"padplus"]=rt/2+G,e["_"+Z+"padminus"]=rt/2-G,e["_"+Z+"size"]=rt,e["_"+Z+"shift"]=X}if(U)C.remove();else{var ht=0,ft=0;if("left"!==e.align&&(ht=(P-y)*("center"===e.align?.5:1)),"top"!==e.valign&&(ft=(R-L)*("middle"===e.valign?.5:1)),f)c.select("svg").attr({x:D+ht-1,y:D+ft}).call(h.setClipUrl,O?M:null);else{var dt=D+ft-v.top,pt=D+ht-v.left;j.call(d.positionText,pt,dt).call(h.setClipUrl,O?M:null)}F.select("rect").call(h.setRect,D,D,P,R),z.call(h.setRect,I/2,I/2,N-I,B-I),C.call(h.setTranslate,Math.round(k.x.text-N/2),Math.round(k.y.text-B/2)),S.attr({transform:"rotate("+T+","+k.x.text+","+k.y.text+")"});var mt=function(r,a){A.selectAll(".annotation-arrow-g").remove();var c=k.x.head,f=k.y.head,d=k.x.tail+r,p=k.y.tail+a,v=k.x.text+r,y=k.y.text+a,x=l.rotationXYMatrix(T,v,y),M=l.apply2DTransform(x),E=l.apply2DTransform2(x),L=+z.attr("width"),I=+z.attr("height"),P=v-.5*L,D=P+L,O=y-.5*I,F=O+I,R=[[P,O,P,F],[P,F,D,F],[D,F,D,O],[D,O,P,O]].map(E);if(!R.reduce(function(t,e){return t^!!l.segmentsIntersect(c,f,c+1e6,f+1e6,e[0],e[1],e[2],e[3])},!1)){R.forEach(function(t){var e=l.segmentsIntersect(d,p,c,f,t[0],t[1],t[2],t[3]);e&&(d=e.x,p=e.y)});var j=e.arrowwidth,N=e.arrowcolor,B=e.arrowside,U=A.append("g").style({opacity:u.opacity(N)}).classed("annotation-arrow-g",!0),V=U.append("path").attr("d","M"+d+","+p+"L"+c+","+f).style("stroke-width",j+"px").call(u.stroke,u.rgb(N));if(g(V,B,e),w.annotationPosition&&V.node().parentNode&&!n){var H=c,q=f;if(e.standoff){var G=Math.sqrt(Math.pow(c-d,2)+Math.pow(f-p,2));H+=e.standoff*(d-c)/G,q+=e.standoff*(p-f)/G}var Y,W,X,Z=U.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(d-H)+","+(p-q),transform:"translate("+H+","+q+")"}).style("stroke-width",j+6+"px").call(u.stroke,"rgba(0,0,0,0)").call(u.fill,"rgba(0,0,0,0)");m.init({element:Z.node(),gd:t,prepFn:function(){var t=h.getTranslate(C);W=t.x,X=t.y,Y={},i&&i.autorange&&(Y[i._name+".autorange"]=!0),s&&s.autorange&&(Y[s._name+".autorange"]=!0)},moveFn:function(t,r){var n=M(W,X),a=n[0]+t,o=n[1]+r;C.call(h.setTranslate,a,o),Y[b+".x"]=i?i.p2r(i.r2p(e.x)+t):e.x+t/_.w,Y[b+".y"]=s?s.p2r(s.r2p(e.y)+r):e.y-r/_.h,e.axref===e.xref&&(Y[b+".ax"]=i.p2r(i.r2p(e.ax)+t)),e.ayref===e.yref&&(Y[b+".ay"]=s.p2r(s.r2p(e.ay)+r)),U.attr("transform","translate("+t+","+r+")"),S.attr({transform:"rotate("+T+","+a+","+o+")"})},doneFn:function(){o.relayout(t,Y);var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};if(e.showarrow&&mt(0,0),E){var gt,vt;m.init({element:C.node(),gd:t,prepFn:function(){vt=S.attr("transform"),gt={}},moveFn:function(t,r){var a="pointer";if(e.showarrow)e.axref===e.xref?gt[b+".ax"]=i.p2r(i.r2p(e.ax)+t):gt[b+".ax"]=e.ax+t,e.ayref===e.yref?gt[b+".ay"]=s.p2r(s.r2p(e.ay)+r):gt[b+".ay"]=e.ay+r,mt(t,r);else{if(n)return;if(i)gt[b+".x"]=e.x+t/i._m;else{var o=e._xsize/_.w,l=e.x+(e._xshift-e.xshift)/_.w-o/2;gt[b+".x"]=m.align(l+t/_.w,o,0,1,e.xanchor)}if(s)gt[b+".y"]=e.y+r/s._m;else{var c=e._ysize/_.h,u=e.y-(e._yshift+e.yshift)/_.h-c/2;gt[b+".y"]=m.align(u-r/_.h,c,0,1,e.yanchor)}i&&s||(a=m.getCursor(i?.5:gt[b+".x"],s?.5:gt[b+".y"],e.xanchor,e.yanchor))}S.attr({transform:"translate("+t+","+r+")"+vt}),p(C,a)},doneFn:function(){p(C),o.relayout(t,gt);var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}}var y,b,x=t._fullLayout,_=t._fullLayout._size,w=t._context.edits;n?(y="annotation-"+n,b=n+".annotations["+r+"]"):(y="annotation",b="annotations["+r+"]"),x._infolayer.selectAll("."+y+'[data-index="'+r+'"]').remove();var M="clip"+x._uid+"_ann"+r;if(e._input&&!1!==e.visible){var k={x:{},y:{}},T=+e.textangle||0,A=x._infolayer.append("g").classed(y,!0).attr("data-index",String(r)).style("opacity",e.opacity),S=A.append("g").classed("annotation-text-g",!0),E=w[e.showarrow?"annotationTail":"annotationPosition"],L=e.captureevents||w.annotationText||E,C=S.append("g").style("pointer-events",L?"all":null).call(p,"default").on("click",function(){t._dragging=!1;var i={index:r,annotation:e._input,fullAnnotation:e,event:a.event};n&&(i.subplotId=n),t.emit("plotly_clickannotation",i)});e.hovertext&&C.on("mouseover",function(){var r=e.hoverlabel,n=r.font,i=this.getBoundingClientRect(),a=t.getBoundingClientRect();f.loneHover({x0:i.left-a.left,x1:i.right-a.left,y:(i.top+i.bottom)/2-a.top,text:e.hovertext,color:r.bgcolor,borderColor:r.bordercolor,fontFamily:n.family,fontSize:n.size,fontColor:n.color},{container:x._hoverlayer.node(),outerContainer:x._paper.node(),gd:t})}).on("mouseout",function(){f.loneUnhover(x._hoverlayer.node())});var I=e.borderwidth,P=e.borderpad,D=I+P,z=C.append("rect").attr("class","bg").style("stroke-width",I+"px").call(u.stroke,e.bordercolor).call(u.fill,e.bgcolor),O=e.width||e.height,F=x._topclips.selectAll("#"+M).data(O?[0]:[]);F.enter().append("clipPath").classed("annclip",!0).attr("id",M).append("rect"),F.exit().remove();var R=e.font,j=C.append("text").classed("annotation-text",!0).text(e.text);w.annotationText?j.call(d.makeEditable,{delegate:C,gd:t}).call(c).on("edit",function(r){e.text=r,this.call(c);var n={};n[b+".text"]=e.text,i&&i.autorange&&(n[i._name+".autorange"]=!0),s&&s.autorange&&(n[s._name+".autorange"]=!0),o.relayout(t,n)}):j.call(c)}else a.selectAll("#"+M).remove()}var a=t("d3"),o=t("../../plotly"),s=t("../../plots/plots"),l=t("../../lib"),c=t("../../plots/cartesian/axes"),u=t("../color"),h=t("../drawing"),f=t("../fx"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),m=t("../dragelement"),g=t("./draw_arrow_head");e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,y=e.indexOf("end")>=0,b=d.backoff*m+r.standoff,x=p.backoff*g+r.startstandoff;if("line"===f.nodeName){l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")};var _=l.x-c.x,w=l.y-c.y;if(u=Math.atan2(w,_),h=u+Math.PI,b&&x&&b+x>Math.sqrt(_*_+w*w))return void o();if(b){if(b*b>_*_+w*w)return void o();var M=b*Math.cos(u),k=b*Math.sin(u);c.x+=M,c.y+=k,t.attr({x2:c.x,y2:c.y})}if(x){if(x*x>_*_+w*w)return void o();var T=x*Math.cos(u),A=x*Math.sin(u);l.x-=T,l.y-=A,t.attr({x1:l.x,y1:l.y})}}else if("path"===f.nodeName){var S=f.getTotalLength(),E="";if(S1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l.pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":835,"../annotations/draw":602}],609:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(r)for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults;var l=o.defaultLine=s.defaultLine;o.lightLine=s.lightLine;var c=o.background=s.background;o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||c).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(o).toRgbString()},o.contrast=function(t,e,r){var n=i(t);1!==n.getAlpha()&&(n=i(o.combine(t,c)));return(n.isDark()?e?n.lighten(e):c:r?n.darken(r):l).toString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;e0?E>=O:E<=O));L++)E>R&&E0?E>=O:E<=O));L++)E>C[0]&&E1){var ot=Math.pow(10,Math.floor(Math.log(at)/Math.LN10));nt*=ot*u.roundUp(at/ot,[2,5,10]),(Math.abs(k.levels.start)/k.levels.size+1e-6)%1<2e-6&&(et.tick0=0)}et.dtick=nt}et.domain=[K+X,K+G-X],et.setScale();var st=A._infolayer.selectAll("g."+e).data([0]);st.enter().append("g").classed(e,!0).classed(w.colorbar,!0).each(function(){var t=n.select(this);t.append("rect").classed(w.cbbg,!0),t.append("g").classed(w.cbfills,!0),t.append("g").classed(w.cblines,!0),t.append("g").classed(w.cbaxis,!0).classed(w.crisp,!0),t.append("g").classed(w.cbtitleunshift,!0).append("g").classed(w.cbtitle,!0),t.append("rect").classed(w.cboutline,!0),t.select(".cbtitle").datum(0)}),st.attr("transform","translate("+Math.round(S.l)+","+Math.round(S.t)+")");var lt=st.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(S.l)+",-"+Math.round(S.t)+")");et._axislayer=st.select(".cbaxis");var ct=0;if(-1!==["top","bottom"].indexOf(k.titleside)){var ut,ht=S.l+(k.x+Y)*S.w,ft=et.titlefont.size;ut="top"===k.titleside?(1-(K+G-X))*S.h+S.t+3+.75*ft:(1-(K+X))*S.h+S.t-3-.25*ft,T(et._id+"title",{attributes:{x:ht,y:ut,"text-anchor":"start"}})}var dt=u.syncOrAsync([o.previousPromises,function(){if(-1!==["top","bottom"].indexOf(k.titleside)){var e=st.select(".cbtitle"),r=e.select("text"),a=[-k.outlinewidth/2,k.outlinewidth/2],o=e.select(".h"+et._id+"title-math-group").node(),s=15.6;if(r.node()&&(s=parseInt(r.node().style.fontSize,10)*v),o?(ct=d.bBox(o).height)>s&&(a[1]-=(ct-s)/2):r.node()&&!r.classed(w.jsPlaceholder)&&(ct=d.bBox(r.node()).height),ct){if(ct+=5,"top"===k.titleside)et.domain[1]-=ct/S.h,a[1]*=-1;else{et.domain[0]+=ct/S.h;var c=g.lineCount(r);a[1]+=(1-c)*s}e.attr("transform","translate("+a+")"),et.setScale()}}st.selectAll(".cbfills,.cblines").attr("transform","translate(0,"+Math.round(S.h*(1-et.domain[1]))+")"),et._axislayer.attr("transform","translate(0,"+Math.round(-S.t)+")");var h=st.select(".cbfills").selectAll("rect.cbfill").data(P);h.enter().append("rect").classed(w.cbfill,!0).style("stroke","none"),h.exit().remove(),h.each(function(t,e){var r=[0===e?C[0]:(P[e]+P[e-1])/2,e===P.length-1?C[1]:(P[e]+P[e+1])/2].map(et.c2p).map(Math.round);e!==P.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Z,width:Math.max(V,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var f=st.select(".cblines").selectAll("path.cbline").data(k.line.color&&k.line.width?I:[]);return f.enter().append("path").classed(w.cbline,!0),f.exit().remove(),f.each(function(t){n.select(this).attr("d","M"+Z+","+(Math.round(et.c2p(t))+k.line.width/2%1)+"h"+V).call(d.lineGroupStyle,k.line.width,D(t),k.line.dash)}),et._axislayer.selectAll("g."+et._id+"tick,path").remove(),et._pos=Z+V+(k.outlinewidth||0)/2-("outside"===k.ticks?1:0),et.side="right",u.syncOrAsync([function(){return l.doTicks(t,et,!0)},function(){if(-1===["top","bottom"].indexOf(k.titleside)){var e=et.titlefont.size,r=et._offset+et._length/2,i=S.l+(et.position||0)*S.w+("right"===et.side?10+e*(et.showticklabels?1:.5):-10-e*(et.showticklabels?.5:0));T("h"+et._id+"title",{avoid:{selection:n.select(t).selectAll("g."+et._id+"tick"),side:k.titleside,offsetLeft:S.l,offsetTop:0,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])},o.previousPromises,function(){var r=V+k.outlinewidth/2+d.bBox(et._axislayer.node()).width;if((N=lt.select("text")).node()&&!N.classed(w.jsPlaceholder)){var n,i=lt.select(".h"+et._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(k.titleside)?d.bBox(i).width:d.bBox(lt.node()).right-Z-S.l,r=Math.max(r,n)}var a=2*k.xpad+r+k.borderwidth+k.outlinewidth/2,s=Q-$;st.select(".cbbg").attr({x:Z-k.xpad-(k.borderwidth+k.outlinewidth)/2,y:$-W,width:Math.max(a,2),height:Math.max(s+2*W,2)}).call(p.fill,k.bgcolor).call(p.stroke,k.bordercolor).style({"stroke-width":k.borderwidth}),st.selectAll(".cboutline").attr({x:Z,y:$+k.ypad+("top"===k.titleside?ct:0),width:Math.max(V,2),height:Math.max(s-2*k.ypad-ct,2)}).call(p.stroke,k.outlinecolor).style({fill:"None","stroke-width":k.outlinewidth});var l=({center:.5,right:1}[k.xanchor]||0)*a;st.attr("transform","translate("+(S.l-l)+","+S.t+")"),o.autoMargin(t,e,{x:k.x,y:k.y,l:a*({right:1,center:.5}[k.xanchor]||0),r:a*({left:1,center:.5}[k.xanchor]||0),t:s*({bottom:1,middle:.5}[k.yanchor]||0),b:s*({top:1,middle:.5}[k.yanchor]||0)})}],t);if(dt&&dt.then&&(t._promises||[]).push(dt),t._context.edits.colorbarPosition){var pt,mt,gt;c.init({element:st.node(),gd:t,prepFn:function(){pt=st.attr("transform"),f(st)},moveFn:function(t,e){st.attr("transform",pt+" translate("+t+","+e+")"),mt=c.align(J+t/S.w,H,0,1,k.xanchor),gt=c.align(K-e/S.h,G,0,1,k.yanchor);var r=c.getCursor(mt,gt,k.xanchor,k.yanchor);f(st,r)},doneFn:function(){f(st),void 0!==mt&&void 0!==gt&&a.restyle(t,{"colorbar.x":mt,"colorbar.y":gt},M().index)}})}return dt}A._infolayer.selectAll("g."+e).remove()}function M(){var r,n,i=e.substr(2);for(r=0;r=0?i.Reds:i.Blues,l.colorscale=m,s.reversescale&&(m=a(m)),s.colorscale=m)}},{"../../lib":738,"./flip_scale":625,"./scales":632}],621:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendFlat;t("./scales.js");e.exports=function(t,e,r){return{color:{valType:"color",arrayOk:!0,editType:e||"style"},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{impliedEdits:{cmin:void 0,cmax:void 0}}),cmax:i({},n.zmax,{editType:e||n.zmax.editType,impliedEdits:{cauto:!1}}),cmin:i({},n.zmin,{editType:e||n.zmin.editType,impliedEdits:{cauto:!1}}),autocolorscale:i({},n.autocolorscale,{dflt:!1===r?r:n.autocolorscale.dflt}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":727,"./attributes":619,"./scales.js":632}],622:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":632}],623:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var h=u.prefix,f=u.cLetter,d=h.slice(0,h.length-1),p=h?i.nestedProperty(t,d).get()||{}:t,m=h?i.nestedProperty(e,d).get()||{}:e,g=p[f+"min"],v=p[f+"max"],y=p.colorscale;c(h+f+"auto",!(n(g)&&n(v)&&g=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],626:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":622,"./is_valid_scale_array":630,"./scales":632}],627:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;l4/3-s?o:s}},{}],634:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":738}],635:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){return a(t.changedTouches?t.changedTouches[0]:t,document.body)}var a=t("mouse-event-offset"),o=t("has-hover"),s=t("../../plotly"),l=t("../../lib"),c=t("../../plots/cartesian/constants"),u=t("../../constants/interactions"),h=e.exports={};h.align=t("./align"),h.getCursor=t("./cursor");var f=t("./unhover");h.unhover=f.wrapped,h.unhoverRaw=f.raw,h.init=function(t){function e(e){x._dragged=!1,x._dragging=!0;var s=i(e);return f=s[0],d=s[1],y=e.target,v=e,b=e.buttons&&2===e.buttons||e.ctrlKey,(p=(new Date).getTime())-x._mouseDownTimew&&(_=Math.max(_-1,1)),x._dragged)t.doneFn&&t.doneFn(e);else if(t.clickFn&&t.clickFn(_,v),!b){var n;try{n=new MouseEvent("click",e)}catch(t){var c=i(e);(n=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,c[0],c[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}y.dispatchEvent(n)}return function(t){t._dragging=!1,t._replotPending&&s.plot(t)}(x),x._dragged=!1,l.pauseEvent(e)}x._dragged=!1}var f,d,p,m,g,v,y,b,x=t.gd,_=1,w=u.DBLCLICKDELAY,M=t.element;x._mouseDownTime||(x._mouseDownTime=0),M.style.pointerEvents="all",M.onmousedown=e,M.ontouchstart=e},h.coverSlip=n},{"../../constants/interactions":716,"../../lib":738,"../../plotly":780,"../../plots/cartesian/constants":790,"./align":633,"./cursor":634,"./unhover":636,"has-hover":289,"mouse-event-offset":454}],636:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/get_graph_div"),o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){t=a(t),i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/events":726,"../../lib/get_graph_div":733,"../../lib/throttle":762,"../fx/constants":650}],637:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],638:[function(t,e,r){"use strict";function n(t,e){var r=t%100;return _.symbolFuncs[r](e)+(t>=200?k:"")}function i(t,e,r,n){var i=l.select(t.node().parentNode),a=-1!==e.indexOf("top")?"top":-1!==e.indexOf("bottom")?"bottom":"middle",o=-1!==e.indexOf("left")?"end":-1!==e.indexOf("right")?"start":"middle",s=n?n/.8+1:0,c=(m.lineCount(t)-1)*v+1,u=S[o]*s,h=.75*r+S[a]*s+(S[a]-1)*c*r/2;t.attr("text-anchor",o),i.attr("transform","translate("+u+","+h+")")}function a(t,e){var r=t.ts||e.textfont.size;return c(r)&&r>0?r:0}function o(t,e,r,n){var i=t[0]-e[0],a=t[1]-e[1],o=r[0]-e[0],s=r[1]-e[1],c=Math.pow(i*i+a*a,E/2),u=Math.pow(o*o+s*s,E/2),h=(u*u*i-c*c*o)*n,f=(u*u*a-c*c*s)*n,d=3*u*(c+u),p=3*c*(c+u);return[[l.round(e[0]+(d&&h/d),2),l.round(e[1]+(d&&f/d),2)],[l.round(e[0]-(p&&h/p),2),l.round(e[1]-(p&&f/p),2)]]}function s(t){var e=t.getAttribute("data-unformatted");if(null!==e)return e+t.getAttribute("data-math")+t.getAttribute("text-anchor")+t.getAttribute("style")}var l=t("d3"),c=t("fast-isnumeric"),u=t("tinycolor2"),h=t("../../registry"),f=t("../color"),d=t("../colorscale"),p=t("../../lib"),m=t("../../lib/svg_text_utils"),g=t("../../constants/xmlns_namespaces"),v=t("../../constants/alignment").LINE_SPACING,y=t("../../constants/interactions").DESELECTDIM,b=t("../../traces/scatter/subtypes"),x=t("../../traces/scatter/make_bubble_size_func"),_=e.exports={};_.font=function(t,e,r,n){p.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(f.fill,n)},_.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},_.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},_.setRect=function(t,e,r,n,i){t.call(_.setPosition,e,r).call(_.setSize,n,i)},_.translatePoint=function(t,e,r,n){var i=r.c2p(t.x),a=n.c2p(t.y);return!!(c(i)&&c(a)&&e.node())&&("text"===e.node().nodeName?e.attr("x",i).attr("y",a):e.attr("transform","translate("+i+","+a+")"),!0)},_.translatePoints=function(t,e,r){t.each(function(t){var n=l.select(this);_.translatePoint(t,n,e,r)})},_.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},_.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,n=e.yaxis;t.each(function(e){var i=e[0].trace,a=i.xcalendar,o=i.ycalendar;t.selectAll(".point,.textpoint").each(function(t){_.hideOutsideRangePoint(t,l.select(this),r,n,a,o)})})}},_.crispRound=function(t,e,r){return e&&c(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},_.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,s=i||a.dash||"";f.stroke(e,n||a.color),_.dashLine(e,s,o)},_.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var i=(((t||[])[0]||{}).trace||{}).line||{},a=e||i.width||0,o=n||i.dash||"";l.select(this).call(f.stroke,r||i.color).call(_.dashLine,o,a)})},_.dashLine=function(t,e,r){r=+r||0,e=_.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},_.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},_.singleFillStyle=function(t){var e=(((l.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(f.fill,e)},_.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=l.select(this);try{r.call(f.fill,e[0].trace.fillcolor)}catch(e){p.error(e,t),r.remove()}})};var w=t("./symbol_defs");_.symbolNames=[],_.symbolFuncs=[],_.symbolNeedLines={},_.symbolNoDot={},_.symbolList=[],Object.keys(w).forEach(function(t){var e=w[t];_.symbolList=_.symbolList.concat([e.n,t,e.n+100,t+"-open"]),_.symbolNames[e.n]=t,_.symbolFuncs[e.n]=e.f,e.needLine&&(_.symbolNeedLines[e.n]=!0),e.noDot?_.symbolNoDot[e.n]=!0:_.symbolList=_.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var M=_.symbolNames.length,k="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";_.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=_.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=M||t>=400?0:Math.floor(Math.max(t,0))};var T={x1:1,x2:0,y1:0,y2:0},A={x1:0,x2:0,y1:1,y2:0};_.gradient=function(t,e,r,n,i,a){var o=e._fullLayout._defs.select(".gradients").selectAll("#"+r).data([n+i+a],p.identity);o.exit().remove(),o.enter().append("radial"===n?"radialGradient":"linearGradient").each(function(){var t=l.select(this);"horizontal"===n?t.attr(T):"vertical"===n&&t.attr(A),t.attr("id",r);var e=u(i),o=u(a);t.append("stop").attr({offset:"0%","stop-color":f.tinyRGB(o),"stop-opacity":o.getAlpha()}),t.append("stop").attr({offset:"100%","stop-color":f.tinyRGB(e),"stop-opacity":e.getAlpha()})}),t.style({fill:"url(#"+r+")","fill-opacity":null})},_.initGradients=function(t){var e=t._fullLayout._defs.selectAll(".gradients").data([0]);e.enter().append("g").classed("gradients",!0),e.selectAll("linearGradient,radialGradient").remove()},_.singlePointStyle=function(t,e,r,i,a,o){var s=r.marker;!function(t,e,r,i,a,o,s,l){if(h.traceIs(r,"symbols")){var c=x(r);e.attr("d",function(t){var e;e="various"===t.ms||"various"===o.size?3:b.isBubble(r)?c(t.ms):(o.size||6)/2,t.mrc=e;var i=_.symbolNumber(t.mx||o.symbol)||0;return t.om=i%200>=100,n(i,e)})}e.style("opacity",function(t){return(t.mo+1||o.opacity+1)-1});var u,d,p,m=!1;if(t.so?(p=s.outlierwidth,d=s.outliercolor,u=o.outliercolor):(p=(t.mlw+1||s.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,d="mlc"in t?t.mlcc=a(t.mlc):Array.isArray(s.color)?f.defaultLine:s.color,Array.isArray(o.color)&&(u=f.defaultLine,m=!0),u="mc"in t?t.mcc=i(t.mc):o.color||"rgba(0,0,0,0)"),t.om)e.call(f.stroke,u).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",p+"px");var g=o.gradient,v=t.mgt;if(v?m=!0:v=g&&g.type,v&&"none"!==v){var y=t.mgc;y?m=!0:y=g.color;var w="g"+l._fullLayout._uid+"-"+r.uid;m&&(w+="-"+t.i),e.call(_.gradient,l,w,v,u,y)}else e.call(f.fill,u);p&&e.call(f.stroke,d)}}(t,e,r,i,a,s,s.line,o)},_.pointStyle=function(t,e,r){if(t.size()){var n=e.marker,i=_.tryColorscale(n,""),a=_.tryColorscale(n,"line");t.each(function(t){_.singlePointStyle(t,l.select(this),e,i,a,r)})}},_.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=e.selected||{},i=e.unselected||{},a=e.marker||{},o=r.marker||{},s=i.marker||{},c=a.opacity,u=o.opacity,d=s.opacity,p=void 0!==u,m=void 0!==d;t.each(function(t){var e,r=l.select(this),n=t.mo,i=void 0!==n;(i||p||m)&&(t.selected?p&&(e=u):e=m?d:y*(i?n:c)),void 0!==e&&r.style("opacity",e)});var g=o.color,v=s.color;(g||v)&&t.each(function(t){var e,r=l.select(this);t.selected?g&&(e=g):v&&(e=v),e&&f.fill(r,e)});var b=o.size,x=s.size,w=void 0!==b,M=void 0!==x;h.traceIs(e,"symbols")&&(w||M)&&t.each(function(t){var e,r=l.select(this),i=t.mrc,o=t.mx||a.symbol||0;e=t.selected?w?b/2:i:M?x/2:i,r.attr("d",n(_.symbolNumber(o),e)),t.mrc2=e})}},_.tryColorscale=function(t,e){var r=e?p.nestedProperty(t,e).get():t,n=r.colorscale,i=r.color;return n&&Array.isArray(i)?d.makeColorScaleFunc(d.extractScale(n,r.cmin,r.cmax)):p.identity};var S={start:1,end:-1,middle:0,bottom:1,top:-1};_.textPointStyle=function(t,e,r){t.each(function(t){var n=l.select(this),o=p.extractOption(t,e,"tx","text");if(o){var s=t.tp||e.textposition,c=a(t,e);n.call(_.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).text(o).call(m.convertToTspans,r).call(i,s,c,t.mrc)}else n.remove()})},_.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=e.selected||{},n=e.unselected||{};t.each(function(t){var o,s=l.select(this),c=t.tc||e.textfont.color,u=t.tp||e.textposition,h=a(t,e),d=(r.textfont||{}).color,p=(n.textfont||{}).color;t.selected?d&&(o=d):p?o=p:d||(o=f.addOpacity(c,y)),o&&f.fill(s,o),i(s,u,h,t.mrc2||t.mrc)})}};var E=.5;_.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(_.savedBBoxes={},C=0),r&&(_.savedBBoxes[r]=v),C++,p.extendFlat({},v)},_.setClipUrl=function(t,e){if(e){var r="#"+e,n=l.select("base");n.size()&&n.attr("href")&&(r=window.location.href.split("#")[0]+r),t.attr("clip-path","url("+r+")")}else t.attr("clip-path",null)},_.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||0,y:+e[1]||0}},_.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a+=" translate("+e+", "+r+")",a=a.trim(),t[i]("transform",a),a},_.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,function(t,e,r){return[e,r].join(" ")}).split(" ");return{x:+e[0]||1,y:+e[1]||1}},_.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a+=" scale("+e+", "+r+")",a=a.trim(),t[i]("transform",a),a},_.setPointGroupScale=function(t,e,r){var n,i,a;return e=e||1,r=r||1,i=1===e&&1===r?"":" scale("+e+","+r+")",a=/\s*sc.*/,t.each(function(){n=(this.getAttribute("transform")||"").replace(a,""),n=(n+=i).trim(),this.setAttribute("transform",n)}),i};var I=/translate\([^)]*\)\s*$/;_.setTextPointsScale=function(t,e,r){t.each(function(){var t,n=l.select(this),i=n.select("text");if(i.node()){var a=parseFloat(i.attr("x")||0),o=parseFloat(i.attr("y")||0),s=(n.attr("transform")||"").match(I);t=1===e&&1===r?[]:["translate("+a+","+o+")","scale("+e+","+r+")","translate("+-a+","+-o+")"],s&&t.push(s),n.attr("transform",t.join(" "))}})}},{"../../constants/alignment":711,"../../constants/interactions":716,"../../constants/xmlns_namespaces":719,"../../lib":738,"../../lib/svg_text_utils":761,"../../registry":861,"../../traces/scatter/make_bubble_size_func":1071,"../../traces/scatter/subtypes":1076,"../color":613,"../colorscale":628,"./symbol_defs":639,d3:123,"fast-isnumeric":132,tinycolor2:543}],639:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:123}],640:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],641:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=[];if(a.visible&&-1!==["linear","log"].indexOf(r.type)){for(var c=s(a),u=0;u0;t.each(function(t){var u,h=t[0].trace,f=h.error_x||{},d=h.error_y||{};h.ids&&(u=function(t){return t.id});var p=o.hasMarkers(h)&&h.marker.maxdisplayed>0;d.visible||f.visible||(t=[]);var m=n.select(this).selectAll("g.errorbar").data(t,u);if(m.exit().remove(),t.length){f.visible||m.selectAll("path.xerror").remove(),d.visible||m.selectAll("path.yerror").remove(),m.style("opacity",1);var g=m.enter().append("g").classed("errorbar",!0);c&&g.style("opacity",0).transition().duration(r.duration).style("opacity",1),a.setClipUrl(m,e.layerClipId),m.each(function(t){var e=n.select(this),a=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}(t,s,l);if(!p||t.vis){var o;if(d.visible&&i(a.x)&&i(a.yh)&&i(a.ys)){var u=d.width;o="M"+(a.x-u)+","+a.yh+"h"+2*u+"m-"+u+",0V"+a.ys,a.noYS||(o+="m-"+u+",0h"+2*u);var h=e.select("path.yerror");!h.size()?h=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0):c&&(h=h.transition().duration(r.duration).ease(r.easing)),h.attr("d",o)}if(f.visible&&i(a.y)&&i(a.xh)&&i(a.xs)){var m=(f.copy_ystyle?d:f).width;o="M"+a.xh+","+(a.y-m)+"v"+2*m+"m0,-"+m+"H"+a.xs,a.noXS||(o+="m0,-"+m+"v"+2*m);var g=e.select("path.xerror");!g.size()?g=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0):c&&(g=g.transition().duration(r.duration).ease(r.easing)),g.attr("d",o)}}})}})}},{"../../traces/scatter/subtypes":1076,"../drawing":638,d3:123,"fast-isnumeric":132}],646:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":613,d3:123}],647:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes");e.exports={hoverlabel:{bgcolor:{valType:"color",arrayOk:!0,editType:"none"},bordercolor:{valType:"color",arrayOk:!0,editType:"none"},font:n({arrayOk:!0,editType:"none"}),namelength:{valType:"integer",min:-1,arrayOk:!0,editType:"none"},editType:"calc"}}},{"../../plots/font_attributes":810}],648:[function(t,e,r){"use strict";function n(t,e,r,n){n=n||i.identity,Array.isArray(t)&&(e[0][r]=n(t))}var i=t("../../lib"),a=t("../../registry");e.exports=function(t){function e(t){return function(e){return i.coerceHoverinfo({hoverinfo:e},{_module:t._module},o)}}for(var r=t.calcdata,o=t._fullLayout,s=0;s=0&&r.indexK.width||J<0||J>K.height)return g.unhoverRaw(t,e)}if(z="xval"in e?b.flat(f,e.xval):b.p2c(S,Z),O="yval"in e?b.flat(f,e.yval):b.p2c(E,J),!l(z[0])||!l(O[0]))return u.warn("Fx.hover failed",e,t),g.unhoverRaw(t,e)}var Q=1/0;for(R=0;RY&&(W.splice(0,Y),Q=W[0].distance)}if(0===W.length)return g.unhoverRaw(t,e);W.sort(function(t,e){return t.distance-e.distance});var nt=t._hoverdata,it=[];for(F=0;F1,st=i(W,{hovermode:D,rotateLabels:ot,bgColor:m.combine(_.plot_bgcolor||m.background,_.paper_bgcolor),container:_._hoverlayer,outerContainer:_._paperdiv,commonLabelOpts:_.hoverlabel},t);if(function(t,e,r){function n(t){var e=t[0],r=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=r.pos+r.dp+r.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;i=!1}if(!(o<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=o;i=!1}if(i){var n=0;for(s=0;se.pmax&&n++;for(s=t.length-1;s>=0&&!(n<=0);s--)(c=t[s]).pos>e.pmax-1&&(c.del=!0,n--);for(s=0;s=0;l--)t[l].dp-=o;for(s=t.length-1;s>=0&&!(n<=0);s--)(c=t[s]).pos+c.dp+c.size>e.pmax&&(c.del=!0,n--)}}}var i,a,o,s,l,c,u,h=0,f=t.map(function(t,n){var i=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===i._id.charAt(0)?M:1)/2,pmin:0,pmax:"x"===i._id.charAt(0)?r.width:r.height}]}).sort(function(t,e){return t[0].posref-e[0].posref});for(;!i&&h<=t.length;){for(h++,i=!0,s=0;s.01&&m.pmin===g.pmin&&m.pmax===g.pmax){for(l=p.length-1;l>=0;l--)p[l].dp+=a;for(d.push.apply(d,p),f.splice(s+1,1),u=0,l=d.length-1;l>=0;l--)u+=d[l].dp;for(o=u/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;i=!1}else s++}f.forEach(n)}for(s=f.length-1;s>=0;s--){var v=f[s];for(l=v.length-1;l>=0;l--){var y=v[l],b=t[y.i];b.offset=y.dp,b.del=y.del}}}(W,ot?"xa":"ya",_),a(st,ot),e.target&&e.target.tagName){var lt=y.getComponentMethod("annotations","hasClickToShow")(t,it);d(s.select(e.target),lt?"pointer":"")}e.target&&!n&&o(t,e,nt)&&(nt&&t.emit("plotly_unhover",{event:e,points:nt}),t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:S,yaxes:E,xvals:z,yvals:O}))}function i(t,e,r){var n,i=e.hovermode,a=e.rotateLabels,o=e.bgColor,l=e.container,c=e.outerContainer,u=e.commonLabelOpts||{},h=e.fontFamily||x.HOVERFONT,d=e.fontSize||x.HOVERFONTSIZE,g=t[0],v=g.xa,y=g.ya,b="y"===i?"yLabel":"xLabel",w=g[b],M=(String(w)||"").split(" ")[0],k=c.node().getBoundingClientRect(),T=k.top,E=k.width,L=k.height,C=g.distance<=x.MAXDIST&&("x"===i||"y"===i);for(n=0;n-1&&n.length>v&&(n=v>3?n.substr(0,v-3)+"...":n.substr(0,v))}void 0!==t.extraText&&(l+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(l+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(l+="y: "+t.yLabel+"
"),l+=(l?"z: ":"")+t.zLabel):C&&t[i+"Label"]===w?l=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(l=t.yLabel):l=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(l+=(l?"
":"")+t.text),""===l&&(""===n&&e.remove(),l=n);var y=e.select("text.nums").call(p.font,t.fontFamily||h,t.fontSize||d,t.fontColor||g).text(l).attr("data-notex",1).call(f.positionText,0,0).call(f.convertToTspans,r),b=e.select("text.name"),x=0;n&&n!==l?(b.call(p.font,t.fontFamily||h,t.fontSize||d,u).text(n).attr("data-notex",1).call(f.positionText,0,0).call(f.convertToTspans,r),x=b.node().getBoundingClientRect().width+2*S):(b.remove(),e.select("rect").remove()),e.select("path").style({fill:u,stroke:g});var M,k,I=y.node().getBoundingClientRect(),P=t.xa._offset+(t.x0+t.x1)/2,D=t.ya._offset+(t.y0+t.y1)/2,z=Math.abs(t.x1-t.x0),O=Math.abs(t.y1-t.y0),F=I.width+A+S+x;t.ty0=T-I.top,t.bx=I.width+2*S,t.by=I.height+2*S,t.anchor="start",t.txwidth=I.width,t.tx2width=x,t.offset=0,a?(t.pos=P,M=D+O/2+F<=L,k=D-O/2-F>=0,"top"!==t.idealAlign&&M||!k?M?(D+=O/2,t.anchor="start"):t.anchor="middle":(D-=O/2,t.anchor="end")):(t.pos=D,M=P+z/2+F<=E,k=P-z/2-F>=0,"left"!==t.idealAlign&&M||!k?M?(P+=z/2,t.anchor="start"):t.anchor="middle":(P-=z/2,t.anchor="end")),y.attr("text-anchor",t.anchor),x&&b.attr("text-anchor",t.anchor),e.attr("transform","translate("+P+","+D+")"+(a?"rotate("+_+")":""))}),D}function a(t,e){t.each(function(t){var r=s.select(this);if(t.del)r.remove();else{var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(A+S),l=o+a*(t.txwidth+S),c=0,u=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,l-=t.tx2width/2),e&&(u*=-T,c=t.offset*k),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*A+c)+","+(A+u)+"v"+(t.by/2-A)+"h"+n*t.bx+"v-"+t.by+"H"+(n*A+c)+"V"+(u-A)+"Z"),i.call(f.positionText,o+c,u+t.ty0-t.by/2+S),t.tx2width&&(r.select("text.name").call(f.positionText,l+a*S+c,u+t.ty0-t.by/2+S),r.select("rect").call(p.setRect,l+(a-1)*t.tx2width/2+c,u-t.by/2-1,t.tx2width,t.by+2))}})}function o(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var s=t("d3"),l=t("fast-isnumeric"),c=t("tinycolor2"),u=t("../../lib"),h=t("../../lib/events"),f=t("../../lib/svg_text_utils"),d=t("../../lib/override_cursor"),p=t("../drawing"),m=t("../color"),g=t("../dragelement"),v=t("../../plots/cartesian/axes"),y=t("../../registry"),b=t("./helpers"),x=t("./constants"),_=x.YANGLE,w=Math.PI*_/180,M=1/Math.sin(w),k=Math.cos(w),T=Math.sin(w),A=x.HOVERARROWSIZE,S=x.HOVERTEXTPAD;r.hover=function(t,e,r,i){t=u.getGraphDiv(t),u.throttle(t._fullLayout._uid+x.HOVERID,x.HOVERMINTIME,function(){n(t,e,r,i)})},r.loneHover=function(t,e){var r={color:t.color||m.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,trace:{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0},n=s.select(e.container),o=e.outerContainer?s.select(e.outerContainer):n,l={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||m.background,container:n,outerContainer:o},c=i([r],l,e.gd);return a(c,l.rotateLabels),c.node()}},{"../../lib":738,"../../lib/events":726,"../../lib/override_cursor":749,"../../lib/svg_text_utils":761,"../../plots/cartesian/axes":785,"../../registry":861,"../color":613,"../dragelement":635,"../drawing":638,"./constants":650,"./helpers":652,d3:123,"fast-isnumeric":132,tinycolor2:543}],654:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r,i){r("hoverlabel.bgcolor",(i=i||{}).bgcolor),r("hoverlabel.bordercolor",i.bordercolor),r("hoverlabel.namelength",i.namelength),n.coerceFont(r,"hoverlabel.font",i.font)}},{"../../lib":738}],655:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../dragelement"),o=t("./helpers"),s=t("./layout_attributes");e.exports={moduleType:"component",name:"fx",constants:t("./constants"),schema:{layout:s},attributes:t("./attributes"),layoutAttributes:s,supplyLayoutGlobalDefaults:t("./layout_global_defaults"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),getDistanceFunction:o.getDistanceFunction,getClosest:o.getClosest,inbox:o.inbox,quadrature:o.quadrature,appendArrayPointValue:o.appendArrayPointValue,castHoverOption:function(t,e,r){return i.castOption(t,e,"hoverlabel."+r)},castHoverinfo:function(t,e,r){return i.castOption(t,r,"hoverinfo",function(r){return i.coerceHoverinfo({hoverinfo:r},{_module:t._module},e)})},hover:t("./hover").hover,unhover:a.unhover,loneHover:t("./hover").loneHover,loneUnhover:function(t){var e=i.isD3Selection(t)?t:n.select(t);e.selectAll("g.hovertext").remove(),e.selectAll(".spikeline").remove()},click:t("./click")}},{"../../lib":738,"../dragelement":635,"./attributes":647,"./calc":648,"./click":649,"./constants":650,"./defaults":651,"./helpers":652,"./hover":653,"./layout_attributes":656,"./layout_defaults":657,"./layout_global_defaults":658,d3:123}],656:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../plots/font_attributes")({editType:"none"});i.family.dflt=n.HOVERFONT,i.size.dflt=n.HOVERFONTSIZE,e.exports={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom",editType:"modebar"},hovermode:{valType:"enumerated",values:["x","y","closest",!1],editType:"modebar"},hoverlabel:{bgcolor:{valType:"color",editType:"none"},bordercolor:{valType:"color",editType:"none"},font:i,namelength:{valType:"integer",min:-1,dflt:15,editType:"none"},editType:"none"}}},{"../../plots/font_attributes":810,"./constants":650}],657:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}a("dragmode");var o;e._has("cartesian")?(e._isHoriz=function(t){for(var e=!0,r=0;r=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],665:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes");e.exports={bgcolor:{valType:"color",editType:"legend"},bordercolor:{valType:"color",dflt:i.defaultLine,editType:"legend"},borderwidth:{valType:"number",min:0,dflt:0,editType:"legend"},font:n({editType:"legend"}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v",editType:"legend"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"],editType:"legend"},tracegroupgap:{valType:"number",min:0,dflt:10,editType:"legend"},x:{valType:"number",min:-2,max:3,dflt:1.02,editType:"legend"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left",editType:"legend"},y:{valType:"number",min:-2,max:3,dflt:1,editType:"legend"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"legend"},editType:"legend"}},{"../../plots/font_attributes":810,"../color/attributes":612}],666:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],667:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("./attributes"),o=t("../../plots/layout_attributes"),s=t("./helpers");e.exports=function(t,e,r){function l(t,e){return i.coerce(d,p,a,t,e)}for(var c,u,h,f,d=t.legend||{},p=e.legend={},m=0,g="normal",v=0;v1)){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),i.coerceFont(l,"font",e.font),l("orientation"),"h"===p.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(c=0,h="left",u=1.1,f="bottom"):(c=0,h="left",u=-.1,f="top")}l("traceorder",g),s.isGrouped(e.legend)&&l("tracegroupgap"),l("x",c),l("xanchor",h),l("y",u),l("yanchor",f),i.noneOrAll(d,p,["x","y"])}}},{"../../lib":738,"../../plots/layout_attributes":837,"../../registry":861,"./attributes":665,"./helpers":671}],668:[function(t,e,r){"use strict";function n(t,e){function r(r){m.convertToTspans(r,e,function(){!function(t,e){var r=t.data()[0][0];if(!r.trace.showlegend)return void t.remove();var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.font.size*b;if(o){var l=d.bBox(o);n=l.height,i=l.width,d.setTranslate(a,0,n/4)}else{var c=t.select(".legendtext"),u=m.lineCount(c),h=c.node();n=s*u,i=h?d.bBox(h).width:0;var f=s*(.3+(1-u)/2);m.positionText(c,40,f)}n=Math.max(n,16)+3,r.height=n,r.width=i}(t,e)})}var n=t.data()[0][0],i=e._fullLayout,a=n.trace,o=h.traceIs(a,"pie"),s=a.index,u=o?n.label:a.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr("text-anchor","start").classed("user-select-none",!0).call(d.font,i.legend.font).text(u),e._context.edits.legendText&&!o?f.call(m.makeEditable,{gd:e}).call(r).on("edit",function(t){this.text(t).call(r);var i=t;this.text()||(t=" ");var a,o=n.trace._fullInput||{},u={};if(-1!==["ohlc","candlestick"].indexOf(o.type))u[(a=n.trace.transforms)[a.length-1].direction+".name"]=t;else if(h.hasTransform(o,"groupby")){var f=h.getTransformIndices(o,"groupby"),d=f[f.length-1],p=c.keyedContainer(o,"transforms["+d+"].styles","target","value.name");""===i?p.remove(n.trace._group):p.set(n.trace._group,t),u=p.constructUpdate()}else u.name=t;return l.restyle(e,u,s)}):f.call(r)}function i(t,e){var r,n=1,i=t.selectAll("rect").data([0]);i.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(p.fill,"rgba(0,0,0,0)"),i.on("mousedown",function(){(r=(new Date).getTime())-e._legendMouseDownTimek&&(n=Math.max(n-1,1)),1===n?r._clickTimeout=setTimeout(function(){g(t,e,n)},k):2===n&&(r._clickTimeout&&clearTimeout(r._clickTimeout),e._legendMouseDownTime=0,g(t,e,n))}})}function a(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=w.isGrouped(i),l=0;if(i.width=0,i.height=0,w.isVertical(i))o&&e.each(function(t,e){d.setTranslate(this,0,e*i.tracegroupgap)}),r.each(function(t){var e=t[0],r=e.height,n=e.width;d.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),l=40;else if(o){for(var c=[i.width],u=e.data(),h=0,f=u.length;ha+_-M,r.each(function(t){var e=t[0],r=g?40+t[0].width:b;a+x+M+r>n.width-(n.margin.r+n.margin.l)&&(x=0,v+=y,i.height=i.height+y,y=0),d.setTranslate(this,a+x,5+a+e.height/2+v),i.width+=M+r,i.height=Math.max(i.height,e.height),x+=M+r,y=Math.max(e.height,y)}),i.width+=2*a,i.height+=10+2*a}i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.each(function(e){var r=e[0];s.select(this).select(".legendtoggle").call(d.setRect,0,-r.height/2,(t._context.edits.legendText?0:i.width)+l,r.height)})}function o(t){var e=t._fullLayout.legend,r="left";M.isRightAnchor(e)?r="right":M.isCenterAnchor(e)&&(r="center");var n="top";M.isBottomAnchor(e)?n="bottom":M.isMiddleAnchor(e)&&(n="middle"),u.autoMargin(t,"legend",{x:e.x,y:e.y,l:e.width*({right:1,center:.5}[r]||0),r:e.width*({left:1,center:.5}[r]||0),b:e.height*({top:1,middle:.5}[n]||0),t:e.height*({bottom:1,middle:.5}[n]||0)})}var s=t("d3"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/plots"),h=t("../../registry"),f=t("../dragelement"),d=t("../drawing"),p=t("../color"),m=t("../../lib/svg_text_utils"),g=t("./handle_click"),v=t("./constants"),y=t("../../constants/interactions"),b=t("../../constants/alignment").LINE_SPACING,x=t("./get_legend_data"),_=t("./style"),w=t("./helpers"),M=t("./anchor_utils"),k=y.DBLCLICKDELAY;e.exports=function(t){function e(t,e){E.attr("data-scroll",e).call(d.setTranslate,0,e),L.call(d.setRect,j,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:y.borderwidth-e})}var r=t._fullLayout,m="legend"+r._uid;if(r._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var y=r.legend,b=r.showlegend&&x(t.calcdata,y),w=r.hiddenlabels||[];if(!r.showlegend||!b.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+m).remove(),void u.autoMargin(t,"legend");var T=r._infolayer.selectAll("g.legend").data([0]);T.enter().append("g").attr({class:"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+m).data([0]);A.enter().append("clipPath").attr("id",m).append("rect");var S=T.selectAll("rect.bg").data([0]);S.enter().append("rect").attr({class:"bg","shape-rendering":"crispEdges"}),S.call(p.stroke,y.bordercolor),S.call(p.fill,y.bgcolor),S.style("stroke-width",y.borderwidth+"px");var E=T.selectAll("g.scrollbox").data([0]);E.enter().append("g").attr("class","scrollbox");var L=T.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({class:"scrollbar",rx:20,ry:2,width:0,height:0}).call(p.fill,"#808BA4");var C=E.selectAll("g.groups").data(b);C.enter().append("g").attr("class","groups"),C.exit().remove();var I=C.selectAll("g.traces").data(c.identity);I.enter().append("g").attr("class","traces"),I.exit().remove(),I.call(_,t).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){s.select(this).call(n,t).call(i,t)});var P=0!==T.enter().size();P&&(a(t,C,I),o(t));var D=r.width,z=r.height;a(t,C,I),y.height>z?function(t){var e=t._fullLayout.legend,r="left";M.isRightAnchor(e)?r="right":M.isCenterAnchor(e)&&(r="center"),u.autoMargin(t,"legend",{x:e.x,y:.5,l:e.width*({right:1,center:.5}[r]||0),r:e.width*({left:1,center:.5}[r]||0),b:0,t:0})}(t):o(t);var O=r._size,F=O.l+O.w*y.x,R=O.t+O.h*(1-y.y);M.isRightAnchor(y)?F-=y.width:M.isCenterAnchor(y)&&(F-=y.width/2),M.isBottomAnchor(y)?R-=y.height:M.isMiddleAnchor(y)&&(R-=y.height/2);var j=y.width,N=O.w;j>N?(F=O.l,j=N):(F+j>D&&(F=D-j),F<0&&(F=0),j=Math.min(D-F,y.width));var B=y.height,U=O.h;B>U?(R=O.t,B=U):(R+B>z&&(R=z-B),R<0&&(R=0),B=Math.min(z-R,y.height)),d.setTranslate(T,F,R);var V,H,q=B-v.scrollBarHeight-2*v.scrollBarMargin,G=y.height-B;if(y.height<=B||t._context.staticPlot)S.attr({width:j-y.borderwidth,height:B-y.borderwidth,x:y.borderwidth/2,y:y.borderwidth/2}),d.setTranslate(E,0,0),A.select("rect").attr({width:j-2*y.borderwidth,height:B-2*y.borderwidth,x:y.borderwidth,y:y.borderwidth}),E.call(d.setClipUrl,m);else{V=v.scrollBarMargin,H=E.attr("data-scroll")||0,S.attr({width:j-2*y.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-y.borderwidth,x:y.borderwidth/2,y:y.borderwidth/2}),A.select("rect").attr({width:j-2*y.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-2*y.borderwidth,x:y.borderwidth,y:y.borderwidth-H}),E.call(d.setClipUrl,m),P&&e(V,H),T.on("wheel",null),T.on("wheel",function(){H=c.constrain(E.attr("data-scroll")-s.event.deltaY/q*G,-G,0),e(V=v.scrollBarMargin-H/G*q,H),0!==H&&H!==-G&&s.event.preventDefault()}),L.on(".drag",null),E.on(".drag",null);var Y=s.behavior.drag().on("drag",function(){V=c.constrain(s.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+q),H=-(V-v.scrollBarMargin)/q*G,e(V,H)});L.call(Y),E.call(Y)}if(t._context.edits.legendPosition){var W,X,Z,J;T.classed("cursor-move",!0),f.init({element:T.node(),gd:t,prepFn:function(){var t=d.getTranslate(T);Z=t.x,J=t.y},moveFn:function(t,e){var r=Z+t,n=J+e;d.setTranslate(T,r,n),W=f.align(r,0,O.l,O.l+O.w,y.xanchor),X=f.align(n,0,O.t+O.h,O.t,y.yanchor)},doneFn:function(){void 0!==W&&void 0!==X&&l.relayout(t,{"legend.x":W,"legend.y":X})},clickFn:function(e,n){var i=r._infolayer.selectAll("g.traces").filter(function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom});i.size()>0&&(1===e?T._clickTimeout=setTimeout(function(){g(i,t,e)},k):2===e&&(T._clickTimeout&&clearTimeout(T._clickTimeout),g(i,t,e)))}})}}}},{"../../constants/alignment":711,"../../constants/interactions":716,"../../lib":738,"../../lib/svg_text_utils":761,"../../plotly":780,"../../plots/plots":846,"../../registry":861,"../color":613,"../dragelement":635,"../drawing":638,"./anchor_utils":664,"./constants":666,"./get_legend_data":669,"./handle_click":670,"./helpers":671,"./style":673,d3:123}],669:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+h;l.push(n),s[n]=[[r]],h++}}var a,o,s={},l=[],c=!1,u={},h=0;for(a=0;ar[1])return r[1]}return i}function i(t){return t[0]}var s,c,u=t[0],h=u.trace,f=l.hasMarkers(h),d=l.hasText(h),p=l.hasLines(h);if(f||d||p){var m={},g={};f&&(m.mc=r("marker.color",i),m.mo=r("marker.opacity",a.mean,[.2,1]),m.ms=r("marker.size",a.mean,[2,16]),m.mlc=r("marker.line.color",i),m.mlw=r("marker.line.width",a.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),p&&(g.line={width:r("line.width",i,[0,10])}),d&&(m.tx="Aa",m.tp=r("textposition",i),m.ts=10,m.tc=r("textfont.color",i),m.tf=r("textfont.family",i)),s=[a.minExtend(u,m)],c=a.minExtend(h,g)}var v=n.select(this).select("g.legendpoints"),y=v.selectAll("path.scatterpts").data(f?s:[]);y.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),y.exit().remove(),y.call(o.pointStyle,c,e),f&&(s[0].mrc=3);var b=v.selectAll("g.pointtext").data(d?s:[]);b.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),b.exit().remove(),b.selectAll("text").call(o.textPointStyle,c,e)})}},{"../../lib":738,"../../registry":861,"../../traces/pie/style_one":1040,"../../traces/scatter/subtypes":1076,"../color":613,"../drawing":638,d3:123}],674:[function(t,e,r){"use strict";function n(t,e){var r,n,i=e.currentTarget,a=i.getAttribute("data-attr"),o=i.getAttribute("data-val")||!0,s=t._fullLayout,l={},c=f.list(t,null,!0),h="on";if("zoom"===a){var d,p="in"===o?.5:2,m=(1+p)/2,g=(1-p)/2;for(n=0;n1)return n(["resetViews","toggleHover"]),i(y,r);f&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"]));var b=function(t){for(var e=a.list({_fullLayout:t},null,!0),r=0;r0)){var d=function(t,e,r){for(var n=r.filter(function(r){return e[r].anchor===t._id}),i=0,a=0;ad&&(d=h)));return d>=f?[f,d]:void 0}}var i=t("../../lib"),a=t("../../plots/cartesian/axes"),o=t("./constants"),s=t("./helpers");e.exports=function(t){var e=t._fullLayout,r=i.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var s=0;sq&&n>G&&!t.shiftKey?h.getCursor(i/r,1-a/n):"move";f(e,o),H=o.split("-")[0]}function c(n,o){if("path"===r.type){var s=function(t){return U(N(t)+n)};R&&"date"===R.type&&(s=p.encodeDate(s));var l=function(t){return V(B(t)+o)};j&&"date"===j.type&&(l=p.encodeDate(l)),r.path=a(O,s,l),d[F]=r.path}else d[b]=r.x0=U(m+n),d[x]=r.y0=V(g+o),d[_]=r.x1=U(v+n),d[w]=r.y1=V(y+o);e.attr("d",i(t,r))}function u(n,o){if("path"===r.type){var s=function(t){return U(N(t)+n)};R&&"date"===R.type&&(s=p.encodeDate(s));var l=function(t){return V(B(t)+o)};j&&"date"===j.type&&(l=p.encodeDate(l)),r.path=a(O,s,l),d[F]=r.path}else{var c=~H.indexOf("n")?M+o:M,u=~H.indexOf("s")?k+o:k,h=~H.indexOf("w")?T+n:T,f=~H.indexOf("e")?A+n:A;u-c>G&&(d[S]=r[I]=V(c),d[E]=r[P]=V(u)),f-h>q&&(d[L]=r[D]=U(h),d[C]=r[z]=U(f))}e.attr("d",i(t,r))}var d,m,g,v,y,b,x,_,w,M,k,T,A,S,E,L,C,I,P,D,z,O,F,R,j,N,B,U,V,H,q=10,G=10,Y={element:e.node(),gd:t,prepFn:function(e){R=l.getFromId(t,r.xref),j=l.getFromId(t,r.yref),N=p.getDataToPixel(t,R),B=p.getDataToPixel(t,j,!0),U=p.getPixelToData(t,R),V=p.getPixelToData(t,j,!0);var i="shapes["+n+"]";"path"===r.type?(O=r.path,F=i+".path"):(m=N(r.x0),g=B(r.y0),v=N(r.x1),y=B(r.y1),b=i+".x0",x=i+".y0",_=i+".x1",w=i+".y1");ml&&(t="X"),t});return n>l&&(c=c.replace(/[\s,]*X.*/,""),s.log("Ignoring extra params in segment "+t)),i+c})}(e.path,n,a);var f=n(e.x0),m=n(e.x1),g=a(e.y0),v=a(e.y1);if("line"===o)return"M"+f+","+g+"L"+m+","+v;if("rect"===o)return"M"+f+","+g+"H"+m+"V"+v+"H"+f+"Z";var y=(f+m)/2,b=(g+v)/2,x=Math.abs(y-f),_=Math.abs(b-g),w="A"+x+","+_,M=y+x+","+b;return"M"+M+w+" 0 1,1 "+(y+","+(b-_))+w+" 0 0,1 "+M+"Z"}function a(t,e,r){return t.replace(d.segmentRE,function(t){var n=0,i=t.charAt(0),a=d.paramIsX[i],o=d.paramIsY[i],s=d.numParams[i];return i+t.substr(1).replace(d.paramRE,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)})})}var o=t("../../plotly"),s=t("../../lib"),l=t("../../plots/cartesian/axes"),c=t("../color"),u=t("../drawing"),h=t("../dragelement"),f=t("../../lib/setcursor"),d=t("./constants"),p=t("./helpers");e.exports={draw:function(t){var e=t._fullLayout;e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._shapeSubplotLayers.selectAll("path").remove();for(var r=0;r0)){n("active"),n("x"),n("y"),i.noneOrAll(t,e,["x","y"]),n("xanchor"),n("yanchor"),n("len"),n("lenmode"),n("pad.t"),n("pad.r"),n("pad.b"),n("pad.l"),i.coerceFont(n,"font",r.font);n("currentvalue.visible")&&(n("currentvalue.xanchor"),n("currentvalue.prefix"),n("currentvalue.suffix"),n("currentvalue.offset"),i.coerceFont(n,"currentvalue.font",e.font)),n("transition.duration"),n("transition.easing"),n("bgcolor"),n("activebgcolor"),n("bordercolor"),n("borderwidth"),n("ticklen"),n("tickwidth"),n("tickcolor"),n("minorticklen")}}var i=t("../../lib"),a=t("../../plots/array_container_defaults"),o=t("./attributes"),s=t("./constants").name,l=o.steps;e.exports=function(t,e){a(t,e,{name:s,handleItemDefaults:n})}},{"../../lib":738,"../../plots/array_container_defaults":782,"./attributes":699,"./constants":700}],702:[function(t,e,r){"use strict";function n(t){return t._index}function i(t,e,r){if(e.currentvalue.visible){var n,i,a=t.selectAll("text").data([0]);switch(e.currentvalue.xanchor){case"right":n=e.inputAreaLength-M.currentValueInset-e.currentValueMaxWidth,i="left";break;case"center":n=.5*e.inputAreaLength,i="middle";break;default:n=M.currentValueInset,i="left"}a.enter().append("text").classed(M.labelClass,!0).classed("user-select-none",!0).attr({"text-anchor":i,"data-notex":1});var o=e.currentvalue.prefix?e.currentvalue.prefix:"";if("string"==typeof r)o+=r;else{o+=e.steps[e.active].label}e.currentvalue.suffix&&(o+=e.currentvalue.suffix),a.call(x.font,e.currentvalue.font).text(o).call(_.convertToTspans,e.gd);var s=_.lineCount(a),l=(e.currentValueMaxLines+1-s)*e.currentvalue.font.size*k;return _.positionText(a,n,l),a}}function a(t,e,r){var n=t.selectAll("rect."+M.gripRectClass).data([0]);n.enter().append("rect").classed(M.gripRectClass,!0).call(u,e,t,r).style("pointer-events","all"),n.attr({width:M.gripWidth,height:M.gripHeight,rx:M.gripRadius,ry:M.gripRadius}).call(b.stroke,r.bordercolor).call(b.fill,r.bgcolor).style("stroke-width",r.borderwidth+"px")}function o(t,e,r){var n=t.selectAll("text").data([0]);return n.enter().append("text").classed(M.labelClass,!0).classed("user-select-none",!0).attr({"text-anchor":"middle","data-notex":1}),n.call(x.font,r.font).text(e.step.label).call(_.convertToTspans,r.gd),n}function s(t,e){var r=t.selectAll("g."+M.labelsClass).data([0]);r.enter().append("g").classed(M.labelsClass,!0);var n=r.selectAll("g."+M.labelGroupClass).data(e.labelSteps);n.enter().append("g").classed(M.labelGroupClass,!0),n.exit().remove(),n.each(function(t){var r=v.select(this);r.call(o,t,e),x.setTranslate(r,d(e,t.fraction),M.tickOffset+e.ticklen+e.font.size*k+M.labelOffset+e.currentValueTotalHeight)})}function l(t,e,r,n,i){var a=Math.round(n*(r.steps.length-1));a!==r.active&&c(t,e,r,a,!0,i)}function c(t,e,r,n,a,o){var s=r.active;r._input.active=r.active=n;var l=r.steps[r.active];e.call(f,r,r.active/(r.steps.length-1),o),e.call(i,r),t.emit("plotly_sliderchange",{slider:r,step:r.steps[r.active],interaction:a,previousActive:s}),l&&l.method&&a&&(e._nextMethod?(e._nextMethod.step=l,e._nextMethod.doCallback=a,e._nextMethod.doTransition=o):(e._nextMethod={step:l,doCallback:a,doTransition:o},e._nextMethodRaf=window.requestAnimationFrame(function(){var r=e._nextMethod.step;r.method&&(r.execute&&y.executeAPICommand(t,r.method,r.args),e._nextMethod=null,e._nextMethodRaf=null)})))}function u(t,e,r){function n(){return r.data()[0]}var i=r.node(),a=v.select(e);t.on("mousedown",function(){var t=n();e.emit("plotly_sliderstart",{slider:t});var o=r.select("."+M.gripRectClass);v.event.stopPropagation(),v.event.preventDefault(),o.call(b.fill,t.activebgcolor);var s=p(t,v.mouse(i)[0]);l(e,r,t,s,!0),t._dragging=!0,a.on("mousemove",function(){var t=n(),a=p(t,v.mouse(i)[0]);l(e,r,t,a,!1)}),a.on("mouseup",function(){var t=n();t._dragging=!1,o.call(b.fill,t.bgcolor),a.on("mouseup",null),a.on("mousemove",null),e.emit("plotly_sliderend",{slider:t,step:t.steps[t.active]})})})}function h(t,e){var r=t.selectAll("rect."+M.tickRectClass).data(e.steps);r.enter().append("rect").classed(M.tickRectClass,!0),r.exit().remove(),r.attr({width:e.tickwidth+"px","shape-rendering":"crispEdges"}),r.each(function(t,r){var n=r%e.labelStride==0,i=v.select(this);i.attr({height:n?e.ticklen:e.minorticklen}).call(b.fill,e.tickcolor),x.setTranslate(i,d(e,r/(e.steps.length-1))-.5*e.tickwidth,(n?M.tickOffset:M.minorTickOffset)+e.currentValueTotalHeight)})}function f(t,e,r,n){var i=t.select("rect."+M.gripRectClass),a=d(e,r);if(!e._invokingCommand){var o=i;n&&e.transition.duration>0&&(o=o.transition().duration(e.transition.duration).ease(e.transition.easing)),o.attr("transform","translate("+(a-.5*M.gripWidth)+","+e.currentValueTotalHeight+")")}}function d(t,e){return t.inputAreaStart+M.stepInset+(t.inputAreaLength-2*M.stepInset)*Math.min(1,Math.max(0,e))}function p(t,e){return Math.min(1,Math.max(0,(e-M.stepInset-t.inputAreaStart)/(t.inputAreaLength-2*M.stepInset-2*t.inputAreaStart)))}function m(t,e,r){var n=t.selectAll("rect."+M.railTouchRectClass).data([0]);n.enter().append("rect").classed(M.railTouchRectClass,!0).call(u,e,t,r).style("pointer-events","all"),n.attr({width:r.inputAreaLength,height:Math.max(r.inputAreaWidth,M.tickOffset+r.ticklen+r.labelHeight)}).call(b.fill,r.bgcolor).attr("opacity",0),x.setTranslate(n,0,r.currentValueTotalHeight)}function g(t,e){var r=t.selectAll("rect."+M.railRectClass).data([0]);r.enter().append("rect").classed(M.railRectClass,!0);var n=e.inputAreaLength-2*M.railInset;r.attr({width:n,height:M.railWidth,rx:M.railRadius,ry:M.railRadius,"shape-rendering":"crispEdges"}).call(b.stroke,e.bordercolor).call(b.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),x.setTranslate(r,M.railInset,.5*(e.inputAreaWidth-M.railWidth)+e.currentValueTotalHeight)}var v=t("d3"),y=t("../../plots/plots"),b=t("../color"),x=t("../drawing"),_=t("../../lib/svg_text_utils"),w=t("../legend/anchor_utils"),M=t("./constants"),k=t("../../constants/alignment").LINE_SPACING;e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[M.name],n=[],i=0;i0?[0]:[]);if(l.enter().append("g").classed(M.containerClassName,!0).style("cursor","ew-resize"),l.exit().remove(),l.exit().size()&&function(t){for(var e=t._fullLayout._pushmargin||{},r=Object.keys(e),n=0;n=r.steps.length&&(r.active=0),e.call(i,r).call(g,r).call(s,r).call(h,r).call(m,t,r).call(a,t,r),x.setTranslate(e,r.lx+r.pad.l,r.ly+r.pad.t),e.call(f,r,r.active/(r.steps.length-1),!1),e.call(i,r)}(t,v.select(this),e)}})}}},{"../../constants/alignment":711,"../../lib/svg_text_utils":761,"../../plots/plots":846,"../color":613,"../drawing":638,"../legend/anchor_utils":664,"./constants":700,d3:123}],703:[function(t,e,r){"use strict";var n=t("./constants");e.exports={moduleType:"component",name:n.name,layoutAttributes:t("./attributes"),supplyLayoutDefaults:t("./defaults"),draw:t("./draw")}},{"./attributes":699,"./constants":700,"./defaults":701,"./draw":702}],704:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plotly"),o=t("../../plots/plots"),s=t("../../lib"),l=t("../drawing"),c=t("../color"),u=t("../../lib/svg_text_utils"),h=t("../../constants/interactions"),f=/ [XY][0-9]* /;(e.exports={}).draw=function(t,e,r){function d(t){s.syncOrAsync([p,m],t)}function p(e){return e.attr("transform",M?"rotate("+[M.rotate,w.x,w.y]+") translate(0, "+M.offset+")":null),e.style({"font-family":A,"font-size":n.round(S,2)+"px",fill:c.rgb(E),opacity:L*c.opacity(E),"font-weight":o.fontWeight}).attr(w).call(u.convertToTspans,t),o.previousPromises(t)}function m(t){var e=n.select(t.node().parentNode);if(_&&_.selection&&_.side&&I){e.attr("transform",null);var r=0,a={left:"right",right:"left",top:"bottom",bottom:"top"}[_.side],o=-1!==["left","top"].indexOf(_.side)?-1:1,c=i(_.pad)?_.pad:2,u=l.bBox(e.node()),h={left:0,top:0,right:T.width,bottom:T.height},f=_.maxShift||(h[_.side]-u[_.side])*("left"===_.side||"top"===_.side?-1:1);if(f<0)r=f;else{var d=_.offsetLeft||0,p=_.offsetTop||0;u.left-=d,u.right-=d,u.top-=p,u.bottom-=p,_.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[_.side]-u[a])+c))}),r=Math.min(f,r)}if(r>0||f<0){var m={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[_.side];e.attr("transform","translate("+m+")")}}}var g,v=r.propContainer,y=r.propName,b=r.placeholder,x=r.traceIndex,_=r.avoid||{},w=r.attributes,M=r.transform,k=r.containerGroup,T=t._fullLayout,A=v.titlefont.family,S=v.titlefont.size,E=v.titlefont.color,L=1,C=!1,I=v.title.trim();"title"===y?g="titleText":-1!==y.indexOf("axis")?g="axisTitleText":y.indexOf(!0)&&(g="colorbarTitleText");var P=t._context.edits[g];""===I?L=0:I.replace(f," % ")===b.replace(f," % ")&&(L=.2,C=!0,P||(I=""));var D=I||P;k||(k=T._infolayer.selectAll(".g-"+e).data([0])).enter().append("g").classed("g-"+e,!0);var z=k.selectAll("text").data(D?[0]:[]);z.enter().append("text"),z.text(I).attr("class",e),z.exit().remove(),D&&(z.call(d),P&&(I?z.on(".opacity",null):(L=0,C=!0,z.text(b).on("mouseover.opacity",function(){n.select(this).transition().duration(h.SHOW_PLACEHOLDER).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(h.HIDE_PLACEHOLDER).style("opacity",0)})),z.call(u.makeEditable,{gd:t}).on("edit",function(e){void 0!==x?a.restyle(t,y,e,x):a.relayout(t,y,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(d)}).on("input",function(t){this.text(t||" ").call(u.positionText,w.x,w.y)})),z.classed("js-placeholder",C))}},{"../../constants/interactions":716,"../../lib":738,"../../lib/svg_text_utils":761,"../../plotly":780,"../../plots/plots":846,"../color":613,"../drawing":638,d3:123,"fast-isnumeric":132}],705:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes");e.exports=o({_isLinkedToArray:"updatemenu",_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:{_isLinkedToArray:"button",method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}},x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a({},s,{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}},"arraydraw","from-root")},{"../../lib/extend":727,"../../plot_api/edit_types":769,"../../plots/font_attributes":810,"../../plots/pad_attributes":845,"../color/attributes":612}],706:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"\u25c4",right:"\u25ba",up:"\u25b2",down:"\u25bc"}}},{}],707:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return i.coerce(t,e,o,r,n)}n("visible",function(t,e){function r(t,e){return i.coerce(n,a,l,t,e)}var n,a,o=t.buttons||[],s=e.buttons=[];for(var c=0;c0)&&(n("active"),n("direction"),n("type"),n("showactive"),n("x"),n("y"),i.noneOrAll(t,e,["x","y"]),n("xanchor"),n("yanchor"),n("pad.t"),n("pad.r"),n("pad.b"),n("pad.l"),i.coerceFont(n,"font",r.font),n("bgcolor",r.paper_bgcolor),n("bordercolor"),n("borderwidth"))}var i=t("../../lib"),a=t("../../plots/array_container_defaults"),o=t("./attributes"),s=t("./constants").name,l=o.buttons;e.exports=function(t,e){a(t,e,{name:s,handleItemDefaults:n})}},{"../../lib":738,"../../plots/array_container_defaults":782,"./attributes":705,"./constants":706}],708:[function(t,e,r){"use strict";function n(t){return t._index}function i(t,e){return+t.attr(M.menuIndexAttrName)===e._index}function a(t,e,r,n,i,a,l,c){e._input.active=e.active=l,"buttons"===e.type?s(t,n,null,null,e):"dropdown"===e.type&&(i.attr(M.menuIndexAttrName,"-1"),o(t,n,i,a,e),c||s(t,n,i,a,e))}function o(t,e,r,n,a){var o=e.selectAll("g."+M.headerClassName).data([0]);o.enter().append("g").classed(M.headerClassName,!0).style("pointer-events","all");var c=a.active,u=a.buttons[c]||M.blankHeaderOpts,h={y:a.pad.t,yPad:0,x:a.pad.l,xPad:0,index:0},g={width:a.headerWidth,height:a.headerHeight};o.call(l,a,u,t).call(p,a,h,g);var v=e.selectAll("text."+M.headerArrowClassName).data([0]);v.enter().append("text").classed(M.headerArrowClassName,!0).classed("user-select-none",!0).attr("text-anchor","end").call(b.font,a.font).text(M.arrowSymbol[a.direction]),v.attr({x:a.headerWidth-M.arrowOffsetX+a.pad.l,y:a.headerHeight/2+M.textOffsetY+a.pad.t}),o.on("click",function(){r.call(m),r.attr(M.menuIndexAttrName,i(r,a)?-1:String(a._index)),s(t,e,r,n,a)}),o.on("mouseover",function(){o.call(f)}),o.on("mouseout",function(){o.call(d,a)}),b.setTranslate(e,a.lx,a.ly)}function s(t,e,r,n,i){r||(r=e).attr("pointer-events","all");var o=function(t){return-1==+t.attr(M.menuIndexAttrName)}(r)&&"buttons"!==i.type?[]:i.buttons,s="dropdown"===i.type?M.dropdownButtonClassName:M.buttonClassName,c=r.selectAll("g."+s).data(o),u=c.enter().append("g").classed(s,!0),m=c.exit();"dropdown"===i.type?(u.attr("opacity","0").transition().attr("opacity","1"),m.transition().attr("opacity","0").remove()):m.remove();var y=0,b=0,x=-1!==["up","down"].indexOf(i.direction);"dropdown"===i.type&&(x?b=i.headerHeight+M.gapButtonHeader:y=i.headerWidth+M.gapButtonHeader),"dropdown"===i.type&&"up"===i.direction&&(b=-M.gapButtonHeader+M.gapButton-i.openHeight),"dropdown"===i.type&&"left"===i.direction&&(y=-M.gapButtonHeader+M.gapButton-i.openWidth);var _={x:i.lx+y+i.pad.l,y:i.ly+b+i.pad.t,yPad:M.gapButton,xPad:M.gapButton,index:0},w={l:_.x+i.borderwidth,t:_.y+i.borderwidth};c.each(function(o,s){var u=g.select(this);u.call(l,i,o,t).call(p,i,_),u.on("click",function(){g.event.defaultPrevented||(a(t,i,0,e,r,n,s),o.execute&&v.executeAPICommand(t,o.method,o.args),t.emit("plotly_buttonclicked",{menu:i,button:o,active:i.active}))}),u.on("mouseover",function(){u.call(f)}),u.on("mouseout",function(){u.call(d,i),c.call(h,i)})}),c.call(h,i),x?(w.w=Math.max(i.openWidth,i.headerWidth),w.h=_.y-w.t):(w.w=_.x-w.l,w.h=Math.max(i.openHeight,i.headerHeight)),w.direction=i.direction,n&&(c.size()?function(t,e,r,n,i,a){var o,s,l,c=i.direction,u="up"===c||"down"===c,h=i.active;if(u)for(s=0,l=0;l0?[0]:[]);if(c.enter().append("g").classed(M.containerClassName,!0).style("cursor","pointer"),c.exit().remove(),c.exit().size()&&function(t){for(var e=t._fullLayout._pushmargin||{},r=Object.keys(e),n=0;nw,T=n.barLength+2*n.barPad,A=n.barWidth+2*n.barPad,S=p,E=g+v;E+A>c&&(E=c-A);var L=this.container.selectAll("rect.scrollbar-horizontal").data(k?[0]:[]);L.exit().on(".drag",null).remove(),L.enter().append("rect").classed("scrollbar-horizontal",!0).call(a.fill,n.barColor),k?(this.hbar=L.attr({rx:n.barRadius,ry:n.barRadius,x:S,y:E,width:T,height:A}),this._hbarXMin=S+T/2,this._hbarTranslateMax=w-T):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var C=v>M,I=n.barWidth+2*n.barPad,P=n.barLength+2*n.barPad,D=p+m,z=g;D+I>l&&(D=l-I);var O=this.container.selectAll("rect.scrollbar-vertical").data(C?[0]:[]);O.exit().on(".drag",null).remove(),O.enter().append("rect").classed("scrollbar-vertical",!0).call(a.fill,n.barColor),C?(this.vbar=O.attr({rx:n.barRadius,ry:n.barRadius,x:D,y:z,width:I,height:P}),this._vbarYMin=z+P/2,this._vbarTranslateMax=M-P):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var F=this.id,R=u-.5,j=C?h+I+.5:h+.5,N=f-.5,B=k?d+A+.5:d+.5,U=s._topdefs.selectAll("#"+F).data(k||C?[0]:[]);if(U.exit().remove(),U.enter().append("clipPath").attr("id",F).append("rect"),k||C?(this._clipRect=U.select("rect").attr({x:Math.floor(R),y:Math.floor(N),width:Math.ceil(j)-Math.floor(R),height:Math.ceil(B)-Math.floor(N)}),this.container.call(o.setClipUrl,F),this.bg.attr({x:p,y:g,width:m,height:v})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(o.setClipUrl,null),delete this._clipRect),k||C){var V=i.behavior.drag().on("dragstart",function(){i.event.sourceEvent.preventDefault()}).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(V);var H=i.behavior.drag().on("dragstart",function(){i.event.sourceEvent.preventDefault(),i.event.sourceEvent.stopPropagation()}).on("drag",this._onBarDrag.bind(this));k&&this.hbar.on(".drag",null).call(H),C&&this.vbar.on(".drag",null).call(H)}this.setTranslate(e,r)},n.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(o.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},n.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=i.event.dx),this.vbar&&(e-=i.event.dy),this.setTranslate(t,e)},n.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=i.event.deltaY),this.vbar&&(e+=i.event.deltaY),this.setTranslate(t,e)},n.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,n=r+this._hbarTranslateMax;t=(s.constrain(i.event.x,r,n)-r)/(n-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,o=a+this._vbarTranslateMax;e=(s.constrain(i.event.y,a,o)-a)/(o-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},n.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=s.constrain(t||0,0,r),e=s.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(o.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(o.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var a=e/n;this.vbar.call(o.setTranslate,t,e+a*this._vbarTranslateMax)}}},{"../../lib":738,"../color":613,"../drawing":638,d3:123}],711:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},LINE_SPACING:1.3,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],712:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],713:[function(t,e,r){"use strict";for(var n=t("../lib/extend").extendFlat,i={circle:{unicode:"\u25cf"},square:{unicode:"\u25a0"},diamond:{unicode:"\u25c6"},cross:{unicode:"\u271a"},x:{unicode:"\u274c"},"triangle-up":{unicode:"\u25b2"},"triangle-down":{unicode:"\u25bc"},"triangle-left":{unicode:"\u25c4"},"triangle-right":{unicode:"\u25ba"},"triangle-ne":{unicode:"\u25e5"},"triangle-nw":{unicode:"\u25e4"},"triangle-se":{unicode:"\u25e2"},"triangle-sw":{unicode:"\u25e3"},pentagon:{unicode:"\u2b1f"},hexagon:{unicode:"\u2b22"},hexagon2:{unicode:"\u2b23"},star:{unicode:"\u2605"},"diamond-tall":{unicode:"\u2666"},bowtie:{unicode:"\u29d3"},"diamond-x":{unicode:"\u2756"},"cross-thin":{unicode:"+",noBorder:!0},asterisk:{unicode:"\u2733",noBorder:!0},"y-up":{unicode:"\u2144",noBorder:!0},"y-down":{unicode:"Y",noBorder:!0},"line-ew":{unicode:"\u2500",noBorder:!0},"line-ns":{unicode:"\u2502",noBorder:!0}},a={},o=Object.keys(i),s=0;s","#62":">",nbsp:"\xa0","#160":"\xa0",times:"\xd7","#215":"\xd7",plusmn:"\xb1","#177":"\xb1",deg:"\xb0","#176":"\xb0"}}},{}],719:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],720:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.32.0",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config"),r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.update=n.update,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=t("./plot_api/register"),r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.validate=t("./plot_api/validate"),r.addFrames=n.addFrames,r.deleteFrames=n.deleteFrames,r.animate=n.animate,r.register(t("./traces/scatter")),r.register([t("./components/fx"),t("./components/legend"),t("./components/annotations"),t("./components/annotations3d"),t("./components/shapes"),t("./components/images"),t("./components/updatemenus"),t("./components/sliders"),t("./components/rangeslider"),t("./components/rangeselector")]),r.register([t("./locale-en"),t("./locale-en-us")]),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=t("./components/fx"),r.Snapshot=t("./snapshot"),r.PlotSchema=t("./plot_api/plot_schema"),r.Queue=t("./lib/queue"),r.d3=t("d3")},{"../build/plotcss":1,"../build/ploticon":2,"./components/annotations":604,"./components/annotations3d":609,"./components/fx":655,"./components/images":663,"./components/legend":672,"./components/rangeselector":684,"./components/rangeslider":690,"./components/shapes":697,"./components/sliders":703,"./components/updatemenus":709,"./fonts/mathjax_config":721,"./lib/queue":752,"./locale-en":767,"./locale-en-us":766,"./plot_api/plot_schema":774,"./plot_api/register":775,"./plot_api/set_plot_config":776,"./plot_api/to_image":778,"./plot_api/validate":779,"./plotly":780,"./snapshot":866,"./snapshot/download":863,"./traces/scatter":1066,d3:123,"es6-promise":129}],721:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],722:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../constants/numerical").BADNUM,a=/^['"%,$#\s']+|[, ]|['"%,$#\s']+$/g;e.exports=function(t){return"string"==typeof t&&(t=t.replace(a,"")),n(t)?Number(t):i}},{"../constants/numerical":717,"fast-isnumeric":132}],723:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("../plots/attributes"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),t("./nested_property")),l=t("./regex").counter,c=t("../constants/interactions").DESELECTDIM;r.valObjectMeta={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)},validateFunction:function(t,e){e.coerceNumber&&(t=+t);for(var r=e.values,n=0;ni.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every(function(t){return i(t).isValid()})?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){"string"==typeof t&&l(r).test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!l(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a0&&(a=a.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+a}return n}function s(t){return t.formatDate("yyyy")}var l=t("d3"),c=t("fast-isnumeric"),u=t("./loggers"),h=t("./mod"),f=t("../constants/numerical"),d=f.BADNUM,p=f.ONEDAY,m=f.ONEHOUR,g=f.ONEMIN,v=f.ONESEC,y=f.EPOCHJD,b=t("../registry"),x=l.time.format.utc,_=/^\s*(-?\d\d\d\d|\d\d)(-(\d?\d)(-(\d?\d)([ Tt]([01]?\d|2[0-3])(:([0-5]\d)(:([0-5]\d(\.\d+)?))?(Z|z|[+\-]\d\d:?\d\d)?)?)?)?)?\s*$/m,w=/^\s*(-?\d\d\d\d|\d\d)(-(\d?\di?)(-(\d?\d)([ Tt]([01]?\d|2[0-3])(:([0-5]\d)(:([0-5]\d(\.\d+)?))?(Z|z|[+\-]\d\d:?\d\d)?)?)?)?)?\s*$/m,M=(new Date).getFullYear()-70;r.dateTick0=function(t,e){return n(t)?e?b.getComponentMethod("calendars","CANONICAL_SUNDAY")[t]:b.getComponentMethod("calendars","CANONICAL_TICK")[t]:e?"2000-01-02":"2000-01-01"},r.dfltRange=function(t){return n(t)?b.getComponentMethod("calendars","DFLTRANGE")[t]:["2000-01-01","2001-01-01"]},r.isJSDate=function(t){return"object"==typeof t&&null!==t&&"function"==typeof t.getTime};var k,T;r.dateTime2ms=function(t,e){if(r.isJSDate(t))return(t=Number(t)-t.getTimezoneOffset()*g)>=k&&t<=T?t:d;if("string"!=typeof t&&"number"!=typeof t)return d;t=String(t);var i=n(e),a=t.charAt(0);!i||"G"!==a&&"g"!==a||(t=t.substr(1),e="");var o=i&&"chinese"===e.substr(0,7),s=t.match(o?w:_);if(!s)return d;var l=s[1],c=s[3]||"1",u=Number(s[5]||1),h=Number(s[7]||0),f=Number(s[9]||0),x=Number(s[11]||0);if(i){if(2===l.length)return d;l=Number(l);var A;try{var S=b.getComponentMethod("calendars","getCal")(e);if(o){var E="i"===c.charAt(c.length-1);c=parseInt(c,10),A=S.newDate(l,S.toMonthIndex(l,c,E),u)}else A=S.newDate(l,Number(c),u)}catch(t){return d}return A?(A.toJD()-y)*p+h*m+f*g+x*v:d}l=2===l.length?(Number(l)+2e3-M)%100+M:Number(l),c-=1;var L=new Date(Date.UTC(2e3,c,u,h,f));return L.setUTCFullYear(l),L.getUTCMonth()!==c?d:L.getUTCDate()!==u?d:L.getTime()+x*v},k=r.MIN_MS=r.dateTime2ms("-9999"),T=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==d};var A=90*p,S=3*m,E=5*g;r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=k&&t<=T))return d;e||(e=0);var i,o,s,l,c,u,f=Math.floor(10*h(t+.05,1)),_=Math.round(t-f/10);if(n(r)){var w=Math.floor(_/p)+y,M=Math.floor(h(t,p));try{i=b.getComponentMethod("calendars","getCal")(r).fromJD(w).formatDate("yyyy-mm-dd")}catch(t){i=x("G%Y-%m-%d")(new Date(_))}if("-"===i.charAt(0))for(;i.length<11;)i="-0"+i.substr(1);else for(;i.length<10;)i="0"+i;o=e=k+p&&t<=T-p))return d;var e=Math.floor(10*h(t+.05,1)),r=new Date(Math.round(t-e/10));return a(l.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,i){if(r.isJSDate(t)||"number"==typeof t){if(n(i))return u.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,i))return u.error("unrecognized date",t),e;return t};var L=/%\d?f/g,C=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,i,a){var l,c;if(a=n(a)&&a,e)return function(t,e,r,i){t=t.replace(L,function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"});var a=new Date(Math.floor(e+.05));if(n(i))try{t=b.getComponentMethod("calendars","worldCalFmt")(t,e,i)}catch(t){return"Invalid"}return r(t)(a)}(e,t,i,a);if(a)try{var u=Math.floor((t+.05)/p)+y,h=b.getComponentMethod("calendars","getCal")(a).fromJD(u);"y"===r?c=s(h):"m"===r?c=function(t){return t.formatDate("M yyyy")}(h):"d"===r?(l=s(h),c=function(t){return t.formatDate("M d")}(h)):(l=function(t){return t.formatDate("M d, yyyy")}(h),c=o(t,r))}catch(t){return"Invalid"}else{var f=new Date(Math.floor(t+.05));"y"===r?c=i("%Y")(f):"m"===r?c=i("%b %Y")(f):"d"===r?(l=i("%Y")(f),c=i("%b %-d")(f)):(l=i("%b %-d, %Y")(f),c=o(t,r))}return c+(l?"\n"+l:"")};var I=3*p;r.incrementMonth=function(t,e,r){r=n(r)&&r;var i=h(t,p);if(t=Math.round(t-i),r)try{var a=Math.round(t/p)+y,o=b.getComponentMethod("calendars","getCal")(r),s=o.fromJD(a);return e%12?o.add(s,e,"m"):o.add(s,e/12,"y"),(s.toJD()-y)*p+i}catch(e){u.error("invalid ms "+t+" in calendar "+r)}var l=new Date(t+I);return l.setUTCMonth(l.getUTCMonth()+e)+i-I},r.findExactDates=function(t,e){for(var r,i,a=0,o=0,s=0,l=0,u=n(e)&&b.getComponentMethod("calendars","getCal")(e),h=0;h0&&(r.push(i),i=[])}return i.length>0&&r.push(i),r},r.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},r.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),r=0;r1||m<0||m>1?null:{x:t+l*m,y:e+h*m}}function i(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}var a=t("./mod");r.segmentsIntersect=n,r.segmentDistance=function(t,e,r,a,o,s,l,c){if(n(t,e,r,a,o,s,l,c))return 0;var u=r-t,h=a-e,f=l-o,d=c-s,p=u*u+h*h,m=f*f+d*d,g=Math.min(i(u,h,p,o-t,s-e),i(u,h,p,l-t,c-e),i(f,d,m,t-o,e-s),i(f,d,m,r-o,a-s));return Math.sqrt(g)};var o,s,l;r.getTextLocation=function(t,e,r,n){if(t===s&&n===l||(o={},s=t,l=n),o[r])return o[r];var i=t.getPointAtLength(a(r-n/2,e)),c=t.getPointAtLength(a(r+n/2,e)),u=Math.atan((c.y-i.y)/(c.x-i.x)),h=t.getPointAtLength(a(r,e)),f={x:(4*h.x+i.x+c.x)/6,y:(4*h.y+i.y+c.y)/6,theta:u};return o[r]=f,f},r.clearLocationCache=function(){s=null},r.getVisibleSegment=function(t,e,r){function n(e){var r=t.getPointAtLength(e);0===e?i=r:e===h&&(a=r);var n=r.xs?r.x-s:0,u=r.yc?r.y-c:0;return Math.sqrt(n*n+u*u)}for(var i,a,o=e.left,s=e.right,l=e.top,c=e.bottom,u=0,h=t.getTotalLength(),f=h,d=n(u);d;){if((u+=d+r)>f)return;d=n(u)}for(d=n(f);d;){if(f-=d+r,u>f)return;d=n(f)}return{min:u,max:f,len:f-u,total:h,isClosed:0===u&&f===h&&Math.abs(i.x-a.x)<.1&&Math.abs(i.y-a.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,h=0,f=0,d=s;h0?d=i:f=i,h++}return a}},{"./mod":745}],733:[function(t,e,r){"use strict";e.exports=function(t){var e;if("string"==typeof t){if(null===(e=document.getElementById(t)))throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}},{}],734:[function(t,e,r){"use strict";function n(t,e){var r=t;return r[3]*=e,r}function i(t){if(o(t))return u;var e=s(t);return e.length?e:u}function a(t){return o(t)?t:h}var o=t("fast-isnumeric"),s=t("color-rgba"),l=t("../components/colorscale"),c=t("../components/color/attributes").defaultLine,u=s(c),h=1;e.exports=function(t,e,r){var o,c,f,d,p,m=t.color,g=Array.isArray(m),v=Array.isArray(e),y=[];if(o=void 0!==t.colorscale?l.makeColorScaleFunc(l.extractScale(t.colorscale,t.cmin,t.cmax)):i,c=g?function(t,e){return void 0===t[e]?u:s(o(t[e]))}:i,f=v?function(t,e){return void 0===t[e]?h:a(t[e])}:a,g||v)for(var b=0;b=0;){var n=t.indexOf(";",r);if(n/g,"")}(function(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(r/g,"\n")}(t))))}},{"../constants/string_mappings":718,"superscript-text":539}],737:[function(t,e,r){"use strict";e.exports=function(t){return t}},{}],738:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../constants/numerical"),o=a.FP_SAFE,s=a.BADNUM,l=e.exports={};l.nestedProperty=t("./nested_property"),l.keyedContainer=t("./keyed_container"),l.relativeAttr=t("./relative_attr"),l.isPlainObject=t("./is_plain_object"),l.isArray=t("./is_array"),l.mod=t("./mod"),l.toLogRange=t("./to_log_range"),l.relinkPrivateKeys=t("./relink_private"),l.ensureArray=t("./ensure_array");var c=t("./coerce");l.valObjectMeta=c.valObjectMeta,l.coerce=c.coerce,l.coerce2=c.coerce2,l.coerceFont=c.coerceFont,l.coerceHoverinfo=c.coerceHoverinfo,l.coerceSelectionMarkerOpacity=c.coerceSelectionMarkerOpacity,l.validate=c.validate;var u=t("./dates");l.dateTime2ms=u.dateTime2ms,l.isDateTime=u.isDateTime,l.ms2DateTime=u.ms2DateTime,l.ms2DateTimeLocal=u.ms2DateTimeLocal,l.cleanDate=u.cleanDate,l.isJSDate=u.isJSDate,l.formatDate=u.formatDate,l.incrementMonth=u.incrementMonth,l.dateTick0=u.dateTick0,l.dfltRange=u.dfltRange,l.findExactDates=u.findExactDates,l.MIN_MS=u.MIN_MS,l.MAX_MS=u.MAX_MS;var h=t("./search");l.findBin=h.findBin,l.sorterAsc=h.sorterAsc,l.sorterDes=h.sorterDes,l.distinctVals=h.distinctVals,l.roundUp=h.roundUp;var f=t("./stats");l.aggNums=f.aggNums,l.len=f.len,l.mean=f.mean,l.variance=f.variance,l.stdev=f.stdev,l.interp=f.interp;var d=t("./matrix");l.init2dArray=d.init2dArray,l.transposeRagged=d.transposeRagged,l.dot=d.dot,l.translationMatrix=d.translationMatrix,l.rotationMatrix=d.rotationMatrix,l.rotationXYMatrix=d.rotationXYMatrix,l.apply2DTransform=d.apply2DTransform,l.apply2DTransform2=d.apply2DTransform2;var p=t("./geometry2d");l.segmentsIntersect=p.segmentsIntersect,l.segmentDistance=p.segmentDistance,l.getTextLocation=p.getTextLocation,l.clearLocationCache=p.clearLocationCache,l.getVisibleSegment=p.getVisibleSegment,l.findPointOnPath=p.findPointOnPath;var m=t("./extend");l.extendFlat=m.extendFlat,l.extendDeep=m.extendDeep,l.extendDeepAll=m.extendDeepAll,l.extendDeepNoArrays=m.extendDeepNoArrays;var g=t("./loggers");l.log=g.log,l.warn=g.warn,l.error=g.error;var v=t("./regex");l.counterRegex=v.counter;var y=t("./throttle");l.throttle=y.throttle,l.throttleDone=y.done,l.clearThrottle=y.clear,l.getGraphDiv=t("./get_graph_div"),l._=t("./localize"),l.notifier=t("./notifier"),l.filterUnique=t("./filter_unique"),l.filterVisible=t("./filter_visible"),l.pushUnique=t("./push_unique"),l.cleanNumber=t("./clean_number"),l.ensureNumber=function(t){return i(t)?(t=Number(t))<-o||t>o?s:i(t)?Number(t):s:s},l.noop=t("./noop"),l.identity=t("./identity"),l.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var i=0;ir?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o-1||c!==1/0&&c>=Math.pow(2,r)?t(e,r,n):s},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},l.syncOrAsync=function(t,e,r){function n(){return l.syncOrAsync(t,e,r)}for(var i,a;t.length;)if(a=t.splice(0,1)[0],(i=a(e))&&i.then)return i.then(n).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;n=0&&t%1==0}function a(e){return void 0!==e&&e1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l};var _=/%{([^\s%{}]*)}/g,w=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(_,function(t,n){return w.test(n)?e[n]||"":(r[n]=r[n]||l.nestedProperty(e,n).get,r[n]()||"")})};l.subplotSort=function(t,e){for(var r=Math.min(t.length,e.length)+1,n=0,i=0,a=0;a=48&&o<=57,c=s>=48&&s<=57;if(l&&(n=10*n+o-48),c&&(i=10*i+s-48),!l||!c){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n}},{"../constants/numerical":717,"./clean_number":722,"./coerce":723,"./dates":724,"./ensure_array":725,"./extend":727,"./filter_unique":728,"./filter_visible":729,"./geometry2d":732,"./get_graph_div":733,"./identity":737,"./is_array":739,"./is_plain_object":740,"./keyed_container":741,"./localize":742,"./loggers":743,"./matrix":744,"./mod":745,"./nested_property":746,"./noop":747,"./notifier":748,"./push_unique":751,"./regex":753,"./relative_attr":754,"./relink_private":755,"./search":756,"./stats":759,"./throttle":762,"./to_log_range":763,d3:123,"fast-isnumeric":132}],739:[function(t,e,r){"use strict";var n="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}};e.exports=function(t){return Array.isArray(t)||n.isView(t)}},{}],740:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],741:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){r=r||"name",a=a||"value";var o,s,l={};s=e&&e.length?n(t,e).get():t,e=e||"",s=s||[];var c={};for(o=0;o2)return l[e]=2|l[e],h.set(t,null);if(u){for(o=e;o1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;e=0;e--){if(n=t[e][0],a=t[e][1],l=!1,c(n))for(r=n.length-1;r>=0;r--)i(n[r],o(a,r))?l?n[r]=void 0:n.pop():l=!0;else if("object"==typeof n&&null!==n)for(s=Object.keys(n),l=!1,r=s.length-1;r>=0;r--)i(n[s[r]],o(a,s[r]))?delete n[s[r]]:l=!0;if(l)return}}(d)):h[e[u]]=n}}function o(t,e){var r=e;return l(e)?r="["+e+"]":t&&(r="."+e),t+r}function s(t,e,r,n){if(void 0===t[e]){if(n)return!1;t[e]="number"==typeof r?[]:{}}return!0}var l=t("fast-isnumeric"),c=t("./is_array"),u=t("./is_plain_object"),h=t("../plot_api/container_array_match");e.exports=function(t,e){if(l(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,c=e.split(".");s/g),s=0;so||a===i||al||e&&c(t))}:function(t,e){var a=t[0],c=t[1];if(a===i||ao||c===i||cl)return!1;var u,h,f,d,p,m=r.length,g=r[0][0],v=r[0][1],y=0;for(u=1;uMath.max(h,g)||c>Math.max(f,v)))if(cu||Math.abs(n(o,f))>i)return!0;return!1};a.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(a+1);for(var c=l+1;c1){r(t.pop())}return{addPt:r,raw:t,filtered:n}}},{"../constants/numerical":717,"./matrix":744}],751:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){var r,n=e.toString();for(r=0;ri.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},a.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},a.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},a.undo=function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("./loggers");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var c,u,h=0,f=e.length,d=0,p=f>1?(e[f-1]-e[0])/(f-1):1;for(u=p>=0?r?n:i:r?o:a,t+=1e-9*p*(r?-1:1)*(p>=0?1:-1);h90&&l.log("Long binary search..."),h-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;it.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":132}],760:[function(t,e,r){"use strict";var n=t("color-rgba");e.exports=function(t){var e=n(t);return e.length?e:[0,0,0,1]}},{"color-rgba":96}],761:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t,e,r){var n="math-output-"+c.randstr([],64),i=l.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(function(t){return t.replace(p,"\\lt ").replace(m,"\\gt ")}(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,i.node()],function(){var e=l.select("body").select("#MathJax_SVG_glyphs");if(i.select(".MathJax_SVG").empty()||!i.select("svg").node())c.log("There was an error in the tex syntax.",t),r();else{var n=i.select("svg").node().getBoundingClientRect();r(i.select(".MathJax_SVG"),e,n)}i.remove()})}function a(t,e){if(!t)return null;var r=t.match(e);return r&&(r[3]||r[4])}function o(t,e){function r(){p++;var e=document.createElementNS(u.svg,"tspan");l.select(e).attr({class:"line",dy:p*f+"em"}),t.appendChild(e),s=e;var r=d;if(d=[{node:e}],r.length>1)for(var i=1;i doesnt match end tag <"+t+">. Pretending it did match.",e),s=d[d.length-1].node}else c.log("Ignoring unexpected end tag .",e)}e=function(t){return function(t,e){if(!t)return"";for(var r=0;r|>|>)/g,g={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},v={sub:"0.3em",sup:"-0.6em"},y={sub:"-0.21em",sup:"0.42em"},b="\u200b",x=["http:","https:","mailto:","",void 0,":"],_=new RegExp("]*)?/?>","g"),w=Object.keys(h.entityToUnicode).map(function(t){return{regExp:new RegExp("&"+t+";","g"),sub:h.entityToUnicode[t]}}),M=/(\r\n?|\n)/g,k=/(<[^<>]*>)/,T=/<(\/?)([^ >]*)(\s+(.*))?>/i,A=//i,S=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,E=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,L=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,C=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i,I=/(^|;)\s*color:/;r.plainText=function(t){return(t||"").replace(_," ")},r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each(function(){function t(t,e){return void 0===e?null===(e=n.attr(t))&&(n.attr(t,0),e=0):n.attr(t,e),e}var n=l.select(this),i=t("x",e),a=t("y",r);"text"===this.nodeName&&n.selectAll("tspan.line").attr({x:i,y:a})})},r.makeEditable=function(t,e){function r(){!function(){var r=l.select(i).select(".svg-container"),a=r.append("div"),c=t.node().style,u=parseFloat(c.fontSize||12);a.classed("plugin-editable editable",!0).style({position:"absolute","font-family":c.fontFamily||"Arial","font-size":u,color:e.fill||c.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(e.text||t.attr("data-unformatted")).call(s(t,r,e)).on("blur",function(){i._editing=!1,t.text(this.textContent).style({opacity:1});var e,r=l.select(this).attr("class");(e=r?"."+r.split(" ")[0]+"-math-group":"[class*=-math-group]")&&l.select(t.node().parentNode).select(e).style({opacity:0});var n=this.textContent;l.select(this).transition().duration(0).remove(),l.select(document).on("mouseup",null),o.edit.call(t,n)}).on("focus",function(){var t=this;i._editing=!0,l.select(document).on("mouseup",function(){if(l.event.target===t)return!1;document.activeElement===a.node()&&a.node().blur()})}).on("keyup",function(){27===l.event.which?(i._editing=!1,t.style({opacity:1}),l.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),o.cancel.call(t,this.textContent)):(o.input.call(t,this.textContent),l.select(this).call(s(t,r,e)))}).on("keydown",function(){13===l.event.which&&this.blur()}).call(n)}(),t.style({opacity:0});var r,a=c.attr("class");(r=a?"."+a.split(" ")[0]+"-math-group":"[class*=-math-group]")&&l.select(t.node().parentNode).select(r).style({opacity:0})}function n(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}var i=e.gd,a=e.delegate,o=l.dispatch("edit","input","cancel"),c=a||t;if(t.style({"pointer-events":a?"none":"all"}),1!==t.size())throw new Error("boo");return e.immediate?r():c.on("click",r),l.rebind(t,o,"on")}},{"../constants/alignment":711,"../constants/string_mappings":718,"../constants/xmlns_namespaces":719,"../lib":738,d3:123}],762:[function(t,e,r){"use strict";function n(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}var i={};r.throttle=function(t,e,r){function a(){r(),o.ts=Date.now(),o.onDone&&(o.onDone(),o.onDone=null)}var o=i[t],s=Date.now();if(!o){for(var l in i)i[l].tso.ts+e?a():o.timer=setTimeout(function(){a(),o.timer=null},e)},r.done=function(t){var e=i[t];return e&&e.timer?new Promise(function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}}):Promise.resolve()},r.clear=function(t){if(t)n(i[t]),delete i[t];else for(var e in i)r.clear(e)}},{}],763:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":132}],764:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson-client").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":812,"topojson-client":545}],765:[function(t,e,r){"use strict";e.exports=function(t,e){if(t instanceof Float32Array)return function(t,e){for(var r=new Float32Array(e),n=0;n0)return t.substr(0,e)}var s=t("fast-isnumeric"),l=t("gl-mat4/fromQuat"),c=t("../registry"),u=t("../lib"),h=t("../plots/plots"),f=t("../plots/cartesian/axis_ids"),d=f.cleanId,p=f.getFromTrace,m=t("../components/color");r.clearPromiseQueue=function(t){Array.isArray(t._promises)&&t._promises.length>0&&u.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var i=(h.subplotsRegistry.cartesian||{}).attrRegex,o=(h.subplotsRegistry.gl3d||{}).attrRegex,s=Object.keys(t);for(e=0;e3?(A.x=1.02,A.xanchor="left"):A.x<-2&&(A.x=-.02,A.xanchor="right"),A.y>3?(A.y=1.02,A.yanchor="bottom"):A.y<-2&&(A.y=-.02,A.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),m.clean(t),t},r.cleanData=function(t,e){for(var n=[],o=t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid}),s=0;s1&&o.warn("Full array edits are incompatible with other edits",h);var y=r[""][""];if(u(y))e.set(null);else{if(!Array.isArray(y))return o.warn("Unrecognized full array edit value",h,y),!0;e.set(y)}return!m&&(f(g,v),d(t),!0)}var b,x,_,w,M,k,T,A=Object.keys(r).map(Number).sort(s),S=e.get(),E=S||[],L=n(v,h).get(),C=[],I=-1,P=E.length;for(b=0;bE.length-(T?0:1))o.warn("index out of range",h,_);else if(void 0!==k)M.length>1&&o.warn("Insertion & removal are incompatible with edits to the same index.",h,_),u(k)?C.push(_):T?("add"===k&&(k={}),E.splice(_,0,k),L&&L.splice(_,0,{})):o.warn("Unrecognized full object edit value",h,_,k),-1===I&&(I=_);else for(x=0;x=0;b--)E.splice(C[b],1),L&&L.splice(C[b],1);if(E.length?S||e.set(E):e.set(null),m)return!1;if(f(g,v),p!==a){var D;if(-1===I)D=A;else{for(P=Math.max(E.length,P),D=[],b=0;b=I);b++)D.push(_);for(b=I;b=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function s(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if(void 0===e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),o(t,e,"currentIndices"),void 0===r||Array.isArray(r)||(r=[r]),void 0!==r&&o(t,r,"newIndices"),void 0!==r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function l(t,e,r,n,i,s){!function(t,e,r,n){var i=v.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!v.isPlainObject(e))throw new Error("update must be a key:value object");if(void 0===r)throw new Error("indices must be an integer or array of integers");o(t,r,"indices");for(var a in e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l,c,u,h=function(t,e,r,n){var i,o,s,l,c,u=v.isPlainObject(n),h=[];Array.isArray(r)||(r=[r]),r=a(r,t.data.length-1);for(var f in e)for(var d=0;d=0&&uY.range[0]?[1,2]:[2,1]);else{var Z=Y.range[0],J=Y.range[1];W?(Z<=0&&J<=0&&r(N+".autorange",!0),Z<=0?Z=J/1e6:J<=0&&(J=Z/1e6),r(N+".range[0]",Math.log(Z)/Math.LN10),r(N+".range[1]",Math.log(J)/Math.LN10)):(r(N+".range[0]",Math.pow(10,Z)),r(N+".range[1]",Math.pow(10,J)))}else r(N+".autorange",!0);x.getComponentMethod("annotations","convertCoords")(t,U,L,r),x.getComponentMethod("images","convertCoords")(t,U,L,r)}else r(N+".autorange",!0),r(N+".range",null);v.nestedProperty(u,N+"._inputRange").set(null)}else if(F.match(z.AX_NAME_PATTERN)){var K=v.nestedProperty(u,S).get(),Q=(L||{}).type;Q&&"-"!==Q||(Q="linear"),x.getComponentMethod("annotations","convertCoords")(t,K,Q,r),x.getComponentMethod("images","convertCoords")(t,K,Q,r)}var $=C.containerArrayMatch(S);if($){a=$.array,o=$.index;var tt=$.property,et=(v.nestedProperty(l,a)||[])[o]||{},rt=et,nt=H||{editType:"calc"},it=-1!==nt.editType.indexOf("calcIfAutorange");""===o?(it?M.calc=!0:D.update(M,nt),it=!1):""===tt&&(rt=L,C.isAddVal(L)?T[S]=null:C.isRemoveVal(L)?(T[S]=et,rt=et):v.warn("unrecognized full object value",e)),it&&(n(rt,"x")||n(rt,"y"))?M.calc=!0:D.update(M,nt),d[a]||(d[a]={});var at=d[a][o];at||(at=d[a][o]={}),at[tt]=L,delete e[S]}else"reverse"===F?(B.range?B.range.reverse():(r(N+".autorange",!0),B.range=[1,0]),U.autorange?M.calc=!0:M.plot=!0):((!u._has("gl2d")&&!u._has("regl")||"dragmode"!==S||"lasso"!==L&&"select"!==L||"lasso"===V||"select"===V)&&H?D.update(M,H):M.calc=!0,E.set(L))}}for(a in d){C.applyContainerArrayChanges(t,v.nestedProperty(l,a),d[a],M)||(M.plot=!0)}var ot=u._axisConstraintGroups||[];for(b in A)for(o=0;o=s.length?s[0]:s[t]:s}function i(t){return Array.isArray(l)?t>=l.length?l[0]:l[t]:l}function a(t,e){var r=0;return function(){if(t&&++r===e)return t()}}if(t=v.getGraphDiv(t),!v.isPlotDiv(t))throw new Error("This element is not a Plotly plot: "+t+". It's likely that you've failed to create a plot before animating it. For more details, see https://plot.ly/javascript/animations/");var o=t._transitionData;o._frameQueue||(o._frameQueue=[]);var s=(r=w.supplyAnimationDefaults(r)).transition,l=r.frame;return void 0===o._frameWaitingCnt&&(o._frameWaitingCnt=0),new Promise(function(l,c){function u(e){if(0!==e.length){for(var s=0;so._timeToNext&&function(){o._currentFrame&&o._currentFrame.onComplete&&o._currentFrame.onComplete();var e=o._currentFrame=o._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,o._lastFrameAt=Date.now(),o._timeToNext=e.frameOpts.duration,w.transition(t,e.frame.data,e.frame.layout,I.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then(function(){e.onComplete&&e.onComplete()}),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(o._animationRaf),o._animationRaf=null}()};e()}()}}function h(t){return Array.isArray(s)?p>=s.length?t.transitionOpts=s[p]:t.transitionOpts=s[0]:t.transitionOpts=s,p++,t}var f,d,p=0,m=[],g=void 0===e||null===e,y=Array.isArray(e);if(!g&&!y&&v.isPlainObject(e))m.push({type:"object",data:h(v.extendFlat({},e))});else if(g||-1!==["string","number"].indexOf(typeof e))for(f=0;f0&&__)&&M.push(d);m=M}}m.length>0?u(m):(t.emit("plotly_animated"),l())})},g.addFrames=function(t,e,r){t=v.getGraphDiv(t);var n=0;if(null===e||void 0===e)return Promise.resolve();if(!v.isPlotDiv(t))throw new Error("This element is not a Plotly plot: "+t+". It's likely that you've failed to create a plot before adding frames. For more details, see https://plot.ly/javascript/animations/");var i,a,o,s,l=t._transitionData._frames,c=t._transitionData._frameHash;if(!Array.isArray(e))throw new Error("addFrames failure: frameList must be an Array of frame definitions"+e);var u=l.length+2*e.length,h=[];for(i=e.length-1;i>=0;i--)if(v.isPlainObject(e[i])){var f=(c[e[i].name]||{}).name,d=e[i].name;f&&d&&"number"==typeof d&&c[f]&&(n++,v.warn('addFrames: overwriting frame "'+c[f].name+'" with a frame whose name of type "number" also equates to "'+f+'". This is valid but may potentially lead to unexpected behavior since all plotly.js frame names are stored internally as strings.'),n>5&&v.warn("addFrames: This API call has yielded too many warnings. For the rest of this call, further warnings about numeric frame names will be suppressed.")),h.push({frame:w.supplyFrameDefaults(e[i]),index:r&&void 0!==r[i]&&null!==r[i]?r[i]:u+i})}h.sort(function(t,e){return t.index>e.index?-1:t.index=0;i--){if("number"==typeof(a=h[i].frame).name&&v.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!a.name)for(;c[a.name="frame "+t._transitionData._counter++];);if(c[a.name]){for(o=0;o=0;r--)n=e[r],a.push({type:"delete",index:n}),o.unshift({type:"insert",index:n,value:i[n]});var s=w.modifyFrames,l=w.modifyFrames,c=[t,o],u=[t,a];return b&&b.add(t,s,c,l,u),w.modifyFrames(t,a)},g.purge=function(t){var e=(t=v.getGraphDiv(t))._fullLayout||{},r=t._fullData||[];return w.cleanPlot([],{},r,e),w.purge(t),y.purge(t),e._container&&e._container.remove(),delete t._context,t}},{"../components/color":613,"../components/drawing":638,"../components/errorbars":644,"../constants/xmlns_namespaces":719,"../lib":738,"../lib/events":726,"../lib/queue":752,"../lib/svg_text_utils":761,"../plotly":780,"../plots/cartesian/axis_ids":788,"../plots/cartesian/constants":790,"../plots/cartesian/constraints":792,"../plots/cartesian/graph_interact":794,"../plots/plots":846,"../plots/polar":849,"../registry":861,"./edit_types":769,"./helpers":770,"./manage_arrays":771,"./plot_schema":774,"./subroutines":777,d3:123,"fast-isnumeric":132,"has-hover":289}],773:[function(t,e,r){"use strict";e.exports={staticPlot:!1,editable:!1,edits:{annotationPosition:!1,annotationTail:!1,annotationText:!1,axisTitleText:!1,colorbarPosition:!1,colorbarTitleText:!1,legendPosition:!1,legendText:!1,shapePosition:!1,titleText:!1},autosizable:!1,queueLength:0,fillFrame:!1,frameMargins:0,scrollZoom:!1,doubleClick:"reset+autosize",showTips:!0,showAxisDragHandles:!0,showAxisRangeEntryBoxes:!0,showLink:!1,sendData:!0,linkText:"Edit chart",showSources:!1,displayModeBar:"hover",modeBarButtonsToRemove:[],modeBarButtonsToAdd:[],modeBarButtons:!1,displaylogo:!0,plotGlPixelRatio:2,setBackground:"transparent",topojsonURL:"https://cdn.plot.ly/",mapboxAccessToken:null,logging:1,globalTransforms:[],locale:"en-US",locales:{}}},{}],774:[function(t,e,r){"use strict";function n(t,e,r){if(!t)return!1;if(t._isLinkedToArray)if(i(e[r]))r++;else if(r=t.items.length)return!1;t=t.items[a]}}return t}function i(t){return t===Math.round(t)&&t>=0}function a(){var t,e,r={};b(r,f);for(t in c.subplotsRegistry)if((e=c.subplotsRegistry[t]).layoutAttributes)if("cartesian"===e.name)s(r,e,"xaxis"),s(r,e,"yaxis");else{s(r,e,"subplot"===e.attr?e.name:e.attr)}r=function(t){return y(t,{radialaxis:g.radialaxis,angularaxis:g.angularaxis}),y(t,g.layout),t}(r);for(t in c.componentsRegistry){var n=(e=c.componentsRegistry[t]).schema;if(n&&(n.subplots||n.layout)){var i=n.subplots;if(i&&i.xaxis&&!i.yaxis)for(var a in i.xaxis)delete r.yaxis[a]}else e.layoutAttributes&&l(r,e.layoutAttributes,e.name)}return{layoutAttributes:o(r)}}function o(t){return function(t){r.crawl(t,function(t,e,n){r.isValObject(t)?"data_array"===t.valType?(t.role="data",n[e+"src"]={valType:"string",editType:"none"}):!0===t.arrayOk&&(n[e+"src"]={valType:"string",editType:"none"}):u.isPlainObject(t)&&(t.role="object")})}(t),function(t){r.crawl(t,function(t,e,r){if(!t)return;var n=t[_];if(!n)return;delete t[_],r[e]={items:{}},r[e].items[n]=t,r[e].role="object"})}(t),t}function s(t,e,r){var n=u.nestedProperty(t,r),i=b({},e.layoutAttributes);i[x]=!0,n.set(i)}function l(t,e,r){var n=u.nestedProperty(t,r);n.set(b(n.get()||{},e))}var c=t("../registry"),u=t("../lib"),h=t("../plots/attributes"),f=t("../plots/layout_attributes"),d=t("../plots/frame_attributes"),p=t("../plots/animation_attributes"),m=t("../plots/polar/area_attributes"),g=t("../plots/polar/axis_attributes"),v=t("./edit_types"),y=u.extendFlat,b=u.extendDeepAll,x="_isSubplotObj",_="_isLinkedToArray",w=[x,_,"_arrayAttrRegexps","_deprecated"];r.IS_SUBPLOT_OBJ=x,r.IS_LINKED_TO_ARRAY=_,r.DEPRECATED="_deprecated",r.UNDERSCORE_ATTRS=w,r.get=function(){var t={};c.allTypes.concat("area").forEach(function(e){t[e]=function(t){var e,r;"area"===t?(e={attributes:m},r={}):r=(e=c.modules[t]._module).basePlotModule;var n={};n.type=null,b(n,h),b(n,e.attributes),r.attributes&&b(n,r.attributes),n.type=t;var i={meta:e.meta||{},attributes:o(n)};if(e.layoutAttributes){var a={};b(a,e.layoutAttributes),i.layoutAttributes=o(a)}return i}(e)});var e={};return Object.keys(c.transformsRegistry).forEach(function(t){e[t]=function(t){var e=c.transformsRegistry[t],r=b({},e.attributes);return Object.keys(c.componentsRegistry).forEach(function(e){var n=c.componentsRegistry[e];n.schema&&n.schema.transforms&&n.schema.transforms[t]&&Object.keys(n.schema.transforms[t]).forEach(function(e){l(r,n.schema.transforms[t][e],e)})}),{attributes:o(r)}}(t)}),{defs:{valObjects:u.valObjectMeta,metaKeys:w.concat(["description","role","editType","impliedEdits"]),editType:{traces:v.traces,layout:v.layout},impliedEdits:{}},traces:t,layout:a(),transforms:e,frames:function(){var t={frames:u.extendDeepAll({},d)};return o(t),t.frames}(),animation:o(p)}},r.crawl=function(t,e,n,i){var a=n||0;i=i||"",Object.keys(t).forEach(function(n){var o=t[n];if(-1===w.indexOf(n)){var s=(i?i+".":"")+n;e(o,n,t,a,s),r.isValObject(o)||u.isPlainObject(o)&&"impliedEdits"!==n&&r.crawl(o,e,a+1,s)}})},r.isValObject=function(t){return t&&void 0!==t.valType},r.findArrayAttributes=function(t){function e(e,r,a,o){i=i.slice(0,o).concat([r]);if(e&&("data_array"===e.valType||!0===e.arrayOk)&&!("colorbar"===i[o-1]&&("ticktext"===r||"tickvals"===r))){var s=function(t){return t.join(".")}(i),l=u.nestedProperty(t,s).get();Array.isArray(l)&&n.push(s)}}var n=[],i=[];if(r.crawl(h,e),t._module&&t._module.attributes&&r.crawl(t._module.attributes,e),t.transforms)for(var a=t.transforms,o=0;o=t.transforms.length)return!1;a=(r=(c.transformsRegistry[t.transforms[l].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)a=m[o];else{var u=t._module;if(u||(u=(c.modules[t.type||h.type.dflt]||{})._module),!u)return!1;if(r=u.attributes,!(a=r&&r[o])){var f=u.basePlotModule;f&&f.attributes&&(a=f.attributes[o])}a||(a=h[o])}return n(a,e,s)},r.getLayoutValObject=function(t,e){return n(function(t,e){var r,n,i,a,o=t._basePlotModules;if(o){var s;for(r=0;r=t[1]||i[1]<=t[0])&&a[0]e[0])return!0}return!1}(r,n,w)?(_.push(t),w.push([r,n])):i=[0];var a=e.plotgroup.selectAll(".bg").data(i);a.enter().append("rect").classed("bg",!0),a.exit().remove(),a.each(function(){e.bg=a;var t=e.plotgroup.node();t.insertBefore(this,t.childNodes[0])})});var M=l._bgLayer.selectAll(".bg").data(_);return M.enter().append("rect").classed("bg",!0),M.exit().remove(),M.each(function(t){l._plots[t].bg=o.select(this)}),x.each(function(t){function r(t){return"M"+k+","+t+"H"+T}function o(t){return"M"+y._offset+","+t+"h"+y._length}function s(t){return"M"+t+","+I+"V"+C}function c(t){return"M"+t+","+b._offset+"v"+b._length}function p(e,r,n){if(!e.showline||t!==e._mainSubplot)return"";if(!e._anchorAxis)return n(e._mainLinePosition);var i=r(e._mainLinePosition);return e.mirror&&(i+=r(e._mainMirrorPosition)),i}var v=l._plots[t],y=v.xaxis,b=v.yaxis;v.bg&&m&&v.bg.call(f.setRect,y._offset-u,b._offset-u,y._length+2*u,b._length+2*u).call(h.fill,l.plot_bgcolor).style("stroke-width",0),v.clipId="clip"+l._uid+t+"plot";var x=l._clips.selectAll("#"+v.clipId).data([0]);x.enter().append("clipPath").attr({class:"plotclip",id:v.clipId}).append("rect"),x.selectAll("rect").attr({width:y._length,height:b._length}),f.setTranslate(v.plot,y._offset,b._offset);var _,w;for(v._hasClipOnAxisFalse?(_=null,w=v.clipId):(_=v.clipId,w=null),f.setClipUrl(v.plot,_),i=0;i1&&d.push(a("object","layout"))),l.supplyDefaults(p);for(var m=p._fullData,g=r.length,v=0;v10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=T&&i<=10||e>=15*T)t._tickround="d";else if(e>=S&&i<=16||e>=A)t._tickround="M";else if(e>=E&&i<=19||e>=S)t._tickround="S";else{var a=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(i,a)-20}}else if(p(e)||"L"===e.charAt(0)){var o=t.range.map(t.r2d||Number);p(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var s=Math.max(Math.abs(o[0]),Math.abs(o[1])),u=Math.floor(Math.log(s)/Math.LN10+.01);Math.abs(u)>3&&(l(t.exponentformat)&&!c(u)?t._tickexponent=3*Math.round((u-1)/3):t._tickexponent=u)}else t._tickround=null}function s(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t){return"SI"===t||"B"===t}function c(t){return t>14||t<-15}function u(t,e,r,n){var i=t<0,a=e._tickround,s=r||e.exponentformat||"B",u=e._tickexponent,h=P.getTickFormat(e),f=e.separatethousands;if(n){var d={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:p(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};o(d),a=(Number(d._tickround)||0)+4,u=d._tickexponent,e.hoverformat&&(h=e.hoverformat)}if(h)return e._numFormat(h)(t).replace(/-/g,L);var m=Math.pow(10,-a)/2;if("none"===s&&(u=0),(t=Math.abs(t))"+b+"":"B"===s&&9===u?t+="B":l(s)&&(t+=V[u/3+5])}return i?L+t:t}function h(t,e){for(var r=0;r2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},P.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&h/u>f&&(l=o,c=s,f=h/u);if(n===i){var m=n-1,v=n+1;r="tozero"===t.rangemode?n<0?[m,0]:[0,v]:"nonnegative"===t.rangemode?[Math.max(0,m),Math.max(0,v)]:[m,v]}else f&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode?(l.val>=0&&(l={val:0,pad:0}),c.val<=0&&(c={val:0,pad:0})):"nonnegative"===t.rangemode&&(l.val-f*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),f=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-f*l.pad,c.val+f*c.pad]);return r[0]===r[1]&&("tozero"===t.rangemode?r=r[0]<0?[r[0],0]:r[0]>0?[0,r[0]]:[0,1]:(r=[r[0]-1,r[0]+1],"nonnegative"===t.rangemode&&(r[0]=Math.max(0,r[0])))),d&&r.reverse(),g.simpleMap(r,t.l2r||Number)},P.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=P.getAutoRange(t),t._r=t.range.slice(),t._rl=g.simpleMap(t._r,t.r2l);var r=t._input;r.range=t.range.slice(),r.autorange=t.autorange}},P.saveRangeInitial=function(t,e){for(var r=P.list(t,"",!0),n=!1,i=0;i=f?d=!1:s.val>=c&&s.pad<=f&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:x&&0===c?0:f})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=h?d=!1:s.val<=u&&s.pad<=h&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:x&&0===u?0:h})}}}if((t.autorange||!!g.nestedProperty(t,"rangeslider.autorange").get())&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,h,f,d,m,v,y=e.length,b=r.padded?.05*t._length:0,x=r.tozero&&("linear"===t.type||"-"===t.type);b&&"domain"===t.constrain&&t._inputDomain&&(b*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0]));var _=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),M=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),k=n(r.vpadplus||r.vpad),T=n(r.vpadminus||r.vpad);for(a=0;a<6;a++)i(a);for(a=y-1;a>5;a--)i(a)}},P.autoBin=function(t,e,r,n,i){var a=g.aggNums(Math.min,null,t),o=g.aggNums(Math.max,null,t);if(i||(i=e.calendar),"category"===e.type)return{start:a-.5,end:o+.5,size:1,_count:o-a+1};var s;if(r)s=(o-a)/r;else{var l=g.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*g.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*g.stdev(t)/Math.pow(t.length,n?.25:.4)),p(s)||(s=1)}var h;h="log"===e.type?{type:"linear",range:[a,o]}:{type:e.type,range:g.simpleMap([a,o],e.c2r,0,i),calendar:i},P.setConvert(h),P.autoTicks(h,s);var f,d,m=P.tickIncrement(P.tickFirst(h),h.dtick,"reverse",i);if("number"==typeof h.dtick)f=(m=function(t,e,r,n,i){function a(e){return(1+100*(e-t)/r.dtick)%100<2}for(var o=0,s=0,l=0,c=0,u=0;u.3*h||a(n)||a(i))){var f=r.dtick/2;t+=t+f.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=P.tickIncrement(t,"M6","reverse")+1.5*T:a.exactMonths>.8?t=P.tickIncrement(t,"M1","reverse")+15.5*T:t-=T/2;var s=P.tickIncrement(t,r);if(s<=n)return s}return t}(m,t,h.dtick,a,i)),f=m,d=0;f<=o;)f=P.tickIncrement(f,h.dtick,!1,i),d++;return{start:e.c2r(m,0,i),end:e.c2r(f,0,i),size:h.dtick,_count:d}},P.calcTicks=function(t){var e=g.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=g.constrain(t._length/r,4,9)+1)),"array"===t.tickmode&&(n*=100),P.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}if(t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),o(t),"array"===t.tickmode)return function(t){var e,r,n=t.tickvals,i=t.ticktext,a=new Array(n.length),o=g.simpleMap(t.range,t.r2l),l=1.0001*o[0]-1e-4*o[1],c=1.0001*o[1]-1e-4*o[0],u=Math.min(l,c),h=Math.max(l,c),f=0;Array.isArray(i)||(i=[]);var d="category"===t.type?t.d2l_noadd:t.d2l;for("log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1)),r=0;ru&&e=l:h<=l)&&!(a.length>u||h===c);h=P.tickIncrement(h,t.dtick,i,t.calendar))c=h,a.push(h);t._tmax=a[a.length-1],t._prevDateHead="",t._inCalcTicks=!0;for(var f=new Array(a.length),d=0;dM?(e/=M,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,r,F)):n>k?(e/=k,t.dtick="M"+a(e,1,R)):n>T?(t.dtick=a(e,T,N),t.tick0=g.dateTick0(t.calendar,!0)):n>A?t.dtick=a(e,A,R):n>S?t.dtick=a(e,S,j):n>E?t.dtick=a(e,E,j):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,r,F))}else if("log"===t.type){t.tick0=0;var i=g.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(i[1]-i[0])<1){var o=1.5*Math.abs((i[1]-i[0])/e);e=Math.abs(Math.pow(10,i[1])-Math.pow(10,i[0]))/o,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,r,F)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,r,F));if(0===t.dtick&&(t.dtick=1),!p(t.dtick)&&"string"!=typeof t.dtick){var s=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(s)}},P.tickIncrement=function(t,e,r,n){var i=r?-1:1;if(p(e))return t+i*e;var a=e.charAt(0),o=i*Number(e.substr(1));if("M"===a)return g.incrementMonth(t,o,n);if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var s="D2"===e?U:B,l=t+.01*i,c=g.roundUp(g.mod(l,1),s,r);return Math.floor(l)+Math.log(d.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},P.tickFirst=function(t){var e=t.r2l||Number,r=g.simpleMap(t.range,e),n=r[1]"+o,t._prevDateHead=o)),e.text=s}(t,o,r,f):"log"===t.type?function(t,e,r,n,i){var a=t.dtick,o=e.x,s=t.tickformat;if("never"===i&&(i=""),!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),s||"string"==typeof a&&"L"===a.charAt(0))e.text=u(Math.pow(10,o),t,i,n);else if(p(a)||"D"===a.charAt(0)&&g.mod(o+.01,1)<.1){var h=Math.round(o);-1!==["e","E","power"].indexOf(t.exponentformat)||l(t.exponentformat)&&c(h)?(e.text=0===h?1:1===h?"10":h>1?"10"+h+"":"10"+L+-h+"",e.fontSize*=1.25):(e.text=u(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,g.mod(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var f=String(e.text).charAt(0);"0"!==f&&"1"!==f||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(o<0?.5:.25)))}}(t,o,0,f,i):"category"===t.type?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}(t,o):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=u(e.x,t,i,n)}(t,o,0,f,i),t.tickprefix&&!n(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!n(t.showticksuffix)&&(o.text+=t.ticksuffix),o},P.hoverLabelText=function(t,e,r){if(r!==C&&r!==e)return P.hoverLabelText(t,e)+" - "+P.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=P.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":L+i:i};var V=["f","p","n","\u03bc","m","","k","M","G","T"];P.getTickFormat=function(t){function e(t){return"string"!=typeof t?t:Number(t.replace("M",""))*k}function r(t,e){var r=["L","D"];if(typeof t==typeof e){if("number"==typeof t)return t-e;var n=r.indexOf(t.charAt(0)),i=r.indexOf(e.charAt(0));return n===i?Number(t.replace(/(L|D)/g,""))-Number(e.replace(/(L|D)/g,"")):n-i}return"number"==typeof t?1:-1}function n(t,e,r){var n=r||function(t){return t},i=e[0],a=e[1];return(!i&&"number"!=typeof i||n(i)<=n(t))&&(!a&&"number"!=typeof a||n(a)>=n(t))}function i(t,e){var n=null===e[0],i=null===e[1],a=r(t,e[0])>=0,o=r(t,e[1])<=0;return(n||a)&&(i||o)}var a,o;if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(a=0;a1&&e1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,o=0,s=0;s2*n}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)}},{"../../registry":861,"./constants":790}],789:[function(t,e,r){"use strict";e.exports=function(t,e,r){if("category"===e.type){var n,i=t.categoryarray,a=Array.isArray(i)&&i.length>0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],790:[function(t,e,r){"use strict";var n=t("../../lib").counterRegex;e.exports={idRegex:{x:n("x"),y:n("y")},attrRegex:n("[xy]axis"),xAxisMatch:n("xaxis"),yAxisMatch:n("yaxis"),AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,SUBPLOT_PATTERN:/^x([0-9]*)y([0-9]*)$/,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,BENDPX:1.5,REDRAWDELAY:50,SELECTDELAY:100,SELECTID:"-select",DFLTRANGEX:[-1,6],DFLTRANGEY:[-1,4],traceLayerClasses:["imagelayer","maplayer","barlayer","carpetlayer","violinlayer","boxlayer","scatterlayer"],layerValue2layerClass:{"above traces":"above","below traces":"below"}}},{"../../lib":738}],791:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./axis_ids").id2name;e.exports=function(t,e,r,a,o){var s=o._axisConstraintGroups,l=e._id,c=l.charAt(0);if(!e.fixedrange&&(r("constrain"),n.coerce(t,e,{constraintoward:{valType:"enumerated",values:"x"===c?["left","center","right"]:["bottom","middle","top"],dflt:"x"===c?"center":"middle"}},"constraintoward"),t.scaleanchor)){var u=function(t,e,r,n){var a,o,s,l,c=n[i(e)].type,u=[];for(o=0;oo*v)||_)for(r=0;rI&&DL&&(L=D);h/=(L-E)/(2*C),E=l.l2r(E),L=l.l2r(L),l.range=l._input.range=T.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}(at,dt,X,Z,pt="M0,0H"+J+"V"+K+"H0V0"),yt=function(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:g.background,stroke:g.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}(at,X,Z),o(at)}function j(e,r){function n(){gt="",ft.r=ft.l,ft.t=ft.b,yt.attr("d","M0,0Z")}if(t._transitioningWithDuration)return!1;var i=Math.max(0,Math.min(J,e+ut)),a=Math.max(0,Math.min(K,r+ht)),o=Math.abs(i-ut),s=Math.abs(a-ht);ft.l=Math.min(ut,i),ft.r=Math.max(ut,i),ft.t=Math.min(ht,a),ft.b=Math.max(ht,a),et?o>L||s>L?(gt="xy",o/J>s/K?(s=o*K/J,ht>a?ft.t=ht-s:ft.b=ht+s):(o=s*J/K,ut>i?ft.l=ut-o:ft.r=ut+o),yt.attr("d",c(ft))):n():!$||s.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}(vt,yt,ft,pt,mt,dt),mt=!0}function N(){if(Math.min(ft.h,ft.w)<2*E)return s(t);"xy"!==gt&&"x"!==gt||i(Y,ft.l/J,ft.r/J,bt,rt),"xy"!==gt&&"y"!==gt||i(W,(K-ft.b)/K,(K-ft.t)/K,bt,nt),s(t),H(),C&&t.data&&t._context.showTips&&(p.notifier(p._(t,"Double-click to zoom back out"),"long"),C=!1)}function B(e){function r(t,e,r){if(!t.fixedrange){var n=p.simpleMap(t.range,t.r2l),i=n[0]+(n[1]-n[0])*e;t.range=n.map(function(e){return t.l2r(i+(e-i)*r)})}}if(t._context.scrollZoom||it._enablescrollzoom){if(t._transitioningWithDuration)return p.pauseEvent(e);var n=t.querySelector(".plotly");if(F(),!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(_t);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),isFinite(i)){var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/200),s=Mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,c=(s.bottom-e.clientY)/s.height;if(O||et){for(O||(l=.5),a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}(r/s._length);var l=s.l2r(i);!1!==l&&void 0!==l&&(s.range[e]=l)}}return n._length*(n._rl[e]-i)/(n._rl[e]-n._rl[a])}if(!t._transitioningWithDuration){if(F(),"ew"===Q||"ns"===$)return Q&&a(Y,e),$&&a(W,r),q([Q?-e:0,$?-r:0,J,K]),void V($,Q);if(et&&Q&&$){var i="w"===Q==("n"===$)?1:-1,o=(e/J+i*r/K)/2;e=o*J,r=i*o*K}"w"===Q?e=n(Y,0,e):"e"===Q?e=n(Y,1,-e):Q||(e=0),"n"===$?r=n(W,1,r):"s"===$?r=n(W,0,-r):$||(r=0);var s="w"===Q?e:0,l="n"===$?r:0;if(et){var c;if(!Q&&1===$.length){for(c=0;c rect").call(v.setTranslate,s,l).call(v.setScale,a,o);var E=g.plot.selectAll(".scatterlayer .trace, .boxlayer .trace, .violinlayer .trace");g.plot.call(v.setTranslate,T,S).call(v.setScale,1/a,1/o),E.selectAll(".point").call(v.setPointGroupScale,a,o),E.selectAll(".textpoint").call(v.setTextPointsScale,a,o),E.call(v.hideOutsideRangePoints,g)}}}var G,Y,W,X,Z,J,K,Q,$,tt,et,rt,nt,it=t._fullLayout,at=t._fullLayout._zoomlayer,ot=z+O==="nsew",st=1===(z+O).length;F();var lt=function(t,e,r,n,i,a,o){var s=t.draglayer.selectAll("."+e).data([0]);return s.enter().append("rect").classed("drag",!0).classed(e,!0).style({fill:"transparent","stroke-width":0}).attr("data-subplot",t.id),s.call(v.setRect,n,i,a,o).call(b,r),s.node()}(e,z+O+"drag",tt,r,I,P,D);if(!$&&!Q&&!l(it.dragmode))return lt.onmousedown=null,lt.style.pointerEvents=ot?"all":"none",lt;var ct={element:lt,gd:t,plotinfo:e,prepFn:function(e,r,n){var i=t._fullLayout.dragmode;ot?e.shiftKey?"pan"===i?i="zoom":l(i)||(i="pan"):e.ctrlKey&&(i="pan"):i="pan",ct.minDrag="lasso"===i?1:void 0,"zoom"===i?(ct.moveFn=j,ct.doneFn=N,ct.minDrag=1,R(0,r,n)):"pan"===i?(ct.moveFn=U,ct.doneFn=H,o(at)):l(i)&&(ct.xaxes=Y,ct.yaxes=W,T(e,r,n,ct,i))},clickFn:function(r,n){if(s(t),2!==r||st||function(){if(!t._transitioningWithDuration){var e,r,n,i=t._context.doubleClick,a=(Q?Y:[]).concat($?W:[]),o={};if("reset+autosize"===i)for(i="autosize",r=0;ru[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return r("layer"),e}},{"../../lib":738,"fast-isnumeric":132}],801:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":711}],802:[function(t,e,r){"use strict";function n(t){return t._id}function i(t,e,r){var n,i,a;if(r){var o=r.points||[];for(n=0;n0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*M*Math.abs(n-i))}return d}function h(e,r,n){var i=c(e,n||t.calendar);if(i===d){if(!a(e))return d;i=c(new Date(+e))}return i}function g(e,r,n){return l(e,r,n||t.calendar)}function v(e){return t._categories[Math.round(e)]}function y(e){if(null!==e&&void 0!==e){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push(e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return d}function b(e){if(t._categoriesMap){var r=t._categoriesMap[e];if(void 0!==r)return r}if(a(e))return+e}function x(e){return a(e)?i.round(t._b+t._m*e,2):d}function _(e){return(e-t._b)/t._m}e=e||{};var w=(t._id||"x").charAt(0),M=10;t.c2l="log"===t.type?r:u,t.l2c="log"===t.type?n:u,t.l2p=x,t.p2l=_,t.c2p="log"===t.type?function(t,e){return x(r(t,e))}:x,t.p2c="log"===t.type?function(t){return n(_(t))}:_,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=s,t.c2d=t.c2r=t.l2d=t.l2r=u,t.d2p=t.r2p=function(e){return t.l2p(s(e))},t.p2d=t.p2r=_,t.cleanPos=u):"log"===t.type?(t.d2r=t.d2l=function(t,e){return r(s(t),e)},t.r2d=t.r2c=function(t){return n(s(t))},t.d2c=t.r2l=s,t.c2d=t.l2r=u,t.c2r=r,t.l2d=n,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return n(_(t))},t.r2p=function(e){return t.l2p(s(e))},t.p2r=_,t.cleanPos=u):"date"===t.type?(t.d2r=t.r2d=o.identity,t.d2c=t.r2c=t.d2l=t.r2l=h,t.c2d=t.c2r=t.l2d=t.l2r=g,t.d2p=t.r2p=function(e,r,n){return t.l2p(h(e,0,n))},t.p2d=t.p2r=function(t,e,r){return g(_(t),e,r)},t.cleanPos=function(e){return o.cleanDate(e,d,t.calendar)}):"category"===t.type&&(t.d2c=t.d2l=y,t.r2d=t.c2d=t.l2d=v,t.d2r=t.d2l_noadd=b,t.r2c=function(e){var r=b(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=u,t.r2l=b,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return v(_(t))},t.r2p=t.d2p,t.p2r=_,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:u(t)}),t.fraction2r=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return t.l2r(r+e*(n-r))},t.r2fraction=function(e){var r=t.r2l(t.range[0]),n=t.r2l(t.range[1]);return(t.r2l(e)-r)/(n-r)},t.cleanRange=function(e){e||(e="range");var r,n,i=o.nestedProperty(t,e).get();if(n="date"===t.type?o.dfltRange(t.calendar):"y"===w?p.DFLTRANGEY:p.DFLTRANGEX,n=n.slice(),i&&2===i.length)for("date"===t.type&&(i[0]=o.cleanDate(i[0],d,t.calendar),i[1]=o.cleanDate(i[1],d,t.calendar)),r=0;r<2;r++)if("date"===t.type){if(!o.isDateTime(i[r],t.calendar)){t[e]=n;break}if(t.r2l(i[0])===t.r2l(i[1])){var s=o.constrain(t.r2l(i[0]),o.MIN_MS+1e3,o.MAX_MS-1e3);i[0]=t.l2r(s-1e3),i[1]=t.l2r(s+1e3);break}}else{if(!a(i[r])){if(!a(i[1-r])){t[e]=n;break}i[r]=i[1-r]*(r?10:.1)}if(i[r]<-f?i[r]=-f:i[r]>f&&(i[r]=f),i[0]===i[1]){var l=Math.max(1,Math.abs(1e-6*i[0]));i[0]-=l,i[1]+=l}}else o.nestedProperty(t,e).set(n)},t.setScale=function(r){var n=e._size;if(t._categories||(t._categories=[]),t._categoriesMap||(t._categoriesMap={}),t.overlaying){var i=m.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var a=r&&t._r?"_r":"range",o=t.calendar;t.cleanRange(a);var s=t.r2l(t[a][0],o),l=t.r2l(t[a][1],o);if("y"===w?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-l),t._b=-t._m*l):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(l-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b))throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,a,o="date"===t.type&&e[r+"calendar"];if(r in e)for(n=e[r],i=new Array(n.length),a=0;a=t.r2l(t.range[0])&&n<=t.r2l(t.range[1])},t._min=[],t._max=[];var k=e._d3locale;"date"===t.type&&(t._dateFormat=k?k.timeFormat.utc:i.time.format.utc),t._separators=e.separators,t._numFormat=k?k.numberFormat:i.format,delete t._minDtick,delete t._forceTick0}},{"../../constants/numerical":717,"../../lib":738,"./axis_ids":788,"./constants":790,d3:123,"fast-isnumeric":132}],804:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r,a,o){var s=function(t){var e=["showexponent","showtickprefix","showticksuffix"].filter(function(e){return void 0!==t[e]});if(e.every(function(r){return t[r]===t[e[0]]})||1===e.length)return t[e[0]]}(t);r("tickprefix")&&r("showtickprefix",s);r("ticksuffix")&&r("showticksuffix",s);if(r("showticklabels")){var l=o.font||{},c=e.color===t.color?e.color:l.color;if(n.coerceFont(r,"tickfont",{family:l.family,size:l.size,color:c}),r("tickangle"),"category"!==a){var u=r("tickformat");!function(t,e){function r(t,e){return n.coerce(s,l,i.tickformatstops,t,e)}var a=t.tickformatstops,o=e.tickformatstops=[];if(Array.isArray(a))for(var s,l,c=0;c0?Number(u):c;else if("string"!=typeof u)e.dtick=c;else{var h=u.charAt(0),f=u.substr(1);((f=n(f)?Number(f):0)<=0||!("date"===o&&"M"===h&&f===Math.round(f)||"log"===o&&"L"===h||"log"===o&&"D"===h&&(1===f||2===f)))&&(e.dtick=c)}var d="date"===o?i.dateTick0(e.calendar):0,p=r("tick0",d);"date"===o?e.tick0=i.cleanDate(p,d):n(p)&&"D1"!==u&&"D2"!==u?e.tick0=Number(p):e.tick0=d}else{void 0===r("tickvals")?e.tickmode="auto":r("ticktext")}}},{"../../constants/numerical":717,"../../lib":738,"fast-isnumeric":132}],807:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plotly"),a=t("../../registry"),o=t("../../components/drawing"),s=t("./axes"),l=t("./constants").attrRegex;e.exports=function(t,e,r,c){function u(t){var e=t.xaxis,r=t.yaxis;d._defs.select("#"+t.clipId+"> rect").call(o.setTranslate,0,0).call(o.setScale,1,1),t.plot.call(o.setTranslate,e._offset,r._offset).call(o.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(o.setPointGroupScale,1,1),n.selectAll(".textpoint").call(o.setTextPointsScale,1,1),n.call(o.hideOutsideRangePoints,t)}function h(e,r){var n,i,l,c=m[e.xaxis._id],u=m[e.yaxis._id],h=[];if(c){i=(n=t._fullLayout[c.axisName])._r,l=c.to,h[0]=(i[0]*(1-r)+r*l[0]-i[0])/(i[1]-i[0])*e.xaxis._length;var f=i[1]-i[0],p=l[1]-l[0];n.range[0]=i[0]*(1-r)+r*l[0],n.range[1]=i[1]*(1-r)+r*l[1],h[2]=e.xaxis._length*(1-r+r*p/f)}else h[0]=0,h[2]=e.xaxis._length;if(u){i=(n=t._fullLayout[u.axisName])._r,l=u.to,h[1]=(i[1]*(1-r)+r*l[1]-i[1])/(i[0]-i[1])*e.yaxis._length;var g=i[1]-i[0],v=l[1]-l[0];n.range[0]=i[0]*(1-r)+r*l[0],n.range[1]=i[1]*(1-r)+r*l[1],h[3]=e.yaxis._length*(1-r+r*v/g)}else h[1]=0,h[3]=e.yaxis._length;!function(e,r){function n(e,r,n){for(i=0;i rect").call(o.setTranslate,k,T).call(o.setScale,1/w,1/M),e.plot.call(o.setTranslate,E,L).call(o.setScale,w,M).selectAll(".points").selectAll(".point").call(o.setPointGroupScale,1/w,1/M),e.plot.selectAll(".points").selectAll(".textpoint").call(o.setTextPointsScale,1/w,1/M)}function f(){x=Date.now();for(var e=Math.min(1,(x-b)/r.duration),n=w(e),a=0;ar.duration?(!function(){for(var e={},r=0;r0?".":"")+i;l.isPlainObject(a)?o(a,e,s,n+1):e(s,i,a)}})}var s=t("../plotly"),l=t("../lib");r.manageCommandObserver=function(t,e,i,a){var o={},s=!0;e&&e._commandObserver&&(o=e._commandObserver),o.cache||(o.cache={}),o.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,i,o.lookupTable);if(e&&e._commandObserver){if(c)return o;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,o}if(c){n(t,c,o.cache),o.check=function(){if(s){var e=n(t,c,o.cache);return e.changed&&a&&void 0!==o.lookupTable[e.value]&&(o.disable(),Promise.resolve(a({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:o.lookupTable[e.value]})).then(o.enable,o.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],h=0;hn*Math.PI/180}return!1},r.getPath=function(){return i.geo.path().projection(r)},r.getBounds=function(t){return r.getPath().bounds(t)},r.fitExtent=function(t,e){var n=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=r.clipExtent&&r.clipExtent();r.scale(150).translate([0,0]),a&&r.clipExtent(null);var o=r.getBounds(e),s=Math.min(n/(o[1][0]-o[0][0]),i/(o[1][1]-o[0][1])),l=+t[0][0]+(n-s*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(i-s*(o[1][1]+o[0][1]))/2;return a&&r.clipExtent(a),r.scale(150*s).translate([l,c])},r.precision(m.precision),n&&r.clipAngle(n-m.clipPad),r}(e);u.center([c.lon-l.lon,c.lat-l.lat]).rotate([-l.lon,-l.lat,l.roll]).parallels(s.parallels);var h=[[r.l+r.w*n.x[0],r.t+r.h*(1-n.y[1])],[r.l+r.w*n.x[1],r.t+r.h*(1-n.y[0])]],f=e.lonaxis,d=e.lataxis,p=function(t,e){var r=m.clipPad,n=t[0]+r,i=t[1]-r,a=e[0]+r,o=e[1]-r;n>0&&i<0&&(i+=360);var s=(i-n)/4;return{type:"Polygon",coordinates:[[[n,a],[n,o],[n+s,o],[n+2*s,o],[n+3*s,o],[i,o],[i,a],[i-s,a],[i-2*s,a],[i-3*s,a],[n,a]]]}}(f.range,d.range);u.fitExtent(h,p);var g=this.bounds=u.getBounds(p),v=this.fitScale=u.scale(),y=u.translate();if(!isFinite(g[0][0])||!isFinite(g[0][1])||!isFinite(g[1][0])||!isFinite(g[1][1])||isNaN(y[0])||isNaN(y[0])){for(var b=this.graphDiv,x=["projection.rotation","center","lonaxis.range","lataxis.range"],_="Invalid geo settings, relayout'ing to default view.",w={},M=0;M0&&w<0&&(w+=360);var M,k=(_+w)/2;if(!c){var T=u?o.projRotate:[k,0,0];M=r("projection.rotation.lon",T[0]),r("projection.rotation.lat",T[1]),r("projection.rotation.roll",T[2]),r("showcoastlines",!u)&&(r("coastlinecolor"),r("coastlinewidth")),r("showocean")&&r("oceancolor")}var A,S;if(c?(A=-96.6,S=38.7):(A=u?k:M,S=(x[0]+x[1])/2),r("center.lon",A),r("center.lat",S),h){r("projection.parallels",o.projParallels||[0,60])}r("projection.scale"),r("showland")&&r("landcolor"),r("showlakes")&&r("lakecolor"),r("showrivers")&&(r("rivercolor"),r("riverwidth")),r("showcountries",u&&"usa"!==i)&&(r("countrycolor"),r("countrywidth")),("usa"===i||"north america"===i&&50===n)&&(r("showsubunits",!0),r("subunitcolor"),r("subunitwidth")),u||r("showframe",!0)&&(r("framecolor"),r("framewidth")),r("bgcolor")}var i=t("../../subplot_defaults"),a=t("../constants"),o=t("./layout_attributes"),s=a.axesNames;e.exports=function(t,e,r){i(t,e,r,{type:"geo",attributes:o,handleDefaults:n,partition:"y"})}},{"../../subplot_defaults":853,"../constants":812,"./layout_attributes":817}],817:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("../constants"),a=t("../../../plot_api/edit_types").overrideAll,o={range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},showgrid:{valType:"boolean",dflt:!1},tick0:{valType:"number"},dtick:{valType:"number"},gridcolor:{valType:"color",dflt:n.lightLine},gridwidth:{valType:"number",min:0,dflt:1}};e.exports=a({domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},resolution:{valType:"enumerated",values:[110,50],dflt:110,coerceNumber:!0},scope:{valType:"enumerated",values:Object.keys(i.scopeDefaults),dflt:"world"},projection:{type:{valType:"enumerated",values:Object.keys(i.projNames)},rotation:{lon:{valType:"number"},lat:{valType:"number"},roll:{valType:"number"}},parallels:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},scale:{valType:"number",min:0,dflt:1}},center:{lon:{valType:"number"},lat:{valType:"number"}},showcoastlines:{valType:"boolean"},coastlinecolor:{valType:"color",dflt:n.defaultLine},coastlinewidth:{valType:"number",min:0,dflt:1},showland:{valType:"boolean",dflt:!1},landcolor:{valType:"color",dflt:i.landColor},showocean:{valType:"boolean",dflt:!1},oceancolor:{valType:"color",dflt:i.waterColor},showlakes:{valType:"boolean",dflt:!1},lakecolor:{valType:"color",dflt:i.waterColor},showrivers:{valType:"boolean",dflt:!1},rivercolor:{valType:"color",dflt:i.waterColor},riverwidth:{valType:"number",min:0,dflt:1},showcountries:{valType:"boolean"},countrycolor:{valType:"color",dflt:n.defaultLine},countrywidth:{valType:"number",min:0,dflt:1},showsubunits:{valType:"boolean"},subunitcolor:{valType:"color",dflt:n.defaultLine},subunitwidth:{valType:"number",min:0,dflt:1},showframe:{valType:"boolean"},framecolor:{valType:"color",dflt:n.defaultLine},framewidth:{valType:"number",min:0,dflt:1},bgcolor:{valType:"color",dflt:n.background},lonaxis:o,lataxis:o},"plot","from-root")},{"../../../components/color/attributes":612,"../../../plot_api/edit_types":769,"../constants":812}],818:[function(t,e,r){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:r(t.geometry,e)}}function r(e,n){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map(function(t){return r(t,n)})};if(!M.hasOwnProperty(e.type))return null;var i=M[e.type];return t.geo.stream(e,n(i)),i.result()}function n(){}function i(t){return t>1?S:t<-1?-S:Math.asin(t)}function a(t){return t>1?0:t<-1?A:Math.acos(t)}function o(t,e){var r=(2+S)*Math.sin(e);e/=2;for(var n=0,i=1/0;n<10&&Math.abs(i)>k;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(A*(4+A))*t*(1+Math.cos(e)),2*Math.sqrt(A/(4+A))*Math.sin(e)]}function s(t,e){function r(r,n){var i=P(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?P:e===1/0?l:(r.invert=function(r,n){var i=P.invert(r/t,n);return i[0]*=e,i},r)}function l(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function c(t,e){return[3*t/(2*A)*Math.sqrt(A*A/3-e*e),e]}function u(t,e){return[t,1.25*Math.log(Math.tan(A/4+.4*e))]}function h(t){return function(e){var r,n=t*Math.sin(e),i=30;do{e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e))}while(Math.abs(r)>k&&--i>0);return e/2}}function f(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791)),e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))]}function d(t,e){var r,n=Math.min(18,36*Math.abs(e)/A),i=Math.floor(n),a=n-i,o=(r=z[i])[0],s=r[1],l=(r=z[++i])[0],c=r[1],u=(r=z[Math.min(19,++i)])[0],h=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?S:-S)*(c+a*(h-s)/2+a*a*(h-2*c+s)/2)]}function p(t,e){return[t*Math.cos(e),e]}function m(t,e){var r=Math.cos(e),n=function(t){return t?t/Math.sin(t):1}(a(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function g(t,e){var r=m(t,e);return[(r[0]+t/S)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&v.hasOwnProperty(t.type)?v[t.type]:r)(t,n)};var v={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},y=[],b=[],x={point:function(t,e){y.push([t,e])},result:function(){var t=y.length?y.length<2?{type:"Point",coordinates:y[0]}:{type:"MultiPoint",coordinates:y}:null;return y=[],t}},_={lineStart:n,point:function(t,e){y.push([t,e])},lineEnd:function(){y.length&&(b.push(y),y=[])},result:function(){var t=b.length?b.length<2?{type:"LineString",coordinates:b[0]}:{type:"MultiLineString",coordinates:b}:null;return b=[],t}},w={polygonStart:n,lineStart:n,point:function(t,e){y.push([t,e])},lineEnd:function(){var t=y.length;if(t){do{y.push(y[0].slice())}while(++t<4);b.push(y),y=[]}},polygonEnd:n,result:function(){if(!b.length)return null;var t=[],e=[];return b.forEach(function(r){!function(t){if((e=t.length)<4)return!1;for(var e,r=0,n=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++rn^d>n&&r<(f-c)*(n-u)/(d-u)+c&&(i=!i)}return i}(t[0],r))return t.push(e),!0})||t.push([e])}),b=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},M={Point:x,MultiPoint:x,LineString:_,MultiLineString:_,Polygon:w,MultiPolygon:w,Sphere:w},k=1e-6,T=k*k,A=Math.PI,S=A/2,E=(Math.sqrt(A),A/180),L=180/A,C=t.geo.projection,I=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=r<0?-1:1,i=a[+(r<0)],o=0,s=i.length-1;oi[o][2][0];++o);var l=e(t-i[o][1][0],r);return l[0]+=e(i[o][1][0],n*r>n*i[o][0][1]?i[o][0][1]:r)[0],l}function n(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++a=0;--r){var h;o=180*(h=a[1][r])[0][0]/A,s=180*h[0][1]/A,l=180*h[1][1]/A,c=180*h[2][0]/A,u=180*h[2][1]/A,e.push(n([[c-1e-6,u-1e-6],[c-1e-6,l+1e-6],[o+1e-6,l+1e-6],[o+1e-6,s-1e-6]],30))}return{type:"Polygon",coordinates:[t.merge(e)]}}(),l)},i},o.lobes=function(t){return arguments.length?(a=t.map(function(t){return t.map(function(t){return[[t[0][0]*A/180,t[0][1]*A/180],[t[1][0]*A/180,t[1][1]*A/180],[t[2][0]*A/180,t[2][1]*A/180]]})}),i=a.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})}),o):a.map(function(t){return t.map(function(t){return[[180*t[0][0]/A,180*t[0][1]/A],[180*t[1][0]/A,180*t[1][1]/A],[180*t[2][0]/A,180*t[2][1]/A]]})})},o},o.invert=function(t,e){var r=.5*e*Math.sqrt((4+A)/A),n=i(r),a=Math.cos(n);return[t/(2/Math.sqrt(A*(4+A))*(1+a)),i((n+r*(a+2))/(2+S))]},(t.geo.eckert4=function(){return C(o)}).raw=o;var P=t.geo.azimuthalEqualArea.raw;l.invert=function(t,e){var r=2*i(e/2);return[t*Math.cos(r/2)/Math.cos(r),r]},(t.geo.hammer=function(){var t=2,e=I(s),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}).raw=s,c.invert=function(t,e){return[2/3*A*t/Math.sqrt(A*A/3-e*e),e]},(t.geo.kavrayskiy7=function(){return C(c)}).raw=c,u.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*A]},(t.geo.miller=function(){return C(u)}).raw=u,h(A);var D=function(t,e,r){function n(r,n){return[t*r*Math.cos(n=a(n)),e*Math.sin(n)]}var a=h(r);return n.invert=function(n,a){var o=i(a/e);return[n/(t*Math.cos(o)),i((2*o+Math.sin(2*o))/r)]},n}(Math.SQRT2/S,Math.SQRT2,A);(t.geo.mollweide=function(){return C(D)}).raw=D,f.invert=function(t,e){var r,n=e,i=25;do{var a=n*n,o=a*a;n-=r=(n*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-e)/(1.007226+a*(.045255+o*(.259866*a-.311325-.005916*11*o)))}while(Math.abs(r)>k&&--i>0);return[t/(.8707+(a=n*n)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979)),n]},(t.geo.naturalEarth=function(){return C(f)}).raw=f;var z=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];z.forEach(function(t){t[1]*=1.0144}),d.invert=function(t,e){var r=e/S,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=z[a][1],s=z[a+1][1],l=z[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,h=2*(Math.abs(r)-s)/c,f=u/c,d=h*(1-f*h*(1-2*f*h));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,m=50;do{d=(i=Math.min(18,Math.abs(n)/5))-(a=Math.floor(i)),o=z[a][1],s=z[a+1][1],l=z[Math.min(19,a+2)][1],n-=(p=(e>=0?S:-S)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*L}while(Math.abs(p)>T&&--m>0);break}}while(--a>=0);var g=z[a][0],v=z[a+1][0],y=z[Math.min(19,a+2)][0];return[t/(v+d*(y-g)/2+d*d*(y-2*v+g)/2),n*E]},(t.geo.robinson=function(){return C(d)}).raw=d,p.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return C(p)}).raw=p,m.invert=function(t,e){if(!(t*t+4*e*e>A*A+k)){var r=t,n=e,i=25;do{var o,s=Math.sin(r),l=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),h=Math.cos(n),f=Math.sin(2*n),d=u*u,p=h*h,m=l*l,g=1-p*c*c,v=g?a(h*c)*Math.sqrt(o=1/g):o=0,y=2*v*h*l-t,b=v*u-e,x=o*(p*m+v*h*c*d),_=o*(.5*s*f-2*v*u*l),w=.25*o*(f*l-v*u*p*s),M=o*(d*c+v*m*h),T=_*w-M*x;if(!T)break;var S=(b*_-y*M)/T,E=(y*w-b*x)/T;r-=S,n-=E}while((Math.abs(S)>k||Math.abs(E)>k)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return C(m)}).raw=m,g.invert=function(t,e){var r=t,n=e,i=25;do{var o,s=Math.cos(n),l=Math.sin(n),c=Math.sin(2*n),u=l*l,h=s*s,f=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),m=p*p,g=1-h*d*d,v=g?a(s*d)*Math.sqrt(o=1/g):o=0,y=.5*(2*v*s*p+r/S)-t,b=.5*(v*l+n)-e,x=.5*o*(h*m+v*s*d*u)+.5/S,_=o*(f*c/4-v*l*p),w=.125*o*(c*p-v*l*h*f),M=.5*o*(u*d+v*m*s)+.5,T=_*w-M*x,A=(b*_-y*M)/T,E=(y*w-b*x)/T;r-=A,n-=E}while((Math.abs(A)>k||Math.abs(E)>k)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return C(g)}).raw=g}},{}],819:[function(t,e,r){"use strict";function n(t,e){return d.behavior.zoom().translate(e.translate()).scale(e.scale())}function i(t,e,r){function n(t,e){var r=p.nestedProperty(s,t);r.get()!==e&&(r.set(e),p.nestedProperty(o,t).set(e),l[i+"."+t]=e)}var i=t.id,a=t.graphDiv,o=a.layout[i],s=a._fullLayout[i],l={};r(n),n("projection.scale",e.scale()/t.fitScale),a.emit("plotly_relayout",l)}function a(t,e){function r(r){var n=e.invert(t.midPt);r("center.lon",n[0]),r("center.lat",n[1])}var a=n(0,e);return a.on("zoomstart",function(){d.select(this).style(v)}).on("zoom",function(){e.scale(d.event.scale).translate(d.event.translate),t.render()}).on("zoomend",function(){d.select(this).style(y),i(t,e,r)}),a}function o(t,e){function r(t){return e.invert(t)}function a(r){var n=e.rotate(),i=e.invert(t.midPt);r("projection.rotation.lon",-n[0]),r("center.lon",i[0]),r("center.lat",i[1])}var o,s,l,c,u,h,f,p,m=n(0,e),g=2;return m.on("zoomstart",function(){d.select(this).style(v),o=d.mouse(this),s=e.rotate(),l=e.translate(),c=s,u=r(o)}).on("zoom",function(){if(h=d.mouse(this),function(t){var n=e(r(t));return Math.abs(n[0]-t[0])>g||Math.abs(n[1]-t[1])>g}(o))return m.scale(e.scale()),void m.translate(e.translate());e.scale(d.event.scale),e.translate([l[0],d.event.translate[1]]),u?r(h)&&(p=r(h),f=[c[0]+(p[0]-u[0]),s[1],s[2]],e.rotate(f),c=f):u=r(o=h),t.render()}).on("zoomend",function(){d.select(this).style(y),i(t,e,a)}),m}function s(t,e){function r(t){var r=e.rotate();t("projection.rotation.lon",-r[0]),t("projection.rotation.lat",-r[1])}var a,o={r:e.rotate(),k:e.scale()},s=n(0,e),u=function(t){var e=0,r=arguments.length,n=[];for(;++em?(a=(f>0?90:-90)-p,i=0):(a=Math.asin(f/m)*g-p,i=Math.sqrt(m*m-f*f));var v=180-a-2*p,y=(Math.atan2(d,u)-Math.atan2(l,i))*g,b=(Math.atan2(d,u)-Math.atan2(l,-i))*g,x=c(r[0],r[1],a,y),_=c(r[0],r[1],v,b);return x<=_?[a,y,r[2]]:[v,b,r[2]]}(v,a,n);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=n),e.rotate(b),n=b}}else a=l(e,t=s);!function(t){t({type:"zoom"})}(u.of(this,arguments))}),function(t){p++||t({type:"zoomstart"})}(u.of(this,arguments))}).on("zoomend",function(){d.select(this).style(y),b.call(s,"zoom",null),function(t){--p||t({type:"zoomend"})}(u.of(this,arguments)),i(t,e,r)}).on("zoom.redraw",function(){t.render()}),d.rebind(s,u,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&function(t){var e=t[0]*m,r=t[1]*m,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}(r)}function c(t,e,r,n){var i=u(r-t),a=u(n-e);return Math.sqrt(i*i+a*a)}function u(t){return(t%360+540)%360-180}function h(t,e,r){var n=r*m,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function f(t,e){for(var r=0,n=0,i=t.length;nMath.abs(u)?(c.boxEnd[1]=c.boxStart[1]+Math.abs(s)*_*(u>=0?1:-1),c.boxEnd[1]h[3]&&(c.boxEnd[1]=h[3],c.boxEnd[0]=c.boxStart[0]+(h[3]-c.boxStart[1])/Math.abs(_))):(c.boxEnd[0]=c.boxStart[0]+Math.abs(u)/_*(s>=0?1:-1),c.boxEnd[0]h[2]&&(c.boxEnd[0]=h[2],c.boxEnd[1]=c.boxStart[1]+(h[2]-c.boxStart[0])*Math.abs(_)))}}else c.boxEnabled?(s=c.boxStart[0]!==c.boxEnd[0],u=c.boxStart[1]!==c.boxEnd[1],s||u?(s&&(a(0,c.boxStart[0],c.boxEnd[0]),t.xaxis.autorange=!1),u&&(a(1,c.boxStart[1],c.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),c.boxEnabled=!1,c.boxInited=!1):c.boxInited&&(c.boxInited=!1);break;case"pan":c.boxEnabled=!1,c.boxInited=!1,r?(c.panning||(c.dragStart[0]=n,c.dragStart[1]=i),Math.abs(c.dragStart[0]-n)f[p+2]&&(f[p]=-1,f[p+2]=1),(d=this[x[p]])._length=o.viewBox[p+2]-o.viewBox[p],s.doAutoRange(d),d.setScale();y(l),o.ticks=this.computeTickMarks(),o.dataBox=this.calcDataBox(),o.merge(r),n.update(o),this.glplot.draw()},w.calcDataBox=function(){var t=this.xaxis,e=this.yaxis,r=t.range,n=e.range,i=t.r2l,a=e.r2l;return[i(r[0]),a(n[0]),i(r[1]),a(n[1])]},w.setRanges=function(t){var e=this.xaxis,r=this.yaxis,n=e.l2r,i=r.l2r;e.range=[n(t[0]),n(t[2])],r.range=[i(t[1]),i(t[3])]},w.updateTraces=function(t,e){var r,n,i,a=Object.keys(this.traces);this.fullData=t;t:for(r=0;rMath.abs(e))c.rotate(a,0,0,-t*r*Math.PI*p.rotateSpeed/window.innerWidth);else{var o=-p.zoomSpeed*i*e/window.innerHeight*(a-c.lastT())/20;c.pan(a,0,0,h*(Math.exp(o)-1))}}},!0),p};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset")},{"3d-view":38,"mouse-change":453,"mouse-event-offset":454,"mouse-wheel":456,"right-now":511}],826:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../components/fx/layout_attributes"),a=t("./scene"),o=t("../get_data").getSubplotData,s=t("../../lib"),l=t("../../constants/xmlns_namespaces");r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=r.attrRegex=s.counterRegex("scene"),r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.baseLayoutAttrOverrides=n({hoverlabel:i.hoverlabel},"plot","nested"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=e._subplots.gl3d,i=0;i1;s(t,e,r,{type:"gl3d",attributes:c,handleDefaults:n,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!a)return i.validate(t[e],c[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":613,"../../../lib":738,"../../../registry":861,"../../subplot_defaults":853,"./axis_defaults":829,"./layout_attributes":832}],832:[function(t,e,r){"use strict";function n(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}var i=t("./axis_attributes"),a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(n(0,0,1),{}),center:a(n(0,0,0),{}),eye:a(n(1.25,1.25,1.25),{}),editType:"camera"},domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1,editType:"plot"},{valType:"number",min:0,max:1,editType:"plot"}],dflt:[0,1],editType:"plot"},y:{valType:"info_array",items:[{valType:"number",min:0,max:1,editType:"plot"},{valType:"number",min:0,max:1,editType:"plot"}],dflt:[0,1],editType:"plot"},editType:"plot"},aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:i,yaxis:i,zaxis:i,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],dflt:"turntable",editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":738,"../../../lib/extend":727,"./axis_attributes":828}],833:[function(t,e,r){"use strict";function n(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}var i=t("../../../lib/str2rgbarray"),a=["xaxis","yaxis","zaxis"];n.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[a[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=i(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new n;return e.merge(t),e}},{"../../../lib/str2rgbarray":760}],834:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,l=t.fullSceneLayout,c=[[],[],[]],u=0;u<3;++u){var h=l[o[u]];if(h._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(h._length)===1/0)c[u]=[];else{h.range[0]=r[u].lo/t.dataScale[u],h.range[1]=r[u].hi/t.dataScale[u],h._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),h.range[0]===h.range[1]&&(h.range[0]-=1,h.range[1]+=1);var f=h.tickmode;if("auto"===h.tickmode){h.tickmode="linear";var d=h.nticks||i.constrain(h._length/40,4,9);n.autoTicks(h,Math.abs(h.range[1]-h.range[0])/d)}for(var p=n.calcTicks(h),m=0;mf[1][s]?d[s]=1:f[1][s]===f[0][s]?d[s]=1:d[s]=1/(f[1][s]-f[0][s]);for(this.dataScale=d,this.convertAnnotations(this),a=0;am[1][a])m[0][a]=-1,m[1][a]=1;else{var A=m[1][a]-m[0][a];m[0][a]-=A/32,m[1][a]+=A/32}}else{var S=l.range;m[0][a]=l.r2l(S[0]),m[1][a]=l.r2l(S[1])}m[0][a]===m[1][a]&&(m[0][a]-=1,m[1][a]+=1),v[a]=m[1][a]-m[0][a],this.glplot.bounds[0][a]=m[0][a]*d[a],this.glplot.bounds[1][a]=m[1][a]*d[a]}var E=[1,1,1];for(a=0;a<3;++a){var L=y[c=(l=u[k[a]]).type];E[a]=Math.pow(L.acc,1/L.count)/d[a]}var C;if("auto"===u.aspectmode)C=Math.max.apply(null,E)/Math.min.apply(null,E)<=4?E:[1,1,1];else if("cube"===u.aspectmode)C=[1,1,1];else if("data"===u.aspectmode)C=E;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var I=u.aspectratio;C=[I.x,I.y,I.z]}u.aspectratio.x=h.aspectratio.x=C[0],u.aspectratio.y=h.aspectratio.y=C[1],u.aspectratio.z=h.aspectratio.z=C[2],this.glplot.aspect=C;var P=u.domain||null,D=e._size||null;if(P&&D){var z=this.container.style;z.position="absolute",z.left=D.l+P.x[0]*D.w+"px",z.top=D.t+(1-P.y[1])*D.h+"px",z.width=D.w*(P.x[1]-P.x[0])+"px",z.height=D.h*(P.y[1]-P.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=this.glplot.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),s(this.glplot.camera)},M.setCamera=function(t){this.glplot.camera.lookAt.apply(this,function(t){return[[t.eye.x,t.eye.y,t.eye.z],[t.center.x,t.center.y,t.center.z],[t.up.x,t.up.y,t.up.z]]}(t))},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;o<3;o++)for(var s=0;s<3;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(l),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;a0}var a=t("../../lib"),o=t("./convert_text_opts"),s=n.prototype;s.update=function(t){this.visible?this.needsNewSource(t)?(this.updateLayer(t),this.updateSource(t)):this.needsNewLayer(t)&&this.updateLayer(t):(this.updateSource(t),this.updateLayer(t)),this.updateStyle(t),this.visible=i(t)},s.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},s.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==t.below},s.updateSource=function(t){var e=this.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,i(t)){var r=function(t){var e,r=t.sourcetype,n=t.source,i={type:r};return"geojson"===r?e="data":"vector"===r&&(e="string"==typeof n?"url":"tiles"),i[e]=n,i}(t);e.addSource(this.idSource,r)}},s.updateLayer=function(t){var e=this.map;if(e.getLayer(this.idLayer)&&e.removeLayer(this.idLayer),this.layerType=t.type,i(t)){e.addLayer({id:this.idLayer,source:this.idSource,"source-layer":t.sourcelayer||"",type:t.type},t.below);this.mapbox.setOptions(this.idLayer,"setLayoutProperty",{visibility:"visible"})}},s.updateStyle=function(t){var e=function(t){var e={},r={};switch(t.type){case"circle":a.extendFlat(r,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":a.extendFlat(r,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity});break;case"fill":a.extendFlat(r,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var n=t.symbol,i=o(n.textposition,n.iconsize);a.extendFlat(e,{"icon-image":n.icon+"-15","icon-size":n.iconsize/10,"text-field":n.text,"text-size":n.textfont.size,"text-anchor":i.anchor,"text-offset":i.offset}),a.extendFlat(r,{"icon-color":t.color,"text-color":n.textfont.color,"text-opacity":t.opacity})}return{layout:e,paint:r}}(t);i(t)&&(this.mapbox.setOptions(this.idLayer,"setLayoutProperty",e.layout),this.mapbox.setOptions(this.idLayer,"setPaintProperty",e.paint))},s.dispose=function(){var t=this.map;t.removeLayer(this.idLayer),t.removeSource(this.idSource)},e.exports=function(t,e,r){var i=new n(t,e);return i.update(r),i}},{"../../lib":738,"./convert_text_opts":839}],842:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color").defaultLine,a=t("../font_attributes"),o=t("../../traces/scatter/attributes").textposition,s=t("../../plot_api/edit_types").overrideAll,l=a({});l.family.dflt="Open Sans Regular, Arial Unicode MS Regular",e.exports=s({_arrayAttrRegexps:[n.counterRegex("mapbox",".layers",!0)],domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},accesstoken:{valType:"string",noBlank:!0,strict:!0},style:{valType:"any",values:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],dflt:"basic"},center:{lon:{valType:"number",dflt:0},lat:{valType:"number",dflt:0}},zoom:{valType:"number",dflt:1},bearing:{valType:"number",dflt:0},pitch:{valType:"number",dflt:0},layers:{_isLinkedToArray:"layer",sourcetype:{valType:"enumerated",values:["geojson","vector"],dflt:"geojson"},source:{valType:"any"},sourcelayer:{valType:"string",dflt:""},type:{valType:"enumerated",values:["circle","line","fill","symbol"],dflt:"circle"},below:{valType:"string",dflt:""},color:{valType:"color",dflt:i},opacity:{valType:"number",min:0,max:1,dflt:1},circle:{radius:{valType:"number",dflt:15}},line:{width:{valType:"number",dflt:2}},fill:{outlinecolor:{valType:"color",dflt:i}},symbol:{icon:{valType:"string",dflt:"marker"},iconsize:{valType:"number",dflt:10},text:{valType:"string",dflt:""},textfont:l,textposition:n.extendFlat({},o,{arrayOk:!1})}}},"plot","from-root")},{"../../components/color":613,"../../lib":738,"../../plot_api/edit_types":769,"../../traces/scatter/attributes":1054,"../font_attributes":810}],843:[function(t,e,r){"use strict";function n(t,e,r){r("accesstoken"),r("style"),r("center.lon"),r("center.lat"),r("zoom"),r("bearing"),r("pitch"),function(t,e){function r(t,e){return i.coerce(n,a,o.layers,t,e)}var n,a,s=t.layers||[],l=e.layers=[];for(var c=0;c=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),l=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){p.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&l.text()?" - ":"")}},p.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=i.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return n.append("input").attr({type:"text",name:"data"}).node().value=p.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},p.supplyDefaults=function(t){var e,r=t._fullLayout||{},n=t._fullLayout={},a=t.layout||{},o=t._fullData||[],s=t._fullData=[],f=t.data||[];t._transitionData||p.createTransitionData(t),n._dfltTitle={plot:h(t,"Click to enter Plot title"),x:h(t,"Click to enter X axis title"),y:h(t,"Click to enter Y axis title"),colorbar:h(t,"Click to enter Colorscale title")},n._traceWord=h(t,"trace");var d=function(t){function e(t){for(var e=!0,r=0;r=0)return!0}return!1},p.cleanPlot=function(t,e,r,n){var i,a,o=n._basePlotModules||[];for(i=0;i0){var c=function(t){var e,r={left:0,right:0,bottom:0,top:0};if(t)for(e in t)t.hasOwnProperty(e)&&(r.left+=t[e].left||0,r.right+=t[e].right||0,r.bottom+=t[e].bottom||0,r.top+=t[e].top||0);return r}(t._boundingBoxMargins),h=c.left+c.right,f=c.bottom+c.top,d=1-2*s,m=r._container&&r._container.node?r._container.node().getBoundingClientRect():{width:r.width,height:r.height};n=Math.round(d*(m.width-h)),i=Math.round(d*(m.height-f))}else{var g=l?window.getComputedStyle(t):{};n=parseFloat(g.width)||r.width,i=parseFloat(g.height)||r.height}var v=p.layoutAttributes.width.min,y=p.layoutAttributes.height.min;n1,x=!e.height&&Math.abs(r.height-i)>1;(x||b)&&(b&&(r.width=n),x&&(r.height=i)),t._initialAutoSize||(t._initialAutoSize={width:n,height:i}),p.sanitizeMargins(r)},p.supplyLayoutModuleDefaults=function(t,e,r,n){var i,a,o,s=l.componentsRegistry,c=e._basePlotModules,u=l.subplotsRegistry.cartesian;for(i in s)(o=s[i]).includeBasePlot&&o.includeBasePlot(t,e);for(c.length||c.push(u),e._has("cartesian")&&u.finalizeSubplots(t,e),a=0;a.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];n._replotting||p.doAutoMargin(t)}},p.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),s=Math.max(e.margin.r||0,0),l=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;if(!1!==e.margin.autoexpand){u.base={l:{val:0,size:i},r:{val:1,size:s},t:{val:1,size:l},b:{val:0,size:c}};for(var h in u){var f=u[h].l||{},d=u[h].b||{},p=f.val,m=f.size,g=d.val,v=d.size;for(var y in u){if(a(m)&&u[y].r){var b=u[y].r.val,x=u[y].r.size;if(b>p){var _=(m*b+(x-e.width)*p)/(b-p),w=(x*(1-p)+(m-e.width)*(1-b))/(b-p);_>=0&&w>=0&&_+w>i+s&&(i=_,s=w)}}if(a(v)&&u[y].t){var M=u[y].t.val,k=u[y].t.size;if(M>g){var T=(v*M+(k-e.height)*g)/(M-g),A=(k*(1-g)+(v-e.height)*(1-M))/(M-g);T>=0&&A>=0&&T+A>c+l&&(c=T,l=A)}}}}}if(r.l=Math.round(i),r.r=Math.round(s),r.t=Math.round(l),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!e._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return o.plot(t)},p.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(u.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!u.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):u.isJSDate(t)?u.ms2DateTimeLocal(+t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&p.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l=(t._transitionData||{})._frames,c={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(c.layout=a(s)),t.framework&&t.framework.isPolar&&(c=t.framework.getConfig()),l&&(c.frames=a(l)),"object"===n?c:JSON.stringify(c)},p.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push(function(){d=!0}),i.redraw&&t._transitionData._interruptCallbacks.push(function(){return o.redraw(t)}),t._transitionData._interruptCallbacks.push(function(){t.emit("plotly_transitioninterrupted",[])});var s,l,c=0,h=0,p=t._fullLayout._basePlotModules,m=!1;if(r)for(l=0;l=0;o--)if(x[o].enabled){r._indexToPoints=x[o]._indexToPoints;break}i&&i.calc&&(b=i.calc(t,r))}Array.isArray(b)&&b[0]||(b=[{x:d,y:d}]),b[0].t||(b[0].t={}),b[0].trace=r,p[a]=b}l.getComponentMethod("fx","calc")(t)},p.rehover=function(t){t._fullLayout._rehover&&t._fullLayout._rehover()},p.generalUpdatePerTraceModule=function(t,e,r){function n(t){for(var e=[],r=0;r=0?f.angularAxis.domain:n.extent(M),E=Math.abs(M[1]-M[0]);T&&!k&&(E=0);var L=S.slice();A&&k&&(L[1]+=E);var C=f.angularAxis.ticksCount||4;C>8&&(C=C/(C/8)+C%8),f.angularAxis.ticksStep&&(C=(L[1]-L[0])/C);var I=f.angularAxis.ticksStep||(L[1]-L[0])/(C*(f.minorTicks+1));w&&(I=Math.max(Math.round(I),1)),L[2]||(L[2]=I);var P=n.range.apply(this,L);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=n.scale.linear().domain(L.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=A?E:0,void 0===(t=n.select(this).select("svg.chart-root"))||t.empty()){var D=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),z=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));t=n.select(z)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var O,F=t.select(".chart-group"),R={fill:"none",stroke:f.tickColor},j={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){O=t.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var N=p.map(function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend=void 0===t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});o.Legend().config({data:p.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:O,elements:N,reverseOrder:f.legend.reverseOrder})})();var B=O.node().getBBox();b=Math.min(f.width-B.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],r.range([0,b]),u.layout.radialAxis.domain=r.domain(),O.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else O=t.select(".legend-group").style({display:"none"});t.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(f.width-(f.margin.left+f.margin.right+2*b+(B?B.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),t.select(".outer-group").attr("transform","translate("+U+")"),f.title){var V=t.select("g.title-group text").style(j).text(f.title),H=V.node().getBBox();V.attr({x:_[0]-H.width/2,y:_[1]-b-20})}var q=t.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=q.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(R),G.attr("r",r),G.exit().remove()}q.select("circle.outside-circle").attr({r:b}).style(R);var Y=t.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var W=n.svg.axis().scale(r).ticks(5).tickSize(5);q.call(W).attr({transform:"rotate("+f.radialAxis.orientation+")"}),q.selectAll(".domain").style(R),q.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(j).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,j["font-size"]]+")":"translate("+[0,j["font-size"]]+")"}}),q.selectAll("g>line").style({stroke:"black"})}var X=t.select(".angular.axis-group").selectAll("g.angular-tick").data(P),Z=X.enter().append("g").classed("angular-tick",!0);X.attr({transform:function(t,e){return"rotate("+c(t)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),X.exit().remove(),Z.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(R),Z.selectAll(".minor").style({stroke:f.minorTickColor}),X.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Z.append("text").classed("axis-text",!0).style(j);var J=X.select("text.axis-text").attr({x:b+f.labelOffset,dy:a+"em",transform:function(t,e){var r=c(t),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":w?w[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(j);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var K=n.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));O.attr({transform:"translate("+[b+K,f.margin.top]+")"});var Q=t.select("g.geometry-group").selectAll("g").size()>0,$=t.select("g.geometry-group").selectAll("g.geometry").data(p);if($.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),$.exit().remove(),p[0]||Q){var tt=[];p.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=$.filter(function(t,r){return r==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,tt.push({data:t,geometryConfig:n})});var et=[];n.nest().key(function(t,e){return void 0!==t.data.groupId||"unstacked"}).entries(tt).forEach(function(t,e){"unstacked"===t.key?et=et.concat(t.values.map(function(t,e){return[t]})):et.push(t.values)}),et.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return i(o[r].defaultConfig(),t)});o[r]().config(n)()})}var rt,nt,it=t.select(".guides-group"),at=t.select(".tooltips-group"),ot=o.tooltipPanel().config({container:at,fontSize:8})(),st=o.tooltipPanel().config({container:at,fontSize:8})(),lt=o.tooltipPanel().config({container:at,hasTick:!0})();if(!k){var ct=it.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var r=o.util.getMousePos(Y).angle;ct.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;rt=s.invert(n);var i=o.util.convertToCartesian(b+12,r+180);ot.text(o.util.round(rt)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){it.select("line").style({opacity:0})})}var ut=it.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Y).radius;ut.attr({r:n}).style({opacity:.5}),nt=r.invert(o.util.getMousePos(Y).radius);var i=o.util.convertToCartesian(n,f.radialAxis.orientation);st.text(o.util.round(nt)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){ut.style({opacity:0}),lt.hide(),ot.hide(),st.hide()}),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};k&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,h=this.getBoundingClientRect(),f=t.node().getBoundingClientRect(),d=[h.left+h.width/2-U[0]-f.left,h.top+h.height/2-U[1]-f.top];lt.config({color:s}).text(u),lt.move(d)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&<.show()}).on("mouseout.tooltip",function(t,e){lt.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})})}(c),this},f.config=function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)}),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},f.getLiveConfig=function(){return u},f.getinputConfig=function(){return c},f.radialScale=function(t){return r},f.angularScale=function(t){return s},f.svg=function(){return t},n.rebind(f,h,"on"),f},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180;return[e,t(n)]})},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if(void 0===t)return null;var r=[].concat(t);return n.range(e).map(function(t,e){return r[e]||r[0]})},o.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=o.util.ensureArray(t[e],r)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map(function(t,e){return n.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:u(s),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return p.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return p.stroke(r,i,a)},"stroke-width":function(t,e){return p["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return p["stroke-dasharray"](r,i,a)},opacity:function(t,e){return p.opacity(r,i,a)},display:function(t,e){return p.display(r,i,a)}})}};var h=t.angularScale.range(),f=Math.abs(h[1]-h[0])/o[0].length*Math.PI/180,d=n.svg.arc().startAngle(function(t){return-f/2}).endAngle(function(t){return f/2}).innerRadius(function(e){return t.radialScale(l+(e[2]||0))}).outerRadius(function(e){return t.radialScale(l+(e[2]||0))+t.radialScale(e[1])});c.arc=function(e,r,i){n.select(this).attr({class:"mark arc",d:d,transform:function(e,r){return"rotate("+(t.orientation+s(e[0])+90)+")"}})};var p={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return a[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return void 0===e[n].data.visible||e[n].data.visible?"block":"none"}},m=n.select(this).selectAll("g.layer").data(o);m.enter().append("g").attr({class:"layer"});var g=m.selectAll("path.mark").data(function(t,e){return t});g.enter().append("path").attr({class:"mark"}),g.style(p).each(c[t.geometryType]),g.exit().remove(),m.exit().remove()})}var e=[o.PolyChart.defaultConfig()],r=n.dispatch("hover"),a={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,r){e[r]||(e[r]={}),i(e[r],o.PolyChart.defaultConfig()),i(e[r],t)}),this):e},t.getColorScale=function(){},n.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){function t(){var r=e.legendConfig,a=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var a=i({},r.elements[e]);return a.name=t,a.color=[].concat(r.elements[e].color)[n],a})}),o=n.merge(a);o=o.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||void 0===r.elements[e].visibleInLegend)}),r.reverseOrder&&(o=o.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof o[0]:r.isContinuous,h=u?r.height:c*o.length,f=s.classed("legend-group",!0).selectAll("svg").data([0]),d=f.enter().append("svg").attr({width:300,height:h+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});d.append("g").classed("legend-axis",!0),d.append("g").classed("legend-marks",!0);var p=n.range(o.length),m=n.scale[u?"linear":"ordinal"]().domain(p).range(l),g=n.scale[u?"linear":"ordinal"]().domain(p)[u?"range":"rangePoints"]([0,h]);if(u){var v=f.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);v.enter().append("stop"),v.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),f.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var y=f.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[c/2,g(e)+c/2]+")"},d:function(t,e){return function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(t)?n.svg.symbol().type(t).size(r)():n.svg.symbol().type("square").size(r)()}(t.symbol,c)},fill:function(t,e){return m(e)}}),y.exit().remove()}var b=n.svg.axis().scale(g).orient("right"),x=f.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(b);return x.selectAll(".domain").style({fill:"none",stroke:"none"}),x.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),x.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),r=n.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},n.rebind(t,r,"on"),t},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,c=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),c};return c.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",h=i||"";e.style({fill:u,"font-size":a.fontSize+"px"}).text(h);var f=a.padding,d=e.node().getBBox(),p={fill:a.color,stroke:s,"stroke-width":"2px"},m=d.width+2*f+l,g=d.height+2*f;return r.attr({d:"M"+[[l,-g/2],[l,-g/4],[a.hasTick?0:l,0],[l,g/4],[l,g/2],[m,g/2],[m,-g/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-g/2+2*f]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(a,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)})}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach(function(t,r){o.util.translator.apply(null,t.concat(e))}),e?(void 0!==s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&void 0!==s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&void 0!==s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&void 0!==s.margin.t){var l=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(s.margin).forEach(function(t,e){u[c[l.indexOf(t.key)]]=t.value}),s.margin=u}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../constants/alignment":711,"../../lib":738,d3:123}],851:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,c=e.exports={};c.framework=function(t){function e(e,i){return i&&(h=i),n.select(n.select(h).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?l(r,e):e,a||(a=o.Axis()),u=o.adapter.plotly().convert(r),a.config(u).render(h),t.data=r.data,t.layout=r.layout,c.fillLayout(t),r}var r,i,a,u,h,f=new s;return e.isPolar=!0,e.svg=function(){return a.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return o.adapter.plotly().convert(a.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:a.angularScale(),r:a.radialScale()}},e.setUndoPoint=function(){var t=this,e=o.util.cloneJson(r);!function(e,r){f.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,i),i=o.util.cloneJson(e)},e.undo=function(){f.undo()},e.redo=function(){f.redo()},e},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../components/color":613,"../../lib":738,"./micropolar":850,"./undo_manager":852,d3:123}],852:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n=o&&(d.min=0,p.min=0,m.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":613,"../../subplot_defaults":853,"./axis_defaults":857,"./layout_attributes":859}],859:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes"),a=t("../../../plot_api/edit_types").overrideAll;e.exports=a({domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i},"plot","from-root")},{"../../../components/color/attributes":612,"../../../plot_api/edit_types":769,"./axis_attributes":856}],860:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e)}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=l._,u=t("../../components/color"),h=t("../../components/drawing"),f=t("../cartesian/set_convert"),d=t("../../lib/extend").extendFlat,p=t("../plots"),m=t("../cartesian/axes"),g=t("../../components/dragelement"),v=t("../../components/fx"),y=t("../../components/titles"),b=t("../cartesian/select"),x=t("../cartesian/constants");e.exports=n;var _=n.prototype;_.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},_.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var i=0;iw*b?i=(a=b)*w:a=(i=y)/w,o=g*i/y,s=v*a/b,r=e.l+e.w*p-i/2,n=e.t+e.h*(1-m)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=x,l.xaxis={type:"linear",range:[_+2*k-x,x-_-2*M],domain:[p-o/2,p+o/2],_id:"x"},f(l.xaxis,l.graphDiv._fullLayout),l.xaxis.setScale(),l.xaxis.isPtWithinRange=function(t){return t.a>=l.aaxis.range[0]&&t.a<=l.aaxis.range[1]&&t.b>=l.baxis.range[1]&&t.b<=l.baxis.range[0]&&t.c>=l.caxis.range[1]&&t.c<=l.caxis.range[0]},l.yaxis={type:"linear",range:[_,x-M-k],domain:[m-s/2,m+s/2],_id:"y"},f(l.yaxis,l.graphDiv._fullLayout),l.yaxis.setScale(),l.yaxis.isPtWithinRange=function(){return!0};var T=l.yaxis.domain[0],A=l.aaxis=d({},t.aaxis,{visible:!0,range:[_,x-M-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[T,T+s*w],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(A,l.graphDiv._fullLayout),A.setScale();var S=l.baxis=d({},t.baxis,{visible:!0,range:[x-_-k,M],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(S,l.graphDiv._fullLayout),S.setScale(),A._counteraxis=S;var E=l.caxis=d({},t.caxis,{visible:!0,range:[x-_-M,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[T,T+s*w],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E,l.graphDiv._fullLayout),E.setScale();var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var C="M0,"+a+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDefRelative.select("path").attr("d",C);var I="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",I),l.clipDefRelative.select("path").attr("transform",null);var P="translate("+(r-S._offset)+","+(n+a)+")";l.layers.baxis.attr("transform",P),l.layers.bgrid.attr("transform",P);var D="translate("+(r+i/2)+","+n+")rotate(30)translate(0,-"+A._offset+")";l.layers.aaxis.attr("transform",D),l.layers.agrid.attr("transform",D);var z="translate("+(r+i/2)+","+n+")rotate(-30)translate(0,-"+E._offset+")";l.layers.caxis.attr("transform",z),l.layers.cgrid.attr("transform",z),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1),l.layers.aline.select("path").attr("d",A.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(u.stroke,A.linecolor||"#000").style("stroke-width",(A.linewidth||0)+"px"),l.layers.bline.select("path").attr("d",S.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(u.stroke,S.linecolor||"#000").style("stroke-width",(S.linewidth||0)+"px"),l.layers.cline.select("path").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(u.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px"),l.graphDiv._context.staticPlot||l.initInteractions(),h.setClipUrl(l.layers.frontplot,l._hasClipOnAxisFalse?null:l.clipId)},_.drawAxes=function(t){var e=this.graphDiv,r=this.id.substr(7)+"title",n=this.aaxis,i=this.baxis,a=this.caxis;if(m.doTicks(e,n,!0),m.doTicks(e,i,!0),m.doTicks(e,a,!0),t){var o=Math.max(n.showticklabels?n.tickfont.size/2:0,(a.showticklabels?.75*a.tickfont.size:0)+("outside"===a.ticks?.87*a.ticklen:0));y.draw(e,"a"+r,{propContainer:n,propName:this.id+".aaxis.title",placeholder:c(e,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-n.titlefont.size/3-o,"text-anchor":"middle"}});var s=(i.showticklabels?i.tickfont.size:0)+("outside"===i.ticks?i.ticklen:0)+3;y.draw(e,"b"+r,{propContainer:i,propName:this.id+".baxis.title",placeholder:c(e,"Click to enter Component B title"),attributes:{x:this.x0-s,y:this.y0+this.h+.83*i.titlefont.size+s,"text-anchor":"middle"}}),y.draw(e,"c"+r,{propContainer:a,propName:this.id+".caxis.title",placeholder:c(e,"Click to enter Component C title"),attributes:{x:this.x0+this.w+s,y:this.y0+this.h+.83*a.titlefont.size+s,"text-anchor":"middle"}})}};var M=x.MINZOOM/2+.87,k="m-0.87,.5h"+M+"v3h-"+(M+5.2)+"l"+(M/2+2.6)+",-"+(.87*M+4.5)+"l2.6,1.5l-"+M/2+","+.87*M+"Z",T="m0.87,.5h-"+M+"v3h"+(M+5.2)+"l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-2.6,1.5l"+M/2+","+.87*M+"Z",A="m0,1l"+M/2+","+.87*M+"l2.6,-1.5l-"+(M/2+2.6)+",-"+(.87*M+4.5)+"l-"+(M/2+2.6)+","+(.87*M+4.5)+"l2.6,1.5l"+M/2+",-"+.87*M+"Z",S="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;_.initInteractions=function(){function t(t,e){return 1-e/O.h}function e(t,e){return 1-(t+(O.h-e)/Math.sqrt(3))/O.w}function r(t,e){return(t-(O.h-e)/Math.sqrt(3))/O.w}function n(n,i){var a=m+n,o=y+i,s=Math.max(0,Math.min(1,t(0,y),t(0,o))),l=Math.max(0,Math.min(1,e(m,y),e(a,o))),c=Math.max(0,Math.min(1,r(m,y),r(a,o))),u=(s/2+c)*O.w,h=(1-s/2-l)*O.w,f=(u+h)/2,d=h-u,p=(1-s)*O.h,g=p-d/w;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),z.transition().style("opacity",1).duration(200),P=!0)}function a(){if(i(R),L!==_){var t={};t[O.id+".aaxis.min"]=L.a,t[O.id+".baxis.min"]=L.b,t[O.id+".caxis.min"]=L.c,s.relayout(R,t),E&&R.data&&R._context.showTips&&(l.notifier(c(R,"Double-click to zoom back out"),"long"),E=!1)}}function f(t,e){var r=t/O.xaxis._m,n=e/O.yaxis._m,i=[(L={a:_.a-n,b:_.b+(r+n)/2,c:_.c-(r-n)/2}).a,L.b,L.c].sort(),a=i.indexOf(L.a),o=i.indexOf(L.b),s=i.indexOf(L.c);i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),L={a:i[a],b:i[o],c:i[s]},e=(_.a-L.a)*O.yaxis._m,t=(_.c-L.c-_.b+L.b)*O.xaxis._m);var l="translate("+(O.x0+t)+","+(O.y0+e)+")";O.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",l);var c="translate("+-t+","+-e+")";O.clipDefRelative.select("path").attr("transform",c),O.aaxis.range=[L.a,O.sum-L.b-L.c],O.baxis.range=[O.sum-L.a-L.c,L.b],O.caxis.range=[O.sum-L.a-L.b,L.c],O.drawAxes(!1),O.plotContainer.selectAll(".crisp").classed("crisp",!1),O._hasClipOnAxisFalse&&O.plotContainer.select(".scatterlayer").selectAll(".trace").call(h.hideOutsideRangePoints,O)}function d(){var t={};t[O.id+".aaxis.min"]=L.a,t[O.id+".baxis.min"]=L.b,t[O.id+".caxis.min"]=L.c,s.relayout(R,t)}function p(){j.selectAll(".select-outline").remove()}var m,y,_,M,L,C,I,P,D,z,O=this,F=O.layers.plotbg.select("path").node(),R=O.graphDiv,j=R._fullLayout._zoomlayer,N={element:F,gd:R,plotinfo:{xaxis:O.xaxis,yaxis:O.yaxis},subplot:O.id,prepFn:function(t,e,r){N.xaxes=[O.xaxis],N.yaxes=[O.yaxis];var i=R._fullLayout.dragmode;t.shiftKey&&(i="pan"===i?"zoom":"pan"),N.minDrag="lasso"===i?1:void 0,"zoom"===i?(N.moveFn=n,N.doneFn=a,function(t,e,r){var n=F.getBoundingClientRect();m=e-n.left,y=r-n.top,_={a:O.aaxis.range[0],b:O.baxis.range[1],c:O.caxis.range[1]},L=_,M=O.aaxis.range[1]-_.a,C=o(O.graphDiv._fullLayout[O.id].bgcolor).getLuminance(),I="M0,"+O.h+"L"+O.w/2+", 0L"+O.w+","+O.h+"Z",P=!1,D=j.append("path").attr("class","zoombox").attr("transform","translate("+O.x0+", "+O.y0+")").style({fill:C>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",I),z=j.append("path").attr("class","zoombox-corners").attr("transform","translate("+O.x0+", "+O.y0+")").style({fill:u.background,stroke:u.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}(0,e,r)):"pan"===i?(N.moveFn=f,N.doneFn=d,_={a:O.aaxis.range[0],b:O.baxis.range[1],c:O.caxis.range[1]},L=_,p()):"select"!==i&&"lasso"!==i||b(t,e,r,N,i)},clickFn:function(t,e){if(i(R),2===t){var r={};r[O.id+".aaxis.min"]=0,r[O.id+".baxis.min"]=0,r[O.id+".caxis.min"]=0,R.emit("plotly_doubleclick",null),s.relayout(R,r)}v.click(R,e,O.id)}};F.onmousemove=function(t){v.hover(R,t,O.id),R._fullLayout._lasthover=F,R._fullLayout._hoversubplot=O.id},F.onmouseout=function(t){R._dragging||g.unhover(R,t)},g.init(N)}},{"../../components/color":613,"../../components/dragelement":635,"../../components/drawing":638,"../../components/fx":655,"../../components/titles":704,"../../lib":738,"../../lib/extend":727,"../../plotly":780,"../cartesian/axes":785,"../cartesian/constants":790,"../cartesian/select":802,"../cartesian/set_convert":803,"../plots":846,d3:123,tinycolor2:543}],861:[function(t,e,r){"use strict";function n(t){if(t.layoutAttributes){var e=t.layoutAttributes._arrayAttrRegexps;if(e)for(var n=0;n-1}var a=t("../lib"),o=a.extendFlat,s=a.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,a=t.data,l=t.layout,c=s([],a),u=s({},l,n(e.tileClass)),h=t._context||{};if(e.width&&(u.width=e.width),e.height&&(u.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){u.annotations=[];var f=Object.keys(u);for(r=0;r")?"":e.html(t).text()});return e.remove(),r}(w),w=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")}(w),w=w.replace(u,"'"),i.isIE()&&(w=(w=(w=w.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),w}},{"../components/color":613,"../components/drawing":638,"../constants/xmlns_namespaces":719,"../lib":738,d3:123}],870:[function(t,e,r){"use strict";var n=t("../../lib").mergeArray;e.exports=function(t,e){for(var r=0;r0&&E>0&&(S<=F&&E<=R||S<=R&&E<=F||("h"===M?F>=S*(R/E):R>=E*(F/S)))?m="inside":(m="outside",T.remove(),T=null)}else m="inside";if(!T&&(T=d(e,k,"outside"===m?I:C),A=p.bBox(T.node()),S=A.width,E=A.height,S<=0||E<=0))T.remove();else{var j;j="outside"===m?function(t,e,r,n,a,o,s){var l,c="h"===o?Math.abs(n-r):Math.abs(e-t);c>2*w&&(l=w);var u=1;s&&(u="h"===o?Math.min(1,c/a.height):Math.min(1,c/a.width));var h,f,d,p,m=(a.left+a.right)/2,g=(a.top+a.bottom)/2;h=u*a.width,f=u*a.height,"h"===o?er?(d=(t+e)/2,p=n+l+f/2):(d=(t+e)/2,p=n-l-f/2);return i(m,g,d,p,u,!1)}(l,c,u,h,A,M,"both"===g.constraintext||"outside"===g.constraintext):function(t,e,r,n,a,o,s){var l,c,u,h,f,d=a.width,p=a.height,m=(a.left+a.right)/2,g=(a.top+a.bottom)/2,v=Math.abs(e-t),y=Math.abs(n-r);v>2*w&&y>2*w?(v-=2*(f=w),y-=2*f):f=0;var b,x;d<=v&&p<=y?(b=!1,x=1):d<=y&&p<=v?(b=!0,x=1):dr?(u=(t+e)/2,h=n-f-c/2):(u=(t+e)/2,h=n+f+c/2);return i(m,g,u,h,x,b)}(l,c,u,h,A,M,"both"===g.constraintext||"inside"===g.constraintext),T.attr("transform",j)}}}function i(t,e,r,n,i,a){var o;i<1?o="scale("+i+") ":(i=1,o="");return"translate("+(r-i*t)+" "+(n-i*e)+")"+o+(a?"rotate("+a+" "+t+" "+e+") ":"")}function a(t,e,r,n){var i=o((e=e||{}).family,r),a=o(e.size,r),l=o(e.color,r);return{family:s(t.family,i,n.family),size:function(t,e,r){if(c(e)){e=+e;var n=t.min,i=t.max,a=void 0!==n&&ei;if(!a)return e}return void 0!==r?r:t.dflt}(t.size,a,n.size),color:function(t,e,r){return u(e).isValid()?e:void 0!==r?r:t.dflt}(t.color,l,n.color)}}function o(t,e){var r;return Array.isArray(t)?e=2?h(t):t>e?Math.ceil(t):Math.floor(t)}var g,v,y,b,x=r.p+(p?f[s]:f),_=x+r.w,w=r.b,M=w+r.s;if("h"===u.orientation?(y=a.c2p(x,!0),b=a.c2p(_,!0),g=i.c2p(w,!0),v=i.c2p(M,!0),r.ct=[v,(y+b)/2]):(g=i.c2p(x,!0),v=i.c2p(_,!0),y=a.c2p(w,!0),b=a.c2p(M,!0),r.ct=[(g+v)/2,b]),c(g)&&c(v)&&c(y)&&c(b)&&g!==v&&y!==b){var k=(r.mlw+1||u.marker.line.width+1||(r.trace?r.trace.marker.line.width:0)+1)-1,T=l.round(k/2%1,2);if(!t._context.staticPlot){var A=d.opacity(r.mc||u.marker.color)<1||k>.01?h:m;v=A(v,g=A(g,v)),b=A(b,y=A(y,b))}var S=l.select(this);S.append("path").style("vector-effect","non-scaling-stroke").attr("d","M"+g+","+y+"V"+b+"H"+v+"V"+y+"Z"),n(t,S,e,s,g,v,y,b)}else l.select(this).remove()})}),s.call(m.plot,e)}},{"../../components/color":613,"../../components/drawing":638,"../../components/errorbars":644,"../../lib":738,"../../lib/svg_text_utils":761,"./attributes":871,d3:123,"fast-isnumeric":132,tinycolor2:543}],879:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[];if(!1===e)for(r=0;ru+s||!p(l))&&(f=!0,c(h,t))}for(var i=r.traces,a=d(e),o="fraction"===t._fullLayout.barnorm?1:100,s=o/1e9,l=e.l2c(e.c2l(0)),u="stack"===t._fullLayout.barmode?o:l,h=[l,u],f=!1,g=0;g1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),r.selectAll("g.points").each(function(e){var r=n.select(this),a=r.selectAll("path"),o=r.selectAll("text"),s=e[0].trace;i.pointStyle(a,s,t),i.selectedPointStyle(a,s),o.each(function(t){function e(e){var n=r[e];return Array.isArray(n)?n[t.i]:n}var r,a=n.select(this);a.classed("bartext-inside")?r=s.insidetextfont:a.classed("bartext-outside")&&(r=s.outsidetextfont),r||(r=s.textfont),i.font(a,e("family"),e("size"),e("color"))}),i.selectedTextStyle(o,s)}),a.style(r)}},{"../../components/drawing":638,"../../components/errorbars":644,d3:123}],883:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":613,"../../components/colorscale/defaults":623,"../../components/colorscale/has_colorscale":627}],884:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},name:{valType:"string",editType:"calc+clearAxisTypes"},text:a({},n.text,{}),whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calcIfAutorange"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers",editType:"calcIfAutorange"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1,editType:"calcIfAutorange"},jitter:{valType:"number",min:0,max:1,editType:"calcIfAutorange"},pointpos:{valType:"number",min:-2,max:2,editType:"calcIfAutorange"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:a({},o.symbol,{arrayOk:!1,editType:"plot"}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:a({},o.size,{arrayOk:!1,editType:"calcIfAutorange"}),color:a({},o.color,{arrayOk:!1,editType:"style"}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine,editType:"style"}),width:a({},s.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":612,"../../lib/extend":727,"../scatter/attributes":1054}],885:[function(t,e,r){"use strict";function n(t,e){return t.v-e.v}function i(t){return t.v}var a=t("fast-isnumeric"),o=t("../../lib"),s=o._,l=t("../../plots/cartesian/axes");e.exports=function(t,e){var r,c,u,h,f,d=t._fullLayout,p=l.getFromId(t,e.xaxis||"x"),m=l.getFromId(t,e.yaxis||"y"),g=[],v="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(c=p,u="x",h=m,f="y"):(c=m,u="y",h=p,f="x");var y=c.makeCalcdata(e,u),b=function(t,e,r,n,i){if(e in t)return r.makeCalcdata(t,e);var s;s=e+"0"in t?t[e+"0"]:"name"in t&&("category"===r.type||a(t.name)&&-1!==["linear","log"].indexOf(r.type)||o.isDateTime(t.name)&&"date"===r.type)?t.name:i;var l=r.d2c(s,0,t[e+"calendar"]);return n.map(function(){return l})}(e,f,h,y,d[v]),x=o.distinctVals(b),_=x.vals,w=x.minDiff/2,M=function(t,e){for(var r=t.length,n=new Array(r+1),i=0;i=0&&E0){var C=A[r].sort(n),I=C.map(i),P=I.length,D={pos:_[r],pts:C};D.min=I[0],D.max=I[P-1],D.mean=o.mean(I,P),D.sd=o.stdev(I,P,D.mean),D.q1=o.interp(I,.25),D.med=o.interp(I,.5),D.q3=o.interp(I,.75),D.lf=Math.min(D.q1,I[Math.min(o.findBin(2.5*D.q1-1.5*D.q3,I,!0)+1,P-1)]),D.uf=Math.max(D.q3,I[Math.max(o.findBin(2.5*D.q3-1.5*D.q1,I),0)]),D.lo=4*D.q1-3*D.q3,D.uo=4*D.q3-3*D.q1,g.push(D)}return function(t,e){if(Array.isArray(e.selectedpoints))for(var r=0;r0?(g[0].t={num:d[v],dPos:w,posLetter:f,valLetter:u,labels:{med:s(t,"median:"),min:s(t,"min:"),q1:s(t,"q1:"),q3:s(t,"q3:"),max:s(t,"max:"),mean:"sd"===e.boxmean?s(t,"mean \xb1 \u03c3:"):s(t,"mean:"),lf:s(t,"lower fence:"),uf:s(t,"upper fence:")}},d[v]++,g):[{t:{empty:!0}}]}},{"../../lib":738,"../../plots/cartesian/axes":785,"fast-isnumeric":132}],886:[function(t,e,r){"use strict";function n(t,e,r,n){var i,a=r("y"),s=r("x");if(a&&a.length)i="v",s||r("x0");else{if(!s||!s.length)return void(e.visible=!1);i="h",r("y0")}o.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x","y"],n),r("orientation",i)}function i(t,e,r,n){var i=n.prefix,o=a.coerce2(t,e,l,"marker.outliercolor"),s=r("marker.line.outliercolor"),c=r(i+"points",o||s?"suspectedoutliers":void 0);c?(r("jitter","all"===c?.3:0),r("pointpos","all"===c?-1.5:0),r("marker.symbol"),r("marker.opacity"),r("marker.size"),r("marker.color",e.line.color),r("marker.line.color"),r("marker.line.width"),"suspectedoutliers"===c&&(r("marker.line.outliercolor",e.marker.color),r("marker.line.outlierwidth")),r("selected.marker.color"),r("unselected.marker.color"),r("selected.marker.size"),r("unselected.marker.size"),r("text")):delete e.marker,r("hoveron"),a.coerceSelectionMarkerOpacity(e,r)}var a=t("../../lib"),o=t("../../registry"),s=t("../../components/color"),l=t("./attributes");e.exports={supplyDefaults:function(t,e,r,o){function c(r,n){return a.coerce(t,e,l,r,n)}n(t,e,c,o),!1!==e.visible&&(c("line.color",(t.marker||{}).color||r),c("line.width"),c("fillcolor",s.addOpacity(e.line.color,.5)),c("whiskerwidth"),c("boxmean"),i(t,e,c,{prefix:"box"}))},handleSampleDefaults:n,handlePointsDefaults:i}},{"../../components/color":613,"../../lib":738,"../../registry":861,"./attributes":884}],887:[function(t,e,r){"use strict";function n(t,e,r,n){var i,c,u,h,f,d,p,m,g,v=t.cd,y=t.xa,b=t.ya,x=v[0].trace,_=v[0].t,w="violin"===x.type,M=[],k="closest"!==n||w?_.bdPos:2.5*_.bdPos,T=function(t){return t.pos+_.bPos-d};w&&"both"!==x.side?("positive"===x.side&&(g=function(t){var e=T(t);return s.inbox(e,e+k)}),"negative"===x.side&&(g=function(t){var e=T(t);return s.inbox(e-k,e)})):g=function(t){var e=T(t);return s.inbox(e-k,e+k)};var A;A=w?function(t){return s.inbox(t.span[0]-f,t.span[1]-f)}:function(t){return s.inbox(t.min-f,t.max-f)},"h"===x.orientation?(f=e,d=r,p=A,m=g,i="y",u=b,c="x",h=y):(f=r,d=e,p=g,m=A,i="x",u=y,c="y",h=b);var S=s.getDistanceFunction(n,p,m);if(s.getClosest(v,S,t),!1===t.index)return[];var E=v[t.index],L=x.line.color,C=(x.marker||{}).color;l.opacity(L)&&x.line.width?t.color=L:l.opacity(C)&&x.boxpoints?t.color=C:t.color=x.fillcolor,t[i+"0"]=u.c2p(E.pos+_.bPos-_.bdPos,!0),t[i+"1"]=u.c2p(E.pos+_.bPos+_.bdPos,!0),a.tickText(u,u.c2l(E.pos),"hover").text,t[i+"LabelVal"]=E.pos;var I={},P=["med","min","q1","q3","max"];(x.boxmean||(x.meanline||{}).visible)&&P.push("mean"),(x.boxpoints||x.points)&&P.push("lf","uf");for(var D=0;Dt.uf}),o=Math.max((t.max-t.min)/10,t.q3-t.q1),c=1e-9*o,u=o*f,m=[],g=0;if(r.jitter){if(0===o)for(g=1,m=new Array(a.length),e=0;et.lo&&(w.so=!0)}return a}).enter().append("path").classed("point",!0).call(c.translatePoints,a,o)}function o(t,e,r,n){var i,a,o=e.pos,c=e.val,u=n.bPos,h=n.bPosPxOffset||0;Array.isArray(n.bdPos)?(i=n.bdPos[0],a=n.bdPos[1]):(i=n.bdPos,a=n.bdPos),t.selectAll("path.mean").data(l.identity).enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}).each(function(t){var e=o.c2p(t.pos+u,!0)+h,n=o.c2p(t.pos+u-i,!0)+h,l=o.c2p(t.pos+u+a,!0)+h,f=c.c2p(t.mean,!0),d=c.c2p(t.mean-t.sd,!0),p=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?s.select(this).attr("d","M"+f+","+n+"V"+l+("sd"===r.boxmean?"m0,0L"+d+","+e+"L"+f+","+n+"L"+p+","+e+"Z":"")):s.select(this).attr("d","M"+n+","+f+"H"+l+("sd"===r.boxmean?"m0,0L"+e+","+d+"L"+n+","+f+"L"+e+","+p+"Z":""))})}var s=t("d3"),l=t("../../lib"),c=t("../../components/drawing"),u=2e9,h=5,f=.01;e.exports={plot:function(t,e,r){var n=t._fullLayout,l=e.xaxis,c=e.yaxis;e.plot.select(".boxlayer").selectAll("g.trace.boxes").data(r).enter().append("g").attr("class","trace boxes").each(function(t){var e=t[0],r=e.t,u=e.trace,h=e.node3=s.select(this),f=n._numBoxes,d="group"===n.boxmode&&f>1,p=r.dPos*(1-n.boxgap)*(1-n.boxgroupgap)/(d?f:1),m=d?2*r.dPos*((r.num+.5)/f-.5)*(1-n.boxgap):0,g=p*u.whiskerwidth;if(!0!==u.visible||r.empty)s.select(this).remove();else{var v,y;"h"===u.orientation?(v=c,y=l):(v=l,y=c),r.bPos=m,r.bdPos=p,r.wdPos=g,i(h,{pos:v,val:y},u,r),u.boxpoints&&a(h,{x:l,y:c},u,r),u.boxmean&&o(h,{pos:v,val:y},u,r)}})},plotBoxAndWhiskers:i,plotPoints:a,plotBoxMean:o}},{"../../components/drawing":638,"../../lib":738,d3:123}],892:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,i=t.cd,a=t.xaxis,o=t.yaxis,s=[];if(!1===e)for(r=0;r=10)return null;for(var r=1/0,i=-1/0,a=t.length,o=0;o0?Math.floor:Math.ceil,I=E>0?Math.ceil:Math.floor,P=E>0?Math.min:Math.max,D=E>0?Math.max:Math.min,z=C(A+L),O=I(S-L),F=[[u=T(A)]];for(i=z;i*E=0;i--)a[u-i]=t[h][i],o[u-i]=e[h][i];for(s.push({x:a,y:o,bicubic:l}),i=h,a=[],o=[];i>=0;i--)a[h-i]=t[i][0],o[h-i]=e[i][0];return s.push({x:a,y:o,bicubic:c}),s}},{}],907:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e,r,a){function o(e){var n,i,o,s,l,c,u,h,f,d,p,g,v=[],y=[],b={};if("b"===r)for(i=t.b2j(e),o=Math.floor(Math.max(0,Math.min(z-2,i))),s=i-o,b.length=z,b.crossLength=D,b.xy=function(e){return t.evalxy([],e,i)},b.dxy=function(e,r){return t.dxydi([],e,o,r,s)},n=0;n0&&(f=t.dxydi([],n-1,o,0,s),v.push(l[0]+f[0]/3),y.push(l[1]+f[1]/3),d=t.dxydi([],n-1,o,1,s),v.push(h[0]-d[0]/3),y.push(h[1]-d[1]/3)),v.push(h[0]),y.push(h[1]),l=h;else for(n=t.a2i(e),c=Math.floor(Math.max(0,Math.min(D-2,n))),u=n-c,b.length=D,b.crossLength=z,b.xy=function(e){return t.evalxy([],n,e)},b.dxy=function(e,r){return t.dxydj([],c,e,u,r)},i=0;i0&&(p=t.dxydj([],c,i-1,u,0),v.push(l[0]+p[0]/3),y.push(l[1]+p[1]/3),g=t.dxydj([],c,i-1,u,1),v.push(h[0]-g[0]/3),y.push(h[1]-g[1]/3)),v.push(h[0]),y.push(h[1]),l=h;return b.axisLetter=r,b.axis=M,b.crossAxis=E,b.value=e,b.constvar=a,b.index=m,b.x=v,b.y=y,b.smoothing=E.smoothing,b}function s(e){var n,i,o,s,l,c=[],u=[],h={};if(h.length=w.length,h.crossLength=S.length,"b"===r)for(o=Math.max(0,Math.min(z-2,e)),l=Math.min(1,Math.max(0,e-o)),h.xy=function(r){return t.evalxy([],r,e)},h.dxy=function(e,r){return t.dxydi([],e,o,r,l)},n=0;nw.length-1||k.push(i(s(c),{color:M.gridcolor,width:M.gridwidth}));for(m=d;mw.length-1||y<0||y>w.length-1))for(b=w[u],x=w[y],l=0;lw[w.length-1]||T.push(i(o(v),{color:M.minorgridcolor,width:M.minorgridwidth}));M.startline&&A.push(i(s(0),{color:M.startlinecolor,width:M.startlinewidth})),M.endline&&A.push(i(s(w.length-1),{color:M.endlinecolor,width:M.endlinewidth}))}else{for(h=5e-15,d=(f=[Math.floor((w[w.length-1]-M.tick0)/M.dtick*(1+h)),Math.ceil((w[0]-M.tick0)/M.dtick/(1+h))].sort(function(t,e){return t-e}))[0],p=f[1],m=d;m<=p;m++)g=M.tick0+M.dtick*m,k.push(i(o(g),{color:M.gridcolor,width:M.gridwidth}));for(m=d-1;mw[w.length-1]||T.push(i(o(v),{color:M.minorgridcolor,width:M.minorgridwidth}));M.startline&&A.push(i(o(w[0]),{color:M.startlinecolor,width:M.startlinewidth})),M.endline&&A.push(i(o(w[w.length-1]),{color:M.endlinecolor,width:M.endlinewidth}))}}},{"../../lib/extend":727,"../../plots/cartesian/axes":785}],908:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e){var r,a,o,s=e._labels=[],l=e._gridlines;for(r=0;re.length&&(t=t.slice(0,e.length)):t=[],n=0;ne.length&&(t=t.slice(0,e.length)):t=[],n=0;ne.length&&(t[n]=t[n].slice(0,e.length)):t[n]=[],i=0;i90&&(d-=180,l=-l),{angle:d,flip:l,p:t.c2p(n,e,r),offsetMultplier:c}}},{}],924:[function(t,e,r){"use strict";function n(t,e,r){var n=t.selectAll(e+"."+r).data([0]);return n.enter().append(e).classed(r,!0),n}function i(t,e,r){var i=r[0],l=r[0].trace,c=e.xaxis,f=e.yaxis,d=l.aaxis,p=l.baxis,m=t._fullLayout,g=e.plot.selectAll(".carpetlayer"),v=m._clips,y=n(g,"g","carpet"+l.uid).classed("trace",!0),b=n(y,"g","minorlayer"),x=n(y,"g","majorlayer"),_=n(y,"g","boundarylayer"),w=n(y,"g","labellayer");y.style("opacity",l.opacity),a(c,f,x,d,"a",d._gridlines),a(c,f,x,p,"b",p._gridlines),a(c,f,b,d,"a",d._minorgridlines),a(c,f,b,p,"b",p._minorgridlines),a(c,f,_,d,"a-boundary",d._boundarylines),a(c,f,_,p,"b-boundary",p._boundarylines);!function(t,e,r,n,i,a,o,l){var c,u,h,f;c=.5*(r.a[0]+r.a[r.a.length-1]),u=r.b[0],h=r.ab2xy(c,u,!0),f=r.dxyda_rough(c,u),s(t,e,r,n,h,f,r.aaxis,i,a,o,"a-title"),c=r.a[0],u=.5*(r.b[0]+r.b[r.b.length-1]),h=r.ab2xy(c,u,!0),f=r.dxydb_rough(c,u),s(t,e,r,n,h,f,r.baxis,i,a,l,"b-title")}(t,w,l,i,c,f,o(t,c,f,l,i,w,d._labels,"a-label"),o(t,c,f,l,i,w,p._labels,"b-label")),function(t,e,r,i,a){var o,s,l,c,f=r.select("#"+t._clipPathId);f.size()||(f=r.append("clipPath").classed("carpetclip",!0));var d=n(f,"path","carpetboundary"),p=e.clipsegments,m=[];for(c=0;c0?"start":"end","data-notex":1}).call(c.font,i.font).text(i.text).call(d.convertToTspans,t),p=c.bBox(this);u.attr("transform","translate("+a.p[0]+","+a.p[1]+") rotate("+a.angle+")translate("+i.axis.labelpadding*s+","+.3*p.height+")"),h=Math.max(h,p.width+i.axis.labelpadding)}),u.exit().remove(),h}function s(t,e,r,n,i,a,o,s,u,h,p){var m=[];o.title&&m.push(o.title);var g=e.selectAll("text."+p).data(m);g.enter().append("text").classed(p,!0),g.each(function(){var e=f(r,s,u,i,a);-1===["start","both"].indexOf(o.showticklabels)&&(h=0),h+=o.titlefont.size+o.titleoffset;l.select(this).text(o.title||"").call(d.convertToTspans,t).attr("transform","translate("+e.p[0]+","+e.p[1]+") rotate("+e.angle+") translate(0,"+h+")").classed("user-select-none",!0).attr("text-anchor","middle").call(c.font,o.titlefont)}),g.exit().remove()}var l=t("d3"),c=t("../../components/drawing"),u=t("./map_1d_array"),h=t("./makepath"),f=t("./orient_text"),d=t("../../lib/svg_text_utils");e.exports=function(t,e,r){for(var n=0;nd&&tm&&ep||eg},h.c2p=function(t){return t},f.c2p=function(t){return t},t.setScale=function(){var e=t.x,r=t.y,n=a(t.xctrl,t.yctrl,e,r,h.smoothing,f.smoothing);t.xctrl=n[0],t.yctrl=n[1],t.evalxy=o([t.xctrl,t.yctrl],c,u,h.smoothing,f.smoothing),t.dxydi=s([t.xctrl,t.yctrl],h.smoothing,f.smoothing),t.dxydj=l([t.xctrl,t.yctrl],h.smoothing,f.smoothing)},t.i2a=function(t){var r=Math.max(0,Math.floor(t[0]),c-2),n=t[0]-r;return(1-n)*e[r]+n*e[r+1]},t.j2b=function(t){var e=Math.max(0,Math.floor(t[1]),c-2),n=t[1]-e;return(1-n)*r[e]+n*r[e+1]},t.ij2ab=function(e){return[t.i2a(e[0]),t.j2b(e[1])]},t.a2i=function(t){var r=Math.max(0,Math.min(i(t,e),c-2)),n=e[r],a=e[r+1];return Math.max(0,Math.min(c-1,r+(t-n)/(a-n)))},t.b2j=function(t){var e=Math.max(0,Math.min(i(t,r),u-2)),n=r[e],a=r[e+1];return Math.max(0,Math.min(u-1,e+(t-n)/(a-n)))},t.ab2ij=function(e){return[t.a2i(e[0]),t.b2j(e[1])]},t.i2c=function(e,r){return t.evalxy([],e,r)},t.ab2xy=function(n,i,a){if(!a&&(ne[c-1]|ir[u-1]))return[!1,!1];var o=t.a2i(n),s=t.b2j(i),l=t.evalxy([],o,s);if(a){var h,f,d,p,m=0,g=0,v=[];ne[c-1]?(h=c-2,f=1,m=(n-e[c-1])/(e[c-1]-e[c-2])):f=o-(h=Math.max(0,Math.min(c-2,Math.floor(o)))),ir[u-1]?(d=u-2,p=1,g=(i-r[u-1])/(r[u-1]-r[u-2])):p=s-(d=Math.max(0,Math.min(u-2,Math.floor(s)))),m&&(t.dxydi(v,h,d,f,p),l[0]+=v[0]*m,l[1]+=v[1]*m),g&&(t.dxydj(v,h,d,f,p),l[0]+=v[0]*g,l[1]+=v[1]*g)}return l},t.c2p=function(t,e,r){return[e.c2p(t[0]),r.c2p(t[1])]},t.p2x=function(t,e,r){return[e.p2c(t[0]),r.p2c(t[1])]},t.dadi=function(t){var r=Math.max(0,Math.min(e.length-2,t));return e[r+1]-e[r]},t.dbdj=function(t){var e=Math.max(0,Math.min(r.length-2,t));return r[e+1]-r[e]},t.dxyda=function(e,r,n,i){var a=t.dxydi(null,e,r,n,i),o=t.dadi(e,n);return[a[0]/o,a[1]/o]},t.dxydb=function(e,r,n,i){var a=t.dxydj(null,e,r,n,i),o=t.dbdj(r,i);return[a[0]/o,a[1]/o]},t.dxyda_rough=function(e,r,n){var i=v*(n||.1),a=t.ab2xy(e+i,r,!0),o=t.ab2xy(e-i,r,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dxydb_rough=function(e,r,n){var i=y*(n||.1),a=t.ab2xy(e,r+i,!0),o=t.ab2xy(e,r-i,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dpdx=function(t){return t._m},t.dpdy=function(t){return t._m}}},{"../../lib/search":756,"./compute_control_points":911,"./constants":912,"./create_i_derivative_evaluator":913,"./create_j_derivative_evaluator":914,"./create_spline_evaluator":915}],926:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){function i(e,r){var n,i=0,a=0;return e>0&&void 0!==(n=t[r][e-1])&&(a++,i+=n),e0&&void 0!==(n=t[r-1][e])&&(a++,i+=n),r0&&o0&&a1e-5);return n.log("Smoother converged to",k,"after",T,"iterations"),t}},{"../../lib":738}],927:[function(t,e,r){"use strict";var n=t("./has_columns"),i=t("../heatmap/convert_column_xyz");e.exports=function(t,e,r){var a=[],o=r("x");o&&!n(o)&&a.push("x"),e._cheater=!o;var s=r("y");if(s&&!n(s)&&a.push("y"),o||s)return a.length&&i(e,e.aaxis,e.baxis,"a","b",a),!0}},{"../heatmap/convert_column_xyz":969,"./has_columns":917}],928:[function(t,e,r){"use strict";var n=t("../scattergeo/attributes"),i=t("../../components/colorscale/attributes"),a=t("../../components/colorbar/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend"),l=s.extendFlat,c=s.extendDeepAll,u=n.marker.line;e.exports=l({locations:{valType:"data_array",editType:"calc"},locationmode:n.locationmode,z:{valType:"data_array",editType:"calc"},text:l({},n.text,{}),marker:{line:{color:u.color,width:l({},u.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:n.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:n.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:l({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]})},c({},i,{zmax:{editType:"calc"},zmin:{editType:"calc"}}),{colorbar:a})},{"../../components/colorbar/attributes":614,"../../components/colorscale/attributes":619,"../../lib/extend":727,"../../plots/attributes":783,"../scattergeo/attributes":1093}],929:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../constants/numerical").BADNUM,a=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),s=t("../scatter/calc_selection");e.exports=function(t,e){for(var r=e.locations.length,l=new Array(r),c=0;cl&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),s("marker.opacity"),i(t,e,o,s,{prefix:"",cLetter:"z"}),n.coerceSelectionMarkerOpacity(e,s)):e.visible=!1}else e.visible=!1}},{"../../components/colorscale/defaults":623,"../../lib":738,"./attributes":928}],931:[function(t,e,r){"use strict";e.exports=function(t,e){return t.location=e.location,t.z=e.z,t}},{}],932:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("./attributes"),a=t("../scatter/fill_hover_text");e.exports=function(t,e,r){var o,s,l,c,u=t.cd,h=u[0].trace,f=t.subplot;for(s=0;s")}(t,h,o,f.mockAxis),[t]}},{"../../plots/cartesian/axes":785,"../scatter/fill_hover_text":1062,"./attributes":928}],933:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":814,"../heatmap/colorbar":968,"./attributes":928,"./calc":929,"./defaults":930,"./event_data":931,"./hover":932,"./plot":934,"./select":935,"./style":936}],934:[function(t,e,r){"use strict";function n(t,e){for(var r=t[0].trace,n=t.length,i=s(r,e),a=0;a0&&t[e+1][0]<0)return e;return null}var r,n,i,a,s=t.geometry,l=s.coordinates,c=t.id,u=[];r="RUS"===c||"FJI"===c?function(t){var r;if(null===e(t))r=t;else for(r=new Array(t.length),a=0;ar?n[i++]=[t[a][0]+360,t[a][1]]:a===r?(n[i++]=t[a],n[i++]=[t[a][0],-90]):n[i++]=t[a];var s=o.tester(n);s.pts.pop(),u.push(s)}:function(t){u.push(o.tester(t))};switch(s.type){case"MultiPolygon":for(n=0;ns.end&&(s.start=s.end=(s.start+s.end)/2),e._input.contours||(e._input.contours={}),a(e._input.contours,{start:s.start,end:s.end,size:s.size}),e._input.autocontour=!0}else{var c=s.start,u=s.end,h=e._input.contours;if(c>u&&(s.start=h.start=u,u=s.end=h.end=c,c=s.start),!(s.size>0)){var f;f=c===u?1:n(c,u,e.ncontours).dtick,h.size=s.size=f}}return r}},{"../../lib":738,"../../plots/cartesian/axes":785,"../heatmap/calc":966}],939:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../components/colorbar/draw"),a=t("./make_color_map"),o=t("./end_plus");e.exports=function(t,e){var r=e[0].trace,s="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+s).remove(),r.showscale){var l=i(t,s);e[0].t.cb=l;var c=r.contours,u=r.line,h=c.size||1,f=c.coloring,d=a(r,{isColorbar:!0});"heatmap"===f&&l.filllevels({start:r.zmin,end:r.zmax,size:(r.zmax-r.zmin)/254}),l.fillcolor("fill"===f||"heatmap"===f?d:"").line({color:"lines"===f?d:u.color,width:!1!==c.showlines?u.width:0,dash:u.dash}).levels({start:c.start,end:o(c),size:h}).options(r.colorbar)()}else n.autoMargin(t,s)}},{"../../components/colorbar/draw":617,"../../plots/plots":846,"./end_plus":943,"./make_color_map":947}],940:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],941:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r){var a=n.coerce2(t,e,i,"contours.start"),o=n.coerce2(t,e,i,"contours.end"),s=!1===a||!1===o,l=r("contours.size");!(s?e.autocontour=!0:r("autocontour",!1))&&l||r("ncontours")}},{"../../lib":738,"./attributes":937}],942:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../heatmap/has_columns"),a=t("../heatmap/xyz_defaults"),o=t("./contours_defaults"),s=t("./style_defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}a(t,e,u,c)?(u("text"),u("connectgaps",i(e)),o(t,e,u),s(t,e,u,c)):e.visible=!1}},{"../../lib":738,"../heatmap/has_columns":972,"../heatmap/xyz_defaults":981,"./attributes":937,"./contours_defaults":941,"./style_defaults":951}],943:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],944:[function(t,e,r){"use strict";function n(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==l.BOTTOMSTART.indexOf(t)?i=1:-1!==l.LEFTSTART.indexOf(t)?n=1:-1!==l.TOPSTART.indexOf(t)?i=-1:n=-1;return[n,i]}(p,r,e),g=[o(t,e,[-m[0],-m[1]])],v=m.join(","),y=t.z.length,b=t.z[0].length;for(h=0;h<1e4;h++){if(p>20?(p=l.CHOOSESADDLE[p][(m[0]||m[1])<0?0:1],t.crossings[d]=l.SADDLEREMAINDER[p]):delete t.crossings[d],!(m=l.NEWDELTA[p])){s.log("Found bad marching index:",p,e,t.level);break}g.push(o(t,e,m)),e[0]+=m[0],e[1]+=m[1],n(g[g.length-1],g[g.length-2],a,c)&&g.pop(),d=e.join(",");var x=m[0]&&(e[0]<0||e[0]>b-2)||m[1]&&(e[1]<0||e[1]>y-2);if(d===f&&m.join(",")===v||r&&x)break;p=t.crossings[d]}1e4===h&&s.log("Infinite loop in contour?");var _,w,M,k,T,A,S,E,L,C,I,P=n(g[0],g[g.length-1],a,c),D=0,z=.2*t.smoothing,O=[],F=0;for(h=1;h=F;h--)if((_=O[h])=F&&_+O[w]E&&L--,t.edgepaths[L]=I.concat(g,C));break}N||(t.edgepaths[E]=g.concat(C))}for(E=0;Et?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r)return t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208;return 15===r?0:r}((c=t[u]).level,s))&&(c.crossings[o]=l,-1!==i.indexOf(l)&&(c.starts.push([e,r]),p&&-1!==i.indexOf(l,i.indexOf(l)+1)&&c.starts.push([e,r])))}},{"./constants":940}],949:[function(t,e,r){"use strict";function n(t,e,n){var l=n[0].trace,c=n[0].x,u=n[0].y,g=l.contours,v=l.uid,y=e.xaxis,b=e.yaxis,x=t._fullLayout,_="contour"+v,w=function(t,e,r){for(var n=t.size,i=[],a=p(t),s=t.start;s1e3){o.warn("Too many contours, clipping at 1000",t);break}return i}(g,e,n[0]);if(!0!==l.visible)return x._paper.selectAll("."+_+",.hm"+v).remove(),void x._infolayer.selectAll(".cb"+v).remove();"heatmap"===g.coloring?(l.zauto&&!1===l.autocontour&&(l._input.zmin=l.zmin=g.start-g.size/2,l._input.zmax=l.zmax=l.zmin+w.length*g.size),h(t,e,[n])):(x._paper.selectAll(".hm"+v).remove(),x._infolayer.selectAll("g.rangeslider-container").selectAll(".hm"+v).remove()),f(w),d(w);var M=y.c2p(c[0],!0),k=y.c2p(c[c.length-1],!0),T=b.c2p(u[0],!0),A=b.c2p(u[u.length-1],!0),S=[[M,A],[k,A],[k,T],[M,T]],E=r.makeContourGroup(e,n,_);!function(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}(E,S,g),function(t,e,r,n){var o=t.selectAll("g.contourfill").data([0]);o.enter().append("g").classed("contourfill",!0);var s=o.selectAll("path").data("fill"===n.coloring?e:[]);s.enter().append("path"),s.exit().remove(),s.each(function(t){var e=i(t,r);e?a.select(this).attr("d",e).style("stroke","none"):a.select(this).remove()})}(E,w,S,g),function(t,e,n,i,l,c){var u=t.selectAll("g.contourlines").data([0]);u.enter().append("g").classed("contourlines",!0);var h=!1!==l.showlines,f=l.showlabels,d=h&&f,p=r.createLines(u,h||f,e),g=r.createLineClip(u,d,n._fullLayout._clips,i.trace.uid),v=t.selectAll("g.contourlabels").data(f?[0]:[]);if(v.exit().remove(),v.enter().append("g").classed("contourlabels",!0),f){var y=[c],b=[];o.clearLocationCache();var x=r.labelFormatter(l,i.t.cb,n._fullLayout),_=s.tester.append("text").attr("data-notex",1).call(s.font,l.labelfont),w=e[0].xaxis._length,M=e[0].yaxis._length,k={left:Math.max(c[0][0],0),right:Math.min(c[2][0],w),top:Math.max(c[0][1],0),bottom:Math.min(c[2][1],M)};k.middle=(k.top+k.bottom)/2,k.center=(k.left+k.right)/2;var T=Math.sqrt(w*w+M*M),A=m.LABELDISTANCE*T/Math.max(1,e.length/m.LABELINCREASE);p.each(function(t){var e=r.calcTextOpts(t.level,x,_,n);a.select(this).selectAll("path").each(function(){var t=o.getVisibleSegment(this,k,e.height/2);if(t&&!(t.len<(e.width+e.height)*m.LABELMIN))for(var n=Math.min(Math.ceil(t.len/A),m.LABELMAX),i=0;i=0&&(c=b,h=f):Math.abs(l[1]-c[1])<.01?Math.abs(l[1]-b[1])<.01&&(b[0]-l[0])*(c[0]-b[0])>=0&&(c=b,h=f):o.log("endpt to newendpt is not vert. or horz.",l,c,b)}if(l=c,h>=0)break;m+="L"+c}if(h===t.edgepaths.length){o.log("unclosed perimeter path");break}g=h,(y=-1===v.indexOf(g))&&(g=v[0],m+="Z")}for(g=0;gn.center?n.right-s:s-n.left)/(u+Math.abs(Math.sin(c)*a)),d=(l>n.middle?n.bottom-l:l-n.top)/(Math.abs(h)+Math.cos(c)*a);if(f<1||d<1)return 1/0;var p=g.EDGECOST*(1/(f-1)+1/(d-1));p+=g.ANGLECOST*c*c;for(var m=s-u,v=l-h,y=s+u,b=l+h,x=0;x2*g.MAXCOST)break;d&&(s/=2),l=(a=c-s/2)+1.5*s}if(f<=g.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var i=e.width/2,a=e.height/2,o=t.x,s=t.y,l=t.theta,c=Math.sin(l),u=Math.cos(l),h=i*u,f=a*c,d=i*c,p=-a*u,m=[[o-h-f,s-d-p],[o+h-f,s+d-p],[o+h+f,s+d+p],[o-h+f,s-d+p]];r.push({text:e.text,x:o,y:s,dy:e.dy,theta:l,level:e.level,width:e.width,height:e.height}),n.push(m)},r.drawLabels=function(t,e,r,n,i){var o=t.selectAll("text").data(e,function(t){return t.text+","+t.x+","+t.y+","+t.theta});if(o.exit().remove(),o.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each(function(t){var e=t.x+Math.sin(t.theta)*t.dy,n=t.y-Math.cos(t.theta)*t.dy;a.select(this).text(t.text).attr({x:e,y:n,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+n+")"}).call(l.convertToTspans,r)}),i){for(var s="",c=0;cb.end&&(b.start=b.end=(b.start+b.end)/2),e._input.contours=a({},b)}else{var _=b.start,w=b.end,M=e._input.contours;if(_>w&&(b.start=M.start=w,w=b.end=M.end=_,_=b.start),!(b.size>0)){var k;k=_===w?1:n(_,w,e.ncontours).dtick,M.size=b.size=k}}return y}}},{"../../components/colorscale/calc":620,"../../lib":738,"../../plots/cartesian/axes":785,"../carpet/lookup_carpetid":919,"../heatmap/clean_2d_array":967,"../heatmap/convert_column_xyz":969,"../heatmap/find_empties":971,"../heatmap/has_columns":972,"../heatmap/interp2d":975,"../heatmap/make_bound_array":976,"../heatmap/max_row_length":977,"./defaults":959}],954:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i,a,o,s=n.a.length,l=n.b.length,c=n.z,u=-1/0,h=1/0;for(i=0;i":case">=":n.contours.value>u&&(t[0].prefixBoundary=!0);break;case"<":case"<=":n.contours.valueu&&(t[0].prefixBoundary=!0);break;case"][":case")(":a=Math.min.apply(null,n.contours.value),o=Math.max.apply(null,n.contours.value),au&&(t[0].prefixBoundary=!0)}}},{}],955:[function(t,e,r){"use strict";e.exports={INEQUALITY_OPS:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"]}},{}],956:[function(t,e,r){"use strict";function n(t,e){function r(t){return s(t)?+t:null}var n,i=Array.isArray(e);return-1!==o.INEQUALITY_OPS.indexOf(t)?n=r(i?e[0]:e):-1!==o.INTERVAL_OPS.indexOf(t)?n=i?[r(e[0]),r(e[1])]:[r(e),r(e)]:-1!==o.SET_OPS.indexOf(t)&&(n=i?e.map(r):[r(e)]),n}function i(t){return function(e){e=n(t,e);var r=Math.min(e[0],e[1]),i=Math.max(e[0],e[1]);return{start:r,end:i,size:i-r}}}function a(t){return function(e){return e=n(t,e),{start:e,end:1/0,size:1/0}}}var o=t("./constants"),s=t("fast-isnumeric");e.exports["[]"]=i("[]"),e.exports["()"]=i("()"),e.exports["[)"]=i("[)"),e.exports["(]"]=i("(]"),e.exports["]["]=i("]["),e.exports[")("]=i(")("),e.exports[")["]=i(")["),e.exports["]("]=i("]("),e.exports[">"]=a(">"),e.exports[">="]=a(">="),e.exports["<"]=a("<"),e.exports["<="]=a("<="),e.exports["="]=a("=")},{"./constants":955,"fast-isnumeric":132}],957:[function(t,e,r){"use strict";var n=t("./constraint_mapping"),i=t("fast-isnumeric");e.exports=function(t,e){var r;-1===["=","<","<=",">",">="].indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:i(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),i(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0));var a=n[e.operation](e.value);e.start=a.start,e.end=a.end,e.size=a.size}},{"./constraint_mapping":956,"fast-isnumeric":132}],958:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){var r,i,a,o=function(t){return t.reverse()},s=function(t){return t};switch(e){case"][":case")[":case"](":case")(":var l=o;o=s,s=l;case"[]":case"[)":case"(]":case"()":if(2!==t.length)return void n.warn("Contour data invalid for the specified inequality range operation.");for(i=t[0],a=t[1],r=0;r=":case">":if(1!==t.length)return void n.warn("Contour data invalid for the specified inequality operation.");for(i=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return a}},{"../../lib":738}],961:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../contour/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("../contour/style"),n.moduleType="trace",n.name="contourcarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","carpet","contour","symbols","showLegend","hasLines","carpetDependent"],n.meta={},e.exports=n},{"../../plots/cartesian":796,"../contour/colorbar":939,"../contour/style":950,"./attributes":952,"./calc":953,"./defaults":959,"./plot":964}],962:[function(t,e,r){"use strict";var n=t("../../components/drawing"),i=t("../carpet/axis_aligned_line"),a=t("../../lib");e.exports=function(t,e,r,o,s,l,c,u){function h(t){return Math.abs(t[1]-r[0][1])=0&&(y=L,x=_):Math.abs(v[1]-y[1])=0&&(y=L,x=_):a.log("endpt to newendpt is not vert. or horz.",v,y,L)}if(x>=0)break;M+=m(v,y),v=y}if(x===e.edgepaths.length){a.log("unclosed perimeter path");break}g=x,(T=-1===k.indexOf(g))&&(g=k[0],M+=m(v,y)+"Z",v=null)}for(g=0;g=0;U--)j=k.clipsegments[U],N=l([],j.x,L.c2p),B=l([],j.y,C.c2p),N.reverse(),B.reverse(),H.push(c(N,B,j.bicubic));var q="M"+H.join("L")+"Z";!function(t,e,r,n,i,a){var o,s,u,h,f=t.selectAll("g.contourbg").data([0]);f.enter().append("g").classed("contourbg",!0);var d=f.selectAll("path").data("fill"!==a||i?[]:[0]);d.enter().append("path"),d.exit().remove();var p=[];for(h=0;hb&&(n.max=b);n.len=n.max-n.min}(this,r,t,n,f,e.height),!(n.len<(e.width+e.height)*m.LABELMIN)))for(var s=Math.min(Math.ceil(n.len/P),m.LABELMAX),l=0;lI){r("x scale is not linear");break}}if(y.length&&"fast"===L){var P=(y[y.length-1]-y[0])/(y.length-1),D=Math.abs(P/100);for(w=0;wD){r("y scale is not linear");break}}}var z=u(_),O="scaled"===e.xtype?"":m,F=p(e,O,g,v,z,k),R="scaled"===e.ytype?"":y,j=p(e,R,b,x,_.length,T);E||(a.expand(k,F),a.expand(T,j));var N={x:F,y:j,z:_,text:e.text};if(S&&(N.xRanges=M.xRanges,N.yRanges=M.yRanges,N.pts=M.pts),s(e,_,"","z"),A&&e.contours&&"heatmap"===e.contours.coloring){var B={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};N.xfill=p(B,O,g,v,z,k),N.yfill=p(B,R,b,x,_.length,T)}return[N]}},{"../../components/colorscale/calc":620,"../../lib":738,"../../plots/cartesian/axes":785,"../../registry":861,"../histogram2d/calc":998,"./clean_2d_array":967,"./convert_column_xyz":969,"./find_empties":971,"./has_columns":972,"./interp2d":975,"./make_bound_array":976,"./max_row_length":977}],967:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){function r(t){if(n(t))return+t}var i,a,o,s,l,c;if(e){for(i=0,l=0;l=0;o--)(s=((h[[(r=(a=f[o])[0])-1,i=a[1]]]||m)[2]+(h[[r+1,i]]||m)[2]+(h[[r,i-1]]||m)[2]+(h[[r,i+1]]||m)[2])/20)&&(l[a]=[r,i,s],f.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(a in l)h[a]=l[a],u.push(l[a])}return u.sort(function(t,e){return e[2]-t[2]})}},{"./max_row_length":977}],972:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],973:[function(t,e,r){"use strict";var n=t("../../components/fx"),i=t("../../lib"),a=t("../../plots/cartesian/axes"),o=n.constants.MAXDIST;e.exports=function(t,e,r,s,l,c){if(!(t.distance=x[0].length||d<0||d>x.length)return}else{if(n.inbox(e-y[0],e-y[y.length-1])>o||n.inbox(r-b[0],r-b[b.length-1])>o)return;if(c){var A;for(k=[2*y[0]-y[1]],A=1;Am&&(v=Math.max(v,Math.abs(t[i][a]-p)/(g-m))))}return v}var a=t("../../lib"),o=[[-1,0],[1,0],[0,-1],[0,1]];e.exports=function(t,e,r){var o,s,l=1;if(Array.isArray(r))for(o=0;o.01;o++)l=i(t,e,n(l));return l>.01&&a.log("interp2d didn't converge quickly",l),t}},{"../../lib":738}],976:[function(t,e,r){"use strict";var n=t("../../registry");e.exports=function(t,e,r,i,a,o){var s,l,c,u=[],h=n.traceIs(t,"contour"),f=n.traceIs(t,"histogram"),d=n.traceIs(t,"gl2d");if(Array.isArray(e)&&e.length>1&&!f&&"category"!==o.type){var p=e.length;if(!(p<=a))return h?e.slice(0,a):e.slice(0,a+1);if(h||d)u=e.slice(0,a);else if(1===a)u=[e[0]-.5,e[0]+.5];else{for(u=[1.5*e[0]-.5*e[1]],c=1;c0;)x=m.c2p(A[k]),k--;for(x0;)M=g.c2p(S[k]),k--;if(M0&&(n=!0);for(var s=0;sa){var o=a-r[t];return r[t]=a,o}}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]c){var l=a(e,i,o),u=a(r,i,o),h=t===s?0:1;return l[h]!==u[h]}return Math.floor(r/t)-Math.floor(e/t)>.1}(f,t,e,l,r,n))break;u=f}return u}function i(t,e){return e&&t>f?t>c?t>1.1*s?s:t>1.1*l?l:c:t>u?u:t>h?h:f:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function a(t,e,r){var n=e.c2d(t,s,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}var o=t("../../constants/numerical"),s=o.ONEAVGYEAR,l=o.ONEAVGMONTH,c=o.ONEDAY,u=o.ONEHOUR,h=o.ONEMIN,f=o.ONESEC,d=t("../../plots/cartesian/axes").tickIncrement;e.exports=function(t,e,r,i,a){var o,l,u=-1.1*e,h=-.1*e,f=t-h,p=r[0],m=r[1],g=Math.min(n(p+h,p+f,i,a),n(m+h,m+f,i,a)),v=Math.min(n(p+u,p+h,i,a),n(m+u,m+h,i,a));if(g>v&&vc){var y=o===s?1:6,b=o===s?"M12":"M1";return function(e,r){var n=i.c2d(e,s,a),o=n.indexOf("-",y);o>0&&(n=n.substr(0,o));var c=i.d2c(n,0,a);if(cp.size/1.9?p.size:p.size/Math.ceil(p.size/x);var A=p.start+(p.size-x)/2;_=A-x*Math.ceil((A-_)/x)}for(h=0;h=0&&w=0;a--)i(a);else if("increasing"===e){for(a=1;a=0;a--)t[a]+=t[a+1];"exclude"===r&&(t.push(0),t.shift())}}(a,b.direction,b.currentbin);var Z=Math.min(i.length,a.length),J=[],K=0,Q=Z-1;for(r=0;r=K;r--)if(a[r]){Q=r;break}for(r=K;r<=Q;r++)if(o(i[r])&&o(a[r])){var $={p:i[r],s:a[r],b:0};b.enabled||($.pts=I[r],H?$.p0=$.p1=I[r].length?T[I[r][0]]:i[r]:($.p0=X(S[r]),$.p1=X(S[r+1],!0))),J.push($)}return 1===J.length&&(J[0].width1=l.tickIncrement(J[0].p,k.size,!1,y)-J[0].p),c(J,e),Array.isArray(e.selectedpoints)&&s.tagSelected(J,e,Y),J}}},{"../../constants/numerical":717,"../../lib":738,"../../plots/cartesian/axes":785,"../bar/arrays_to_calcdata":870,"./average":986,"./bin_functions":988,"./bin_label_vals":989,"./clean_bins":991,"./norm_functions":996,"fast-isnumeric":132}],991:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib").cleanDate,a=t("../../constants/numerical"),o=a.ONEDAY,s=a.BADNUM;e.exports=function(t,e,r){var a=e.type,l=r+"bins",c=t[l];c||(c=t[l]={});var u="date"===a?function(t){return t||0===t?i(t,s,c.calendar):null}:function(t){return n(t)?Number(t):null};c.start=u(c.start),c.end=u(c.end);var h="date"===a?o:1,f=c.size;if(n(f))c.size=f>0?Number(f):h;else if("string"!=typeof f)c.size=h;else{var d=f.charAt(0),p=f.substr(1);((p=n(p)?Number(p):0)<=0||"date"!==a||"M"!==d||p!==Math.round(p))&&(c.size=h)}var m="autobin"+r;"boolean"!=typeof t[m]&&(t[m]=!((c.start||0===c.start)&&(c.end||0===c.end))),t[m]||delete t["nbins"+r]}},{"../../constants/numerical":717,"../../lib":738,"fast-isnumeric":132}],992:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/color"),o=t("./bin_defaults"),s=t("../bar/style_defaults"),l=t("../../components/errorbars/defaults"),c=t("./attributes");e.exports=function(t,e,r,u){function h(r,n){return i.coerce(t,e,c,r,n)}var f=h("x"),d=h("y");h("cumulative.enabled")&&(h("cumulative.direction"),h("cumulative.currentbin")),h("text");var p=h("orientation",d&&!f?"h":"v"),m=e["v"===p?"x":"y"];if(m&&m.length){n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x","y"],u);e["h"===p?"x":"y"]&&h("histfunc");o(t,e,h,"h"===p?["y"]:["x"]),s(t,e,h,r,u),l(t,e,a.defaultLine,{axis:"y"}),l(t,e,a.defaultLine,{axis:"x",inherit:"y"}),i.coerceSelectionMarkerOpacity(e,h)}else e.visible=!1}},{"../../components/color":613,"../../components/errorbars/defaults":643,"../../lib":738,"../../registry":861,"../bar/style_defaults":883,"./attributes":985,"./bin_defaults":987}],993:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){if(t.x="xVal"in e?e.xVal:e.x,t.y="yVal"in e?e.yVal:e.y,e.xa&&(t.xaxis=e.xa),e.ya&&(t.yaxis=e.ya),!(r.cumulative||{}).enabled){var a=Array.isArray(i)?n[0].pts[i[0]][i[1]]:n[i].pts;t.pointNumbers=a,t.binNumber=t.pointNumber,delete t.pointNumber,delete t.pointIndex;var o;if(r._indexToPoints){o=[];for(var s=0;sT&&g.splice(T,g.length-T),y.length>T&&y.splice(T,y.length-T),n(e,"x",g,m,_,M,b),n(e,"y",y,v,w,k,x);var A=[],S=[],E=[],L="string"==typeof e.xbins.size,C="string"==typeof e.ybins.size,I=[],P=[],D=L?I:e.xbins,z=C?P:e.ybins,O=0,F=[],R=[],j=e.histnorm,N=e.histfunc,B=-1!==j.indexOf("density"),U="max"===N||"min"===N?null:0,V=c.count,H=u[j],q=!1,G=[],Y=[],W="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";W&&"count"!==N&&(q="avg"===N,V=c[N]);var X=e.xbins,Z=_(X.start),J=_(X.end)+(Z-l.tickIncrement(Z,X.size,!1,b))/1e6;for(r=Z;r=0&&d=0&&p0)o=c(t.alphahull,f);else{var d=["x","y","z"].indexOf(t.delaunayaxis);o=l(f.map(function(t){return[t[(d+1)%3],t[(d+2)%3]]}))}var p={positions:f,cells:o,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:h(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.vertexIntensityBounds=[t.cmin,t.cmax],p.colormap=function(t){return t.map(function(t){var e=t[0],r=s(t[1]).toRgb();return{index:e,rgb:[r.r,r.g,r.b,1]}})}(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolor[0],p.vertexColors=i(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=i(t.facecolor)):(this.color=t.color,p.meshColor=h(t.color)),this.mesh.update(p)},f.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=function(t,e){var r=t.glplot.gl,i=o({gl:r}),a=new n(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}},{"../../lib/str2rgbarray":760,"alpha-shape":44,"convex-hull":104,"delaunay-triangulate":124,"gl-mesh3d":206,tinycolor2:543}],1010:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}function c(t){var e=t.map(function(t){var e=l(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var u=c(["x","y","z"]),h=c(["i","j","k"]);if(u){h&&h.forEach(function(t){for(var e=0;ei?r=!0:e1)){var h=a.simpleMap(u.x,e.d2c,0,r.xcalendar),f=a.distinctVals(h).minDiff;o=Math.min(o,f)}}for(o===1/0&&(o=1),c=0;c");S.push(o,o,o,o,o,o,null)},R=0;Rs&&(n.log("parcoords traces support up to "+s+" dimensions at the moment"),c.splice(s)),l=0;l0)&&(r("label"),r("tickvals"),r("ticktext"),r("tickformat"),r("range"),r("constraintrange"),h=Math.min(h,o.values.length)),o._index=l,u.push(o));if(isFinite(h))for(l=0;lh&&(o.values=o.values.slice(0,h));return u}(t,e);!function(t,e,r,i,s){s("line.color",r),a(t,"line")&&n.isArray(t.line.color)?(s("line.colorscale"),o(t,e,i,s,{prefix:"line.",cLetter:"c"})):s("line.color",r)}(t,e,r,l,c),c("domain.x"),c("domain.y"),Array.isArray(u)&&u.length||(e.visible=!1);var h={family:l.font.family,size:Math.round(l.font.size*(10/12)),color:l.font.color};n.coerceFont(c,"labelfont",h),n.coerceFont(c,"tickfont",h),n.coerceFont(c,"rangefont",h)}},{"../../components/colorscale/defaults":623,"../../components/colorscale/has_colorscale":627,"../../lib":738,"./attributes":1019,"./constants":1023}],1025:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.colorbar=t("./colorbar"),n.moduleType="trace",n.name="parcoords",n.basePlotModule=t("./base_plot"),n.categories=["gl","regl","noOpacity"],n.meta={},e.exports=n},{"./attributes":1019,"./base_plot":1020,"./calc":1021,"./colorbar":1022,"./defaults":1024,"./plot":1028}],1026:[function(t,e,r){"use strict";function n(t,e,r,n,i){var a=t._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,r,n,i),t.clear({color:[0,0,0,0],depth:1})}function i(t,e,r,i,a,o){function s(c){var u;u=Math.min(i,a-c*i),o.offset=f*c*i,o.count=f*u,0===c&&(window.cancelAnimationFrame(r.currentRafs[l]),delete r.currentRafs[l],n(t,o.scissorX,o.scissorY,o.scissorWidth,o.viewBoxSize[1])),r.clearOnly||(e(o),c*i+u>>8*e)%256/255}function s(t,e){var r={};return[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map(function(r){return function(t,e,r){var n,i,a,o=[];for(i=0;i=h-4?o(s,h-2-l):.5);return i}(E,S,A,C),O=s(E,z),F=e.regl,R=F.texture({shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest",data:function(t,e,r){for(var n=[],i=0;i<256;i++){var a=t(i/255);n.push((e?p:a).concat(r))}return n}(w,M,Math.round(255*(M?I:1)))}),j=F({profile:!1,blend:{enable:L,func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:1,dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]},depth:{enable:!L,mask:!0,func:"less",range:[0,1]},cull:{enable:!0,face:"back"},scissor:{enable:!0,box:{x:F.prop("scissorX"),y:F.prop("scissorY"),width:F.prop("scissorWidth"),height:F.prop("scissorHeight")}},viewport:{x:F.prop("viewportX"),y:F.prop("viewportY"),width:F.prop("viewportWidth"),height:F.prop("viewportHeight")},dither:!1,vert:k?"precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nuniform float scatter;\n\nvarying vec4 fragColor;\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nvoid main() {\n\n float x = 0.5 * sign(pf[3]) + 0.5;\n float prominence = abs(pf[3]);\n float depth = 1.0 - prominence;\n\n mat4 pA = mat4(p0, p1, p2, p3);\n mat4 pB = mat4(p4, p5, p6, p7);\n mat4 pC = mat4(p8, p9, pa, pb);\n mat4 pD = mat4(pc, pd, pe, abs(pf));\n\n float show = float(mshow(pA, loA, hiA) &&\n mshow(pB, loB, hiB) &&\n mshow(pC, loC, hiC) &&\n mshow(pD, loD, hiD));\n\n vec2 yy = show * vec2(val(pA, dim2A) + val(pB, dim2B) + val(pC, dim2C) + val(pD, dim2D),\n val(pA, dim1A) + val(pB, dim1B) + val(pC, dim1C) + val(pD, dim1D));\n\n vec2 dimensionToggle = vec2(x, 1.0 - x);\n\n vec2 scatterToggle = vec2(scatter, 1.0 - scatter);\n\n float y = dot(yy, dimensionToggle);\n mat2 xy = mat2(viewBoxSize * yy + dimensionToggle, viewBoxSize * vec2(x, y));\n\n vec2 viewBoxXY = viewBoxPosition + xy * scatterToggle;\n\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n gl_Position = vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n\n // pick coloring\n fragColor = vec4(pf.rgb, 1.0);\n}\n":"precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 p0, p1, p2, p3,\n p4, p5, p6, p7,\n p8, p9, pa, pb,\n pc, pd, pe;\n\nattribute vec4 pf;\n\nuniform mat4 dim1A, dim2A, dim1B, dim2B, dim1C, dim2C, dim1D, dim2D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution,\n viewBoxPosition,\n viewBoxSize;\n\nuniform sampler2D palette;\n\nuniform vec2 colorClamp;\n\nuniform float scatter;\n\nvarying vec4 fragColor;\n\nvec4 zero = vec4(0, 0, 0, 0);\nvec4 unit = vec4(1, 1, 1, 1);\nvec2 xyProjection = vec2(1, 1);\n\nmat4 mclamp(mat4 m, mat4 lo, mat4 hi) {\n return mat4(clamp(m[0], lo[0], hi[0]),\n clamp(m[1], lo[1], hi[1]),\n clamp(m[2], lo[2], hi[2]),\n clamp(m[3], lo[3], hi[3]));\n}\n\nbool mshow(mat4 p, mat4 lo, mat4 hi) {\n return mclamp(p, lo, hi) == p;\n}\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * unit, unit);\n}\n\nvoid main() {\n\n float x = 0.5 * sign(pf[3]) + 0.5;\n float prominence = abs(pf[3]);\n float depth = 1.0 - prominence;\n\n mat4 pA = mat4(p0, p1, p2, p3);\n mat4 pB = mat4(p4, p5, p6, p7);\n mat4 pC = mat4(p8, p9, pa, pb);\n mat4 pD = mat4(pc, pd, pe, abs(pf));\n\n float show = float(mshow(pA, loA, hiA) &&\n mshow(pB, loB, hiB) &&\n mshow(pC, loC, hiC) &&\n mshow(pD, loD, hiD));\n\n vec2 yy = show * vec2(val(pA, dim2A) + val(pB, dim2B) + val(pC, dim2C) + val(pD, dim2D),\n val(pA, dim1A) + val(pB, dim1B) + val(pC, dim1C) + val(pD, dim1D));\n\n vec2 dimensionToggle = vec2(x, 1.0 - x);\n\n vec2 scatterToggle = vec2(scatter, 1.0 - scatter);\n\n float y = dot(yy, dimensionToggle);\n mat2 xy = mat2(viewBoxSize * yy + dimensionToggle, viewBoxSize * vec2(x, y));\n\n vec2 viewBoxXY = viewBoxPosition + xy * scatterToggle;\n\n float depthOrHide = depth + 2.0 * (1.0 - show);\n\n gl_Position = vec4(\n xyProjection * (2.0 * viewBoxXY / resolution - 1.0),\n depthOrHide,\n 1.0\n );\n\n // visible coloring\n float clampedColorIndex = clamp((prominence - colorClamp[0]) / (colorClamp[1] - colorClamp[0]), 0.0, 1.0);\n fragColor = texture2D(palette, vec2((clampedColorIndex * 255.0 + 0.5) / 256.0, 0.5));\n}\n",frag:"precision lowp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n",primitive:"lines",lineWidth:1,attributes:O,uniforms:{resolution:F.prop("resolution"),viewBoxPosition:F.prop("viewBoxPosition"),viewBoxSize:F.prop("viewBoxSize"),dim1A:F.prop("dim1A"),dim2A:F.prop("dim2A"),dim1B:F.prop("dim1B"),dim2B:F.prop("dim2B"),dim1C:F.prop("dim1C"),dim2C:F.prop("dim2C"),dim1D:F.prop("dim1D"),dim2D:F.prop("dim2D"),loA:F.prop("loA"),hiA:F.prop("hiA"),loB:F.prop("loB"),hiB:F.prop("hiB"),loC:F.prop("loC"),hiC:F.prop("hiC"),loD:F.prop("loD"),hiD:F.prop("hiD"),palette:R,colorClamp:F.prop("colorClamp"),scatter:F.prop("scatter")},offset:F.prop("offset"),count:F.prop("count")}),N=[0,1],B=[];return{setColorDomain:function(t){N[0]=t[0],N[1]=t[1]},render:function(t,e,a){var o,s,l,c=1/0,h=-1/0;for(o=0;oh&&(h=t[o].dim2.canvasX,l=o),t[o].dim1.canvasXi)return a;i=o,a=n[r]}return n[n.length-1]}function o(t){return d.scale.linear().domain(i(t))}function s(t,e,r){var i=v(e),a=i.trace,s=i.lineColor,l=i.cscale,c=a.line,u=a.domain,p=a.dimensions,m=t.width,g=a.labelfont,y=a.tickfont,b=a.rangefont,x=f.extendDeep({},c,{color:s.map(o({values:s,range:[c.cmin,c.cmax]})),blockLineCount:h.blockLineCount,canvasOverdrag:h.overdrag*h.canvasPixelRatio}),_=Math.floor(m*(u.x[1]-u.x[0])),w=Math.floor(t.height*(u.y[1]-u.y[0])),M=t.margin||{l:80,r:80,t:100,b:80},k=_,T=w;return{key:r,colCount:p.filter(n).length,dimensions:p,tickDistance:h.tickDistance,unitToColor:function(t){var e=t.map(function(t){return t[0]}),r=t.map(function(t){return t[1]}).map(function(t){return d.rgb(t)}),n="rgb".split("").map(function(t){return d.scale.linear().clamp(!0).domain(e).range(r.map(function(t){return function(e){return e[t]}}(t)))});return function(t){return n.map(function(e){return e(t)})}}(l),lines:x,labelFont:g,tickFont:y,rangeFont:b,layoutWidth:m,layoutHeight:t.height,domain:u,translateX:u.x[0]*m,translateY:t.height-u.y[1]*t.height,pad:M,canvasWidth:k*h.canvasPixelRatio+2*x.canvasOverdrag,canvasHeight:T*h.canvasPixelRatio,width:k,height:T,canvasPixelRatio:h.canvasPixelRatio}}function l(t){var e=t.width,r=t.height,a=t.dimensions,s=t.canvasPixelRatio,l=function(r){return e*r/Math.max(1,t.colCount-1)},c=h.verticalPadding/(r*s),u=1-2*c,f=function(t){return c+u*t},p={key:t.key,xScale:l,model:t},m={};return p.dimensions=a.filter(n).map(function(e,n){var a=o(e),c=m[e.label];m[e.label]=(c||0)+1;return{key:e.label+(c?"__"+c:""),label:e.label,tickFormat:e.tickformat,tickvals:e.tickvals,ticktext:e.ticktext,ordinal:!!e.tickvals,scatter:h.scatter||e.scatter,xIndex:n,crossfilterDimensionIndex:n,visibleIndex:e._index,height:r,values:e.values,paddedUnitValues:e.values.map(a).map(f),xScale:l,x:l(n),canvasX:l(n)*s,unitScale:function(t,e){return d.scale.linear().range([t-e,e])}(r,h.verticalPadding),domainScale:function(t,e,r){var n=i(r),a=r.ticktext;return r.tickvals?d.scale.ordinal().domain(r.tickvals.map(function(t,e){return function(r,n){if(e){var i=e[n];return null===i||void 0===i?t(r):i}return t(r)}}(d.format(r.tickformat),a))).range(r.tickvals.map(function(t){return(t-n[0])/(n[1]-n[0])}).map(function(r){return t-e+r*(e-(t-e))})):d.scale.linear().domain(n).range([t-e,e])}(r,h.verticalPadding,e),ordinalScale:function(t){var e=i(t);return t.tickvals&&d.scale.ordinal().domain(t.tickvals).range(t.tickvals.map(function(t){return(t-e[0])/(e[1]-e[0])}))}(e),domainToUnitScale:a,filter:e.constraintrange?e.constraintrange.map(a):[0,1],parent:p,model:t}}),p}function c(t){t.classed(h.cn.axisExtentText,!0).attr("text-anchor","middle").style("cursor","default").style("user-select","none")}var u=t("./lines"),h=t("./constants"),f=t("../../lib"),d=t("d3"),p=t("../../components/drawing"),m=t("../../lib/gup").keyFun,g=t("../../lib/gup").repeat,v=t("../../lib/gup").unwrap;e.exports=function(t,e,r,n,i,o){function y(t){return t.dimensions.some(function(t){return 0!==t.filter[0]||1!==t.filter[1]})}function b(t,e){return(h.scatter?function(t,e){for(var r=e.panels||(e.panels=[]),n=t.each(function(t){return t})[e.key].map(function(t){return t.__data__}),i=n.length-1,a=i,o=0;o=r||s>=n)return;var l=t.lineLayer.readPixel(a,n-1-s),c=0!==l[3],u=c?l[2]+256*(l[1]+256*l[0]):null,h={x:a,y:s,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:u};u!==L&&(c?o.hover(h):o.unhover&&o.unhover(h),L=u)}}),S.style("opacity",function(t){return t.pick?.01:1}),e.style("background","rgba(255, 255, 255, 0)");var C=e.selectAll("."+h.cn.parcoords).data(A,m);C.exit().remove(),C.enter().append("g").classed(h.cn.parcoords,!0).attr("overflow","visible").style("box-sizing","content-box").style("position","absolute").style("left",0).style("overflow","visible").style("shape-rendering","crispEdges").style("pointer-events","none").call(function(t){var e=t.selectAll("defs").data(g,m);e.enter().append("defs");var r=e.selectAll("#"+h.id.filterBarPattern).data(g,m);r.enter().append("pattern").attr("id",h.id.filterBarPattern).attr("patternUnits","userSpaceOnUse"),r.attr("x",-h.bar.width).attr("width",h.bar.capturewidth).attr("height",function(t){return t.model.height});var n=r.selectAll("rect").data(g,m);n.enter().append("rect").attr("shape-rendering","crispEdges"),n.attr("height",function(t){return t.model.height}).attr("width",h.bar.width).attr("x",h.bar.width/2).attr("fill",h.bar.fillcolor).attr("fill-opacity",h.bar.fillopacity).attr("stroke",h.bar.strokecolor).attr("stroke-opacity",h.bar.strokeopacity).attr("stroke-width",h.bar.strokewidth)}),C.attr("width",function(t){return t.model.width+t.model.pad.l+t.model.pad.r}).attr("height",function(t){return t.model.height+t.model.pad.t+t.model.pad.b}).attr("transform",function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"});var I=C.selectAll("."+h.cn.parcoordsControlView).data(g,m);I.enter().append("g").classed(h.cn.parcoordsControlView,!0).style("box-sizing","content-box"),I.attr("transform",function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"});var P=I.selectAll("."+h.cn.yAxis).data(function(t){return t.dimensions},m);P.enter().append("g").classed(h.cn.yAxis,!0).each(function(t){E.dimensions.push(t)}),I.each(function(t){b(P,t)}),S.filter(function(t){return!!t.viewModel}).each(function(t){t.lineLayer=u(this,t,h.scatter),t.viewModel[t.key]=t.lineLayer,E.renderers.push(function(){t.lineLayer.render(t.viewModel.panels,!0)}),t.lineLayer.render(t.viewModel.panels,!t.context)}),P.attr("transform",function(t){return"translate("+t.xScale(t.xIndex)+", 0)"}),P.call(d.behavior.drag().origin(function(t){return t}).on("drag",function(t){var e=t.parent;T=!1,k||(t.x=Math.max(-h.overdrag,Math.min(t.model.width+h.overdrag,d.event.x)),t.canvasX=t.x*t.model.canvasPixelRatio,P.sort(function(t,e){return t.x-e.x}).each(function(e,r){e.xIndex=r,e.x=t===e?e.x:e.xScale(e.xIndex),e.canvasX=e.x*e.model.canvasPixelRatio}),b(P,e),P.filter(function(e){return 0!==Math.abs(t.xIndex-e.xIndex)}).attr("transform",function(t){return"translate("+t.xScale(t.xIndex)+", 0)"}),d.select(this).attr("transform","translate("+t.x+", 0)"),P.each(function(r,n,i){i===t.parent.key&&(e.dimensions[n]=r)}),e.contextLayer&&e.contextLayer.render(e.panels,!1,!y(e)),e.focusLayer.render&&e.focusLayer.render(e.panels))}).on("dragend",function(t){var e=t.parent;k?"ending"===k&&(k=!1):(t.x=t.xScale(t.xIndex),t.canvasX=t.x*t.model.canvasPixelRatio,b(P,e),d.select(this).attr("transform",function(t){return"translate("+t.x+", 0)"}),e.contextLayer&&e.contextLayer.render(e.panels,!1,!y(e)),e.focusLayer&&e.focusLayer.render(e.panels),e.pickLayer&&e.pickLayer.render(e.panels,!0),T=!0,o&&o.axesMoved&&o.axesMoved(e.key,e.dimensions.map(function(t){return t.crossfilterDimensionIndex})))})),P.exit().remove();var D=P.selectAll("."+h.cn.axisOverlays).data(g,m);D.enter().append("g").classed(h.cn.axisOverlays,!0),D.selectAll("."+h.cn.axis).remove();var z=D.selectAll("."+h.cn.axis).data(g,m);z.enter().append("g").classed(h.cn.axis,!0),z.each(function(t){var e=t.model.height/t.model.tickDistance,r=t.domainScale,n=r.domain();d.select(this).call(d.svg.axis().orient("left").tickSize(4).outerTickSize(2).ticks(e,t.tickFormat).tickValues(t.ordinal?n:null).tickFormat(t.ordinal?function(t){return t}:null).scale(r)),p.font(z.selectAll("text"),t.model.tickFont)}),z.selectAll(".domain, .tick>line").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),z.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var O=D.selectAll("."+h.cn.axisHeading).data(g,m);O.enter().append("g").classed(h.cn.axisHeading,!0);var F=O.selectAll("."+h.cn.axisTitle).data(g,m);F.enter().append("text").classed(h.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),F.attr("transform","translate(0,"+-h.axisTitleOffset+")").text(function(t){return t.label}).each(function(t){p.font(F,t.model.labelFont)});var R=D.selectAll("."+h.cn.axisExtent).data(g,m);R.enter().append("g").classed(h.cn.axisExtent,!0);var j=R.selectAll("."+h.cn.axisExtentTop).data(g,m);j.enter().append("g").classed(h.cn.axisExtentTop,!0),j.attr("transform","translate(0,"+-h.axisExtentOffset+")");var N=j.selectAll("."+h.cn.axisExtentTopText).data(g,m);N.enter().append("text").classed(h.cn.axisExtentTopText,!0).call(c),N.text(function(t){return x(t)(t.domainScale.domain().slice(-1)[0])}).each(function(t){p.font(N,t.model.rangeFont)});var B=R.selectAll("."+h.cn.axisExtentBottom).data(g,m);B.enter().append("g").classed(h.cn.axisExtentBottom,!0),B.attr("transform",function(t){return"translate(0,"+(t.model.height+h.axisExtentOffset)+")"});var U=B.selectAll("."+h.cn.axisExtentBottomText).data(g,m);U.enter().append("text").classed(h.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(c),U.text(function(t){return x(t)(t.domainScale.domain()[0])}).each(function(t){p.font(U,t.model.rangeFont)});var V=D.selectAll("."+h.cn.axisBrush).data(g,m),H=V.enter().append("g").classed(h.cn.axisBrush,!0);V.each(function(t){t.brush||(t.brush=d.svg.brush().y(t.unitScale).on("brushstart",_).on("brush",w).on("brushend",M),0===t.filter[0]&&1===t.filter[1]||t.brush.extent(t.filter),d.select(this).call(t.brush))}),H.selectAll("rect").attr("x",-h.bar.capturewidth/2).attr("width",h.bar.capturewidth),H.selectAll("rect.extent").attr("fill","url(#"+h.id.filterBarPattern+")").style("cursor","ns-resize").filter(function(t){return 0===t.filter[0]&&1===t.filter[1]}).attr("y",-100),H.selectAll(".resize rect").attr("height",h.bar.handleheight).attr("opacity",0).style("visibility","visible"),H.selectAll(".resize.n rect").style("cursor","n-resize").attr("y",h.bar.handleoverlap-h.bar.handleheight),H.selectAll(".resize.s rect").style("cursor","s-resize").attr("y",h.bar.handleoverlap);var q=!1,G=!1;return E}},{"../../components/drawing":638,"../../lib":738,"../../lib/gup":735,"./constants":1023,"./lines":1026,d3:123}],1028:[function(t,e,r){(function(r){"use strict";var n=t("./parcoords"),i=t("regl");e.exports=function(t,e){var a=t._fullLayout,o=a._toppaper,s=a._paperdiv,l=a._glcontainer;a._glcanvas.each(function(e){e.regl||(e.regl=i({canvas:this,attributes:{antialias:!e.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||r.devicePixelRatio}))});var c={},u={},h=a._size;e.forEach(function(e,r){c[r]=t.data[r].dimensions,u[r]=t.data[r].dimensions.slice()});n(s,o,l,e,{width:h.w,height:h.h,margin:{t:h.t,r:h.r,b:h.b,l:h.l}},{filterChanged:function(e,r,n){var i=u[e][r],a=i.constraintrange;a&&2===a.length||(a=i.constraintrange=[]),a[0]=n[0],a[1]=n[1],t.emit("plotly_restyle")},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){function n(t){return!("visible"in t)||t.visible}function i(t,e,r){var n=e.indexOf(r),i=t.indexOf(n);return-1===i&&(i+=e.length),i}var a=function(t){return function(e,n){return i(r,t,e)-i(r,t,n)}}(u[e].filter(n));c[e].sort(a),u[e].filter(function(t){return!n(t)}).sort(function(t){return u[e].indexOf(t)}).forEach(function(t){c[e].splice(c[e].indexOf(t),1),c[e].splice(u[e].indexOf(t),0,t)}),t.emit("plotly_restyle")}})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./parcoords":1027,regl:508}],1029:[function(t,e,r){"use strict";var n=t("../../components/color/attributes"),i=t("../../plots/font_attributes"),a=t("../../plots/attributes"),o=t("../../lib/extend").extendFlat,s=i({editType:"calc",colorEditType:"style"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:n.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:o({},a.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"calc"},textfont:o({},s,{}),insidetextfont:o({},s,{}),outsidetextfont:o({},s,{}),domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1,editType:"calc"},{valType:"number",min:0,max:1,editType:"calc"}],dflt:[0,1],editType:"calc"},y:{valType:"info_array",items:[{valType:"number",min:0,max:1,editType:"calc"},{valType:"number",min:0,max:1,editType:"calc"}],dflt:[0,1],editType:"calc"},editType:"calc"},hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"}}},{"../../components/color/attributes":612,"../../lib/extend":727,"../../plots/attributes":783,"../../plots/font_attributes":810}],1030:[function(t,e,r){"use strict";var n=t("../../registry");r.name="pie",r.plot=function(t){var e=n.getModule("pie"),r=function(t,e){for(var r=[],n=0;n")}}return y};var l},{"../../components/color":613,"./helpers":1034,"fast-isnumeric":132,tinycolor2:543}],1032:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values"),c=o("labels");if(!Array.isArray(c)){if(!Array.isArray(l)||!l.length)return void(e.visible=!1);o("label0"),o("dlabel")}o("marker.line.width")&&o("marker.line.color");var u=o("marker.colors");Array.isArray(u)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),f=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hovertext"),f&&"none"!==f){var d=o("textposition"),p=Array.isArray(d)||"auto"===d,m=p||"inside"===d,g=p||"outside"===d;if(m||g){var v=s(o,"textfont",a.font);m&&s(o,"insidetextfont",v),g&&s(o,"outsidetextfont",v)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":738,"./attributes":1029}],1033:[function(t,e,r){"use strict";var n=t("../../components/fx/helpers").appendArrayMultiPointValues;e.exports=function(t,e){var r={curveNumber:e.index,pointNumbers:t.pts,data:e._input,fullData:e,label:t.label,color:t.color,value:t.v,v:t.v};return 1===t.pts.length&&(r.pointNumber=r.i=t.pts[0]),n(r,e,t.pts),r}},{"../../components/fx/helpers":652}],1034:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)},r.getFirstFilled=function(t,e){if(Array.isArray(t))for(var r=0;r0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}var a=t("d3"),o=t("../../components/fx"),s=t("../../components/color"),l=t("../../components/drawing"),c=t("../../lib/svg_text_utils"),u=t("./helpers"),h=t("./event_data");e.exports=function(t,e){var r=t._fullLayout;!function(t,e){var r,n,i,a,o,s,l,c,u,h=[];for(i=0;il&&(l=s.pull[a]);o.r=Math.min(r,n)/(2+2*l),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===h.indexOf(s.scalegroup)&&h.push(s.scalegroup)}for(a=0;aa.vTotal/2?1:0)}(e),f.each(function(){var f=a.select(this).selectAll("g.slice").data(e);f.enter().append("g").classed("slice",!0),f.exit().remove();var m=[[[],[]],[[],[]]],g=!1;f.each(function(e){function s(t,r,n,i){return"a"+i*d.r+","+i*d.r+" 0 "+e.largeArc+(n?" 1 ":" 0 ")+i*(r[0]-t[0])+","+i*(r[1]-t[1])}if(e.hidden)a.select(this).selectAll("path,g").remove();else{e.pointNumber=e.i,e.curveNumber=p.index,m[e.pxmid[1]<0?0:1][e.pxmid[0]<0?0:1].push(e);var f=d.cx,v=d.cy,y=a.select(this),b=y.selectAll("path.surface").data([e]),x=!1,_=!1;if(b.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),y.select("path.textline").remove(),y.on("mouseover",function(){var i=t._fullLayout,s=t._fullData[p.index];if(!t._dragging&&!1!==i.hovermode){var l=s.hoverinfo;if(Array.isArray(l)&&(l=o.castHoverinfo({hoverinfo:[u.castOption(l,e.pts)],_module:p._module},i,0)),"all"===l&&(l="label+text+value+percent+name"),"none"!==l&&"skip"!==l&&l){var c=n(e,d),m=f+e.pxmid[0]*(1-c),g=v+e.pxmid[1]*(1-c),y=r.separators,b=[];if(-1!==l.indexOf("label")&&b.push(e.label),-1!==l.indexOf("text")){var w=u.castOption(s.hovertext||s.text,e.pts);w&&b.push(w)}-1!==l.indexOf("value")&&b.push(u.formatPieValue(e.v,y)),-1!==l.indexOf("percent")&&b.push(u.formatPiePercent(e.v/d.vTotal,y));var M=p.hoverlabel,k=M.font;o.loneHover({x0:m-c*d.r,x1:m+c*d.r,y:g,text:b.join("
"),name:-1!==l.indexOf("name")?s.name:void 0,idealAlign:e.pxmid[0]<0?"left":"right",color:u.castOption(M.bgcolor,e.pts)||e.color,borderColor:u.castOption(M.bordercolor,e.pts),fontFamily:u.castOption(k.family,e.pts),fontSize:u.castOption(k.size,e.pts),fontColor:u.castOption(k.color,e.pts)},{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:t}),x=!0}t.emit("plotly_hover",{points:[h(e,s)],event:a.event}),_=!0}}).on("mouseout",function(r){var n=t._fullLayout,i=t._fullData[p.index];_&&(r.originalEvent=a.event,t.emit("plotly_unhover",{points:[h(e,i)],event:a.event}),_=!1),x&&(o.loneUnhover(n._hoverlayer.node()),x=!1)}).on("click",function(){var r=t._fullLayout,n=t._fullData[p.index];t._dragging||!1===r.hovermode||(t._hoverdata=[h(e,n)],o.click(t,a.event))}),p.pull){var w=+u.castOption(p.pull,e.pts)||0;w>0&&(f+=w*e.pxmid[0],v+=w*e.pxmid[1])}e.cxFinal=f,e.cyFinal=v;var M=p.hole;if(e.v===d.vTotal){var k="M"+(f+e.px0[0])+","+(v+e.px0[1])+s(e.px0,e.pxmid,!0,1)+s(e.pxmid,e.px0,!0,1)+"Z";M?b.attr("d","M"+(f+M*e.px0[0])+","+(v+M*e.px0[1])+s(e.px0,e.pxmid,!1,M)+s(e.pxmid,e.px0,!1,M)+"Z"+k):b.attr("d",k)}else{var T=s(e.px0,e.px1,!0,1);if(M){var A=1-M;b.attr("d","M"+(f+M*e.px1[0])+","+(v+M*e.px1[1])+s(e.px1,e.px0,!1,M)+"l"+A*e.px0[0]+","+A*e.px0[1]+T+"Z")}else b.attr("d","M"+f+","+v+"l"+e.px0[0]+","+e.px0[1]+T+"Z")}var S=u.castOption(p.textposition,e.pts),E=y.selectAll("g.slicetext").data(e.text&&"none"!==S?[0]:[]);E.enter().append("g").classed("slicetext",!0),E.exit().remove(),E.each(function(){var r=a.select(this).selectAll("text").data([0]);r.enter().append("text").attr("data-notex",1),r.exit().remove(),r.text(e.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(l.font,"outside"===S?p.outsidetextfont:p.insidetextfont).call(c.convertToTspans,t);var o,s=l.bBox(r.node());"outside"===S?o=i(s,e):(o=function(t,e,r){var i=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=n(e,r),c={scale:l*r.r*2/i,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),h=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),f={scale:2*h/t.height,rCenter:Math.cos(h/r.r)-h*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),m=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),g={scale:2*m/t.width,rCenter:Math.cos(m/r.r)-m/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},v=g.scale>f.scale?g:f;return c.scale<1&&v.scale>c.scale?v:c}(s,e,d),"auto"===S&&o.scale<1&&(r.call(l.font,p.outsidetextfont),p.outsidetextfont.family===p.insidetextfont.family&&p.outsidetextfont.size===p.insidetextfont.size||(s=l.bBox(r.node())),o=i(s,e)));var u=f+e.pxmid[0]*o.rCenter+(o.x||0),h=v+e.pxmid[1]*o.rCenter+(o.y||0);o.outside&&(e.yLabelMin=h-s.height/2,e.yLabelMid=h,e.yLabelMax=h+s.height/2,e.labelExtraX=0,e.labelExtraY=0,g=!0),r.attr("transform","translate("+u+","+h+")"+(o.scale<1?"scale("+o.scale+")":"")+(o.rotate?"rotate("+o.rotate+")":"")+"translate("+-(s.left+s.right)/2+","+-(s.top+s.bottom)/2+")")})}}),g&&function(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,d=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),p=o?t.yLabelMin:t.yLabelMax,g=o?t.yLabelMax:t.yLabelMin,v=t.cyFinal+c(t.px0[1],t.px1[1]),y=d-p;if(y*f>0&&(t.labelExtraY=y),Array.isArray(e.pull))for(i=0;i=(u.castOption(e.pull,a.pts)||0)||((t.pxmid[1]-a.pxmid[1])*f>0?(y=a.cyFinal+c(a.px0[1],a.px1[1])-p-t.labelExtraY)*f>0&&(t.labelExtraY+=y):(g+t.labelExtraY-v)*f>0&&(n=3*h*Math.abs(i-m.indexOf(t)),(s=a.cxFinal+l(a.px0[0],a.px1[0])+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*h>0&&(t.labelExtraX+=s)))}var a,o,s,l,c,h,f,d,p,m,g,v,y;for(o=0;o<2;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;a<2;a++){for(l=a?Math.max:Math.min,h=a?1:-1,(d=t[o][a]).sort(s),p=t[1-o][a],m=p.concat(d),v=[],g=0;gMath.abs(c)?i+="l"+c*t.pxmid[0]/t.pxmid[1]+","+c+"H"+(n+t.labelExtraX+o):i+="l"+t.labelExtraX+","+l+"v"+(c-l)+"h"+o}else i+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(s.stroke,p.outsidetextfont.color).attr({"stroke-width":Math.min(2,p.outsidetextfont.size/8),d:i,fill:"none"})}})})}),setTimeout(function(){f.selectAll("tspan").each(function(){var t=a.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":613,"../../components/drawing":638,"../../components/fx":655,"../../lib/svg_text_utils":761,"./event_data":1033,"./helpers":1034,d3:123}],1039:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each(function(t){n.select(this).call(i,t,e)})})}},{"./style_one":1040,d3:123}],1040:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("./helpers").castOption;e.exports=function(t,e,r){var a=r.marker.line,o=i(a.color,e.pts)||n.defaultLine,s=i(a.width,e.pts)||0;t.style({"stroke-width":s}).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":613,"./helpers":1034}],1041:[function(t,e,r){"use strict";var n=t("../scattergl/attributes");e.exports={x:n.x,y:n.y,xy:{valType:"data_array",editType:"calc"},indices:{valType:"data_array",editType:"calc"},xbounds:{valType:"data_array",editType:"calc"},ybounds:{valType:"data_array",editType:"calc"},text:n.text,marker:{color:{valType:"color",arrayOk:!1,editType:"calc"},opacity:{valType:"number",min:0,max:1,dflt:1,arrayOk:!1,editType:"calc"},blend:{valType:"boolean",dflt:null,editType:"calc"},sizemin:{valType:"number",min:.1,max:2,dflt:.5,editType:"calc"},sizemax:{valType:"number",min:.1,dflt:20,editType:"calc"},border:{color:{valType:"color",arrayOk:!1,editType:"calc"},arearatio:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},editType:"calc"},editType:"calc"}}},{"../scattergl/attributes":1102}],1042:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.type="pointcloud",this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=new Int32Array(0),this.bounds=[0,0,0,0],this.pointcloudOptions={positions:new Float32Array(0),idToIndex:this.idToIndex,sizemin:.5,sizemax:12,color:[0,0,0,1],areaRatio:1,borderColor:[0,0,0,1]},this.pointcloud=i(t.glplot,this.pointcloudOptions),this.pointcloud._trace=this}var i=t("gl-pointcloud2d"),a=t("../../lib/str2rgbarray"),o=t("../scatter/get_trace_color"),s=["xaxis","yaxis"],l=n.prototype;l.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:this.pickXYData?[this.pickXYData[2*e],this.pickXYData[2*e+1]]:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:this.color,name:this.name,pointIndex:e,hoverinfo:this.hoverinfo}},l.update=function(t){this.index=t.index,this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-1/0,-1/0],this.updateFast(t),this.color=o(t,{})},l.updateFast=function(t){var e,r,n,i,o,s,l=this.xData=this.pickXData=t.x,c=this.yData=this.pickYData=t.y,u=this.pickXYData=t.xy,h=t.xbounds&&t.ybounds,f=t.indices,d=this.bounds;if(u){if(n=u,e=u.length>>>1,h)d[0]=t.xbounds[0],d[2]=t.xbounds[1],d[1]=t.ybounds[0],d[3]=t.ybounds[1];else for(s=0;sd[2]&&(d[2]=i),od[3]&&(d[3]=o);if(f)r=f;else for(r=new Int32Array(e),s=0;sd[2]&&(d[2]=i),od[3]&&(d[3]=o);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var p=a(t.marker.color),m=a(t.marker.border.color),g=t.opacity*t.marker.opacity;p[3]*=g,this.pointcloudOptions.color=p;var v=t.marker.blend;if(null===v){v=l.length<100||c.length<100}this.pointcloudOptions.blend=v,m[3]*=g,this.pointcloudOptions.borderColor=m;var y=t.marker.sizemin,b=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=y,this.pointcloudOptions.sizeMax=b,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions),this.expandAxesFast(d,b/2)},l.expandAxesFast=function(t,e){for(var r,n,i,a=e||.5,o=0;o<2;o++)(n=(r=this.scene[s[o]])._min)||(n=[]),n.push({val:t[o],pad:a}),(i=r._max)||(i=[]),i.push({val:t[o+2],pad:a})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new n(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":760,"../scatter/get_trace_color":1064,"gl-pointcloud2d":231}],1043:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}a("x"),a("y"),a("xbounds"),a("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),a("text"),a("marker.color",r),a("marker.opacity"),a("marker.blend"),a("marker.sizemin"),a("marker.sizemax"),a("marker.border.color",r),a("marker.border.arearatio")}},{"../../lib":738,"./attributes":1041}],1044:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../scatter3d/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="pointcloud",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl","gl2d","showLegend"],n.meta={},e.exports=n},{"../../plots/gl2d":823,"../scatter3d/calc":1080,"./attributes":1041,"./convert":1042,"./defaults":1043}],1045:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../../plots/attributes"),a=t("../../components/color/attributes"),o=t("../../components/fx/attributes"),s=t("../../lib/extend").extendFlat,l=t("../../plot_api/edit_types").overrideAll;e.exports=l({hoverinfo:s({},i.hoverinfo,{flags:["label","text","value","percent","name"]}),hoverlabel:o.hoverlabel,domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},orientation:{valType:"enumerated",values:["v","h"],dflt:"h"},valueformat:{valType:"string",dflt:".3s"},valuesuffix:{valType:"string",dflt:""},arrangement:{valType:"enumerated",values:["snap","perpendicular","freeform","fixed"],dflt:"snap"},textfont:n({}),node:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:.5,arrayOk:!0}},pad:{valType:"number",arrayOk:!1,min:0,dflt:20},thickness:{valType:"number",arrayOk:!1,min:1,dflt:20}},link:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}},source:{valType:"data_array",dflt:[]},target:{valType:"data_array",dflt:[]},value:{valType:"data_array",dflt:[]}}},"calc","nested")},{"../../components/color/attributes":612,"../../components/fx/attributes":647,"../../lib/extend":727,"../../plot_api/edit_types":769,"../../plots/attributes":783,"../../plots/font_attributes":810}],1046:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../components/fx/layout_attributes");r.name="sankey",r.baseLayoutAttrOverrides=n({hoverlabel:o.hoverlabel},"plot","nested"),r.plot=function(t){var e=i(t.calcdata,"sankey");a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("sankey"),a=e._has&&e._has("sankey");i&&!a&&n._paperdiv.selectAll(".sankey").remove()}},{"../../components/fx/layout_attributes":656,"../../plot_api/edit_types":769,"../../plots/get_data":820,"./plot":1051}],1047:[function(t,e,r){"use strict";var n=t("strongly-connected-components"),i=t("../../lib"),a=t("../../lib/gup").wrap;e.exports=function(t,e){return function(t,e,r){for(var i=t.map(function(){return[]}),a=0;a1})}(e.node.label,e.link.source,e.link.target)&&(i.error("Circularity is present in the Sankey data. Removing all nodes and links."),e.link.label=[],e.link.source=[],e.link.target=[],e.link.value=[],e.link.color=[],e.node.label=[],e.node.color=[]),a({link:e.link,node:e.node})}},{"../../lib":738,"../../lib/gup":735,"strongly-connected-components":537}],1048:[function(t,e,r){"use strict";e.exports={nodeTextOffsetHorizontal:4,nodeTextOffsetVertical:3,nodePadAcross:10,sankeyIterations:50,forceIterations:5,forceTicksPerFrame:10,duration:500,ease:"cubic-in-out",cn:{sankey:"sankey",sankeyLinks:"sankey-links",sankeyLink:"sankey-link",sankeyNodeSet:"sankey-node-set",sankeyNode:"sankey-node",nodeRect:"node-rect",nodeCapture:"node-capture",nodeCentered:"node-entered",nodeLabelGuide:"node-label-guide",nodeLabel:"node-label",nodeLabelTextPath:"node-label-text-path"}}},{}],1049:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../components/color/attributes").defaults,o=t("../../components/color"),s=t("tinycolor2");e.exports=function(t,e,r,l){function c(r,a){return n.coerce(t,e,i,r,a)}c("node.label"),c("node.pad"),c("node.thickness"),c("node.line.color"),c("node.line.width");c("node.color",e.node.label.map(function(t,e){return o.addOpacity(function(t){return a[t%a.length]}(e),.8)})),c("link.label"),c("link.source"),c("link.target"),c("link.value"),c("link.line.color"),c("link.line.width"),c("link.color",e.link.value.map(function(){return s(l.paper_bgcolor).getLuminance()<.333?"rgba(255, 255, 255, 0.6)":"rgba(0, 0, 0, 0.2)"})),c("domain.x"),c("domain.y"),c("orientation"),c("valueformat"),c("valuesuffix"),c("arrangement"),n.coerceFont(c,"textfont",n.extendFlat({},l.font));e.node.label.some(function(t,r){return-1===e.link.source.indexOf(r)&&-1===e.link.target.indexOf(r)})&&n.warn("Some of the nodes are neither sources nor targets, they will not be displayed.")}},{"../../components/color":613,"../../components/color/attributes":612,"../../lib":738,"./attributes":1045,tinycolor2:543}],1050:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("./calc"),n.plot=t("./plot"),n.moduleType="trace",n.name="sankey",n.basePlotModule=t("./base_plot"),n.categories=["noOpacity"],n.meta={},e.exports=n},{"./attributes":1045,"./base_plot":1046,"./calc":1047,"./defaults":1049,"./plot":1051}],1051:[function(t,e,r){"use strict";function n(t){return""!==t}function i(t,e){return t.filter(function(t){return t.key===e.traceId})}function a(t,e){p.select(t).select("path").style("fill-opacity",e),p.select(t).select("rect").style("fill-opacity",e)}function o(t){p.select(t).select("text.name").style("fill","black")}function s(t){return function(e){return-1!==t.node.sourceLinks.indexOf(e.link)||-1!==t.node.targetLinks.indexOf(e.link)}}function l(t){return function(e){return-1!==e.node.sourceLinks.indexOf(t.link)||-1!==e.node.targetLinks.indexOf(t.link)}}function c(t,e,r){e&&r&&i(r,e).selectAll("."+b.sankeyLink).filter(s(e)).call(h.bind(0,e,r,!1))}function u(t,e,r){e&&r&&i(r,e).selectAll("."+b.sankeyLink).filter(s(e)).call(f.bind(0,e,r,!1))}function h(t,e,r,n){var a=n.datum().link.label;n.style("fill-opacity",.4),a&&i(e,t).selectAll("."+b.sankeyLink).filter(function(t){return t.link.label===a}).style("fill-opacity",.4),r&&i(e,t).selectAll("."+b.sankeyNode).filter(l(t)).call(c)}function f(t,e,r,n){var a=n.datum().link.label;n.style("fill-opacity",function(t){return t.tinyColorAlpha}),a&&i(e,t).selectAll("."+b.sankeyLink).filter(function(t){return t.link.label===a}).style("fill-opacity",function(t){return t.tinyColorAlpha}),r&&i(e,t).selectAll(b.sankeyNode).filter(l(t)).call(u)}function d(t,e){var r=t.hoverlabel||{},n=y.nestedProperty(r,e).get();return!Array.isArray(n)&&n}var p=t("d3"),m=t("./render"),g=t("../../components/fx"),v=t("../../components/color"),y=t("../../lib"),b=t("./constants").cn,x=y._;e.exports=function(t,e){var r=t._fullLayout,i=r._paper,s=r._size,l=x(t,"source:")+" ",y=x(t,"target:")+" ",_=x(t,"incoming flow count:")+" ",w=x(t,"outgoing flow count:")+" ";m(i,e,{width:s.w,height:s.h,margin:{t:s.t,r:s.r,b:s.b,l:s.l}},{linkEvents:{hover:function(e,r,n){p.select(e).call(h.bind(0,r,n,!0)),t.emit("plotly_hover",{event:p.event,points:[r.link]})},follow:function(e,i){var s=i.link.trace,c=t._fullLayout._paperdiv.node().getBoundingClientRect(),u=e.getBoundingClientRect(),h=u.left+u.width/2,f=u.top+u.height/2,m=g.loneHover({x:h-c.left,y:f-c.top,name:p.format(i.valueFormat)(i.link.value)+i.valueSuffix,text:[i.link.label||"",l+i.link.source.label,y+i.link.target.label].filter(n).join("
"),color:d(s,"bgcolor")||v.addOpacity(i.tinyColorHue,1),borderColor:d(s,"bordercolor"),fontFamily:d(s,"font.family"),fontSize:d(s,"font.size"),fontColor:d(s,"font.color"),idealAlign:p.event.x"),color:d(s,"bgcolor")||i.tinyColorHue,borderColor:d(s,"bordercolor"),fontFamily:d(s,"font.family"),fontSize:d(s,"font.size"),fontColor:d(s,"font.color"),idealAlign:"left"},{container:r._hoverlayer.node(),outerContainer:r._paper.node(),gd:t});a(v,.85),o(v)},unhover:function(e,n,i){p.select(e).call(u,n,i),t.emit("plotly_unhover",{event:p.event,points:[n.node]}),g.loneUnhover(r._hoverlayer.node())},select:function(e,r,n){var i=r.node;i.originalEvent=p.event,t._hoverdata=[i],p.select(e).call(u,r,n),g.click(t,{target:!0})}}})}},{"../../components/color":613,"../../components/fx":655,"../../lib":738,"./constants":1048,"./render":1052,d3:123}],1052:[function(t,e,r){"use strict";function n(t){t.lastDraggedX=t.x,t.lastDraggedY=t.y}function i(t){return function(e){return e.node.originalX===t.node.originalX}}function a(t){for(var e=0;e1||t.linkLineWidth>0}function f(t){return"translate("+t.translateX+","+t.translateY+")"+(t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)")}function d(t){return"translate("+(t.horizontal?0:t.labelY)+" "+(t.horizontal?t.labelY:0)+")"}function p(t){return w.svg.line()([[t.horizontal?t.left?-t.sizeAcross:t.visibleWidth+_.nodeTextOffsetHorizontal:_.nodeTextOffsetHorizontal,0],[t.horizontal?t.left?-_.nodeTextOffsetHorizontal:t.sizeAcross:t.visibleHeight-_.nodeTextOffsetHorizontal,0]])}function m(t){return t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)"}function g(t){return t.horizontal?"scale(1 1)":"scale(-1 1)"}function v(t){return t.darkBackground&&!t.horizontal?"rgb(255,255,255)":"rgb(0,0,0)"}function y(t){return t.horizontal&&t.left?"100%":"0%"}function b(t,e,r){t.on(".basic",null).on("mouseover.basic",function(t){t.interactionState.dragInProgress||(r.hover(this,t,e),t.interactionState.hovered=[this,t])}).on("mousemove.basic",function(t){t.interactionState.dragInProgress||(r.follow(this,t),t.interactionState.hovered=[this,t])}).on("mouseout.basic",function(t){t.interactionState.dragInProgress||(r.unhover(this,t,e),t.interactionState.hovered=!1)}).on("click.basic",function(t){t.interactionState.hovered&&(r.unhover(this,t,e),t.interactionState.hovered=!1),t.interactionState.dragInProgress||r.select(this,t,e)})}function x(t,e,r){var a=w.behavior.drag().origin(function(t){return t.node}).on("dragstart",function(a){if("fixed"!==a.arrangement&&(E.raiseToTop(this),a.interactionState.dragInProgress=a.node,n(a.node),a.interactionState.hovered&&(r.nodeEvents.unhover.apply(0,a.interactionState.hovered),a.interactionState.hovered=!1),"snap"===a.arrangement)){var o=a.traceId+"|"+Math.floor(a.node.originalX);a.forceLayouts[o]?a.forceLayouts[o].alpha(1):function(t,e,r){var n=r.sankey.nodes().filter(function(t){return t.originalX===r.node.originalX});r.forceLayouts[e]=S.forceSimulation(n).alphaDecay(0).force("collide",S.forceCollide().radius(function(t){return t.dy/2+r.nodePad/2}).strength(1).iterations(_.forceIterations)).force("constrain",function(t,e,r,n){return function(){for(var t=0,i=0;i0&&n.forceLayouts[e].alpha(0)}}(0,e,n,r)).stop()}(0,o,a),function(t,e,r,n){window.requestAnimationFrame(function a(){for(var o=0;o<_.forceTicksPerFrame;o++)r.forceLayouts[n].tick();r.sankey.relayout(),c(t.filter(i(r)),e),r.forceLayouts[n].alpha()>0&&window.requestAnimationFrame(a)})}(t,e,a,o)}}).on("drag",function(r){if("fixed"!==r.arrangement){var a=w.event.x,o=w.event.y;"snap"===r.arrangement?(r.node.x=a,r.node.y=o):("freeform"===r.arrangement&&(r.node.x=a),r.node.y=Math.max(r.node.dy/2,Math.min(r.size-r.node.dy/2,o))),n(r.node),"snap"!==r.arrangement&&(r.sankey.relayout(),c(t.filter(i(r)),e))}}).on("dragend",function(t){t.interactionState.dragInProgress=!1});t.on(".drag",null).call(a)}var _=t("./constants"),w=t("d3"),M=t("tinycolor2"),k=t("../../components/color"),T=t("../../components/drawing"),A=t("@plotly/d3-sankey").sankey,S=t("d3-force"),E=t("../../lib"),L=t("../../lib/gup").keyFun,C=t("../../lib/gup").repeat,I=t("../../lib/gup").unwrap;e.exports=function(t,e,r,n){var i=t.selectAll("."+_.cn.sankey).data(e.filter(function(t){return I(t).trace.visible}).map(function(t,e,r){for(var n,i=I(e).trace,o=i.domain,s=i.node,l=i.link,c=i.arrangement,u="h"===i.orientation,h=i.node.pad,f=i.node.thickness,d=i.node.line.color,p=i.node.line.width,m=i.link.line.color,g=i.link.line.width,v=i.valueformat,y=i.valuesuffix,b=i.textfont,x=t.width*(o.x[1]-o.x[0]),w=t.height*(o.y[1]-o.y[0]),M=s.label.map(function(t,e){return{pointNumber:e,label:t,color:E.isArray(s.color)?s.color[e]:s.color}}),k=l.value.map(function(t,e){return{pointNumber:e,label:l.label[e],color:E.isArray(l.color)?l.color[e]:l.color,source:l.source[e],target:l.target[e],value:t}}),T=A().size(u?[x,w]:[w,x]).nodeWidth(f).nodePadding(h).nodes(M).links(k).layout(_.sankeyIterations),S=T.nodes(),L=0;L5?t.node.label:""}).attr("text-anchor",function(t){return t.horizontal&&t.left?"end":"start"}),R.transition().ease(_.ease).duration(_.duration).attr("startOffset",y).style("fill",v)}},{"../../components/color":613,"../../components/drawing":638,"../../lib":738,"../../lib/gup":735,"./constants":1048,"@plotly/d3-sankey":39,d3:123,"d3-force":119,tinycolor2:543}],1053:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;rg&&p.splice(g,p.length-g),m.length>g&&m.splice(g,m.length-g);var v={padded:!0},y={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,u=r.size,Array.isArray(u)){var b={type:"linear"};i.setConvert(b),(u=b.makeCalcdata(e.marker,"size")).length>g&&u.splice(g,u.length-g)}var x,_=1.6*(e.marker.sizeref||1);x="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/_),3)}:function(t){return Math.max((t||0)/_,3)},v.ppad=y.ppad=Array.isArray(u)?u.map(x):x(u)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||p[0]===p[g-1]&&m[0]===m[g-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(v.padded=!1,v.ppad=0):v.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||p[0]===p[g-1]&&m[0]===m[g-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(y.padded=!1):y.tozero=!0,i.expand(f,p,v),i.expand(d,m,y);var w=new Array(g);for(h=0;h=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],1058:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../components/colorscale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,l=r.marker,c="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+c).remove(),void 0!==l&&l.showscale){var u=l.color,h=l.cmin,f=l.cmax;n(h)||(h=i.aggNums(Math.min,null,u)),n(f)||(f=i.aggNums(Math.max,null,u));var d=e[0].t.cb=s(t,c),p=o.makeColorScaleFunc(o.extractScale(l.colorscale,h,f),{noNumericCheck:!0});d.fillcolor(p).filllevels({start:h,end:f,size:(f-h)/254}).options(l.colorbar)()}else a.autoMargin(t,c)}},{"../../components/colorbar/draw":617,"../../components/colorscale":628,"../../lib":738,"../../plots/plots":846,"fast-isnumeric":132}],1059:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){a.hasLines(t)&&n(t,"line")&&i(t,t.line.color,"line","c"),a.hasMarkers(t)&&(n(t,"marker")&&i(t,t.marker.color,"marker","c"),n(t,"marker.line")&&i(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":620,"../../components/colorscale/has_colorscale":627,"./subtypes":1076}],1060:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20,minTolerance:.2,toleranceGrowth:10,maxScreensAway:20}},{}],1061:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),h=t("./text_defaults"),f=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function m(r,a){return n.coerce(t,e,i,r,a)}var g=s(t,e,p,m),v=gH!=(O=I[L][1])>=H&&(P=(D=I[L-1][0])+(I[L][0]-D)*(H-z)/(O-z),N=Math.min(N,P),B=Math.max(B,P));N=Math.max(N,0),B=Math.min(B,d._length);var q=s.defaultLine;return s.opacity(f.fillcolor)?q=f.fillcolor:s.opacity((f.line||{}).color)&&(q=f.line.color),n.extendFlat(t,{distance:c+10,x0:N,x1:B,y0:H,y1:H,color:q}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":613,"../../components/errorbars":644,"../../components/fx":655,"../../lib":738,"./fill_hover_text":1062,"./get_trace_color":1064}],1066:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.cleanData=t("./clean_data"),n.calc=t("./calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./colorbar"),n.style=t("./style").style,n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.animatable=!0,n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/cartesian":796,"./arrays_to_calcdata":1053,"./attributes":1054,"./calc":1055,"./clean_data":1057,"./colorbar":1058,"./defaults":1061,"./hover":1065,"./plot":1073,"./select":1074,"./style":1075,"./subtypes":1076}],1067:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,a,o,s){var l=(t.marker||{}).color;if(o("line.color",r),n(t,"line"))i(t,e,a,o,{prefix:"line.",cLetter:"c"});else{o("line.color",!Array.isArray(l)&&l||r)}o("line.width"),(s||{}).noDash||o("line.dash")}},{"../../components/colorscale/defaults":623,"../../components/colorscale/has_colorscale":627}],1068:[function(t,e,r){"use strict";var n=t("../../constants/numerical").BADNUM,i=t("../../lib"),a=i.segmentsIntersect,o=i.constrain,s=t("./constants");e.exports=function(t,e){function r(e){var r=z.c2p(t[e].x),i=O.c2p(t[e].y);return r!==n&&i!==n&&[r,i]}function l(t){var e=t[0]/z._length,r=t[1]/O._length;return(1+s.toleranceGrowth*Math.max(0,-e,e-1,-r,r-1))*j}function c(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function u(t,e){for(var r=[],n=0,i=0;i<4;i++){var o=nt[i],s=a(t[0],t[1],e[0],e[1],o[0],o[1],o[2],o[3]);s&&(!n||Math.abs(s.x-r[0][0])>1||Math.abs(s.y-r[0][1])>1)&&(s=[s.x,s.y],n&&c(s,t)tt||t[1]rt)return[o(t[0],$,tt),o(t[1],et,rt)]}function f(t,e){return t[0]===e[0]&&(t[0]===$||t[0]===tt)||(t[1]===e[1]&&(t[1]===et||t[1]===rt)||void 0)}function d(t,e){var r=[],n=h(t),i=h(e);return n&&i&&f(n,i)?r:(n&&r.push(n),i&&r.push(i),r)}function p(t,e,r){return function(n,a){var o=h(n),s=h(a),l=[];if(o&&s&&f(o,s))return l;o&&l.push(o),s&&l.push(s);var c=2*i.constrain((n[t]+a[t])/2,e,r)-((o||n)[t]+(s||a)[t]);if(c){(o&&s?c>0==o[t]>s[t]?o:s:o||s)[t]+=c}return l}}function m(t){var e=t[0],r=t[1],n=e===H[q-1][0],i=r===H[q-1][1];if(!n||!i)if(q>1){var a=e===H[q-2][0],o=r===H[q-2][1];n&&(e===$||e===tt)&&a?o?q--:H[q-1]=t:i&&(r===et||r===rt)&&o?a?q--:H[q-1]=t:H[q++]=t}else H[q++]=t}function g(t){H[q-1][0]!==t[0]&&H[q-1][1]!==t[1]&&m([W,X]),m(t),Z=null,W=X=0}function v(t){if(G=t[0]<$?$:t[0]>tt?tt:0,Y=t[1]rt?rt:0,G||Y){if(q)if(Z){var e=K(Z,t);e.length>1&&(g(e[0]),H[q++]=e[1])}else J=K(H[q-1],t)[0],H[q++]=J;else H[q++]=[G||t[0],Y||t[1]];var r=H[q-1];G&&Y&&(r[0]!==G||r[1]!==Y)?(Z&&(W!==G&&X!==Y?m(W&&X?function(t,e){var r=e[0]-t[0],n=(e[1]-t[1])/r;return(t[1]*e[0]-e[1]*t[0])/r>0?[n>0?$:tt,rt]:[n>0?tt:$,et]}(Z,t):[W||G,X||Y]):W&&X&&m([W,X])),m([G,Y])):W-G&&X-Y&&m([G||W,Y||X]),Z=t,W=G,X=Y}else Z&&g(K(Z,t)[0]),H[q++]=t}var y,b,x,_,w,M,k,T,A,S,E,L,C,I,P,D,z=e.xaxis,O=e.yaxis,F=e.simplify,R=e.connectGaps,j=e.baseTolerance,N=e.shape,B="linear"===N,U=[],V=s.minTolerance,H=new Array(t.length),q=0;F||(j=V=-1);var G,Y,W,X,Z,J,K,Q=s.maxScreensAway,$=-z._length*Q,tt=z._length*(1+Q),et=-O._length*Q,rt=O._length*(1+Q),nt=[[$,et,tt,et],[tt,et,tt,rt],[tt,rt,$,rt],[$,rt,$,et]];for("linear"===N||"spline"===N?K=u:"hv"===N||"vh"===N?K=d:"hvh"===N?K=p(0,$,tt):"vhv"===N&&(K=p(1,et,rt)),y=0;yl(M))break;x=M,(C=A[0]*T[0]+A[1]*T[1])>E?(E=C,_=M,k=!1):C=t.length||!M)break;v(M),b=M}}else v(_)}Z&&m([W||Z[0],X||Z[1]]),U.push(H.slice(0,q))}return U}},{"../../constants/numerical":717,"../../lib":738,"./constants":1060}],1069:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],1070:[function(t,e,r){"use strict";e.exports=function(t,e,r){for(var n,i=null,a=0;a0?Math.max(e,i):0}}},{"fast-isnumeric":132}],1072:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,c){var u=o.isBubble(t),h=(t.line||{}).color;if(c=c||{},h&&(r=h),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),c.noLine||(l("marker.line.color",h&&!Array.isArray(h)&&e.marker.color!==h?h:u?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0)),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),c.gradient){"none"!==l("marker.gradient.type")&&l("marker.gradient.color")}}},{"../../components/color":613,"../../components/colorscale/defaults":623,"../../components/colorscale/has_colorscale":627,"./subtypes":1076}],1073:[function(t,e,r){"use strict";function n(t,e,r,n,u,f,d){function p(t){return _?t.transition():t}function m(t){return t.filter(function(t){return t.vis})}function g(t){return t.id}function v(){return!1}function y(e){var n,s=e[0].trace,c=i.select(this),u=l.hasMarkers(s),h=l.hasText(s),f=function(t){if(t.ids)return g}(s),d=v,y=v;u&&(d=s.marker.maxdisplayed||s._needsCull?m:a.identity),h&&(y=s.marker.maxdisplayed||s._needsCull?m:a.identity);var b=(n=c.selectAll("path.point").data(d,f)).enter().append("path").classed("point",!0);_&&b.call(o.pointStyle,s,t).call(o.translatePoints,w,M).style("opacity",0).transition().style("opacity",1);var x=u&&o.tryColorscale(s.marker,""),k=u&&o.tryColorscale(s.marker,"line");n.order(),n.each(function(e){var n=i.select(this),a=p(n);o.translatePoint(e,a,w,M)?(o.singlePointStyle(e,a,s,x,k,t),r.layerClipId&&o.hideOutsideRangePoint(e,a,w,M,s.xcalendar,s.ycalendar),s.customdata&&n.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()}),_?n.exit().transition().style("opacity",0).remove():n.exit().remove(),(n=c.selectAll("g").data(y,f)).enter().append("g").classed("textpoint",!0).append("text"),n.order(),n.each(function(t){var e=i.select(this),n=p(e.select("text"));o.translatePoint(t,n,w,M)?r.layerClipId&&o.hideOutsideRangePoint(t,e,w,M,s.xcalendar,s.ycalendar):e.remove()}),n.selectAll("text").call(o.textPointStyle,s,t).each(function(t){var e=w.c2p(t.x),r=M.c2p(t.y);i.select(this).selectAll("tspan.line").each(function(){p(i.select(this)).attr({x:e,y:r})})}),n.exit().remove()}var b,x;!function(t,e,r,n,o){var s=r.xaxis,c=r.yaxis,u=i.extent(a.simpleMap(s.range,s.r2c)),h=i.extent(a.simpleMap(c.range,c.r2c)),f=n[0].trace;if(!l.hasMarkers(f))return;var d=f.marker.maxdisplayed;if(0===d)return;var p=n.filter(function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=h[0]&&t.y<=h[1]}),m=Math.ceil(p.length/d),g=0;o.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0,w=r.xaxis,M=r.yaxis,k=n[0].trace,T=k.line,A=i.select(f);if(A.call(s.plot,r,d),!0===k.visible){p(A).style("opacity",k.opacity);var S,E,L=k.fill.charAt(k.fill.length-1);"x"!==L&&"y"!==L&&(L=""),n[0].node3=A;var C="",I=[],P=k._prevtrace;P&&(C=P._prevRevpath||"",E=P._nextFill,I=P._polygons);var D,z,O,F,R,j,N,B,U,V="",H="",q=[],G=a.noop;if(S=k._ownFill,l.hasLines(k)||"none"!==k.fill){for(E&&E.datum(n),-1!==["hv","vh","hvh","vhv"].indexOf(T.shape)?(O=o.steps(T.shape),F=o.steps(T.shape.split("").reverse().join(""))):O=F="spline"===T.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),T.smoothing):o.smoothopen(t,T.smoothing)}:function(t){return"M"+t.join("L")},R=function(t){return F(t.reverse())},q=c(n,{xaxis:w,yaxis:M,connectGaps:k.connectgaps,baseTolerance:Math.max(T.width||1,3)/4,shape:T.shape,simplify:T.simplify}),U=k._polygons=new Array(q.length),x=0;x1){var r=i.select(this);if(r.datum(n),t)p(r.style("opacity",0).attr("d",D).call(o.lineGroupStyle)).style("opacity",1);else{var a=p(r);a.attr("d",D),o.singleLineStyle(n,a)}}}}}var Y=A.selectAll(".js-line").data(q);p(Y.exit()).style("opacity",0).remove(),Y.each(G(!1)),Y.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(o.lineGroupStyle).each(G(!0)),o.setClipUrl(Y,r.layerClipId),q.length&&(S?j&&B&&(L?("y"===L?j[1]=B[1]=M.c2p(0,!0):"x"===L&&(j[0]=B[0]=w.c2p(0,!0)),p(S).attr("d","M"+B+"L"+j+"L"+V.substr(1)).call(o.singleFillStyle)):p(S).attr("d",V+"Z").call(o.singleFillStyle)):"tonext"===k.fill.substr(0,6)&&V&&C&&("tonext"===k.fill?p(E).attr("d",V+"Z"+C+"Z").call(o.singleFillStyle):p(E).attr("d",V+"L"+C.substr(1)+"Z").call(o.singleFillStyle),k._polygons=k._polygons.concat(I)),k._prevRevpath=H,k._prevPolygons=U);var W=A.selectAll(".points");b=W.data([n]),W.each(y),b.enter().append("g").classed("points",!0).each(y),b.exit().remove(),b.each(function(t){var e=!1===t[0].trace.cliponaxis;o.setClipUrl(i.select(this),e?null:r.layerClipId)})}}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./line_points"),u=t("./link_traces"),h=t("../../lib/polygon").tester;e.exports=function(t,e,r,a,s){var l,c,h,f,d=e.plot.select("g.scatterlayer"),p=!a,m=!!a&&a.duration>0;for((h=d.selectAll("g.trace").data(r,function(t){return t[0].trace.uid})).enter().append("g").attr("class",function(t){return"trace scatter trace"+t[0].trace.uid}).style("stroke-miterlimit",2),u(t,e,r),function(t,e,r){var n;e.selectAll("g.trace").each(function(t){var e=i.select(this);if((n=t[0].trace)._nexttrace){if(n._nextFill=e.select(".js-fill.js-tonext"),!n._nextFill.size()){var a=":first-child";e.select(".js-fill.js-tozero").size()&&(a+=" + *"),n._nextFill=e.insert("path",a).attr("class","js-fill js-tonext")}}else e.selectAll(".js-fill.js-tonext").remove(),n._nextFill=null;n.fill&&("tozero"===n.fill.substr(0,6)||"toself"===n.fill||"to"===n.fill.substr(0,2)&&!n._prevtrace)?(n._ownFill=e.select(".js-fill.js-tozero"),n._ownFill.size()||(n._ownFill=e.insert("path",":first-child").attr("class","js-fill js-tozero"))):(e.selectAll(".js-fill.js-tozero").remove(),n._ownFill=null),e.selectAll(".js-fill").call(o.setClipUrl,r.layerClipId)})}(0,d,e),l=0,c={};lc[e[0].trace.uid]?1:-1}),m){s&&(f=s());i.transition().duration(a.duration).ease(a.easing).each("end",function(){f&&f()}).each("interrupt",function(){f&&f()}).each(function(){d.selectAll("g.trace").each(function(i,o){n(t,o,e,i,r,this,a)})})}else d.selectAll("g.trace").each(function(i,o){n(t,o,e,i,r,this,a)});p&&h.exit().remove(),d.selectAll("path:not([d])").remove()}},{"../../components/drawing":638,"../../components/errorbars":644,"../../lib":738,"../../lib/polygon":750,"./line_points":1068,"./link_traces":1070,"./subtypes":1076,d3:123}],1074:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,c=t.yaxis,u=[],h=s[0].trace;if(!n.hasMarkers(h)&&!n.hasText(h))return[];if(!1===e)for(r=0;r=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}(e.textposition),r.textColor=g(e.textfont,1,S),r.textSize=o(e.textfont.size,S,p.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var P=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;n<3;++n){var D=e.projection[P[n]];(r.project[n]=D.show)&&(r.projectOpacity[n]=D.opacity,r.projectScale[n]=D.scale)}r.errorBounds=x(e,d);var z=function(t){for(var e=[0,0,0],r=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0],i=0;i<3;i++){var a=t[i];a&&!1!==a.copy_zstyle&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=m(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}([e.error_x,e.error_y,e.error_z]);return r.errorColor=z.color,r.errorLineWidth=z.lineWidth,r.errorCapSize=z.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=m(e.surfacecolor),r}function l(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}var c=t("gl-line3d"),u=t("gl-scatter3d"),h=t("gl-error3d"),f=t("gl-mesh3d"),d=t("delaunay-triangulate"),p=t("../../lib"),m=t("../../lib/str2rgbarray"),g=t("../../lib/gl_format_color"),v=t("../scatter/make_bubble_size_func"),y=t("../../constants/gl3d_dashes"),b=t("../../constants/gl3d_markers"),x=t("./calc_errors"),_=n.prototype;_.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels?void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel=this.textLabels:t.textLabel="";var e=t.index=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},_.update=function(t){var e,r,n,i,a=this.scene.glplot.gl,o=y.solid;this.data=t;var p=s(this.scene,t);"mode"in p&&(this.mode=p.mode),"lineDashes"in p&&p.lineDashes in y&&(o=y[p.lineDashes]),this.color=l(p.scatterColor)||l(p.lineColor),this.dataPoints=p.position,e={gl:a,position:p.position,color:p.lineColor,lineWidth:p.lineWidth||1,dashes:o[0],dashScale:o[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=c(e),this.linePlot._trace=this,this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var m=t.opacity;if(t.marker&&t.marker.opacity&&(m*=t.marker.opacity),r={gl:a,position:p.position,color:p.scatterColor,size:p.scatterSize,glyph:p.scatterMarker,opacity:m,orthographic:!0,lineWidth:p.scatterLineWidth,lineColor:p.scatterLineColor,project:p.project,projectScale:p.projectScale,projectOpacity:p.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=u(r),this.scatterPlot._trace=this,this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),i={gl:a,position:p.position,glyph:p.text,color:p.textColor,size:p.textSize,angle:p.textAngle,alignment:p.textOffset,font:p.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=t.hovertext||t.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(i):(this.textMarkers=u(i),this.textMarkers._trace=this,this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:a,position:p.position,color:p.errorColor,error:p.errorBounds,lineWidth:p.errorLineWidth,capSize:p.errorCapSize,opacity:t.opacity},this.errorBars?p.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):p.errorBounds&&(this.errorBars=h(n),this.errorBars._trace=this,this.scene.glplot.add(this.errorBars)),p.delaunayAxis>=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;n=0&&f("surfacecolor",d||p);for(var m=["x","y","z"],g=0;g<3;++g){var v="projection."+m[g];f(v+".show")&&(f(v+".opacity"),f(v+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../components/errorbars/defaults":643,"../../lib":738,"../../registry":861,"../scatter/line_defaults":1067,"../scatter/marker_defaults":1072,"../scatter/subtypes":1076,"../scatter/text_defaults":1077,"./attributes":1079}],1084:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl3d_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl3d_markers":715,"../../plots/gl3d":826,"../scatter/colorbar":1058,"./attributes":1079,"./calc":1080,"./convert":1082,"./defaults":1083}],1085:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/color_attributes"),o=t("../../components/colorbar/attributes"),s=t("../../lib/extend").extendFlat,l=n.marker,c=n.line,u=l.line;e.exports={carpet:{valType:"string",editType:"calc"},a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},mode:s({},n.mode,{dflt:"markers"}),text:s({},n.text,{}),line:{color:c.color,width:c.width,dash:c.dash,shape:s({},c.shape,{values:["linear","spline"]}),smoothing:c.smoothing,editType:"calc"},connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","toself","tonext"]}),fillcolor:n.fillcolor,marker:s({symbol:l.symbol,opacity:l.opacity,maxdisplayed:l.maxdisplayed,size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,line:s({width:u.width,editType:"calc"},a("marker".line)),gradient:l.gradient,editType:"calc"},a("marker"),{showscale:l.showscale,colorbar:o}),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:s({},i.hoverinfo,{flags:["a","b","text","name"]}),hoveron:n.hoveron}},{"../../components/colorbar/attributes":614,"../../components/colorscale/color_attributes":621,"../../lib/extend":727,"../../plots/attributes":783,"../scatter/attributes":1054}],1086:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../scatter/subtypes"),o=t("../scatter/colorscale_calc"),s=t("../scatter/arrays_to_calcdata"),l=t("../scatter/calc_selection"),c=t("../carpet/lookup_carpetid");e.exports=function(t,e){var r=e.carpetTrace=c(t,e);if(r&&r.visible&&"legendonly"!==r.visible){var u;e.xaxis=r.xaxis,e.yaxis=r.yaxis;var h,f,d=e.a.length,p=new Array(d),m=!1;for(u=0;ud&&b.splice(d,b.length-d)}return o(e),s(p,e),l(p,e),p}}},{"../../plots/cartesian/axes":785,"../carpet/lookup_carpetid":919,"../scatter/arrays_to_calcdata":1053,"../scatter/calc_selection":1056,"../scatter/colorscale_calc":1059,"../scatter/subtypes":1076,"fast-isnumeric":132}],1087:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),h=t("./attributes");e.exports=function(t,e,r,f){function d(r,i){return n.coerce(t,e,h,r,i)}d("carpet"),e.xaxis="x",e.yaxis="y";var p,m=d("a"),g=d("b");if(p=Math.min(m.length,g.length)){m&&p0?t.labelprefix.replace(/ = $/,""):t._hovertitle,g.push(r+": "+e.toFixed(3)+t.labelsuffix)}var o=n(t,e,r,i);if(o&&!1!==o[0].index){var s=o[0];if(void 0===s.index){var l=1-s.y0/t.ya._length,c=t.xa._length,u=c*l/2,h=c-u;return s.x0=Math.max(Math.min(s.x0,h),u),s.x1=Math.max(Math.min(s.x1,h),u),o}var f=s.cd[s.index];s.a=f.a,s.b=f.b,s.xLabelVal=void 0,s.yLabelVal=void 0;var d=s.trace,p=d._carpet,m=(f.hi||d.hoverinfo).split("+"),g=[];-1!==m.indexOf("all")&&(m=["a","b"]),-1!==m.indexOf("a")&&a(p.aaxis,f.a),-1!==m.indexOf("b")&&a(p.baxis,f.b);var v=p.ab2ij([f.a,f.b]),y=Math.floor(v[0]),b=v[0]-y,x=Math.floor(v[1]),_=v[1]-x,w=p.evalxy([],y,x,b,_);return g.push("y: "+w[1].toFixed(3)),s.extraText=g.join("
"),o}}},{"../scatter/hover":1065}],1090:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scattercarpet",n.basePlotModule=t("../../plots/cartesian"),n.categories=["carpet","symbols","markerColorscale","showLegend","carpetDependent"],n.meta={},e.exports=n},{"../../plots/cartesian":796,"../scatter/colorbar":1058,"../scatter/select":1074,"./attributes":1085,"./calc":1086,"./defaults":1087,"./event_data":1088,"./hover":1089,"./plot":1091,"./style":1092}],1091:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../plots/cartesian/axes"),a=t("../../components/drawing");e.exports=function(t,e,r){var o,s,l,c=r[0][0].carpet,u={xaxis:i.getFromId(t,c.xaxis||"x"),yaxis:i.getFromId(t,c.yaxis||"y"),plot:e.plot};for(n(t,u,r),o=0;o")}(u,g,d.mockAxis,c[0].t.labels),[t]}}},{"../../components/fx":655,"../../constants/numerical":717,"../../plots/cartesian/axes":785,"../scatter/fill_hover_text":1062,"../scatter/get_trace_color":1064,"./attributes":1093}],1098:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scattergeo",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","symbols","markerColorscale","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/geo":814,"../scatter/colorbar":1058,"./attributes":1093,"./calc":1094,"./defaults":1095,"./event_data":1096,"./hover":1097,"./plot":1099,"./select":1100,"./style":1101}],1099:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../constants/numerical").BADNUM,o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../lib/geo_location_utils").locationToFeature,l=t("../../lib/geojson_utils"),c=t("../scatter/subtypes"),u=t("./style");e.exports=function(t,e){function r(t,e){t.lonlat[0]===a&&n.select(e).remove()}for(var h=0;h=e.length?t(i):t(e[a]);return n}function o(t,e,r){return l(D(t,r),P(e,r),r)}function s(t,e,r,n){var i=w(t,e,n);return i=Array.isArray(i[0])?i:a(g.identity,[i],n),l(i,P(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;iZ?X-Z:0),!q||H.noBorder||H.noFill?u(this.scatter.options.colors,Y,f,B,G):u(this.scatter.options.colors,C,f,0),u(this.scatter.options.borderColors,W,f,B,G);N?(this.scatter.options.positions=null,this.fancyScatter.update(),this.scatter.options.positions=T):this.fancyScatter.update()}else this.fancyScatter.clear();this.scatter.clear(),this.expandAxesFancy(l,h,j)},I.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,s=this.yData;for(n=new Float64Array(2*a.length),r=0;r=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),f=e-h;if(n.getClosest(s,function(t){var e=t.lonlat;if(e[0]===o)return 1/0;var n=Math.abs(c.c2p(e)-c.c2p([f,e[1]])),i=Math.abs(u.c2p(e)-u.c2p([e[0],r])),a=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(n*n+i*i)-a,1-3/a)},t),!1!==t.index){var d=s[t.index],p=d.lonlat,m=[p[0]+h,p[1]],g=c.c2p(m),v=u.c2p(m),y=d.mrc||1;return t.x0=g-y,t.x1=g+y,t.y0=v-y,t.y1=v+y,t.color=i(l,d),t.extraText=function(t,e,r){function n(t){return t+"\xb0"}var i=(e.hi||t.hoverinfo).split("+"),o=-1!==i.indexOf("all"),s=-1!==i.indexOf("lon"),l=-1!==i.indexOf("lat"),c=e.lonlat,u=[];return o||s&&l?u.push("("+n(c[0])+", "+n(c[1])+")"):s?u.push(r.lon+n(c[0])):l&&u.push(r.lat+n(c[1])),(o||-1!==i.indexOf("text"))&&a(e,t,u),u.join("
")}(l,d,s[0].t.labels),[t]}}},{"../../components/fx":655,"../../constants/numerical":717,"../scatter/fill_hover_text":1062,"../scatter/get_trace_color":1064}],1113:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("../scattergeo/calc"),n.plot=t("./plot"),n.hoverPoints=t("./hover"),n.eventData=t("./event_data"),n.selectPoints=t("./select"),n.style=function(t,e){if(e){e[0].trace._glTrace.update(e)}},n.moduleType="trace",n.name="scattermapbox",n.basePlotModule=t("../../plots/mapbox"),n.categories=["mapbox","gl","symbols","markerColorscale","showLegend","scatterlike"],n.meta={},e.exports=n},{"../../plots/mapbox":840,"../scatter/colorbar":1058,"../scattergeo/calc":1094,"./attributes":1108,"./defaults":1110,"./event_data":1111,"./hover":1112,"./plot":1114,"./select":1115}],1114:[function(t,e,r){"use strict";function n(t,e){this.mapbox=t,this.map=t.map,this.uid=e,this.idSourceFill=e+"-source-fill",this.idSourceLine=e+"-source-line",this.idSourceCircle=e+"-source-circle",this.idSourceSymbol=e+"-source-symbol",this.idLayerFill=e+"-layer-fill",this.idLayerLine=e+"-layer-line",this.idLayerCircle=e+"-layer-circle",this.idLayerSymbol=e+"-layer-symbol",this.mapbox.initSource(this.idSourceFill),this.mapbox.initSource(this.idSourceLine),this.mapbox.initSource(this.idSourceCircle),this.mapbox.initSource(this.idSourceSymbol),this.map.addLayer({id:this.idLayerFill,source:this.idSourceFill,type:"fill"}),this.map.addLayer({id:this.idLayerLine,source:this.idSourceLine,type:"line"}),this.map.addLayer({id:this.idLayerCircle,source:this.idSourceCircle,type:"circle"}),this.map.addLayer({id:this.idLayerSymbol,source:this.idSourceSymbol,type:"symbol"})}function i(t){return"visible"===t.layout.visibility}var a=t("./convert"),o=n.prototype;o.update=function(t){var e=this.mapbox,r=a(t);e.setOptions(this.idLayerFill,"setLayoutProperty",r.fill.layout),e.setOptions(this.idLayerLine,"setLayoutProperty",r.line.layout),e.setOptions(this.idLayerCircle,"setLayoutProperty",r.circle.layout),e.setOptions(this.idLayerSymbol,"setLayoutProperty",r.symbol.layout),i(r.fill)&&(e.setSourceData(this.idSourceFill,r.fill.geojson),e.setOptions(this.idLayerFill,"setPaintProperty",r.fill.paint)),i(r.line)&&(e.setSourceData(this.idSourceLine,r.line.geojson),e.setOptions(this.idLayerLine,"setPaintProperty",r.line.paint)),i(r.circle)&&(e.setSourceData(this.idSourceCircle,r.circle.geojson),e.setOptions(this.idLayerCircle,"setPaintProperty",r.circle.paint)),i(r.symbol)&&(e.setSourceData(this.idSourceSymbol,r.symbol.geojson),e.setOptions(this.idLayerSymbol,"setPaintProperty",r.symbol.paint)),t[0].trace._glTrace=this},o.dispose=function(){var t=this.map;t.removeLayer(this.idLayerFill),t.removeLayer(this.idLayerLine),t.removeLayer(this.idLayerCircle),t.removeLayer(this.idLayerSymbol),t.removeSource(this.idSourceFill),t.removeSource(this.idSourceLine),t.removeSource(this.idSourceCircle),t.removeSource(this.idSourceSymbol)},e.exports=function(t,e){var r=new n(t,e[0].trace.uid);return r.update(e),r}},{"./convert":1109}],1115:[function(t,e,r){"use strict";var n=t("../scatter/subtypes");e.exports=function(t,e){var r,i,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,h=[],f=l[0].trace;if(!n.hasMarkers(f))return[];if(!1===e)for(s=0;sk&&S.splice(k,S.length-k)}return o(e),s(T,e),l(T,e),T}},{"../../plots/cartesian/axes":785,"../scatter/arrays_to_calcdata":1053,"../scatter/calc_selection":1056,"../scatter/colorscale_calc":1059,"../scatter/subtypes":1076,"fast-isnumeric":132}],1118:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),h=t("./attributes");e.exports=function(t,e,r,f){function d(r,i){return n.coerce(t,e,h,r,i)}var p,m=d("a"),g=d("b"),v=d("c");if(m?(p=m.length,g?(p=Math.min(p,g.length),v&&(p=Math.min(p,v.length))):p=v?Math.min(p,v.length):0):g&&v&&(p=Math.min(g.length,v.length)),p){m&&p"),s}}},{"../../plots/cartesian/axes":785,"../scatter/hover":1065}],1121:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("../scatter/select"),n.eventData=t("./event_data"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend","scatter-like"],n.meta={},e.exports=n},{"../../plots/ternary":854,"../scatter/colorbar":1058,"../scatter/select":1074,"./attributes":1116,"./calc":1117,"./defaults":1118,"./event_data":1119,"./hover":1120,"./plot":1122,"./style":1123}],1122:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){var r=t.plotContainer;r.select(".scatterlayer").selectAll("*").remove();for(var i={xaxis:t.xaxis,yaxis:t.yaxis,plot:r,layerClipId:t._hasClipOnAxisFalse?t.clipIdRelative:null},a=0;a",uplift:5,goldenRatio:1.618,columnTitleOffset:28,columnExtentOffset:10,transitionEase:"cubic-out",transitionDuration:100,releaseTransitionEase:"cubic-out",releaseTransitionDuration:120,scrollbarWidth:8,scrollbarCaptureWidth:18,scrollbarOffset:5,scrollbarHideDelay:1e3,scrollbarHideDuration:1e3,cn:{table:"table",tableControlView:"table-control-view",scrollBackground:"scroll-background",yColumn:"y-column",columnBlock:"column-block",scrollAreaClip:"scroll-area-clip",scrollAreaClipRect:"scroll-area-clip-rect",columnBoundary:"column-boundary",columnBoundaryClippath:"column-boundary-clippath",columnBoundaryRect:"column-boundary-rect",columnCells:"column-cells",columnCell:"column-cell",cellRect:"cell-rect",cellText:"cell-text",cellTextHolder:"cell-text-holder",scrollbarKit:"scrollbar-kit",scrollbar:"scrollbar",scrollbarSlider:"scrollbar-slider",scrollbarGlyph:"scrollbar-glyph",scrollbarCaptureZone:"scrollbar-capture-zone"}}},{}],1134:[function(t,e,r){"use strict";function n(t){return t.calcdata.columns.reduce(function(e,r){return r.xIndex=e||c===t.length-1)&&(n[i]=o,o.key=l++,o.firstRowIndex=s,o.lastRowIndex=c,o={firstRowIndex:null,lastRowIndex:null,rows:[]},i+=a,s=c+1,a=0);return n}var o=t("./constants"),s=t("../../lib/extend").extendFlat,l=t("fast-isnumeric");e.exports=function(t,e){var r=e.header.values.map(function(t){return Array.isArray(t)?t:[t]}),c=e.cells.values,u=e.domain,h=Math.floor(t._fullLayout._size.w*(u.x[1]-u.x[0])),f=Math.floor(t._fullLayout._size.h*(u.y[1]-u.y[0])),d=r.length?r[0].map(function(){return e.header.height}):[],p=c.length?c[0].map(function(){return e.cells.height}):[],m=d.reduce(function(t,e){return t+e},0),g=a(p,f-m+o.uplift),v=i(a(d,m),[]),y=i(g,v),b={},x=e._fullInput.columnorder,_=r.map(function(t,r){var n=Array.isArray(e.columnwidth)?e.columnwidth[Math.min(r,e.columnwidth.length-1)]:e.columnwidth;return l(n)?Number(n):1}),w=_.reduce(function(t,e){return t+e},0);_=_.map(function(t){return t/w*h});var M={key:e.index,translateX:u.x[0]*t._fullLayout._size.w,translateY:t._fullLayout._size.h*(1-u.y[1]),size:t._fullLayout._size,width:h,height:f,columnOrder:x,groupHeight:f,rowBlocks:y,headerRowBlocks:v,scrollY:0,cells:e.cells,headerCells:s({},e.header,{values:r}),gdColumns:r.map(function(t){return t[0]}),gdColumnsOriginalOrder:r.map(function(t){return t[0]}),prevPages:[0,0],scrollbarState:{scrollbarScrollInProgress:!1},columns:r.map(function(t,e){var r=b[t];b[t]=(r||0)+1;return{key:t+"__"+b[t],label:t,specIndex:e,xIndex:x[e],xScale:n,x:void 0,calcdata:void 0,columnWidth:_[e]}})};return M.columns.forEach(function(t){t.calcdata=M,t.x=n(t)}),M}},{"../../lib/extend":727,"./constants":1133,"fast-isnumeric":132}],1135:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat;r.splitToPanels=function(t){var e=[0,0],r=n({},t,{key:"header",type:"header",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!0,values:t.calcdata.headerCells.values[t.specIndex],rowBlocks:t.calcdata.headerRowBlocks,calcdata:n({},t.calcdata,{cells:t.calcdata.headerCells})});return[n({},t,{key:"cells1",type:"cells",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),n({},t,{key:"cells2",type:"cells",page:1,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),r]},r.splitToCells=function(t){var e=function(t){var e=t.rowBlocks[t.page],r=e?e.rows[0].rowIndex:0;return[r,e?r+e.rows.length:0]}(t);return t.values.slice(e[0],e[1]).map(function(r,n){return{keyWithinBlock:n+("string"==typeof r&&r.match(/[<$&> ]/)?"_keybuster_"+Math.random():""),key:e[0]+n,column:t,calcdata:t.calcdata,page:t.page,rowBlocks:t.rowBlocks,value:r}})}},{"../../lib/extend":727}],1136:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}o("domain.x"),o("domain.y"),o("columnwidth"),o("header.values"),o("header.format"),o("header.align"),o("header.prefix"),o("header.suffix"),o("header.height"),o("header.line.width"),o("header.line.color"),o("header.fill.color"),n.coerceFont(o,"header.font",n.extendFlat({},a.font)),function(t,e){for(var r=t.columnorder||[],n=t.header.values.length,i=r.slice(0,n),a=i.slice().sort(function(t,e){return t-e}),o=i.map(function(t){return a.indexOf(t)}),s=o.length;s/i),o=!i||a;t.mayHaveMarkup=i&&n.match(/[<&>]/);var s=function(t){return"string"==typeof t&&t.match(T.latexCheck)}(n);t.latex=s;var l,h=s?"":u(t.calcdata.cells.prefix,e,r)||"",f=s?"":u(t.calcdata.cells.suffix,e,r)||"",d=s?null:u(t.calcdata.cells.format,e,r)||null,p=h+(d?A.format(d)(t.value):t.value)+f;t.wrappingNeeded=!t.wrapped&&!o&&!s&&(l=c(p)),t.cellHeightMayIncrease=a||s||t.mayHaveMarkup||(void 0===l?c(p):l),t.needsConvertToTspans=t.mayHaveMarkup||t.wrappingNeeded||t.latex;var m;if(t.wrappingNeeded){var g=(" "===T.wrapSplitCharacter?p.replace(/i&&n.push(a),i+=l}return n}(i,u,c);1===h.length&&(h[0]===i.length-1?h.unshift(h[0]-1):h.push(h[0]+1)),h[0]%2&&h.reverse(),e.each(function(t,e){t.page=h[e],t.scrollY=u}),e.attr("transform",function(t){return"translate(0 "+(w(t.rowBlocks,t.page)-t.scrollY)+")"}),t&&(v(t,r,e,h,n.prevPages,n,0),v(t,r,e,h,n.prevPages,n,1),o(r,t))}}function g(t,e,r,n){return function(i){var a=i.calcdata?i.calcdata:i,o=e.filter(function(t){return a.key===t.key}),s=r||a.scrollbarState.dragMultiplier;a.scrollY=void 0===n?a.scrollY+s*A.event.dy:n;var l=o.selectAll("."+T.cn.yColumn).selectAll("."+T.cn.columnBlock).filter(f);m(t,l,o)}}function v(t,e,r,n,i,a,o){n[o]!==i[o]&&(clearTimeout(a.currentRepaint[o]),a.currentRepaint[o]=setTimeout(function(){var a=r.filter(function(t,e){return e===o&&n[e]!==i[e]});s(t,e,a,r),i[o]=n[o]}))}function y(t,e,r){return function(){var n=A.select(e.parentNode);n.each(function(t){var e=t.fragments;n.selectAll("tspan.line").each(function(t,r){e[r].width=this.getComputedTextLength()});var r,i,a=e[e.length-1].width,o=e.slice(0,-1),s=[],l=0,c=t.column.columnWidth-2*T.cellPad;for(t.value="";o.length;)l+(i=(r=o.shift()).width+a)>c&&(t.value+=s.join(T.wrapSpacer)+T.lineBreaker,s=[],l=0),s.push(r.text),l+=i;l&&(t.value+=s.join(T.wrapSpacer)),t.wrapped=!0}),n.selectAll("tspan.line").remove(),l(n.select("."+T.cn.cellText),r,t),A.select(e.parentNode.parentNode).call(_)}}function b(t,e,r,n,i){return function(){if(!i.settledY){var a=A.select(e.parentNode),s=k(i),l=i.key-s.firstRowIndex,c=s.rows[l].rowHeight,u=i.cellHeightMayIncrease?e.parentNode.getBoundingClientRect().height+2*T.cellPad:c,h=Math.max(u,c);h-s.rows[l].rowHeight&&(s.rows[l].rowHeight=h,t.selectAll("."+T.cn.columnCell).call(_),m(null,t.filter(f),0),o(r,n,!0)),a.attr("transform",function(){var t=this.parentNode.getBoundingClientRect(),e=A.select(this.parentNode).select("."+T.cn.cellRect).node().getBoundingClientRect(),r=this.transform.baseVal.consolidate(),n=e.top-t.top+(r?r.matrix.f:T.cellPad);return"translate("+x(i,A.select(this.parentNode).select("."+T.cn.cellTextHolder).node().getBoundingClientRect().width)+" "+n+")"}),i.settledY=!0}}}function x(t,e){switch(t.align){case"left":return T.cellPad;case"right":return t.column.columnWidth-(e||0)-T.cellPad;case"center":return(t.column.columnWidth-(e||0))/2;default:return T.cellPad}}function _(t){t.attr("transform",function(t){var e=t.rowBlocks[0].auxiliaryBlocks.reduce(function(t,e){return t+M(e,1/0)},0);return"translate(0 "+(M(k(t),t.key)+e)+")"}).selectAll("."+T.cn.cellRect).attr("height",function(t){return function(t,e){return t.rows[e-t.firstRowIndex]}(k(t),t.key).rowHeight})}function w(t,e){for(var r=0,n=e-1;n>=0;n--)r+=function(t){var e=t.allRowsHeight;if(void 0!==e)return e;for(var r=0,n=0;n0){var y,b,x,_,w,M=t.xa,k=t.ya;"h"===f.orientation?(w=e,y="y",x=k,b="x",_=M):(w=r,y="x",x=M,b="y",_=k);var T=h[t.index];if(w>=T.span[0]&&w<=T.span[1]){var A=n.extendFlat({},t),S=_.c2p(w,!0),E=o.getKdeValue(T,f,w),L=o.getPositionOnKdePath(T,f,S),C=x._offset,I=x._length;A[y+"0"]=L[0],A[y+"1"]=L[1],A[b+"0"]=A[b+"1"]=S,A[b+"Label"]=b+": "+i.hoverLabelText(_,w)+", "+h[0].t.labels.kde+" "+E.toFixed(3),g.push(A),(u={stroke:t.color})[y+"1"]=n.constrain(C+L[0],C,C+I),u[y+"2"]=n.constrain(C+L[1],C,C+I),u[b+"1"]=u[b+"2"]=_._offset+S}}}-1!==d.indexOf("points")&&(c=a.hoverOnPoints(t,e,r));var P=l.selectAll(".violinline-"+f.uid).data(u?[0]:[]);return P.enter().append("line").classed("violinline-"+f.uid,!0).attr("stroke-width",1.5),P.exit().remove(),P.attr(u),"closest"===s?c?[c]:g:c?(g.push(c),g):g}},{"../../lib":738,"../../plots/cartesian/axes":785,"../box/hover":887,"./helpers":1142}],1144:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),setPositions:t("./set_positions"),plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","symbols","oriented","box-violin","showLegend"],meta:{}}},{"../../plots/cartesian":796,"../box/select":892,"./attributes":1139,"./calc":1140,"./defaults":1141,"./hover":1143,"./layout_attributes":1145,"./layout_defaults":1146,"./plot":1147,"./set_positions":1148,"./style":1149}],1145:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),i=t("../../lib").extendFlat;e.exports={violinmode:i({},n.boxmode,{}),violingap:i({},n.boxgap,{}),violingroupgap:i({},n.boxgroupgap,{})}},{"../../lib":738,"../box/layout_attributes":889}],1146:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes"),a=t("../box/layout_defaults");e.exports=function(t,e,r){a._supply(t,e,r,function(r,a){return n.coerce(t,e,i,r,a)},"violin")}},{"../../lib":738,"../box/layout_defaults":890,"./layout_attributes":1145}],1147:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../box/plot"),s=t("../scatter/line_points"),l=t("./helpers");e.exports=function(t,e,r){function c(t){var e=s(t,{xaxis:h,yaxis:f,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0});return a.smoothopen(e[0],1)}var u=t._fullLayout,h=e.xaxis,f=e.yaxis;e.plot.select(".violinlayer").selectAll("g.trace.violins").data(r).enter().append("g").attr("class","trace violins").each(function(t){var r=t[0],a=r.t,s=r.trace,d=r.node3=n.select(this),p=u._numViolins,m="group"===u.violinmode&&p>1,g=a.bdPos=a.dPos*(1-u.violingap)*(1-u.violingroupgap)/(m?p:1),v=a.bPos=m?2*a.dPos*((a.num+.5)/p-.5)*(1-u.violingap):0;if(!0!==s.visible||a.empty)n.select(this).remove();else{var y=e[a.valLetter+"axis"],b=e[a.posLetter+"axis"],x="both"===s.side,_=x||"positive"===s.side,w=x||"negative"===s.side,M=s.box&&s.box.visible,k=s.meanline&&s.meanline.visible,T=u._violinScaleGroupStats[s.scalegroup];if(d.selectAll("path.violin").data(i.identity).enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin").each(function(t){var e,r=n.select(this),i=t.density,o=i.length,l=t.pos+v,u=b.c2p(l);switch(s.scalemode){case"width":e=T.maxWidth/g;break;case"count":e=T.maxWidth/g*(T.maxCount/t.pts.length)}var h,f,d,p,m,M,k;if(_){for(M=new Array(o),p=0;pi&&(i=c,a=l)}}return i?s(a):h};case"rms":return function(t,e){for(var r=0,i=0,a=0;a=",">","<="],l=["[]","()","[)","(]","][",")(","](",")["],c=["{}","}{"];r.moduleType="transform",r.name="filter",r.attributes={enabled:{valType:"boolean",dflt:!0,editType:"calc"},target:{valType:"string",strict:!0,noBlank:!0,arrayOk:!0,dflt:"x",editType:"calc"},operation:{valType:"enumerated",values:[].concat(s).concat(l).concat(c),dflt:"=",editType:"calc"},value:{valType:"any",dflt:0,editType:"calc"},preservegaps:{valType:"boolean",dflt:!1,editType:"calc"},editType:"calc"},r.supplyDefaults=function(t){function e(e,i){return n.coerce(t,a,r.attributes,e,i)}var a={};if(e("enabled")){e("preservegaps"),e("operation"),e("value"),e("target");var o=i.getComponentMethod("calendars","handleDefaults");o(t,a,"valuecalendar",null),o(t,a,"targetcalendar",null)}return a},r.calcTransform=function(t,e,r){function i(t,r){for(var i=0;i":return function(t){return f(t)>i};case">=":return function(t){return f(t)>=i};case"[]":return function(t){var e=f(t);return e>=i[0]&&e<=i[1]};case"()":return function(t){var e=f(t);return e>i[0]&&e=i[0]&&ei[0]&&e<=i[1]};case"][":return function(t){var e=f(t);return e<=i[0]||e>=i[1]};case")(":return function(t){var e=f(t);return ei[1]};case"](":return function(t){var e=f(t);return e<=i[0]||e>i[1]};case")[":return function(t){var e=f(t);return e=i[1]};case"{}":return function(t){return-1!==i.indexOf(f(t))};case"}{":return function(t){return-1===i.indexOf(f(t))}}}(r,a.getDataToCoordFunc(t,e,h,u),d),b={},x={},_=0;r.preservegaps?(g=function(t){b[t.astr]=n.extendDeep([],t.get()),t.set(new Array(f))},v=function(t,e){var r=b[t.astr][e];t.get()[e]=r}):(g=function(t){b[t.astr]=n.extendDeep([],t.get()),t.set([])},v=function(t,e){var r=b[t.astr][e];t.get().push(r)}),i(g);for(var w=o(e.transforms,r),M=0;M1?"%{group} (%{trace})":"%{group}");var l=t.styles,c=s.styles=[];if(l)for(o=0;o mem.pdf + +# cpu profiling +go build cpu.go +./cpu +go tool pprof -pdf ./cpu cpu.pprof > cpu.pdf +``` + +This will generate PDF document with visualized profile. + +- [Memory PDF profile example](/files/golang-profiling-mem.pdf) +- [CPU PDF profile example](/files/golang-profiling-cpu.pdf) diff --git a/content/2017-04-10-what-its-like-to-be-a-software-developer.md b/content/2017-04-10-what-its-like-to-be-a-software-developer.md new file mode 100644 index 0000000..2949931 --- /dev/null +++ b/content/2017-04-10-what-its-like-to-be-a-software-developer.md @@ -0,0 +1,33 @@ +--- +layout: post +title: What it's like to be a software developer +description: Couple of observations regarding project management +slug: what-its-like-to-be-a-software-developer +date: 2017-04-10 +--- + +I get asked a lot what the hell I actually do. I find it funny but I guess it is my fault in most cases. I try not to be the kind of a man that is always talking about his work. I live in a small village and most of my neighbours probably have no idea what I actually do. And I am ok with that. I prefer this. But on some occasions I find it disturbing how people judge other people just because they don't understand what they are all about. Many of them probably think I am some strange kind of a looser that is awake all the time and works from home. He probably plays games and type on a computer :) What kind of a job is that? That is no job at all! :) You work for eight hours, then you go home and drink a beer and go work in your workshop. This is what real men do! + +Well, you know. It's just the way it is. And it takes time for people to understand. Being home after many years in living elsewhere really grounded me in some cases. Coming back to the place where you grew up brings some sort of a humility back in your life. And this is ok. Nobody want's to be Icarus anyways. + +What I am meaning to say is if you are in a similar situation as me it will take time for people to start understanding you. Don't get discouraged by this. Take it as it is. People judge what they don't understand. + +I have this saying that sleeping is for pussies and we will sleep when we die. I am 32 years old now and I haven't slowed down regarding my work hours. I have steped up the pace. I usually work for about 16-18 hours a day every day. It doesn't matter if it's Monday or Saturday. Work needs to be done. + +I know that there are other ways. But if you want to be good there really is no other way. There are no shortcuts. There is no easier way to get to the point where you really know what the hell you are doing. Myth about this genius programmer truly is one huge bullshit. Without putting in the hours nothing can be achieved. There is no success without dedication. + +My friends and coworkers often ask me how the hell did I learn so much stuff. Where do I find the time to go through all this material. And I have a simple response for them: "When you go to sleep I begin reading and prototyping. When you go on a trip I make prototype projects just for the sake of learning. When you take your time for fucking around I read articles and books hunting that single small piece of information that will help me one day." And often they don't believe me. They think I am just that smart and everything is easy for me. They have this misguided belief that I just had all this knowledge implanted in me at birth. And this is not the case. I have read so much in my lifetime and most of this information was useful to me later in my life. But that didn't stop me even though I had no immediate use of it. This probably is the main difference between me and my friends. I don't learn because I need to but because I am piecing together this huge puzzle and I threat is like a game. This amazing game of enlightenment. + +I had many burn-downs in my career. Most of them come around new years. I guess around this time things slow down a bit and right then when you relax for a minute or two things get real :). They say when you enter your retirment you should never ever park your ass on a couch. You will die there :) When my burndown happens I fall into this huge depression and I start questioning my sanity. I question my decisions. I question my progress in life. I question everything. I try to understand if all this is worth it?! And every time this happens I struggle with this kind of questions. And by the time all this is over I come to the same conclusion every single time. Yes it fucking is worth it. And through the years I have noticed that this is some sort of a reset for me. This helps me maintain my sanity in the long run :) I love it when things get tough. It gets me to the next level. This teaches me progress is life. + +I don't even count anymore how many programming languages I have learned. I even stop noticing projects. They just fly by. It's like I am hunting this revelation that is set for me. And this drives me. This helps me every day to step up my game. Every single problem I solve I come little closer to my goal. My never reaching goal. And it's ok with me if I never reach this goal. + +The only problem I have now is time. There just ain't enough time to learn everything day has to offer. It's like I am on a quest to become this mini search machine :). + +This obsession with learning has come to the point where I stopped watching TV and news all together. I find this as noise that clutters your mind. The whole point about news is to frighten you and put your mind into a dangerous loop where you thinks that nothing matters anyways → world is going to shit. And the truth is so far away from this. We are living in this times where all this amazing possibilities are at hand. We just need to take control of our mindset and everything starts to look possible again. + +What else can say after more than 10 years in this space? What else can be said anyways? I still love what I do as much as I did 10 years ago. I love it even more. And if I would have a single suggestion for all of you is to stop worrying about immediate benefits and focus on the long run. Learn, prototype, experiment and have fun. We all get frustrated at times but that doesn't mean we should stop. Doing this kind of work is a privilege. We are making and creating. In the most pure sense we are creators. And there really is no better way to live your life. + +> A life without challenge, a life without hardship, a life without purpose, seems pale and pointless. With challenge come perseverance and gumption. With hardship come resilience and resolve. With purpose come strength and understanding. +> +> — Terry Fallis, The High Road diff --git a/content/2017-04-17-what-i-ve-learned-developing-ad-server.md b/content/2017-04-17-what-i-ve-learned-developing-ad-server.md new file mode 100644 index 0000000..77b396d --- /dev/null +++ b/content/2017-04-17-what-i-ve-learned-developing-ad-server.md @@ -0,0 +1,144 @@ +--- +layout: post +title: What I've learned developing ad server +description: Lessons I learned developing contextual ad server +slug: what-i-ve-learned-developing-ad-server +date: 2017-04-17 +--- + +**Table of contents** + +1. [Aggregate everything](#aggregate-everything) +2. [Measure everything](#measure-everything) +3. [Cache control is your friend](#cache-control-is-your-friend) +4. [Learn NGINX](#learn-nginx) +5. [Use Redis/Memcached](#use-redismemcached) +6. [Conclusion](#conclusion) + +For the past year and half I have been developing native advertising server that contextually matches ads and displays them in different template forms on variety of websites. This project grew from serving thousands of ads per day to millions. + +The system is made from couple of core components: + +- API for serving ads, +- Utils - cronjobs and queue management tools, +- Dashboard UI. + +Initial release was using [MongoDB](https://www.mongodb.com/) for full-text search but was later replaced by [Elasticsearch](https://www.elastic.co/) for better CPU utilization and better search performance. This provided us with many amazing functionalities of [Elasticsearch](https://www.elastic.co/). You should check it out if you do any search related operations. + +Because the premise of the server is to provide native ad experience, they are rendered on the client side via simple templating engine. This ensures that ads can be displayed number of different ways based on the visual style of the page. And this makes Javascript client library quite complex. + +So now that you know basic information about the product lets get into the lessons we learned. + +## Aggregate everything + +After beta version was released everything (impressions, clicks, etc) was written in nanosecond resolution in the database. At that time we were using [PostgreSQL](https://www.postgresql.org/) and database quickly grew way above 200GB in disk space. And that was problematic. Statistics took disturbingly long time to aggregate. Also using indexes on stats table in database was no help after we reached 500 million datapoints. + +> There is a marketing product information and there is real life experience. And the tend to be quite the opposite. + +This was the reason that now everything is aggregated on daily basis and this data is then fed to Elastic in form of daily summary. With this we achieved we can now track many more dimensions such as zone, channel and platform information. And with this information we can now adapt occurrences of ads on specific places more precisely. + +We have also adapted [Redis](https://redis.io/) as a full-time citizen in our stack. Because Redis also stores information on a local disk we have some sort of backup if server would accidentally suffer some failure. + +All the real-time statistics for ad serving and redirecting is presented as counters in Redis instance and daily extracted and pushed to Elastic. + +## Measure everything + +The thing about software is that we really don't know how well it is performing under load until such load is presented. When testing locally everything is fine but when on production things tend to fall apart. + +As a solution for this we are measuring everything we can. Function execution time (by encapsulating functions with timers), server performance (cpu, memory, disk, etc), Nginx and [uWSGI](https://uwsgi-docs.readthedocs.io/) performance. We sacrifice a bit of performance for the sake of this information. And we store all this information for later analysis. + +**Example of function execution time** + +```json +{ + "get_final_filtered_ads": { + "counter": 1931250, + "avg": 0.0066143431, + "elapsed": 12773.9500310003 + }, + "store_keywords_statistics": { + "counter": 1931011, + "avg": 0.0004605267, + "elapsed": 889.2821669996 + }, + "match_by_context": { + "counter": 1931011, + "avg": 0.0055960716, + "elapsed": 10806.0758889999 + }, + "match_by_high_performance": { + "counter": 262, + "avg": 0.0152770229, + "elapsed": 4.00258 + }, + "store_impression_stats": { + "counter": 1931250, + "avg": 0.0006189991, + "elapsed": 1195.4419869999 + } +} +``` + +We have also started profiling with [cProfile](https://pymotw.com/2/profile/) and then visualizing with [KCachegrind](http://kcachegrind.sourceforge.net/). This provides much more detailed look into code execution. + +## Cache control is your friend + +Because we use Javascript library for rendering ads we rely on this script extensively and when in need we need to be able to change behavior of the script quickly. + +In our case we can not simply replace javascript url in html code. It usually takes a day or two for the guys who maintain sites to change code or add ?ver=xxx attribute. And this makes rapid deployment and testing very difficult and time consuming. There is a limitation of how much you can test locally. + +We are now in the process of integrating [Google Tag Manager](https://www.google.com/analytics/tag-manager/) but couple of websites are developed on ASP.net platform that have some problems with tag manager. With a solution below we are certain that we are serving latest version of the script. + +And it only takes one mistake and users have the script cached and in case of caching it for 1 year you probably know where the problem is. + +```nginx +# nginx ➜ /etc/nginx/sites-available/default +location /static/ { + alias /path-to-static-content/; + autoindex off; + charset utf-8; + gzip on; + gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; + location ~* \.(ico|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ { + expires 1y; + add_header Pragma public; + add_header Cache-Control "public"; + } + location ~* \.(css|js|txt)$ { + expires 3600s; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate"; + } +} +``` + +Also be careful when redirecting to url in your python code. We noticed that if we didn't precisely setup cache control and expire headers in response we didn't get the request on the server and therefore couldn't measure clicks. So when redirecting do as follows and there will be no problems. + +```python +# python ➜ bottlepy web micro-framework +response = bottle.HTTPResponse(status=302) +response.set_header("Cache-Control", "no-store, no-cache, must-revalidate") +response.set_header("Expires", "Thu, 01 Jan 1970 00:00:00 GMT") +response.set_header("Location", url) +return response +``` + +> Cache control in browsers is quite aggressive and you need to be precise to avoid future problems. We learned that lesson the hard way. + +## Learn NGINX + +When deciding on a web server we went with Nginx as a reverse proxy for our applications. We adapted micro-service oriented architecture early in the project to ensure when we scale we can easily add additional servers to our cluster. And Nginx was crucial to perform load balancing and static content delivery. + +At first our config file was quite simple and later grew larger. After patching and adding new settings I sat down and learned more about the guts of Nginx. This proved to be very useful and we were able to squeeze much more out of our setup. So I advise you to take your time and read through the [documentation](https://nginx.org/en/docs/). This saved us a lot of headache. Googling for solutions only goes so far. + +## Use Redis/Memcached + +As explained above we are using caching basically for everything. It is the corner stone of our services. At first we were very careful about the quantity of things we stored in [Redis](https://redis.io/). But we later found out that the memory footprint is very low even when storing large amount of data in it. + +So we gradually increased our usage to caching whole HTML outputs of dashboard. This improved our performance in order of magnitude. And by using native TTL support this goes hand in hand with our needs. + +The reason why we choose [Redis](https://redis.io/) over [Memcached](https://memcached.org/) was the nature of scalability of Redis out of the box. But all this can be achieved with Memcached. + +## Conclusion + +There are a lot more details that could have been written and every single topic in here deserves it's own post but you probably got the idea about the problems we faced. diff --git a/content/2017-04-21-profiling-python-web-applications-with-visual-tools.md b/content/2017-04-21-profiling-python-web-applications-with-visual-tools.md new file mode 100644 index 0000000..9a31cab --- /dev/null +++ b/content/2017-04-21-profiling-python-web-applications-with-visual-tools.md @@ -0,0 +1,192 @@ +--- +layout: post +title: Profiling Python web applications with visual tools +description: Missing link when debugging and profiling python web applications +slug: profiling-python-web-applications-with-visual-tools +date: 2017-04-21 +--- + +**Table of contents** + +1. [Simple web-service](#simple-web-service) +2. [Visualize profile](#visualize-profile) +3. [Update 2017-04-22](#update-2017-04-22) + +I have been profiling my software with KCachegrind for a long time now and I was missing this option when I am developing API's or other web services. I always knew that this is possible but never really took the time and dive into it. + +Before we begin there are some requirements. We will need to: + +- implement [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) into our web app, +- convert output to [callgrind](http://valgrind.org/docs/manual/cl-manual.html) format with [pyprof2calltree](https://pypi.python.org/pypi/pyprof2calltree/), +- visualize data with [KCachegrind](http://kcachegrind.sourceforge.net/html/Home.html) or [Profiling Viewer](http://www.profilingviewer.com/). + + +If you are using MacOS you should check out [Profiling Viewer](http://www.profilingviewer.com/) or [MacCallGrind](http://www.maccallgrind.com/). + +![KCachegrind](/files/kcachegrind.png) + +We will be dividing this post into two main categories: + +- writing simple web-service, +- visualize profile of this web-service. + +## Simple web-service + +Let's use virtualenv so we won't pollute our base system. If you don't have virtualenv installed on your system you can install it with pip command. + +```bash +# let's install virtualenv globally +$ sudo pip install virtualenv + +# let's also install pyprof2calltree globally +$ sudo pip install pyprof2calltree + +# now we create project +$ mkdir demo-project +$ cd demo-project/ + +# now let's create folder where we will store profiles +$ mkdir prof + +# now we create empty virtualenv in venv/ folder +$ virtualenv --no-site-packages venv + +# we now need to activate virtualenv +$ source venv/bin/activate + +# you can check if virtualenv was correctly initialized by +# checking where your python interpreter is located +# if command bellow points to your created directory and not some +# system dir like /usr/bin/python then everything is fine +$ which python + +# we can check now if all is good ➜ if ok couple of +# lines will be displayed +$ pip freeze +# appdirs==1.4.3 +# packaging==16.8 +# pyparsing==2.2.0 +# six==1.10.0 + +# now we are ready to install bottlepy ➜ web micro-framework +$ pip install bottle + +# you can deactivate virtualenv but you will then go +# under system domain ➜ for now don't deactivate +$ deactivate +``` + +We are now ready to write simple web service. Let's create file app.py and paste code bellow in this newly created file. + +```python +# -*- coding: utf-8 -*- + +import bottle +import random +import cProfile + +app = bottle.Bottle() + +# this function is a decorator and encapsulates function +# and performs profiling and then saves it to subfolder +# prof/function-name.prof +# in our example only awesome_random_number function will +# be profiled because it has do_cprofile defined +def do_cprofile(func): + def profiled_func(*args, **kwargs): + profile = cProfile.Profile() + try: + profile.enable() + result = func(*args, **kwargs) + profile.disable() + return result + finally: + profile.dump_stats("prof/" + str(func.__name__) + ".prof") + return profiled_func + + +# we use profiling over specific function with including +# @do_cprofile above function declaration +@app.route("/") +@do_cprofile +def awesome_random_number(): + awesome_random_number = random.randint(0, 100) + return "awesome random number is " + str(awesome_random_number) + +@app.route("/test") +def test(): + return "dummy test" + +if __name__ == '__main__': + bottle.run( + app = app, + host = "0.0.0.0", + port = 4000 + ) + +# run with 'python app.py' +# open browser 'http://0.0.0.0:4000' +``` + +When browser hits awesome\_random\_number() function profile is created in prof/ subfolder. + +## Visualize profile + +Now let's create callgrind format from this cProfile output. + +```bash +$ cd prof/ +$ pyprof2calltree -i awesome_random_number.prof +# this creates 'awesome_random_number.prof.log' file in the same folder +``` + +This file can be opened with visualizing tools listed above. In this case we will be using Profilling Viewer under MacOS. You can open image in new tab. As you can see from this example there is hierarchy of execution order of your code. + +![Profilling Viewer](/files/profiling-viewer.png) + +> Make sure you convert output of the cProfile output every time you want to refresh and take a look at your possible optimizations because cProfile updates .prof file every time browser hits the function. + +This is just a simple example but when you are developing real-life applications this can be very illuminating, especially to see which parts of your code are bottlenecks and need to be optimized. + +## Update 2017-04-22 + +Reddit user [mvt](https://www.reddit.com/user/mvt) also recommended this awesome web based profile visualizer [SnakeViz](https://jiffyclub.github.io/snakeviz/) that directly takes output from [cProfile](https://docs.python.org/2/library/profile.html#module-cProfile) module. + + + +```bash +# let's install it globally as well +$ sudo pip install snakeviz + +# now let's visualize +$ cd prof/ +$ snakeviz awesome_random_number.prof +# this automatically opens browser window and +# shows visualized profile +``` + +![SnakeViz](/files/snakeviz.png) + +Reddit user [ccharles](https://www.reddit.com/user/ccharles) suggested a better way for installing pip software by targeting user level instead of using sudo. + + + +```bash +# now we need to add this path to our $PATH variable +# we do this my adding this line at the end of your +# ~/.bashrc file +PATH=$PATH:$HOME/.local/bin/ + +# in order to use this new configuration you can close +# and reopen terminal or reload .bashrc file +$ source ~/.bashrc + +# now let's test if new directory is present in $PATH +$ echo $PATH + +# now we can install on user level by adding --user +# without use of sudo +$ pip install snakeviz --user +``` + +Or as suggested by [mvt](https://www.reddit.com/user/mvt) you can use [pipsi](https://github.com/mitsuhiko/pipsi). diff --git a/content/2017-08-11-simple-iot.md b/content/2017-08-11-simple-iot.md new file mode 100644 index 0000000..17246ba --- /dev/null +++ b/content/2017-08-11-simple-iot.md @@ -0,0 +1,499 @@ +--- +layout: post +title: Simple IOT application supported by real-time monitoring and data history +description: Develop simple IOT application with Arduino MKR1000 and Python +slug: simple-iot-application +date: 2017-08-11 +--- + +**Table of contents** + +1. [Initial thoughts](#initial-thoughts) +2. [Simple Python API](#simple-python-api) + 1. [Basic web application](#basic-web-application) + 2. [Web application security](#web-application-security) + 3. [Simple API for writing data-points](#simple-api-for-writing-data-points) +3. [Sending data to API with Arduino MKR1000](#sending-data-to-api-with-arduino-mkr1000) +4. [Data visualization](#data-visualization) +5. [Conclusion](#conclusion) + +## Initial thoughts + +I have been developing these kind of application for the better part of my last 5 years and people keep asking me how to approach developing such application and I will give a try explaining it here. + +IOT applications are really no different than any other kind of applications. We have data that needs to be collected and visualized in some form of tables or charts. The main difference here is that most of the times these data is collected by some kind of device foreign to developer that mainly operates in web domain. But fear not, it's not that different than writing some JavaScript. + +There are many devices able to transmit data via wireless or wired network by default but for the sake of example we will be using commonly known Arduino with wireless module already on the board → [Arduino MKR1000](https://store.arduino.cc/arduino-mkr1000). + +In order to make this little project as accessible to others as possible I will try to make it as inexpensive as possible. And by this I mean that I will avoid using hosted virtual servers and will be using my own laptop as a server. But you must buy Arduino MKR1000 to follow steps below. But if you would want to deploy this software I would suggest using [DigitalOcean](https://www.digitalocean.com) → smallest VPS is only per month making this one of the most affordable option out there. Please notice that this software will not run on stock web hosting that only supports LAMP (Linux, Apache, MySQL, and PHP). + +_But before we begin please take notice that this is strictly experimental code and not well optimized and there are much better ways in handling some aspects of the application but that requires much deeper knowledge of technology that is not needed for an example like this._ + +**Development steps** + +1. Simple Python API that will receive and store incoming data. +2. Prototype C++ code that will read "sensor data" and transmit it to API. +3. Data visualization with charts → extends Python web application. + +Step 1. and 3. will share the same web application. One route will be dedicated to API and another to serving HTML with chart. + +Schema below represents what we will try to achieve and how different parts correlates to each other. + +![Overview](/files/simple-iot-application-overview.svg) + +## Simple Python API + +I have always been a fan of simplicity so we will be using [Bottle: Python Web Framework](https://bottlepy.org/docs/dev/). It is a single file web framework that seriously simplifies working with routes, templating and has built-in web server that satisfies our need in this case. + +First we need to install bottle package. This can be done by downloading ```bottle.py``` and placing it in the root of your application or by using pip software ```pip install bottle --user```. + +If you are using Linux or MacOS then Python is already installed. If you will try to test this on Windows please install [Python for Windows](https://www.python.org/downloads/windows/). There may be some problems with path when you will try to launch ```python webapp.py``` so please take care of this before you continue. + +### Basic web application + +Most basic bottle application is quite simple. Paste code below in ```webapp.py``` file and save. + +```python +# -*- coding: utf-8 -*- + +import bottle + +# initializing bottle app +app = bottle.Bottle() + +# triggered when / is accessed from browser +# only accepts GET → no POST allowed +@app.route("/", method=["GET"]) +def route_default(): + return "howdy from python" + +# starting server on http://0.0.0.0:5000 +if __name__ == "__main__": + bottle.run( + app = app, + host = "0.0.0.0", + port = 5000, + debug = True, + reloader = True, + catchall = True, + ) +``` + +To run this simple application you should open command prompt or terminal on your machine and go to the folder containing your file and type ```python webapp.py```. If everything goes ok then open your web browser and point it to ```http://0.0.0.0:5000```. + +If you would like change the port of your application (like port 80) and not use root to run your app this will present a problem. The TCP/IP port numbers below 1024 are privileged ports → this is a security feature. So in order of simplicity and security use a port number above 1024 like I have used port 5000. + +If this fails at any time please fix it before you continue, because nothing below will work otherwise. + +> We use 0.0.0.0 as default host so that this app is available over your local network. If you find your local ip ```ifconfig``` and try accessing this site with your phone (if on same network/router as your machine) this should work as well (example of such ip ```http://192.168.1.15:5000```). This is a must have because Arduino will be accessing this application to send it's data. + +### Web application security + +There is a lot to be said about security and is a topic of many books. Of course all this can not be written here but to just establish some basic security → you should always use SSL with your application. Some fantastic free certificates are available by [Let's Encrypt - Free SSL/TLS Certificates](https://letsencrypt.org). With SSL certificate installed you should then make use of HTTP headers and send your "API key" via a header. If your key is send via header then this key is encrypted by SSL and send encrypted over the network. Never send your api keys by GET parameter like ```http://example.com/?api_key=somekeyvalue```. The problem that this kind of sending presents is that this key is visible in logs and by network sniffers. + +There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. + +### Simple API for writing data-points + +We will now be using boilerplate code from example above and extend it to be able to write data received by API to local storage. For example use I will use SQLite3 because it plays well with Python and can store quite large amount of data. I have been using it to collect gigabytes of data in a single database without any corruption or problems → your experience may vary. + +To avoid learning SQLite I will be using [Dataset: databases for lazy people](https://dataset.readthedocs.io/en/latest/index.html). This package abstracts SQL and simplifies writing and reading data from database. You should install this package with pip software ```pip install dataset --user```. + +Because API will use POST method I will be testing if code works correctly by using [Restlet Client for Google Chrome](https://chrome.google.com/webstore/detail/restlet-client-rest-api-t/aejoelaoggembcahagimdiliamlcdmfm). This software also allows you to set headers → for basic security with API_KEY. + +To quickly generate passwords or API keys I usually use this nifty website [RandomKeygen](https://randomkeygen.com/). + +Copy and paste code below over your previous code in file ```webapp.py```. + +```python +# -*- coding: utf-8 -*- + +import time +import bottle +import random +import dataset + +# initializing bottle app +app = bottle.Bottle() + +# connects to sqlite database +# check_same_thread=False allows using it in multi-threaded mode +app.config["dsn"] = dataset.connect("sqlite:///data.db?check_same_thread=False") + +# api key that will be used in Arduino code +app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH" + +# triggered when /api is accessed from browser +# only accepts POST → no GET allowed +@app.route("/api", method=["POST"]) +def route_default(): + status = 400 + ts = int(time.time()) # current timestamp + value = bottle.request.body.read() # data from device + api_key = bottle.request.get_header("Api_Key") # api key from header + + # outputs to console received data for debug reason + print ">>> {} :: {}".format(value, api_key) + + # if api_key is correct and value is present + # then writes attribute to point table + if api_key == app.config["api_key"] and value: + app.config["dsn"]["point"].insert(dict(ts=ts, value=value)) + status = 200 + + # we only need to return status + return bottle.HTTPResponse(status=status, body="") + +# starting server on http://0.0.0.0:5000 +if __name__ == "__main__": + bottle.run( + app = app, + host = "0.0.0.0", + port = 5000, + debug = True, + reloader = True, + catchall = True, + ) +``` + +To run this simply go to folder containing python file and run ```python webapp.py``` from terminal. If everything goes ok you should have simple API available via POST method on /api route. + +After testing the service with Restlet Client you should be able to view your data in a database file ```data.db```. + +![REST settings example](/files/iot-rest-example.png) + +You can also check the contents of new database file by using desktop client for SQLite → [DB Browser for SQLite](http://sqlitebrowser.org/). + +![SQLite database example](/files/iot-sqlite-db.png) + +Table structure is as simple as it can be. We have ts (timestamp) and value (value from Arduino). As you can see timestamp is generated on API side. If you would happen to have atomic clock on Arduino it would be then better to generate and send timestamp with the value. This would be particularity useful if we would be collecting sensor data at a higher frequency and then sending this data in bulk to API. + +> If you will deploy this app with uWSGI and multi-threaded, use DSN (Data Source Name) url with ```?check_same_thread=False```. + +Ok, now that we have some sort of a working API with some basic security so unwanted people can not post data to your database can we proceed further and try to program Arduino to send data to API. + +## Sending data to API with Arduino MKR1000 + +First of all you should have MKR1000 module and microUSB cable to proceed. If you have ever done any work with Arduino you should know that you also need [Arduino IDE](https://www.arduino.cc/en/Main/Software). On provided link you should be able to download and install IDE. Once that task is completed and you have successfully run blink example you should proceed to the next step. + +In order to use wireless capabilities of MKR1000 you need to first install [WiFi101 library](https://www.arduino.cc/en/Reference/WiFi101) in Arduino IDE. Please check before you install, you may already have it installed. + +Code below is a working example that sends data to API. Before you try to test your code make sure you have run Python web application. Then change settings for wifi, api endpoint and api_key. If by some reason code bellow doesn't work for you please leave a comment and I'll try to help. + +Once you have opened IDE and copied this code try to compile and upload it. Then open "Serial monitor" to see if any output is presented by Arduino. + +```c +#include + +// wifi settings +char ssid[] = "ssid-name"; +char pass[] = "ssid-password"; + +// api server enpoint +char server[] = "192.168.6.22"; +int port = 5000; + +// api key that must be the same as the one in Python code +String api_key = "JtF2aUE5SGHfVJBCG5SH"; + +// frequency data is sent in ms - every 5 seconds +int timeout = 1000 * 5; + +int status = WL_IDLE_STATUS; + +void setup() { + + // initialize serial and wait for port to open: + Serial.begin(9600); + delay(1000); + + // check for the presence of the shield + if (WiFi.status() == WL_NO_SHIELD) { + Serial.println("WiFi shield not present"); + while (true); + } + + // attempt to connect to wifi network + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + status = WiFi.begin(ssid, pass); + // wait 10 seconds for connection + delay(10000); + } + + // output wifi status to serial monitor + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} + +void loop() { + + WiFiClient client; + + if (client.connect(server, port)) { + + // I use random number generator for this example + // but you can use analog or digital inputs from arduino + String content = String(random(1000)); + + client.println("POST /api HTTP/1.1"); + client.println("Connection: close"); + client.println("Api-Key: " + api_key); + client.println("Content-Length: " + String(content.length())); + client.println(); + client.println(content); + + delay(100); + client.stop(); + Serial.println("Data sent successfully ..."); + + } else { + Serial.println("Problem sending data ..."); + } + + // waits for x seconds and continue looping + delay(timeout); + +} +``` + +As seen from example you can notice that Arduino is generating random integer between [ 0 .. 1000 ]. You can easily replace this with a temperature sensor or any other kind of sensor. + +Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. + +## Data visualization + +Before we continue we should examine our project folder structure. Currently we only have two files in our project: + +_simple-iot-app/_ + +* _webapp.py_ +* _data.db_ + +We will now add HTML template that will contain CSS and JavaScript code inline for the simplicity reason. And for the bottle framework to be able to scan root application folder for templates we will add ```bottle.TEMPLATE_PATH.insert(0, "./")``` in ```webapp.py```. By default bottle framework uses ```views/``` subfolder to store templates. This is not the ideal situation and if you will use bottle to develop web applications you should use native behavior and store templates in it's predefined folder. But for the sake of example we will over-ride this. Be careful to fully replace your code with new code that is provided below. Avoid partially replacing code in file :) Also new code for reading data-points is provided in Python example below. + +First we add new route to our web application. It should be trigger when browser hits root of application ```http://0.0.0.0:5000/```. This route will do nothing more than render ```frontend.html``` template. This is done by ```return bottle.template("frontend.html")```. Check code below to further examine how exactly this is done. + +Now we will expand ```/api``` route and use different methods to write or read data-points. For writing data-point we will use POST method and for reading points we will use GET method. GET method will return JSON object with latest readings and historical data. + +There is a fantastic JavaScript library for plotting time-series charts called [MetricsGraphics.js](https://www.metricsgraphicsjs.org) that is based on [D3.js](https://d3js.org/) library for visualizing data. + +Data schema required by MetricsGraphics.js → to achieve this we need to transform data from database into this format: + +```json +[ + { + "date": "2017-08-11 01:07:20", + "value": 933 + }, + { + "date": "2017-08-11 01:07:30", + "value": 743 + } +] +``` + +Web application is now complete and we only need ```frontend.html``` that we will develop now. If you would try to start web app now and go to root app this will return error because we don't have frontend.html yet. + +```python +# -*- coding: utf-8 -*- + +import time +import bottle +import json +import datetime +import random +import dataset + +# initializing bottle app +app = bottle.Bottle() + +# adds root directory as template folder +bottle.TEMPLATE_PATH.insert(0, "./") + +# connects to sqlite database +# check_same_thread=False allows using it in multi-threaded mode +app.config["db"] = dataset.connect("sqlite:///data.db?check_same_thread=False") + +# api key that will be used in Arduino code +app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH" + +# triggered when / is accessed from browser +# only accepts GET → no POST allowed +@app.route("/", method=["GET"]) +def route_default(): + return bottle.template("frontend.html") + +# triggered when /api is accessed from browser +# accepts POST and GET +@app.route("/api", method=["GET", "POST"]) +def route_default(): + + # if method is POST then we write datapoint + if bottle.request.method == "POST": + status = 400 + ts = int(time.time()) # current timestamp + value = bottle.request.body.read() # data from device + api_key = bottle.request.get_header("Api-Key") # api key from header + + # outputs to console recieved data for debug reason + print ">>> {} :: {}".format(value, api_key) + + # if api_key is correct and value is present + # then writes attribute to point table + if api_key == app.config["api_key"] and value: + app.config["db"]["point"].insert(dict(ts=ts, value=value)) + status = 200 + + # we only need to return status + return bottle.HTTPResponse(status=status, body="") + + # if method is GET then we read datapoint + else: + response = [] + datapoints = app.config["db"]["point"].all() + + for point in datapoints: + response.append({ + "date": datetime.datetime.fromtimestamp(int(point["ts"])).strftime("%Y-%m-%d %H:%M:%S"), + "value": point["value"] + }) + + bottle.response.content_type = "application/json" + return json.dumps(response) + +# starting server on http://0.0.0.0:5000 +if __name__ == "__main__": + bottle.run( + app = app, + host = "0.0.0.0", + port = 5000, + debug = True, + reloader = True, + catchall = True, + ) +``` + +And now finally we can implement ```frontend.html```. Create file with this name and copy code below. When you are done you can start web application. Steps for this part are listed below the code. + +```html + + + + + + Simple IOT application + + + + +

Simple IOT application

+ +
+
+
+ + + + + + + + + + + + + +``` + +Now the folder structure should look like: + +_simple-iot-app/_ + +* _webapp.py_ +* _data.db_ +* _frontend.html_ + +Ok, lets now start application and start feeding it data. + +1. ```python webapp.py``` +2. connect Arduino MKR1000 to power source +3. open browser and go to ```http://0.0.0.0:5000``` + +If everything goes well you should be seeing new data-points rendered on chart every 5 seconds. + +If you navigate to ```http://0.0.0.0:5000``` you should see rendered chart as shown on picture below. + +![Application output](/files/iot-app-output.png) + +Complete application with all the code is available for [download](/files/simple-iot-application.zip). + +## Conclusion + +I hope this clarifies some aspects of IOT application development. Of course this is a minimal example and is far from what can be done in real life with some further dive into other technologies. + +If you would like to continue exploring IOT world here are some interesting resources for you to examine: + +* [Reading Sensors with an Arduino](https://www.allaboutcircuits.com/projects/reading-sensors-with-an-arduino/) +* [MQTT 101 – How to Get Started with the lightweight IoT Protocol](http://www.hivemq.com/blog/how-to-get-started-with-mqtt) +* [Stream Updates with Server-Sent Events](https://www.html5rocks.com/en/tutorials/eventsource/basics/) +* [Internet of Things (IoT) Tutorials](http://www.tutorialspoint.com/internet_of_things/) + +Any comment or additional ideas are welcomed in comments below.) diff --git a/content/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md b/content/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md new file mode 100644 index 0000000..6a9fbe5 --- /dev/null +++ b/content/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md @@ -0,0 +1,271 @@ +--- +layout: post +title: Using DigitalOcean Spaces Object Storage with FUSE +description: Using DigitalOcean Spaces Object Storage with FUSE +slug: using-digitalocean-spaces-object-storage-with-fuse +date: 2018-01-16 +--- + +**Table of contents** + +1. [Is it possible to use them as a mounted drive with FUSE?](#is-it-possible-to-use-them-as-a-mounted-drive-with-fuse) +2. [Will the performance degrade over time and over different sizes of objects?](#will-the-performance-degrade-over-time-and-over-different-sizes-of-objects) + 1. [Measurement experiment 1: File copy](#measurement-experiment-1-file-copy) + 2. [Measurement experiment 2: SQLite performanse](#measurement-experiment-2-sqlite-performanse) +3. [Can storage be mounted on multiple machines at the same time and be writable?](#can-storage-be-mounted-on-multiple-machines-at-the-same-time-and-be-writable) +4. [Observations and conslusion](#observations-and-conslusion) + +Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) which is Object Storage very similar to Amazon's S3. This really peaked my interest, because this was something I was missing and even the thought of going over the internet for such functionality was in no interest to me. Also in fashion with their previous pricing this also is very cheap and pricing page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). You must love them for that :) + +### Initial requirements + +* Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) +* Will the performance degrade over time and over different sizes of objects? (tl;dr NO&YES) +* Can storage be mounted on multiple machines at the same time and be writable? (tl;dr YES) + +> Let me be clear. This scripts I use are made just for benchmarking and are not intended to be used in real-life situations. Besides that, I am looking into using this approaches but adding caching service in front of it and then dumping everything as an object to storage. This could potentially be some interesting post of itself. But in case you would need real-time data without eventual consistency please take this scripts as they are: not usable in such situations. + +## Is it possible to use them as a mounted drive with FUSE? + +Well, actually they can be used in such manor. Because they are similar to [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). + +To make this work you will need DigitalOcean account. If you don't have one you will not be able to test this code. But if you have an account then you go and [create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). If you click on this link you will already have preselected Debian 9 with smallest VM option. + +* Please be sure to add you SSH key, because we will login to this machine remotely. +* If you change your region please remember which one you choose because we will need this information when we try to mount space to our machine. + +Instuctions on how to use SSH keys and how to setup them are available in article [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). + +![DigitalOcean Droplets](/files/fuse-droplets.png) + +After we created Droplet it's time to create new Space. This is done by clicking on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we will use it in examples below. You can either choose Private or Public, it doesn't matter in our case. And you can always change that in the future. + +When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). This link will guide to the page when you can generate this key. After you create new one, please save provided Key and Secret because Secret will not be shown again. + +![DigitalOcean Spaces](/files/fuse-spaces.png) + +Now that we have new Space and Access key we should SSH into our machine. + +```bash +# replace IP with the ip of your newly created droplet +ssh root@IP + +# this will install utilities for mounting storage objects as FUSE +apt install s3fs + +# we now need to provide credentials (access key we created earlier) +# replace KEY and SECRET with your own credentials but leave the colon between them +# we also need to set proper permissions +echo "KEY:SECRET" > .passwd-s3fs +chmod 600 .passwd-s3fs + +# now we mount space to our machine +# replace UNIQUE-NAME with the name you choose earlier +# if you choose different region for your space be careful about -ourl option (ams3) +s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tmp + +# now we try to create a file +# once you mount it may take a couple of seconds to retrieve data +echo "Hello cruel world" > /mnt/hello.txt +``` + +After all this you can return to your browser and go to [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your created space. If file hello.txt is present you have successfully mounted space to your machine and wrote data to it. + +I choose the same region for my Droplet and my Space but you don't have to. You can have different regions. What this actually does to performance I don't know. + +Additional information on FUSE: + +* [Github project page for s3fs](https://github.com/s3fs-fuse/s3fs-fuse) +* [FUSE - Filesystem in Userspace](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) + +## Will the performance degrade over time and over different sizes of objects? + +For this task I didn't want to just read and write text files or uploading images. I actually wanted to figure out if using something like SQlite is viable in this case. + +### Measurement experiment 1: File copy + +```bash +# first we create some dummy files at different sizes +dd if=/dev/zero of=10KB.dat bs=1024 count=10 #10KB +dd if=/dev/zero of=100KB.dat bs=1024 count=100 #100KB +dd if=/dev/zero of=1MB.dat bs=1024 count=1024 #1MB +dd if=/dev/zero of=10MB.dat bs=1024 count=10240 #10MB + +# now we set time command to only return real +TIMEFORMAT=%R + +# now lets test it +(time cp 10KB.dat /mnt/) |& tee -a 10KB.results.txt + +# and now we automate +# this will perform the same operation 100 times +# this will output results into separated files based on objecty size +n=0; while (( n++ < 100 )); do (time cp 10KB.dat /mnt/10KB.$n.dat) |& tee -a 10KB.results.txt; done +n=0; while (( n++ < 100 )); do (time cp 100KB.dat /mnt/100KB.$n.dat) |& tee -a 100KB.results.txt; done +n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.results.txt; done +n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done +``` + +Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). + +As I suspected, object size is not really that important. Sadly I don't have the time to test performance over periods of time. But if some of you would do it please send me your data. I would be interested in seeing results. + +**Here are plotted results** + +You can download [raw result here](/files/copy-benchmarks.tsv). Measurements are in seconds. + + +
+ + +As far as these tests show, performance is quite stable and can be predicted which is fantastic. But this is a small test and spans only over couple of hours. So you should not completely trust them. + +### Measurement experiment 2: SQLite performanse + +I was unable to use database file directly from mounted drive so this is a no-go as I suspected. So I executed code below on a local disk just to get some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can see performance of SQLite is quite amazing. You could then potentially just copy file to mounted drive and be done with it. + +```python +import time +import sqlite3 +import sys + +if len(sys.argv) < 3: + print("usage: python sqlite-benchmark.py DB_PATH NUM_RECORDS REPEAT") + exit() + +def data_iter(x): + for i in range(x): + yield "m" + str(i), "f" + str(i*i) + +header_line = "%s\t%s\t%s\t%s\t%s\n" % ("DROPTABLE", "CREATETABLE", "INSERTMANY", "FETCHALL", "COMMIT") +with open("sqlite-benchmarks.tsv", "w") as fp: + fp.write(header_line) + +start_time = time.time() +conn = sqlite3.connect(sys.argv[1]) +c = conn.cursor() +end_time = time.time() +result_time = CONNECT = end_time - start_time +print("CONNECT: %g seconds" % (result_time)) + +start_time = time.time() +c.execute("PRAGMA journal_mode=WAL") +c.execute("PRAGMA temp_store=MEMORY") +c.execute("PRAGMA synchronous=OFF") +result_time = PRAGMA = end_time - start_time +print("PRAGMA: %g seconds" % (result_time)) + +for i in range(int(sys.argv[3])): + print("#%i" % (i)) + + start_time = time.time() + c.execute("drop table if exists test") + end_time = time.time() + result_time = DROPTABLE = end_time - start_time + print("DROPTABLE: %g seconds" % (result_time)) + + start_time = time.time() + c.execute("create table if not exists test(a,b)") + end_time = time.time() + result_time = CREATETABLE = end_time - start_time + print("CREATETABLE: %g seconds" % (result_time)) + + start_time = time.time() + c.executemany("INSERT INTO test VALUES (?, ?)", data_iter(int(sys.argv[2]))) + end_time = time.time() + result_time = INSERTMANY = end_time - start_time + print("INSERTMANY: %g seconds" % (result_time)) + + start_time = time.time() + c.execute("select count(*) from test") + res = c.fetchall() + end_time = time.time() + result_time = FETCHALL = end_time - start_time + print("FETCHALL: %g seconds" % (result_time)) + + start_time = time.time() + conn.commit() + end_time = time.time() + result_time = COMMIT = end_time - start_time + print("COMMIT: %g seconds" % (result_time)) + + print + log_line = "%f\t%f\t%f\t%f\t%f\n" % (DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT) + with open("sqlite-benchmarks.tsv", "a") as fp: + fp.write(log_line) + +start_time = time.time() +conn.close() +end_time = time.time() +result_time = CLOSE = end_time - start_time +print("CLOSE: %g seconds" % (result_time)) +``` + +You can download [raw result here](/files/sqlite-benchmarks.tsv). And again, these results are done on a local block storage and do not represent capabilities of object storage. With my current approach and state of the test code these can not be done. I would need to make Python code much more robust and check locking etc. + +
+ + +## Can storage be mounted on multiple machines at the same time and be writable? + +Well, this one didn't take long to test. And the answer is **YES**. I mounted space on both machines and measured same performance on both machines. But because file is downloaded before write and then uploaded on complete there could potentially be problems is another process is trying to access the same file. + +## Observations and conslusion + +Using Spaces in this way makes it easier to access and manage files. But besides that you would need to write additional code to make this one play nice with you applications. + +Nevertheless, this was extremely simple to setup and use and this is just another excellent product in DigitalOcean product line. I found this exercise very valuable and am thinking about implementing some sort of mechanism for SQLite, so data can be stored on Spaces and accessed by many VM's. For a project where data doesn't need to be accessible in real-time and can have couple of minutes old data this would be very interesting. If any of you find this proposal interesting please write in a comment box below or shoot me an email and I will keep you posted. diff --git a/content/2018-08-05-the-bullshit-web-developments-pov.md b/content/2018-08-05-the-bullshit-web-developments-pov.md new file mode 100644 index 0000000..46dfc19 --- /dev/null +++ b/content/2018-08-05-the-bullshit-web-developments-pov.md @@ -0,0 +1,93 @@ +--- +layout: post +title: The Bullshit Web - Development's Point of View +description: State of front-end development and what this does to the future of web +slug: the-bullshit-web-developments-pov +date: 2018-08-05 +--- + +**Table of contents** + +1. [Initial thoughts](#initial-thoughts) +2. [Front-end frameworks](#front-end-frameworks) +3. [Obsolescence to the rescue](#obsolescence-to-the-rescue) +4. [Unnecessary complexity](#unnecessary-complexity) +5. [Speed of development trumps code quality](#speed-of-development-trumps-code-quality) +6. [Load times of most popular websites](#load-times-of-most-popular-websites) + +## Initial thoughts + +I have recently read an amazing essay by Nick Heer on the web called [The Bullshit Web](https://pxlnv.com/blog/bullshit-web/) and it got me thinking about the future of the web as it is today. + +> The average internet connection in the United States is about six times as fast as it was just ten years ago, but instead of making it faster to browse the same types of websites, we’re simply occupying that extra bandwidth with more stuff. +> +> **-- Nick Heer** + +I really try to stray away from frond-end development as much as possible. The reason is nowhere close to me having any bad opinions but having to work with clients on visual stuff drains me to the point of sheer horror. + +I have observed silently the progress that was made in this field because I thought things will get better with time. I was so wrong. So wrong. Not only that things got extremely complicated to work with, the whole stack became so massive even simple pages have insanely large footprint. + +The Bullshit Web essay concentrates mostly on page sizes and AMP but I would like to address tooling and technologies for development in this post. + +Currently we have two types of websites: + +- informational websites, +- web applications. + +The problem that occurs is that more and more websites are treathed as web application where simple web page would suffice. And this in my opinion adds insult to the injury. + +We talk about progressive web applications, AMP, and other technologies that are solving the problems of bandwidth, usability and in general making web faster but in reality this rarely gets applied in real life scenarios. Most of the time this are just demos on conferences. + +## Front-end frameworks + +I am not of those purists that denies usage of JavaScript frameworks or SASS but there are limits to where this obsession should go. In order to use these technologies properly one should ask himself where exactly they are needed and not use them like hammer for nails. + +Whenever I need to do front-end UI I usually check specification before embarking on journey of coding. And most of the times I really don't need frameworks. Most of the code I need to write in JavaScript is done in couple of hundred lines of code and does exactly what specification requires. And developer that will be working on this code after me doesn't need to learn new framework, tooling, etc. Just pure vanilla JavaScript. In all of my years as a developer I can count on fingers on my one hand when I used some sort of a framework. And even in this exceptions we later rewrote code to vanilla JavaScript because maintaining complex code was just to time consuming. + +There is an argument to be made for using frameworks in cases where multiple people are working a project and code must be easily transferable and on-boarding process must be swift. But in reality this is just another bullshit excuse to stick with what is "cool". I stand by Function over Form. And this also conflicts with the notion that frameworks never change. Frameworks evolve and adapt to market needs and most of the times get massive and hard to maintain. And we get stuck with massive codebase that is developed with many hacks and workarounds, because framework didn't support some feature at the time of development. I personally hate workarounds and being a smart-ass that intentionally makes code harder to read. I find frameworks similar to the story about Cain and Abel. Either you get murdered or framework gets. Most of the times framework dies and leaves legacy nobody would want. + +Huge strives have been made to address this problem and many fantastic frameworks emerged and some of theme are absolutely amazing. But there needs to be a strong case for using them in a project. We should never blindly use them regardless of the problem we are trying to solve. + +I must admit that tooling around front-end is getting better and better and we are slowly getting there but there still is a long road ahead. + +## Obsolescence to the rescue + +We can all agree that frameworks or libraries usually are there to fill the gap what currently is widely supported by the standard. Most of this so called frameworks are just libraries that unifies browser compatibility. The prime example of this is jQuery. There was a time almost everybody was using jQuery. But through time HTML5 specs were updated to include ideas from jQuery and this filled the browser compatibility gap. There is this awesome article [The Rise and Fall of jQuery](https://www.evolutionjobs.com/uk/media/the-rise-and-fall-of-jquery-117981/). + +Don't get me wrong. Yes, I dislike jQuery but I find it indispensable and without it our web would be very different. For the worst in my opinion. It was a huge stepping stone for front-end development. But there comes a time where technologies get obsolete and standards catch up with the requirements of the field. + +And because libraries and frameworks have short lifespan I try to stay away from them and if possible use vanilla code. There is a wonderfull article about [The Brutal Lifecycle of JavaScript Frameworks](https://stackoverflow.blog/2018/01/11/brutal-lifecycle-javascript-frameworks/) that explains how quick they popup and become obsolete. + +> JavaScript UI frameworks and libraries work in cycles. Every six months or so, a new one pops up, claiming that it has revolutionized UI development. Thousands of developers adopt it into their new projects, blog posts are written, Stack Overflow questions are asked and answered, and then a newer (and even more revolutionary) framework pops up to usurp the throne. +> +> **-- Ian Allen** + +## Unnecessary complexity + +Libraries have a tendency to speed up development which is ok but there are a huge drawbacks in the future. Most of the times we work on simple projects. Not everybody is working on Facebook, Google or that kind of mamuth apps and by using libraries provided to us by these companies we introduce complexity these companies need in order to make their apps. And usually these libraries include edge case functionalities that only apply to them and by providing simpler way to use libraries very complex approaches get implemented. + +Another reason for me to not use frameworks and libraries is that there usually is a team behind a project and by working on a feature by your own it takes too much time to read through the documentation and properly understand what the reasoning was behind a feature in a library. Most of the stuff (dashboarding, tables, widgets) that I work on are done much faster by pure using JS. Codebase footprint is smaller and doesn't require other developers to learn a completly new framework. + +This freameworks are heavily opinionated. No question about it. And by using them you accept their dogma. And by doing so you put yourself in a wierd position when new "disruptive" framework comes to life. If we think about it these frameworks should rather be called "approaches". + +> *Just to be completely honest* +> +> There are use-cases for such frameworks. And there are situations where they are indispensable. I am not saying that they don't make sense. All I am saying that in my line of work I noticed that not every project is fit for a framework and it's better to not use them in such cases. + +An awesome talk about [Learning from JavaScript Libraries by Trevor Landau](https://www.youtube.com/watch?v=u2PgPWj8KrM). + +## Speed of development trumps code quality + +I have found out that most of these frameworks or libraries have become very difficult to undestand in a matter of hours. In the past this was diifferent somehow. You could learn jQuery in a matter of hours and use it the next day like you were a pro. I know that it's not fair to compare framework and library but for our case this is acceptable. + +Every developer should have the knowledge and experience when selecting or not selection framework. I always stay true to [Occam's razor](https://en.wikipedia.org/wiki/Occam%27s_razor). And when prototyping I always use as barebone setup as I can. I see no problem with completly dumping a block of code and replacing it with something more complex if this makes sense. But there needs to be a huge reason behind this decision. + +Workarounds are one of the nessesary evils perticulary when dealing with frameworks. Either because the lack of time of just plain reason that framework doesn't support something. And this is the my main problem with them. In real life we don't have the time to properly implement ideas behind a framework. And when shit hits the fan we butcher up the code and mix different ideas just to catch a deadline. And this is in contadiction with the whole idea of using a framework. + +The impact that this has on quality and readability of code is massive. And threating this just as a symptom is probably the worst thing you can do. Through time these hacked-up code becomes legacy and additional code is molded to the code that already is in the codebase. And by doing this our code becomes more and more foregin of the initial concept. + +Code quality and readability should come first regardless of frameworks and libraries. Code should be as close to bare-metal as possible so when frameworks change our code is still usable and can be refreshed by any developer with the basic knowledge of desired programming language. + +## Load times of most popular websites + +All this directly impacts performanse. Terabytes of bandwidth wasted because there was a decision made early in the development cycle. Laggy performance, slow loading, bad experience just because development team was not cautious enough. diff --git a/content/2019-01-03-encoding-binary-data-into-dna-sequence.md b/content/2019-01-03-encoding-binary-data-into-dna-sequence.md new file mode 100644 index 0000000..6d7e6b7 --- /dev/null +++ b/content/2019-01-03-encoding-binary-data-into-dna-sequence.md @@ -0,0 +1,415 @@ +--- +layout: post +title: Encoding binary data into DNA sequence +description: Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. +slug: encoding-binary-data-into-dna-sequence +date: 2019-01-03 +--- + +**Table of contents** + +1. [Initial thoughts](#initial-thoughts) +2. [Glossary](#glossary) +3. [Data encoding](#data-encoding) +4. [Quick history of DNA](#quick-history-of-dna) +5. [What is DNA?](#what-is-dna) +6. [Encode binary data into DNA sequence](#encode-binary-data-into-dna-sequence) + 1. [Basic Encoding](#basic-encoding) + 2. [FASTA file format](#fasta-file-format) + 3. [PNG encoded DNA sequence](#png-encoded-dna-sequence) +7. [Encoding text file in practice](#encoding-text-file-in-practice) +8. [Toolkit for encoding data](#toolkit-for-encoding-data) + 1. [dnae-encode](#dnae-encode) + 2. [dnae-png](#dnae-png) +9. [Benchmarks](#benchmarks) +10. [References](#references) + +## Initial thoughts + +Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. Well, this is all possible now. It was not done on a large scale because it is quite expensive to create DNA strands but it's possible. + +Encoding data into DNA sequence is relatively simple process once you understand the relationship between binary data and nucleotides and scientists have been making large leaps in this field in order to provide viable long-term storage solution for our data that would potentially survive our specie if case of global disaster. We could imprint all the world's knowledge into plants and ensure the survival of our knowledge. + +More optimistic usage for this technology would be easier storage of ever growing data we produce every day. Once machines for sequencing DNA become fast enough and cheaper this could mean the next evolution of storing data and abandoning classical hard and solid state drives in data warehouses. + +As we currently stand this is still not viable but it is quite an amazing and cool technology. + +My interests in this field are purely in encoding processes and experimental testing mainly because I don't have the access to this expensive machines. My initial goal was to create a toolkit that can be used by everybody to encode their data into a proper DNA sequence. + +## Glossary + +**deoxyribose** +: A five-carbon sugar molecule with a hydrogen atom rather than a hydroxyl group in the 2′ position; the sugar component of DNA nucleotides. + +**double helix** +: The molecular shape of DNA in which two strands of nucleotides wind around each other in a spiral shape. + +**nitrogenous base** +: A nitrogen-containing molecule that acts as a base; often referring to one of the purine or pyrimidine components of nucleic acids. + +**phosphate group** +: A molecular group consisting of a central phosphorus atom bound to four oxygen atoms. + +**RGB** +: The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. + +**GCC** +: The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. + +## Data encoding + +**TL;DR:** Encoding involves the use of a code to change original data into a form that can be used by an external process [^1]. + +Encoding is the process of converting data into a format required for a number of information processing needs, including: + +- Program compiling and execution +- Data transmission, storage and compression/decompression +- Application data processing, such as file conversion + +Encoding can have two meanings[^1]: + +- In computer technology, encoding is the process of applying a specific code, such as letters, symbols and numbers, to data for conversion into an equivalent cipher. +- In electronics, encoding refers to analog to digital conversion. + +## Quick history of DNA + +- **1869** - Friedrich Miescher identifies "nuclein". +- **1900s** - The Eugenics Movement. +- **1900** – Mendel's theories are rediscovered by researchers. +- **1944** - Oswald Avery identifies DNA as the 'transforming principle'. +- **1952** - Rosalind Franklin photographs crystallized DNA fibres. +- **1953** - James Watson and Francis Crick discover the double helix structure of DNA. +- **1965** - Marshall Nirenberg is the first person to sequence the bases in each codon. +- **1983** - Huntington's disease is the first mapped genetic disease. +- **1990** - The Human Genome Project begins. +- **1995** - Haemophilus Influenzae is the first bacterium genome sequenced. +- **1996** - Dolly the sheep is cloned. +- **1999** - First human chromosome is decoded. +- **2000** – Genetic code of the fruit fly is decoded. +- **2002** – Mouse is the first mammal to have its genome decoded. +- **2003** – The Human Genome Project is completed. +- **2013** – DNA Worldwide and Eurofins Forensic discover identical twins have differences in their genetic makeup [^2]. + +## What is DNA? + +Deoxyribonucleic acid, a self-replicating material which is **present in nearly all living organisms** as the main constituent of chromosomes. It is the **carrier of genetic information**. + +> The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars. We are made of starstuff. +> +> **-- Carl Sagan, Cosmos** + +The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases (cytosine (C), thymine (T), adenine (A), guanine (G)), and a phosphate. Cytosine and thymine are pyrimidine bases, while adenine and guanine are purine bases. The sugar and the base together are called a nucleoside. + +![DNA](/files/dna-sequence/dna-basics.jpg#center) + +*DNA (a) forms a double stranded helix, and (b) adenine pairs with thymine and cytosine pairs with guanine. (credit a: modification of work by Jerome Walker, Dennis Myts) [^3]* + +## Encode binary data into DNA sequence + +As an input file you can use any file you want: +- ASCII files, +- Compiled programs, +- Multimedia files (MP3, MP4, MVK, etc), +- Images, +- Database files, +- etc. + +Note: If you would copy all the bytes from RAM to file or pipe data to file you could encode also this data as long as you provide file pointer to the encoder. + +### Basic Encoding + +As already mentioned, the Basic Encoding is based on a simple mapping. Since DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually referred using the first letter). Using this technique we can encode + +$$ log_2(4) = log_2(2^2) = 2 bits $$ + +using a single nucleotide. In this way, we are able to use the 4 bases that compose the DNA strand to encode each byte of data. + +| Two bits | Nucleotides | +| -------- | ---------------- | +| 00 | **A** (Adenine) | +| 10 | **G** (Guanine) | +| 01 | **C** (Cytosine) | +| 11 | **T** (Thymine) | + +With this in mind we can simply encode any data by using two-bit to Nucleotides conversion + +```pascal +{ Algorithm 1: Naive byte array to DNA encode } +procedure EncodeToDNASequence(f) string +begin + enc string + while not eof(f) do + c byte := buffer[0] { Read 1 byte from buffer } + bin integer := sprintf('08b', c) { Convert to string binary } + for e in range[0, 2, 4, 6] do + if e[0] == 48 and e[1] == 48 then { 0x00 - A (Adenine) } + enc += 'A' + else if e[0] == 48 and e[1] == 49 then { 0x01 - G (Guanine) } + enc += 'G' + else if e[0] == 49 and e[1] == 48 then { 0x10 - C (Cytosine) } + enc += 'C' + else if e[0] == 49 and e[1] == 49 then { 0x11 - T (Thymine) } + enc += 'T' + return enc { Return DNA sequence } +end +``` + +Another encoding would be **Goldman encoding**. Using this encoding helps with Nonsense mutation (amino acids replaced by a stop codon) that occurs and is the most problematic during translation because it leads to truncated amino acid sequences, which in turn results in truncated proteins. [^4] + +[Where to store big data? In DNA: Nick Goldman at TEDxPrague](https://www.youtube.com/watch?v=a4PiGWNsIEU) + +### FASTA file format + +In bioinformatics, FASTA format is a text-based format for representing either nucleotide sequences or peptide sequences, in which nucleotides or amino acids are represented using single-letter codes. The format also allows for sequence names and comments to precede the sequences. The format originates from the FASTA software package, but has now become a standard in the field of bioinformatics. [^5] + +The first line in a FASTA file started either with a ">" (greater-than) symbol or, less frequently, a ";" (semicolon) was taken as a comment. Subsequent lines starting with a semicolon would be ignored by software. Since the only comment used was the first, it quickly became used to hold a summary description of the sequence, often starting with a unique library accession number, and with time it has become commonplace to always use ">" for the first line and to not use ";" comments (which would otherwise be ignored). + +```text +;LCBO - Prolactin precursor - Bovine +; a sample sequence in FASTA format +MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS +EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL +VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED +ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC* + +>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken +ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID +FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA +DIDGDGQVNYEEFVQMMTAK* + +>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus] +LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV +EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG +LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL +GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX +IENY +``` + +FASTA format was extended by [FASTQ](https://en.wikipedia.org/wiki/FASTQ_format) format from the [Sanger Centre](https://www.sanger.ac.uk/) in Cambridge. + +### PNG encoded DNA sequence + +| Nucleotides | RGB | Color name | +| ------------ | ----------- | ---------- | +| A (Adenine) | (0,0,255) | Blue | +| G (Guanine) | (0,100,0) | Green | +| C (Cytosine) | (255,0,0) | Red | +| T (Thymine) | (255,255,0) | Yellow | + +With this in mind we can create a simple algorithm to create PNG representation of a DNA sequence. + +```pascal +{ Algorithm 2: Naive DNA to PNG encode from FASTA file } +procedure EncodeDNASequenceToPNG(f) +begin + i image + while not eof(f) do + c char := buffer[0] { Read 1 char from buffer } + case c of + 'A': color := RGB(0, 0, 255) { Blue } + 'G': color := RGB(0, 100, 0) { Green } + 'C': color := RGB(255, 0, 0) { Red } + 'T': color := RGB(255, 255, 0) { Yellow } + drawRect(i, [x, y], color) + save(i) { Save PNG image } +end +``` + +## Encoding text file in practice + +In this example we will take a simple text file as our input stream for encoding. This file will have a quote from Niels Bohr and saved as txt file. + +> How wonderful that we have met with a paradox. Now we have some hope of making progress. +> ― Niels Bohr + +First we encode text file into FASTA file. + +```bash +./dnae-encode -i quote.txt -o quote.fa +2019/01/10 00:38:29 Gathering input file stats +2019/01/10 00:38:29 Starting encoding ... + 106 B / 106 B [==================================] 100.00% 0s +2019/01/10 00:38:29 Saving to FASTA file ... +2019/01/10 00:38:29 Output FASTA file length is 438 B +2019/01/10 00:38:29 Process took 987.263µs +2019/01/10 00:38:29 Done ... +``` + +Output of `quote.fa` file contains the encoded DNA sequence in ASCII format. + +```text +>SEQ1 +GACAGCTTGTGTACAAGTGTGCTTGCTCGCGAGCGGGTACGCGCGTGGGCTAACAAGTGA +GCCAGCAGGTGAACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGCTGGCGGGTGA +ACAAGTGTGCCGGTGAGCCAACAAGCAGACAAGTAAGCAGGTACGCAGGCGAGCTTGTCA +ACTCACAAGATCGCTTGTGTACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGTAT +GCTTGCTGGCGGACAAGCCAGCTTGTAAGCGGACAAGCTTGCGCACAAGCTGGCAGGCCT +GCCGGCTCGCGTACAAATTCACAAGTAAGTACGCTTGCGTGTACGCGGGTATGTATACTC +AACCTCACCAAACGGGACAAGATCGCCGGCGGGCTAGTATACAAGAACGCTTGCCAGTAC +AACC +``` + +Then we encode FASTA file from previous operation to encode this data into PNG. + +```bash +./dnae-png -i quote.fa -o quote.png +2019/01/10 00:40:09 Gathering input file stats ... +2019/01/10 00:40:09 Deconstructing FASTA file ... +2019/01/10 00:40:09 Compositing image file ... + 424 / 424 [==================================] 100.00% 0s +2019/01/10 00:40:09 Saving output file ... +2019/01/10 00:40:09 Output image file length is 1.1 kB +2019/01/10 00:40:09 Process took 19.036117ms +2019/01/10 00:40:09 Done ... +``` + +After encoding into PNG format this file looks like this. + +![Encoded Quote in PNG format](/files/dna-sequence/quote.png) + +The larger the input stream is the larger the PNG file would be. + +Compiled basic Hello World C program with [GCC](https://www.gnu.org/software/gcc/) would [look like](/files/dna-sequence/sample.png). + +```c +// gcc -O3 -o sample sample.c +#include + +main() { + printf("Hello, world!\n"); + return 0; +} +``` + +## Toolkit for encoding data + +I have created a toolkit with two main programs: +- dnae-encode (encodes file into FASTA file) +- dnae-png (encodes FASTA file into PNG) + +Toolkit with full source code is available on [github.com/mitjafelicijan/dna-encoding](https://github.com/mitjafelicijan/dna-encoding). + +### dnae-encode + +```bash +> ./dnae-encode --help +usage: dnae-encode --input=INPUT [] + +A command-line application that encodes file into DNA sequence. + +Flags: + --help Show context-sensitive help (also try --help-long and --help-man). + -i, --input=INPUT Input file (ASCII or binary) which will be encoded into DNA sequence. + -o, --output="out.fa" Output file which stores DNA sequence in FASTA format. + -s, --sequence=SEQ1 The description line (defline) or header/identifier line, gives a name and/or a unique identifier for the sequence. + -c, --columns=60 Row characters length (no more than 120 characters). Devices preallocate fixed line sizes in software. + --version Show application version. +``` + +### dnae-png + +```bash +> ./dnae-png --help +usage: dnae-png --input=INPUT [] + +A command-line application that encodes FASTA file into PNG image. + +Flags: + --help Show context-sensitive help (also try --help-long and --help-man). + -i, --input=INPUT Input FASTA file which will be encoded into PNG image. + -o, --output="out.png" Output file in PNG format that represents DNA sequence in graphical way. + -s, --size=10 Size of pairings of DNA bases on image in pixels (lower resolution lower file size). + --version Show application version. +``` + +## Benchmarks + +First we generate some binary sample data with dd. + +```bash +dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) of=1KB.bin bs=1KB count=1 iflag=fullblock +``` + +Our freshly generated 1KB file looks something like this (its full of garbage data as intended). + +![Sample binary file 1KB](/files/dna-sequence/sample-binary-file.png) + +We create following binary files: +- 1KB.bin +- 10KB.bin +- 100KB.bin +- 1MB.bin +- 10MB.bin +- 100MB.bin + +After this we create FASTA files for all the binary files by encoding them into DNA sequence. + +```bash +./dnae-encode -i 100MB.bin -o 100MB.fa +``` + +Then we GZIP all the FASTA files to see how much the can be compressed. + +```bash +gzip -9 < 10MB.fa > 10MB.fa.gz +``` + + + +**Speed of encoding binary file into FASTA format.** + +
+ + +**File sizes of encoded files and also GZIP-ed variations.** + +
+ + +[Download ODS file with benchmarks.](/files/dna-sequence/benchmarks.ods). + +## References + +[^1]: https://www.techopedia.com/definition/948/encoding +[^2]: https://www.dna-worldwide.com/resource/160/history-dna-timeline +[^3]: https://opentextbc.ca/biology/chapter/9-1-the-structure-of-dna/ +[^4]: https://arxiv.org/abs/1801.04774 +[^5]: https://en.wikipedia.org/wiki/FASTA_format diff --git a/content/cv.md b/content/cv.md new file mode 100644 index 0000000..619be1a --- /dev/null +++ b/content/cv.md @@ -0,0 +1,64 @@ +--- +layout: page +title: Curriculum Vitae +description: Summary of my experiences, skills and major projects I have worked on through year +slug: curriculum-vitae +--- + +**Mitja Felicijan** +*Embedded systems developer* +*[mitja.felicijan@gmail.com](mailto:mitja.felicijan@gmail.com?subject=Website+CV+Contact)* +*Slovenia, EU* + +## Technical experience + +- **Key languages:** Golang, Python, C/C++, Bash, C#, Java, Perl. +- **Platforms:** GNU/Linux, Arch, Debian, Gentoo, Red Hat, Custom distros. +- **Fields of study:** Zigbee, KNX, Modbus, Machine to Machine, Embedded systems, Operating systems, Distributed systems, IOT, RDBMS, Algorithms, Database engine design, SQL, NoSQL, NewSQL, Big data analytics, Machine learning, Prediction algorithms, Realtime analytics, Systems automation. + +## Major projects + +- SMS marketing system (2007) +- Yacht management software (2008) +- Smart Home Gateway (2009) +- Moxa UPort 1130 USB to RS485 Universal Linux driver (2009) +- Remote management of electricity meter (2009) +- Remote management of blood pressure monitor (2010) +- Infomat automation system (2010) +- GPS Tourist - GIS Software (2011) +- Minimal GNU/Linux distribution for embedded platforms (2011) +- Digital Jukebox system (2012) +- NanoCloudLogger - Machine to Machine (2012) +- Street Lightning System (2012) +- Smart cabins with hardware sensor management (2013) +- Contextual advertising server (2015) +- Network accessible database engine for caching and in-memory storage (2016) +- Tick database engine specifically designed for storing and processing large amount of sensor data with high write throughput (2016) +- Wireless industrial lighting management system - hardware and software (2016) +- Minimal configuration reverse proxy (2017) +- Industrial IOT platform for deployment on on-premise (2018) + +## Employment history + +- Freelancer (2001 – Present) +- Software developer at Mobinia (2005 – 2007) +- CTO at Milk (2007 – 2009) +- Founder and CTO of UTS (2009 – 2014) +- Founding member of Origami Group (2014 – 2017) +- Senior Software Engineer at TSmedia (2015 - 2017) + +## Awards + +- Regional Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010 +- National Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010 + +## Key responsibilities + +- Responsible for embedded platforms development. +- Responsible for hardware design and driver development. +- Responsible for the designing, develop and test the systems. +- Responsible for implementation of the systems. +- Responsible for writing and maintaining user and technical documents. +- Responsible for development and maintenance of the project. +- Responsible for code revision, testing and output. +- Work on the enhancement suggested by the customers and fixes the bugs reported.) diff --git a/curriculum-vitae.md b/curriculum-vitae.md deleted file mode 100644 index 87792eb..0000000 --- a/curriculum-vitae.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -layout: page -title: Curriculum Vitae -description: Summary of my experiences, skills and major projects I have worked on through year ---- - -**Mitja Felicijan** -*Embedded systems developer* -*[mitja.felicijan@gmail.com](mailto:mitja.felicijan@gmail.com?subject=Website+CV+Contact)* -*Slovenia, EU* - -### Technical experience - -- **Key languages:** Golang, Python, C/C++, Bash, C#, Java, Perl. -- **Platforms:** GNU/Linux, Arch, Debian, Gentoo, Red Hat, Custom distros. -- **Fields of study:** Zigbee, KNX, Modbus, Machine to Machine, Embedded systems, Operating systems, Distributed systems, IOT, RDBMS, Algorithms, Database engine design, SQL, NoSQL, NewSQL, Big data analytics, Machine learning, Prediction algorithms, Realtime analytics, Systems automation. - -### Major projects - -- SMS marketing system (2007) -- Yacht management software (2008) -- Smart Home Gateway (2009) -- Moxa UPort 1130 USB to RS485 Universal Linux driver (2009) -- Remote management of electricity meter (2009) -- Remote management of blood pressure monitor (2010) -- Infomat automation system (2010) -- GPS Tourist - GIS Software (2011) -- Minimal GNU/Linux distribution for embedded platforms (2011) -- Digital Jukebox system (2012) -- NanoCloudLogger - Machine to Machine (2012) -- Street Lightning System (2012) -- Smart cabins with hardware sensor management (2013) -- Contextual advertising server (2015) -- Network accessible database engine for caching and in-memory storage (2016) -- Tick database engine specifically designed for storing and processing large amount of sensor data with high write throughput (2016) -- Wireless industrial lighting management system - hardware and software (2016) -- Minimal configuration reverse proxy (2017) -- Industrial IOT platform for deployment on on-premise (2018) - -### Employment history - -- Freelancer (2001 – Present) -- Software developer at Mobinia (2005 – 2007) -- CTO at Milk (2007 – 2009) -- Founder and CTO of UTS (2009 – 2014) -- Founding member of Origami Group (2014 – 2017) -- Senior Software Engineer at TSmedia (2015 - 2017) - -### Awards - -- Regional Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010 -- National Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010 - -### Key responsibilities - -- Responsible for embedded platforms development. -- Responsible for hardware design and driver development. -- Responsible for the designing, develop and test the systems. -- Responsible for implementation of the systems. -- Responsible for writing and maintaining user and technical documents. -- Responsible for development and maintenance of the project. -- Responsible for code revision, testing and output. -- Work on the enhancement suggested by the customers and fixes the bugs reported. diff --git a/developers-mantra.md b/developers-mantra.md deleted file mode 100644 index e38aabf..0000000 --- a/developers-mantra.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -layout: page -title: Developer's mantra -description: Basic rules every developer should follow ---- - -1. Follow Occam's razor whenever you can. -2. Early optimization is the root of all evil. -3. Always be transparent and truthful. -4. Focus on little incremental steps. -5. Document everything and follow standards. -6. Assumption is the mother of all fuck ups. diff --git a/files/copy-benchmarks.tsv b/files/copy-benchmarks.tsv deleted file mode 100644 index c7a7af4..0000000 --- a/files/copy-benchmarks.tsv +++ /dev/null @@ -1,101 +0,0 @@ -10KB 100KB 1MB 10MB -0.15 0.187 0.317 0.653 -0.158 0.237 0.192 0.659 -0.134 0.359 0.236 0.604 -0.136 0.292 0.196 0.501 -4.411 4.479 4.376 0.649 -0.134 0.481 0.265 0.608 -0.146 0.266 0.28 0.516 -4.282 0.307 4.549 0.562 -0.152 0.28 0.229 0.512 -0.162 0.37 0.315 0.652 -0.13 4.735 0.222 5.171 -4.29 8.767 0.283 5.076 -4.555 4.682 0.318 4.941 -4.658 4.691 0.177 9.624 -4.778 4.791 4.415 5.114 -8.794 8.604 0.311 5.223 -4.582 4.727 0.234 9.28 -4.596 4.638 0.212 5.064 -4.7 4.65 4.458 5.221 -8.822 9.159 0.191 5.032 -4.628 4.641 0.324 9.226 -4.6 4.921 0.197 5.22 -8.85 4.58 4.405 5.245 -4.65 9.142 0.215 5.168 -4.884 6.67 0.248 9.273 -4.581 4.594 0.248 5.082 -8.864 4.844 4.502 5.121 -4.704 4.656 0.177 5.173 -4.616 8.883 0.209 9.334 -4.729 4.962 4.366 4.966 -8.918 4.682 0.186 6.702 -4.686 4.58 0.168 5.111 -5.123 8.84 4.747 5.084 -4.846 4.732 8.85 5.065 -8.887 4.639 4.824 9.286 -4.681 8.897 4.791 5.104 -4.649 4.682 4.835 5.194 -8.847 4.663 8.929 5.271 -4.568 4.604 4.762 9.444 -4.657 8.74 4.772 5.076 -4.636 4.724 4.838 5.168 -8.778 4.846 9.065 5.057 -4.995 4.571 5.074 9.314 -2.343 9.222 4.818 5.732 -4.742 4.646 8.909 5.32 -4.82 4.842 4.778 5.167 -8.791 4.66 4.759 5.157 -4.835 8.944 4.804 9.323 -4.599 5.594 8.952 5.299 -4.809 4.628 1.567 5.294 -8.744 4.771 5.59 5.018 -4.71 8.919 4.771 9.257 -4.704 4.7 9.003 5.064 -4.765 4.605 4.781 5.185 -8.866 4.669 4.844 5.392 -4.897 8.925 4.786 9.279 -4.568 5.168 8.893 5.1 -4.679 4.757 5.41 5.232 -8.922 4.702 4.7 1.984 -4.669 8.721 4.906 5.366 -4.707 4.555 8.96 5.245 -8.938 4.615 4.89 5.216 -4.608 4.621 4.677 9.237 -4.58 8.954 4.908 5.194 -4.707 4.575 8.968 5.017 -8.822 4.781 4.882 9.714 -4.674 8.833 4.834 5.02 -5.005 4.689 4.762 5.312 -4.732 4.799 9.111 5.286 -8.894 4.675 4.936 5.185 -4.747 8.764 4.739 9.312 -4.785 4.749 4.845 5.34 -4.656 4.705 9.181 5.256 -8.899 4.601 4.739 5.261 -4.594 8.813 4.576 9.329 -4.585 4.716 8.813 5.343 -8.718 4.723 4.819 5.092 -4.725 4.757 4.83 5.061 -4.737 8.899 4.772 9.488 -4.692 4.717 8.831 5.13 -8.841 4.951 4.787 5.309 -4.66 8.895 4.746 5.228 -4.749 4.595 4.833 5.26 -4.715 4.615 8.928 9.381 -8.849 4.651 4.826 5.289 -4.66 8.897 4.802 5.197 -4.588 4.844 4.883 9.311 -4.753 4.888 9.053 5.072 -8.841 4.737 4.75 5.157 -4.794 8.976 5.063 5.196 -4.544 4.673 9.036 9.335 -8.74 4.654 6.377 5.29 -4.729 4.752 5.001 5.048 -4.654 8.98 4.873 5.544 -4.9 4.606 4.723 5.192 -8.757 4.802 5.427 9.056 -4.859 8.969 4.816 5.3 -4.701 4.662 9.002 5.138 -4.943 4.813 4.894 5.15 -8.772 4.721 4.785 9.168 diff --git a/files/dev101-git-topics-1.png b/files/dev101-git-topics-1.png deleted file mode 100644 index bb09380..0000000 Binary files a/files/dev101-git-topics-1.png and /dev/null differ diff --git a/files/dev101-git-topics-2.png b/files/dev101-git-topics-2.png deleted file mode 100644 index 39a370a..0000000 Binary files a/files/dev101-git-topics-2.png and /dev/null differ diff --git a/files/dna-sequence/benchmarks.ods b/files/dna-sequence/benchmarks.ods deleted file mode 100644 index 62a8e30..0000000 Binary files a/files/dna-sequence/benchmarks.ods and /dev/null differ diff --git a/files/dna-sequence/chart-encoding-speed.png b/files/dna-sequence/chart-encoding-speed.png deleted file mode 100644 index 7fb106d..0000000 Binary files a/files/dna-sequence/chart-encoding-speed.png and /dev/null differ diff --git a/files/dna-sequence/chart-file-sizes.png b/files/dna-sequence/chart-file-sizes.png deleted file mode 100644 index 31bfa66..0000000 Binary files a/files/dna-sequence/chart-file-sizes.png and /dev/null differ diff --git a/files/dna-sequence/dna-basics.jpg b/files/dna-sequence/dna-basics.jpg deleted file mode 100644 index c2e7f52..0000000 Binary files a/files/dna-sequence/dna-basics.jpg and /dev/null differ diff --git a/files/dna-sequence/quote.png b/files/dna-sequence/quote.png deleted file mode 100644 index 09fb01c..0000000 Binary files a/files/dna-sequence/quote.png and /dev/null differ diff --git a/files/dna-sequence/sample-binary-file.png b/files/dna-sequence/sample-binary-file.png deleted file mode 100644 index 1e4622a..0000000 Binary files a/files/dna-sequence/sample-binary-file.png and /dev/null differ diff --git a/files/dna-sequence/sample.png b/files/dna-sequence/sample.png deleted file mode 100644 index 30f12da..0000000 Binary files a/files/dna-sequence/sample.png and /dev/null differ diff --git a/files/fuse-droplets.png b/files/fuse-droplets.png deleted file mode 100644 index d7ce243..0000000 Binary files a/files/fuse-droplets.png and /dev/null differ diff --git a/files/fuse-spaces.png b/files/fuse-spaces.png deleted file mode 100644 index 4dcc1c5..0000000 Binary files a/files/fuse-spaces.png and /dev/null differ diff --git a/files/golang-profiling-cpu.pdf b/files/golang-profiling-cpu.pdf deleted file mode 100644 index 15241cb..0000000 Binary files a/files/golang-profiling-cpu.pdf and /dev/null differ diff --git a/files/golang-profiling-mem.pdf b/files/golang-profiling-mem.pdf deleted file mode 100644 index 822e445..0000000 Binary files a/files/golang-profiling-mem.pdf and /dev/null differ diff --git a/files/iot-app-output.png b/files/iot-app-output.png deleted file mode 100644 index 1c80589..0000000 Binary files a/files/iot-app-output.png and /dev/null differ diff --git a/files/iot-rest-example.png b/files/iot-rest-example.png deleted file mode 100644 index 3ed86aa..0000000 Binary files a/files/iot-rest-example.png and /dev/null differ diff --git a/files/iot-sqlite-db.png b/files/iot-sqlite-db.png deleted file mode 100644 index 82e1e29..0000000 Binary files a/files/iot-sqlite-db.png and /dev/null differ diff --git a/files/kcachegrind.png b/files/kcachegrind.png deleted file mode 100644 index 0dc48ab..0000000 Binary files a/files/kcachegrind.png and /dev/null differ diff --git a/files/profiling-viewer.png b/files/profiling-viewer.png deleted file mode 100644 index a450513..0000000 Binary files a/files/profiling-viewer.png and /dev/null differ diff --git a/files/simple-iot-application-overview.svg b/files/simple-iot-application-overview.svg deleted file mode 100644 index 817666d..0000000 --- a/files/simple-iot-application-overview.svg +++ /dev/null @@ -1,2 +0,0 @@ - -
Database
Database
Web application


[Not supported by viewer]
Write
datapoint
[Not supported by viewer]
Read
datapoints
[Not supported by viewer]
Arduino
MKR1000
[Not supported by viewer]
Web browser
Web browser
Route: /
[Not supported by viewer]
Route: /api
[Not supported by viewer]
\ No newline at end of file diff --git a/files/simple-iot-application.zip b/files/simple-iot-application.zip deleted file mode 100644 index 46d3205..0000000 Binary files a/files/simple-iot-application.zip and /dev/null differ diff --git a/files/snakeviz.png b/files/snakeviz.png deleted file mode 100644 index 5bab395..0000000 Binary files a/files/snakeviz.png and /dev/null differ diff --git a/files/sqlite-benchmarks.tsv b/files/sqlite-benchmarks.tsv deleted file mode 100644 index daa2c21..0000000 --- a/files/sqlite-benchmarks.tsv +++ /dev/null @@ -1,1001 +0,0 @@ -DROPTABLE CREATETABLE INSERTMANY FETCHALL COMMIT -0.000732 0.000400 0.008133 0.000065 0.000166 -0.000200 0.000214 0.003105 0.000043 0.000171 -0.000246 0.000170 0.006594 0.000044 0.000101 -0.000182 0.000166 0.003892 0.000043 0.000112 -0.000248 0.000654 0.002308 0.000041 0.000090 -0.000240 0.000184 0.002253 0.000053 0.000110 -0.000698 0.000483 0.003737 0.000041 0.000165 -0.000217 0.000179 0.002470 0.000049 0.000107 -0.000243 0.000160 0.002668 0.000054 0.000340 -0.000196 0.000169 0.002247 0.000040 0.000096 -0.000191 0.000162 0.003522 0.000260 0.000102 -0.000195 0.000188 0.002325 0.000041 0.000132 -0.000194 0.000202 0.002291 0.000039 0.000091 -0.000195 0.000196 0.004114 0.000042 0.000108 -0.000204 0.000200 0.002971 0.000040 0.000106 -0.000227 0.000159 0.002208 0.000039 0.000117 -0.000207 0.000176 0.003558 0.000040 0.000124 -0.000255 0.000179 0.002870 0.000040 0.000125 -0.000209 0.000176 0.002248 0.000040 0.000176 -0.000211 0.000174 0.002661 0.000039 0.000180 -0.000208 0.000219 0.002321 0.000039 0.000151 -0.000212 0.000178 0.002609 0.000040 0.000132 -0.000205 0.000209 0.002666 0.000039 0.000126 -0.000205 0.000176 0.002501 0.000041 0.000133 -0.000243 0.000183 0.002220 0.000037 0.000117 -0.000504 0.000173 0.002230 0.000121 0.000414 -0.000270 0.000200 0.002325 0.000040 0.000154 -0.000208 0.000176 0.002386 0.000038 0.000123 -0.000229 0.000182 0.002245 0.000039 0.000127 -0.000211 0.000176 0.002544 0.000039 0.000136 -0.000204 0.000180 0.002133 0.000037 0.000129 -0.000205 0.000178 0.002330 0.000048 0.000146 -0.000210 0.000178 0.002242 0.000039 0.000109 -0.000210 0.000259 0.002766 0.000039 0.000118 -0.000317 0.000495 0.002237 0.000039 0.000195 -0.000454 0.000246 0.002447 0.000040 0.000172 -0.000936 0.000200 0.002305 0.000057 0.000173 -0.000263 0.000178 0.002251 0.000038 0.000166 -0.000240 0.000183 0.002169 0.000068 0.000176 -0.000251 0.000189 0.002221 0.000038 0.000141 -0.000268 0.000215 0.002322 0.000039 0.000226 -0.000287 0.000223 0.002696 0.000045 0.000247 -0.000362 0.000229 0.002551 0.000043 0.000133 -0.000239 0.000200 0.002621 0.000045 0.000133 -0.000634 0.000208 0.002619 0.000046 0.000138 -0.000236 0.000205 0.002589 0.000046 0.000137 -0.000262 0.000205 0.002607 0.000045 0.000142 -0.000239 0.000198 0.002754 0.000044 0.000185 -0.000238 0.000198 0.002593 0.000057 0.000160 -0.000242 0.000221 0.003784 0.000122 0.000174 -0.000242 0.000201 0.002625 0.000054 0.000148 -0.000296 0.000225 0.002934 0.000044 0.000134 -0.000239 0.000245 0.003428 0.000046 0.000158 -0.000261 0.000251 0.002569 0.000046 0.000139 -0.000260 0.000230 0.002603 0.000045 0.000145 -0.000302 0.000212 0.002580 0.000045 0.000176 -0.000794 0.000197 0.002856 0.000046 0.000141 -0.000273 0.000209 0.003173 0.000045 0.000217 -0.000240 0.000201 0.002844 0.000043 0.000167 -0.000389 0.000175 0.004315 0.000055 0.000091 -0.000275 0.000534 0.004991 0.000053 0.000092 -0.000229 0.000215 0.004084 0.000045 0.000074 -0.000172 0.000474 0.002611 0.000043 0.000069 -0.000201 0.000174 0.002485 0.000043 0.000069 -0.000173 0.000220 0.002541 0.000045 0.000068 -0.000167 0.000161 0.002827 0.000043 0.000071 -0.000168 0.000160 0.003512 0.000068 0.000075 -0.000211 0.000167 0.002530 0.000044 0.000069 -0.000193 0.000230 0.003664 0.000046 0.000074 -0.000171 0.000161 0.002575 0.000076 0.000075 -0.000169 0.000161 0.002595 0.000044 0.000076 -0.000981 0.000174 0.002556 0.000045 0.000072 -0.000168 0.000163 0.002568 0.000043 0.000072 -0.000163 0.000158 0.002579 0.000043 0.000386 -0.000168 0.000160 0.002579 0.000059 0.000088 -0.000176 0.000163 0.002559 0.000044 0.000075 -0.000167 0.000161 0.002558 0.000043 0.000075 -0.000169 0.000161 0.002599 0.000043 0.000095 -0.000174 0.000163 0.002633 0.000046 0.000076 -0.000170 0.000165 0.002576 0.000858 0.000079 -0.000169 0.000162 0.002611 0.000044 0.000075 -0.000170 0.000199 0.002621 0.000043 0.000074 -0.000170 0.000167 0.003611 0.000043 0.000073 -0.000171 0.000159 0.002764 0.000046 0.000076 -0.000171 0.000165 0.002639 0.000044 0.000073 -0.000168 0.000162 0.003131 0.000046 0.000075 -0.000170 0.000162 0.002858 0.000044 0.000074 -0.000171 0.000164 0.002841 0.000043 0.000075 -0.000167 0.000161 0.002971 0.000043 0.000074 -0.000170 0.000226 0.002842 0.000044 0.000074 -0.000171 0.000165 0.002822 0.000044 0.000075 -0.000173 0.000160 0.002895 0.000045 0.000073 -0.000167 0.000217 0.002697 0.000044 0.000076 -0.000170 0.000197 0.002699 0.000044 0.000075 -0.000171 0.000163 0.003230 0.000045 0.000097 -0.000170 0.000164 0.003167 0.000046 0.000082 -0.000172 0.000196 0.002559 0.000043 0.000075 -0.000168 0.000165 0.003006 0.000045 0.000075 -0.000176 0.000160 0.002567 0.000043 0.000075 -0.000167 0.000163 0.002757 0.000045 0.000076 -0.000171 0.000162 0.002802 0.000045 0.000076 -0.000169 0.000162 0.003102 0.000043 0.000072 -0.000167 0.000162 0.002624 0.000043 0.000075 -0.000170 0.000161 0.002589 0.000043 0.000072 -0.000222 0.000253 0.002657 0.000045 0.000075 -0.000172 0.000162 0.002586 0.000044 0.000084 -0.000172 0.000165 0.002933 0.000044 0.000075 -0.000169 0.000192 0.002609 0.000044 0.000074 -0.000194 0.000162 0.003020 0.000045 0.000081 -0.000170 0.000164 0.002908 0.000045 0.000076 -0.000169 0.000163 0.002567 0.000042 0.000073 -0.000167 0.000159 0.003071 0.000042 0.000074 -0.000222 0.000163 0.003175 0.000043 0.000076 -0.000167 0.000160 0.002641 0.000046 0.000099 -0.000171 0.000168 0.002586 0.000057 0.000075 -0.000170 0.000168 0.003148 0.000046 0.000075 -0.000171 0.000159 0.002770 0.000041 0.000074 -0.000173 0.000158 0.002643 0.000055 0.000077 -0.000313 0.000174 0.002920 0.000045 0.000075 -0.000170 0.000163 0.002551 0.000044 0.000072 -0.000173 0.000161 0.002599 0.000045 0.000073 -0.000167 0.000160 0.003505 0.000046 0.000075 -0.000171 0.000161 0.002894 0.000045 0.000074 -0.000171 0.000166 0.002572 0.000042 0.000073 -0.000166 0.000160 0.004099 0.000044 0.000102 -0.000181 0.000160 0.002499 0.000046 0.000071 -0.000174 0.000175 0.002560 0.000043 0.000068 -0.000165 0.000168 0.003083 0.000044 0.000070 -0.000210 0.000163 0.002535 0.000040 0.000068 -0.000164 0.000177 0.002906 0.000044 0.000075 -0.000175 0.000227 0.002971 0.000043 0.000073 -0.000167 0.000175 0.003409 0.000046 0.000078 -0.000172 0.000166 0.002640 0.000046 0.000074 -0.000177 0.000164 0.002574 0.000046 0.000076 -0.000170 0.000163 0.002631 0.000046 0.000075 -0.000216 0.000168 0.002596 0.000046 0.000076 -0.000170 0.000163 0.002659 0.000045 0.000074 -0.000172 0.000162 0.002677 0.000046 0.000075 -0.000170 0.000159 0.002604 0.000044 0.000081 -0.000171 0.000161 0.003163 0.000046 0.000076 -0.000171 0.000162 0.002574 0.000313 0.000075 -0.000170 0.000186 0.002988 0.000046 0.000074 -0.000171 0.000162 0.002596 0.000043 0.000077 -0.000168 0.000160 0.002640 0.000055 0.000074 -0.000169 0.000161 0.002567 0.000043 0.000371 -0.000170 0.000162 0.002704 0.000057 0.000078 -0.000255 0.000185 0.002453 0.000293 0.000066 -0.000148 0.000143 0.002169 0.000037 0.000066 -0.000173 0.000141 0.002238 0.000039 0.000085 -0.000154 0.000174 0.002679 0.000041 0.000065 -0.000149 0.000144 0.002187 0.000037 0.000065 -0.000146 0.000140 0.002760 0.000039 0.000071 -0.000147 0.000151 0.002193 0.000039 0.000065 -0.000150 0.000172 0.002207 0.000039 0.000067 -0.000147 0.000141 0.002126 0.000037 0.000060 -0.000191 0.000141 0.002119 0.000036 0.000086 -0.000149 0.000144 0.002440 0.000039 0.000065 -0.000148 0.000143 0.003287 0.000041 0.000068 -0.000152 0.000149 0.002555 0.000040 0.000069 -0.000148 0.000141 0.002203 0.000038 0.000065 -0.000147 0.000139 0.002371 0.000052 0.000075 -0.000148 0.000143 0.002201 0.000037 0.000066 -0.000149 0.000140 0.002186 0.000038 0.000062 -0.000152 0.000154 0.002215 0.000038 0.000062 -0.000149 0.000144 0.002505 0.000039 0.000067 -0.000148 0.000140 0.002216 0.000038 0.000101 -0.000160 0.000144 0.002574 0.000039 0.000067 -0.000150 0.000144 0.002266 0.000040 0.000068 -0.000151 0.000142 0.003640 0.000040 0.000068 -0.000150 0.000142 0.002207 0.000038 0.000066 -0.000148 0.000140 0.002337 0.000041 0.000068 -0.000151 0.000144 0.002138 0.000038 0.000063 -0.000146 0.000178 0.002369 0.000039 0.000060 -0.000150 0.000141 0.002290 0.000039 0.000067 -0.000149 0.000143 0.002569 0.000050 0.000070 -0.000149 0.000143 0.002797 0.000040 0.000068 -0.000149 0.000143 0.002720 0.000039 0.000066 -0.000273 0.000154 0.002255 0.000039 0.000066 -0.000147 0.000141 0.002180 0.000037 0.000065 -0.000884 0.000142 0.002164 0.000036 0.000060 -0.000188 0.000143 0.002248 0.000039 0.000062 -0.000148 0.000142 0.002178 0.000038 0.000064 -0.000151 0.000140 0.002705 0.000038 0.000063 -0.000145 0.000144 0.002588 0.000039 0.000064 -0.000147 0.000142 0.002196 0.000037 0.000064 -0.000147 0.000139 0.002169 0.000035 0.000060 -0.000151 0.000894 0.002267 0.000039 0.000061 -0.000152 0.000145 0.002178 0.000038 0.000061 -0.000185 0.000142 0.002148 0.000036 0.000062 -0.000147 0.000141 0.002845 0.000040 0.000065 -0.000159 0.000178 0.002193 0.000039 0.000063 -0.000145 0.000141 0.002571 0.000039 0.000066 -0.000149 0.000141 0.003380 0.000038 0.000065 -0.000200 0.000149 0.002439 0.000039 0.000066 -0.000152 0.000140 0.002193 0.000037 0.000065 -0.000147 0.000139 0.002239 0.000037 0.000066 -0.000200 0.000143 0.002190 0.000039 0.000066 -0.000147 0.000139 0.002243 0.000038 0.000062 -0.000421 0.000144 0.002229 0.000038 0.000062 -0.000147 0.000149 0.002715 0.000038 0.000063 -0.000151 0.000176 0.002144 0.000036 0.000060 -0.000145 0.000138 0.002184 0.000038 0.000064 -0.000146 0.000207 0.002526 0.000040 0.000067 -0.000163 0.000142 0.002366 0.000038 0.000070 -0.000149 0.000143 0.002143 0.000038 0.000065 -0.000150 0.000142 0.002146 0.000035 0.000059 -0.000162 0.000147 0.002736 0.000038 0.000067 -0.000149 0.000146 0.002383 0.000040 0.000071 -0.000147 0.000139 0.002485 0.000038 0.000065 -0.000147 0.000143 0.002811 0.000039 0.000098 -0.000181 0.000142 0.002503 0.000039 0.000066 -0.000150 0.000143 0.002227 0.000039 0.000065 -0.000149 0.000143 0.002182 0.000036 0.000061 -0.000148 0.000387 0.002159 0.000036 0.000059 -0.000147 0.000173 0.002267 0.000039 0.000063 -0.000147 0.000143 0.002729 0.000039 0.000066 -0.000149 0.000142 0.002574 0.000040 0.000069 -0.000149 0.000143 0.002560 0.000040 0.000068 -0.000152 0.000141 0.002203 0.000038 0.000066 -0.000151 0.000139 0.002234 0.000038 0.000087 -0.000148 0.000140 0.002152 0.000036 0.000060 -0.000185 0.000140 0.002274 0.000039 0.000063 -0.000148 0.000144 0.002211 0.000038 0.000066 -0.000149 0.000141 0.002692 0.000039 0.000066 -0.000148 0.000145 0.002519 0.000039 0.000066 -0.000147 0.000143 0.002188 0.000038 0.000066 -0.000149 0.000171 0.002171 0.000038 0.000093 -0.000150 0.000182 0.002185 0.000038 0.000068 -0.000191 0.000154 0.002172 0.000037 0.000061 -0.000145 0.000140 0.002253 0.000043 0.000065 -0.000147 0.000139 0.002673 0.000038 0.000066 -0.000191 0.000144 0.002740 0.000038 0.000066 -0.000147 0.000142 0.002187 0.000038 0.000064 -0.000146 0.000181 0.002180 0.000038 0.000066 -0.000176 0.000142 0.002152 0.000039 0.000061 -0.000149 0.000142 0.002164 0.000037 0.000064 -0.000245 0.000150 0.002771 0.000055 0.000084 -0.000149 0.000145 0.003006 0.000040 0.000069 -0.000153 0.000144 0.002701 0.000040 0.000067 -0.000149 0.000144 0.002192 0.000038 0.000065 -0.000148 0.000143 0.002220 0.000038 0.000063 -0.000146 0.000140 0.002210 0.000038 0.000062 -0.000157 0.000144 0.002174 0.000038 0.000060 -0.000148 0.000171 0.002208 0.000039 0.000061 -0.000146 0.000141 0.002685 0.000039 0.000064 -0.000146 0.000139 0.002811 0.000038 0.000064 -0.000147 0.000140 0.002234 0.000037 0.000063 -0.000143 0.000143 0.002209 0.000040 0.000066 -0.000149 0.000144 0.002162 0.000037 0.000091 -0.000408 0.000141 0.002140 0.000036 0.000060 -0.000142 0.000149 0.002208 0.000132 0.000061 -0.000148 0.000142 0.002706 0.000040 0.000066 -0.000148 0.000142 0.002502 0.000039 0.000065 -0.000176 0.000144 0.002265 0.000039 0.000066 -0.000150 0.000142 0.002199 0.000039 0.000065 -0.000147 0.000154 0.002201 0.000040 0.000067 -0.000150 0.000142 0.002164 0.000036 0.000094 -0.000183 0.000177 0.002253 0.000039 0.000063 -0.000189 0.000143 0.002480 0.000039 0.000066 -0.000148 0.000141 0.002212 0.000037 0.000064 -0.000150 0.000137 0.002192 0.000037 0.000065 -0.000144 0.000140 0.002271 0.000039 0.000062 -0.000190 0.000171 0.002145 0.000037 0.000061 -0.000146 0.000141 0.005865 0.000099 0.000083 -0.000178 0.000165 0.002792 0.000040 0.000066 -0.000148 0.000233 0.002742 0.000039 0.000079 -0.000157 0.000151 0.002225 0.000039 0.000066 -0.000149 0.000142 0.002215 0.000039 0.000081 -0.000165 0.000141 0.002239 0.000039 0.000081 -0.000150 0.000154 0.002154 0.000036 0.000060 -0.000152 0.000151 0.002216 0.000039 0.000075 -0.000172 0.000141 0.004471 0.000060 0.000092 -0.000250 0.000210 0.002881 0.000040 0.000066 -0.000176 0.000152 0.002262 0.000038 0.000337 -0.000164 0.000154 0.002485 0.000039 0.000074 -0.000149 0.000180 0.002148 0.000039 0.000078 -0.000194 0.000145 0.002345 0.000044 0.000064 -0.000164 0.000201 0.002483 0.000040 0.000062 -0.000148 0.000140 0.002249 0.000038 0.000076 -0.000155 0.000144 0.002504 0.000039 0.000067 -0.000166 0.000150 0.002780 0.000040 0.000079 -0.000150 0.000142 0.002194 0.000038 0.000086 -0.000178 0.000153 0.002360 0.000039 0.000079 -0.000160 0.000154 0.002159 0.000036 0.000079 -0.000195 0.000445 0.002203 0.000038 0.000074 -0.000171 0.000161 0.002220 0.000038 0.000087 -0.000165 0.000151 0.002231 0.000038 0.000088 -0.000149 0.000141 0.003445 0.000040 0.000068 -0.000148 0.000143 0.002465 0.000039 0.000081 -0.000165 0.000150 0.002228 0.000038 0.000067 -0.000160 0.000142 0.003231 0.000039 0.000066 -0.000149 0.000141 0.002215 0.000038 0.000078 -0.000146 0.000152 0.002152 0.000038 0.000077 -0.000168 0.000140 0.002258 0.000040 0.000076 -0.000193 0.000142 0.002266 0.000039 0.000085 -0.000261 0.000164 0.002160 0.000037 0.000061 -0.000151 0.000419 0.002217 0.000037 0.000073 -0.000163 0.000148 0.002856 0.000038 0.000106 -0.000258 0.000204 0.002267 0.000040 0.000075 -0.000178 0.000159 0.002266 0.000038 0.000070 -0.000158 0.000149 0.002665 0.000039 0.000085 -0.000164 0.000154 0.002478 0.000039 0.000077 -0.000148 0.000140 0.002459 0.000038 0.000066 -0.000161 0.000142 0.002206 0.000038 0.000074 -0.000155 0.000151 0.002230 0.000039 0.000083 -0.000161 0.000142 0.002225 0.000037 0.000072 -0.000161 0.000187 0.002450 0.000038 0.000063 -0.000145 0.000155 0.002438 0.000039 0.000079 -0.000166 0.000138 0.002296 0.000039 0.000076 -0.000170 0.000156 0.002446 0.000038 0.000078 -0.000160 0.000159 0.002211 0.000038 0.000078 -0.000159 0.000142 0.002190 0.000036 0.000110 -0.000157 0.000150 0.002336 0.000039 0.000073 -0.000165 0.000182 0.002132 0.000038 0.000072 -0.000160 0.000140 0.002641 0.000066 0.000066 -0.000147 0.000153 0.002153 0.000039 0.000080 -0.000148 0.000156 0.002165 0.000037 0.000077 -0.000147 0.000151 0.002201 0.000038 0.000067 -0.000162 0.000143 0.002216 0.000040 0.000080 -0.000165 0.000148 0.002223 0.000055 0.000080 -0.000193 0.000143 0.002155 0.000037 0.000078 -0.000165 0.000143 0.003005 0.000040 0.000067 -0.000151 0.000145 0.002511 0.000039 0.000070 -0.000149 0.000173 0.002246 0.000039 0.000066 -0.000148 0.000143 0.002808 0.000040 0.000067 -0.000148 0.000142 0.002513 0.000038 0.000066 -0.000148 0.000143 0.002203 0.000037 0.000065 -0.000146 0.000138 0.002123 0.000038 0.000061 -0.000170 0.000149 0.002165 0.000036 0.000062 -0.000144 0.000145 0.002186 0.000037 0.000059 -0.000144 0.000139 0.002520 0.000037 0.000065 -0.000146 0.000139 0.002559 0.000038 0.000066 -0.000153 0.000142 0.002537 0.000038 0.000067 -0.000168 0.000144 0.002217 0.000048 0.000066 -0.000147 0.000141 0.002120 0.000037 0.000063 -0.000188 0.001725 0.002541 0.000040 0.000067 -0.000149 0.000143 0.002229 0.000038 0.000076 -0.000147 0.000143 0.002233 0.000037 0.000062 -0.000182 0.000142 0.002150 0.000037 0.000061 -0.000148 0.000140 0.002196 0.000037 0.000065 -0.000145 0.000140 0.002473 0.000037 0.000065 -0.000147 0.000139 0.002725 0.000040 0.000067 -0.000149 0.000142 0.002217 0.000039 0.000065 -0.000146 0.000140 0.002167 0.000037 0.000061 -0.000176 0.000144 0.002415 0.000039 0.000064 -0.000171 0.000144 0.002925 0.000040 0.000068 -0.000152 0.000167 0.002190 0.000039 0.000066 -0.000149 0.000142 0.002530 0.000039 0.000067 -0.000150 0.000142 0.003059 0.000040 0.000068 -0.000149 0.000142 0.002417 0.000038 0.000072 -0.000149 0.000143 0.002569 0.000038 0.000068 -0.000148 0.000141 0.002262 0.000040 0.000068 -0.000152 0.000144 0.002253 0.000038 0.000066 -0.000149 0.000142 0.002134 0.000037 0.000061 -0.000277 0.000427 0.002186 0.000036 0.000060 -0.000145 0.000139 0.002791 0.000039 0.000065 -0.000149 0.000144 0.002238 0.000039 0.000066 -0.000147 0.000144 0.002514 0.000039 0.000066 -0.000148 0.000143 0.002683 0.000038 0.000063 -0.000147 0.000139 0.002214 0.000037 0.000068 -0.000145 0.000139 0.002149 0.000036 0.000059 -0.000185 0.000139 0.002214 0.000037 0.000060 -0.000145 0.000140 0.003549 0.000039 0.000066 -0.000187 0.000142 0.002160 0.000037 0.000059 -0.000147 0.000158 0.002212 0.000038 0.000065 -0.000148 0.000140 0.002483 0.000039 0.000067 -0.000147 0.000142 0.003034 0.000039 0.000066 -0.000148 0.000142 0.002228 0.000039 0.000066 -0.000145 0.000151 0.002225 0.000040 0.000067 -0.000149 0.000142 0.002858 0.000048 0.000083 -0.000203 0.000185 0.004022 0.000049 0.000086 -0.000212 0.000188 0.005086 0.000056 0.000093 -0.000220 0.000203 0.004209 0.000051 0.000085 -0.000208 0.000247 0.009261 0.000098 0.000089 -0.000211 0.000262 0.002546 0.000041 0.000066 -0.000198 0.000150 0.002534 0.000039 0.000079 -0.000159 0.000143 0.002207 0.000038 0.000094 -0.000157 0.000143 0.002173 0.000038 0.000062 -0.000198 0.000505 0.002157 0.000039 0.000079 -0.000164 0.000143 0.002172 0.000038 0.000076 -0.000156 0.000148 0.002259 0.000039 0.000080 -0.000161 0.000142 0.002219 0.000039 0.000076 -0.000161 0.000143 0.002266 0.000039 0.000085 -0.000161 0.000141 0.002150 0.000036 0.000077 -0.000179 0.000140 0.002140 0.000036 0.000071 -0.000157 0.000151 0.002316 0.000040 0.000079 -0.000149 0.000143 0.002269 0.000039 0.000066 -0.000161 0.000142 0.002206 0.000040 0.000091 -0.000172 0.000143 0.002244 0.000039 0.000067 -0.000168 0.000142 0.002189 0.000039 0.000083 -0.000163 0.000188 0.002156 0.000037 0.000077 -0.000168 0.000143 0.002266 0.000039 0.000084 -0.000166 0.000147 0.002205 0.000325 0.000078 -0.000175 0.000140 0.002173 0.000037 0.000106 -0.000170 0.000153 0.002158 0.000036 0.000083 -0.000168 0.000147 0.002825 0.000039 0.000108 -0.000172 0.000151 0.002483 0.000038 0.000085 -0.000160 0.000143 0.002163 0.000038 0.000066 -0.000161 0.000154 0.002493 0.000039 0.000084 -0.000167 0.000153 0.002564 0.000040 0.000082 -0.000159 0.000151 0.002185 0.000046 0.000088 -0.000157 0.000156 0.002175 0.000039 0.000076 -0.000150 0.000144 0.002151 0.000038 0.000063 -0.000160 0.000140 0.002429 0.000038 0.000064 -0.000160 0.000154 0.002184 0.000048 0.000077 -0.000168 0.000142 0.002686 0.000040 0.000119 -0.000164 0.000152 0.002279 0.000039 0.000075 -0.000161 0.000143 0.002192 0.000068 0.000067 -0.000161 0.000154 0.002190 0.000040 0.000092 -0.000246 0.000146 0.003064 0.000038 0.000072 -0.000163 0.000158 0.002171 0.000037 0.000073 -0.000216 0.000144 0.002209 0.000039 0.000115 -0.000159 0.000141 0.003338 0.000039 0.000079 -0.000277 0.000158 0.002464 0.000039 0.000082 -0.000168 0.000150 0.002227 0.000037 0.000079 -0.000168 0.000146 0.002775 0.000038 0.000077 -0.000146 0.000147 0.002694 0.000042 0.000084 -0.000160 0.000145 0.002807 0.000039 0.000066 -0.000162 0.000177 0.002187 0.000063 0.000066 -0.000147 0.000141 0.002220 0.000038 0.000085 -0.000160 0.000142 0.002216 0.000037 0.000077 -0.000166 0.000159 0.002224 0.000039 0.000108 -0.000147 0.000141 0.002746 0.000039 0.000078 -0.000159 0.000141 0.002194 0.000037 0.000063 -0.000164 0.000143 0.002164 0.000039 0.000067 -0.000169 0.000152 0.002278 0.000074 0.000088 -0.000157 0.000157 0.002155 0.000068 0.000076 -0.000159 0.000140 0.002170 0.000035 0.000078 -0.000156 0.000141 0.002299 0.000040 0.000066 -0.000192 0.000160 0.002241 0.000039 0.000082 -0.000149 0.000143 0.002288 0.000039 0.000079 -0.000161 0.000142 0.002185 0.000049 0.000077 -0.000147 0.000149 0.002284 0.000039 0.000063 -0.000456 0.000144 0.002203 0.000046 0.000064 -0.000187 0.000144 0.002147 0.000037 0.000061 -0.000147 0.000140 0.002238 0.000040 0.000067 -0.000147 0.000140 0.003077 0.000041 0.000068 -0.000151 0.000142 0.002226 0.000038 0.000065 -0.000146 0.000142 0.002188 0.000039 0.000065 -0.000145 0.000141 0.002156 0.000036 0.000061 -0.000143 0.000172 0.002379 0.000037 0.000060 -0.000152 0.000231 0.002172 0.000038 0.000065 -0.000153 0.000142 0.002181 0.000039 0.000065 -0.000148 0.000142 0.002567 0.000039 0.000067 -0.000150 0.000142 0.002177 0.000038 0.000072 -0.000147 0.000146 0.002328 0.000038 0.000063 -0.000146 0.000150 0.002211 0.000038 0.000063 -0.000149 0.000143 0.002222 0.000040 0.000072 -0.000150 0.000144 0.002455 0.000039 0.000065 -0.000147 0.000144 0.002206 0.000039 0.000066 -0.000145 0.000141 0.002153 0.000055 0.000070 -0.000443 0.000144 0.002139 0.000036 0.000069 -0.000147 0.000182 0.002188 0.000037 0.000061 -0.000146 0.000138 0.002248 0.000038 0.000067 -0.000147 0.000142 0.002817 0.000039 0.000067 -0.000148 0.000144 0.002230 0.000038 0.000066 -0.000148 0.000142 0.002239 0.000039 0.000067 -0.000149 0.000142 0.002197 0.000038 0.000063 -0.000181 0.000674 0.002170 0.000038 0.000061 -0.000146 0.000195 0.002204 0.000037 0.000061 -0.000146 0.000141 0.002260 0.000039 0.000067 -0.000150 0.000142 0.002193 0.000045 0.000065 -0.000147 0.000140 0.002229 0.000036 0.000066 -0.000146 0.000137 0.002197 0.000037 0.000062 -0.000152 0.000159 0.002187 0.000036 0.000060 -0.000145 0.000139 0.002224 0.000037 0.000064 -0.000149 0.000144 0.002175 0.000038 0.000066 -0.000150 0.000143 0.002187 0.000038 0.000066 -0.000148 0.000141 0.002152 0.000036 0.000061 -0.000185 0.000141 0.002176 0.000036 0.000064 -0.000169 0.000145 0.002483 0.000038 0.000067 -0.000149 0.000141 0.002225 0.000036 0.000064 -0.000244 0.000149 0.002538 0.000038 0.000065 -0.000156 0.000143 0.002317 0.000039 0.000297 -0.000228 0.000172 0.002222 0.000039 0.000300 -0.000149 0.000145 0.002173 0.000040 0.000066 -0.000154 0.000145 0.002155 0.000038 0.000093 -0.000161 0.000145 0.002178 0.000039 0.000063 -0.000147 0.000170 0.002299 0.000039 0.000066 -0.000149 0.000142 0.003494 0.000040 0.000066 -0.000149 0.000178 0.002237 0.000038 0.000062 -0.000148 0.000143 0.002150 0.000037 0.000064 -0.000146 0.000139 0.002315 0.000038 0.000065 -0.000147 0.000141 0.002269 0.000039 0.000067 -0.000173 0.000145 0.002191 0.000037 0.000065 -0.000166 0.000144 0.002247 0.000038 0.000061 -0.000146 0.000140 0.002551 0.000038 0.000065 -0.000148 0.000175 0.002202 0.000037 0.000064 -0.000145 0.000141 0.002217 0.000038 0.000063 -0.000146 0.000138 0.002164 0.000132 0.000547 -0.000148 0.000144 0.008140 0.000160 0.000893 -0.000311 0.000221 0.004526 0.000058 0.000109 -0.000238 0.000225 0.003475 0.000044 0.000094 -0.000178 0.000177 0.002537 0.000041 0.000087 -0.000172 0.000161 0.002194 0.000048 0.000084 -0.000172 0.000163 0.002177 0.000040 0.000084 -0.001177 0.000156 0.002351 0.000041 0.000325 -0.000167 0.000163 0.002273 0.000040 0.000088 -0.000170 0.000151 0.002245 0.000040 0.000077 -0.000172 0.000896 0.002181 0.000038 0.000080 -0.000202 0.000164 0.002449 0.000038 0.000076 -0.000162 0.000161 0.002188 0.000037 0.000078 -0.000165 0.000154 0.002440 0.000074 0.000091 -0.000167 0.000149 0.002185 0.000039 0.000081 -0.000176 0.000154 0.002427 0.000040 0.000093 -0.000168 0.000154 0.002304 0.000038 0.000105 -0.000672 0.000160 0.002260 0.000038 0.000088 -0.000686 0.000159 0.002207 0.000038 0.000084 -0.000163 0.000154 0.002186 0.000037 0.000077 -0.000173 0.000153 0.002399 0.000038 0.000082 -0.000166 0.000157 0.002709 0.000039 0.000077 -0.000155 0.000149 0.002143 0.000038 0.000097 -0.000166 0.000154 0.003454 0.000051 0.000106 -0.000166 0.000160 0.002539 0.000039 0.000128 -0.000169 0.000149 0.002307 0.000039 0.000085 -0.000170 0.000158 0.002225 0.000040 0.000088 -0.000170 0.000180 0.002165 0.000036 0.000103 -0.000203 0.000160 0.002345 0.000039 0.000075 -0.000173 0.000191 0.002160 0.000038 0.000074 -0.000165 0.000156 0.002243 0.000039 0.000085 -0.000172 0.000154 0.002260 0.000040 0.000090 -0.000163 0.000164 0.002258 0.000040 0.000085 -0.000168 0.000143 0.002755 0.000039 0.000086 -0.000178 0.000155 0.002202 0.000039 0.000075 -0.000164 0.000153 0.002267 0.000038 0.000081 -0.000161 0.000154 0.002158 0.000036 0.000090 -0.000169 0.000158 0.002454 0.000037 0.000061 -0.000162 0.000154 0.002543 0.000038 0.000091 -0.000170 0.000154 0.002168 0.000037 0.000085 -0.000166 0.000151 0.002852 0.000038 0.000087 -0.000167 0.000165 0.002484 0.000039 0.000089 -0.000374 0.000197 0.002217 0.000038 0.000082 -0.000156 0.000150 0.002213 0.000038 0.000112 -0.000683 0.000155 0.002131 0.000038 0.000077 -0.000162 0.000164 0.002199 0.000038 0.000076 -0.000176 0.000154 0.002345 0.000038 0.000089 -0.000175 0.000150 0.002928 0.000039 0.000082 -0.000161 0.000140 0.002528 0.000039 0.000066 -0.000159 0.000151 0.002256 0.000039 0.000075 -0.000155 0.000156 0.002233 0.000040 0.000066 -0.000171 0.000156 0.002149 0.000066 0.000084 -0.000182 0.000154 0.002233 0.000037 0.000117 -0.000166 0.000160 0.002460 0.000037 0.000088 -0.000159 0.000165 0.002891 0.000043 0.000075 -0.000169 0.000143 0.002383 0.000038 0.000084 -0.000162 0.000149 0.002313 0.000039 0.000078 -0.000166 0.000161 0.003837 0.000041 0.000092 -0.000166 0.000144 0.002389 0.000038 0.000078 -0.000185 0.000153 0.002548 0.000040 0.000090 -0.000166 0.000152 0.002943 0.000037 0.000063 -0.000147 0.000140 0.002284 0.000038 0.000066 -0.000145 0.000141 0.002555 0.000038 0.000071 -0.000189 0.000143 0.002235 0.000038 0.000359 -0.000149 0.000140 0.002779 0.000053 0.000089 -0.000211 0.000206 0.002744 0.000040 0.000067 -0.000150 0.000144 0.002471 0.000039 0.000065 -0.000151 0.000140 0.002563 0.000040 0.000064 -0.000148 0.000138 0.002305 0.000039 0.000066 -0.000148 0.000141 0.002162 0.000036 0.000060 -0.000182 0.000145 0.002403 0.000042 0.000063 -0.000152 0.000141 0.002311 0.000039 0.000065 -0.000148 0.000180 0.002192 0.000038 0.000065 -0.000149 0.000141 0.002516 0.000039 0.000066 -0.000147 0.000142 0.002193 0.000040 0.000064 -0.000146 0.000138 0.002194 0.000036 0.000060 -0.000197 0.000142 0.002291 0.000038 0.000063 -0.000148 0.000142 0.002440 0.000039 0.000066 -0.000148 0.000143 0.002228 0.000039 0.000066 -0.000149 0.000140 0.002216 0.000038 0.000067 -0.000148 0.000145 0.002196 0.000038 0.000066 -0.000148 0.000141 0.002157 0.000036 0.000061 -0.000144 0.000175 0.002491 0.000039 0.000063 -0.000147 0.000141 0.002290 0.000039 0.000066 -0.000149 0.000143 0.002508 0.000039 0.000067 -0.000149 0.000142 0.002536 0.000039 0.000067 -0.000150 0.000141 0.003132 0.000046 0.000070 -0.000153 0.000145 0.002202 0.000039 0.000067 -0.000149 0.000143 0.002102 0.000037 0.000067 -0.000989 0.000142 0.002188 0.000063 0.000068 -0.000151 0.000142 0.002229 0.000038 0.000068 -0.001481 0.000141 0.002238 0.000039 0.000070 -0.000148 0.000142 0.002204 0.000037 0.000093 -0.000160 0.000141 0.002138 0.000038 0.000062 -0.000145 0.000141 0.002708 0.000039 0.000065 -0.000147 0.000142 0.002218 0.000039 0.000067 -0.000148 0.000140 0.002759 0.000038 0.000066 -0.000148 0.000139 0.003156 0.000037 0.000067 -0.000185 0.000141 0.002259 0.000040 0.000066 -0.000148 0.000142 0.002226 0.000047 0.000068 -0.000148 0.000142 0.002305 0.000040 0.000090 -0.001000 0.000155 0.002217 0.000064 0.000068 -0.000154 0.000144 0.002554 0.000038 0.000065 -0.000148 0.000141 0.002151 0.000038 0.000066 -0.000146 0.000181 0.003031 0.000039 0.000062 -0.000146 0.000180 0.002254 0.000039 0.000061 -0.000147 0.000143 0.002188 0.000039 0.000065 -0.000147 0.000140 0.002259 0.000039 0.000063 -0.000146 0.000141 0.002238 0.000038 0.000076 -0.000148 0.000141 0.002163 0.000038 0.000061 -0.000153 0.000143 0.002195 0.000043 0.000072 -0.000149 0.000177 0.003291 0.000039 0.000063 -0.000258 0.000153 0.002150 0.000039 0.000066 -0.000157 0.000144 0.002155 0.000037 0.000060 -0.000160 0.001194 0.002269 0.000040 0.000100 -0.000164 0.000151 0.002162 0.000038 0.000078 -0.000163 0.000424 0.002178 0.000036 0.000069 -0.001333 0.000389 0.002249 0.000039 0.000066 -0.000175 0.000142 0.002208 0.000037 0.000102 -0.000443 0.000156 0.002249 0.000040 0.000062 -0.000244 0.001562 0.003049 0.000041 0.000083 -0.000208 0.000183 0.002483 0.000040 0.000068 -0.000164 0.000156 0.002220 0.000040 0.000078 -0.000169 0.000142 0.002694 0.000040 0.000083 -0.000162 0.000152 0.002453 0.000038 0.000077 -0.000157 0.000189 0.002306 0.000040 0.000077 -0.000162 0.000151 0.002200 0.000039 0.000325 -0.000150 0.000142 0.002251 0.000039 0.000066 -0.000172 0.000157 0.002184 0.000039 0.000073 -0.000160 0.000150 0.002678 0.000038 0.000326 -0.000165 0.000151 0.002292 0.000038 0.000094 -0.000162 0.000156 0.002203 0.000037 0.000083 -0.000170 0.000141 0.002175 0.000037 0.000074 -0.000149 0.000166 0.002235 0.000039 0.000071 -0.000161 0.000143 0.002423 0.000036 0.000180 -0.000164 0.000152 0.003095 0.000039 0.000076 -0.000172 0.000153 0.002466 0.000039 0.000115 -0.000151 0.000153 0.002274 0.000039 0.000066 -0.000150 0.000142 0.003179 0.000040 0.000080 -0.000172 0.000159 0.002421 0.000039 0.000083 -0.000159 0.000142 0.002165 0.000037 0.000068 -0.000155 0.000150 0.002233 0.000041 0.000123 -0.000153 0.000158 0.002253 0.000039 0.000571 -0.000203 0.000145 0.002269 0.000041 0.000077 -0.000164 0.000158 0.002176 0.000038 0.000086 -0.000197 0.000144 0.002220 0.000041 0.000080 -0.000174 0.000403 0.002224 0.000039 0.000063 -0.000218 0.000144 0.002150 0.000036 0.000069 -0.000149 0.000141 0.002479 0.000040 0.000079 -0.000163 0.000145 0.002664 0.000039 0.000082 -0.000150 0.000152 0.002446 0.000040 0.000069 -0.000203 0.000154 0.002205 0.000043 0.000077 -0.000160 0.000143 0.002210 0.000039 0.000087 -0.000194 0.000145 0.002167 0.000038 0.000069 -0.000151 0.000154 0.002137 0.000036 0.000079 -0.000162 0.000140 0.002697 0.000037 0.000085 -0.000162 0.000143 0.002233 0.000039 0.000076 -0.000148 0.000144 0.002210 0.000039 0.000065 -0.000151 0.000152 0.003015 0.000041 0.000084 -0.000158 0.000156 0.002730 0.000039 0.000079 -0.000312 0.000165 0.002207 0.000038 0.000076 -0.000167 0.000139 0.002297 0.000040 0.000065 -0.000172 0.000154 0.002205 0.000037 0.000080 -0.000146 0.000149 0.002286 0.000039 0.000076 -0.000164 0.000151 0.002214 0.000038 0.000073 -0.000162 0.000169 0.003110 0.000038 0.000067 -0.000293 0.000144 0.002182 0.000038 0.000060 -0.000157 0.000153 0.003778 0.000049 0.000095 -0.001735 0.000210 0.004360 0.000050 0.000083 -0.000297 0.000198 0.002532 0.000039 0.000072 -0.000185 0.000163 0.002173 0.000039 0.000070 -0.000183 0.000142 0.002122 0.000038 0.000062 -0.000147 0.000145 0.002443 0.000039 0.000066 -0.000149 0.000144 0.002473 0.000040 0.000066 -0.000147 0.000139 0.002949 0.000038 0.000063 -0.000147 0.000139 0.002737 0.000039 0.000066 -0.000199 0.000142 0.002927 0.000038 0.000066 -0.000149 0.000141 0.002188 0.000038 0.000065 -0.000147 0.000144 0.002203 0.000038 0.000066 -0.000149 0.000141 0.002154 0.000037 0.000062 -0.000144 0.000137 0.003526 0.000037 0.000066 -0.000151 0.000153 0.002150 0.000036 0.000060 -0.000145 0.000138 0.002202 0.000037 0.000065 -0.000272 0.000187 0.002477 0.000038 0.000306 -0.000148 0.000141 0.002421 0.000038 0.000067 -0.000147 0.000141 0.002252 0.000039 0.000065 -0.000150 0.000140 0.002144 0.000037 0.000061 -0.000191 0.000144 0.002229 0.000038 0.000060 -0.000145 0.000145 0.002202 0.000038 0.000061 -0.000146 0.000142 0.002418 0.000038 0.000065 -0.000189 0.000171 0.002568 0.000040 0.000066 -0.000150 0.000141 0.002300 0.000039 0.000067 -0.000151 0.000141 0.002199 0.000038 0.000347 -0.000147 0.000140 0.002165 0.000035 0.000061 -0.000151 0.000646 0.002310 0.000040 0.000062 -0.000161 0.000410 0.002195 0.000038 0.000061 -0.000147 0.000141 0.002466 0.000039 0.000066 -0.000147 0.000141 0.003026 0.000038 0.000066 -0.000148 0.000142 0.002223 0.000038 0.000065 -0.000147 0.000142 0.002196 0.000038 0.000067 -0.000147 0.000141 0.002155 0.000044 0.000064 -0.000146 0.000140 0.002354 0.000039 0.000067 -0.000149 0.000143 0.002186 0.000037 0.000062 -0.000150 0.000144 0.002498 0.000040 0.000063 -0.000178 0.000212 0.002453 0.000039 0.000062 -0.000149 0.000177 0.002463 0.000038 0.000063 -0.000147 0.000142 0.002507 0.000038 0.000067 -0.000149 0.000142 0.002717 0.000038 0.000066 -0.000148 0.000141 0.002452 0.000037 0.000065 -0.000147 0.000140 0.002266 0.000039 0.000066 -0.000149 0.000141 0.002183 0.000037 0.000066 -0.000153 0.000142 0.002203 0.000039 0.000067 -0.000152 0.000419 0.002245 0.000040 0.000062 -0.000149 0.000181 0.002181 0.000038 0.000063 -0.000147 0.000142 0.002224 0.000039 0.000066 -0.000147 0.000142 0.002204 0.000038 0.000066 -0.000146 0.000141 0.002250 0.000038 0.000065 -0.000148 0.000141 0.002142 0.000038 0.000063 -0.000156 0.000139 0.002176 0.000036 0.000060 -0.000243 0.000148 0.002768 0.000039 0.000069 -0.000146 0.000204 0.002194 0.000037 0.000065 -0.000147 0.000143 0.003071 0.000039 0.000066 -0.000148 0.000144 0.003489 0.000042 0.000073 -0.000151 0.000151 0.002173 0.000039 0.000064 -0.000146 0.000140 0.003509 0.000038 0.000067 -0.000148 0.000142 0.002191 0.000038 0.000064 -0.000146 0.000139 0.002441 0.000039 0.000117 -0.000174 0.000141 0.002133 0.000038 0.000065 -0.000151 0.000142 0.002257 0.000039 0.000073 -0.000163 0.000147 0.002187 0.000038 0.000061 -0.000146 0.000222 0.002193 0.000038 0.000062 -0.000145 0.000143 0.002434 0.000037 0.000064 -0.000145 0.000139 0.002933 0.000041 0.000066 -0.000146 0.000140 0.002680 0.000037 0.000065 -0.000143 0.000139 0.002217 0.001029 0.000065 -0.000145 0.000139 0.002361 0.000039 0.000067 -0.000150 0.000143 0.002186 0.000068 0.000066 -0.000148 0.000142 0.002149 0.000037 0.000061 -0.000147 0.000181 0.002183 0.000037 0.000061 -0.000146 0.000455 0.002305 0.000038 0.000074 -0.000148 0.000143 0.002223 0.000038 0.000066 -0.000148 0.000141 0.002547 0.000038 0.000066 -0.000148 0.000143 0.002180 0.000038 0.000336 -0.000146 0.000141 0.002102 0.000037 0.000063 -0.000150 0.000145 0.002170 0.000037 0.000067 -0.000152 0.000138 0.002982 0.000038 0.000067 -0.000149 0.000143 0.002419 0.000037 0.000064 -0.000145 0.000195 0.002228 0.000040 0.000067 -0.000148 0.000143 0.002193 0.000038 0.000064 -0.000155 0.000141 0.002166 0.000067 0.000066 -0.000454 0.000176 0.002193 0.000038 0.000063 -0.000186 0.000142 0.002165 0.000035 0.000066 -0.000144 0.000138 0.002542 0.000038 0.000066 -0.000148 0.000143 0.002733 0.000039 0.000066 -0.000147 0.000141 0.002227 0.000038 0.000067 -0.000145 0.000142 0.002764 0.000037 0.000064 -0.000144 0.000138 0.002207 0.000037 0.000065 -0.000147 0.000185 0.002262 0.000038 0.000062 -0.000154 0.000160 0.002163 0.000038 0.000063 -0.000150 0.000145 0.002719 0.000038 0.000065 -0.000145 0.000139 0.002226 0.000037 0.000074 -0.000148 0.000140 0.002517 0.000038 0.000067 -0.000148 0.000142 0.003734 0.000039 0.000067 -0.000147 0.000143 0.002508 0.000039 0.000067 -0.000146 0.000143 0.002288 0.000038 0.000067 -0.000149 0.000143 0.002899 0.000039 0.000067 -0.000150 0.000145 0.002232 0.000037 0.000065 -0.000148 0.000142 0.002169 0.000039 0.000067 -0.000161 0.000141 0.002196 0.000036 0.000060 -0.000145 0.000137 0.002467 0.000040 0.000064 -0.000147 0.000141 0.002168 0.000037 0.000063 -0.000147 0.000139 0.002165 0.000037 0.000064 -0.000146 0.000138 0.002167 0.000036 0.000060 -0.000150 0.000141 0.002326 0.000039 0.000063 -0.000149 0.000179 0.002197 0.000039 0.000063 -0.000148 0.000142 0.002538 0.000039 0.000067 -0.000148 0.000148 0.002555 0.000039 0.000067 -0.000150 0.000144 0.002180 0.000038 0.000066 -0.000245 0.000152 0.002203 0.000038 0.000065 -0.000146 0.000142 0.002118 0.000036 0.000091 -0.000648 0.000141 0.002173 0.000035 0.000058 -0.000142 0.000149 0.002137 0.000037 0.000059 -0.000144 0.000138 0.002191 0.000037 0.000063 -0.000143 0.000137 0.002795 0.000039 0.000065 -0.000147 0.000256 0.002250 0.000038 0.000064 -0.000148 0.000142 0.002231 0.000040 0.000075 -0.000149 0.000143 0.002174 0.000038 0.000061 -0.000182 0.000708 0.002255 0.000038 0.000061 -0.000181 0.000170 0.002222 0.000038 0.000060 -0.000148 0.000141 0.002177 0.000038 0.000065 -0.000147 0.000141 0.002478 0.000039 0.000065 -0.000148 0.000141 0.002191 0.000039 0.000065 -0.000146 0.000139 0.002161 0.000067 0.000063 -0.000157 0.000138 0.002174 0.000036 0.000059 -0.000143 0.000165 0.002396 0.000040 0.000067 -0.000148 0.000141 0.002302 0.000044 0.000067 -0.000148 0.000142 0.002226 0.000043 0.000065 -0.000149 0.000142 0.002198 0.000038 0.000087 -0.000147 0.000143 0.002221 0.000039 0.000066 -0.000146 0.000142 0.002376 0.000065 0.000063 -0.000152 0.000154 0.002201 0.000038 0.000062 -0.000150 0.000142 0.002705 0.000039 0.000067 -0.000149 0.000142 0.002267 0.000039 0.000067 -0.000194 0.000149 0.002347 0.000039 0.000066 -0.000155 0.000141 0.002594 0.000038 0.000066 -0.000148 0.000141 0.002189 0.000038 0.000064 -0.000202 0.000142 0.002155 0.000039 0.000062 -0.000182 0.000146 0.002204 0.000037 0.000061 -0.000146 0.000139 0.002466 0.000037 0.000065 -0.000146 0.000140 0.002463 0.000036 0.000065 -0.000146 0.000139 0.002209 0.000037 0.000063 -0.000145 0.000138 0.002146 0.000036 0.000060 -0.000181 0.000142 0.003356 0.000038 0.000068 -0.000161 0.000142 0.002169 0.000038 0.000062 -0.000146 0.000175 0.002538 0.000039 0.000061 -0.000148 0.000141 0.002482 0.000039 0.000067 -0.000148 0.000144 0.002450 0.000040 0.000066 -0.000149 0.000143 0.002466 0.000043 0.000068 -0.000148 0.000144 0.003551 0.000038 0.000068 -0.000149 0.000142 0.002482 0.000039 0.000066 -0.000149 0.000142 0.002220 0.000039 0.000066 -0.000151 0.000140 0.002199 0.000038 0.000064 -0.000148 0.000184 0.002185 0.000038 0.000066 -0.000145 0.000140 0.002158 0.000036 0.000092 -0.000158 0.000140 0.002262 0.000038 0.000062 -0.000148 0.000143 0.002674 0.000039 0.000066 -0.000148 0.000140 0.002421 0.000039 0.000066 -0.000149 0.000149 0.002433 0.000038 0.000065 -0.000146 0.000172 0.002187 0.000038 0.000065 -0.000146 0.000140 0.002311 0.000039 0.000323 -0.000149 0.000142 0.002180 0.000038 0.000091 -0.000420 0.000143 0.002483 0.000038 0.000063 -0.000685 0.000145 0.002136 0.000035 0.000064 -0.000146 0.000145 0.002433 0.000038 0.000062 -0.000146 0.000139 0.002496 0.000039 0.000066 -0.000149 0.000139 0.003626 0.000041 0.000068 -0.000153 0.000147 0.002272 0.000042 0.000067 -0.000248 0.000155 0.002208 0.000038 0.000063 -0.000146 0.000138 0.002524 0.000038 0.000068 -0.000147 0.000140 0.002176 0.000210 0.000065 -0.000147 0.000140 0.002166 0.000036 0.000060 -0.000144 0.000146 0.002169 0.000036 0.000057 -0.000144 0.000138 0.002207 0.000037 0.000063 -0.000145 0.000138 0.002183 0.000037 0.000062 -0.000145 0.000137 0.002167 0.000036 0.000059 -0.000148 0.000453 0.002310 0.000038 0.000061 -0.000183 0.000855 0.002326 0.000037 0.000061 -0.000146 0.000175 0.002672 0.000036 0.000060 -0.000143 0.000140 0.002238 0.000039 0.000065 -0.000146 0.000139 0.002473 0.000037 0.000064 -0.000146 0.000139 0.002196 0.000039 0.000065 -0.000145 0.000139 0.002141 0.000036 0.000061 -0.000174 0.000397 0.002175 0.000036 0.000059 -0.000143 0.000139 0.002647 0.000037 0.000065 -0.000147 0.000138 0.002196 0.000037 0.000064 -0.000146 0.000138 0.002199 0.000037 0.000063 -0.000146 0.000138 0.002167 0.000036 0.000066 -0.000169 0.000141 0.002156 0.000036 0.000060 -0.000143 0.000139 0.002180 0.000037 0.000065 -0.000144 0.000136 0.002756 0.000039 0.000066 -0.000150 0.000141 0.002919 0.000039 0.000066 -0.000147 0.000140 0.002184 0.000036 0.000065 -0.000145 0.000138 0.002168 0.000036 0.000091 -0.000156 0.000139 0.002169 0.000036 0.000059 -0.000143 0.000139 0.002741 0.000038 0.000065 -0.000147 0.000140 0.002429 0.000037 0.000063 -0.000145 0.000139 0.002226 0.000037 0.000064 -0.000145 0.000139 0.003381 0.000040 0.000066 -0.000153 0.000141 0.002262 0.000038 0.000064 -0.000145 0.000140 0.002137 0.000036 0.000062 -0.000154 0.000650 0.002217 0.000038 0.000063 -0.000184 0.000143 0.002209 0.000038 0.000062 -0.000153 0.000142 0.002907 0.000039 0.000066 -0.000147 0.000142 0.002158 0.000038 0.000064 -0.000146 0.000140 0.002953 0.000039 0.000068 -0.000148 0.000143 0.002208 0.000039 0.000065 -0.000149 0.000139 0.002187 0.000036 0.000065 -0.000144 0.000139 0.002157 0.000036 0.000061 -0.000154 0.000926 0.002139 0.000036 0.000059 -0.000183 0.000140 0.002526 0.000038 0.000062 -0.000148 0.000142 0.002207 0.000038 0.000066 -0.000147 0.000139 0.002790 0.000039 0.000069 -0.000149 0.000144 0.002251 0.000038 0.000066 -0.000151 0.000140 0.002220 0.000039 0.000066 -0.000148 0.000142 0.002523 0.000038 0.000064 -0.000151 0.000138 0.002151 0.000037 0.000065 -0.000147 0.000140 0.002251 0.000037 0.000062 -0.000149 0.000139 0.002607 0.000037 0.000065 -0.000147 0.000141 0.003380 0.000037 0.000066 -0.000147 0.000139 0.002285 0.000069 0.000066 -0.000149 0.000142 0.002566 0.000038 0.000067 -0.000147 0.000142 0.002523 0.000038 0.000067 -0.000152 0.000143 0.002215 0.000038 0.000067 -0.000150 0.000144 0.002243 0.000038 0.000075 -0.000149 0.000141 0.002148 0.000036 0.000063 -0.000182 0.000144 0.002167 0.000036 0.000062 -0.000278 0.000155 0.002631 0.000036 0.000061 -0.000149 0.000139 0.003175 0.000040 0.000066 -0.000156 0.000140 0.002660 0.000038 0.000065 -0.000148 0.000141 0.006171 0.000067 0.000069 -0.000164 0.000142 0.002713 0.000038 0.000064 -0.000161 0.000150 0.002270 0.000038 0.000081 -0.000160 0.000283 0.002276 0.000038 0.000083 -0.000168 0.000150 0.002207 0.000037 0.000072 -0.000151 0.000669 0.002160 0.000038 0.000062 -0.000196 0.000156 0.002363 0.000036 0.000061 -0.000162 0.000141 0.002160 0.000037 0.000077 -0.000147 0.000141 0.002676 0.000038 0.000096 -0.000162 0.000143 0.002263 0.000037 0.000065 -0.000162 0.000141 0.002206 0.000036 0.000080 -0.000146 0.000139 0.002149 0.000036 0.000060 -0.000169 0.000884 0.002163 0.000036 0.000076 -0.000187 0.000140 0.002222 0.000036 0.000061 -0.000145 0.000140 0.002192 0.000037 0.000084 -0.000145 0.000138 0.002619 0.000039 0.000116 -0.000158 0.000149 0.002213 0.000038 0.000089 -0.000145 0.000183 0.002154 0.000038 0.000089 -0.000162 0.000142 0.002142 0.000037 0.000061 -0.000146 0.000178 0.002401 0.000038 0.000062 -0.000145 0.000150 0.002741 0.000037 0.000081 -0.000147 0.000139 0.002360 0.000040 0.000067 -0.000151 0.000153 0.002459 0.000039 0.000075 -0.000148 0.000155 0.002459 0.000037 0.000091 -0.000153 0.000152 0.002174 0.000036 0.000064 -0.000424 0.000149 0.002116 0.000036 0.000068 -0.000166 0.000168 0.002625 0.000038 0.000076 -0.000146 0.000141 0.002957 0.000038 0.000067 -0.000160 0.000142 0.002501 0.000039 0.000079 -0.000147 0.000143 0.002219 0.000038 0.000066 -0.000160 0.000143 0.002771 0.000040 0.000079 -0.000148 0.000150 0.002426 0.000037 0.000082 -0.000146 0.000138 0.002134 0.000036 0.000103 -0.000659 0.000143 0.002197 0.000036 0.000073 -0.000179 0.000153 0.002301 0.000038 0.000074 -0.000147 0.000142 0.002258 0.000038 0.000066 -0.000146 0.000141 0.002210 0.000038 0.000066 -0.000161 0.000141 0.002235 0.000038 0.000084 -0.000145 0.000138 0.002131 0.000036 0.000060 -0.000151 0.000211 0.002265 0.000038 0.000062 -0.000147 0.000142 0.002254 0.000038 0.000067 -0.000148 0.000143 0.002217 0.000038 0.000079 -0.000160 0.000155 0.002229 0.000038 0.000066 -0.000145 0.000142 0.002129 0.000038 0.000065 -0.000165 0.000140 0.002140 0.000036 0.000076 -0.000162 0.000142 0.002452 0.000039 0.000079 -0.000148 0.000143 0.002253 0.000059 0.000068 -0.000164 0.000142 0.003378 0.000039 0.000096 -0.000150 0.000194 0.002192 0.000039 0.000067 -0.000161 0.000152 0.002202 0.000037 0.000077 -0.000160 0.000141 0.002258 0.000039 0.000067 -0.000167 0.000143 0.002706 0.000039 0.000067 -0.000149 0.000155 0.002280 0.000037 0.000100 -0.000174 0.000144 0.002134 0.000037 0.000090 -0.001167 0.000154 0.002224 0.000038 0.000067 -0.000162 0.000155 0.002181 0.000035 0.000065 -0.000773 0.000153 0.002145 0.000036 0.000060 -0.000149 0.000161 0.002160 0.000036 0.000071 -0.000208 0.000144 0.002164 0.000035 0.000060 -0.000143 0.000138 0.002156 0.000036 0.000064 -0.000143 0.000138 0.002225 0.000055 0.000066 -0.000147 0.000141 0.002734 0.000038 0.000065 -0.000145 0.000147 0.002173 0.000037 0.000064 -0.000146 0.000139 0.002112 0.000037 0.000060 -0.000144 0.000137 0.002708 0.000038 0.000064 -0.000144 0.000139 0.002421 0.000037 0.000064 -0.000145 0.000140 0.002449 0.000037 0.000063 -0.000143 0.000138 0.002278 0.000038 0.000064 -0.000145 0.000140 0.002427 0.000040 0.000130 -0.000151 0.000142 0.002155 0.000036 0.000064 -0.000181 0.000139 0.002435 0.000036 0.000060 -0.000145 0.000138 0.003527 0.000038 0.000065 -0.000146 0.000178 0.002178 0.000036 0.000060 -0.000145 0.000138 0.002139 0.000037 0.000065 -0.000145 0.000137 0.003006 0.000037 0.000064 -0.000146 0.000139 0.002204 0.000037 0.000065 -0.000145 0.000139 0.002211 0.000038 0.000062 -0.000182 0.000140 0.002221 0.000036 0.000061 -0.000145 0.000139 0.003169 0.000038 0.000068 -0.000149 0.000174 0.002414 0.000038 0.000066 -0.000147 0.000142 0.002234 0.000038 0.000066 -0.000149 0.000143 0.002678 0.000038 0.000065 -0.000148 0.000141 0.002886 0.000038 0.000066 -0.000145 0.000140 0.002250 0.000038 0.000065 -0.000148 0.000139 0.002181 0.000035 0.000065 -0.000718 0.000142 0.002141 0.000035 0.000059 -0.000189 0.000140 0.002383 0.000036 0.000059 -0.000145 0.000139 0.002206 0.000039 0.000065 -0.000154 0.000186 0.002457 0.000038 0.000066 -0.000190 0.000141 0.002224 0.000038 0.000066 -0.000149 0.000141 0.002151 0.000037 0.000066 -0.000215 0.000143 0.002151 0.000035 0.000061 -0.000144 0.000138 0.002822 0.000039 0.000065 -0.000147 0.000139 0.002275 0.000038 0.000065 -0.000148 0.000141 0.002211 0.000036 0.000064 -0.000146 0.000138 0.002201 0.000037 0.000066 -0.000148 0.000140 0.002273 0.000038 0.000068 -0.000150 0.000144 0.002188 0.000037 0.000063 -0.000152 0.000151 0.002190 0.000037 0.000062 -0.000146 0.000142 0.003145 0.000039 0.000067 -0.000151 0.000139 0.002218 0.000037 0.000065 -0.000145 0.000138 0.002264 0.000037 0.000066 -0.000148 0.000142 0.003011 0.000039 0.000067 -0.000149 0.000141 0.002196 0.000038 0.000065 -0.000146 0.000141 0.002188 0.000036 0.000060 -0.000149 0.000140 0.002190 0.000035 0.000060 -0.000144 0.000137 0.002641 0.000038 0.000064 -0.000146 0.000138 0.002182 0.000043 0.000065 -0.000146 0.000141 0.002216 0.000036 0.000064 -0.000147 0.000139 0.002294 0.000039 0.000068 -0.000657 0.000145 0.002143 0.000037 0.000062 -0.000154 0.000415 0.002237 0.000040 0.000084 diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..a50fe51 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,161 @@ +'use strict'; + +const util = require('util'); +const gulp = require('gulp'); +const concat = require('gulp-concat'); +const terser = require('gulp-terser'); +const clean = require('gulp-clean-css'); +const settings = require('./settings.js'); +const minify = require('html-minifier').minify; + +const fs = require('fs'); +const markdown = require('markdown-it'); +const prism = require('markdown-it-prism'); +const nunjucks = require('nunjucks'); +const yaml = require('yaml'); +const slugify = require('slugify'); +const dayjs = require('dayjs'); + +const md = new markdown({ + html: true, + linkify: false, + typographer: true, + breaks: true, +}) + .use(prism) + .use(require('markdown-it-table').markdownItTable) + .use(require('markdown-it-deflist')) + .use(require('markdown-it-footnote')) + .use(require('markdown-it-anchor')) + .use(require('markdown-it-checkbox')) + +nunjucks.configure('layouts', { + autoescape: false, + noCache: true, +}); + +gulp.task('js', () => gulp.src(settings.assets.javascript) + .pipe(concat('bundle.js')) + .pipe(terser()) + .pipe(gulp.dest('tmp')) +); + +gulp.task('css', () => gulp.src(settings.assets.css) + .pipe(concat('bundle.css')) + .pipe(clean({})) + .pipe(gulp.dest('tmp')) +); + +gulp.task('generate-static', function (done) { + fs.readdir('content', function (err, items) { + + let posts = []; + items.forEach(item => { + if (item.endsWith('.md')) { + + processMarkdown(`content/${item}`); + + let contents = fs.readFileSync(`content/${item}`, 'utf8'); + let raw = contents.split('---'); + let meta = null; + + try { + meta = yaml.parse(raw[1]) + } catch (error) { } + + if (meta.layout == 'post') { + meta.dateFormatted = dayjs(meta.date).format('MMMM D, YYYY'); + meta.dateOriginal = meta.date; + meta.date = new Date(meta.date); + posts.push(meta) + } + } + }); + + const css = fs.readFileSync('tmp/bundle.css', 'utf8'); + const javascript = fs.readFileSync('tmp/bundle.js', 'utf8'); + + let page = nunjucks.render(`index.njk`, { + css: ``, + javascript: ``, + currentYear: new Date().getFullYear(), + timestamp: Math.floor(Date.now() / 1000), + vars: settings.vars, + posts: posts.reverse(), + }); + + util.log(`Processing: Index`); + + fs.writeFileSync(`public/index.html`, minify(page, { + removeAttributeQuotes: true, + collapseWhitespace: true, + removeComments: true, + removeTagWhitespace: true, + })); + + }); + + done(); +}); + +const processMarkdown = (file) => { + const contents = fs.readFileSync(file, 'utf8'); + let raw = contents.split('---'); + let meta = null; + + try { + meta = yaml.parse(raw[1]) + } catch (error) { } + + //const slug = slugify(meta.title, { lower: true }); + const slug = meta.slug; + const css = fs.readFileSync('tmp/bundle.css', 'utf8'); + const javascript = fs.readFileSync('tmp/bundle.js', 'utf8'); + + raw.shift(); + raw.shift(); + + let post = nunjucks.render(`${meta.layout}.njk`, { + content: md.render(raw.join('')), + title: meta.title.substring(0, 65), + description: meta.description, + css: ``, + javascript: ``, + slug: slug, + currentYear: new Date().getFullYear(), + timestamp: Math.floor(Date.now() / 1000), + vars: settings.vars, + writtenDate: { + formatted: dayjs(meta.date).format('MMMM D, YYYY'), + original: meta.date, + }, + }); + + util.log(`Processing: ${meta.title}`); + + fs.writeFileSync(`public/${slug}.html`, minify(post, { + removeAttributeQuotes: true, + collapseWhitespace: true, + removeComments: true, + removeTagWhitespace: true, + })); +}; + +const watchers = (done) => { + gulp.watch('source/*.css', { + awaitWriteFinish: true, + }).on('change', gulp.series('css')); + + gulp.watch('source/*.js', { + awaitWriteFinish: true, + }).on('change', gulp.series('js')); + + gulp.watch('content/*.md', { + awaitWriteFinish: true, + }).on('change', processMarkdown); + + done(); +} + +gulp.task('dev', gulp.parallel(watchers)); +gulp.task('build', gulp.series('css', 'js', 'generate-static')); diff --git a/index.md b/index.md deleted file mode 100644 index 860b64a..0000000 --- a/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Mitja Felicijan - Embedded systems developer -description: Embedded systems developer and fanatical fan of science fiction -layout: index ---- diff --git a/layouts/footer.njk b/layouts/footer.njk new file mode 100644 index 0000000..b0d3702 --- /dev/null +++ b/layouts/footer.njk @@ -0,0 +1,25 @@ + + + + + + + diff --git a/layouts/index.njk b/layouts/index.njk new file mode 100644 index 0000000..6a2441f --- /dev/null +++ b/layouts/index.njk @@ -0,0 +1,57 @@ + + + + + + + + + + + + {{ vars.title }} + + + + + + + + + + + + + + + + {{ css }} + + + + + +
+ + {% include "navigation.njk" %} + + + + {{ javascript }} + + {% include "footer.njk" %} + +
+ + + + diff --git a/layouts/navigation.njk b/layouts/navigation.njk new file mode 100644 index 0000000..2f73825 --- /dev/null +++ b/layouts/navigation.njk @@ -0,0 +1,39 @@ + + + + diff --git a/layouts/page.njk b/layouts/page.njk new file mode 100644 index 0000000..1e9aa4d --- /dev/null +++ b/layouts/page.njk @@ -0,0 +1,56 @@ + + + + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + {{ css }} + + + + + +
+ + {% include "navigation.njk" %} + +
+ +
+

{{ title }}

+
+ + {{ content }} + +
+ + {{ javascript }} + + {% include "footer.njk" %} + +
+ + + + diff --git a/layouts/post.njk b/layouts/post.njk new file mode 100644 index 0000000..2fc0f7b --- /dev/null +++ b/layouts/post.njk @@ -0,0 +1,59 @@ + + + + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + {{ css }} + + + + + +
+ + {% include "navigation.njk" %} + +
+ +
+

{{ title }}

+

Published on + + by {{ vars.author }}

+
+ + {{ content|safe }} + +
+ + {{ javascript }} + + {% include "footer.njk" %} + +
+ + + + diff --git a/learn/python-0001.md b/learn/python-0001.md deleted file mode 100644 index 43ad167..0000000 --- a/learn/python-0001.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -layout: page -title: Learn Python by working on a project -description: Couple of observations regarding project management. ---- - -Application will fetch and cache Flickr feed and in the second phase display these images on a webpage. - -``$ y=\sum_{i=1}^n g(x_i) $`` - -Categories: Python, Bottlepy, SQLite3, RSS - -**Table of contents** - -- [Prepare environment](#prepare-environment) -- [sdfsd](#sdfsd) - -#### Prepare environment - -Over the years I had privilege to work on some very. - -```go -package main - -func dummy_benchmark() { - fmt.Println("sencond set ...") - for i := 0; i < 9182312232; i++ { - i *= 2 - i /= 2 - } -} -``` -#### sdfsd - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mollis tempus sodales. Nulla sit amet laoreet ligula. Quisque fermentum auctor congue. Nulla dignissim enim neque, efficitur commodo enim condimentum iaculis. - -```css -body { - text-align: center; -} -``` -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mollis tempus sodales. Nulla sit amet laoreet ligula. Quisque fermentum auctor congue. Nulla dignissim enim neque, efficitur commodo enim condimentum iaculis. - - - diff --git a/notes.txt b/notes.txt deleted file mode 100644 index b859e08..0000000 --- a/notes.txt +++ /dev/null @@ -1 +0,0 @@ -https://devhints.io/jekyll diff --git a/package.json b/package.json new file mode 100644 index 0000000..c13ef46 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "blog", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "dev": "gulp dev", + "build": "gulp build" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "dayjs": "^1.8.6", + "gulp": "^4.0.0", + "gulp-clean-css": "^4.0.0", + "gulp-concat": "^2.6.1", + "gulp-terser": "^1.1.7", + "html-minifier": "^3.5.21", + "http-server": "^0.11.1", + "markdown-it": "^8.4.2", + "markdown-it-anchor": "^5.0.2", + "markdown-it-checkbox": "^1.1.0", + "markdown-it-deflist": "^2.0.3", + "markdown-it-footnote": "^3.0.1", + "markdown-it-prism": "^2.0.1", + "markdown-it-table": "^2.0.4", + "nunjucks": "^3.1.7", + "slugify": "^1.3.4", + "yaml": "^1.3.2" + } +} diff --git a/public/curriculum-vitae.html b/public/curriculum-vitae.html new file mode 100644 index 0000000..8dc2be2 --- /dev/null +++ b/public/curriculum-vitae.html @@ -0,0 +1,27 @@ +Curriculum Vitae

Curriculum Vitae

Mitja Felicijan
Embedded systems developer
mitja.felicijan@gmail.com
Slovenia, EU

Technical experience

  • Key languages: Golang, Python, C/C++, Bash, C#, Java, Perl.
  • Platforms: GNU/Linux, Arch, Debian, Gentoo, Red Hat, Custom distros.
  • Fields of study: Zigbee, KNX, Modbus, Machine to Machine, Embedded systems, Operating systems, Distributed systems, IOT, RDBMS, Algorithms, Database engine design, SQL, NoSQL, NewSQL, Big data analytics, Machine learning, Prediction algorithms, Realtime analytics, Systems automation.

Major projects

  • SMS marketing system (2007)
  • Yacht management software (2008)
  • Smart Home Gateway (2009)
  • Moxa UPort 1130 USB to RS485 Universal Linux driver (2009)
  • Remote management of electricity meter (2009)
  • Remote management of blood pressure monitor (2010)
  • Infomat automation system (2010)
  • GPS Tourist - GIS Software (2011)
  • Minimal GNU/Linux distribution for embedded platforms (2011)
  • Digital Jukebox system (2012)
  • NanoCloudLogger - Machine to Machine (2012)
  • Street Lightning System (2012)
  • Smart cabins with hardware sensor management (2013)
  • Contextual advertising server (2015)
  • Network accessible database engine for caching and in-memory storage (2016)
  • Tick database engine specifically designed for storing and processing large amount of sensor data with high write throughput (2016)
  • Wireless industrial lighting management system - hardware and software (2016)
  • Minimal configuration reverse proxy (2017)
  • Industrial IOT platform for deployment on on-premise (2018)

Employment history

  • Freelancer (2001 – Present)
  • Software developer at Mobinia (2005 – 2007)
  • CTO at Milk (2007 – 2009)
  • Founder and CTO of UTS (2009 – 2014)
  • Founding member of Origami Group (2014 – 2017)
  • Senior Software Engineer at TSmedia (2015 - 2017)

Awards

  • Regional Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010
  • National Award for Innovation by Chamber of Commerce and Industry of Slovenia for project Intelligent system management and regulation of Street Lighting, 2010

Key responsibilities

  • Responsible for embedded platforms development.
  • Responsible for hardware design and driver development.
  • Responsible for the designing, develop and test the systems.
  • Responsible for implementation of the systems.
  • Responsible for writing and maintaining user and technical documents.
  • Responsible for development and maintenance of the project.
  • Responsible for code revision, testing and output.
  • Work on the enhancement suggested by the customers and fixes the bugs reported.)
\ No newline at end of file diff --git a/public/encoding-binary-data-into-dna-sequence.html b/public/encoding-binary-data-into-dna-sequence.html new file mode 100644 index 0000000..e89e5c4 --- /dev/null +++ b/public/encoding-binary-data-into-dna-sequence.html @@ -0,0 +1,170 @@ +Encoding binary data into DNA sequence

Encoding binary data into DNA sequence

Published on by Mitja Felicijan

Table of contents

  1. Initial thoughts
  2. Glossary
  3. Data encoding
  4. Quick history of DNA
  5. What is DNA?
  6. Encode binary data into DNA sequence
    1. Basic Encoding
    2. FASTA file format
    3. PNG encoded DNA sequence
  7. Encoding text file in practice
  8. Toolkit for encoding data
    1. dnae-encode
    2. dnae-png
  9. Benchmarks
  10. References

Initial thoughts

Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it. Well, this is all possible now. It was not done on a large scale because it is quite expensive to create DNA strands but it’s possible.

Encoding data into DNA sequence is relatively simple process once you understand the relationship between binary data and nucleotides and scientists have been making large leaps in this field in order to provide viable long-term storage solution for our data that would potentially survive our specie if case of global disaster. We could imprint all the world’s knowledge into plants and ensure the survival of our knowledge.

More optimistic usage for this technology would be easier storage of ever growing data we produce every day. Once machines for sequencing DNA become fast enough and cheaper this could mean the next evolution of storing data and abandoning classical hard and solid state drives in data warehouses.

As we currently stand this is still not viable but it is quite an amazing and cool technology.

My interests in this field are purely in encoding processes and experimental testing mainly because I don’t have the access to this expensive machines. My initial goal was to create a toolkit that can be used by everybody to encode their data into a proper DNA sequence.

Glossary

deoxyribose
A five-carbon sugar molecule with a hydrogen atom rather than a hydroxyl group in the 2′ position; the sugar component of DNA nucleotides.
double helix
The molecular shape of DNA in which two strands of nucleotides wind around each other in a spiral shape.
nitrogenous base
A nitrogen-containing molecule that acts as a base; often referring to one of the purine or pyrimidine components of nucleic acids.
phosphate group
A molecular group consisting of a central phosphorus atom bound to four oxygen atoms.
RGB
The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors.
GCC
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages.

Data encoding

TL;DR: Encoding involves the use of a code to change original data into a form that can be used by an external process [1].

Encoding is the process of converting data into a format required for a number of information processing needs, including:

  • Program compiling and execution
  • Data transmission, storage and compression/decompression
  • Application data processing, such as file conversion

Encoding can have two meanings[1:1]:

  • In computer technology, encoding is the process of applying a specific code, such as letters, symbols and numbers, to data for conversion into an equivalent cipher.
  • In electronics, encoding refers to analog to digital conversion.

Quick history of DNA

  • 1869 - Friedrich Miescher identifies “nuclein”.
  • 1900s - The Eugenics Movement.
  • 1900 – Mendel’s theories are rediscovered by researchers.
  • 1944 - Oswald Avery identifies DNA as the ‘transforming principle’.
  • 1952 - Rosalind Franklin photographs crystallized DNA fibres.
  • 1953 - James Watson and Francis Crick discover the double helix structure of DNA.
  • 1965 - Marshall Nirenberg is the first person to sequence the bases in each codon.
  • 1983 - Huntington’s disease is the first mapped genetic disease.
  • 1990 - The Human Genome Project begins.
  • 1995 - Haemophilus Influenzae is the first bacterium genome sequenced.
  • 1996 - Dolly the sheep is cloned.
  • 1999 - First human chromosome is decoded.
  • 2000 – Genetic code of the fruit fly is decoded.
  • 2002 – Mouse is the first mammal to have its genome decoded.
  • 2003 – The Human Genome Project is completed.
  • 2013 – DNA Worldwide and Eurofins Forensic discover identical twins have differences in their genetic makeup [2].

What is DNA?

Deoxyribonucleic acid, a self-replicating material which is present in nearly all living organisms as the main constituent of chromosomes. It is the carrier of genetic information.

The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pies were made in the interiors of collapsing stars. We are made of starstuff.

– Carl Sagan, Cosmos

The nucleotide in DNA consists of a sugar (deoxyribose), one of four bases (cytosine ©, thymine (T), adenine (A), guanine (G)), and a phosphate. Cytosine and thymine are pyrimidine bases, while adenine and guanine are purine bases. The sugar and the base together are called a nucleoside.

DNA

DNA (a) forms a double stranded helix, and (b) adenine pairs with thymine and cytosine pairs with guanine. (credit a: modification of work by Jerome Walker, Dennis Myts) [3]

Encode binary data into DNA sequence

As an input file you can use any file you want:

  • ASCII files,
  • Compiled programs,
  • Multimedia files (MP3, MP4, MVK, etc),
  • Images,
  • Database files,
  • etc.

Note: If you would copy all the bytes from RAM to file or pipe data to file you could encode also this data as long as you provide file pointer to the encoder.

Basic Encoding

As already mentioned, the Basic Encoding is based on a simple mapping. Since DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually referred using the first letter). Using this technique we can encode

$$ log_2(4) = log_2(2^2) = 2 bits $$

using a single nucleotide. In this way, we are able to use the 4 bases that compose the DNA strand to encode each byte of data.

Two bitsNucleotides
00A (Adenine)
10G (Guanine)
01C (Cytosine)
11T (Thymine)

With this in mind we can simply encode any data by using two-bit to Nucleotides conversion

{ Algorithm 1: Naive byte array to DNA encode }
+procedure EncodeToDNASequence(f) string
+begin
+  enc string
+  while not eof(f) do
+    c byte := buffer[0]                             { Read 1 byte from buffer }
+    bin integer := sprintf('08b', c)                { Convert to string binary }
+    for e in range[0, 2, 4, 6] do
+      if e[0] == 48 and e[1] == 48 then             { 0x00 - A (Adenine) }
+        enc += 'A'
+      else if e[0] == 48 and e[1] == 49 then        { 0x01 - G (Guanine) }
+        enc += 'G'
+      else if e[0] == 49 and e[1] == 48 then        { 0x10 - C (Cytosine) }
+        enc += 'C'
+      else if e[0] == 49 and e[1] == 49 then        { 0x11 - T (Thymine) }
+        enc += 'T'
+  return enc                                        { Return DNA sequence }
+end
+

Another encoding would be Goldman encoding. Using this encoding helps with Nonsense mutation (amino acids replaced by a stop codon) that occurs and is the most problematic during translation because it leads to truncated amino acid sequences, which in turn results in truncated proteins. [4]

Where to store big data? In DNA: Nick Goldman at TEDxPrague

FASTA file format

In bioinformatics, FASTA format is a text-based format for representing either nucleotide sequences or peptide sequences, in which nucleotides or amino acids are represented using single-letter codes. The format also allows for sequence names and comments to precede the sequences. The format originates from the FASTA software package, but has now become a standard in the field of bioinformatics. [5]

The first line in a FASTA file started either with a “>” (greater-than) symbol or, less frequently, a “;” (semicolon) was taken as a comment. Subsequent lines starting with a semicolon would be ignored by software. Since the only comment used was the first, it quickly became used to hold a summary description of the sequence, often starting with a unique library accession number, and with time it has become commonplace to always use “>” for the first line and to not use “;” comments (which would otherwise be ignored).

;LCBO - Prolactin precursor - Bovine
+; a sample sequence in FASTA format
+MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS
+EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL
+VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED
+ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC*
+
+>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken
+ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID
+FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA
+DIDGDGQVNYEEFVQMMTAK*
+
+>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
+LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
+EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
+LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
+GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
+IENY
+

FASTA format was extended by FASTQ format from the Sanger Centre in Cambridge.

PNG encoded DNA sequence

| Nucleotides | RGB | Color name |
| | – | - |
| A (Adenine) | (0,0,255) | Blue |
| G (Guanine) | (0,100,0) | Green |
| C (Cytosine) | (255,0,0) | Red |
| T (Thymine) | (255,255,0) | Yellow |

With this in mind we can create a simple algorithm to create PNG representation of a DNA sequence.

{ Algorithm 2: Naive DNA to PNG encode from FASTA file }
+procedure EncodeDNASequenceToPNG(f)
+begin
+  i image
+  while not eof(f) do
+    c char := buffer[0]                             { Read 1 char from buffer }
+    case c of
+      'A': color := RGB(0, 0, 255)                  { Blue }
+      'G': color := RGB(0, 100, 0)                  { Green }
+      'C': color := RGB(255, 0, 0)                  { Red }
+      'T': color := RGB(255, 255, 0)                { Yellow }
+    drawRect(i, [x, y], color)
+  save(i)                                           { Save PNG image }
+end
+

Encoding text file in practice

In this example we will take a simple text file as our input stream for encoding. This file will have a quote from Niels Bohr and saved as txt file.

How wonderful that we have met with a paradox. Now we have some hope of making progress.
― Niels Bohr

First we encode text file into FASTA file.

./dnae-encode -i quote.txt -o quote.fa
+2019/01/10 00:38:29 Gathering input file stats
+2019/01/10 00:38:29 Starting encoding ...
+ 106 B / 106 B [==================================] 100.00% 0s
+2019/01/10 00:38:29 Saving to FASTA file ...
+2019/01/10 00:38:29 Output FASTA file length is 438 B
+2019/01/10 00:38:29 Process took 987.263µs
+2019/01/10 00:38:29 Done ...
+

Output of quote.fa file contains the encoded DNA sequence in ASCII format.

>SEQ1
+GACAGCTTGTGTACAAGTGTGCTTGCTCGCGAGCGGGTACGCGCGTGGGCTAACAAGTGA
+GCCAGCAGGTGAACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGCTGGCGGGTGA
+ACAAGTGTGCCGGTGAGCCAACAAGCAGACAAGTAAGCAGGTACGCAGGCGAGCTTGTCA
+ACTCACAAGATCGCTTGTGTACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGTAT
+GCTTGCTGGCGGACAAGCCAGCTTGTAAGCGGACAAGCTTGCGCACAAGCTGGCAGGCCT
+GCCGGCTCGCGTACAAATTCACAAGTAAGTACGCTTGCGTGTACGCGGGTATGTATACTC
+AACCTCACCAAACGGGACAAGATCGCCGGCGGGCTAGTATACAAGAACGCTTGCCAGTAC
+AACC
+

Then we encode FASTA file from previous operation to encode this data into PNG.

./dnae-png -i quote.fa -o quote.png
+2019/01/10 00:40:09 Gathering input file stats ...
+2019/01/10 00:40:09 Deconstructing FASTA file ...
+2019/01/10 00:40:09 Compositing image file ...
+ 424 / 424 [==================================] 100.00% 0s
+2019/01/10 00:40:09 Saving output file ...
+2019/01/10 00:40:09 Output image file length is 1.1 kB
+2019/01/10 00:40:09 Process took 19.036117ms
+2019/01/10 00:40:09 Done ...
+

After encoding into PNG format this file looks like this.

Encoded Quote in PNG format

The larger the input stream is the larger the PNG file would be.

Compiled basic Hello World C program with GCC would look like.

// gcc -O3 -o sample sample.c
+#include <stdio.h>
+
+main() {
+  printf("Hello, world!\n");
+  return 0;
+}
+

Toolkit for encoding data

I have created a toolkit with two main programs:

  • dnae-encode (encodes file into FASTA file)
  • dnae-png (encodes FASTA file into PNG)

Toolkit with full source code is available on github.com/mitjafelicijan/dna-encoding.

dnae-encode

> ./dnae-encode --help
+usage: dnae-encode --input=INPUT [<flags>]
+
+A command-line application that encodes file into DNA sequence.
+
+Flags:
+      --help             Show context-sensitive help (also try --help-long and --help-man).
+  -i, --input=INPUT      Input file (ASCII or binary) which will be encoded into DNA sequence.
+  -o, --output="out.fa"  Output file which stores DNA sequence in FASTA format.
+  -s, --sequence=SEQ1    The description line (defline) or header/identifier line, gives a name and/or a unique identifier for the sequence.
+  -c, --columns=60       Row characters length (no more than 120 characters). Devices preallocate fixed line sizes in software.
+      --version          Show application version.
+

dnae-png

> ./dnae-png --help
+usage: dnae-png --input=INPUT [<flags>]
+
+A command-line application that encodes FASTA file into PNG image.
+
+Flags:
+      --help              Show context-sensitive help (also try --help-long and --help-man).
+  -i, --input=INPUT       Input FASTA file which will be encoded into PNG image.
+  -o, --output="out.png"  Output file in PNG format that represents DNA sequence in graphical way.
+  -s, --size=10           Size of pairings of DNA bases on image in pixels (lower resolution lower file size).
+      --version           Show application version.
+

Benchmarks

First we generate some binary sample data with dd.

dd if=<(openssl enc -aes-256-ctr  -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) of=1KB.bin bs=1KB count=1 iflag=fullblock
+

Our freshly generated 1KB file looks something like this (its full of garbage data as intended).

Sample binary file 1KB

We create following binary files:

  • 1KB.bin
  • 10KB.bin
  • 100KB.bin
  • 1MB.bin
  • 10MB.bin
  • 100MB.bin

After this we create FASTA files for all the binary files by encoding them into DNA sequence.

./dnae-encode -i 100MB.bin -o 100MB.fa
+

Then we GZIP all the FASTA files to see how much the can be compressed.

gzip -9 < 10MB.fa > 10MB.fa.gz
+

Speed of encoding binary file into FASTA format.

File sizes of encoded files and also GZIP-ed variations.

Download ODS file with benchmarks..

References


  1. https://www.techopedia.com/definition/948/encoding ↩︎ ↩︎

  2. https://www.dna-worldwide.com/resource/160/history-dna-timeline ↩︎

  3. https://opentextbc.ca/biology/chapter/9-1-the-structure-of-dna/ ↩︎

  4. https://arxiv.org/abs/1801.04774 ↩︎

  5. https://en.wikipedia.org/wiki/FASTA_format ↩︎

\ No newline at end of file diff --git a/public/files/copy-benchmarks.tsv b/public/files/copy-benchmarks.tsv new file mode 100644 index 0000000..c7a7af4 --- /dev/null +++ b/public/files/copy-benchmarks.tsv @@ -0,0 +1,101 @@ +10KB 100KB 1MB 10MB +0.15 0.187 0.317 0.653 +0.158 0.237 0.192 0.659 +0.134 0.359 0.236 0.604 +0.136 0.292 0.196 0.501 +4.411 4.479 4.376 0.649 +0.134 0.481 0.265 0.608 +0.146 0.266 0.28 0.516 +4.282 0.307 4.549 0.562 +0.152 0.28 0.229 0.512 +0.162 0.37 0.315 0.652 +0.13 4.735 0.222 5.171 +4.29 8.767 0.283 5.076 +4.555 4.682 0.318 4.941 +4.658 4.691 0.177 9.624 +4.778 4.791 4.415 5.114 +8.794 8.604 0.311 5.223 +4.582 4.727 0.234 9.28 +4.596 4.638 0.212 5.064 +4.7 4.65 4.458 5.221 +8.822 9.159 0.191 5.032 +4.628 4.641 0.324 9.226 +4.6 4.921 0.197 5.22 +8.85 4.58 4.405 5.245 +4.65 9.142 0.215 5.168 +4.884 6.67 0.248 9.273 +4.581 4.594 0.248 5.082 +8.864 4.844 4.502 5.121 +4.704 4.656 0.177 5.173 +4.616 8.883 0.209 9.334 +4.729 4.962 4.366 4.966 +8.918 4.682 0.186 6.702 +4.686 4.58 0.168 5.111 +5.123 8.84 4.747 5.084 +4.846 4.732 8.85 5.065 +8.887 4.639 4.824 9.286 +4.681 8.897 4.791 5.104 +4.649 4.682 4.835 5.194 +8.847 4.663 8.929 5.271 +4.568 4.604 4.762 9.444 +4.657 8.74 4.772 5.076 +4.636 4.724 4.838 5.168 +8.778 4.846 9.065 5.057 +4.995 4.571 5.074 9.314 +2.343 9.222 4.818 5.732 +4.742 4.646 8.909 5.32 +4.82 4.842 4.778 5.167 +8.791 4.66 4.759 5.157 +4.835 8.944 4.804 9.323 +4.599 5.594 8.952 5.299 +4.809 4.628 1.567 5.294 +8.744 4.771 5.59 5.018 +4.71 8.919 4.771 9.257 +4.704 4.7 9.003 5.064 +4.765 4.605 4.781 5.185 +8.866 4.669 4.844 5.392 +4.897 8.925 4.786 9.279 +4.568 5.168 8.893 5.1 +4.679 4.757 5.41 5.232 +8.922 4.702 4.7 1.984 +4.669 8.721 4.906 5.366 +4.707 4.555 8.96 5.245 +8.938 4.615 4.89 5.216 +4.608 4.621 4.677 9.237 +4.58 8.954 4.908 5.194 +4.707 4.575 8.968 5.017 +8.822 4.781 4.882 9.714 +4.674 8.833 4.834 5.02 +5.005 4.689 4.762 5.312 +4.732 4.799 9.111 5.286 +8.894 4.675 4.936 5.185 +4.747 8.764 4.739 9.312 +4.785 4.749 4.845 5.34 +4.656 4.705 9.181 5.256 +8.899 4.601 4.739 5.261 +4.594 8.813 4.576 9.329 +4.585 4.716 8.813 5.343 +8.718 4.723 4.819 5.092 +4.725 4.757 4.83 5.061 +4.737 8.899 4.772 9.488 +4.692 4.717 8.831 5.13 +8.841 4.951 4.787 5.309 +4.66 8.895 4.746 5.228 +4.749 4.595 4.833 5.26 +4.715 4.615 8.928 9.381 +8.849 4.651 4.826 5.289 +4.66 8.897 4.802 5.197 +4.588 4.844 4.883 9.311 +4.753 4.888 9.053 5.072 +8.841 4.737 4.75 5.157 +4.794 8.976 5.063 5.196 +4.544 4.673 9.036 9.335 +8.74 4.654 6.377 5.29 +4.729 4.752 5.001 5.048 +4.654 8.98 4.873 5.544 +4.9 4.606 4.723 5.192 +8.757 4.802 5.427 9.056 +4.859 8.969 4.816 5.3 +4.701 4.662 9.002 5.138 +4.943 4.813 4.894 5.15 +8.772 4.721 4.785 9.168 diff --git a/public/files/dev101-git-topics-1.png b/public/files/dev101-git-topics-1.png new file mode 100644 index 0000000..bb09380 Binary files /dev/null and b/public/files/dev101-git-topics-1.png differ diff --git a/public/files/dev101-git-topics-2.png b/public/files/dev101-git-topics-2.png new file mode 100644 index 0000000..39a370a Binary files /dev/null and b/public/files/dev101-git-topics-2.png differ diff --git a/public/files/dna-sequence/benchmarks.ods b/public/files/dna-sequence/benchmarks.ods new file mode 100644 index 0000000..62a8e30 Binary files /dev/null and b/public/files/dna-sequence/benchmarks.ods differ diff --git a/public/files/dna-sequence/chart-encoding-speed.png b/public/files/dna-sequence/chart-encoding-speed.png new file mode 100644 index 0000000..7fb106d Binary files /dev/null and b/public/files/dna-sequence/chart-encoding-speed.png differ diff --git a/public/files/dna-sequence/chart-file-sizes.png b/public/files/dna-sequence/chart-file-sizes.png new file mode 100644 index 0000000..31bfa66 Binary files /dev/null and b/public/files/dna-sequence/chart-file-sizes.png differ diff --git a/public/files/dna-sequence/dna-basics.jpg b/public/files/dna-sequence/dna-basics.jpg new file mode 100644 index 0000000..c2e7f52 Binary files /dev/null and b/public/files/dna-sequence/dna-basics.jpg differ diff --git a/public/files/dna-sequence/quote.png b/public/files/dna-sequence/quote.png new file mode 100644 index 0000000..09fb01c Binary files /dev/null and b/public/files/dna-sequence/quote.png differ diff --git a/public/files/dna-sequence/sample-binary-file.png b/public/files/dna-sequence/sample-binary-file.png new file mode 100644 index 0000000..1e4622a Binary files /dev/null and b/public/files/dna-sequence/sample-binary-file.png differ diff --git a/public/files/dna-sequence/sample.png b/public/files/dna-sequence/sample.png new file mode 100644 index 0000000..30f12da Binary files /dev/null and b/public/files/dna-sequence/sample.png differ diff --git a/public/files/fuse-droplets.png b/public/files/fuse-droplets.png new file mode 100644 index 0000000..d7ce243 Binary files /dev/null and b/public/files/fuse-droplets.png differ diff --git a/public/files/fuse-spaces.png b/public/files/fuse-spaces.png new file mode 100644 index 0000000..4dcc1c5 Binary files /dev/null and b/public/files/fuse-spaces.png differ diff --git a/public/files/golang-profiling-cpu.pdf b/public/files/golang-profiling-cpu.pdf new file mode 100644 index 0000000..15241cb Binary files /dev/null and b/public/files/golang-profiling-cpu.pdf differ diff --git a/public/files/golang-profiling-mem.pdf b/public/files/golang-profiling-mem.pdf new file mode 100644 index 0000000..822e445 Binary files /dev/null and b/public/files/golang-profiling-mem.pdf differ diff --git a/public/files/iot-app-output.png b/public/files/iot-app-output.png new file mode 100644 index 0000000..1c80589 Binary files /dev/null and b/public/files/iot-app-output.png differ diff --git a/public/files/iot-rest-example.png b/public/files/iot-rest-example.png new file mode 100644 index 0000000..3ed86aa Binary files /dev/null and b/public/files/iot-rest-example.png differ diff --git a/public/files/iot-sqlite-db.png b/public/files/iot-sqlite-db.png new file mode 100644 index 0000000..82e1e29 Binary files /dev/null and b/public/files/iot-sqlite-db.png differ diff --git a/public/files/kcachegrind.png b/public/files/kcachegrind.png new file mode 100644 index 0000000..0dc48ab Binary files /dev/null and b/public/files/kcachegrind.png differ diff --git a/public/files/profiling-viewer.png b/public/files/profiling-viewer.png new file mode 100644 index 0000000..a450513 Binary files /dev/null and b/public/files/profiling-viewer.png differ diff --git a/public/files/simple-iot-application-overview.svg b/public/files/simple-iot-application-overview.svg new file mode 100644 index 0000000..817666d --- /dev/null +++ b/public/files/simple-iot-application-overview.svg @@ -0,0 +1,2 @@ + +
Database
Database
Web application


[Not supported by viewer]
Write
datapoint
[Not supported by viewer]
Read
datapoints
[Not supported by viewer]
Arduino
MKR1000
[Not supported by viewer]
Web browser
Web browser
Route: /
[Not supported by viewer]
Route: /api
[Not supported by viewer]
\ No newline at end of file diff --git a/public/files/simple-iot-application.zip b/public/files/simple-iot-application.zip new file mode 100644 index 0000000..46d3205 Binary files /dev/null and b/public/files/simple-iot-application.zip differ diff --git a/public/files/snakeviz.png b/public/files/snakeviz.png new file mode 100644 index 0000000..5bab395 Binary files /dev/null and b/public/files/snakeviz.png differ diff --git a/public/files/sqlite-benchmarks.tsv b/public/files/sqlite-benchmarks.tsv new file mode 100644 index 0000000..daa2c21 --- /dev/null +++ b/public/files/sqlite-benchmarks.tsv @@ -0,0 +1,1001 @@ +DROPTABLE CREATETABLE INSERTMANY FETCHALL COMMIT +0.000732 0.000400 0.008133 0.000065 0.000166 +0.000200 0.000214 0.003105 0.000043 0.000171 +0.000246 0.000170 0.006594 0.000044 0.000101 +0.000182 0.000166 0.003892 0.000043 0.000112 +0.000248 0.000654 0.002308 0.000041 0.000090 +0.000240 0.000184 0.002253 0.000053 0.000110 +0.000698 0.000483 0.003737 0.000041 0.000165 +0.000217 0.000179 0.002470 0.000049 0.000107 +0.000243 0.000160 0.002668 0.000054 0.000340 +0.000196 0.000169 0.002247 0.000040 0.000096 +0.000191 0.000162 0.003522 0.000260 0.000102 +0.000195 0.000188 0.002325 0.000041 0.000132 +0.000194 0.000202 0.002291 0.000039 0.000091 +0.000195 0.000196 0.004114 0.000042 0.000108 +0.000204 0.000200 0.002971 0.000040 0.000106 +0.000227 0.000159 0.002208 0.000039 0.000117 +0.000207 0.000176 0.003558 0.000040 0.000124 +0.000255 0.000179 0.002870 0.000040 0.000125 +0.000209 0.000176 0.002248 0.000040 0.000176 +0.000211 0.000174 0.002661 0.000039 0.000180 +0.000208 0.000219 0.002321 0.000039 0.000151 +0.000212 0.000178 0.002609 0.000040 0.000132 +0.000205 0.000209 0.002666 0.000039 0.000126 +0.000205 0.000176 0.002501 0.000041 0.000133 +0.000243 0.000183 0.002220 0.000037 0.000117 +0.000504 0.000173 0.002230 0.000121 0.000414 +0.000270 0.000200 0.002325 0.000040 0.000154 +0.000208 0.000176 0.002386 0.000038 0.000123 +0.000229 0.000182 0.002245 0.000039 0.000127 +0.000211 0.000176 0.002544 0.000039 0.000136 +0.000204 0.000180 0.002133 0.000037 0.000129 +0.000205 0.000178 0.002330 0.000048 0.000146 +0.000210 0.000178 0.002242 0.000039 0.000109 +0.000210 0.000259 0.002766 0.000039 0.000118 +0.000317 0.000495 0.002237 0.000039 0.000195 +0.000454 0.000246 0.002447 0.000040 0.000172 +0.000936 0.000200 0.002305 0.000057 0.000173 +0.000263 0.000178 0.002251 0.000038 0.000166 +0.000240 0.000183 0.002169 0.000068 0.000176 +0.000251 0.000189 0.002221 0.000038 0.000141 +0.000268 0.000215 0.002322 0.000039 0.000226 +0.000287 0.000223 0.002696 0.000045 0.000247 +0.000362 0.000229 0.002551 0.000043 0.000133 +0.000239 0.000200 0.002621 0.000045 0.000133 +0.000634 0.000208 0.002619 0.000046 0.000138 +0.000236 0.000205 0.002589 0.000046 0.000137 +0.000262 0.000205 0.002607 0.000045 0.000142 +0.000239 0.000198 0.002754 0.000044 0.000185 +0.000238 0.000198 0.002593 0.000057 0.000160 +0.000242 0.000221 0.003784 0.000122 0.000174 +0.000242 0.000201 0.002625 0.000054 0.000148 +0.000296 0.000225 0.002934 0.000044 0.000134 +0.000239 0.000245 0.003428 0.000046 0.000158 +0.000261 0.000251 0.002569 0.000046 0.000139 +0.000260 0.000230 0.002603 0.000045 0.000145 +0.000302 0.000212 0.002580 0.000045 0.000176 +0.000794 0.000197 0.002856 0.000046 0.000141 +0.000273 0.000209 0.003173 0.000045 0.000217 +0.000240 0.000201 0.002844 0.000043 0.000167 +0.000389 0.000175 0.004315 0.000055 0.000091 +0.000275 0.000534 0.004991 0.000053 0.000092 +0.000229 0.000215 0.004084 0.000045 0.000074 +0.000172 0.000474 0.002611 0.000043 0.000069 +0.000201 0.000174 0.002485 0.000043 0.000069 +0.000173 0.000220 0.002541 0.000045 0.000068 +0.000167 0.000161 0.002827 0.000043 0.000071 +0.000168 0.000160 0.003512 0.000068 0.000075 +0.000211 0.000167 0.002530 0.000044 0.000069 +0.000193 0.000230 0.003664 0.000046 0.000074 +0.000171 0.000161 0.002575 0.000076 0.000075 +0.000169 0.000161 0.002595 0.000044 0.000076 +0.000981 0.000174 0.002556 0.000045 0.000072 +0.000168 0.000163 0.002568 0.000043 0.000072 +0.000163 0.000158 0.002579 0.000043 0.000386 +0.000168 0.000160 0.002579 0.000059 0.000088 +0.000176 0.000163 0.002559 0.000044 0.000075 +0.000167 0.000161 0.002558 0.000043 0.000075 +0.000169 0.000161 0.002599 0.000043 0.000095 +0.000174 0.000163 0.002633 0.000046 0.000076 +0.000170 0.000165 0.002576 0.000858 0.000079 +0.000169 0.000162 0.002611 0.000044 0.000075 +0.000170 0.000199 0.002621 0.000043 0.000074 +0.000170 0.000167 0.003611 0.000043 0.000073 +0.000171 0.000159 0.002764 0.000046 0.000076 +0.000171 0.000165 0.002639 0.000044 0.000073 +0.000168 0.000162 0.003131 0.000046 0.000075 +0.000170 0.000162 0.002858 0.000044 0.000074 +0.000171 0.000164 0.002841 0.000043 0.000075 +0.000167 0.000161 0.002971 0.000043 0.000074 +0.000170 0.000226 0.002842 0.000044 0.000074 +0.000171 0.000165 0.002822 0.000044 0.000075 +0.000173 0.000160 0.002895 0.000045 0.000073 +0.000167 0.000217 0.002697 0.000044 0.000076 +0.000170 0.000197 0.002699 0.000044 0.000075 +0.000171 0.000163 0.003230 0.000045 0.000097 +0.000170 0.000164 0.003167 0.000046 0.000082 +0.000172 0.000196 0.002559 0.000043 0.000075 +0.000168 0.000165 0.003006 0.000045 0.000075 +0.000176 0.000160 0.002567 0.000043 0.000075 +0.000167 0.000163 0.002757 0.000045 0.000076 +0.000171 0.000162 0.002802 0.000045 0.000076 +0.000169 0.000162 0.003102 0.000043 0.000072 +0.000167 0.000162 0.002624 0.000043 0.000075 +0.000170 0.000161 0.002589 0.000043 0.000072 +0.000222 0.000253 0.002657 0.000045 0.000075 +0.000172 0.000162 0.002586 0.000044 0.000084 +0.000172 0.000165 0.002933 0.000044 0.000075 +0.000169 0.000192 0.002609 0.000044 0.000074 +0.000194 0.000162 0.003020 0.000045 0.000081 +0.000170 0.000164 0.002908 0.000045 0.000076 +0.000169 0.000163 0.002567 0.000042 0.000073 +0.000167 0.000159 0.003071 0.000042 0.000074 +0.000222 0.000163 0.003175 0.000043 0.000076 +0.000167 0.000160 0.002641 0.000046 0.000099 +0.000171 0.000168 0.002586 0.000057 0.000075 +0.000170 0.000168 0.003148 0.000046 0.000075 +0.000171 0.000159 0.002770 0.000041 0.000074 +0.000173 0.000158 0.002643 0.000055 0.000077 +0.000313 0.000174 0.002920 0.000045 0.000075 +0.000170 0.000163 0.002551 0.000044 0.000072 +0.000173 0.000161 0.002599 0.000045 0.000073 +0.000167 0.000160 0.003505 0.000046 0.000075 +0.000171 0.000161 0.002894 0.000045 0.000074 +0.000171 0.000166 0.002572 0.000042 0.000073 +0.000166 0.000160 0.004099 0.000044 0.000102 +0.000181 0.000160 0.002499 0.000046 0.000071 +0.000174 0.000175 0.002560 0.000043 0.000068 +0.000165 0.000168 0.003083 0.000044 0.000070 +0.000210 0.000163 0.002535 0.000040 0.000068 +0.000164 0.000177 0.002906 0.000044 0.000075 +0.000175 0.000227 0.002971 0.000043 0.000073 +0.000167 0.000175 0.003409 0.000046 0.000078 +0.000172 0.000166 0.002640 0.000046 0.000074 +0.000177 0.000164 0.002574 0.000046 0.000076 +0.000170 0.000163 0.002631 0.000046 0.000075 +0.000216 0.000168 0.002596 0.000046 0.000076 +0.000170 0.000163 0.002659 0.000045 0.000074 +0.000172 0.000162 0.002677 0.000046 0.000075 +0.000170 0.000159 0.002604 0.000044 0.000081 +0.000171 0.000161 0.003163 0.000046 0.000076 +0.000171 0.000162 0.002574 0.000313 0.000075 +0.000170 0.000186 0.002988 0.000046 0.000074 +0.000171 0.000162 0.002596 0.000043 0.000077 +0.000168 0.000160 0.002640 0.000055 0.000074 +0.000169 0.000161 0.002567 0.000043 0.000371 +0.000170 0.000162 0.002704 0.000057 0.000078 +0.000255 0.000185 0.002453 0.000293 0.000066 +0.000148 0.000143 0.002169 0.000037 0.000066 +0.000173 0.000141 0.002238 0.000039 0.000085 +0.000154 0.000174 0.002679 0.000041 0.000065 +0.000149 0.000144 0.002187 0.000037 0.000065 +0.000146 0.000140 0.002760 0.000039 0.000071 +0.000147 0.000151 0.002193 0.000039 0.000065 +0.000150 0.000172 0.002207 0.000039 0.000067 +0.000147 0.000141 0.002126 0.000037 0.000060 +0.000191 0.000141 0.002119 0.000036 0.000086 +0.000149 0.000144 0.002440 0.000039 0.000065 +0.000148 0.000143 0.003287 0.000041 0.000068 +0.000152 0.000149 0.002555 0.000040 0.000069 +0.000148 0.000141 0.002203 0.000038 0.000065 +0.000147 0.000139 0.002371 0.000052 0.000075 +0.000148 0.000143 0.002201 0.000037 0.000066 +0.000149 0.000140 0.002186 0.000038 0.000062 +0.000152 0.000154 0.002215 0.000038 0.000062 +0.000149 0.000144 0.002505 0.000039 0.000067 +0.000148 0.000140 0.002216 0.000038 0.000101 +0.000160 0.000144 0.002574 0.000039 0.000067 +0.000150 0.000144 0.002266 0.000040 0.000068 +0.000151 0.000142 0.003640 0.000040 0.000068 +0.000150 0.000142 0.002207 0.000038 0.000066 +0.000148 0.000140 0.002337 0.000041 0.000068 +0.000151 0.000144 0.002138 0.000038 0.000063 +0.000146 0.000178 0.002369 0.000039 0.000060 +0.000150 0.000141 0.002290 0.000039 0.000067 +0.000149 0.000143 0.002569 0.000050 0.000070 +0.000149 0.000143 0.002797 0.000040 0.000068 +0.000149 0.000143 0.002720 0.000039 0.000066 +0.000273 0.000154 0.002255 0.000039 0.000066 +0.000147 0.000141 0.002180 0.000037 0.000065 +0.000884 0.000142 0.002164 0.000036 0.000060 +0.000188 0.000143 0.002248 0.000039 0.000062 +0.000148 0.000142 0.002178 0.000038 0.000064 +0.000151 0.000140 0.002705 0.000038 0.000063 +0.000145 0.000144 0.002588 0.000039 0.000064 +0.000147 0.000142 0.002196 0.000037 0.000064 +0.000147 0.000139 0.002169 0.000035 0.000060 +0.000151 0.000894 0.002267 0.000039 0.000061 +0.000152 0.000145 0.002178 0.000038 0.000061 +0.000185 0.000142 0.002148 0.000036 0.000062 +0.000147 0.000141 0.002845 0.000040 0.000065 +0.000159 0.000178 0.002193 0.000039 0.000063 +0.000145 0.000141 0.002571 0.000039 0.000066 +0.000149 0.000141 0.003380 0.000038 0.000065 +0.000200 0.000149 0.002439 0.000039 0.000066 +0.000152 0.000140 0.002193 0.000037 0.000065 +0.000147 0.000139 0.002239 0.000037 0.000066 +0.000200 0.000143 0.002190 0.000039 0.000066 +0.000147 0.000139 0.002243 0.000038 0.000062 +0.000421 0.000144 0.002229 0.000038 0.000062 +0.000147 0.000149 0.002715 0.000038 0.000063 +0.000151 0.000176 0.002144 0.000036 0.000060 +0.000145 0.000138 0.002184 0.000038 0.000064 +0.000146 0.000207 0.002526 0.000040 0.000067 +0.000163 0.000142 0.002366 0.000038 0.000070 +0.000149 0.000143 0.002143 0.000038 0.000065 +0.000150 0.000142 0.002146 0.000035 0.000059 +0.000162 0.000147 0.002736 0.000038 0.000067 +0.000149 0.000146 0.002383 0.000040 0.000071 +0.000147 0.000139 0.002485 0.000038 0.000065 +0.000147 0.000143 0.002811 0.000039 0.000098 +0.000181 0.000142 0.002503 0.000039 0.000066 +0.000150 0.000143 0.002227 0.000039 0.000065 +0.000149 0.000143 0.002182 0.000036 0.000061 +0.000148 0.000387 0.002159 0.000036 0.000059 +0.000147 0.000173 0.002267 0.000039 0.000063 +0.000147 0.000143 0.002729 0.000039 0.000066 +0.000149 0.000142 0.002574 0.000040 0.000069 +0.000149 0.000143 0.002560 0.000040 0.000068 +0.000152 0.000141 0.002203 0.000038 0.000066 +0.000151 0.000139 0.002234 0.000038 0.000087 +0.000148 0.000140 0.002152 0.000036 0.000060 +0.000185 0.000140 0.002274 0.000039 0.000063 +0.000148 0.000144 0.002211 0.000038 0.000066 +0.000149 0.000141 0.002692 0.000039 0.000066 +0.000148 0.000145 0.002519 0.000039 0.000066 +0.000147 0.000143 0.002188 0.000038 0.000066 +0.000149 0.000171 0.002171 0.000038 0.000093 +0.000150 0.000182 0.002185 0.000038 0.000068 +0.000191 0.000154 0.002172 0.000037 0.000061 +0.000145 0.000140 0.002253 0.000043 0.000065 +0.000147 0.000139 0.002673 0.000038 0.000066 +0.000191 0.000144 0.002740 0.000038 0.000066 +0.000147 0.000142 0.002187 0.000038 0.000064 +0.000146 0.000181 0.002180 0.000038 0.000066 +0.000176 0.000142 0.002152 0.000039 0.000061 +0.000149 0.000142 0.002164 0.000037 0.000064 +0.000245 0.000150 0.002771 0.000055 0.000084 +0.000149 0.000145 0.003006 0.000040 0.000069 +0.000153 0.000144 0.002701 0.000040 0.000067 +0.000149 0.000144 0.002192 0.000038 0.000065 +0.000148 0.000143 0.002220 0.000038 0.000063 +0.000146 0.000140 0.002210 0.000038 0.000062 +0.000157 0.000144 0.002174 0.000038 0.000060 +0.000148 0.000171 0.002208 0.000039 0.000061 +0.000146 0.000141 0.002685 0.000039 0.000064 +0.000146 0.000139 0.002811 0.000038 0.000064 +0.000147 0.000140 0.002234 0.000037 0.000063 +0.000143 0.000143 0.002209 0.000040 0.000066 +0.000149 0.000144 0.002162 0.000037 0.000091 +0.000408 0.000141 0.002140 0.000036 0.000060 +0.000142 0.000149 0.002208 0.000132 0.000061 +0.000148 0.000142 0.002706 0.000040 0.000066 +0.000148 0.000142 0.002502 0.000039 0.000065 +0.000176 0.000144 0.002265 0.000039 0.000066 +0.000150 0.000142 0.002199 0.000039 0.000065 +0.000147 0.000154 0.002201 0.000040 0.000067 +0.000150 0.000142 0.002164 0.000036 0.000094 +0.000183 0.000177 0.002253 0.000039 0.000063 +0.000189 0.000143 0.002480 0.000039 0.000066 +0.000148 0.000141 0.002212 0.000037 0.000064 +0.000150 0.000137 0.002192 0.000037 0.000065 +0.000144 0.000140 0.002271 0.000039 0.000062 +0.000190 0.000171 0.002145 0.000037 0.000061 +0.000146 0.000141 0.005865 0.000099 0.000083 +0.000178 0.000165 0.002792 0.000040 0.000066 +0.000148 0.000233 0.002742 0.000039 0.000079 +0.000157 0.000151 0.002225 0.000039 0.000066 +0.000149 0.000142 0.002215 0.000039 0.000081 +0.000165 0.000141 0.002239 0.000039 0.000081 +0.000150 0.000154 0.002154 0.000036 0.000060 +0.000152 0.000151 0.002216 0.000039 0.000075 +0.000172 0.000141 0.004471 0.000060 0.000092 +0.000250 0.000210 0.002881 0.000040 0.000066 +0.000176 0.000152 0.002262 0.000038 0.000337 +0.000164 0.000154 0.002485 0.000039 0.000074 +0.000149 0.000180 0.002148 0.000039 0.000078 +0.000194 0.000145 0.002345 0.000044 0.000064 +0.000164 0.000201 0.002483 0.000040 0.000062 +0.000148 0.000140 0.002249 0.000038 0.000076 +0.000155 0.000144 0.002504 0.000039 0.000067 +0.000166 0.000150 0.002780 0.000040 0.000079 +0.000150 0.000142 0.002194 0.000038 0.000086 +0.000178 0.000153 0.002360 0.000039 0.000079 +0.000160 0.000154 0.002159 0.000036 0.000079 +0.000195 0.000445 0.002203 0.000038 0.000074 +0.000171 0.000161 0.002220 0.000038 0.000087 +0.000165 0.000151 0.002231 0.000038 0.000088 +0.000149 0.000141 0.003445 0.000040 0.000068 +0.000148 0.000143 0.002465 0.000039 0.000081 +0.000165 0.000150 0.002228 0.000038 0.000067 +0.000160 0.000142 0.003231 0.000039 0.000066 +0.000149 0.000141 0.002215 0.000038 0.000078 +0.000146 0.000152 0.002152 0.000038 0.000077 +0.000168 0.000140 0.002258 0.000040 0.000076 +0.000193 0.000142 0.002266 0.000039 0.000085 +0.000261 0.000164 0.002160 0.000037 0.000061 +0.000151 0.000419 0.002217 0.000037 0.000073 +0.000163 0.000148 0.002856 0.000038 0.000106 +0.000258 0.000204 0.002267 0.000040 0.000075 +0.000178 0.000159 0.002266 0.000038 0.000070 +0.000158 0.000149 0.002665 0.000039 0.000085 +0.000164 0.000154 0.002478 0.000039 0.000077 +0.000148 0.000140 0.002459 0.000038 0.000066 +0.000161 0.000142 0.002206 0.000038 0.000074 +0.000155 0.000151 0.002230 0.000039 0.000083 +0.000161 0.000142 0.002225 0.000037 0.000072 +0.000161 0.000187 0.002450 0.000038 0.000063 +0.000145 0.000155 0.002438 0.000039 0.000079 +0.000166 0.000138 0.002296 0.000039 0.000076 +0.000170 0.000156 0.002446 0.000038 0.000078 +0.000160 0.000159 0.002211 0.000038 0.000078 +0.000159 0.000142 0.002190 0.000036 0.000110 +0.000157 0.000150 0.002336 0.000039 0.000073 +0.000165 0.000182 0.002132 0.000038 0.000072 +0.000160 0.000140 0.002641 0.000066 0.000066 +0.000147 0.000153 0.002153 0.000039 0.000080 +0.000148 0.000156 0.002165 0.000037 0.000077 +0.000147 0.000151 0.002201 0.000038 0.000067 +0.000162 0.000143 0.002216 0.000040 0.000080 +0.000165 0.000148 0.002223 0.000055 0.000080 +0.000193 0.000143 0.002155 0.000037 0.000078 +0.000165 0.000143 0.003005 0.000040 0.000067 +0.000151 0.000145 0.002511 0.000039 0.000070 +0.000149 0.000173 0.002246 0.000039 0.000066 +0.000148 0.000143 0.002808 0.000040 0.000067 +0.000148 0.000142 0.002513 0.000038 0.000066 +0.000148 0.000143 0.002203 0.000037 0.000065 +0.000146 0.000138 0.002123 0.000038 0.000061 +0.000170 0.000149 0.002165 0.000036 0.000062 +0.000144 0.000145 0.002186 0.000037 0.000059 +0.000144 0.000139 0.002520 0.000037 0.000065 +0.000146 0.000139 0.002559 0.000038 0.000066 +0.000153 0.000142 0.002537 0.000038 0.000067 +0.000168 0.000144 0.002217 0.000048 0.000066 +0.000147 0.000141 0.002120 0.000037 0.000063 +0.000188 0.001725 0.002541 0.000040 0.000067 +0.000149 0.000143 0.002229 0.000038 0.000076 +0.000147 0.000143 0.002233 0.000037 0.000062 +0.000182 0.000142 0.002150 0.000037 0.000061 +0.000148 0.000140 0.002196 0.000037 0.000065 +0.000145 0.000140 0.002473 0.000037 0.000065 +0.000147 0.000139 0.002725 0.000040 0.000067 +0.000149 0.000142 0.002217 0.000039 0.000065 +0.000146 0.000140 0.002167 0.000037 0.000061 +0.000176 0.000144 0.002415 0.000039 0.000064 +0.000171 0.000144 0.002925 0.000040 0.000068 +0.000152 0.000167 0.002190 0.000039 0.000066 +0.000149 0.000142 0.002530 0.000039 0.000067 +0.000150 0.000142 0.003059 0.000040 0.000068 +0.000149 0.000142 0.002417 0.000038 0.000072 +0.000149 0.000143 0.002569 0.000038 0.000068 +0.000148 0.000141 0.002262 0.000040 0.000068 +0.000152 0.000144 0.002253 0.000038 0.000066 +0.000149 0.000142 0.002134 0.000037 0.000061 +0.000277 0.000427 0.002186 0.000036 0.000060 +0.000145 0.000139 0.002791 0.000039 0.000065 +0.000149 0.000144 0.002238 0.000039 0.000066 +0.000147 0.000144 0.002514 0.000039 0.000066 +0.000148 0.000143 0.002683 0.000038 0.000063 +0.000147 0.000139 0.002214 0.000037 0.000068 +0.000145 0.000139 0.002149 0.000036 0.000059 +0.000185 0.000139 0.002214 0.000037 0.000060 +0.000145 0.000140 0.003549 0.000039 0.000066 +0.000187 0.000142 0.002160 0.000037 0.000059 +0.000147 0.000158 0.002212 0.000038 0.000065 +0.000148 0.000140 0.002483 0.000039 0.000067 +0.000147 0.000142 0.003034 0.000039 0.000066 +0.000148 0.000142 0.002228 0.000039 0.000066 +0.000145 0.000151 0.002225 0.000040 0.000067 +0.000149 0.000142 0.002858 0.000048 0.000083 +0.000203 0.000185 0.004022 0.000049 0.000086 +0.000212 0.000188 0.005086 0.000056 0.000093 +0.000220 0.000203 0.004209 0.000051 0.000085 +0.000208 0.000247 0.009261 0.000098 0.000089 +0.000211 0.000262 0.002546 0.000041 0.000066 +0.000198 0.000150 0.002534 0.000039 0.000079 +0.000159 0.000143 0.002207 0.000038 0.000094 +0.000157 0.000143 0.002173 0.000038 0.000062 +0.000198 0.000505 0.002157 0.000039 0.000079 +0.000164 0.000143 0.002172 0.000038 0.000076 +0.000156 0.000148 0.002259 0.000039 0.000080 +0.000161 0.000142 0.002219 0.000039 0.000076 +0.000161 0.000143 0.002266 0.000039 0.000085 +0.000161 0.000141 0.002150 0.000036 0.000077 +0.000179 0.000140 0.002140 0.000036 0.000071 +0.000157 0.000151 0.002316 0.000040 0.000079 +0.000149 0.000143 0.002269 0.000039 0.000066 +0.000161 0.000142 0.002206 0.000040 0.000091 +0.000172 0.000143 0.002244 0.000039 0.000067 +0.000168 0.000142 0.002189 0.000039 0.000083 +0.000163 0.000188 0.002156 0.000037 0.000077 +0.000168 0.000143 0.002266 0.000039 0.000084 +0.000166 0.000147 0.002205 0.000325 0.000078 +0.000175 0.000140 0.002173 0.000037 0.000106 +0.000170 0.000153 0.002158 0.000036 0.000083 +0.000168 0.000147 0.002825 0.000039 0.000108 +0.000172 0.000151 0.002483 0.000038 0.000085 +0.000160 0.000143 0.002163 0.000038 0.000066 +0.000161 0.000154 0.002493 0.000039 0.000084 +0.000167 0.000153 0.002564 0.000040 0.000082 +0.000159 0.000151 0.002185 0.000046 0.000088 +0.000157 0.000156 0.002175 0.000039 0.000076 +0.000150 0.000144 0.002151 0.000038 0.000063 +0.000160 0.000140 0.002429 0.000038 0.000064 +0.000160 0.000154 0.002184 0.000048 0.000077 +0.000168 0.000142 0.002686 0.000040 0.000119 +0.000164 0.000152 0.002279 0.000039 0.000075 +0.000161 0.000143 0.002192 0.000068 0.000067 +0.000161 0.000154 0.002190 0.000040 0.000092 +0.000246 0.000146 0.003064 0.000038 0.000072 +0.000163 0.000158 0.002171 0.000037 0.000073 +0.000216 0.000144 0.002209 0.000039 0.000115 +0.000159 0.000141 0.003338 0.000039 0.000079 +0.000277 0.000158 0.002464 0.000039 0.000082 +0.000168 0.000150 0.002227 0.000037 0.000079 +0.000168 0.000146 0.002775 0.000038 0.000077 +0.000146 0.000147 0.002694 0.000042 0.000084 +0.000160 0.000145 0.002807 0.000039 0.000066 +0.000162 0.000177 0.002187 0.000063 0.000066 +0.000147 0.000141 0.002220 0.000038 0.000085 +0.000160 0.000142 0.002216 0.000037 0.000077 +0.000166 0.000159 0.002224 0.000039 0.000108 +0.000147 0.000141 0.002746 0.000039 0.000078 +0.000159 0.000141 0.002194 0.000037 0.000063 +0.000164 0.000143 0.002164 0.000039 0.000067 +0.000169 0.000152 0.002278 0.000074 0.000088 +0.000157 0.000157 0.002155 0.000068 0.000076 +0.000159 0.000140 0.002170 0.000035 0.000078 +0.000156 0.000141 0.002299 0.000040 0.000066 +0.000192 0.000160 0.002241 0.000039 0.000082 +0.000149 0.000143 0.002288 0.000039 0.000079 +0.000161 0.000142 0.002185 0.000049 0.000077 +0.000147 0.000149 0.002284 0.000039 0.000063 +0.000456 0.000144 0.002203 0.000046 0.000064 +0.000187 0.000144 0.002147 0.000037 0.000061 +0.000147 0.000140 0.002238 0.000040 0.000067 +0.000147 0.000140 0.003077 0.000041 0.000068 +0.000151 0.000142 0.002226 0.000038 0.000065 +0.000146 0.000142 0.002188 0.000039 0.000065 +0.000145 0.000141 0.002156 0.000036 0.000061 +0.000143 0.000172 0.002379 0.000037 0.000060 +0.000152 0.000231 0.002172 0.000038 0.000065 +0.000153 0.000142 0.002181 0.000039 0.000065 +0.000148 0.000142 0.002567 0.000039 0.000067 +0.000150 0.000142 0.002177 0.000038 0.000072 +0.000147 0.000146 0.002328 0.000038 0.000063 +0.000146 0.000150 0.002211 0.000038 0.000063 +0.000149 0.000143 0.002222 0.000040 0.000072 +0.000150 0.000144 0.002455 0.000039 0.000065 +0.000147 0.000144 0.002206 0.000039 0.000066 +0.000145 0.000141 0.002153 0.000055 0.000070 +0.000443 0.000144 0.002139 0.000036 0.000069 +0.000147 0.000182 0.002188 0.000037 0.000061 +0.000146 0.000138 0.002248 0.000038 0.000067 +0.000147 0.000142 0.002817 0.000039 0.000067 +0.000148 0.000144 0.002230 0.000038 0.000066 +0.000148 0.000142 0.002239 0.000039 0.000067 +0.000149 0.000142 0.002197 0.000038 0.000063 +0.000181 0.000674 0.002170 0.000038 0.000061 +0.000146 0.000195 0.002204 0.000037 0.000061 +0.000146 0.000141 0.002260 0.000039 0.000067 +0.000150 0.000142 0.002193 0.000045 0.000065 +0.000147 0.000140 0.002229 0.000036 0.000066 +0.000146 0.000137 0.002197 0.000037 0.000062 +0.000152 0.000159 0.002187 0.000036 0.000060 +0.000145 0.000139 0.002224 0.000037 0.000064 +0.000149 0.000144 0.002175 0.000038 0.000066 +0.000150 0.000143 0.002187 0.000038 0.000066 +0.000148 0.000141 0.002152 0.000036 0.000061 +0.000185 0.000141 0.002176 0.000036 0.000064 +0.000169 0.000145 0.002483 0.000038 0.000067 +0.000149 0.000141 0.002225 0.000036 0.000064 +0.000244 0.000149 0.002538 0.000038 0.000065 +0.000156 0.000143 0.002317 0.000039 0.000297 +0.000228 0.000172 0.002222 0.000039 0.000300 +0.000149 0.000145 0.002173 0.000040 0.000066 +0.000154 0.000145 0.002155 0.000038 0.000093 +0.000161 0.000145 0.002178 0.000039 0.000063 +0.000147 0.000170 0.002299 0.000039 0.000066 +0.000149 0.000142 0.003494 0.000040 0.000066 +0.000149 0.000178 0.002237 0.000038 0.000062 +0.000148 0.000143 0.002150 0.000037 0.000064 +0.000146 0.000139 0.002315 0.000038 0.000065 +0.000147 0.000141 0.002269 0.000039 0.000067 +0.000173 0.000145 0.002191 0.000037 0.000065 +0.000166 0.000144 0.002247 0.000038 0.000061 +0.000146 0.000140 0.002551 0.000038 0.000065 +0.000148 0.000175 0.002202 0.000037 0.000064 +0.000145 0.000141 0.002217 0.000038 0.000063 +0.000146 0.000138 0.002164 0.000132 0.000547 +0.000148 0.000144 0.008140 0.000160 0.000893 +0.000311 0.000221 0.004526 0.000058 0.000109 +0.000238 0.000225 0.003475 0.000044 0.000094 +0.000178 0.000177 0.002537 0.000041 0.000087 +0.000172 0.000161 0.002194 0.000048 0.000084 +0.000172 0.000163 0.002177 0.000040 0.000084 +0.001177 0.000156 0.002351 0.000041 0.000325 +0.000167 0.000163 0.002273 0.000040 0.000088 +0.000170 0.000151 0.002245 0.000040 0.000077 +0.000172 0.000896 0.002181 0.000038 0.000080 +0.000202 0.000164 0.002449 0.000038 0.000076 +0.000162 0.000161 0.002188 0.000037 0.000078 +0.000165 0.000154 0.002440 0.000074 0.000091 +0.000167 0.000149 0.002185 0.000039 0.000081 +0.000176 0.000154 0.002427 0.000040 0.000093 +0.000168 0.000154 0.002304 0.000038 0.000105 +0.000672 0.000160 0.002260 0.000038 0.000088 +0.000686 0.000159 0.002207 0.000038 0.000084 +0.000163 0.000154 0.002186 0.000037 0.000077 +0.000173 0.000153 0.002399 0.000038 0.000082 +0.000166 0.000157 0.002709 0.000039 0.000077 +0.000155 0.000149 0.002143 0.000038 0.000097 +0.000166 0.000154 0.003454 0.000051 0.000106 +0.000166 0.000160 0.002539 0.000039 0.000128 +0.000169 0.000149 0.002307 0.000039 0.000085 +0.000170 0.000158 0.002225 0.000040 0.000088 +0.000170 0.000180 0.002165 0.000036 0.000103 +0.000203 0.000160 0.002345 0.000039 0.000075 +0.000173 0.000191 0.002160 0.000038 0.000074 +0.000165 0.000156 0.002243 0.000039 0.000085 +0.000172 0.000154 0.002260 0.000040 0.000090 +0.000163 0.000164 0.002258 0.000040 0.000085 +0.000168 0.000143 0.002755 0.000039 0.000086 +0.000178 0.000155 0.002202 0.000039 0.000075 +0.000164 0.000153 0.002267 0.000038 0.000081 +0.000161 0.000154 0.002158 0.000036 0.000090 +0.000169 0.000158 0.002454 0.000037 0.000061 +0.000162 0.000154 0.002543 0.000038 0.000091 +0.000170 0.000154 0.002168 0.000037 0.000085 +0.000166 0.000151 0.002852 0.000038 0.000087 +0.000167 0.000165 0.002484 0.000039 0.000089 +0.000374 0.000197 0.002217 0.000038 0.000082 +0.000156 0.000150 0.002213 0.000038 0.000112 +0.000683 0.000155 0.002131 0.000038 0.000077 +0.000162 0.000164 0.002199 0.000038 0.000076 +0.000176 0.000154 0.002345 0.000038 0.000089 +0.000175 0.000150 0.002928 0.000039 0.000082 +0.000161 0.000140 0.002528 0.000039 0.000066 +0.000159 0.000151 0.002256 0.000039 0.000075 +0.000155 0.000156 0.002233 0.000040 0.000066 +0.000171 0.000156 0.002149 0.000066 0.000084 +0.000182 0.000154 0.002233 0.000037 0.000117 +0.000166 0.000160 0.002460 0.000037 0.000088 +0.000159 0.000165 0.002891 0.000043 0.000075 +0.000169 0.000143 0.002383 0.000038 0.000084 +0.000162 0.000149 0.002313 0.000039 0.000078 +0.000166 0.000161 0.003837 0.000041 0.000092 +0.000166 0.000144 0.002389 0.000038 0.000078 +0.000185 0.000153 0.002548 0.000040 0.000090 +0.000166 0.000152 0.002943 0.000037 0.000063 +0.000147 0.000140 0.002284 0.000038 0.000066 +0.000145 0.000141 0.002555 0.000038 0.000071 +0.000189 0.000143 0.002235 0.000038 0.000359 +0.000149 0.000140 0.002779 0.000053 0.000089 +0.000211 0.000206 0.002744 0.000040 0.000067 +0.000150 0.000144 0.002471 0.000039 0.000065 +0.000151 0.000140 0.002563 0.000040 0.000064 +0.000148 0.000138 0.002305 0.000039 0.000066 +0.000148 0.000141 0.002162 0.000036 0.000060 +0.000182 0.000145 0.002403 0.000042 0.000063 +0.000152 0.000141 0.002311 0.000039 0.000065 +0.000148 0.000180 0.002192 0.000038 0.000065 +0.000149 0.000141 0.002516 0.000039 0.000066 +0.000147 0.000142 0.002193 0.000040 0.000064 +0.000146 0.000138 0.002194 0.000036 0.000060 +0.000197 0.000142 0.002291 0.000038 0.000063 +0.000148 0.000142 0.002440 0.000039 0.000066 +0.000148 0.000143 0.002228 0.000039 0.000066 +0.000149 0.000140 0.002216 0.000038 0.000067 +0.000148 0.000145 0.002196 0.000038 0.000066 +0.000148 0.000141 0.002157 0.000036 0.000061 +0.000144 0.000175 0.002491 0.000039 0.000063 +0.000147 0.000141 0.002290 0.000039 0.000066 +0.000149 0.000143 0.002508 0.000039 0.000067 +0.000149 0.000142 0.002536 0.000039 0.000067 +0.000150 0.000141 0.003132 0.000046 0.000070 +0.000153 0.000145 0.002202 0.000039 0.000067 +0.000149 0.000143 0.002102 0.000037 0.000067 +0.000989 0.000142 0.002188 0.000063 0.000068 +0.000151 0.000142 0.002229 0.000038 0.000068 +0.001481 0.000141 0.002238 0.000039 0.000070 +0.000148 0.000142 0.002204 0.000037 0.000093 +0.000160 0.000141 0.002138 0.000038 0.000062 +0.000145 0.000141 0.002708 0.000039 0.000065 +0.000147 0.000142 0.002218 0.000039 0.000067 +0.000148 0.000140 0.002759 0.000038 0.000066 +0.000148 0.000139 0.003156 0.000037 0.000067 +0.000185 0.000141 0.002259 0.000040 0.000066 +0.000148 0.000142 0.002226 0.000047 0.000068 +0.000148 0.000142 0.002305 0.000040 0.000090 +0.001000 0.000155 0.002217 0.000064 0.000068 +0.000154 0.000144 0.002554 0.000038 0.000065 +0.000148 0.000141 0.002151 0.000038 0.000066 +0.000146 0.000181 0.003031 0.000039 0.000062 +0.000146 0.000180 0.002254 0.000039 0.000061 +0.000147 0.000143 0.002188 0.000039 0.000065 +0.000147 0.000140 0.002259 0.000039 0.000063 +0.000146 0.000141 0.002238 0.000038 0.000076 +0.000148 0.000141 0.002163 0.000038 0.000061 +0.000153 0.000143 0.002195 0.000043 0.000072 +0.000149 0.000177 0.003291 0.000039 0.000063 +0.000258 0.000153 0.002150 0.000039 0.000066 +0.000157 0.000144 0.002155 0.000037 0.000060 +0.000160 0.001194 0.002269 0.000040 0.000100 +0.000164 0.000151 0.002162 0.000038 0.000078 +0.000163 0.000424 0.002178 0.000036 0.000069 +0.001333 0.000389 0.002249 0.000039 0.000066 +0.000175 0.000142 0.002208 0.000037 0.000102 +0.000443 0.000156 0.002249 0.000040 0.000062 +0.000244 0.001562 0.003049 0.000041 0.000083 +0.000208 0.000183 0.002483 0.000040 0.000068 +0.000164 0.000156 0.002220 0.000040 0.000078 +0.000169 0.000142 0.002694 0.000040 0.000083 +0.000162 0.000152 0.002453 0.000038 0.000077 +0.000157 0.000189 0.002306 0.000040 0.000077 +0.000162 0.000151 0.002200 0.000039 0.000325 +0.000150 0.000142 0.002251 0.000039 0.000066 +0.000172 0.000157 0.002184 0.000039 0.000073 +0.000160 0.000150 0.002678 0.000038 0.000326 +0.000165 0.000151 0.002292 0.000038 0.000094 +0.000162 0.000156 0.002203 0.000037 0.000083 +0.000170 0.000141 0.002175 0.000037 0.000074 +0.000149 0.000166 0.002235 0.000039 0.000071 +0.000161 0.000143 0.002423 0.000036 0.000180 +0.000164 0.000152 0.003095 0.000039 0.000076 +0.000172 0.000153 0.002466 0.000039 0.000115 +0.000151 0.000153 0.002274 0.000039 0.000066 +0.000150 0.000142 0.003179 0.000040 0.000080 +0.000172 0.000159 0.002421 0.000039 0.000083 +0.000159 0.000142 0.002165 0.000037 0.000068 +0.000155 0.000150 0.002233 0.000041 0.000123 +0.000153 0.000158 0.002253 0.000039 0.000571 +0.000203 0.000145 0.002269 0.000041 0.000077 +0.000164 0.000158 0.002176 0.000038 0.000086 +0.000197 0.000144 0.002220 0.000041 0.000080 +0.000174 0.000403 0.002224 0.000039 0.000063 +0.000218 0.000144 0.002150 0.000036 0.000069 +0.000149 0.000141 0.002479 0.000040 0.000079 +0.000163 0.000145 0.002664 0.000039 0.000082 +0.000150 0.000152 0.002446 0.000040 0.000069 +0.000203 0.000154 0.002205 0.000043 0.000077 +0.000160 0.000143 0.002210 0.000039 0.000087 +0.000194 0.000145 0.002167 0.000038 0.000069 +0.000151 0.000154 0.002137 0.000036 0.000079 +0.000162 0.000140 0.002697 0.000037 0.000085 +0.000162 0.000143 0.002233 0.000039 0.000076 +0.000148 0.000144 0.002210 0.000039 0.000065 +0.000151 0.000152 0.003015 0.000041 0.000084 +0.000158 0.000156 0.002730 0.000039 0.000079 +0.000312 0.000165 0.002207 0.000038 0.000076 +0.000167 0.000139 0.002297 0.000040 0.000065 +0.000172 0.000154 0.002205 0.000037 0.000080 +0.000146 0.000149 0.002286 0.000039 0.000076 +0.000164 0.000151 0.002214 0.000038 0.000073 +0.000162 0.000169 0.003110 0.000038 0.000067 +0.000293 0.000144 0.002182 0.000038 0.000060 +0.000157 0.000153 0.003778 0.000049 0.000095 +0.001735 0.000210 0.004360 0.000050 0.000083 +0.000297 0.000198 0.002532 0.000039 0.000072 +0.000185 0.000163 0.002173 0.000039 0.000070 +0.000183 0.000142 0.002122 0.000038 0.000062 +0.000147 0.000145 0.002443 0.000039 0.000066 +0.000149 0.000144 0.002473 0.000040 0.000066 +0.000147 0.000139 0.002949 0.000038 0.000063 +0.000147 0.000139 0.002737 0.000039 0.000066 +0.000199 0.000142 0.002927 0.000038 0.000066 +0.000149 0.000141 0.002188 0.000038 0.000065 +0.000147 0.000144 0.002203 0.000038 0.000066 +0.000149 0.000141 0.002154 0.000037 0.000062 +0.000144 0.000137 0.003526 0.000037 0.000066 +0.000151 0.000153 0.002150 0.000036 0.000060 +0.000145 0.000138 0.002202 0.000037 0.000065 +0.000272 0.000187 0.002477 0.000038 0.000306 +0.000148 0.000141 0.002421 0.000038 0.000067 +0.000147 0.000141 0.002252 0.000039 0.000065 +0.000150 0.000140 0.002144 0.000037 0.000061 +0.000191 0.000144 0.002229 0.000038 0.000060 +0.000145 0.000145 0.002202 0.000038 0.000061 +0.000146 0.000142 0.002418 0.000038 0.000065 +0.000189 0.000171 0.002568 0.000040 0.000066 +0.000150 0.000141 0.002300 0.000039 0.000067 +0.000151 0.000141 0.002199 0.000038 0.000347 +0.000147 0.000140 0.002165 0.000035 0.000061 +0.000151 0.000646 0.002310 0.000040 0.000062 +0.000161 0.000410 0.002195 0.000038 0.000061 +0.000147 0.000141 0.002466 0.000039 0.000066 +0.000147 0.000141 0.003026 0.000038 0.000066 +0.000148 0.000142 0.002223 0.000038 0.000065 +0.000147 0.000142 0.002196 0.000038 0.000067 +0.000147 0.000141 0.002155 0.000044 0.000064 +0.000146 0.000140 0.002354 0.000039 0.000067 +0.000149 0.000143 0.002186 0.000037 0.000062 +0.000150 0.000144 0.002498 0.000040 0.000063 +0.000178 0.000212 0.002453 0.000039 0.000062 +0.000149 0.000177 0.002463 0.000038 0.000063 +0.000147 0.000142 0.002507 0.000038 0.000067 +0.000149 0.000142 0.002717 0.000038 0.000066 +0.000148 0.000141 0.002452 0.000037 0.000065 +0.000147 0.000140 0.002266 0.000039 0.000066 +0.000149 0.000141 0.002183 0.000037 0.000066 +0.000153 0.000142 0.002203 0.000039 0.000067 +0.000152 0.000419 0.002245 0.000040 0.000062 +0.000149 0.000181 0.002181 0.000038 0.000063 +0.000147 0.000142 0.002224 0.000039 0.000066 +0.000147 0.000142 0.002204 0.000038 0.000066 +0.000146 0.000141 0.002250 0.000038 0.000065 +0.000148 0.000141 0.002142 0.000038 0.000063 +0.000156 0.000139 0.002176 0.000036 0.000060 +0.000243 0.000148 0.002768 0.000039 0.000069 +0.000146 0.000204 0.002194 0.000037 0.000065 +0.000147 0.000143 0.003071 0.000039 0.000066 +0.000148 0.000144 0.003489 0.000042 0.000073 +0.000151 0.000151 0.002173 0.000039 0.000064 +0.000146 0.000140 0.003509 0.000038 0.000067 +0.000148 0.000142 0.002191 0.000038 0.000064 +0.000146 0.000139 0.002441 0.000039 0.000117 +0.000174 0.000141 0.002133 0.000038 0.000065 +0.000151 0.000142 0.002257 0.000039 0.000073 +0.000163 0.000147 0.002187 0.000038 0.000061 +0.000146 0.000222 0.002193 0.000038 0.000062 +0.000145 0.000143 0.002434 0.000037 0.000064 +0.000145 0.000139 0.002933 0.000041 0.000066 +0.000146 0.000140 0.002680 0.000037 0.000065 +0.000143 0.000139 0.002217 0.001029 0.000065 +0.000145 0.000139 0.002361 0.000039 0.000067 +0.000150 0.000143 0.002186 0.000068 0.000066 +0.000148 0.000142 0.002149 0.000037 0.000061 +0.000147 0.000181 0.002183 0.000037 0.000061 +0.000146 0.000455 0.002305 0.000038 0.000074 +0.000148 0.000143 0.002223 0.000038 0.000066 +0.000148 0.000141 0.002547 0.000038 0.000066 +0.000148 0.000143 0.002180 0.000038 0.000336 +0.000146 0.000141 0.002102 0.000037 0.000063 +0.000150 0.000145 0.002170 0.000037 0.000067 +0.000152 0.000138 0.002982 0.000038 0.000067 +0.000149 0.000143 0.002419 0.000037 0.000064 +0.000145 0.000195 0.002228 0.000040 0.000067 +0.000148 0.000143 0.002193 0.000038 0.000064 +0.000155 0.000141 0.002166 0.000067 0.000066 +0.000454 0.000176 0.002193 0.000038 0.000063 +0.000186 0.000142 0.002165 0.000035 0.000066 +0.000144 0.000138 0.002542 0.000038 0.000066 +0.000148 0.000143 0.002733 0.000039 0.000066 +0.000147 0.000141 0.002227 0.000038 0.000067 +0.000145 0.000142 0.002764 0.000037 0.000064 +0.000144 0.000138 0.002207 0.000037 0.000065 +0.000147 0.000185 0.002262 0.000038 0.000062 +0.000154 0.000160 0.002163 0.000038 0.000063 +0.000150 0.000145 0.002719 0.000038 0.000065 +0.000145 0.000139 0.002226 0.000037 0.000074 +0.000148 0.000140 0.002517 0.000038 0.000067 +0.000148 0.000142 0.003734 0.000039 0.000067 +0.000147 0.000143 0.002508 0.000039 0.000067 +0.000146 0.000143 0.002288 0.000038 0.000067 +0.000149 0.000143 0.002899 0.000039 0.000067 +0.000150 0.000145 0.002232 0.000037 0.000065 +0.000148 0.000142 0.002169 0.000039 0.000067 +0.000161 0.000141 0.002196 0.000036 0.000060 +0.000145 0.000137 0.002467 0.000040 0.000064 +0.000147 0.000141 0.002168 0.000037 0.000063 +0.000147 0.000139 0.002165 0.000037 0.000064 +0.000146 0.000138 0.002167 0.000036 0.000060 +0.000150 0.000141 0.002326 0.000039 0.000063 +0.000149 0.000179 0.002197 0.000039 0.000063 +0.000148 0.000142 0.002538 0.000039 0.000067 +0.000148 0.000148 0.002555 0.000039 0.000067 +0.000150 0.000144 0.002180 0.000038 0.000066 +0.000245 0.000152 0.002203 0.000038 0.000065 +0.000146 0.000142 0.002118 0.000036 0.000091 +0.000648 0.000141 0.002173 0.000035 0.000058 +0.000142 0.000149 0.002137 0.000037 0.000059 +0.000144 0.000138 0.002191 0.000037 0.000063 +0.000143 0.000137 0.002795 0.000039 0.000065 +0.000147 0.000256 0.002250 0.000038 0.000064 +0.000148 0.000142 0.002231 0.000040 0.000075 +0.000149 0.000143 0.002174 0.000038 0.000061 +0.000182 0.000708 0.002255 0.000038 0.000061 +0.000181 0.000170 0.002222 0.000038 0.000060 +0.000148 0.000141 0.002177 0.000038 0.000065 +0.000147 0.000141 0.002478 0.000039 0.000065 +0.000148 0.000141 0.002191 0.000039 0.000065 +0.000146 0.000139 0.002161 0.000067 0.000063 +0.000157 0.000138 0.002174 0.000036 0.000059 +0.000143 0.000165 0.002396 0.000040 0.000067 +0.000148 0.000141 0.002302 0.000044 0.000067 +0.000148 0.000142 0.002226 0.000043 0.000065 +0.000149 0.000142 0.002198 0.000038 0.000087 +0.000147 0.000143 0.002221 0.000039 0.000066 +0.000146 0.000142 0.002376 0.000065 0.000063 +0.000152 0.000154 0.002201 0.000038 0.000062 +0.000150 0.000142 0.002705 0.000039 0.000067 +0.000149 0.000142 0.002267 0.000039 0.000067 +0.000194 0.000149 0.002347 0.000039 0.000066 +0.000155 0.000141 0.002594 0.000038 0.000066 +0.000148 0.000141 0.002189 0.000038 0.000064 +0.000202 0.000142 0.002155 0.000039 0.000062 +0.000182 0.000146 0.002204 0.000037 0.000061 +0.000146 0.000139 0.002466 0.000037 0.000065 +0.000146 0.000140 0.002463 0.000036 0.000065 +0.000146 0.000139 0.002209 0.000037 0.000063 +0.000145 0.000138 0.002146 0.000036 0.000060 +0.000181 0.000142 0.003356 0.000038 0.000068 +0.000161 0.000142 0.002169 0.000038 0.000062 +0.000146 0.000175 0.002538 0.000039 0.000061 +0.000148 0.000141 0.002482 0.000039 0.000067 +0.000148 0.000144 0.002450 0.000040 0.000066 +0.000149 0.000143 0.002466 0.000043 0.000068 +0.000148 0.000144 0.003551 0.000038 0.000068 +0.000149 0.000142 0.002482 0.000039 0.000066 +0.000149 0.000142 0.002220 0.000039 0.000066 +0.000151 0.000140 0.002199 0.000038 0.000064 +0.000148 0.000184 0.002185 0.000038 0.000066 +0.000145 0.000140 0.002158 0.000036 0.000092 +0.000158 0.000140 0.002262 0.000038 0.000062 +0.000148 0.000143 0.002674 0.000039 0.000066 +0.000148 0.000140 0.002421 0.000039 0.000066 +0.000149 0.000149 0.002433 0.000038 0.000065 +0.000146 0.000172 0.002187 0.000038 0.000065 +0.000146 0.000140 0.002311 0.000039 0.000323 +0.000149 0.000142 0.002180 0.000038 0.000091 +0.000420 0.000143 0.002483 0.000038 0.000063 +0.000685 0.000145 0.002136 0.000035 0.000064 +0.000146 0.000145 0.002433 0.000038 0.000062 +0.000146 0.000139 0.002496 0.000039 0.000066 +0.000149 0.000139 0.003626 0.000041 0.000068 +0.000153 0.000147 0.002272 0.000042 0.000067 +0.000248 0.000155 0.002208 0.000038 0.000063 +0.000146 0.000138 0.002524 0.000038 0.000068 +0.000147 0.000140 0.002176 0.000210 0.000065 +0.000147 0.000140 0.002166 0.000036 0.000060 +0.000144 0.000146 0.002169 0.000036 0.000057 +0.000144 0.000138 0.002207 0.000037 0.000063 +0.000145 0.000138 0.002183 0.000037 0.000062 +0.000145 0.000137 0.002167 0.000036 0.000059 +0.000148 0.000453 0.002310 0.000038 0.000061 +0.000183 0.000855 0.002326 0.000037 0.000061 +0.000146 0.000175 0.002672 0.000036 0.000060 +0.000143 0.000140 0.002238 0.000039 0.000065 +0.000146 0.000139 0.002473 0.000037 0.000064 +0.000146 0.000139 0.002196 0.000039 0.000065 +0.000145 0.000139 0.002141 0.000036 0.000061 +0.000174 0.000397 0.002175 0.000036 0.000059 +0.000143 0.000139 0.002647 0.000037 0.000065 +0.000147 0.000138 0.002196 0.000037 0.000064 +0.000146 0.000138 0.002199 0.000037 0.000063 +0.000146 0.000138 0.002167 0.000036 0.000066 +0.000169 0.000141 0.002156 0.000036 0.000060 +0.000143 0.000139 0.002180 0.000037 0.000065 +0.000144 0.000136 0.002756 0.000039 0.000066 +0.000150 0.000141 0.002919 0.000039 0.000066 +0.000147 0.000140 0.002184 0.000036 0.000065 +0.000145 0.000138 0.002168 0.000036 0.000091 +0.000156 0.000139 0.002169 0.000036 0.000059 +0.000143 0.000139 0.002741 0.000038 0.000065 +0.000147 0.000140 0.002429 0.000037 0.000063 +0.000145 0.000139 0.002226 0.000037 0.000064 +0.000145 0.000139 0.003381 0.000040 0.000066 +0.000153 0.000141 0.002262 0.000038 0.000064 +0.000145 0.000140 0.002137 0.000036 0.000062 +0.000154 0.000650 0.002217 0.000038 0.000063 +0.000184 0.000143 0.002209 0.000038 0.000062 +0.000153 0.000142 0.002907 0.000039 0.000066 +0.000147 0.000142 0.002158 0.000038 0.000064 +0.000146 0.000140 0.002953 0.000039 0.000068 +0.000148 0.000143 0.002208 0.000039 0.000065 +0.000149 0.000139 0.002187 0.000036 0.000065 +0.000144 0.000139 0.002157 0.000036 0.000061 +0.000154 0.000926 0.002139 0.000036 0.000059 +0.000183 0.000140 0.002526 0.000038 0.000062 +0.000148 0.000142 0.002207 0.000038 0.000066 +0.000147 0.000139 0.002790 0.000039 0.000069 +0.000149 0.000144 0.002251 0.000038 0.000066 +0.000151 0.000140 0.002220 0.000039 0.000066 +0.000148 0.000142 0.002523 0.000038 0.000064 +0.000151 0.000138 0.002151 0.000037 0.000065 +0.000147 0.000140 0.002251 0.000037 0.000062 +0.000149 0.000139 0.002607 0.000037 0.000065 +0.000147 0.000141 0.003380 0.000037 0.000066 +0.000147 0.000139 0.002285 0.000069 0.000066 +0.000149 0.000142 0.002566 0.000038 0.000067 +0.000147 0.000142 0.002523 0.000038 0.000067 +0.000152 0.000143 0.002215 0.000038 0.000067 +0.000150 0.000144 0.002243 0.000038 0.000075 +0.000149 0.000141 0.002148 0.000036 0.000063 +0.000182 0.000144 0.002167 0.000036 0.000062 +0.000278 0.000155 0.002631 0.000036 0.000061 +0.000149 0.000139 0.003175 0.000040 0.000066 +0.000156 0.000140 0.002660 0.000038 0.000065 +0.000148 0.000141 0.006171 0.000067 0.000069 +0.000164 0.000142 0.002713 0.000038 0.000064 +0.000161 0.000150 0.002270 0.000038 0.000081 +0.000160 0.000283 0.002276 0.000038 0.000083 +0.000168 0.000150 0.002207 0.000037 0.000072 +0.000151 0.000669 0.002160 0.000038 0.000062 +0.000196 0.000156 0.002363 0.000036 0.000061 +0.000162 0.000141 0.002160 0.000037 0.000077 +0.000147 0.000141 0.002676 0.000038 0.000096 +0.000162 0.000143 0.002263 0.000037 0.000065 +0.000162 0.000141 0.002206 0.000036 0.000080 +0.000146 0.000139 0.002149 0.000036 0.000060 +0.000169 0.000884 0.002163 0.000036 0.000076 +0.000187 0.000140 0.002222 0.000036 0.000061 +0.000145 0.000140 0.002192 0.000037 0.000084 +0.000145 0.000138 0.002619 0.000039 0.000116 +0.000158 0.000149 0.002213 0.000038 0.000089 +0.000145 0.000183 0.002154 0.000038 0.000089 +0.000162 0.000142 0.002142 0.000037 0.000061 +0.000146 0.000178 0.002401 0.000038 0.000062 +0.000145 0.000150 0.002741 0.000037 0.000081 +0.000147 0.000139 0.002360 0.000040 0.000067 +0.000151 0.000153 0.002459 0.000039 0.000075 +0.000148 0.000155 0.002459 0.000037 0.000091 +0.000153 0.000152 0.002174 0.000036 0.000064 +0.000424 0.000149 0.002116 0.000036 0.000068 +0.000166 0.000168 0.002625 0.000038 0.000076 +0.000146 0.000141 0.002957 0.000038 0.000067 +0.000160 0.000142 0.002501 0.000039 0.000079 +0.000147 0.000143 0.002219 0.000038 0.000066 +0.000160 0.000143 0.002771 0.000040 0.000079 +0.000148 0.000150 0.002426 0.000037 0.000082 +0.000146 0.000138 0.002134 0.000036 0.000103 +0.000659 0.000143 0.002197 0.000036 0.000073 +0.000179 0.000153 0.002301 0.000038 0.000074 +0.000147 0.000142 0.002258 0.000038 0.000066 +0.000146 0.000141 0.002210 0.000038 0.000066 +0.000161 0.000141 0.002235 0.000038 0.000084 +0.000145 0.000138 0.002131 0.000036 0.000060 +0.000151 0.000211 0.002265 0.000038 0.000062 +0.000147 0.000142 0.002254 0.000038 0.000067 +0.000148 0.000143 0.002217 0.000038 0.000079 +0.000160 0.000155 0.002229 0.000038 0.000066 +0.000145 0.000142 0.002129 0.000038 0.000065 +0.000165 0.000140 0.002140 0.000036 0.000076 +0.000162 0.000142 0.002452 0.000039 0.000079 +0.000148 0.000143 0.002253 0.000059 0.000068 +0.000164 0.000142 0.003378 0.000039 0.000096 +0.000150 0.000194 0.002192 0.000039 0.000067 +0.000161 0.000152 0.002202 0.000037 0.000077 +0.000160 0.000141 0.002258 0.000039 0.000067 +0.000167 0.000143 0.002706 0.000039 0.000067 +0.000149 0.000155 0.002280 0.000037 0.000100 +0.000174 0.000144 0.002134 0.000037 0.000090 +0.001167 0.000154 0.002224 0.000038 0.000067 +0.000162 0.000155 0.002181 0.000035 0.000065 +0.000773 0.000153 0.002145 0.000036 0.000060 +0.000149 0.000161 0.002160 0.000036 0.000071 +0.000208 0.000144 0.002164 0.000035 0.000060 +0.000143 0.000138 0.002156 0.000036 0.000064 +0.000143 0.000138 0.002225 0.000055 0.000066 +0.000147 0.000141 0.002734 0.000038 0.000065 +0.000145 0.000147 0.002173 0.000037 0.000064 +0.000146 0.000139 0.002112 0.000037 0.000060 +0.000144 0.000137 0.002708 0.000038 0.000064 +0.000144 0.000139 0.002421 0.000037 0.000064 +0.000145 0.000140 0.002449 0.000037 0.000063 +0.000143 0.000138 0.002278 0.000038 0.000064 +0.000145 0.000140 0.002427 0.000040 0.000130 +0.000151 0.000142 0.002155 0.000036 0.000064 +0.000181 0.000139 0.002435 0.000036 0.000060 +0.000145 0.000138 0.003527 0.000038 0.000065 +0.000146 0.000178 0.002178 0.000036 0.000060 +0.000145 0.000138 0.002139 0.000037 0.000065 +0.000145 0.000137 0.003006 0.000037 0.000064 +0.000146 0.000139 0.002204 0.000037 0.000065 +0.000145 0.000139 0.002211 0.000038 0.000062 +0.000182 0.000140 0.002221 0.000036 0.000061 +0.000145 0.000139 0.003169 0.000038 0.000068 +0.000149 0.000174 0.002414 0.000038 0.000066 +0.000147 0.000142 0.002234 0.000038 0.000066 +0.000149 0.000143 0.002678 0.000038 0.000065 +0.000148 0.000141 0.002886 0.000038 0.000066 +0.000145 0.000140 0.002250 0.000038 0.000065 +0.000148 0.000139 0.002181 0.000035 0.000065 +0.000718 0.000142 0.002141 0.000035 0.000059 +0.000189 0.000140 0.002383 0.000036 0.000059 +0.000145 0.000139 0.002206 0.000039 0.000065 +0.000154 0.000186 0.002457 0.000038 0.000066 +0.000190 0.000141 0.002224 0.000038 0.000066 +0.000149 0.000141 0.002151 0.000037 0.000066 +0.000215 0.000143 0.002151 0.000035 0.000061 +0.000144 0.000138 0.002822 0.000039 0.000065 +0.000147 0.000139 0.002275 0.000038 0.000065 +0.000148 0.000141 0.002211 0.000036 0.000064 +0.000146 0.000138 0.002201 0.000037 0.000066 +0.000148 0.000140 0.002273 0.000038 0.000068 +0.000150 0.000144 0.002188 0.000037 0.000063 +0.000152 0.000151 0.002190 0.000037 0.000062 +0.000146 0.000142 0.003145 0.000039 0.000067 +0.000151 0.000139 0.002218 0.000037 0.000065 +0.000145 0.000138 0.002264 0.000037 0.000066 +0.000148 0.000142 0.003011 0.000039 0.000067 +0.000149 0.000141 0.002196 0.000038 0.000065 +0.000146 0.000141 0.002188 0.000036 0.000060 +0.000149 0.000140 0.002190 0.000035 0.000060 +0.000144 0.000137 0.002641 0.000038 0.000064 +0.000146 0.000138 0.002182 0.000043 0.000065 +0.000146 0.000141 0.002216 0.000036 0.000064 +0.000147 0.000139 0.002294 0.000039 0.000068 +0.000657 0.000145 0.002143 0.000037 0.000062 +0.000154 0.000415 0.002237 0.000040 0.000084 diff --git a/public/gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.html b/public/gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.html new file mode 100644 index 0000000..941c26b --- /dev/null +++ b/public/gce-aws-docker-and-why-i-choose-classic-vms-and-digitalocean.html @@ -0,0 +1,27 @@ +GCE, AWS, Docker and why I choose classic VM’s and DigitalOcean f

GCE, AWS, Docker and why I choose classic VM’s and DigitalOcean f

Published on by Mitja Felicijan

Table of contents

  1. Docker tools and complexity that comes with it
  2. Lack of real life examples of Docker in action
  3. Ease of deployment
  4. Where to go from here

I have been developing a product for the past few months and one of product’s requirement is the ability to automatically scale quickly on system’s demand.

As most of you probably know system design is much more important then actual code that will drive the product. And this was my main concern when developing this product. I have read anything I could get my hands on about Docker as it was hyped so much in media for the past two years. At a first glance Docker was ideal fit for this platform. But then as I started to seriously experiment with it and developing around it several problems occurred. Well, it would be unfair to call them problems but lets say drawbacks when developing rapidly.

To put it in perspective: this project is basically MVP that needs to automatically scale when new customers signs up. These customers are sending metrics to my system that is later visualized and analyzed. There were some basic requirements that I needed the answer before I choose technology.

  • Pricing involving hardware and infrastructure.
  • Ease of implementation/deployment and scaling.
  • How much will this cost me per customer?

The way I envisioned the architecture was straight forward → simple nodes in cluster that take care of x number of customers (1 node ~ 10 customers). I found that pricing in GCE and AWS is very hard to predict → what the cost will be when system would scale. And this was necessary for me to know in order to make financial projection of costs. This is the most important thing for me at this time as I am deciding on prices we should charge future customers and establish healthy revenue model and subsequently business model. I want this product to organically scale and fuel its future development with money made by product itself → very little startup capital (10 nodes for six months & capital for company expanses). I have made many simulations but could not figure out with at least some certainty what will that cost be. Based on this both of the providers are currently not suited for me. So I choose DigitalOcean. They have really straight forward pricing model and this allowed me to make pretty accurate cost matrix for my infrastructure.

I love hard metrics. By this I mean metrics I can test now and have trust they will hold in the future. This was the reason I found Docker too volatile as containers are spawned and halted and there is really no way in predicting this numbers. I have no problem with spawning multiple VMs and not using them but having basically limited control over that is at this time unacceptable for me.

Docker tools and complexity that comes with it

Probably some of you will correct me on this one, but I find all this management tools like Kubernetes, Swarm etc a bit overkill for a startup project. All this tools are able to scale really massively but they all require extensive knowledge of DevOps. When you are a one man band trying to push a product out, there just is no time to learn these tools and concepts in depth in order to really take advantage of their features. It is much easier to use internal metrics of your app (uwsgi stats server, golang middleware stats) and simply fetch them to one server and visualize them. That task alone took me couple of hours and I had simple metrics system in place that with collaboration of DigitalOcean API enabled me to auto spawn new VMs on demand when users reached max number of users supported by current number of nodes. There is something to say about simplicity of this solution. And I love simple solutions.

Lack of real life examples of Docker in action

I found many HelloWorld examples and tutorials showing how to spawn containers and deploying simple python apps but I haven’t found really clear example of showing how to battle permanent storage with containers, load balancing, disk management, ip & port management.

This is not Docker’s nor community’s fault to be absolutely clear. It just shows that it is not that simple to deploy real-world application with Docker. Maybe my software architecture is not designed with Docker in mind.

Ease of deployment

What I really love about Docker is ease of deployment of your application code via container. Multilayered architecture of Docker images also adds to pros list. And the fact that containers sit on top of host OS makes it very intriguing. But if you use container engine from Google you basically spawn VM’s and run containers in this machines and this takes bare-metal approach out of the equation. So at the end you still use hypervisior. I guess if I had my own hardware servers I would be able to fully take advantage of containers.

Because most of my code in nodes is written in Golang and C++ deployment becomes pretty easy. All I have to do is replace binaries on node and that’s that. To avoid downtime I have two instances of one node and I load balance between them. So when I am updating software I first update on node1.A and then node1.B if first one is successful.

Where to go from here

Docker is amazing technology. But the weird pricing model and steep learning curve for deployment of real live application at this time is too much of a hassle for me. I am sure I could lower costs with Docker approach but it would just took too much time at this stage to implement it properly.

I am currently trying to adapt my project to fit Docker and I believe this would be an interesting solution. Idea is to use one container for one customer. I would just need to find the solution for auto-spawning containers on demand for a specific customer. I would then need a flexible load balancer to correctly forward traffic to container designated for this customer. The problem I have is that I need very flexible storage solution because the amount of data that will be aggregated will scale exponentially and I need to permanently store this on disk. And VM approach is allowing me to precisely calculate per customer per VM how much disk I need. Maybe one of you may have a better solution.

\ No newline at end of file diff --git a/public/golang-profiling-simplified.html b/public/golang-profiling-simplified.html new file mode 100644 index 0000000..e1fdefe --- /dev/null +++ b/public/golang-profiling-simplified.html @@ -0,0 +1,94 @@ +Golang profiling simplified

Golang profiling simplified

Published on by Mitja Felicijan

Table of contents

  1. Where are my pprof files?
  2. Why is my cpu profile empty?
  3. Profiling
    1. Memory profiling
    2. CPU profiling
    3. Generating profiling reports

Many posts have been written regarding profiling in Golang and I haven’t found proper tutorial regarding this. Almost all of them are missing some part of important information and it gets pretty frustrating when you have a deadline and are not finding simple distilled solution.

Nevertheless, after searching and experimenting I have found a solution that works for me and probably should also for you.

Where are my pprof files?

By default pprof files are generated in /tmp/ folder. You can override folder where this files are generated programmatically in your golang code as we will see below in example.

Why is my cpu profile empty?

I have found out that sometimes CPU profile is empty because program was not executing long enough. Programs, that execute too quickly don’t produce pprof file in my cases. Well, file is generated but only contains 4KB of information.

Profiling

As you can see from examples we are executing dummy_benchmark functions to ensure some sort of execution. Memory profiling can be done without such a “complex” function. But CPU profiling needs it.

Both memory and CPU profiling examples are almost the same. Only parameters in main function when calling profile.Start are different. When we set profile.ProfilePath(“.”) we tell profiler to store pprof files in the same folder as our program.

Memory profiling

package main
+
+import (
+  "fmt"
+  "time"
+  "github.com/pkg/profile"
+)
+
+func dummy_benchmark() {
+
+  fmt.Println("first set ...")
+  for i := 0; i < 918231333; i++ {
+    i *= 2
+    i /= 2
+  }
+
+  <-time.After(time.Second*3)
+
+  fmt.Println("sencond set ...")
+  for i := 0; i < 9182312232; i++ {
+    i *= 2
+    i /= 2
+  }
+}
+
+func main() {
+  defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
+  dummy_benchmark()
+}
+

CPU profiling

package main
+
+import (
+  "fmt"
+  "time"
+  "github.com/pkg/profile"
+)
+
+func dummy_benchmark() {
+
+  fmt.Println("first set ...")
+  for i := 0; i < 918231333; i++ {
+    i *= 2
+    i /= 2
+  }
+
+  <-time.After(time.Second*3)
+
+  fmt.Println("sencond set ...")
+  for i := 0; i < 9182312232; i++ {
+    i *= 2
+    i /= 2
+  }
+}
+
+func main() {
+  defer profile.Start(profile.CPUProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
+  dummy_benchmark()
+}
+

Generating profiling reports

# memory profiling
+go build mem.go
+./mem
+go tool pprof -pdf ./mem mem.pprof > mem.pdf
+
+# cpu profiling
+go build cpu.go
+./cpu
+go tool pprof -pdf ./cpu cpu.pprof > cpu.pdf
+

This will generate PDF document with visualized profile.

\ No newline at end of file diff --git a/public/how-we-successfully-destroyed-the-joy-of-product-development.html b/public/how-we-successfully-destroyed-the-joy-of-product-development.html new file mode 100644 index 0000000..534a966 --- /dev/null +++ b/public/how-we-successfully-destroyed-the-joy-of-product-development.html @@ -0,0 +1,27 @@ +How we successfully destroyed the joy of product development

How we successfully destroyed the joy of product development

Published on by Mitja Felicijan

No matter how hard we try to reinvent processes in software development we still haven’t found perfect solution for this. And to dismiss SDLC just because it’s something old is as ridiculous as the concept of designers being user experience gurus. As I have written couple of times before designers have their place and is not in the UX community. Most of them probably never heard of Jakob Nielsen and this proves a lot. Don’t get me wrong. There are designers out there that are absolutely amazing in what they do, but most of them are not. Good design has little to do with how things look in my opinion. But it has very much to do with how product behaves. And to take a chance on design look only is scary to me.

I have this huge beef with so called UX “experts”. I really do. From the bottom of my heart. I almost hate them. Well, not the pure ghetto ones. There are many of them out there I am sure of. But I have not had the pleasure to work with such person.

Good UX expert should have programming background and an eye for design. Being UX expert requires you to be analytical and precise. Not really qualities of designers. Design is much more about the feeling and emotional perception. And this two don’t dance well together.

Natural progression of project focused on user should be:

  • detailed requirements and fantastic prototypes/wireframes with detailed user journey diagrams,
  • design focused and restricted to serve requirements,
  • code written just to fulfill design and requirements → nothing more and nothing less → no additional dead code should be allowed,
  • testing should be done on all targeted devices → avoid bugs and you will avoid brand failure.

Designer should never be allowed to have blank canvas. Good software is written because there are many restrictions either in requirements or real world. And most importantly → good software is solving only one problem at the time. I don’t see why this shouldn’t apply to design as well.

Yes yes we get it, but we don’t have the time or the money to do project development like that. Well, you better find it or you will slowly decline into abyss of mediocre companies that have nothing to show for. Clients are not dumb and are in need of quality products and services. It is not enough anymore for a product that just works. It has to be technically precise and functionally on the spot.

When developers and designers are forced to think and work from the scratch many new doors open. New ideas are born how to solve problems that were previously not possible because they were living in a box of limited thought and patterns. If you solve problems always only with your knowledge nothing new can be invented. When there is no room for experimentation there is no room for improvement. You want your developers and designers to be this fountain of innovation and you don’t really let them innovate, you are just slowly closing front doors of your company. Good developers and designers are hard to find and even easier to loose.

Being agile does not mean to be a slave of constant changes. It does not mean that project managers can constantly change requirements at their will. And it sure does not mean that clear vision on product direction should be something we said goodby to. We have perverted initial intention of Manifesto for Agile Software Development as we always do. We have taken it so far and we have all become slaves of advertisement by consulting companies trying to cash in on this “new - but old” concept.

Manifesto for Agile Software Development states:

  • individuals and interactions over processes and tools,
  • working software over comprehensive documentation,
  • customer collaboration over contract negotiation,
  • responding to change over following a plan.

This was written in times when software was developed very differently than how we do it now. We have eliminated many of the problems from old age just by listening to reason and not trendy hyped words that are just tools of marketing strategist to avoid the real issues. Being flat, being agile, being stupid is what I say.

Development and design should be about improving yourself and consequently product you are working on. When this becomes a chore you should probably start thinking about changing companies. People make products not management.

\ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..108a5b7 --- /dev/null +++ b/public/index.html @@ -0,0 +1,27 @@ +Mitja Felicijan - Embedded systems developer
\ No newline at end of file diff --git a/public/profiling-python-web-applications-with-visual-tools.html b/public/profiling-python-web-applications-with-visual-tools.html new file mode 100644 index 0000000..931ffe5 --- /dev/null +++ b/public/profiling-python-web-applications-with-visual-tools.html @@ -0,0 +1,139 @@ +Profiling Python web applications with visual tools

Profiling Python web applications with visual tools

Published on by Mitja Felicijan

Table of contents

  1. Simple web-service
  2. Visualize profile
  3. Update 2017-04-22

I have been profiling my software with KCachegrind for a long time now and I was missing this option when I am developing API’s or other web services. I always knew that this is possible but never really took the time and dive into it.

Before we begin there are some requirements. We will need to:

If you are using MacOS you should check out Profiling Viewer or MacCallGrind.

KCachegrind

We will be dividing this post into two main categories:

  • writing simple web-service,
  • visualize profile of this web-service.

Simple web-service

Let’s use virtualenv so we won’t pollute our base system. If you don’t have virtualenv installed on your system you can install it with pip command.

# let's install virtualenv globally
+$ sudo pip install virtualenv
+
+# let's also install pyprof2calltree globally
+$ sudo pip install pyprof2calltree
+
+# now we create project
+$ mkdir demo-project
+$ cd demo-project/
+
+# now let's create folder where we will store profiles
+$ mkdir prof
+
+# now we create empty virtualenv in venv/ folder
+$ virtualenv --no-site-packages venv
+
+# we now need to activate virtualenv
+$ source venv/bin/activate
+
+# you can check if virtualenv was correctly initialized by
+# checking where your python interpreter is located
+# if command bellow points to your created directory and not some
+# system dir like /usr/bin/python then everything is fine
+$ which python
+
+# we can check now if all is good ➜ if ok couple of
+# lines will be displayed
+$ pip freeze
+# appdirs==1.4.3
+# packaging==16.8
+# pyparsing==2.2.0
+# six==1.10.0
+
+# now we are ready to install bottlepy ➜ web micro-framework
+$ pip install bottle
+
+# you can deactivate virtualenv but you will then go
+# under system domain ➜ for now don't deactivate
+$ deactivate
+

We are now ready to write simple web service. Let’s create file app.py and paste code bellow in this newly created file.

# -*- coding: utf-8 -*-
+
+import bottle
+import random
+import cProfile
+
+app = bottle.Bottle()
+
+# this function is a decorator and encapsulates function
+# and performs profiling and then saves it to subfolder
+# prof/function-name.prof
+# in our example only awesome_random_number function will
+# be profiled because it has do_cprofile defined
+def do_cprofile(func):
+  def profiled_func(*args, **kwargs):
+    profile = cProfile.Profile()
+    try:
+      profile.enable()
+      result = func(*args, **kwargs)
+      profile.disable()
+      return result
+    finally:
+      profile.dump_stats("prof/" + str(func.__name__) + ".prof")
+  return profiled_func
+
+
+# we use profiling over specific function with including
+# @do_cprofile above function declaration
+@app.route("/")
+@do_cprofile
+def awesome_random_number():
+  awesome_random_number = random.randint(0, 100)
+  return "awesome random number is " + str(awesome_random_number)
+
+@app.route("/test")
+def test():
+  return "dummy test"
+
+if __name__ == '__main__':
+  bottle.run(
+    app = app,
+    host = "0.0.0.0",
+    port = 4000
+  )
+
+# run with 'python app.py'
+# open browser 'http://0.0.0.0:4000'
+

When browser hits awesome_random_number() function profile is created in prof/ subfolder.

Visualize profile

Now let’s create callgrind format from this cProfile output.

$ cd prof/
+$ pyprof2calltree -i awesome_random_number.prof
+# this creates 'awesome_random_number.prof.log' file in the same folder
+

This file can be opened with visualizing tools listed above. In this case we will be using Profilling Viewer under MacOS. You can open image in new tab. As you can see from this example there is hierarchy of execution order of your code.

Profilling Viewer

Make sure you convert output of the cProfile output every time you want to refresh and take a look at your possible optimizations because cProfile updates .prof file every time browser hits the function.

This is just a simple example but when you are developing real-life applications this can be very illuminating, especially to see which parts of your code are bottlenecks and need to be optimized.

Update 2017-04-22

Reddit user mvt also recommended this awesome web based profile visualizer SnakeViz that directly takes output from cProfile module.

# let's install it globally as well
+$ sudo pip install snakeviz
+
+# now let's visualize
+$ cd prof/
+$ snakeviz awesome_random_number.prof
+# this automatically opens browser window and
+# shows visualized profile
+

SnakeViz

Reddit user ccharles suggested a better way for installing pip software by targeting user level instead of using sudo.

# now we need to add this path to our $PATH variable
+# we do this my adding this line at the end of your
+# ~/.bashrc file
+PATH=$PATH:$HOME/.local/bin/
+
+# in order to use this new configuration you can close
+# and reopen terminal or reload .bashrc file
+$ source ~/.bashrc
+
+# now let's test if new directory is present in $PATH
+$ echo $PATH
+
+# now we can install on user level by adding --user
+# without use of sudo
+$ pip install snakeviz --user
+

Or as suggested by mvt you can use pipsi.

\ No newline at end of file diff --git a/public/simple-iot-application.html b/public/simple-iot-application.html new file mode 100644 index 0000000..d5fcbe8 --- /dev/null +++ b/public/simple-iot-application.html @@ -0,0 +1,340 @@ +Simple IOT application supported by real-time monitoring and data

Simple IOT application supported by real-time monitoring and data

Published on by Mitja Felicijan

Table of contents

  1. Initial thoughts
  2. Simple Python API
    1. Basic web application
    2. Web application security
    3. Simple API for writing data-points
  3. Sending data to API with Arduino MKR1000
  4. Data visualization
  5. Conclusion

Initial thoughts

I have been developing these kind of application for the better part of my last 5 years and people keep asking me how to approach developing such application and I will give a try explaining it here.

IOT applications are really no different than any other kind of applications. We have data that needs to be collected and visualized in some form of tables or charts. The main difference here is that most of the times these data is collected by some kind of device foreign to developer that mainly operates in web domain. But fear not, it’s not that different than writing some JavaScript.

There are many devices able to transmit data via wireless or wired network by default but for the sake of example we will be using commonly known Arduino with wireless module already on the board → Arduino MKR1000.

In order to make this little project as accessible to others as possible I will try to make it as inexpensive as possible. And by this I mean that I will avoid using hosted virtual servers and will be using my own laptop as a server. But you must buy Arduino MKR1000 to follow steps below. But if you would want to deploy this software I would suggest using DigitalOcean → smallest VPS is only per month making this one of the most affordable option out there. Please notice that this software will not run on stock web hosting that only supports LAMP (Linux, Apache, MySQL, and PHP).

But before we begin please take notice that this is strictly experimental code and not well optimized and there are much better ways in handling some aspects of the application but that requires much deeper knowledge of technology that is not needed for an example like this.

Development steps

  1. Simple Python API that will receive and store incoming data.
  2. Prototype C++ code that will read “sensor data” and transmit it to API.
  3. Data visualization with charts → extends Python web application.

Step 1. and 3. will share the same web application. One route will be dedicated to API and another to serving HTML with chart.

Schema below represents what we will try to achieve and how different parts correlates to each other.

Overview

Simple Python API

I have always been a fan of simplicity so we will be using Bottle: Python Web Framework. It is a single file web framework that seriously simplifies working with routes, templating and has built-in web server that satisfies our need in this case.

First we need to install bottle package. This can be done by downloading bottle.py and placing it in the root of your application or by using pip software pip install bottle --user.

If you are using Linux or MacOS then Python is already installed. If you will try to test this on Windows please install Python for Windows. There may be some problems with path when you will try to launch python webapp.py so please take care of this before you continue.

Basic web application

Most basic bottle application is quite simple. Paste code below in webapp.py file and save.

# -*- coding: utf-8 -*-
+
+import bottle
+
+# initializing bottle app
+app = bottle.Bottle()
+
+# triggered when / is accessed from browser
+# only accepts GET → no POST allowed
+@app.route("/", method=["GET"])
+def route_default():
+  return "howdy from python"
+
+# starting server on http://0.0.0.0:5000
+if __name__ == "__main__":
+  bottle.run(
+    app = app,
+    host = "0.0.0.0",
+    port = 5000,
+    debug = True,
+    reloader = True,
+    catchall = True,
+  )
+

To run this simple application you should open command prompt or terminal on your machine and go to the folder containing your file and type python webapp.py. If everything goes ok then open your web browser and point it to http://0.0.0.0:5000.

If you would like change the port of your application (like port 80) and not use root to run your app this will present a problem. The TCP/IP port numbers below 1024 are privileged ports → this is a security feature. So in order of simplicity and security use a port number above 1024 like I have used port 5000.

If this fails at any time please fix it before you continue, because nothing below will work otherwise.

We use 0.0.0.0 as default host so that this app is available over your local network. If you find your local ip ifconfig and try accessing this site with your phone (if on same network/router as your machine) this should work as well (example of such ip http://192.168.1.15:5000). This is a must have because Arduino will be accessing this application to send it’s data.

Web application security

There is a lot to be said about security and is a topic of many books. Of course all this can not be written here but to just establish some basic security → you should always use SSL with your application. Some fantastic free certificates are available by Let’s Encrypt - Free SSL/TLS Certificates. With SSL certificate installed you should then make use of HTTP headers and send your “API key” via a header. If your key is send via header then this key is encrypted by SSL and send encrypted over the network. Never send your api keys by GET parameter like http://example.com/?api_key=somekeyvalue. The problem that this kind of sending presents is that this key is visible in logs and by network sniffers.

There is a fantastic article describing some aspects about security: 11 Web Application Security Best Practices. Please check it out.

Simple API for writing data-points

We will now be using boilerplate code from example above and extend it to be able to write data received by API to local storage. For example use I will use SQLite3 because it plays well with Python and can store quite large amount of data. I have been using it to collect gigabytes of data in a single database without any corruption or problems → your experience may vary.

To avoid learning SQLite I will be using Dataset: databases for lazy people. This package abstracts SQL and simplifies writing and reading data from database. You should install this package with pip software pip install dataset --user.

Because API will use POST method I will be testing if code works correctly by using Restlet Client for Google Chrome. This software also allows you to set headers → for basic security with API_KEY.

To quickly generate passwords or API keys I usually use this nifty website RandomKeygen.

Copy and paste code below over your previous code in file webapp.py.

# -*- coding: utf-8 -*-
+
+import time
+import bottle
+import random
+import dataset
+
+# initializing bottle app
+app = bottle.Bottle()
+
+# connects to sqlite database
+# check_same_thread=False allows using it in multi-threaded mode
+app.config["dsn"] = dataset.connect("sqlite:///data.db?check_same_thread=False")
+
+# api key that will be used in Arduino code
+app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH"
+
+# triggered when /api is accessed from browser
+# only accepts POST → no GET allowed
+@app.route("/api", method=["POST"])
+def route_default():
+  status = 400
+  ts = int(time.time()) # current timestamp
+  value = bottle.request.body.read() # data from device
+  api_key = bottle.request.get_header("Api_Key") # api key from header
+
+  # outputs to console received data for debug reason
+  print ">>> {} :: {}".format(value, api_key)
+
+  # if api_key is correct and value is present
+  # then writes attribute to point table
+  if api_key == app.config["api_key"] and value:
+    app.config["dsn"]["point"].insert(dict(ts=ts, value=value))
+    status = 200
+
+  # we only need to return status
+  return bottle.HTTPResponse(status=status, body="")
+
+# starting server on http://0.0.0.0:5000
+if __name__ == "__main__":
+  bottle.run(
+    app = app,
+    host = "0.0.0.0",
+    port = 5000,
+    debug = True,
+    reloader = True,
+    catchall = True,
+  )
+

To run this simply go to folder containing python file and run python webapp.py from terminal. If everything goes ok you should have simple API available via POST method on /api route.

After testing the service with Restlet Client you should be able to view your data in a database file data.db.

REST settings example

You can also check the contents of new database file by using desktop client for SQLite → DB Browser for SQLite.

SQLite database example

Table structure is as simple as it can be. We have ts (timestamp) and value (value from Arduino). As you can see timestamp is generated on API side. If you would happen to have atomic clock on Arduino it would be then better to generate and send timestamp with the value. This would be particularity useful if we would be collecting sensor data at a higher frequency and then sending this data in bulk to API.

If you will deploy this app with uWSGI and multi-threaded, use DSN (Data Source Name) url with ?check_same_thread=False.

Ok, now that we have some sort of a working API with some basic security so unwanted people can not post data to your database can we proceed further and try to program Arduino to send data to API.

Sending data to API with Arduino MKR1000

First of all you should have MKR1000 module and microUSB cable to proceed. If you have ever done any work with Arduino you should know that you also need Arduino IDE. On provided link you should be able to download and install IDE. Once that task is completed and you have successfully run blink example you should proceed to the next step.

In order to use wireless capabilities of MKR1000 you need to first install WiFi101 library in Arduino IDE. Please check before you install, you may already have it installed.

Code below is a working example that sends data to API. Before you try to test your code make sure you have run Python web application. Then change settings for wifi, api endpoint and api_key. If by some reason code bellow doesn’t work for you please leave a comment and I’ll try to help.

Once you have opened IDE and copied this code try to compile and upload it. Then open “Serial monitor” to see if any output is presented by Arduino.

#include <WiFi101.h>
+
+// wifi settings
+char ssid[] = "ssid-name";
+char pass[] = "ssid-password";
+
+// api server enpoint
+char server[] = "192.168.6.22";
+int port = 5000;
+
+// api key that must be the same as the one in Python code
+String api_key = "JtF2aUE5SGHfVJBCG5SH";
+
+// frequency data is sent in ms - every 5 seconds
+int timeout = 1000 * 5;
+
+int status = WL_IDLE_STATUS;
+
+void setup() {
+
+  // initialize serial and wait for port to open:
+  Serial.begin(9600);
+  delay(1000);
+
+  // check for the presence of the shield
+  if (WiFi.status() == WL_NO_SHIELD) {
+    Serial.println("WiFi shield not present");
+    while (true);
+  }
+
+  // attempt to connect to wifi network
+  while (status != WL_CONNECTED) {
+    Serial.print("Attempting to connect to SSID: ");
+    Serial.println(ssid);
+    status = WiFi.begin(ssid, pass);
+    // wait 10 seconds for connection
+    delay(10000);
+  }
+
+  // output wifi status to serial monitor
+  Serial.print("SSID: ");
+  Serial.println(WiFi.SSID());
+
+  IPAddress ip = WiFi.localIP();
+  Serial.print("IP Address: ");
+  Serial.println(ip);
+
+  long rssi = WiFi.RSSI();
+  Serial.print("signal strength (RSSI):");
+  Serial.print(rssi);
+  Serial.println(" dBm");
+}
+
+void loop() {
+
+  WiFiClient client;
+
+  if (client.connect(server, port)) {
+
+    // I use random number generator for this example
+    // but you can use analog or digital inputs from arduino
+    String content = String(random(1000));
+
+    client.println("POST /api HTTP/1.1");
+    client.println("Connection: close");
+    client.println("Api-Key: " + api_key);
+    client.println("Content-Length: " + String(content.length()));
+    client.println();
+    client.println(content);
+
+    delay(100);
+    client.stop();
+    Serial.println("Data sent successfully ...");
+
+  } else {
+    Serial.println("Problem sending data ...");
+  }
+
+  // waits for x seconds and continue looping
+  delay(timeout);
+
+}
+

As seen from example you can notice that Arduino is generating random integer between [ 0 … 1000 ]. You can easily replace this with a temperature sensor or any other kind of sensor.

Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization.

Data visualization

Before we continue we should examine our project folder structure. Currently we only have two files in our project:

simple-iot-app/

  • webapp.py
  • data.db

We will now add HTML template that will contain CSS and JavaScript code inline for the simplicity reason. And for the bottle framework to be able to scan root application folder for templates we will add bottle.TEMPLATE_PATH.insert(0, "./") in webapp.py. By default bottle framework uses views/ subfolder to store templates. This is not the ideal situation and if you will use bottle to develop web applications you should use native behavior and store templates in it’s predefined folder. But for the sake of example we will over-ride this. Be careful to fully replace your code with new code that is provided below. Avoid partially replacing code in file :) Also new code for reading data-points is provided in Python example below.

First we add new route to our web application. It should be trigger when browser hits root of application http://0.0.0.0:5000/. This route will do nothing more than render frontend.html template. This is done by return bottle.template("frontend.html"). Check code below to further examine how exactly this is done.

Now we will expand /api route and use different methods to write or read data-points. For writing data-point we will use POST method and for reading points we will use GET method. GET method will return JSON object with latest readings and historical data.

There is a fantastic JavaScript library for plotting time-series charts called MetricsGraphics.js that is based on D3.js library for visualizing data.

Data schema required by MetricsGraphics.js → to achieve this we need to transform data from database into this format:

[
+  {
+    "date": "2017-08-11 01:07:20",
+    "value": 933
+  },
+  {
+    "date": "2017-08-11 01:07:30",
+    "value": 743
+  }
+]
+

Web application is now complete and we only need frontend.html that we will develop now. If you would try to start web app now and go to root app this will return error because we don’t have frontend.html yet.

# -*- coding: utf-8 -*-
+
+import time
+import bottle
+import json
+import datetime
+import random
+import dataset
+
+# initializing bottle app
+app = bottle.Bottle()
+
+# adds root directory as template folder
+bottle.TEMPLATE_PATH.insert(0, "./")
+
+# connects to sqlite database
+# check_same_thread=False allows using it in multi-threaded mode
+app.config["db"] = dataset.connect("sqlite:///data.db?check_same_thread=False")
+
+# api key that will be used in Arduino code
+app.config["api_key"] = "JtF2aUE5SGHfVJBCG5SH"
+
+# triggered when / is accessed from browser
+# only accepts GET → no POST allowed
+@app.route("/", method=["GET"])
+def route_default():
+  return bottle.template("frontend.html")
+
+# triggered when /api is accessed from browser
+# accepts POST and GET
+@app.route("/api", method=["GET", "POST"])
+def route_default():
+
+  # if method is POST then we write datapoint
+  if bottle.request.method == "POST":
+    status = 400
+    ts = int(time.time()) # current timestamp
+    value = bottle.request.body.read() # data from device
+    api_key = bottle.request.get_header("Api-Key") # api key from header
+
+    # outputs to console recieved data for debug reason
+    print ">>> {} :: {}".format(value, api_key)
+
+    # if api_key is correct and value is present
+    # then writes attribute to point table
+    if api_key == app.config["api_key"] and value:
+      app.config["db"]["point"].insert(dict(ts=ts, value=value))
+      status = 200
+
+      # we only need to return status
+      return bottle.HTTPResponse(status=status, body="")
+
+  # if method is GET then we read datapoint
+  else:
+    response = []
+    datapoints = app.config["db"]["point"].all()
+
+    for point in datapoints:
+      response.append({
+        "date": datetime.datetime.fromtimestamp(int(point["ts"])).strftime("%Y-%m-%d %H:%M:%S"),
+        "value": point["value"]
+      })
+
+    bottle.response.content_type = "application/json"
+    return json.dumps(response)
+
+# starting server on http://0.0.0.0:5000
+if __name__ == "__main__":
+  bottle.run(
+    app = app,
+    host = "0.0.0.0",
+    port = 5000,
+    debug = True,
+    reloader = True,
+    catchall = True,
+  )
+

And now finally we can implement frontend.html. Create file with this name and copy code below. When you are done you can start web application. Steps for this part are listed below the code.

<!DOCTYPE html>
+<html>
+
+  <head>
+    <meta charset="utf-8">
+    <title>Simple IOT application</title>
+  </head>
+
+  <body>
+
+    <h1>Simple IOT application</h1>
+
+    <div class="chart-placeholder">
+      <div id="chart"></div>
+    </div>
+
+    <!-- application main script -->
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/metrics-graphics/2.11.0/metricsgraphics.min.js"></script>
+    <script>
+      function fetch_and_render() {
+        d3.json("/api", function(data) {
+          data = MG.convert.date(data, "date", "%Y-%m-%d %H:%M:%S");
+          MG.data_graphic({
+            data: data,
+            chart_type: "line",
+            full_width: true,
+            height: 270,
+            target: document.getElementById("chart"),
+            x_accessor: "date",
+            y_accessor: "value"
+          });
+        });
+      }
+      window.onload = function() {
+        // initial call for rendering
+        fetch_and_render();
+
+        // updates chart every 5 seconds
+        setInterval(function() {
+          fetch_and_render();
+        }, 5000);
+      }
+    </script>
+
+    <!-- application styles -->
+    <style>
+      body {
+        font: 13px sans-serif;
+        padding: 20px 50px;
+      }
+      .chart-placeholder {
+        border: 2px solid #ccc;
+        width: 100%;
+        user-select: none;
+      }
+      /* chart styles */
+      .mg-line1-color {
+        stroke: red;
+        stroke-width: 2;
+      }
+      .mg-main-area, .mg-main-line {
+        fill: #fff;
+      }
+      .mg-x-axis line, .mg-y-axis line {
+        stroke: #b3b2b2;
+        stroke-width: 1px;
+      }
+    </style>
+
+  </body>
+
+</html>
+

Now the folder structure should look like:

simple-iot-app/

  • webapp.py
  • data.db
  • frontend.html

Ok, lets now start application and start feeding it data.

  1. python webapp.py
  2. connect Arduino MKR1000 to power source
  3. open browser and go to http://0.0.0.0:5000

If everything goes well you should be seeing new data-points rendered on chart every 5 seconds.

If you navigate to http://0.0.0.0:5000 you should see rendered chart as shown on picture below.

Application output

Complete application with all the code is available for download.

Conclusion

I hope this clarifies some aspects of IOT application development. Of course this is a minimal example and is far from what can be done in real life with some further dive into other technologies.

If you would like to continue exploring IOT world here are some interesting resources for you to examine:

Any comment or additional ideas are welcomed in comments below.)

\ No newline at end of file diff --git a/public/software-development-pitfalls.html b/public/software-development-pitfalls.html new file mode 100644 index 0000000..6767c71 --- /dev/null +++ b/public/software-development-pitfalls.html @@ -0,0 +1,27 @@ +Software development and my favorite pitfalls

Software development and my favorite pitfalls

Published on by Mitja Felicijan

Table of contents

  1. Initial thoughts
  2. Ping emails
  3. Everybody is a project manager
  4. We are never wrong
  5. Micromanaging
  6. Human contact, no need for it!
  7. MVP is killing innovation
  8. Pressure wasteland
  9. Conclusion

Initial thoughts

Over the years I had privilege to work on some very excited projects both in software development field and also in electronics field and every experience taught me some invaluable lessons about how NOT TO approach development. And through this post I will try to point out some of the absurd outdated techniques I find the most annoying and damaging during a development cycle. There will be swearing because this topic really gets on my nerves and I never coherently tried to explain them in writing. So if I get heated up please bare with me :)

As new methods of project management are emerging, underlaying processes still stay old and outdated. This is mainly because we as people are unable to completely shift away from this approaches.

I was always struggling with communication, and many times that cost me a relationship or two because I was not on the ball all the time. Through every experience I became more convinced that I am the problem and never ever doubted that the problem may be that communication never evolved a single step from emails. And if you think for a second, not many thing have changed around this topic. We just have different representations of email (message boards, chats, project management tools). And I believe this is the real problem we are facing now.

There are many articles written about hyper connectivity and the effects that are a direct result of it. But mainstream does nothing towards it. We are just putting out fires and we do nothing to prevent it. I am certain this will be a major source of grief in coming years. And what we all can do to avoid this is to change our mindset and experiment on our communication skills, development approaches. We need to maximize possible output that a person can give. And to achieve this we need to listen to them, encourage them. I know that not everybody is a naturally born leader, but everybody has an opinion.

There are many talks right now about methodologies such as Scrum, Kanban, Cleanroom and they all fucking piss me of :). These are all boxes that imprison people and take away their freedom of thought. This is a straight forward mindfuck / amputation of creativity.

Let me list a couple of things that I find really destructive and bad for a project and in a long run company.

Ping emails

Ping emails are emails you have to write as soon as you receive an email. It’s sole purpose is to inform sender that you received their email and you are working on it. It’s result is only to calm down the sender that their task is being dealt with. It’s intent basically is, I did my job by sending you this email so I am on clear ground. I categorize this email as fuck you email. This is one of the most irritating types of emails I need to write. This is the ultimate control freak show you can experience and it gives sender false feeling of control. Newsflash: We do not live in 1982 where there was a possibility that email never reached destination. I really fucking hate this from the bottom of my heart :)

They should be like: “Yes, I am fucking alive and I am at your service my leash!”. I guess if I would reply like this, I wouldn’t have to write any more of this kind of messages :)

Everybody is a project manager

Well, this is a tough one. I noticed that as soon as you let people to give their suggestions you are basically fucked. There is a truth in saying: “Give low expectations and deliver little bit more you promised.”.

People tend to take a role of a manager as soon as they are presented with an opportunity. And by getting angry at them you only provoke yourself. They are not at fault. You just need to tell them they are only giving suggestions and not tasks at the beginning and everything will be alright. But if you give them a feeling that they are in control you will have immense problems explaining why their features are not in current release.

Project mission must be always on the top of project requirements and any deviation from it will result in major project butchering. And by this I mean that project will get it’s own path and you will be left with half done software that helps nobody. Clear mission goal and clean execution will allow you to develop software will clear intent.

We are never wrong

I find this type of arrogance the worst. We must always conduct ourselves that we are infallible and cannot make mistakes. As soon as procedure or process is established there is no room for changes or improvements. This is the most idiotic thing someone can say of think. If think that processes need to involve and change over time. This is imperative and need to have in your organization if you want to improve and develop company. We all need to grow balls and change everything in order to adapt to current situations. Being a prisoner of predefined processes kills creativity.

I am constantly trying new software for project managing and communication. I believe every team has it’s own dynamic and it needs to be discovered organically and naturally through many experiments. By putting team in a box you are amputating their creativity and therefore minimizing their potential. But if you talk to an executive you will mainly find archetypical thinking and a strong need to compartmentalize everything from business processes to resource management. And this type of management that often displays micro management technique only works on short periods (couple of years) and then employees either leave company or become basically retarded drones on auto pilot.

Micromanaging

This basically implies that everybody on the team is a fucking idiot that needs to have a todo list that they can not write themselves. How about spoon feeding the team at launch because besides the team leader everybody must be a retarded idiot at best.

I prefer milestones as they give developers much more freedom and creativity developing and not waste their time checking some bizarre todo list that was not even thought through. Project always changes through development cycle and all you are left at the end is a list of unchecked tasks and the wrath of management why they are not completed. Best WTF moment!

Human contact, no need for it!

We are vigorously trying to eliminate physical contact by replacing short meetings with software with no regards that we are not machines. Many times a simple 5min meeting at morning can solve most of the problems. In rapid development short bursts of man to man communication is possibly the best way to go.

We now have all this software available and all what we get out of it is a huge clusterfuck. An obstacle and not a solution. So why we still use them? Because we strive to better ourselves.

MVP is killing innovation

Many will disagree with me on this one but I stand strong by this statement. What I noticed in my experience that all this buzz words surrounding us only mislead and capture you in a circle of solving a problem that already has a solution but we are unable to see it without using some fancy word for it. The toughest this to do for a developer is to minimize requirements. Well this is though only for bad developers. Yes, I said is. There are many types of developers out there. And those unable to minimize feature scope are the ones you don’t need on your team. Their only goal is to solve problems that exist only in their fucking heads. And than you have to argue with them and waste energy on them instead of developing your awesome product. They are a cancer and I suggest you cut them off.

MVP as an idea is great but sadly people don’t understand underlaying philosophy and they spent too much time focusing and fixating on something that every sane person with normal IQ will understand without some made up acronym. And the result is a lot of talking and barely no execution.

Well MVP is not directly killing innovation but stupid people do when they try to understand it.

Pressure wasteland

You must never allow to be pressured into confirming a deadline if you are not sure. We often feel a need that we are in service of others which is true to some extent. But it is also true that others are in service to us to some extent. And we forget this. We are all pressured all the time to make decisions just to calm other people down. And when they leave your office you experience WTF moment :) How the hell did they manage to fuck me up again :)

People need to realize that more pressure you put on somebody less they will be able todo. So 5 min update email requests will only resolve in mental breakdown and inability to work that day. Constant poking is probably the only thing I loose my mind instantly. For all you that are doing this: “We are not fucking idiots and stop bothering us with your own insecurities and let us do our job. We will do it quicker and better without you moron breathing on our necks.”

If this happens to me I end up with no energy at the end. Don’t you get it? You will get much more from and out of me if you ask me like a human person and not your personal butler. On a long run you are destroying your relationships and nobody would want to work with you. Your schizophrenic approach will damage only you in a long run. Nobody is anybody’s property.

Conclusion

I am guilty of many things described in this post. And I find it hard sometimes to acknowledge this. And I lie to myself and try vigorously to find some explanation why I do this things. There is always space for growth. And maybe you will also find some of yourself in this post and realize what needs to change in order to evolve.

\ No newline at end of file diff --git a/public/test.css b/public/test.css new file mode 100644 index 0000000..e69de29 diff --git a/public/the-bullshit-web-developments-pov.html b/public/the-bullshit-web-developments-pov.html new file mode 100644 index 0000000..366fe5e --- /dev/null +++ b/public/the-bullshit-web-developments-pov.html @@ -0,0 +1,27 @@ +The Bullshit Web - Development's Point of View

The Bullshit Web - Development's Point of View

Published on by Mitja Felicijan

Table of contents

  1. Initial thoughts
  2. Front-end frameworks
  3. Obsolescence to the rescue
  4. Unnecessary complexity
  5. Speed of development trumps code quality
  6. Load times of most popular websites

Initial thoughts

I have recently read an amazing essay by Nick Heer on the web called The Bullshit Web and it got me thinking about the future of the web as it is today.

The average internet connection in the United States is about six times as fast as it was just ten years ago, but instead of making it faster to browse the same types of websites, we’re simply occupying that extra bandwidth with more stuff.

– Nick Heer

I really try to stray away from frond-end development as much as possible. The reason is nowhere close to me having any bad opinions but having to work with clients on visual stuff drains me to the point of sheer horror.

I have observed silently the progress that was made in this field because I thought things will get better with time. I was so wrong. So wrong. Not only that things got extremely complicated to work with, the whole stack became so massive even simple pages have insanely large footprint.

The Bullshit Web essay concentrates mostly on page sizes and AMP but I would like to address tooling and technologies for development in this post.

Currently we have two types of websites:

  • informational websites,
  • web applications.

The problem that occurs is that more and more websites are treathed as web application where simple web page would suffice. And this in my opinion adds insult to the injury.

We talk about progressive web applications, AMP, and other technologies that are solving the problems of bandwidth, usability and in general making web faster but in reality this rarely gets applied in real life scenarios. Most of the time this are just demos on conferences.

Front-end frameworks

I am not of those purists that denies usage of JavaScript frameworks or SASS but there are limits to where this obsession should go. In order to use these technologies properly one should ask himself where exactly they are needed and not use them like hammer for nails.

Whenever I need to do front-end UI I usually check specification before embarking on journey of coding. And most of the times I really don’t need frameworks. Most of the code I need to write in JavaScript is done in couple of hundred lines of code and does exactly what specification requires. And developer that will be working on this code after me doesn’t need to learn new framework, tooling, etc. Just pure vanilla JavaScript. In all of my years as a developer I can count on fingers on my one hand when I used some sort of a framework. And even in this exceptions we later rewrote code to vanilla JavaScript because maintaining complex code was just to time consuming.

There is an argument to be made for using frameworks in cases where multiple people are working a project and code must be easily transferable and on-boarding process must be swift. But in reality this is just another bullshit excuse to stick with what is “cool”. I stand by Function over Form. And this also conflicts with the notion that frameworks never change. Frameworks evolve and adapt to market needs and most of the times get massive and hard to maintain. And we get stuck with massive codebase that is developed with many hacks and workarounds, because framework didn’t support some feature at the time of development. I personally hate workarounds and being a smart-ass that intentionally makes code harder to read. I find frameworks similar to the story about Cain and Abel. Either you get murdered or framework gets. Most of the times framework dies and leaves legacy nobody would want.

Huge strives have been made to address this problem and many fantastic frameworks emerged and some of theme are absolutely amazing. But there needs to be a strong case for using them in a project. We should never blindly use them regardless of the problem we are trying to solve.

I must admit that tooling around front-end is getting better and better and we are slowly getting there but there still is a long road ahead.

Obsolescence to the rescue

We can all agree that frameworks or libraries usually are there to fill the gap what currently is widely supported by the standard. Most of this so called frameworks are just libraries that unifies browser compatibility. The prime example of this is jQuery. There was a time almost everybody was using jQuery. But through time HTML5 specs were updated to include ideas from jQuery and this filled the browser compatibility gap. There is this awesome article The Rise and Fall of jQuery.

Don’t get me wrong. Yes, I dislike jQuery but I find it indispensable and without it our web would be very different. For the worst in my opinion. It was a huge stepping stone for front-end development. But there comes a time where technologies get obsolete and standards catch up with the requirements of the field.

And because libraries and frameworks have short lifespan I try to stay away from them and if possible use vanilla code. There is a wonderfull article about The Brutal Lifecycle of JavaScript Frameworks that explains how quick they popup and become obsolete.

JavaScript UI frameworks and libraries work in cycles. Every six months or so, a new one pops up, claiming that it has revolutionized UI development. Thousands of developers adopt it into their new projects, blog posts are written, Stack Overflow questions are asked and answered, and then a newer (and even more revolutionary) framework pops up to usurp the throne.

– Ian Allen

Unnecessary complexity

Libraries have a tendency to speed up development which is ok but there are a huge drawbacks in the future. Most of the times we work on simple projects. Not everybody is working on Facebook, Google or that kind of mamuth apps and by using libraries provided to us by these companies we introduce complexity these companies need in order to make their apps. And usually these libraries include edge case functionalities that only apply to them and by providing simpler way to use libraries very complex approaches get implemented.

Another reason for me to not use frameworks and libraries is that there usually is a team behind a project and by working on a feature by your own it takes too much time to read through the documentation and properly understand what the reasoning was behind a feature in a library. Most of the stuff (dashboarding, tables, widgets) that I work on are done much faster by pure using JS. Codebase footprint is smaller and doesn’t require other developers to learn a completly new framework.

This freameworks are heavily opinionated. No question about it. And by using them you accept their dogma. And by doing so you put yourself in a wierd position when new “disruptive” framework comes to life. If we think about it these frameworks should rather be called “approaches”.

Just to be completely honest

There are use-cases for such frameworks. And there are situations where they are indispensable. I am not saying that they don’t make sense. All I am saying that in my line of work I noticed that not every project is fit for a framework and it’s better to not use them in such cases.

An awesome talk about Learning from JavaScript Libraries by Trevor Landau.

Speed of development trumps code quality

I have found out that most of these frameworks or libraries have become very difficult to undestand in a matter of hours. In the past this was diifferent somehow. You could learn jQuery in a matter of hours and use it the next day like you were a pro. I know that it’s not fair to compare framework and library but for our case this is acceptable.

Every developer should have the knowledge and experience when selecting or not selection framework. I always stay true to Occam’s razor. And when prototyping I always use as barebone setup as I can. I see no problem with completly dumping a block of code and replacing it with something more complex if this makes sense. But there needs to be a huge reason behind this decision.

Workarounds are one of the nessesary evils perticulary when dealing with frameworks. Either because the lack of time of just plain reason that framework doesn’t support something. And this is the my main problem with them. In real life we don’t have the time to properly implement ideas behind a framework. And when shit hits the fan we butcher up the code and mix different ideas just to catch a deadline. And this is in contadiction with the whole idea of using a framework.

The impact that this has on quality and readability of code is massive. And threating this just as a symptom is probably the worst thing you can do. Through time these hacked-up code becomes legacy and additional code is molded to the code that already is in the codebase. And by doing this our code becomes more and more foregin of the initial concept.

Code quality and readability should come first regardless of frameworks and libraries. Code should be as close to bare-metal as possible so when frameworks change our code is still usable and can be refreshed by any developer with the basic knowledge of desired programming language.

All this directly impacts performanse. Terabytes of bandwidth wasted because there was a decision made early in the development cycle. Laggy performance, slow loading, bad experience just because development team was not cautious enough.

\ No newline at end of file diff --git a/public/using-digitalocean-spaces-object-storage-with-fuse.html b/public/using-digitalocean-spaces-object-storage-with-fuse.html new file mode 100644 index 0000000..247684f --- /dev/null +++ b/public/using-digitalocean-spaces-object-storage-with-fuse.html @@ -0,0 +1,190 @@ +Using DigitalOcean Spaces Object Storage with FUSE

Using DigitalOcean Spaces Object Storage with FUSE

Published on by Mitja Felicijan

Table of contents

  1. Is it possible to use them as a mounted drive with FUSE?
  2. Will the performance degrade over time and over different sizes of objects?
    1. Measurement experiment 1: File copy
    2. Measurement experiment 2: SQLite performanse
  3. Can storage be mounted on multiple machines at the same time and be writable?
  4. Observations and conslusion

Couple of months ago DigitalOcean introduced new product called Spaces which is Object Storage very similar to Amazon’s S3. This really peaked my interest, because this was something I was missing and even the thought of going over the internet for such functionality was in no interest to me. Also in fashion with their previous pricing this also is very cheap and pricing page is a no-brainer compared to AWS or GCE. Prices are clearly and precisely defined and outlined. You must love them for that :)

Initial requirements

  • Is it possible to use them as a mounted drive with FUSE? (tl;dr YES)
  • Will the performance degrade over time and over different sizes of objects? (tl;dr NO&YES)
  • Can storage be mounted on multiple machines at the same time and be writable? (tl;dr YES)

Let me be clear. This scripts I use are made just for benchmarking and are not intended to be used in real-life situations. Besides that, I am looking into using this approaches but adding caching service in front of it and then dumping everything as an object to storage. This could potentially be some interesting post of itself. But in case you would need real-time data without eventual consistency please take this scripts as they are: not usable in such situations.

Is it possible to use them as a mounted drive with FUSE?

Well, actually they can be used in such manor. Because they are similar to AWS S3 many tools are available and you can find many articles and Stackoverflow items.

To make this work you will need DigitalOcean account. If you don’t have one you will not be able to test this code. But if you have an account then you go and create new Droplet. If you click on this link you will already have preselected Debian 9 with smallest VM option.

  • Please be sure to add you SSH key, because we will login to this machine remotely.
  • If you change your region please remember which one you choose because we will need this information when we try to mount space to our machine.

Instuctions on how to use SSH keys and how to setup them are available in article How To Use SSH Keys with DigitalOcean Droplets.

DigitalOcean Droplets

After we created Droplet it’s time to create new Space. This is done by clicking on a button Create (right top corner) and selecting Spaces. Choose pronounceable Unique name because we will use it in examples below. You can either choose Private or Public, it doesn’t matter in our case. And you can always change that in the future.

When you have created new Space we should generate Access key. This link will guide to the page when you can generate this key. After you create new one, please save provided Key and Secret because Secret will not be shown again.

DigitalOcean Spaces

Now that we have new Space and Access key we should SSH into our machine.

# replace IP with the ip of your newly created droplet
+ssh root@IP
+
+# this will install utilities for mounting storage objects as FUSE
+apt install s3fs
+
+# we now need to provide credentials (access key we created earlier)
+# replace KEY and SECRET with your own credentials but leave the colon between them
+# we also need to set proper permissions
+echo "KEY:SECRET" > .passwd-s3fs
+chmod 600 .passwd-s3fs
+
+# now we mount space to our machine
+# replace UNIQUE-NAME with the name you choose earlier
+# if you choose different region for your space be careful about -ourl option (ams3)
+s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tmp
+
+# now we try to create a file
+# once you mount it may take a couple of seconds to retrieve data
+echo "Hello cruel world" > /mnt/hello.txt
+

After all this you can return to your browser and go to DigitalOcean Spaces and click on your created space. If file hello.txt is present you have successfully mounted space to your machine and wrote data to it.

I choose the same region for my Droplet and my Space but you don’t have to. You can have different regions. What this actually does to performance I don’t know.

Additional information on FUSE:

Will the performance degrade over time and over different sizes of objects?

For this task I didn’t want to just read and write text files or uploading images. I actually wanted to figure out if using something like SQlite is viable in this case.

Measurement experiment 1: File copy

# first we create some dummy files at different sizes
+dd if=/dev/zero of=10KB.dat bs=1024 count=10 #10KB
+dd if=/dev/zero of=100KB.dat bs=1024 count=100 #100KB
+dd if=/dev/zero of=1MB.dat bs=1024 count=1024 #1MB
+dd if=/dev/zero of=10MB.dat bs=1024 count=10240 #10MB
+
+# now we set time command to only return real
+TIMEFORMAT=%R
+
+# now lets test it
+(time cp 10KB.dat /mnt/) |& tee -a 10KB.results.txt
+
+# and now we automate
+# this will perform the same operation 100 times
+# this will output results into separated files based on objecty size
+n=0; while (( n++ < 100 )); do (time cp 10KB.dat /mnt/10KB.$n.dat) |& tee -a 10KB.results.txt; done
+n=0; while (( n++ < 100 )); do (time cp 100KB.dat /mnt/100KB.$n.dat) |& tee -a 100KB.results.txt; done
+n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.results.txt; done
+n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done
+

Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close ‘/mnt/100MB.1.dat’: Operation not permitted).

As I suspected, object size is not really that important. Sadly I don’t have the time to test performance over periods of time. But if some of you would do it please send me your data. I would be interested in seeing results.

Here are plotted results

You can download raw result here. Measurements are in seconds.

As far as these tests show, performance is quite stable and can be predicted which is fantastic. But this is a small test and spans only over couple of hours. So you should not completely trust them.

Measurement experiment 2: SQLite performanse

I was unable to use database file directly from mounted drive so this is a no-go as I suspected. So I executed code below on a local disk just to get some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can see performance of SQLite is quite amazing. You could then potentially just copy file to mounted drive and be done with it.

import time
+import sqlite3
+import sys
+
+if len(sys.argv) < 3:
+  print("usage: python sqlite-benchmark.py DB_PATH NUM_RECORDS REPEAT")
+  exit()
+
+def data_iter(x):
+  for i in range(x):
+    yield "m" + str(i), "f" + str(i*i)
+
+header_line = "%s\t%s\t%s\t%s\t%s\n" % ("DROPTABLE", "CREATETABLE", "INSERTMANY", "FETCHALL", "COMMIT")
+with open("sqlite-benchmarks.tsv", "w") as fp:
+  fp.write(header_line)
+
+start_time = time.time()
+conn = sqlite3.connect(sys.argv[1])
+c = conn.cursor()
+end_time = time.time()
+result_time = CONNECT = end_time - start_time
+print("CONNECT: %g seconds" % (result_time))
+
+start_time = time.time()
+c.execute("PRAGMA journal_mode=WAL")
+c.execute("PRAGMA temp_store=MEMORY")
+c.execute("PRAGMA synchronous=OFF")
+result_time = PRAGMA = end_time - start_time
+print("PRAGMA: %g seconds" % (result_time))
+
+for i in range(int(sys.argv[3])):
+  print("#%i" % (i))
+
+  start_time = time.time()
+  c.execute("drop table if exists test")
+  end_time = time.time()
+  result_time = DROPTABLE = end_time - start_time
+  print("DROPTABLE: %g seconds" % (result_time))
+
+  start_time = time.time()
+  c.execute("create table if not exists test(a,b)")
+  end_time = time.time()
+  result_time = CREATETABLE = end_time - start_time
+  print("CREATETABLE: %g seconds" % (result_time))
+
+  start_time = time.time()
+  c.executemany("INSERT INTO test VALUES (?, ?)", data_iter(int(sys.argv[2])))
+  end_time = time.time()
+  result_time = INSERTMANY = end_time - start_time
+  print("INSERTMANY: %g seconds" % (result_time))
+
+  start_time = time.time()
+  c.execute("select count(*) from test")
+  res = c.fetchall()
+  end_time = time.time()
+  result_time = FETCHALL = end_time - start_time
+  print("FETCHALL: %g seconds" % (result_time))
+
+  start_time = time.time()
+  conn.commit()
+  end_time = time.time()
+  result_time = COMMIT = end_time - start_time
+  print("COMMIT: %g seconds" % (result_time))
+
+  print
+  log_line = "%f\t%f\t%f\t%f\t%f\n" % (DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT)
+  with open("sqlite-benchmarks.tsv", "a") as fp:
+    fp.write(log_line)
+
+start_time = time.time()
+conn.close()
+end_time = time.time()
+result_time = CLOSE = end_time - start_time
+print("CLOSE: %g seconds" % (result_time))
+

You can download raw result here. And again, these results are done on a local block storage and do not represent capabilities of object storage. With my current approach and state of the test code these can not be done. I would need to make Python code much more robust and check locking etc.

Can storage be mounted on multiple machines at the same time and be writable?

Well, this one didn’t take long to test. And the answer is YES. I mounted space on both machines and measured same performance on both machines. But because file is downloaded before write and then uploaded on complete there could potentially be problems is another process is trying to access the same file.

Observations and conslusion

Using Spaces in this way makes it easier to access and manage files. But besides that you would need to write additional code to make this one play nice with you applications.

Nevertheless, this was extremely simple to setup and use and this is just another excellent product in DigitalOcean product line. I found this exercise very valuable and am thinking about implementing some sort of mechanism for SQLite, so data can be stored on Spaces and accessed by many VM’s. For a project where data doesn’t need to be accessible in real-time and can have couple of minutes old data this would be very interesting. If any of you find this proposal interesting please write in a comment box below or shoot me an email and I will keep you posted.

\ No newline at end of file diff --git a/public/what-i-ve-learned-developing-ad-server.html b/public/what-i-ve-learned-developing-ad-server.html new file mode 100644 index 0000000..74d639e --- /dev/null +++ b/public/what-i-ve-learned-developing-ad-server.html @@ -0,0 +1,78 @@ +What I've learned developing ad server

What I've learned developing ad server

Published on by Mitja Felicijan

Table of contents

  1. Aggregate everything
  2. Measure everything
  3. Cache control is your friend
  4. Learn NGINX
  5. Use Redis/Memcached
  6. Conclusion

For the past year and half I have been developing native advertising server that contextually matches ads and displays them in different template forms on variety of websites. This project grew from serving thousands of ads per day to millions.

The system is made from couple of core components:

  • API for serving ads,
  • Utils - cronjobs and queue management tools,
  • Dashboard UI.

Initial release was using MongoDB for full-text search but was later replaced by Elasticsearch for better CPU utilization and better search performance. This provided us with many amazing functionalities of Elasticsearch. You should check it out if you do any search related operations.

Because the premise of the server is to provide native ad experience, they are rendered on the client side via simple templating engine. This ensures that ads can be displayed number of different ways based on the visual style of the page. And this makes Javascript client library quite complex.

So now that you know basic information about the product lets get into the lessons we learned.

Aggregate everything

After beta version was released everything (impressions, clicks, etc) was written in nanosecond resolution in the database. At that time we were using PostgreSQL and database quickly grew way above 200GB in disk space. And that was problematic. Statistics took disturbingly long time to aggregate. Also using indexes on stats table in database was no help after we reached 500 million datapoints.

There is a marketing product information and there is real life experience. And the tend to be quite the opposite.

This was the reason that now everything is aggregated on daily basis and this data is then fed to Elastic in form of daily summary. With this we achieved we can now track many more dimensions such as zone, channel and platform information. And with this information we can now adapt occurrences of ads on specific places more precisely.

We have also adapted Redis as a full-time citizen in our stack. Because Redis also stores information on a local disk we have some sort of backup if server would accidentally suffer some failure.

All the real-time statistics for ad serving and redirecting is presented as counters in Redis instance and daily extracted and pushed to Elastic.

Measure everything

The thing about software is that we really don’t know how well it is performing under load until such load is presented. When testing locally everything is fine but when on production things tend to fall apart.

As a solution for this we are measuring everything we can. Function execution time (by encapsulating functions with timers), server performance (cpu, memory, disk, etc), Nginx and uWSGI performance. We sacrifice a bit of performance for the sake of this information. And we store all this information for later analysis.

Example of function execution time

{
+  "get_final_filtered_ads": {
+    "counter": 1931250,
+    "avg": 0.0066143431,
+    "elapsed": 12773.9500310003
+  },
+  "store_keywords_statistics": {
+    "counter": 1931011,
+    "avg": 0.0004605267,
+    "elapsed": 889.2821669996
+  },
+  "match_by_context": {
+    "counter": 1931011,
+    "avg": 0.0055960716,
+    "elapsed": 10806.0758889999
+  },
+  "match_by_high_performance": {
+    "counter": 262,
+    "avg": 0.0152770229,
+    "elapsed": 4.00258
+  },
+  "store_impression_stats": {
+    "counter": 1931250,
+    "avg": 0.0006189991,
+    "elapsed": 1195.4419869999
+  }
+}
+

We have also started profiling with cProfile and then visualizing with KCachegrind. This provides much more detailed look into code execution.

Cache control is your friend

Because we use Javascript library for rendering ads we rely on this script extensively and when in need we need to be able to change behavior of the script quickly.

In our case we can not simply replace javascript url in html code. It usually takes a day or two for the guys who maintain sites to change code or add ?ver=xxx attribute. And this makes rapid deployment and testing very difficult and time consuming. There is a limitation of how much you can test locally.

We are now in the process of integrating Google Tag Manager but couple of websites are developed on ASP.net platform that have some problems with tag manager. With a solution below we are certain that we are serving latest version of the script.

And it only takes one mistake and users have the script cached and in case of caching it for 1 year you probably know where the problem is.

# nginx ➜ /etc/nginx/sites-available/default
+location /static/ {
+  alias /path-to-static-content/;
+  autoindex off;
+  charset utf-8;
+  gzip on;
+  gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
+  location ~* \.(ico|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ {
+    expires 1y;
+    add_header Pragma public;
+    add_header Cache-Control "public";
+  }
+  location ~* \.(css|js|txt)$ {
+    expires 3600s;
+    add_header Pragma public;
+    add_header Cache-Control "public, must-revalidate";
+  }
+}
+

Also be careful when redirecting to url in your python code. We noticed that if we didn’t precisely setup cache control and expire headers in response we didn’t get the request on the server and therefore couldn’t measure clicks. So when redirecting do as follows and there will be no problems.

# python ➜ bottlepy web micro-framework
+response = bottle.HTTPResponse(status=302)
+response.set_header("Cache-Control", "no-store, no-cache, must-revalidate")
+response.set_header("Expires", "Thu, 01 Jan 1970 00:00:00 GMT")
+response.set_header("Location", url)
+return response
+

Cache control in browsers is quite aggressive and you need to be precise to avoid future problems. We learned that lesson the hard way.

Learn NGINX

When deciding on a web server we went with Nginx as a reverse proxy for our applications. We adapted micro-service oriented architecture early in the project to ensure when we scale we can easily add additional servers to our cluster. And Nginx was crucial to perform load balancing and static content delivery.

At first our config file was quite simple and later grew larger. After patching and adding new settings I sat down and learned more about the guts of Nginx. This proved to be very useful and we were able to squeeze much more out of our setup. So I advise you to take your time and read through the documentation. This saved us a lot of headache. Googling for solutions only goes so far.

Use Redis/Memcached

As explained above we are using caching basically for everything. It is the corner stone of our services. At first we were very careful about the quantity of things we stored in Redis. But we later found out that the memory footprint is very low even when storing large amount of data in it.

So we gradually increased our usage to caching whole HTML outputs of dashboard. This improved our performance in order of magnitude. And by using native TTL support this goes hand in hand with our needs.

The reason why we choose Redis over Memcached was the nature of scalability of Redis out of the box. But all this can be achieved with Memcached.

Conclusion

There are a lot more details that could have been written and every single topic in here deserves it’s own post but you probably got the idea about the problems we faced.

\ No newline at end of file diff --git a/public/what-its-like-to-be-a-software-developer.html b/public/what-its-like-to-be-a-software-developer.html new file mode 100644 index 0000000..416c537 --- /dev/null +++ b/public/what-its-like-to-be-a-software-developer.html @@ -0,0 +1,27 @@ +What it's like to be a software developer

What it's like to be a software developer

Published on by Mitja Felicijan

I get asked a lot what the hell I actually do. I find it funny but I guess it is my fault in most cases. I try not to be the kind of a man that is always talking about his work. I live in a small village and most of my neighbours probably have no idea what I actually do. And I am ok with that. I prefer this. But on some occasions I find it disturbing how people judge other people just because they don’t understand what they are all about. Many of them probably think I am some strange kind of a looser that is awake all the time and works from home. He probably plays games and type on a computer :) What kind of a job is that? That is no job at all! :) You work for eight hours, then you go home and drink a beer and go work in your workshop. This is what real men do!

Well, you know. It’s just the way it is. And it takes time for people to understand. Being home after many years in living elsewhere really grounded me in some cases. Coming back to the place where you grew up brings some sort of a humility back in your life. And this is ok. Nobody want’s to be Icarus anyways.

What I am meaning to say is if you are in a similar situation as me it will take time for people to start understanding you. Don’t get discouraged by this. Take it as it is. People judge what they don’t understand.

I have this saying that sleeping is for pussies and we will sleep when we die. I am 32 years old now and I haven’t slowed down regarding my work hours. I have steped up the pace. I usually work for about 16-18 hours a day every day. It doesn’t matter if it’s Monday or Saturday. Work needs to be done.

I know that there are other ways. But if you want to be good there really is no other way. There are no shortcuts. There is no easier way to get to the point where you really know what the hell you are doing. Myth about this genius programmer truly is one huge bullshit. Without putting in the hours nothing can be achieved. There is no success without dedication.

My friends and coworkers often ask me how the hell did I learn so much stuff. Where do I find the time to go through all this material. And I have a simple response for them: “When you go to sleep I begin reading and prototyping. When you go on a trip I make prototype projects just for the sake of learning. When you take your time for fucking around I read articles and books hunting that single small piece of information that will help me one day.” And often they don’t believe me. They think I am just that smart and everything is easy for me. They have this misguided belief that I just had all this knowledge implanted in me at birth. And this is not the case. I have read so much in my lifetime and most of this information was useful to me later in my life. But that didn’t stop me even though I had no immediate use of it. This probably is the main difference between me and my friends. I don’t learn because I need to but because I am piecing together this huge puzzle and I threat is like a game. This amazing game of enlightenment.

I had many burn-downs in my career. Most of them come around new years. I guess around this time things slow down a bit and right then when you relax for a minute or two things get real :). They say when you enter your retirment you should never ever park your ass on a couch. You will die there :) When my burndown happens I fall into this huge depression and I start questioning my sanity. I question my decisions. I question my progress in life. I question everything. I try to understand if all this is worth it?! And every time this happens I struggle with this kind of questions. And by the time all this is over I come to the same conclusion every single time. Yes it fucking is worth it. And through the years I have noticed that this is some sort of a reset for me. This helps me maintain my sanity in the long run :) I love it when things get tough. It gets me to the next level. This teaches me progress is life.

I don’t even count anymore how many programming languages I have learned. I even stop noticing projects. They just fly by. It’s like I am hunting this revelation that is set for me. And this drives me. This helps me every day to step up my game. Every single problem I solve I come little closer to my goal. My never reaching goal. And it’s ok with me if I never reach this goal.

The only problem I have now is time. There just ain’t enough time to learn everything day has to offer. It’s like I am on a quest to become this mini search machine :).

This obsession with learning has come to the point where I stopped watching TV and news all together. I find this as noise that clutters your mind. The whole point about news is to frighten you and put your mind into a dangerous loop where you thinks that nothing matters anyways → world is going to shit. And the truth is so far away from this. We are living in this times where all this amazing possibilities are at hand. We just need to take control of our mindset and everything starts to look possible again.

What else can say after more than 10 years in this space? What else can be said anyways? I still love what I do as much as I did 10 years ago. I love it even more. And if I would have a single suggestion for all of you is to stop worrying about immediate benefits and focus on the long run. Learn, prototype, experiment and have fun. We all get frustrated at times but that doesn’t mean we should stop. Doing this kind of work is a privilege. We are making and creating. In the most pure sense we are creators. And there really is no better way to live your life.

A life without challenge, a life without hardship, a life without purpose, seems pale and pointless. With challenge come perseverance and gumption. With hardship come resilience and resolve. With purpose come strength and understanding.

— Terry Fallis, The High Road

\ No newline at end of file diff --git a/robots.txt b/robots.txt deleted file mode 100644 index c2a49f4..0000000 --- a/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Allow: / diff --git a/settings.js b/settings.js new file mode 100644 index 0000000..c5627d8 --- /dev/null +++ b/settings.js @@ -0,0 +1,16 @@ +exports.assets = { + css: [ + 'source/default.css', 'source/prism.css' + ], + javascript: [ + 'source/prism.js', 'source/languages/*.js', 'source/default.js' + ], +} + +exports.vars = { + domain: 'https://mitjafelicijan.com', + handle: '@mitjafelicijan', + author: 'Mitja Felicijan', + title: 'Mitja Felicijan - Embedded systems developer', + description: 'Embedded systems developer and fanatical fan of science fiction', +} diff --git a/slides/.jsbeautifyrc b/slides/.jsbeautifyrc deleted file mode 100644 index 5d90dea..0000000 --- a/slides/.jsbeautifyrc +++ /dev/null @@ -1,51 +0,0 @@ -{ - "html": { - "allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg", "dust", "njk"], - "brace_style": "collapse", - "end_with_newline": true, - "indent_char": " ", - "indent_handlebars": true, - "indent_inner_html": true, - "indent_scripts": "keep", - "indent_size": 4, - "indent_with_tabs": true, - "max_preserve_newlines": 10, - "preserve_newlines": true, - "unformatted": ["a", "span", "img", "code", "pre", "sub", "sup", "em", "strong", "b", "i", "u", "strike", "big", "small", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "hr"], - "wrap_line_length": 0 - }, - "css": { - "allowed_file_extensions": ["css", "scss", "sass", "less"], - "end_with_newline": true, - "indent_char": " ", - "indent_size": 4, - "indent_with_tabs": true, - "newline_between_rules": true, - "selector_separator": " ", - "selector_separator_newline": true, - "preserve_newlines": false, - "max_preserve_newlines": 10 - }, - "js": { - "allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"], - "brace_style": "collapse", - "break_chained_methods": false, - "e4x": true, - "end_with_newline": true, - "indent_char": " ", - "indent_level": 0, - "indent_size": 4, - "indent_with_tabs": true, - "jslint_happy": false, - "keep_array_indentation": true, - "keep_function_indentation": true, - "max_preserve_newlines": 0, - "preserve_newlines": true, - "space_after_anon_function": false, - "space_before_conditional": true, - "space_in_empty_paren": false, - "space_in_paren": false, - "unescape_strings": false, - "wrap_line_length": 0 - } -} diff --git a/slides/.jshintignore b/slides/.jshintignore deleted file mode 100644 index 4d662aa..0000000 --- a/slides/.jshintignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -bower_components -lib/external -vendor -help -steal -funcunit -**/*.min.js -**/production.js diff --git a/slides/.jshintrc b/slides/.jshintrc deleted file mode 100644 index 7c84ea6..0000000 --- a/slides/.jshintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "strict": false, - "esversion": 6, - "curly": true, - "noempty": true, - "trailing": true, - "white": false, - "evil": true -} diff --git a/slides/index.html b/slides/index.html deleted file mode 100644 index 648ac4b..0000000 --- a/slides/index.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - -
-
-
-

Presentation list

- -
-
- -
- - - - - - - - - - - - - - - - - - - - diff --git a/slides/presentations/basic-math-in-programming/cartesian-coordinate-system.svg b/slides/presentations/basic-math-in-programming/cartesian-coordinate-system.svg deleted file mode 100644 index 8090e31..0000000 --- a/slides/presentations/basic-math-in-programming/cartesian-coordinate-system.svg +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (0,0) - - - - - - - - - - - - - - - - diff --git a/slides/presentations/basic-math-in-programming/default.pug b/slides/presentations/basic-math-in-programming/default.pug deleted file mode 100644 index 7ca262b..0000000 --- a/slides/presentations/basic-math-in-programming/default.pug +++ /dev/null @@ -1,206 +0,0 @@ -section - h1 Why understanding of basic math is important for computer programing - p September 21, 2018, rev2 - a(href="https://twitter.com/mitjafelicijan") @mitjafelicijan - -section - h2 Agenda - ol - li Levenshtein distance - li Shortest path algorithm - li Distance Formula - li - -section.center - q We Cannot Solve Our Problems With The Same Thinking We Used When We Created Them. - footer — Albert Einstein - -section - h2 How we usually find solutions and why this is problematic? - - ul - li We search for code example instead of algorithms. - li We copy and paste and do testing on trial&error principle. - li We don't take enough time to properly understand problem we a re trying to solve. - li Brute force solutions we make are usually not optimized - -section - h2 Levenshtein distance - p The Levenshtein distance is a string metric for measuring difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (i.e. insertions, deletions or substitutions) required to change one word into the other. - - hr - - div.center - img(src="levenshtein-distance.svg", height="150") - - hr - - div.center - img(src="test.png") - - hr - - pre - code.language-python - | def levenshtein(seq1, seq2): - | oneago = None - | thisrow = range(1, len(seq2) + 1) + [0] - | for x in xrange(len(seq1)): - | twoago, oneago, thisrow = oneago, thisrow, [0] * len(seq2) + [x + 1] - | for y in xrange(len(seq2)): - | delcost = oneago[y] + 1 - | addcost = thisrow[y - 1] + 1 - | subcost = oneago[y - 1] + (seq1[x] != seq2[y]) - | thisrow[y] = min(delcost, addcost, subcost) - | return thisrow[len(seq2) - 1] - - - hr - - h4 Going further - ul - li - a(href="https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance") https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance - li - a(href="https://en.wikipedia.org/wiki/Levenshtein_distance") https://en.wikipedia.org/wiki/Levenshtein_distance - li - a(href="https://rosettacode.org/wiki/Levenshtein_distance") https://rosettacode.org/wiki/Levenshtein_distance - - - - - - - - - - - - -section - h2 Basic linear algebra - - pre - code.language-css - | body { - | background: black; - | } - - pre - code.language-javascript - | $(document).ready(function() { - | $('pre code').each(function(i, block) { - | hljs.highlightBlock(block); - | }); - | }); - - hr - figcaption.right Step 1: Finding nearest point - - div.center - img(src="drawing1.svg") - - hr - figcaption.right Step 1: Finding nearest point - - $$ \large{ \mathbb{R}^2 ∈ \vec{a} \bar{a} } $$ - $$ \large{ e^{i\pi} + 1 = 0 } $$ - $$ \large{ x = {-b \pm \sqrt{b^2-4ac} \over 2a} } $$ - - hr - figcaption.right Step 2: Finding nearest point - - pre - code.language-python - | fruits = ["apple", "banana", "cherry"] - | for x in fruits: - | if x == "banana": - | break - | print(x) - - hr - figcaption.right Finding nearest point - - $$ \large{ \mathbb{R}^2 ∈ \vec{a} \bar{a} } $$ - $$ \large{ e^{i\pi} + 1 = 0 } $$ - $$ \large{ x = {-b \pm \sqrt{b^2-4ac} \over 2a} } $$ - - hr - figcaption.right Finding nearest point - - pre - code.language-c - | #include - | int main () { - | for( ; ; ) { - | printf("This loop will run forever.\n"); - | } - | return 0; - | } - - hr - figcaption.right Finding nearest point - - pre - code.language-python - | fruits = ["apple", "banana", "cherry"] - | for x in fruits: - | if x == "banana": - | break - | print(x) - - hr - figcaption.right Finding nearest point - - pre - code.language-sql - | SELECT `CustomerName`, `City` FROM `Customers`; - - hr - figcaption.right Finding nearest point - - pre - code.language-go - | package main - | import "fmt" - | func main() { - | sum := 0 - | for i := 0; i < 10; i++ { - | sum += i - | } - | fmt.Println(sum) - | } - - hr - figcaption.right Finding nearest point - - pre - code.language-javascript - | $(document).ready(function() { - | $('pre code').each(function(i, block) { - | hljs.highlightBlock(block); - | }); - | }); - - hr - figcaption.right Finding nearest point - - pre - code.language-css - | body { - | background: black; - | } - -section - h3 Grid example - div.grid.col-1-1 - div Lipsum - div Lipsum - - div.grid.col-2-1 - div Lipsum - div Lipsum - - div.grid.col-1-2 - div Lipsum - div Lipsum diff --git a/slides/presentations/basic-math-in-programming/drawing1.svg b/slides/presentations/basic-math-in-programming/drawing1.svg deleted file mode 100644 index 19212c3..0000000 --- a/slides/presentations/basic-math-in-programming/drawing1.svg +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - a - - - - - diff --git a/slides/presentations/basic-math-in-programming/kmplot.fkt b/slides/presentations/basic-math-in-programming/kmplot.fkt deleted file mode 100644 index 85e4ec6..0000000 --- a/slides/presentations/basic-math-in-programming/kmplot.fkt +++ /dev/null @@ -1,37 +0,0 @@ - - - - 1 - 1 - 1 - -0.3319027181688177 - 6.615164520743903 - -1.445161290322586 - 6.5032258064516 - - - 1 - - - 0 - 0 - 1 - 1 - - - f(x) = 0 - - 0 - - - - g(x) = 0 - 0 - - - - Cantarell - Cantarell - Cantarell - - diff --git a/slides/presentations/basic-math-in-programming/kmplot.svg b/slides/presentations/basic-math-in-programming/kmplot.svg deleted file mode 100644 index 877038c..0000000 --- a/slides/presentations/basic-math-in-programming/kmplot.svg +++ /dev/null @@ -1,395 +0,0 @@ - - -Qt SVG Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -X -Y - - - -+0.4 - - - -+0.8 - - - -+1.2 - - - -+1.6 - - - -+2.0 - - - -+2.4 - - - -+2.8 - - - -+3.2 - - - -+3.6 - - - -+4.0 - - - -+4.4 - - - -+4.8 - - - -+5.2 - - - -+5.6 - - - -+6.0 - - - -+6.4 - - - -−1.0 - - - -−0.5 - - - -+0.5 - - - -+1.0 - - - -+1.5 - - - -+2.0 - - - -+2.5 - - - -+3.0 - - - -+3.5 - - - -+4.0 - - - -+4.5 - - - -+5.0 - - - -+5.5 - - - -+6.0 - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/slides/presentations/basic-math-in-programming/levenshtein-distance.svg b/slides/presentations/basic-math-in-programming/levenshtein-distance.svg deleted file mode 100644 index f8546da..0000000 --- a/slides/presentations/basic-math-in-programming/levenshtein-distance.svg +++ /dev/null @@ -1,211 +0,0 @@ - -{\displaystyle \qquad \operatorname {lev} _{a,b}(i,j)={\begin{cases}\max(i,j)&{\text{ if }}\min(i,j)=0,\\\min {\begin{cases}\operatorname {lev} _{a,b}(i-1,j)+1\\\operatorname {lev} _{a,b}(i,j-1)+1\\\operatorname {lev} _{a,b}(i-1,j-1)+1_{(a_{i}\neq b_{j})}\end{cases}}&{\text{ otherwise.}}\end{cases}}} - - - \ No newline at end of file diff --git a/slides/presentations/basic-math-in-programming/meta.json b/slides/presentations/basic-math-in-programming/meta.json deleted file mode 100644 index f34a689..0000000 --- a/slides/presentations/basic-math-in-programming/meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "title": "Why understanding of basic math is important for computer programing" -} diff --git a/slides/presentations/basic-math-in-programming/test.png b/slides/presentations/basic-math-in-programming/test.png deleted file mode 100644 index 5b57317..0000000 Binary files a/slides/presentations/basic-math-in-programming/test.png and /dev/null differ diff --git a/slides/vendor/slides.css b/slides/vendor/slides.css deleted file mode 100644 index 36d22da..0000000 --- a/slides/vendor/slides.css +++ /dev/null @@ -1,223 +0,0 @@ -@charset "utf-8"; -@import url("https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900&subset=latin-ext"); - -* { - box-sizing: border-box; - background-color: transparent; - margin: 0; - padding: 0; - border: 0; - outline: none; - text-decoration: none; - position: relative; - box-shadow: none; - -moz-osx-font-smoothing: grayscale !important; - text-rendering: optimizeLegibility !important; - -webkit-font-smoothing: antialiased !important; -} - -body { - font-family: "Roboto", sans-serif; - color: #222; - font-size: 24px; - margin: 0; - padding: 0; - line-height: 270%; - font-weight: 400; - color: #111; -} - -.wrapper { - overflow: auto; -} - -a { - color: crimson; - font-weight: 500; -} - -img { - max-width: 100%; - margin-top: 30px; -} - -table { - border-collapse: collapse; - border-spacing: 0; -} - -section { - padding: 70px 100px; -} - -nav { - position: fixed; - right: 50px; - bottom: 20px; - font-size: 80%; - font-weight: 500; -} - -figcaption { - color: #888; - font-size: 80%; - margin: 0; - padding: 0; - line-height: 0; - font-weight: 600; -} - -hr { - border-top: 3px solid #eee; - margin: 50px 0 40px 0; -} - -ul, -ol { - margin-left: 30px; -} - -ol { - list-style-type: lower-roman; -} - -h1, -h2, -h3, -h4, -h5, -h6 { - margin: 0 0 50px 0; - font-weight: 700; - display: block; - color: #000; -} - -h1 { - font-size: 300%; - margin-bottom: 100px; - line-height: 130%; -} - -h2 { - font-size: 200%; -} - -h3 { - font-size: 160%; - margin-bottom: 20px; -} - -h4 { - font-size: 140%; - margin-bottom: 20px; -} - -h5 { - font-size: 120%; - margin-bottom: 20px; -} - -h6 { - font-size: 100%; - margin-bottom: 20px; -} - -p { - display: block; - margin: 15px auto; - line-height: 160%; - color: inherit; -} - -q { - display: inline-block; - font-size: 200%; - font-weight: 600; - padding: 100px 0 30px 0; -} - -/*grid*/ -.grid { - display: grid; - grid-column-gap: 20px; - grid-row-gap: 20px; - text-align: left; -} - -.grid>* { - border: 0px dotted black; -} - -.col-1-1 { - grid-template-columns: 1fr 1fr; -} - -.col-1-2 { - grid-template-columns: 1fr 2fr; -} - -.col-2-1 { - grid-template-columns: 2fr 1fr; -} - -/* aligments */ -.left { - text-align: left; -} - -.right { - text-align: right; -} - -.center { - text-align: center; - margin-left: auto; - margin-right: auto; -} - -.top { - vertical-align: top; -} - -.middle { - vertical-align: middle; -} - -.bottom { - vertical-align: bottom; -} - -.full-width { - width: 100%; -} - -/* other */ -.hide { - display: none; -} - -.show { - display: block; -} - -/* presentation mode */ -.wrapper:-webkit-full-screen { - width: 100%; - height: 100%; - background: #fff; - padding: 50px; - font-size: 28px; - line-height: 250%; -} - -/* prism line numbers */ -pre[class*=language-] { - display: block; - background: #fff; - padding: 0; - margin-bottom: 20px; - font-family: 'Courier New', Courier, monospace; - font-size: 90%; - font-weight: 500; -} diff --git a/slides/vendor/slides.js b/slides/vendor/slides.js deleted file mode 100644 index c987e51..0000000 --- a/slides/vendor/slides.js +++ /dev/null @@ -1,140 +0,0 @@ -window.addEventListener('load', function(evt) { - - let main = document.querySelector('main'); - let nav = document.querySelector('nav'); - let wrapper = document.querySelector('div.wrapper'); - let hash = window.location.hash.slice(1, window.location.hash.length); - - if (hash.length > 0) { - - fetch(`presentations/${hash}/default.pug`).then(function(response) { - response.text().then(function(template) { - if (response.status == 200) { - main.innerHTML = jade.render(template, {}); - initSlideshow(); - } else { - main.innerHTML = '

Presentation does not exists!

'; - } - }).catch(function(error) { - console.log(error); - }); - }); - - fetch(`presentations/${hash}/meta.json`).then(function(response) { - response.json().then(function(data) { - document.title = data.title; - }).catch(function(error) { - console.log(error); - }); - }); - - } - - function initSlideshow() { - - // mathjax formulas - MathJax.Hub.Config({ - //displayAlign: 'left', - extensions: ['tex2jax.js'], - jax: ['input/TeX', 'output/SVG'], - tex2jax: { - skipTags: ['script', 'noscript', 'style', 'textarea', 'code'], - inlineMath: [ - ['$', '$'], - ["\\(", "\\)"] - ], - displayMath: [ - ['$$', '$$'], - ["\\[", "\\]"] - ], - } - }); - MathJax.Hub.Configured(); - - // syntax highlighting - Prism.highlightAll(); - - // initializes slides - function showSlide(slides, op) { - let tmpIdx = currentIdx + op; - if (tmpIdx >= 0 && tmpIdx < slides.length) { - slides.forEach(function(slide) { - slide.classList.add('hide'); - }); - slides[tmpIdx].classList.remove('hide'); - window.scrollTo(0, 0); - nav.innerHTML = `${tmpIdx+1} / ${slides.length}`; - currentIdx = tmpIdx; - } - } - - // fixes images relative path - document.querySelectorAll('img').forEach(function(image) { - image.src = `presentations/${hash}/${image.getAttribute('src')}`; - }); - - let slides = document.querySelectorAll('section'); - let currentIdx = 0; - showSlide(slides, currentIdx); - - document.addEventListener('keydown', function(evt) { - switch (evt.code) { - case 'ArrowRight': - { - showSlide(slides, 1); - break; - } - case 'ArrowLeft': - { - showSlide(slides, -1); - break; - } - case 'KeyF': - { - if (wrapper.requestFullscreen) { - wrapper.requestFullscreen(); - } else if (wrapper.mozRequestFullScreen) { - wrapper.mozRequestFullScreen(); - } else if (wrapper.webkitRequestFullscreen) { - wrapper.webkitRequestFullscreen(); - } else if (wrapper.msRequestFullscreen) { - wrapper.msRequestFullscreen(); - } - break; - } - } - }, false); - - - //var elem = document.getElementById("myvideo"); - //if (elem.requestFullscreen) { - // elem.requestFullscreen(); - //} - - } - -}, false); - - -// hide mouse after 5seconds -(function() { - var mouseTimer = null, - cursorVisible = true; - - function disappearCursor() { - mouseTimer = null; - document.body.style.cursor = 'none'; - cursorVisible = false; - } - - document.onmousemove = function() { - if (mouseTimer) { - window.clearTimeout(mouseTimer); - } - if (!cursorVisible) { - document.body.style.cursor = 'default'; - cursorVisible = true; - } - mouseTimer = window.setTimeout(disappearCursor, 2000); - }; -})(); diff --git a/source/default.css b/source/default.css new file mode 100644 index 0000000..a7dff38 --- /dev/null +++ b/source/default.css @@ -0,0 +1,262 @@ +@charset "utf-8"; + +@import url('https://fonts.googleapis.com/css?family=Heebo:100,300,400,500,700,800,900" rel="stylesheet">'); +@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600,700,900" rel="stylesheet">'); + +* { + box-sizing: border-box; + -moz-osx-font-smoothing: grayscale !important; + text-rendering: optimizeLegibility !important; + -webkit-font-smoothing: antialiased !important; +} + +body { + font-family: 'Heebo', sans-serif; + font-size: 18px; + line-height: 170%; +} + +a { + color: inherit; + text-decoration: underline; + text-decoration-color: fuchsia; + text-decoration-style: wavy; + border: 2px dotted transparent; + display: inline-block; +} + +a:active { + border-color: black; +} + +ol a { + text-decoration: none; +} + +ol a:hover { + text-decoration: underline; +} + +h1 { + line-height: 140%; + font-weight: 900; + font-size: 250%; +} + +h2,h3,h4,h5 { + margin-top: 50px; +} + +img { + max-width: 100%; + margin: 0 auto; + display: block; +} + +.wrapper { + max-width: 750px; + margin: 0 auto; +} + +blockquote { + margin: 50px 0 50px 50px; +} + +.pubdate { + font-size: 80%; + color: #666; +} + +/********************************************************** CODE HIGHLIGHTING */ + +pre, code { + font-family: 'Source Code Pro', monospace !important; + font-weight: 500; +} + +pre { + font-size: 80%; + margin: 20px; + background: #eee; +} + +p > code { + background: rgb(48, 46, 46); + padding: 1px 0.95rem 2px; + border-radius: 1em; + font-size: 70%; + font-weight: 600; + color: #fff; + display: inline; + -webkit-box-decoration-break: clone; + cursor:crosshair; +} + +p > code:hover { + background: fuchsia; +} + +/***************************************************************** OL COUNTER */ + +ol { + list-style: none; + counter-reset: li; +} + +ol li { + counter-increment: li; +} + +ol li::before { + content: counter(li) "."; + color: #ccc; + font-weight: 500; + display: inline-block; + width: 1em; + margin-left: -1.5em; + margin-right: 0.9em; + text-align: right; +} + +ol li a { + text-decoration: none; +} + +/********************************************************************* TABLES */ + +table { + width: 100%; + border-collapse: collapse; + border-spacing: 0; + font-size: 90%; + text-align: left; + margin-top: 50px; + margin-bottom: 50px; +} + +th,td { + border-bottom: 2px solid #888; + padding: 10px; +} + +th { + font-size: 130%; +} + +tr:last-child td { + border-width: 0; +} + +/****************************************************************** FOOTNOTES */ + +.footnotes p { + padding: 0; + display: inline-block; + margin: 0; +} + +.footnotes-sep { + border: 0; +} + +/************************************************* BGCOLOR WHEN TEXT SELECTED */ + +::selection { + background: #ff0; + color: #000; +} + +::-moz-selection { + background: #ff0; + color: #000; +} + +/********************************************************** CUSTOM SCROLLBARS */ + +pre::-webkit-scrollbar { + width: 5px; + height: 8px; + background-color: transparent; +} + +pre::-webkit-scrollbar-thumb { + background: #ddd; +} + +/*************************************************************** HEADER + NAV */ + +menu { + display: grid; + grid-template-columns: 1fr 1fr; + font-size: 80%; + padding: 0; + padding-top: 10px; + +} + +menu a.logo { + background: black; + color: white; + font-weight: 800; + text-decoration: none; + padding: 3px 15px; +} + +menu a.logo:hover { + background: fuchsia; + color: white; +} + +menu nav { + text-align: right; + margin-top: 3px; +} + +menu nav a { + padding-top: 8px; + margin-left: 25px; +} + +menu nav a svg { + width: 20px; + height: 20px; +} + +/********************************************************************* FOOTER */ + +footer { + padding-top: 50px; + padding-bottom: 50px; + font-weight: 500; + font-size: 80%; +} + +footer > * { + text-decoration: none; + margin-right: 20px; + color: #333; +} + +/***************************************************************** RESPONSIVE */ + +@media only screen and (max-width:800px) { + body { + font-size: 16px; + } + + .wrapper { + padding: 10px 20px !important; + } + + h1 { + font-size: 200%; + } +} + +.article-list a { + text-decoration: none; +} + +.article-list a h2 { + margin-bottom: 5px; +} diff --git a/source/default.js b/source/default.js new file mode 100644 index 0000000..2df34f0 --- /dev/null +++ b/source/default.js @@ -0,0 +1,21 @@ +//Responsive tables +document.querySelectorAll('table').forEach(function (element) { + if (!element.classList.contains('rouge-table')) { + let parent = element.parentNode; + let wrapper = document.createElement('div'); + wrapper.classList.add('responsive-table'); + parent.replaceChild(wrapper, element); + wrapper.appendChild(element); + } +}); + + +// Open external links in new tab +let links = document.links; +for (let i = 0, linksLength = links.length; i < linksLength; i++) { + if (links[i].hostname != window.location.hostname) { + links[i].target = '_blank'; + links[i].setAttribute('rel', 'noopener nofollow'); + } +} + diff --git a/source/languages/prism-bash.js b/source/languages/prism-bash.js new file mode 100644 index 0000000..5093ffd --- /dev/null +++ b/source/languages/prism-bash.js @@ -0,0 +1,84 @@ +(function(Prism) { + var insideString = { + variable: [ + // Arithmetic Environment + { + pattern: /\$?\(\([\s\S]+?\)\)/, + inside: { + // If there is a $ sign at the beginning highlight $(( and )) as variable + variable: [{ + pattern: /(^\$\(\([\s\S]+)\)\)/, + lookbehind: true + }, + /^\$\(\(/ + ], + number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/, + // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic + operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/, + // If there is no $ sign at the beginning highlight (( and )) as punctuation + punctuation: /\(\(?|\)\)?|,|;/ + } + }, + // Command Substitution + { + pattern: /\$\([^)]+\)|`[^`]+`/, + greedy: true, + inside: { + variable: /^\$\(|^`|\)$|`$/ + } + }, + /\$(?:[\w#?*!@]+|\{[^}]+\})/i + ] + }; + + Prism.languages.bash = { + 'shebang': { + pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/, + alias: 'important' + }, + 'comment': { + pattern: /(^|[^"{\\])#.*/, + lookbehind: true + }, + 'string': [ + //Support for Here-Documents https://en.wikipedia.org/wiki/Here_document + { + pattern: /((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/, + lookbehind: true, + greedy: true, + inside: insideString + }, + { + pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/, + greedy: true, + inside: insideString + } + ], + 'variable': insideString.variable, + // Originally based on http://ss64.com/bash/ + 'function': { + pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/, + lookbehind: true + }, + 'keyword': { + pattern: /(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/, + lookbehind: true + }, + 'boolean': { + pattern: /(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/, + lookbehind: true + }, + 'operator': /&&?|\|\|?|==?|!=?|<<>|<=?|>=?|=~/, + 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/ + }; + + var inside = insideString.variable[1].inside; + inside.string = Prism.languages.bash.string; + inside['function'] = Prism.languages.bash['function']; + inside.keyword = Prism.languages.bash.keyword; + inside['boolean'] = Prism.languages.bash['boolean']; + inside.operator = Prism.languages.bash.operator; + inside.punctuation = Prism.languages.bash.punctuation; + + Prism.languages.shell = Prism.languages.bash; +})(Prism); diff --git a/source/languages/prism-c.js b/source/languages/prism-c.js new file mode 100644 index 0000000..86ffac0 --- /dev/null +++ b/source/languages/prism-c.js @@ -0,0 +1,33 @@ +Prism.languages.c = Prism.languages.extend('clike', { + 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/, + 'operator': /-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|\|?|[~^%?*\/]/, + 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i +}); + +Prism.languages.insertBefore('c', 'string', { + 'macro': { + // allow for multiline macro definitions + // spaces after the # character compile fine with gcc + pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im, + lookbehind: true, + alias: 'property', + inside: { + // highlight the path of the include statement as a string + 'string': { + pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/, + lookbehind: true + }, + // highlight macro directives as keywords + 'directive': { + pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/, + lookbehind: true, + alias: 'keyword' + } + } + }, + // highlight predefined macros as constants + 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/ +}); + +delete Prism.languages.c['class-name']; +delete Prism.languages.c['boolean']; diff --git a/source/languages/prism-css.js b/source/languages/prism-css.js new file mode 100644 index 0000000..e6fdf6f --- /dev/null +++ b/source/languages/prism-css.js @@ -0,0 +1,52 @@ +Prism.languages.css = { + 'comment': /\/\*[\s\S]*?\*\//, + 'atrule': { + pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i, + inside: { + 'rule': /@[\w-]+/ + // See rest below + } + }, + 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'selector': /[^{}\s][^{};]*?(?=\s*\{)/, + 'string': { + pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, + 'important': /\B!important\b/i, + 'function': /[-a-z0-9]+(?=\()/i, + 'punctuation': /[(){};:]/ +}; + +Prism.languages.css['atrule'].inside.rest = Prism.languages.css; + +if (Prism.languages.markup) { + Prism.languages.insertBefore('markup', 'tag', { + 'style': { + pattern: /()[\s\S]*?(?=<\/style>)/i, + lookbehind: true, + inside: Prism.languages.css, + alias: 'language-css', + greedy: true + } + }); + + Prism.languages.insertBefore('inside', 'attr-value', { + 'style-attr': { + pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, + inside: { + 'attr-name': { + pattern: /^\s*style/i, + inside: Prism.languages.markup.tag.inside + }, + 'punctuation': /^\s*=\s*['"]|['"]\s*$/, + 'attr-value': { + pattern: /.+/i, + inside: Prism.languages.css + } + }, + alias: 'language-css' + } + }, Prism.languages.markup.tag); +} \ No newline at end of file diff --git a/source/languages/prism-go.js b/source/languages/prism-go.js new file mode 100644 index 0000000..cc792a0 --- /dev/null +++ b/source/languages/prism-go.js @@ -0,0 +1,12 @@ +Prism.languages.go = Prism.languages.extend('clike', { + 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/, + 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/, + 'boolean': /\b(?:_|iota|nil|true|false)\b/, + 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, + 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i, + 'string': { + pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/, + greedy: true + } +}); +delete Prism.languages.go['class-name']; diff --git a/source/languages/prism-javascript.js b/source/languages/prism-javascript.js new file mode 100644 index 0000000..7800a7d --- /dev/null +++ b/source/languages/prism-javascript.js @@ -0,0 +1,56 @@ +Prism.languages.javascript = Prism.languages.extend('clike', { + 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, + 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, + // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) + 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i, + 'operator': /-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ +}); + +Prism.languages.insertBefore('javascript', 'keyword', { + 'regex': { + pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, + lookbehind: true, + greedy: true + }, + // This must be declared before keyword because we use "function" inside the look-forward + 'function-variable': { + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, + alias: 'function' + }, + 'constant': /\b[A-Z][A-Z\d_]*\b/ +}); + +Prism.languages.insertBefore('javascript', 'string', { + 'template-string': { + pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, + greedy: true, + inside: { + 'interpolation': { + pattern: /\${[^}]+}/, + inside: { + 'interpolation-punctuation': { + pattern: /^\${|}$/, + alias: 'punctuation' + }, + rest: null // See below + } + }, + 'string': /[\s\S]+/ + } + } +}); +Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript; + +if (Prism.languages.markup) { + Prism.languages.insertBefore('markup', 'tag', { + 'script': { + pattern: /()[\s\S]*?(?=<\/script>)/i, + lookbehind: true, + inside: Prism.languages.javascript, + alias: 'language-javascript', + greedy: true + } + }); +} + +Prism.languages.js = Prism.languages.javascript; diff --git a/source/languages/prism-json.js b/source/languages/prism-json.js new file mode 100644 index 0000000..06e847e --- /dev/null +++ b/source/languages/prism-json.js @@ -0,0 +1,14 @@ +Prism.languages.json = { + 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i, + 'string': { + pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, + greedy: true + }, + 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, + 'punctuation': /[{}[\]);,]/, + 'operator': /:/g, + 'boolean': /\b(?:true|false)\b/i, + 'null': /\bnull\b/i +}; + +Prism.languages.jsonp = Prism.languages.json; diff --git a/source/languages/prism-nginx.js b/source/languages/prism-nginx.js new file mode 100644 index 0000000..c3fea0c --- /dev/null +++ b/source/languages/prism-nginx.js @@ -0,0 +1,11 @@ +Prism.languages.nginx = Prism.languages.extend('clike', { + 'comment': { + pattern: /(^|[^"{\\])#.*/, + lookbehind: true + }, + 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i +}); + +Prism.languages.insertBefore('nginx', 'keyword', { + 'variable': /\$[a-z_]+/i +}); \ No newline at end of file diff --git a/source/languages/prism-pascal.js b/source/languages/prism-pascal.js new file mode 100644 index 0000000..bc7a283 --- /dev/null +++ b/source/languages/prism-pascal.js @@ -0,0 +1,55 @@ +// Based on Free Pascal + +/* TODO + Support inline asm ? +*/ + +Prism.languages.pascal = { + 'comment': [ + /\(\*[\s\S]+?\*\)/, + /\{[\s\S]+?\}/, + /\/\/.*/ + ], + 'string': { + pattern: /(?:'(?:''|[^'\r\n])*'|#[&$%]?[a-f\d]+)+|\^[a-z]/i, + greedy: true + }, + 'keyword': [ + { + // Turbo Pascal + pattern: /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i, + lookbehind: true + }, + { + // Free Pascal + pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i, + lookbehind: true + }, + { + // Object Pascal + pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i, + lookbehind: true + }, + { + // Modifiers + pattern: /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i, + lookbehind: true + } + ], + 'number': [ + // Hexadecimal, octal and binary + /(?:[&%]\d+|\$[a-f\d]+)/i, + // Decimal + /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i + ], + 'operator': [ + /\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/i, + { + pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/, + lookbehind: true + } + ], + 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/ +}; + +Prism.languages.objectpascal = Prism.languages.pascal; \ No newline at end of file diff --git a/source/languages/prism-python.js b/source/languages/prism-python.js new file mode 100644 index 0000000..ecad408 --- /dev/null +++ b/source/languages/prism-python.js @@ -0,0 +1,29 @@ +Prism.languages.python = { + 'comment': { + pattern: /(^|[^\\])#.*/, + lookbehind: true + }, + 'triple-quoted-string': { + pattern: /("""|''')[\s\S]+?\1/, + greedy: true, + alias: 'string' + }, + 'string': { + pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'function': { + pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, + lookbehind: true + }, + 'class-name': { + pattern: /(\bclass\s+)\w+/i, + lookbehind: true + }, + 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/, + 'builtin':/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/, + 'boolean': /\b(?:True|False|None)\b/, + 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, + 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/, + 'punctuation': /[{}[\];(),.:]/ +}; diff --git a/source/prism.css b/source/prism.css new file mode 100644 index 0000000..21c8aa8 --- /dev/null +++ b/source/prism.css @@ -0,0 +1,167 @@ +/** + * prism.js default theme for JavaScript, CSS and HTML + * Based on dabblet (http://dabblet.com) + * @author Lea Verou + */ + + code[class*="language-"], + pre[class*="language-"] { + color: black; + font-family: monospace; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + word-wrap: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; + } + + pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, + code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { + text-shadow: none; + } + + pre[class*="language-"]::selection, pre[class*="language-"] ::selection, + code[class*="language-"]::selection, code[class*="language-"] ::selection { + text-shadow: none; + } + + @media print { + code[class*="language-"], + pre[class*="language-"] { + text-shadow: none; + } + } + + /* Code blocks */ + pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; + } + + :not(pre) > code[class*="language-"], + pre[class*="language-"] { + } + + /* Inline code */ + :not(pre) > code[class*="language-"] { + padding: .1em; + border-radius: .3em; + white-space: normal; + } + + .token.comment, + .token.prolog, + .token.doctype, + .token.cdata { + color: slategray; + } + + .token.punctuation { + color: #999; + } + + .namespace { + opacity: .7; + } + + .token.property, + .token.tag, + .token.boolean, + .token.number, + .token.constant, + .token.symbol, + .token.deleted { + color: #905; + } + + .token.selector, + .token.attr-name, + .token.string, + .token.char, + .token.builtin, + .token.inserted { + color: #690; + } + + .token.operator, + .token.entity, + .token.url, + .language-css .token.string, + .style .token.string { + color: #9a6e3a; + /*background: hsla(0, 0%, 100%, .5);*/ + } + + .token.atrule, + .token.attr-value, + .token.keyword { + color: #07a; + } + + .token.function, + .token.class-name { + color: #DD4A68; + } + + .token.regex, + .token.important, + .token.variable { + color: #e90; + } + + .token.important, + .token.bold { + font-weight: bold; + } + .token.italic { + font-style: italic; + } + + .token.entity { + cursor: help; + } + + pre[class*="language-"].line-numbers { + position: relative; + padding-left: 3.8em; + counter-reset: linenumber; +} + +pre[class*="language-"].line-numbers > code { + position: relative; + white-space: inherit; +} + +.line-numbers .line-numbers-rows { + position: absolute; + pointer-events: none; + top: 0; + font-size: 100%; + left: -3.8em; + width: 3em; /* works for line-numbers below 1000 lines */ + letter-spacing: -1px; + border-right: 1px solid #999; + + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + +} + + .line-numbers-rows > span { + pointer-events: none; + display: block; + counter-increment: linenumber; + } diff --git a/source/prism.js b/source/prism.js new file mode 100644 index 0000000..304be1e --- /dev/null +++ b/source/prism.js @@ -0,0 +1,1071 @@ + +/* ********************************************** + Begin prism-core.js +********************************************** */ + +var _self = (typeof window !== 'undefined') + ? window // if in browser + : ( + (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) + ? self // if in worker + : {} // if in node js + ); + +/** + * Prism: Lightweight, robust, elegant syntax highlighting + * MIT license http://www.opensource.org/licenses/mit-license.php/ + * @author Lea Verou http://lea.verou.me + */ + +var Prism = (function () { + + // Private helper vars + var lang = /\blang(?:uage)?-([\w-]+)\b/i; + var uniqueId = 0; + + var _ = _self.Prism = { + manual: _self.Prism && _self.Prism.manual, + disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, + util: { + encode: function (tokens) { + if (tokens instanceof Token) { + return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); + } else if (_.util.type(tokens) === 'Array') { + return tokens.map(_.util.encode); + } else { + return tokens.replace(/&/g, '&').replace(/ text.length) { + // Something went terribly wrong, ABORT, ABORT! + return; + } + + if (str instanceof Token) { + continue; + } + + if (greedy && i != strarr.length - 1) { + pattern.lastIndex = pos; + var match = pattern.exec(text); + if (!match) { + break; + } + + var from = match.index + (lookbehind ? match[1].length : 0), + to = match.index + match[0].length, + k = i, + p = pos; + + for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) { + p += strarr[k].length; + // Move the index i to the element in strarr that is closest to from + if (from >= p) { + ++i; + pos = p; + } + } + + // If strarr[i] is a Token, then the match starts inside another Token, which is invalid + if (strarr[i] instanceof Token) { + continue; + } + + // Number of tokens to delete and replace with the new match + delNum = k - i; + str = text.slice(pos, p); + match.index -= pos; + } else { + pattern.lastIndex = 0; + + var match = pattern.exec(str), + delNum = 1; + } + + if (!match) { + if (oneshot) { + break; + } + + continue; + } + + if (lookbehind) { + lookbehindLength = match[1] ? match[1].length : 0; + } + + var from = match.index + lookbehindLength, + match = match[0].slice(lookbehindLength), + to = from + match.length, + before = str.slice(0, from), + after = str.slice(to); + + var args = [i, delNum]; + + if (before) { + ++i; + pos += before.length; + args.push(before); + } + + var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy); + + args.push(wrapped); + + if (after) { + args.push(after); + } + + Array.prototype.splice.apply(strarr, args); + + if (delNum != 1) + _.matchGrammar(text, strarr, grammar, i, pos, true, token); + + if (oneshot) + break; + } + } + } + }, + + tokenize: function (text, grammar) { + var strarr = [text]; + + var rest = grammar.rest; + + if (rest) { + for (var token in rest) { + grammar[token] = rest[token]; + } + + delete grammar.rest; + } + + _.matchGrammar(text, strarr, grammar, 0, 0, false); + + return strarr; + }, + + hooks: { + all: {}, + + add: function (name, callback) { + var hooks = _.hooks.all; + + hooks[name] = hooks[name] || []; + + hooks[name].push(callback); + }, + + run: function (name, env) { + var callbacks = _.hooks.all[name]; + + if (!callbacks || !callbacks.length) { + return; + } + + for (var i = 0, callback; callback = callbacks[i++];) { + callback(env); + } + } + } + }; + + var Token = _.Token = function (type, content, alias, matchedStr, greedy) { + this.type = type; + this.content = content; + this.alias = alias; + // Copy of the full string this token was created from + this.length = (matchedStr || "").length | 0; + this.greedy = !!greedy; + }; + + Token.stringify = function (o, language, parent) { + if (typeof o == 'string') { + return o; + } + + if (_.util.type(o) === 'Array') { + return o.map(function (element) { + return Token.stringify(element, language, o); + }).join(''); + } + + var env = { + type: o.type, + content: Token.stringify(o.content, language, parent), + tag: 'span', + classes: ['token', o.type], + attributes: {}, + language: language, + parent: parent + }; + + if (o.alias) { + var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias]; + Array.prototype.push.apply(env.classes, aliases); + } + + _.hooks.run('wrap', env); + + var attributes = Object.keys(env.attributes).map(function (name) { + return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; + }).join(' '); + + return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + ''; + + }; + + if (!_self.document) { + if (!_self.addEventListener) { + // in Node.js + return _self.Prism; + } + + if (!_.disableWorkerMessageHandler) { + // In worker + _self.addEventListener('message', function (evt) { + var message = JSON.parse(evt.data), + lang = message.language, + code = message.code, + immediateClose = message.immediateClose; + + _self.postMessage(_.highlight(code, _.languages[lang], lang)); + if (immediateClose) { + _self.close(); + } + }, false); + } + + return _self.Prism; + } + + //Get current script and highlight + var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); + + if (script) { + _.filename = script.src; + + if (!_.manual && !script.hasAttribute('data-manual')) { + if (document.readyState !== "loading") { + if (window.requestAnimationFrame) { + window.requestAnimationFrame(_.highlightAll); + } else { + window.setTimeout(_.highlightAll, 16); + } + } + else { + document.addEventListener('DOMContentLoaded', _.highlightAll); + } + } + } + + return _self.Prism; + +})(); + +if (typeof module !== 'undefined' && module.exports) { + module.exports = Prism; +} + +// hack for components to work correctly in node.js +if (typeof global !== 'undefined') { + global.Prism = Prism; +} + + +/* ********************************************** + Begin prism-markup.js +********************************************** */ + +Prism.languages.markup = { + 'comment': //, + 'prolog': /<\?[\s\S]+?\?>/, + 'doctype': //i, + 'cdata': //i, + 'tag': { + pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i, + greedy: true, + inside: { + 'tag': { + pattern: /^<\/?[^\s>\/]+/i, + inside: { + 'punctuation': /^<\/?/, + 'namespace': /^[^\s>\/:]+:/ + } + }, + 'attr-value': { + pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i, + inside: { + 'punctuation': [ + /^=/, + { + pattern: /(^|[^\\])["']/, + lookbehind: true + } + ] + } + }, + 'punctuation': /\/?>/, + 'attr-name': { + pattern: /[^\s>\/]+/, + inside: { + 'namespace': /^[^\s>\/:]+:/ + } + } + + } + }, + 'entity': /&#?[\da-z]{1,8};/i +}; + +Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = + Prism.languages.markup['entity']; + +// Plugin to make entity title show the real entity, idea by Roman Komarov +Prism.hooks.add('wrap', function (env) { + + if (env.type === 'entity') { + env.attributes['title'] = env.content.replace(/&/, '&'); + } +}); + +Prism.languages.xml = Prism.languages.extend('markup', {}); +Prism.languages.html = Prism.languages.markup; +Prism.languages.mathml = Prism.languages.markup; +Prism.languages.svg = Prism.languages.markup; + + +/* ********************************************** + Begin prism-css.js +********************************************** */ + +Prism.languages.css = { + 'comment': /\/\*[\s\S]*?\*\//, + 'atrule': { + pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i, + inside: { + 'rule': /@[\w-]+/ + // See rest below + } + }, + 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'selector': /[^{}\s][^{};]*?(?=\s*\{)/, + 'string': { + pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, + 'important': /!important\b/i, + 'function': /[-a-z0-9]+(?=\()/i, + 'punctuation': /[(){};:,]/ +}; + +Prism.languages.css['atrule'].inside.rest = Prism.languages.css; + +if (Prism.languages.markup) { + Prism.languages.insertBefore('markup', 'tag', { + 'style': { + pattern: /()[\s\S]*?(?=<\/style>)/i, + lookbehind: true, + inside: Prism.languages.css, + alias: 'language-css', + greedy: true + } + }); + + Prism.languages.insertBefore('inside', 'attr-value', { + 'style-attr': { + pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, + inside: { + 'attr-name': { + pattern: /^\s*style/i, + inside: Prism.languages.markup.tag.inside + }, + 'punctuation': /^\s*=\s*['"]|['"]\s*$/, + 'attr-value': { + pattern: /.+/i, + inside: Prism.languages.css + } + }, + alias: 'language-css' + } + }, Prism.languages.markup.tag); +} + + +/* ********************************************** + Begin prism-clike.js +********************************************** */ + +Prism.languages.clike = { + 'comment': [ + { + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + lookbehind: true + }, + { + pattern: /(^|[^\\:])\/\/.*/, + lookbehind: true, + greedy: true + } + ], + 'string': { + pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'class-name': { + pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, + lookbehind: true, + inside: { + punctuation: /[.\\]/ + } + }, + 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, + 'boolean': /\b(?:true|false)\b/, + 'function': /\w+(?=\()/, + 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, + 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, + 'punctuation': /[{}[\];(),.:]/ +}; + + +/* ********************************************** + Begin prism-javascript.js +********************************************** */ + +Prism.languages.javascript = Prism.languages.extend('clike', { + 'class-name': [ + Prism.languages.clike['class-name'], + { + pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, + lookbehind: true + } + ], + 'keyword': [ + { + pattern: /((?:^|})\s*)(?:catch|finally)\b/, + lookbehind: true + }, + /\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/ + ], + 'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, + // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) + 'function': /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\(|\.(?:apply|bind|call)\()/, + 'operator': /-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ +}); + +Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/ + +Prism.languages.insertBefore('javascript', 'keyword', { + 'regex': { + pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, + lookbehind: true, + greedy: true + }, + // This must be declared before keyword because we use "function" inside the look-forward + 'function-variable': { + pattern: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/, + alias: 'function' + }, + 'parameter': [ + { + pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i, + inside: Prism.languages.javascript + }, + { + pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/, + lookbehind: true, + inside: Prism.languages.javascript + } + ], + 'constant': /\b[A-Z][A-Z\d_]*\b/ +}); + +Prism.languages.insertBefore('javascript', 'string', { + 'template-string': { + pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, + greedy: true, + inside: { + 'interpolation': { + pattern: /\${[^}]+}/, + inside: { + 'interpolation-punctuation': { + pattern: /^\${|}$/, + alias: 'punctuation' + }, + rest: Prism.languages.javascript + } + }, + 'string': /[\s\S]+/ + } + } +}); + +if (Prism.languages.markup) { + Prism.languages.insertBefore('markup', 'tag', { + 'script': { + pattern: /()[\s\S]*?(?=<\/script>)/i, + lookbehind: true, + inside: Prism.languages.javascript, + alias: 'language-javascript', + greedy: true + } + }); +} + +Prism.languages.js = Prism.languages.javascript; + + +/* ********************************************** + Begin prism-file-highlight.js +********************************************** */ + +(function () { + if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) { + return; + } + + /** + * @param {Element} [container=document] + */ + self.Prism.fileHighlight = function (container) { + container = container || document; + + var Extensions = { + 'js': 'javascript', + 'py': 'python', + 'rb': 'ruby', + 'ps1': 'powershell', + 'psm1': 'powershell', + 'sh': 'bash', + 'bat': 'batch', + 'h': 'c', + 'tex': 'latex' + }; + + Array.prototype.slice.call(container.querySelectorAll('pre[data-src]')).forEach(function (pre) { + // ignore if already loaded + if (pre.hasAttribute('data-src-loaded')) { + return; + } + + // load current + var src = pre.getAttribute('data-src'); + + var language, parent = pre; + var lang = /\blang(?:uage)?-([\w-]+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } + + if (parent) { + language = (pre.className.match(lang) || [, ''])[1]; + } + + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } + + var code = document.createElement('code'); + code.className = 'language-' + language; + + pre.textContent = ''; + + code.textContent = 'Loading…'; + + pre.appendChild(code); + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', src, true); + + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + + if (xhr.status < 400 && xhr.responseText) { + code.textContent = xhr.responseText; + + Prism.highlightElement(code); + // mark as loaded + pre.setAttribute('data-src-loaded', ''); + } + else if (xhr.status >= 400) { + code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; + } + else { + code.textContent = '✖ Error: File does not exist or is empty'; + } + } + }; + + xhr.send(null); + }); + + if (Prism.plugins.toolbar) { + Prism.plugins.toolbar.registerButton('download-file', function (env) { + var pre = env.element.parentNode; + if (!pre || !/pre/i.test(pre.nodeName) || !pre.hasAttribute('data-src') || !pre.hasAttribute('data-download-link')) { + return; + } + var src = pre.getAttribute('data-src'); + var a = document.createElement('a'); + a.textContent = pre.getAttribute('data-download-link-label') || 'Download'; + a.setAttribute('download', ''); + a.href = src; + return a; + }); + } + + }; + + document.addEventListener('DOMContentLoaded', function () { + // execute inside handler, for dropping Event as argumnet + self.Prism.fileHighlight(); + }); + +})(); + +(function () { + + if (typeof self === 'undefined' || !self.Prism || !self.document) { + return; + } + + /** + * Plugin name which is used as a class name for
 which is activating the plugin
+	 * @type {String}
+	 */
+  var PLUGIN_NAME = 'line-numbers';
+
+	/**
+	 * Regular expression used for determining line breaks
+	 * @type {RegExp}
+	 */
+  var NEW_LINE_EXP = /\n(?!$)/g;
+
+	/**
+	 * Resizes line numbers spans according to height of line of code
+	 * @param {Element} element 
 element
+	 */
+  var _resizeElement = function (element) {
+    var codeStyles = getStyles(element);
+    var whiteSpace = codeStyles['white-space'];
+
+    if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
+      var codeElement = element.querySelector('code');
+      var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
+      var lineNumberSizer = element.querySelector('.line-numbers-sizer');
+      var codeLines = codeElement.textContent.split(NEW_LINE_EXP);
+
+      if (!lineNumberSizer) {
+        lineNumberSizer = document.createElement('span');
+        lineNumberSizer.className = 'line-numbers-sizer';
+
+        codeElement.appendChild(lineNumberSizer);
+      }
+
+      lineNumberSizer.style.display = 'block';
+
+      codeLines.forEach(function (line, lineNumber) {
+        lineNumberSizer.textContent = line || '\n';
+        var lineSize = lineNumberSizer.getBoundingClientRect().height;
+        lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
+      });
+
+      lineNumberSizer.textContent = '';
+      lineNumberSizer.style.display = 'none';
+    }
+  };
+
+	/**
+	 * Returns style declarations for the element
+	 * @param {Element} element
+	 */
+  var getStyles = function (element) {
+    if (!element) {
+      return null;
+    }
+
+    return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null);
+  };
+
+  window.addEventListener('resize', function () {
+    Array.prototype.forEach.call(document.querySelectorAll('pre.' + PLUGIN_NAME), _resizeElement);
+  });
+
+  Prism.hooks.add('complete', function (env) {
+    if (!env.code) {
+      return;
+    }
+
+    // works only for  wrapped inside 
 (not inline)
+    var pre = env.element.parentNode;
+    var clsReg = /\s*\bline-numbers\b\s*/;
+    if (
+      !pre || !/pre/i.test(pre.nodeName) ||
+      // Abort only if nor the 
 nor the  have the class
+      (!clsReg.test(pre.className) && !clsReg.test(env.element.className))
+    ) {
+      return;
+    }
+
+    if (env.element.querySelector('.line-numbers-rows')) {
+      // Abort if line numbers already exists
+      return;
+    }
+
+    if (clsReg.test(env.element.className)) {
+      // Remove the class 'line-numbers' from the 
+      env.element.className = env.element.className.replace(clsReg, ' ');
+    }
+    if (!clsReg.test(pre.className)) {
+      // Add the class 'line-numbers' to the 
+      pre.className += ' line-numbers';
+    }
+
+    var match = env.code.match(NEW_LINE_EXP);
+    var linesNum = match ? match.length + 1 : 1;
+    var lineNumbersWrapper;
+
+    var lines = new Array(linesNum + 1);
+    lines = lines.join('');
+
+    lineNumbersWrapper = document.createElement('span');
+    lineNumbersWrapper.setAttribute('aria-hidden', 'true');
+    lineNumbersWrapper.className = 'line-numbers-rows';
+    lineNumbersWrapper.innerHTML = lines;
+
+    if (pre.hasAttribute('data-start')) {
+      pre.style.counterReset = 'linenumber ' + (parseInt(pre.getAttribute('data-start'), 10) - 1);
+    }
+
+    env.element.appendChild(lineNumbersWrapper);
+
+    _resizeElement(pre);
+
+    Prism.hooks.run('line-numbers', env);
+  });
+
+  Prism.hooks.add('line-numbers', function (env) {
+    env.plugins = env.plugins || {};
+    env.plugins.lineNumbers = true;
+  });
+
+	/**
+	 * Global exports
+	 */
+  Prism.plugins.lineNumbers = {
+		/**
+		 * Get node for provided line number
+		 * @param {Element} element pre element
+		 * @param {Number} number line number
+		 * @return {Element|undefined}
+		 */
+    getLine: function (element, number) {
+      if (element.tagName !== 'PRE' || !element.classList.contains(PLUGIN_NAME)) {
+        return;
+      }
+
+      var lineNumberRows = element.querySelector('.line-numbers-rows');
+      var lineNumberStart = parseInt(element.getAttribute('data-start'), 10) || 1;
+      var lineNumberEnd = lineNumberStart + (lineNumberRows.children.length - 1);
+
+      if (number < lineNumberStart) {
+        number = lineNumberStart;
+      }
+      if (number > lineNumberEnd) {
+        number = lineNumberEnd;
+      }
+
+      var lineIndex = number - lineNumberStart;
+
+      return lineNumberRows.children[lineIndex];
+    }
+  };
+
+}());
diff --git a/sw.js b/sw.js
deleted file mode 100644
index d25632e..0000000
--- a/sw.js
+++ /dev/null
@@ -1,20 +0,0 @@
-importScripts('/assets/cache-polyfill.js');
-
-self.addEventListener('install', function (e) {
-	e.waitUntil(
-		caches.open('mitjafelicijan').then(function (cache) {
-			return cache.addAll([
-				'/?homescreen=1',
-				'/assets/site.min.css',
-			]);
-		})
-	);
-});
-
-self.addEventListener('fetch', function (event) {
-	event.respondWith(
-		caches.match(event.request).then(function (response) {
-			return response || fetch(event.request);
-		})
-	);
-});
diff --git a/tools/draw/app.css b/tools/draw/app.css
deleted file mode 100644
index 60db957..0000000
--- a/tools/draw/app.css
+++ /dev/null
@@ -1,76 +0,0 @@
-@charset "utf-8";
-
-* {
-	box-sizing: border-box;
-	background-color: transparent;
-	margin: 0;
-	padding: 0;
-	border: 0;
-	list-style-type: none;
-	outline: none;
-	text-decoration: none;
-	position: relative;
-	box-shadow: none;
-	-moz-osx-font-smoothing: grayscale !important;
-	text-rendering: optimizeLegibility !important;
-	-webkit-font-smoothing: antialiased !important;
-	font-family: Arial, Helvetica, sans-serif;
-	user-select: none;
-}
-
-body {
-	margin: 0;
-	padding: 0;
-	font-size: 13px;
-}
-
-section {
-	position: fixed;
-	left: 0;
-	top: 0;
-	right: 0;
-	bottom: 0;
-	background-image: linear-gradient(0deg, transparent 24%, rgba(0, 0, 0, .08) 25%, rgba(0, 0, 0, .08) 26%, transparent 27%, transparent 74%, rgba(0, 0, 0, .08) 75%, rgba(0, 0, 0, .08) 76%, transparent 77%, transparent), linear-gradient(90deg, transparent 24%, rgba(0, 0, 0, .08) 25%, rgba(0, 0, 0, .08) 26%, transparent 27%, transparent 74%, rgba(0, 0, 0, .08) 75%, rgba(0, 0, 0, .08) 76%, transparent 77%, transparent);
-	background-size: 50px 50px;
-}
-
-canvas {
-	width: 100%;
-	height: 100%;
-}
-
-button {
-	display: block;
-	background: #fff;
-	border-radius: 5px;
-	width: 100%;
-	font-weight: bold;
-	cursor: pointer;
-	text-align: center;
-}
-
-nav.colors {
-	position: fixed;
-	left: 10px;
-	top: 10px;
-	width: 40px;
-}
-
-nav.colors button {
-	height: 40px;
-	margin-bottom: 10px;
-	border-radius: 50%;
-}
-
-nav.tools {
-	position: fixed;
-	left: 10px;
-	bottom: 10px;
-	width: 65px;
-}
-
-nav.tools button {
-	border: 2px solid #bbb;
-	padding: 10px 0;
-	margin-top: 10px;
-}
diff --git a/tools/draw/app.js b/tools/draw/app.js
deleted file mode 100644
index 4c73d75..0000000
--- a/tools/draw/app.js
+++ /dev/null
@@ -1,72 +0,0 @@
-window.addEventListener('load', function(evt) {
-
-	let paintStyle = getComputedStyle(document.querySelector('section'));
-	let canvas = document.querySelector('canvas');
-	let ctx = canvas.getContext('2d');
-
-	canvas.width = parseInt(paintStyle.getPropertyValue('width'));
-	canvas.height = parseInt(paintStyle.getPropertyValue('height'));
-
-	var mouse = {
-		x: 0,
-		y: 0
-	};
-
-	ctx.lineWidth = 3;
-	ctx.lineJoin = 'round';
-	ctx.lineCap = 'round';
-	ctx.strokeStyle = 'limegreen';
-
-	canvas.addEventListener('mousemove', function(e) {
-		mouse.x = e.pageX - this.offsetLeft;
-		mouse.y = e.pageY - this.offsetTop;
-	}, false);
-
-	canvas.addEventListener('mousedown', function(e) {
-		ctx.beginPath();
-		ctx.moveTo(mouse.x, mouse.y);
-		canvas.addEventListener('mousemove', onPaint, false);
-	}, false);
-
-	canvas.addEventListener('mouseup', function() {
-		canvas.removeEventListener('mousemove', onPaint, false);
-	}, false);
-
-	var onPaint = function() {
-		ctx.lineCap = 'round';
-		ctx.lineTo(mouse.x, mouse.y);
-		ctx.stroke();
-	};
-
-
-	document.querySelectorAll('nav button').forEach(function(button, idx) {
-
-		if (button.dataset.method == 'color') {
-			button.style.background = button.dataset.value;
-		}
-
-		button.addEventListener('click', function(evt) {
-			switch (button.dataset.method) {
-				case 'color':
-					{
-						ctx.strokeStyle = button.dataset.value;
-						break;
-					}
-				case 'size':
-					{
-						ctx.lineWidth = parseInt(button.dataset.value);
-						break;
-					}
-			}
-		});
-
-	});
-
-	document.addEventListener('keydown', function(evt) {
-		if (evt.keyCode == 8) {
-			ctx.clearRect(0, 0, canvas.width, canvas.height);
-		}
-		console.log(evt.keyCode);
-	}, false);
-
-});
diff --git a/tools/draw/favicon.png b/tools/draw/favicon.png
deleted file mode 100644
index f60ca30..0000000
Binary files a/tools/draw/favicon.png and /dev/null differ
diff --git a/tools/draw/index.html b/tools/draw/index.html
deleted file mode 100644
index 87ff1d2..0000000
--- a/tools/draw/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-	
-		
-		
-		
-		Draw
-		
-		
-	
-
-	
-
-		
- -
- - - - - - - - - - diff --git a/tools/editor/favicon.ico b/tools/editor/favicon.ico deleted file mode 100644 index f2a4604..0000000 Binary files a/tools/editor/favicon.ico and /dev/null differ diff --git a/tools/editor/index.html b/tools/editor/index.html deleted file mode 100644 index 3bdef13..0000000 --- a/tools/editor/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - Editor - - - - - - - - - - -
- - - - - - -- cgit v1.2.3