[
  {
    "path": ".gitattributes",
    "content": "app/assets/** linguist-vendored\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/issue.md",
    "content": "---\nname: Issue\nabout: Create an issue\n---\n\nHi,\n\nBefore creating an issue, please check out the Contributing Guide:\n\nhttps://github.com/ankane/pghero/blob/master/CONTRIBUTING.md\n\nThanks!\n"
  },
  {
    "path": ".github/workflows/build.yml",
    "content": "name: build\non: [push, pull_request]\njobs:\n  build:\n    runs-on: ${{ matrix.os || 'ubuntu-latest' }}\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - ruby: \"4.0\"\n            gemfile: Gemfile\n            postgres: 18\n          - ruby: 3.4\n            gemfile: gemfiles/activerecord80.gemfile\n            postgres: 16\n          - ruby: 3.3\n            gemfile: gemfiles/activerecord72.gemfile\n            postgres: 15\n          - ruby: 3.2\n            gemfile: gemfiles/activerecord71.gemfile\n            postgres: 13\n            os: ubuntu-22.04\n    env:\n      BUNDLE_GEMFILE: ${{ matrix.gemfile }}\n    steps:\n      - uses: actions/checkout@v5\n      - uses: ruby/setup-ruby@v1\n        with:\n          ruby-version: ${{ matrix.ruby }}\n          bundler-cache: true\n      - uses: ankane/setup-postgres@v1\n        with:\n          postgres-version: ${{ matrix.postgres }}\n          database: pghero_test\n          config: |\n            shared_preload_libraries = 'pg_stat_statements'\n      - run: bundle exec rake test\n"
  },
  {
    "path": ".gitignore",
    "content": "*.gem\n*.rbc\n.bundle\n.config\n.yardoc\n*.lock\nInstalledFiles\n_yardoc\ncoverage\ndoc/\nlib/bundler/man\npkg\nrdoc\nspec/reports\ntest/tmp\ntest/version_tmp\ntmp\n*.bundle\n*.so\n*.o\n*.a\n*.log\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## 3.7.0 (2025-05-26)\n\n- Dropped support for Linux package for Ubuntu 20.04\n- Dropped support for Ruby < 3.2 and Rails < 7.1\n\n## 3.6.2 (2025-03-21)\n\n- Improved query in `sequences` method\n\n## 3.6.1 (2024-10-14)\n\n- Fixed error when Propshaft is installed but not used\n\n## 3.6.0 (2024-07-10)\n\n- Improved CSP support\n- Dropped support for Linux packages for Ubuntu 18.04, CentOS 7, and SLES 12\n- Dropped support for Ruby < 3.1 and Rails < 6.1\n\n## 3.5.0 (2024-05-21)\n\n- Added materialized views to space page and `relation_sizes` method\n- Added Linux package for Debian 12\n- Fixed error with `slow_queries` method\n\n## 3.4.1 (2024-02-07)\n\n- Added current stats to query details page\n- Improved tune page for latest PgTune\n\n## 3.4.0 (2023-11-28)\n\n- Added support for explaining normalized queries with Postgres 16\n- Added Docker image for `linux/arm64`\n\n## 3.3.4 (2023-09-05)\n\n- Fixed support for aliases in config file\n\n## 3.3.3 (2023-04-18)\n\n- Fixed error with system stats for Azure Database\n\n## 3.3.2 (2023-04-12)\n\n- Fixed error with suggested indexes and empty statements\n\n## 3.3.1 (2023-03-15)\n\n- Fixed error with Uglifier\n\n## 3.3.0 (2023-03-11)\n\n- Improved handling of lock timeouts\n- Improved syntax highlighting\n\n## 3.2.0 (2023-02-21)\n\n- Added support for pg_query 4\n- Added `pghero:clean_space_stats` rake task\n- Added support for specifying retention period with `clean_query_stats` and `clean_space_stats`\n- Removed reset button when historical query stats are enabled\n\n## 3.1.0 (2023-01-04)\n\n- Fixed explain error message leaking data - [more info](https://github.com/ankane/pghero/issues/439)\n- Explain analyze is now opt-in - [more info](https://github.com/ankane/pghero/issues/438)\n- Added support for disabling explain and explain analyze\n- Added support for visualize without explain analyze\n- Added `explain_v2` method\n\n## 3.0.1 (2022-10-09)\n\n- Fixed message when database user does not have permission to reset query stats\n\n## 3.0.0 (2022-09-13)\n\n- Changed `capture_query_stats` to only reset stats for current database in Postgres 12+\n- Changed `reset_query_stats` to only reset stats for current database (use `reset_instance_query_stats` to reset stats for entire instance)\n- Added `visualize_url` option to config\n- Removed `access_key_id`, `secret_access_key`, `region`, and `db_instance_identifier` methods (use `aws_` prefixed methods instead)\n- Dropped support for Linux packages for EOL versions\n- Dropped support for Ruby < 2.7 and Rails < 6\n- Dropped support for pg_query < 2\n- Dropped support for aws-sdk < 2\n\n## 2.8.3 (2022-05-01)\n\n- Added support for `google-apis-monitoring_v3`\n- Added experimental support for Propshaft\n- Fixed error with walsender queries on live queries page\n\n## 2.8.2 (2021-12-15)\n\n- Fixed sorting by name on space page when historical space stats are not enabled\n- Fixed deprecation warnings with Active Record 7\n\n## 2.8.1 (2021-03-25)\n\n- Added support for pg_query 2\n\n## 2.8.0 (2021-03-14)\n\n- No longer show walsender in long running queries\n- Show relative time on maintenance page\n- Added support for `PGHERO_TZ` for Docker and Linux\n\n## 2.7.4 (2021-02-01)\n\n- Fixed error on redirect with Ruby 3\n- Fixed error with unparsable sequences\n\n## 2.7.3 (2020-11-23)\n\n- Improved index suggestions when hash, GiST, GIN, or BRIN index present\n\n## 2.7.2 (2020-09-10)\n\n- Fixed error with historical query stats\n\n## 2.7.1 (2020-09-07)\n\n- Added `/health` endpoint to Docker image and Linux packages\n- Fixed error with `cast_value`\n\n## 2.7.0 (2020-08-04)\n\n- Fixed CSRF vulnerability with non-session based authentication - [more info](https://github.com/ankane/pghero/issues/330)\n- Added `database`, `user`, and `query_hash` options to `reset_query_stats` method\n\n## 2.6.0 (2020-07-09)\n\n- Added support for Postgres 13 beta 2\n- Added support for non-integer explain timeout\n\n## 2.5.1 (2020-06-23)\n\n- Added support for `google-cloud-monitoring` >= 1\n- Added support for `google-cloud-monitoring-v3`\n- Fixed system stats not showing up in Rails 6 with environment variables\n\n## 2.5.0 (2020-05-24)\n\n- Added system stats for Google Cloud SQL and Azure Database\n- Added experimental `filter_data` option\n- Localized times on maintenance page\n- Improved connection pooling\n- Improved error message for non-Postgres connections\n- Fixed more deprecation warnings in Ruby 2.7\n\n## 2.4.2 (2020-04-16)\n\n- Added `connections` method\n- Fixed deprecation warnings in Ruby 2.7\n\n## 2.4.1 (2019-11-21)\n\n- Fixed file permissions on `highlight.pack.js`\n\n## 2.4.0 (2019-11-11)\n\n- Added `invalid_constraints` method\n- Added `spec` option\n- Added `override_csp` option\n- Show all databases in Rails 6 when no config\n\n## 2.3.0 (2019-08-18)\n\n- Added support for Postgres 12 beta 1\n- Added methods and tasks for cleaning up stats\n- Dropped support for Rails < 5\n\n## 2.2.1 (2019-06-04)\n\n- Added `config_path` option\n- Fixed error with sequences when temporary tables\n- Fixed error when `config.action_controller.include_all_helpers = false`\n\n## 2.2.0 (2018-09-03)\n\n- Added check for connections idle in transaction\n- Improved duplicate index logic to detect more duplicates\n- Don't report concurrent indexes in-progress as invalid on dashboard\n- Fixed error with large number of sequences\n- Bumped `total_connections_threshold` to 500 by default\n\n## 2.1.1 (2018-04-24)\n\n- Added `explain_timeout_sec` option\n- Fixed error with unparsable sequences\n- Stopped throwing `Same sequence name in multiple schemas` error\n\n## 2.1.0 (2017-11-30)\n\n- Fixed issue with sequences in different schema than table\n- No longer throw errors for unreadable sequences\n- Fixed replication lag for Amazon Aurora\n- Added `vacuum_progress` method\n\n## 2.0.8 (2017-11-12)\n\n- Added support for Postgres 10 replicas\n- Added support for pg_query 1.0.0\n- Show queries with insufficient privilege on live queries page\n- Default to table schema for sequences\n\n## 2.0.7 (2017-10-28)\n\n- Fixed issue with sequences in different schema than table\n- Fixed query details when multiple users have same query hash\n- Fixed error with invalid indexes in non-public schema\n- Raise error when capture query stats fails\n\n## 2.0.6 (2017-09-24)\n\n- More robust methods for multiple databases\n- Added support for `RAILS_RELATIVE_URL_ROOT` for Linux and Docker\n\n## 2.0.5 (2017-09-14)\n\n- Fixed error with sequences in different schemas\n- Better advice\n\n## 2.0.4 (2017-08-28)\n\n- Fixed `AssetNotPrecompiled` error\n- Do not silently ignore sequence danger when user does not have permissions\n\n## 2.0.3 (2017-08-22)\n\n- Added SQL to recreate invalid indexes\n- Added unused index marker to Space page\n- Fixed `capture_query_stats` on Postgres < 9.4\n\n## 2.0.2 (2017-08-09)\n\n- Fixed error with suggested indexes\n- Fixed error with `pg_replication_slots`\n\n## 2.0.1 (2017-08-08)\n\n- Fixed capture space stats\n\n## 2.0.0 (2017-08-08)\n\nNew features\n\n- Query details page\n- Added check for inactive replication slots\n- Added `table_sizes` method for full table sizes\n- Added syntax highlighting\n- Added `min_size` option to `analyze_tables`\n\nBreaking changes\n\n- Methods now return symbols for keys instead of strings\n- Methods raise `PgHero::NotEnabled` error when a feature isn’t enabled\n- Requires pg_query 0.9.0+ for suggested indexes\n- Historical query stats require the `pghero_query_stats` table to have `query_hash` and `user` columns\n- Removed `with` option - use:\n\n```ruby\nPgHero.databases[:database2].running_queries\n```\n\ninstead of\n\n```ruby\nPgHero.with(:database2) { PgHero.running_queries }\n```\n\n- Removed options from `connection_sources` method\n- Removed `locks` method\n\n## 1.7.0 (2017-05-01)\n\n- Fixed migrations for Rails 5.1+\n- Added `analyze`, `analyze_tables`, and `analyze_all` methods\n- Added `pghero:analyze` rake task\n- Fixed system stats display issue\n\n## 1.6.5 (2017-04-19)\n\n- Added support for Rails API\n- Added support for Amazon STS\n- Fixed replica check when `hot_standby = on` for primary\n\n## 1.6.4 (2017-03-12)\n\n- Only show connection charts if there are connections\n- Fixed duplicate indexes for multiple schemas\n- Fixed display issue for queries without word break\n- Removed maintenance tab for replicas\n\n## 1.6.3 (2017-02-09)\n\n- Added 10 second timeout for explain\n- No longer show autovacuum in long running queries\n- Added charts for connections\n- Added new config format\n- Removed Chartkick gem dependency for charts\n- Fixed error when primary database is not PostgreSQL\n\n## 1.6.2 (2016-10-26)\n\n- Suggest GiST over GIN for `LIKE` queries again (seeing better performance)\n\n## 1.6.1 (2016-10-24)\n\n- Suggest GIN over GiST for `LIKE` queries\n\n## 1.6.0 (2016-10-20)\n\n- Removed mostly inactionable items (cache hit rate and index usage)\n- Restored duplicate indexes to homepage\n- Fixed issue with exact duplicate indexes\n- Way better `blocked_queries` method\n\n## 1.5.3 (2016-10-06)\n\n- Fixed Rails 5 error with multiple databases\n- Fixed duplicate index detection with expressions\n\n## 1.5.2 (2016-10-01)\n\n- Added support for PostgreSQL 9.6\n- Fixed incorrect query start for live queries in transactions\n\n## 1.5.1 (2016-09-27)\n\n- Better tune page for PostgreSQL 9.5\n\n## 1.5.0 (2016-09-21)\n\n- Added user to query stats (opt-in)\n- Added user to connection sources\n- Added `capture_space_stats` method and rake task\n- Added visualize button to explain page\n- Better charts for system stats\n\n## 1.4.2 (2016-09-06)\n\n- Fixed `wrong constant name` error in development\n- Added different periods for system stats\n\n## 1.4.1 (2016-08-25)\n\n- Removed external assets\n\n## 1.4.0 (2016-08-24)\n\n- Updated for Rails 5\n- Fixed error when `pg_stat_statements` not enabled in `shared_libraries`\n\n## 1.3.2 (2016-08-03)\n\n- Improved performance of query stats\n\n## 1.3.1 (2016-07-10)\n\n- Improved grouping of query stats\n- Added `blocked_queries` method\n\n## 1.3.0 (2016-06-27)\n\n- Added query hash for better query stats grouping\n- Added sequence danger check\n- Added `capture_query_stats` option to config\n\n## 1.2.4 (2016-05-06)\n\n- Fixed user methods\n\n## 1.2.3 (2016-04-20)\n\n- Added schema to queries\n- Fixed deprecation warning on Rails 5\n- Fix for pg_query >= 0.9.0\n\n## 1.2.2 (2016-01-20)\n\n- Better suggested indexes\n- Removed duplicate indexes noise\n- Fixed partial and expression indexes\n\n## 1.2.1 (2016-01-07)\n\n- Better suggested indexes\n- Removed unused indexes noise\n- Removed autovacuum danger noise\n- Removed maintenance tab\n- Fixed suggested indexes for replicas\n- Fixed issue w/ suggested indexes where same table name exists in multiple schemas\n\n## 1.2.0 (2015-12-31)\n\n- Added suggested indexes\n- Added duplicate indexes\n- Added maintenance tab\n- Added load stats for RDS\n- Added `table_caching` and `index_caching` methods\n- Added configurable cache hit rate threshold\n- Show all connections in connections tab\n\n## 1.1.4 (2015-12-08)\n\n- Added check for transaction ID wraparound failure\n- Added check for autovacuum danger\n\n## 1.1.3 (2015-10-21)\n\n- Fixed system stats\n\n## 1.1.2 (2015-10-18)\n\n- Added invalid indexes\n- Fixed RDS stats for aws-sdk 2\n\n## 1.1.1 (2015-07-23)\n\n- Added `tables` option to `create_user` method\n- Added ability to sort query stats by average_time and calls\n- Only show unused indexes with no index scans in UI\n\n## 1.1.0 (2015-06-26)\n\n- Added historical query stats\n\n## 1.0.1 (2015-04-17)\n\n- Fixed connection bad errors\n- Restore previous connection properly for nested with blocks\n- Added analyze button to explain page\n- Added explain button to live queries page\n\n## 1.0.0 (2015-04-11)\n\n- More platforms!\n- Support for multiple databases!\n- Added `replica?` method\n- Added `replication_lag` method\n- Added `ssl_used?` method\n- Added `kill_long_running_queries` method\n- Added env vars for settings\n\n## 0.1.10 (2015-03-20)\n\n- Added connections page\n- Added message for insufficient privilege\n- Added `ip` to `connection_sources`\n\n## 0.1.9 (2015-01-25)\n\n- Added tune page\n- Removed minimum size for unused indexes\n\n## 0.1.8 (2015-01-19)\n\n- Added `total_percent` to `query_stats`\n- Added `total_connections`\n- Added `connection_stats` for Amazon RDS\n\n## 0.1.7 (2014-11-12)\n\n- Added support for pg_stat_statements on Amazon RDS\n- Added `long_running_query_sec`, `slow_query_ms` and `slow_query_calls` options\n\n## 0.1.6 (2014-10-09)\n\n- Added methods to create and drop users\n- Added locks\n\n## 0.1.5 (2014-09-03)\n\n- Added system stats for Amazon RDS\n- Added code to remove unused indexes\n- Require unused indexes to be at least 1 MB\n- Use `pg_terminate_backend` to ensure queries are killed\n\n## 0.1.4 (2014-08-31)\n\n- Reduced long running queries threshold to 1 minute\n- Fixed duration\n- Fixed wrapping\n- Friendlier dependencies for JRuby\n\n## 0.1.3 (2014-08-04)\n\n- Reverted `query_stats_available?` fix\n\n## 0.1.2 (2014-08-03)\n\n- Fixed `query_stats_available?` method\n\n## 0.1.1 (2014-08-03)\n\n- Added explain\n- Added query stats\n- Fixed CSS issues\n\n## 0.1.0 (2014-07-23)\n\n- Improved explanations\n- Updated design\n\n## 0.0.3 (2014-07-22)\n\n- Fixed `missing_indexes` method\n\n## 0.0.2 (2014-07-21)\n\n- Added `unused_tables` method\n- Added `database_size` method\n\n## 0.0.1 (2014-07-21)\n\n- First release\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\nFirst, thanks for wanting to contribute. You’re awesome! :heart:\n\n## Help\n\nWe’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).\n\nAll features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.\n\n## Bugs\n\nThink you’ve discovered a bug?\n\n1. Search existing issues to see if it’s been reported.\n2. Try the `master` branch to make sure it hasn’t been fixed.\n\n```rb\ngem \"pghero\", github: \"ankane/pghero\"\n```\n\nIf the above steps don’t help, create an issue. Include:\n\n- Detailed steps to reproduce\n- Complete backtraces for exceptions\n\n## New Features\n\nIf you’d like to discuss a new feature, create an issue and start the title with `[Idea]`.\n\n## Pull Requests\n\nFork the project and create a pull request. A few tips:\n\n- Keep changes to a minimum. If you have multiple features or fixes, submit multiple pull requests.\n- Follow the existing style. The code should read like it’s written by a single person.\n\nFeel free to open an issue to get feedback on your idea before spending too much time on it.\n\n---\n\nThis contributing guide is released under [CCO](https://creativecommons.org/publicdomain/zero/1.0/) (public domain). Use it for your own project without attribution.\n"
  },
  {
    "path": "Gemfile",
    "content": "source \"https://rubygems.org\"\n\ngemspec\n\ngem \"rake\"\ngem \"minitest\"\ngem \"activerecord\", \"~> 8.1.0\"\ngem \"combustion\"\ngem \"pg\"\ngem \"pg_query\", platform: [:ruby, :windows]\ngem \"tzinfo-data\", platform: :windows\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Copyright (c) 2014-2025 Andrew Kane, 2008-2014 Heroku (initial queries)\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# PgHero\n\nA performance dashboard for Postgres\n\n[See it in action](https://pghero.dokkuapp.com/)\n\n[![Screenshot](https://pghero.dokkuapp.com/assets/pghero-88a0d052.png)](https://pghero.dokkuapp.com/)\n\n:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)\n\n[![Build Status](https://github.com/ankane/pghero/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/pghero/actions)\n\n## Documentation\n\nPgHero is available as a Docker image, Linux package, and Rails engine.\n\nSelect your preferred method of installation to get started.\n\n- [Docker](guides/Docker.md)\n- [Linux](guides/Linux.md)\n- [Rails](guides/Rails.md)\n\n## Related Projects\n\n- [Dexter](https://github.com/ankane/dexter) - The automatic indexer for Postgres\n- [PgBouncerHero](https://github.com/kwent/pgbouncerhero) - A dashboard for PgBouncer\n- [pgsync](https://github.com/ankane/pgsync) - Sync Postgres data between databases\n- [pgslice](https://github.com/ankane/pgslice) - Postgres partitioning as easy as pie\n\n## Credits\n\nA big thanks to [Craig Kerstiens](https://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/) and [Heroku](https://blog.heroku.com/archives/2013/5/10/more_insight_into_your_database_with_pgextras) for the initial queries and [Bootswatch](https://github.com/thomaspark/bootswatch) for the theme.\n\n## History\n\nView the [changelog](https://github.com/ankane/pghero/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/pghero/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/pghero/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n"
  },
  {
    "path": "Rakefile",
    "content": "require \"bundler/gem_tasks\"\nrequire \"rake/testtask\"\n\nRake::TestTask.new do |t|\n  t.pattern = \"test/**/*_test.rb\"\nend\n\ntask default: :test\n"
  },
  {
    "path": "app/assets/javascripts/pghero/Chart.bundle.js",
    "content": "/*!\n * Chart.js v4.2.0\n * https://www.chartjs.org\n * (c) 2023 Chart.js Contributors\n * Released under the MIT License\n *\n * @kurkle/color v0.3.2\n * https://github.com/kurkle/color#readme\n * (c) 2023 Jukka Kurkela\n * Released under the MIT License\n *\n * chartjs-adapter-date-fns v3.0.0\n * https://www.chartjs.org\n * (c) 2022 chartjs-adapter-date-fns Contributors\n * Released under the MIT license\n *\n * date-fns v2.29.3\n * https://date-fns.org\n * (c) 2021 Sasha Koss and Lesha Koss\n * Released under the MIT License\n */\n\n(function (global, factory) {\n  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n  typeof define === 'function' && define.amd ? define(factory) :\n  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chart = factory());\n})(this, (function () { 'use strict';\n\n  function _iterableToArrayLimit(arr, i) {\n    var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n    if (null != _i) {\n      var _s,\n        _e,\n        _x,\n        _r,\n        _arr = [],\n        _n = !0,\n        _d = !1;\n      try {\n        if (_x = (_i = _i.call(arr)).next, 0 === i) {\n          if (Object(_i) !== _i) return;\n          _n = !1;\n        } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);\n      } catch (err) {\n        _d = !0, _e = err;\n      } finally {\n        try {\n          if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;\n        } finally {\n          if (_d) throw _e;\n        }\n      }\n      return _arr;\n    }\n  }\n  function ownKeys(object, enumerableOnly) {\n    var keys = Object.keys(object);\n    if (Object.getOwnPropertySymbols) {\n      var symbols = Object.getOwnPropertySymbols(object);\n      enumerableOnly && (symbols = symbols.filter(function (sym) {\n        return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n      })), keys.push.apply(keys, symbols);\n    }\n    return keys;\n  }\n  function _objectSpread2(target) {\n    for (var i = 1; i < arguments.length; i++) {\n      var source = null != arguments[i] ? arguments[i] : {};\n      i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {\n        _defineProperty$w(target, key, source[key]);\n      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {\n        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n      });\n    }\n    return target;\n  }\n  function _typeof$z(obj) {\n    \"@babel/helpers - typeof\";\n\n    return _typeof$z = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n      return typeof obj;\n    } : function (obj) {\n      return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n    }, _typeof$z(obj);\n  }\n  function _classCallCheck$x(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$x(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);\n    }\n  }\n  function _createClass$x(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$x(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$x(Constructor, staticProps);\n    Object.defineProperty(Constructor, \"prototype\", {\n      writable: false\n    });\n    return Constructor;\n  }\n  function _defineProperty$w(obj, key, value) {\n    key = _toPropertyKey(key);\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  function _inherits$w(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    Object.defineProperty(subClass, \"prototype\", {\n      writable: false\n    });\n    if (superClass) _setPrototypeOf$w(subClass, superClass);\n  }\n  function _getPrototypeOf$w(o) {\n    _getPrototypeOf$w = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$w(o);\n  }\n  function _setPrototypeOf$w(o, p) {\n    _setPrototypeOf$w = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$w(o, p);\n  }\n  function _isNativeReflectConstruct$w() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _assertThisInitialized$w(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _possibleConstructorReturn$w(self, call) {\n    if (call && (typeof call === \"object\" || typeof call === \"function\")) {\n      return call;\n    } else if (call !== void 0) {\n      throw new TypeError(\"Derived constructors may only return object or undefined\");\n    }\n    return _assertThisInitialized$w(self);\n  }\n  function _createSuper$w(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$w();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$w(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$w(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$w(this, result);\n    };\n  }\n  function _superPropBase(object, property) {\n    while (!Object.prototype.hasOwnProperty.call(object, property)) {\n      object = _getPrototypeOf$w(object);\n      if (object === null) break;\n    }\n    return object;\n  }\n  function _get() {\n    if (typeof Reflect !== \"undefined\" && Reflect.get) {\n      _get = Reflect.get.bind();\n    } else {\n      _get = function _get(target, property, receiver) {\n        var base = _superPropBase(target, property);\n        if (!base) return;\n        var desc = Object.getOwnPropertyDescriptor(base, property);\n        if (desc.get) {\n          return desc.get.call(arguments.length < 3 ? target : receiver);\n        }\n        return desc.value;\n      };\n    }\n    return _get.apply(this, arguments);\n  }\n  function _slicedToArray(arr, i) {\n    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();\n  }\n  function _toConsumableArray(arr) {\n    return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();\n  }\n  function _arrayWithoutHoles(arr) {\n    if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);\n  }\n  function _arrayWithHoles(arr) {\n    if (Array.isArray(arr)) return arr;\n  }\n  function _iterableToArray(iter) {\n    if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n  }\n  function _unsupportedIterableToArray$1(o, minLen) {\n    if (!o) return;\n    if (typeof o === \"string\") return _arrayLikeToArray$1(o, minLen);\n    var n = Object.prototype.toString.call(o).slice(8, -1);\n    if (n === \"Object\" && o.constructor) n = o.constructor.name;\n    if (n === \"Map\" || n === \"Set\") return Array.from(o);\n    if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);\n  }\n  function _arrayLikeToArray$1(arr, len) {\n    if (len == null || len > arr.length) len = arr.length;\n    for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n    return arr2;\n  }\n  function _nonIterableSpread() {\n    throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n  }\n  function _nonIterableRest() {\n    throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n  }\n  function _createForOfIteratorHelper$1(o, allowArrayLike) {\n    var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n    if (!it) {\n      if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n        if (it) o = it;\n        var i = 0;\n        var F = function () {};\n        return {\n          s: F,\n          n: function () {\n            if (i >= o.length) return {\n              done: true\n            };\n            return {\n              done: false,\n              value: o[i++]\n            };\n          },\n          e: function (e) {\n            throw e;\n          },\n          f: F\n        };\n      }\n      throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n    }\n    var normalCompletion = true,\n      didErr = false,\n      err;\n    return {\n      s: function () {\n        it = it.call(o);\n      },\n      n: function () {\n        var step = it.next();\n        normalCompletion = step.done;\n        return step;\n      },\n      e: function (e) {\n        didErr = true;\n        err = e;\n      },\n      f: function () {\n        try {\n          if (!normalCompletion && it.return != null) it.return();\n        } finally {\n          if (didErr) throw err;\n        }\n      }\n    };\n  }\n  function _toPrimitive(input, hint) {\n    if (typeof input !== \"object\" || input === null) return input;\n    var prim = input[Symbol.toPrimitive];\n    if (prim !== undefined) {\n      var res = prim.call(input, hint || \"default\");\n      if (typeof res !== \"object\") return res;\n      throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n    }\n    return (hint === \"string\" ? String : Number)(input);\n  }\n  function _toPropertyKey(arg) {\n    var key = _toPrimitive(arg, \"string\");\n    return typeof key === \"symbol\" ? key : String(key);\n  }\n\n  /*!\n   * @kurkle/color v0.3.2\n   * https://github.com/kurkle/color#readme\n   * (c) 2023 Jukka Kurkela\n   * Released under the MIT License\n   */\n  function round(v) {\n    return v + 0.5 | 0;\n  }\n  var lim = function lim(v, l, h) {\n    return Math.max(Math.min(v, h), l);\n  };\n  function p2b(v) {\n    return lim(round(v * 2.55), 0, 255);\n  }\n  function n2b(v) {\n    return lim(round(v * 255), 0, 255);\n  }\n  function b2n(v) {\n    return lim(round(v / 2.55) / 100, 0, 1);\n  }\n  function n2p(v) {\n    return lim(round(v * 100), 0, 100);\n  }\n  var map$1 = {\n    0: 0,\n    1: 1,\n    2: 2,\n    3: 3,\n    4: 4,\n    5: 5,\n    6: 6,\n    7: 7,\n    8: 8,\n    9: 9,\n    A: 10,\n    B: 11,\n    C: 12,\n    D: 13,\n    E: 14,\n    F: 15,\n    a: 10,\n    b: 11,\n    c: 12,\n    d: 13,\n    e: 14,\n    f: 15\n  };\n  var hex = _toConsumableArray('0123456789ABCDEF');\n  var h1 = function h1(b) {\n    return hex[b & 0xF];\n  };\n  var h2 = function h2(b) {\n    return hex[(b & 0xF0) >> 4] + hex[b & 0xF];\n  };\n  var eq = function eq(b) {\n    return (b & 0xF0) >> 4 === (b & 0xF);\n  };\n  var isShort = function isShort(v) {\n    return eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a);\n  };\n  function hexParse(str) {\n    var len = str.length;\n    var ret;\n    if (str[0] === '#') {\n      if (len === 4 || len === 5) {\n        ret = {\n          r: 255 & map$1[str[1]] * 17,\n          g: 255 & map$1[str[2]] * 17,\n          b: 255 & map$1[str[3]] * 17,\n          a: len === 5 ? map$1[str[4]] * 17 : 255\n        };\n      } else if (len === 7 || len === 9) {\n        ret = {\n          r: map$1[str[1]] << 4 | map$1[str[2]],\n          g: map$1[str[3]] << 4 | map$1[str[4]],\n          b: map$1[str[5]] << 4 | map$1[str[6]],\n          a: len === 9 ? map$1[str[7]] << 4 | map$1[str[8]] : 255\n        };\n      }\n    }\n    return ret;\n  }\n  var alpha = function alpha(a, f) {\n    return a < 255 ? f(a) : '';\n  };\n  function _hexString(v) {\n    var f = isShort(v) ? h1 : h2;\n    return v ? '#' + f(v.r) + f(v.g) + f(v.b) + alpha(v.a, f) : undefined;\n  }\n  var HUE_RE = /^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\n  function hsl2rgbn(h, s, l) {\n    var a = s * Math.min(l, 1 - l);\n    var f = function f(n) {\n      var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12;\n      return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n    };\n    return [f(0), f(8), f(4)];\n  }\n  function hsv2rgbn(h, s, v) {\n    var f = function f(n) {\n      var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 60) % 6;\n      return v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);\n    };\n    return [f(5), f(3), f(1)];\n  }\n  function hwb2rgbn(h, w, b) {\n    var rgb = hsl2rgbn(h, 1, 0.5);\n    var i;\n    if (w + b > 1) {\n      i = 1 / (w + b);\n      w *= i;\n      b *= i;\n    }\n    for (i = 0; i < 3; i++) {\n      rgb[i] *= 1 - w - b;\n      rgb[i] += w;\n    }\n    return rgb;\n  }\n  function hueValue(r, g, b, d, max) {\n    if (r === max) {\n      return (g - b) / d + (g < b ? 6 : 0);\n    }\n    if (g === max) {\n      return (b - r) / d + 2;\n    }\n    return (r - g) / d + 4;\n  }\n  function rgb2hsl(v) {\n    var range = 255;\n    var r = v.r / range;\n    var g = v.g / range;\n    var b = v.b / range;\n    var max = Math.max(r, g, b);\n    var min = Math.min(r, g, b);\n    var l = (max + min) / 2;\n    var h, s, d;\n    if (max !== min) {\n      d = max - min;\n      s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n      h = hueValue(r, g, b, d, max);\n      h = h * 60 + 0.5;\n    }\n    return [h | 0, s || 0, l];\n  }\n  function calln(f, a, b, c) {\n    return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b);\n  }\n  function hsl2rgb(h, s, l) {\n    return calln(hsl2rgbn, h, s, l);\n  }\n  function hwb2rgb(h, w, b) {\n    return calln(hwb2rgbn, h, w, b);\n  }\n  function hsv2rgb(h, s, v) {\n    return calln(hsv2rgbn, h, s, v);\n  }\n  function hue(h) {\n    return (h % 360 + 360) % 360;\n  }\n  function hueParse(str) {\n    var m = HUE_RE.exec(str);\n    var a = 255;\n    var v;\n    if (!m) {\n      return;\n    }\n    if (m[5] !== v) {\n      a = m[6] ? p2b(+m[5]) : n2b(+m[5]);\n    }\n    var h = hue(+m[2]);\n    var p1 = +m[3] / 100;\n    var p2 = +m[4] / 100;\n    if (m[1] === 'hwb') {\n      v = hwb2rgb(h, p1, p2);\n    } else if (m[1] === 'hsv') {\n      v = hsv2rgb(h, p1, p2);\n    } else {\n      v = hsl2rgb(h, p1, p2);\n    }\n    return {\n      r: v[0],\n      g: v[1],\n      b: v[2],\n      a: a\n    };\n  }\n  function _rotate(v, deg) {\n    var h = rgb2hsl(v);\n    h[0] = hue(h[0] + deg);\n    h = hsl2rgb(h);\n    v.r = h[0];\n    v.g = h[1];\n    v.b = h[2];\n  }\n  function _hslString(v) {\n    if (!v) {\n      return;\n    }\n    var a = rgb2hsl(v);\n    var h = a[0];\n    var s = n2p(a[1]);\n    var l = n2p(a[2]);\n    return v.a < 255 ? \"hsla(\".concat(h, \", \").concat(s, \"%, \").concat(l, \"%, \").concat(b2n(v.a), \")\") : \"hsl(\".concat(h, \", \").concat(s, \"%, \").concat(l, \"%)\");\n  }\n  var map$2 = {\n    x: 'dark',\n    Z: 'light',\n    Y: 're',\n    X: 'blu',\n    W: 'gr',\n    V: 'medium',\n    U: 'slate',\n    A: 'ee',\n    T: 'ol',\n    S: 'or',\n    B: 'ra',\n    C: 'lateg',\n    D: 'ights',\n    R: 'in',\n    Q: 'turquois',\n    E: 'hi',\n    P: 'ro',\n    O: 'al',\n    N: 'le',\n    M: 'de',\n    L: 'yello',\n    F: 'en',\n    K: 'ch',\n    G: 'arks',\n    H: 'ea',\n    I: 'ightg',\n    J: 'wh'\n  };\n  var names$1 = {\n    OiceXe: 'f0f8ff',\n    antiquewEte: 'faebd7',\n    aqua: 'ffff',\n    aquamarRe: '7fffd4',\n    azuY: 'f0ffff',\n    beige: 'f5f5dc',\n    bisque: 'ffe4c4',\n    black: '0',\n    blanKedOmond: 'ffebcd',\n    Xe: 'ff',\n    XeviTet: '8a2be2',\n    bPwn: 'a52a2a',\n    burlywood: 'deb887',\n    caMtXe: '5f9ea0',\n    KartYuse: '7fff00',\n    KocTate: 'd2691e',\n    cSO: 'ff7f50',\n    cSnflowerXe: '6495ed',\n    cSnsilk: 'fff8dc',\n    crimson: 'dc143c',\n    cyan: 'ffff',\n    xXe: '8b',\n    xcyan: '8b8b',\n    xgTMnPd: 'b8860b',\n    xWay: 'a9a9a9',\n    xgYF: '6400',\n    xgYy: 'a9a9a9',\n    xkhaki: 'bdb76b',\n    xmagFta: '8b008b',\n    xTivegYF: '556b2f',\n    xSange: 'ff8c00',\n    xScEd: '9932cc',\n    xYd: '8b0000',\n    xsOmon: 'e9967a',\n    xsHgYF: '8fbc8f',\n    xUXe: '483d8b',\n    xUWay: '2f4f4f',\n    xUgYy: '2f4f4f',\n    xQe: 'ced1',\n    xviTet: '9400d3',\n    dAppRk: 'ff1493',\n    dApskyXe: 'bfff',\n    dimWay: '696969',\n    dimgYy: '696969',\n    dodgerXe: '1e90ff',\n    fiYbrick: 'b22222',\n    flSOwEte: 'fffaf0',\n    foYstWAn: '228b22',\n    fuKsia: 'ff00ff',\n    gaRsbSo: 'dcdcdc',\n    ghostwEte: 'f8f8ff',\n    gTd: 'ffd700',\n    gTMnPd: 'daa520',\n    Way: '808080',\n    gYF: '8000',\n    gYFLw: 'adff2f',\n    gYy: '808080',\n    honeyMw: 'f0fff0',\n    hotpRk: 'ff69b4',\n    RdianYd: 'cd5c5c',\n    Rdigo: '4b0082',\n    ivSy: 'fffff0',\n    khaki: 'f0e68c',\n    lavFMr: 'e6e6fa',\n    lavFMrXsh: 'fff0f5',\n    lawngYF: '7cfc00',\n    NmoncEffon: 'fffacd',\n    ZXe: 'add8e6',\n    ZcSO: 'f08080',\n    Zcyan: 'e0ffff',\n    ZgTMnPdLw: 'fafad2',\n    ZWay: 'd3d3d3',\n    ZgYF: '90ee90',\n    ZgYy: 'd3d3d3',\n    ZpRk: 'ffb6c1',\n    ZsOmon: 'ffa07a',\n    ZsHgYF: '20b2aa',\n    ZskyXe: '87cefa',\n    ZUWay: '778899',\n    ZUgYy: '778899',\n    ZstAlXe: 'b0c4de',\n    ZLw: 'ffffe0',\n    lime: 'ff00',\n    limegYF: '32cd32',\n    lRF: 'faf0e6',\n    magFta: 'ff00ff',\n    maPon: '800000',\n    VaquamarRe: '66cdaa',\n    VXe: 'cd',\n    VScEd: 'ba55d3',\n    VpurpN: '9370db',\n    VsHgYF: '3cb371',\n    VUXe: '7b68ee',\n    VsprRggYF: 'fa9a',\n    VQe: '48d1cc',\n    VviTetYd: 'c71585',\n    midnightXe: '191970',\n    mRtcYam: 'f5fffa',\n    mistyPse: 'ffe4e1',\n    moccasR: 'ffe4b5',\n    navajowEte: 'ffdead',\n    navy: '80',\n    Tdlace: 'fdf5e6',\n    Tive: '808000',\n    TivedBb: '6b8e23',\n    Sange: 'ffa500',\n    SangeYd: 'ff4500',\n    ScEd: 'da70d6',\n    pOegTMnPd: 'eee8aa',\n    pOegYF: '98fb98',\n    pOeQe: 'afeeee',\n    pOeviTetYd: 'db7093',\n    papayawEp: 'ffefd5',\n    pHKpuff: 'ffdab9',\n    peru: 'cd853f',\n    pRk: 'ffc0cb',\n    plum: 'dda0dd',\n    powMrXe: 'b0e0e6',\n    purpN: '800080',\n    YbeccapurpN: '663399',\n    Yd: 'ff0000',\n    Psybrown: 'bc8f8f',\n    PyOXe: '4169e1',\n    saddNbPwn: '8b4513',\n    sOmon: 'fa8072',\n    sandybPwn: 'f4a460',\n    sHgYF: '2e8b57',\n    sHshell: 'fff5ee',\n    siFna: 'a0522d',\n    silver: 'c0c0c0',\n    skyXe: '87ceeb',\n    UXe: '6a5acd',\n    UWay: '708090',\n    UgYy: '708090',\n    snow: 'fffafa',\n    sprRggYF: 'ff7f',\n    stAlXe: '4682b4',\n    tan: 'd2b48c',\n    teO: '8080',\n    tEstN: 'd8bfd8',\n    tomato: 'ff6347',\n    Qe: '40e0d0',\n    viTet: 'ee82ee',\n    JHt: 'f5deb3',\n    wEte: 'ffffff',\n    wEtesmoke: 'f5f5f5',\n    Lw: 'ffff00',\n    LwgYF: '9acd32'\n  };\n  function unpack() {\n    var unpacked = {};\n    var keys = Object.keys(names$1);\n    var tkeys = Object.keys(map$2);\n    var i, j, k, ok, nk;\n    for (i = 0; i < keys.length; i++) {\n      ok = nk = keys[i];\n      for (j = 0; j < tkeys.length; j++) {\n        k = tkeys[j];\n        nk = nk.replace(k, map$2[k]);\n      }\n      k = parseInt(names$1[ok], 16);\n      unpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF];\n    }\n    return unpacked;\n  }\n  var names;\n  function nameParse(str) {\n    if (!names) {\n      names = unpack();\n      names.transparent = [0, 0, 0, 0];\n    }\n    var a = names[str.toLowerCase()];\n    return a && {\n      r: a[0],\n      g: a[1],\n      b: a[2],\n      a: a.length === 4 ? a[3] : 255\n    };\n  }\n  var RGB_RE = /^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\n  function rgbParse(str) {\n    var m = RGB_RE.exec(str);\n    var a = 255;\n    var r, g, b;\n    if (!m) {\n      return;\n    }\n    if (m[7] !== r) {\n      var v = +m[7];\n      a = m[8] ? p2b(v) : lim(v * 255, 0, 255);\n    }\n    r = +m[1];\n    g = +m[3];\n    b = +m[5];\n    r = 255 & (m[2] ? p2b(r) : lim(r, 0, 255));\n    g = 255 & (m[4] ? p2b(g) : lim(g, 0, 255));\n    b = 255 & (m[6] ? p2b(b) : lim(b, 0, 255));\n    return {\n      r: r,\n      g: g,\n      b: b,\n      a: a\n    };\n  }\n  function _rgbString(v) {\n    return v && (v.a < 255 ? \"rgba(\".concat(v.r, \", \").concat(v.g, \", \").concat(v.b, \", \").concat(b2n(v.a), \")\") : \"rgb(\".concat(v.r, \", \").concat(v.g, \", \").concat(v.b, \")\"));\n  }\n  var to = function to(v) {\n    return v <= 0.0031308 ? v * 12.92 : Math.pow(v, 1.0 / 2.4) * 1.055 - 0.055;\n  };\n  var from = function from(v) {\n    return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n  };\n  function _interpolate(rgb1, rgb2, t) {\n    var r = from(b2n(rgb1.r));\n    var g = from(b2n(rgb1.g));\n    var b = from(b2n(rgb1.b));\n    return {\n      r: n2b(to(r + t * (from(b2n(rgb2.r)) - r))),\n      g: n2b(to(g + t * (from(b2n(rgb2.g)) - g))),\n      b: n2b(to(b + t * (from(b2n(rgb2.b)) - b))),\n      a: rgb1.a + t * (rgb2.a - rgb1.a)\n    };\n  }\n  function modHSL(v, i, ratio) {\n    if (v) {\n      var tmp = rgb2hsl(v);\n      tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1));\n      tmp = hsl2rgb(tmp);\n      v.r = tmp[0];\n      v.g = tmp[1];\n      v.b = tmp[2];\n    }\n  }\n  function clone$1(v, proto) {\n    return v ? Object.assign(proto || {}, v) : v;\n  }\n  function fromObject(input) {\n    var v = {\n      r: 0,\n      g: 0,\n      b: 0,\n      a: 255\n    };\n    if (Array.isArray(input)) {\n      if (input.length >= 3) {\n        v = {\n          r: input[0],\n          g: input[1],\n          b: input[2],\n          a: 255\n        };\n        if (input.length > 3) {\n          v.a = n2b(input[3]);\n        }\n      }\n    } else {\n      v = clone$1(input, {\n        r: 0,\n        g: 0,\n        b: 0,\n        a: 1\n      });\n      v.a = n2b(v.a);\n    }\n    return v;\n  }\n  function functionParse(str) {\n    if (str.charAt(0) === 'r') {\n      return rgbParse(str);\n    }\n    return hueParse(str);\n  }\n  var Color = /*#__PURE__*/function () {\n    function Color(input) {\n      _classCallCheck$x(this, Color);\n      if (input instanceof Color) {\n        return input;\n      }\n      var type = _typeof$z(input);\n      var v;\n      if (type === 'object') {\n        v = fromObject(input);\n      } else if (type === 'string') {\n        v = hexParse(input) || nameParse(input) || functionParse(input);\n      }\n      this._rgb = v;\n      this._valid = !!v;\n    }\n    _createClass$x(Color, [{\n      key: \"valid\",\n      get: function get() {\n        return this._valid;\n      }\n    }, {\n      key: \"rgb\",\n      get: function get() {\n        var v = clone$1(this._rgb);\n        if (v) {\n          v.a = b2n(v.a);\n        }\n        return v;\n      },\n      set: function set(obj) {\n        this._rgb = fromObject(obj);\n      }\n    }, {\n      key: \"rgbString\",\n      value: function rgbString() {\n        return this._valid ? _rgbString(this._rgb) : undefined;\n      }\n    }, {\n      key: \"hexString\",\n      value: function hexString() {\n        return this._valid ? _hexString(this._rgb) : undefined;\n      }\n    }, {\n      key: \"hslString\",\n      value: function hslString() {\n        return this._valid ? _hslString(this._rgb) : undefined;\n      }\n    }, {\n      key: \"mix\",\n      value: function mix(color, weight) {\n        if (color) {\n          var c1 = this.rgb;\n          var c2 = color.rgb;\n          var w2;\n          var p = weight === w2 ? 0.5 : weight;\n          var w = 2 * p - 1;\n          var a = c1.a - c2.a;\n          var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n          w2 = 1 - w1;\n          c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5;\n          c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5;\n          c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5;\n          c1.a = p * c1.a + (1 - p) * c2.a;\n          this.rgb = c1;\n        }\n        return this;\n      }\n    }, {\n      key: \"interpolate\",\n      value: function interpolate(color, t) {\n        if (color) {\n          this._rgb = _interpolate(this._rgb, color._rgb, t);\n        }\n        return this;\n      }\n    }, {\n      key: \"clone\",\n      value: function clone() {\n        return new Color(this.rgb);\n      }\n    }, {\n      key: \"alpha\",\n      value: function alpha(a) {\n        this._rgb.a = n2b(a);\n        return this;\n      }\n    }, {\n      key: \"clearer\",\n      value: function clearer(ratio) {\n        var rgb = this._rgb;\n        rgb.a *= 1 - ratio;\n        return this;\n      }\n    }, {\n      key: \"greyscale\",\n      value: function greyscale() {\n        var rgb = this._rgb;\n        var val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11);\n        rgb.r = rgb.g = rgb.b = val;\n        return this;\n      }\n    }, {\n      key: \"opaquer\",\n      value: function opaquer(ratio) {\n        var rgb = this._rgb;\n        rgb.a *= 1 + ratio;\n        return this;\n      }\n    }, {\n      key: \"negate\",\n      value: function negate() {\n        var v = this._rgb;\n        v.r = 255 - v.r;\n        v.g = 255 - v.g;\n        v.b = 255 - v.b;\n        return this;\n      }\n    }, {\n      key: \"lighten\",\n      value: function lighten(ratio) {\n        modHSL(this._rgb, 2, ratio);\n        return this;\n      }\n    }, {\n      key: \"darken\",\n      value: function darken(ratio) {\n        modHSL(this._rgb, 2, -ratio);\n        return this;\n      }\n    }, {\n      key: \"saturate\",\n      value: function saturate(ratio) {\n        modHSL(this._rgb, 1, ratio);\n        return this;\n      }\n    }, {\n      key: \"desaturate\",\n      value: function desaturate(ratio) {\n        modHSL(this._rgb, 1, -ratio);\n        return this;\n      }\n    }, {\n      key: \"rotate\",\n      value: function rotate(deg) {\n        _rotate(this._rgb, deg);\n        return this;\n      }\n    }]);\n    return Color;\n  }();\n\n  /**\n   * @namespace Chart.helpers\n   */ /**\n      * An empty function that can be used, for example, for optional callback.\n      */\n  function noop() {\n    /* noop */}\n  /**\n   * Returns a unique id, sequentially generated from a global variable.\n   */\n  var uid = function () {\n    var id = 0;\n    return function () {\n      return id++;\n    };\n  }();\n  /**\n   * Returns true if `value` is neither null nor undefined, else returns false.\n   * @param value - The value to test.\n   * @since 2.7.0\n   */\n  function isNullOrUndef(value) {\n    return value === null || typeof value === 'undefined';\n  }\n  /**\n   * Returns true if `value` is an array (including typed arrays), else returns false.\n   * @param value - The value to test.\n   * @function\n   */\n  function isArray(value) {\n    if (Array.isArray && Array.isArray(value)) {\n      return true;\n    }\n    var type = Object.prototype.toString.call(value);\n    if (type.slice(0, 7) === '[object' && type.slice(-6) === 'Array]') {\n      return true;\n    }\n    return false;\n  }\n  /**\n   * Returns true if `value` is an object (excluding null), else returns false.\n   * @param value - The value to test.\n   * @since 2.7.0\n   */\n  function isObject(value) {\n    return value !== null && Object.prototype.toString.call(value) === '[object Object]';\n  }\n  /**\n   * Returns true if `value` is a finite number, else returns false\n   * @param value  - The value to test.\n   */\n  function isNumberFinite(value) {\n    return (typeof value === 'number' || value instanceof Number) && isFinite(+value);\n  }\n  /**\n   * Returns `value` if finite, else returns `defaultValue`.\n   * @param value - The value to return if defined.\n   * @param defaultValue - The value to return if `value` is not finite.\n   */\n  function finiteOrDefault(value, defaultValue) {\n    return isNumberFinite(value) ? value : defaultValue;\n  }\n  /**\n   * Returns `value` if defined, else returns `defaultValue`.\n   * @param value - The value to return if defined.\n   * @param defaultValue - The value to return if `value` is undefined.\n   */\n  function valueOrDefault(value, defaultValue) {\n    return typeof value === 'undefined' ? defaultValue : value;\n  }\n  var toPercentage = function toPercentage(value, dimension) {\n    return typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 : +value / dimension;\n  };\n  var toDimension = function toDimension(value, dimension) {\n    return typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 * dimension : +value;\n  };\n  /**\n   * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the\n   * value returned by `fn`. If `fn` is not a function, this method returns undefined.\n   * @param fn - The function to call.\n   * @param args - The arguments with which `fn` should be called.\n   * @param [thisArg] - The value of `this` provided for the call to `fn`.\n   */\n  function callback(fn, args, thisArg) {\n    if (fn && typeof fn.call === 'function') {\n      return fn.apply(thisArg, args);\n    }\n  }\n  function each(loopable, fn, thisArg, reverse) {\n    var i, len, keys;\n    if (isArray(loopable)) {\n      len = loopable.length;\n      if (reverse) {\n        for (i = len - 1; i >= 0; i--) {\n          fn.call(thisArg, loopable[i], i);\n        }\n      } else {\n        for (i = 0; i < len; i++) {\n          fn.call(thisArg, loopable[i], i);\n        }\n      }\n    } else if (isObject(loopable)) {\n      keys = Object.keys(loopable);\n      len = keys.length;\n      for (i = 0; i < len; i++) {\n        fn.call(thisArg, loopable[keys[i]], keys[i]);\n      }\n    }\n  }\n  /**\n   * Returns true if the `a0` and `a1` arrays have the same content, else returns false.\n   * @param a0 - The array to compare\n   * @param a1 - The array to compare\n   * @private\n   */\n  function _elementsEqual(a0, a1) {\n    var i, ilen, v0, v1;\n    if (!a0 || !a1 || a0.length !== a1.length) {\n      return false;\n    }\n    for (i = 0, ilen = a0.length; i < ilen; ++i) {\n      v0 = a0[i];\n      v1 = a1[i];\n      if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) {\n        return false;\n      }\n    }\n    return true;\n  }\n  /**\n   * Returns a deep copy of `source` without keeping references on objects and arrays.\n   * @param source - The value to clone.\n   */\n  function clone(source) {\n    if (isArray(source)) {\n      return source.map(clone);\n    }\n    if (isObject(source)) {\n      var target = Object.create(null);\n      var keys = Object.keys(source);\n      var klen = keys.length;\n      var k = 0;\n      for (; k < klen; ++k) {\n        target[keys[k]] = clone(source[keys[k]]);\n      }\n      return target;\n    }\n    return source;\n  }\n  function isValidKey(key) {\n    return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;\n  }\n  /**\n   * The default merger when Chart.helpers.merge is called without merger option.\n   * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.\n   * @private\n   */\n  function _merger(key, target, source, options) {\n    if (!isValidKey(key)) {\n      return;\n    }\n    var tval = target[key];\n    var sval = source[key];\n    if (isObject(tval) && isObject(sval)) {\n      // eslint-disable-next-line @typescript-eslint/no-use-before-define\n      merge(tval, sval, options);\n    } else {\n      target[key] = clone(sval);\n    }\n  }\n  function merge(target, source, options) {\n    var sources = isArray(source) ? source : [source];\n    var ilen = sources.length;\n    if (!isObject(target)) {\n      return target;\n    }\n    options = options || {};\n    var merger = options.merger || _merger;\n    var current;\n    for (var i = 0; i < ilen; ++i) {\n      current = sources[i];\n      if (!isObject(current)) {\n        continue;\n      }\n      var keys = Object.keys(current);\n      for (var k = 0, klen = keys.length; k < klen; ++k) {\n        merger(keys[k], target, current, options);\n      }\n    }\n    return target;\n  }\n  function mergeIf(target, source) {\n    // eslint-disable-next-line @typescript-eslint/no-use-before-define\n    return merge(target, source, {\n      merger: _mergerIf\n    });\n  }\n  /**\n   * Merges source[key] in target[key] only if target[key] is undefined.\n   * @private\n   */\n  function _mergerIf(key, target, source) {\n    if (!isValidKey(key)) {\n      return;\n    }\n    var tval = target[key];\n    var sval = source[key];\n    if (isObject(tval) && isObject(sval)) {\n      mergeIf(tval, sval);\n    } else if (!Object.prototype.hasOwnProperty.call(target, key)) {\n      target[key] = clone(sval);\n    }\n  }\n  /**\n   * @private\n   */\n  function _deprecated(scope, value, previous, current) {\n    if (value !== undefined) {\n      console.warn(scope + ': \"' + previous + '\" is deprecated. Please use \"' + current + '\" instead');\n    }\n  }\n  // resolveObjectKey resolver cache\n  var keyResolvers = {\n    // Chart.helpers.core resolveObjectKey should resolve empty key to root object\n    '': function _(v) {\n      return v;\n    },\n    // default resolvers\n    x: function x(o) {\n      return o.x;\n    },\n    y: function y(o) {\n      return o.y;\n    }\n  };\n  /**\n   * @private\n   */\n  function _splitKey(key) {\n    var parts = key.split('.');\n    var keys = [];\n    var tmp = '';\n    var _iterator = _createForOfIteratorHelper$1(parts),\n      _step;\n    try {\n      for (_iterator.s(); !(_step = _iterator.n()).done;) {\n        var part = _step.value;\n        tmp += part;\n        if (tmp.endsWith('\\\\')) {\n          tmp = tmp.slice(0, -1) + '.';\n        } else {\n          keys.push(tmp);\n          tmp = '';\n        }\n      }\n    } catch (err) {\n      _iterator.e(err);\n    } finally {\n      _iterator.f();\n    }\n    return keys;\n  }\n  function _getKeyResolver(key) {\n    var keys = _splitKey(key);\n    return function (obj) {\n      var _iterator2 = _createForOfIteratorHelper$1(keys),\n        _step2;\n      try {\n        for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n          var k = _step2.value;\n          if (k === '') {\n            break;\n          }\n          obj = obj && obj[k];\n        }\n      } catch (err) {\n        _iterator2.e(err);\n      } finally {\n        _iterator2.f();\n      }\n      return obj;\n    };\n  }\n  function resolveObjectKey(obj, key) {\n    var resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));\n    return resolver(obj);\n  }\n  /**\n   * @private\n   */\n  function _capitalize(str) {\n    return str.charAt(0).toUpperCase() + str.slice(1);\n  }\n  var defined = function defined(value) {\n    return typeof value !== 'undefined';\n  };\n  var isFunction = function isFunction(value) {\n    return typeof value === 'function';\n  };\n  // Adapted from https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality#31129384\n  var setsEqual = function setsEqual(a, b) {\n    if (a.size !== b.size) {\n      return false;\n    }\n    var _iterator3 = _createForOfIteratorHelper$1(a),\n      _step3;\n    try {\n      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n        var item = _step3.value;\n        if (!b.has(item)) {\n          return false;\n        }\n      }\n    } catch (err) {\n      _iterator3.e(err);\n    } finally {\n      _iterator3.f();\n    }\n    return true;\n  };\n  /**\n   * @param e - The event\n   * @private\n   */\n  function _isClickEvent(e) {\n    return e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu';\n  }\n\n  /**\n   * @alias Chart.helpers.math\n   * @namespace\n   */\n  var PI = Math.PI;\n  var TAU = 2 * PI;\n  var PITAU = TAU + PI;\n  var INFINITY = Number.POSITIVE_INFINITY;\n  var RAD_PER_DEG = PI / 180;\n  var HALF_PI = PI / 2;\n  var QUARTER_PI = PI / 4;\n  var TWO_THIRDS_PI = PI * 2 / 3;\n  var log10 = Math.log10;\n  var sign = Math.sign;\n  function almostEquals(x, y, epsilon) {\n    return Math.abs(x - y) < epsilon;\n  }\n  /**\n   * Implementation of the nice number algorithm used in determining where axis labels will go\n   */\n  function niceNum(range) {\n    var roundedRange = Math.round(range);\n    range = almostEquals(range, roundedRange, range / 1000) ? roundedRange : range;\n    var niceRange = Math.pow(10, Math.floor(log10(range)));\n    var fraction = range / niceRange;\n    var niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 5 ? 5 : 10;\n    return niceFraction * niceRange;\n  }\n  /**\n   * Returns an array of factors sorted from 1 to sqrt(value)\n   * @private\n   */\n  function _factorize(value) {\n    var result = [];\n    var sqrt = Math.sqrt(value);\n    var i;\n    for (i = 1; i < sqrt; i++) {\n      if (value % i === 0) {\n        result.push(i);\n        result.push(value / i);\n      }\n    }\n    if (sqrt === (sqrt | 0)) {\n      result.push(sqrt);\n    }\n    result.sort(function (a, b) {\n      return a - b;\n    }).pop();\n    return result;\n  }\n  function isNumber(n) {\n    return !isNaN(parseFloat(n)) && isFinite(n);\n  }\n  function almostWhole(x, epsilon) {\n    var rounded = Math.round(x);\n    return rounded - epsilon <= x && rounded + epsilon >= x;\n  }\n  /**\n   * @private\n   */\n  function _setMinAndMaxByKey(array, target, property) {\n    var i, ilen, value;\n    for (i = 0, ilen = array.length; i < ilen; i++) {\n      value = array[i][property];\n      if (!isNaN(value)) {\n        target.min = Math.min(target.min, value);\n        target.max = Math.max(target.max, value);\n      }\n    }\n  }\n  function toRadians(degrees) {\n    return degrees * (PI / 180);\n  }\n  function toDegrees(radians) {\n    return radians * (180 / PI);\n  }\n  /**\n   * Returns the number of decimal places\n   * i.e. the number of digits after the decimal point, of the value of this Number.\n   * @param x - A number.\n   * @returns The number of decimal places.\n   * @private\n   */\n  function _decimalPlaces(x) {\n    if (!isNumberFinite(x)) {\n      return;\n    }\n    var e = 1;\n    var p = 0;\n    while (Math.round(x * e) / e !== x) {\n      e *= 10;\n      p++;\n    }\n    return p;\n  }\n  // Gets the angle from vertical upright to the point about a centre.\n  function getAngleFromPoint(centrePoint, anglePoint) {\n    var distanceFromXCenter = anglePoint.x - centrePoint.x;\n    var distanceFromYCenter = anglePoint.y - centrePoint.y;\n    var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);\n    var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);\n    if (angle < -0.5 * PI) {\n      angle += TAU; // make sure the returned angle is in the range of (-PI/2, 3PI/2]\n    }\n\n    return {\n      angle: angle,\n      distance: radialDistanceFromCenter\n    };\n  }\n  function distanceBetweenPoints(pt1, pt2) {\n    return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));\n  }\n  /**\n   * Shortest distance between angles, in either direction.\n   * @private\n   */\n  function _angleDiff(a, b) {\n    return (a - b + PITAU) % TAU - PI;\n  }\n  /**\n   * Normalize angle to be between 0 and 2*PI\n   * @private\n   */\n  function _normalizeAngle(a) {\n    return (a % TAU + TAU) % TAU;\n  }\n  /**\n   * @private\n   */\n  function _angleBetween(angle, start, end, sameAngleIsFullCircle) {\n    var a = _normalizeAngle(angle);\n    var s = _normalizeAngle(start);\n    var e = _normalizeAngle(end);\n    var angleToStart = _normalizeAngle(s - a);\n    var angleToEnd = _normalizeAngle(e - a);\n    var startToAngle = _normalizeAngle(a - s);\n    var endToAngle = _normalizeAngle(a - e);\n    return a === s || a === e || sameAngleIsFullCircle && s === e || angleToStart > angleToEnd && startToAngle < endToAngle;\n  }\n  /**\n   * Limit `value` between `min` and `max`\n   * @param value\n   * @param min\n   * @param max\n   * @private\n   */\n  function _limitValue(value, min, max) {\n    return Math.max(min, Math.min(max, value));\n  }\n  /**\n   * @param {number} value\n   * @private\n   */\n  function _int16Range(value) {\n    return _limitValue(value, -32768, 32767);\n  }\n  /**\n   * @param value\n   * @param start\n   * @param end\n   * @param [epsilon]\n   * @private\n   */\n  function _isBetween(value, start, end) {\n    var epsilon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1e-6;\n    return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon;\n  }\n  function _lookup(table, value, cmp) {\n    cmp = cmp || function (index) {\n      return table[index] < value;\n    };\n    var hi = table.length - 1;\n    var lo = 0;\n    var mid;\n    while (hi - lo > 1) {\n      mid = lo + hi >> 1;\n      if (cmp(mid)) {\n        lo = mid;\n      } else {\n        hi = mid;\n      }\n    }\n    return {\n      lo: lo,\n      hi: hi\n    };\n  }\n  /**\n   * Binary search\n   * @param table - the table search. must be sorted!\n   * @param key - property name for the value in each entry\n   * @param value - value to find\n   * @param last - lookup last index\n   * @private\n   */\n  var _lookupByKey = function _lookupByKey(table, key, value, last) {\n    return _lookup(table, value, last ? function (index) {\n      var ti = table[index][key];\n      return ti < value || ti === value && table[index + 1][key] === value;\n    } : function (index) {\n      return table[index][key] < value;\n    });\n  };\n  /**\n   * Reverse binary search\n   * @param table - the table search. must be sorted!\n   * @param key - property name for the value in each entry\n   * @param value - value to find\n   * @private\n   */\n  var _rlookupByKey = function _rlookupByKey(table, key, value) {\n    return _lookup(table, value, function (index) {\n      return table[index][key] >= value;\n    });\n  };\n  /**\n   * Return subset of `values` between `min` and `max` inclusive.\n   * Values are assumed to be in sorted order.\n   * @param values - sorted array of values\n   * @param min - min value\n   * @param max - max value\n   */\n  function _filterBetween(values, min, max) {\n    var start = 0;\n    var end = values.length;\n    while (start < end && values[start] < min) {\n      start++;\n    }\n    while (end > start && values[end - 1] > max) {\n      end--;\n    }\n    return start > 0 || end < values.length ? values.slice(start, end) : values;\n  }\n  var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];\n  function listenArrayEvents(array, listener) {\n    if (array._chartjs) {\n      array._chartjs.listeners.push(listener);\n      return;\n    }\n    Object.defineProperty(array, '_chartjs', {\n      configurable: true,\n      enumerable: false,\n      value: {\n        listeners: [listener]\n      }\n    });\n    arrayEvents.forEach(function (key) {\n      var method = '_onData' + _capitalize(key);\n      var base = array[key];\n      Object.defineProperty(array, key, {\n        configurable: true,\n        enumerable: false,\n        value: function value() {\n          for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n            args[_key] = arguments[_key];\n          }\n          var res = base.apply(this, args);\n          array._chartjs.listeners.forEach(function (object) {\n            if (typeof object[method] === 'function') {\n              object[method].apply(object, args);\n            }\n          });\n          return res;\n        }\n      });\n    });\n  }\n  function unlistenArrayEvents(array, listener) {\n    var stub = array._chartjs;\n    if (!stub) {\n      return;\n    }\n    var listeners = stub.listeners;\n    var index = listeners.indexOf(listener);\n    if (index !== -1) {\n      listeners.splice(index, 1);\n    }\n    if (listeners.length > 0) {\n      return;\n    }\n    arrayEvents.forEach(function (key) {\n      delete array[key];\n    });\n    delete array._chartjs;\n  }\n  /**\n   * @param items\n   */\n  function _arrayUnique(items) {\n    var set = new Set();\n    var i, ilen;\n    for (i = 0, ilen = items.length; i < ilen; ++i) {\n      set.add(items[i]);\n    }\n    if (set.size === ilen) {\n      return items;\n    }\n    return Array.from(set);\n  }\n  function fontString(pixelSize, fontStyle, fontFamily) {\n    return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;\n  }\n  /**\n  * Request animation polyfill\n  */\n  var requestAnimFrame = function () {\n    if (typeof window === 'undefined') {\n      return function (callback) {\n        return callback();\n      };\n    }\n    return window.requestAnimationFrame;\n  }();\n  /**\n   * Throttles calling `fn` once per animation frame\n   * Latest arguments are used on the actual call\n   */\n  function throttled(fn, thisArg) {\n    var argsToUse = [];\n    var ticking = false;\n    return function () {\n      for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n        args[_key2] = arguments[_key2];\n      }\n      // Save the args for use later\n      argsToUse = args;\n      if (!ticking) {\n        ticking = true;\n        requestAnimFrame.call(window, function () {\n          ticking = false;\n          fn.apply(thisArg, argsToUse);\n        });\n      }\n    };\n  }\n  /**\n   * Debounces calling `fn` for `delay` ms\n   */\n  function debounce(fn, delay) {\n    var timeout;\n    return function () {\n      for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n        args[_key3] = arguments[_key3];\n      }\n      if (delay) {\n        clearTimeout(timeout);\n        timeout = setTimeout(fn, delay, args);\n      } else {\n        fn.apply(this, args);\n      }\n      return delay;\n    };\n  }\n  /**\n   * Converts 'start' to 'left', 'end' to 'right' and others to 'center'\n   * @private\n   */\n  var _toLeftRightCenter = function _toLeftRightCenter(align) {\n    return align === 'start' ? 'left' : align === 'end' ? 'right' : 'center';\n  };\n  /**\n   * Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`\n   * @private\n   */\n  var _alignStartEnd = function _alignStartEnd(align, start, end) {\n    return align === 'start' ? start : align === 'end' ? end : (start + end) / 2;\n  };\n  /**\n   * Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`\n   * @private\n   */\n  var _textX = function _textX(align, left, right, rtl) {\n    var check = rtl ? 'left' : 'right';\n    return align === check ? right : align === 'center' ? (left + right) / 2 : left;\n  };\n  /**\n   * Return start and count of visible points.\n   * @private\n   */\n  function _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {\n    var pointCount = points.length;\n    var start = 0;\n    var count = pointCount;\n    if (meta._sorted) {\n      var iScale = meta.iScale,\n        _parsed = meta._parsed;\n      var axis = iScale.axis;\n      var _iScale$getUserBounds = iScale.getUserBounds(),\n        min = _iScale$getUserBounds.min,\n        max = _iScale$getUserBounds.max,\n        minDefined = _iScale$getUserBounds.minDefined,\n        maxDefined = _iScale$getUserBounds.maxDefined;\n      if (minDefined) {\n        start = _limitValue(Math.min(\n        // @ts-expect-error Need to type _parsed\n        _lookupByKey(_parsed, iScale.axis, min).lo,\n        // @ts-expect-error Need to fix types on _lookupByKey\n        animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo), 0, pointCount - 1);\n      }\n      if (maxDefined) {\n        count = _limitValue(Math.max(\n        // @ts-expect-error Need to type _parsed\n        _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,\n        // @ts-expect-error Need to fix types on _lookupByKey\n        animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1), start, pointCount) - start;\n      } else {\n        count = pointCount - start;\n      }\n    }\n    return {\n      start: start,\n      count: count\n    };\n  }\n  /**\n   * Checks if the scale ranges have changed.\n   * @param {object} meta - dataset meta.\n   * @returns {boolean}\n   * @private\n   */\n  function _scaleRangesChanged(meta) {\n    var xScale = meta.xScale,\n      yScale = meta.yScale,\n      _scaleRanges = meta._scaleRanges;\n    var newRanges = {\n      xmin: xScale.min,\n      xmax: xScale.max,\n      ymin: yScale.min,\n      ymax: yScale.max\n    };\n    if (!_scaleRanges) {\n      meta._scaleRanges = newRanges;\n      return true;\n    }\n    var changed = _scaleRanges.xmin !== xScale.min || _scaleRanges.xmax !== xScale.max || _scaleRanges.ymin !== yScale.min || _scaleRanges.ymax !== yScale.max;\n    Object.assign(_scaleRanges, newRanges);\n    return changed;\n  }\n  var atEdge = function atEdge(t) {\n    return t === 0 || t === 1;\n  };\n  var elasticIn = function elasticIn(t, s, p) {\n    return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));\n  };\n  var elasticOut = function elasticOut(t, s, p) {\n    return Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;\n  };\n  /**\n   * Easing functions adapted from Robert Penner's easing equations.\n   * @namespace Chart.helpers.easing.effects\n   * @see http://www.robertpenner.com/easing/\n   */\n  var effects = {\n    linear: function linear(t) {\n      return t;\n    },\n    easeInQuad: function easeInQuad(t) {\n      return t * t;\n    },\n    easeOutQuad: function easeOutQuad(t) {\n      return -t * (t - 2);\n    },\n    easeInOutQuad: function easeInOutQuad(t) {\n      return (t /= 0.5) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1);\n    },\n    easeInCubic: function easeInCubic(t) {\n      return t * t * t;\n    },\n    easeOutCubic: function easeOutCubic(t) {\n      return (t -= 1) * t * t + 1;\n    },\n    easeInOutCubic: function easeInOutCubic(t) {\n      return (t /= 0.5) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2);\n    },\n    easeInQuart: function easeInQuart(t) {\n      return t * t * t * t;\n    },\n    easeOutQuart: function easeOutQuart(t) {\n      return -((t -= 1) * t * t * t - 1);\n    },\n    easeInOutQuart: function easeInOutQuart(t) {\n      return (t /= 0.5) < 1 ? 0.5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2);\n    },\n    easeInQuint: function easeInQuint(t) {\n      return t * t * t * t * t;\n    },\n    easeOutQuint: function easeOutQuint(t) {\n      return (t -= 1) * t * t * t * t + 1;\n    },\n    easeInOutQuint: function easeInOutQuint(t) {\n      return (t /= 0.5) < 1 ? 0.5 * t * t * t * t * t : 0.5 * ((t -= 2) * t * t * t * t + 2);\n    },\n    easeInSine: function easeInSine(t) {\n      return -Math.cos(t * HALF_PI) + 1;\n    },\n    easeOutSine: function easeOutSine(t) {\n      return Math.sin(t * HALF_PI);\n    },\n    easeInOutSine: function easeInOutSine(t) {\n      return -0.5 * (Math.cos(PI * t) - 1);\n    },\n    easeInExpo: function easeInExpo(t) {\n      return t === 0 ? 0 : Math.pow(2, 10 * (t - 1));\n    },\n    easeOutExpo: function easeOutExpo(t) {\n      return t === 1 ? 1 : -Math.pow(2, -10 * t) + 1;\n    },\n    easeInOutExpo: function easeInOutExpo(t) {\n      return atEdge(t) ? t : t < 0.5 ? 0.5 * Math.pow(2, 10 * (t * 2 - 1)) : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2);\n    },\n    easeInCirc: function easeInCirc(t) {\n      return t >= 1 ? t : -(Math.sqrt(1 - t * t) - 1);\n    },\n    easeOutCirc: function easeOutCirc(t) {\n      return Math.sqrt(1 - (t -= 1) * t);\n    },\n    easeInOutCirc: function easeInOutCirc(t) {\n      return (t /= 0.5) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);\n    },\n    easeInElastic: function easeInElastic(t) {\n      return atEdge(t) ? t : elasticIn(t, 0.075, 0.3);\n    },\n    easeOutElastic: function easeOutElastic(t) {\n      return atEdge(t) ? t : elasticOut(t, 0.075, 0.3);\n    },\n    easeInOutElastic: function easeInOutElastic(t) {\n      var s = 0.1125;\n      var p = 0.45;\n      return atEdge(t) ? t : t < 0.5 ? 0.5 * elasticIn(t * 2, s, p) : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);\n    },\n    easeInBack: function easeInBack(t) {\n      var s = 1.70158;\n      return t * t * ((s + 1) * t - s);\n    },\n    easeOutBack: function easeOutBack(t) {\n      var s = 1.70158;\n      return (t -= 1) * t * ((s + 1) * t + s) + 1;\n    },\n    easeInOutBack: function easeInOutBack(t) {\n      var s = 1.70158;\n      if ((t /= 0.5) < 1) {\n        return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s));\n      }\n      return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);\n    },\n    easeInBounce: function easeInBounce(t) {\n      return 1 - effects.easeOutBounce(1 - t);\n    },\n    easeOutBounce: function easeOutBounce(t) {\n      var m = 7.5625;\n      var d = 2.75;\n      if (t < 1 / d) {\n        return m * t * t;\n      }\n      if (t < 2 / d) {\n        return m * (t -= 1.5 / d) * t + 0.75;\n      }\n      if (t < 2.5 / d) {\n        return m * (t -= 2.25 / d) * t + 0.9375;\n      }\n      return m * (t -= 2.625 / d) * t + 0.984375;\n    },\n    easeInOutBounce: function easeInOutBounce(t) {\n      return t < 0.5 ? effects.easeInBounce(t * 2) * 0.5 : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;\n    }\n  };\n  function isPatternOrGradient(value) {\n    if (value && _typeof$z(value) === 'object') {\n      var type = value.toString();\n      return type === '[object CanvasPattern]' || type === '[object CanvasGradient]';\n    }\n    return false;\n  }\n  function color(value) {\n    return isPatternOrGradient(value) ? value : new Color(value);\n  }\n  function getHoverColor(value) {\n    return isPatternOrGradient(value) ? value : new Color(value).saturate(0.5).darken(0.1).hexString();\n  }\n  var numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];\n  var colors = ['color', 'borderColor', 'backgroundColor'];\n  function applyAnimationsDefaults(defaults) {\n    defaults.set('animation', {\n      delay: undefined,\n      duration: 1000,\n      easing: 'easeOutQuart',\n      fn: undefined,\n      from: undefined,\n      loop: undefined,\n      to: undefined,\n      type: undefined\n    });\n    defaults.describe('animation', {\n      _fallback: false,\n      _indexable: false,\n      _scriptable: function _scriptable(name) {\n        return name !== 'onProgress' && name !== 'onComplete' && name !== 'fn';\n      }\n    });\n    defaults.set('animations', {\n      colors: {\n        type: 'color',\n        properties: colors\n      },\n      numbers: {\n        type: 'number',\n        properties: numbers\n      }\n    });\n    defaults.describe('animations', {\n      _fallback: 'animation'\n    });\n    defaults.set('transitions', {\n      active: {\n        animation: {\n          duration: 400\n        }\n      },\n      resize: {\n        animation: {\n          duration: 0\n        }\n      },\n      show: {\n        animations: {\n          colors: {\n            from: 'transparent'\n          },\n          visible: {\n            type: 'boolean',\n            duration: 0\n          }\n        }\n      },\n      hide: {\n        animations: {\n          colors: {\n            to: 'transparent'\n          },\n          visible: {\n            type: 'boolean',\n            easing: 'linear',\n            fn: function fn(v) {\n              return v | 0;\n            }\n          }\n        }\n      }\n    });\n  }\n  function applyLayoutsDefaults(defaults) {\n    defaults.set('layout', {\n      autoPadding: true,\n      padding: {\n        top: 0,\n        right: 0,\n        bottom: 0,\n        left: 0\n      }\n    });\n  }\n  var intlCache = new Map();\n  function getNumberFormat(locale, options) {\n    options = options || {};\n    var cacheKey = locale + JSON.stringify(options);\n    var formatter = intlCache.get(cacheKey);\n    if (!formatter) {\n      formatter = new Intl.NumberFormat(locale, options);\n      intlCache.set(cacheKey, formatter);\n    }\n    return formatter;\n  }\n  function formatNumber(num, locale, options) {\n    return getNumberFormat(locale, options).format(num);\n  }\n  var formatters$4 = {\n    values: function values(value) {\n      return isArray(value) ? value : '' + value;\n    },\n    numeric: function numeric(tickValue, index, ticks) {\n      if (tickValue === 0) {\n        return '0';\n      }\n      var locale = this.chart.options.locale;\n      var notation;\n      var delta = tickValue;\n      if (ticks.length > 1) {\n        var maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value));\n        if (maxTick < 1e-4 || maxTick > 1e+15) {\n          notation = 'scientific';\n        }\n        delta = calculateDelta(tickValue, ticks);\n      }\n      var logDelta = log10(Math.abs(delta));\n      var numDecimal = Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);\n      var options = {\n        notation: notation,\n        minimumFractionDigits: numDecimal,\n        maximumFractionDigits: numDecimal\n      };\n      Object.assign(options, this.options.ticks.format);\n      return formatNumber(tickValue, locale, options);\n    },\n    logarithmic: function logarithmic(tickValue, index, ticks) {\n      if (tickValue === 0) {\n        return '0';\n      }\n      var remain = ticks[index].significand || tickValue / Math.pow(10, Math.floor(log10(tickValue)));\n      if ([1, 2, 3, 5, 10, 15].includes(remain) || index > 0.8 * ticks.length) {\n        return formatters$4.numeric.call(this, tickValue, index, ticks);\n      }\n      return '';\n    }\n  };\n  function calculateDelta(tickValue, ticks) {\n    var delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;\n    if (Math.abs(delta) >= 1 && tickValue !== Math.floor(tickValue)) {\n      delta = tickValue - Math.floor(tickValue);\n    }\n    return delta;\n  }\n  var Ticks = {\n    formatters: formatters$4\n  };\n  function applyScaleDefaults(defaults) {\n    defaults.set('scale', {\n      display: true,\n      offset: false,\n      reverse: false,\n      beginAtZero: false,\n      bounds: 'ticks',\n      grace: 0,\n      grid: {\n        display: true,\n        lineWidth: 1,\n        drawOnChartArea: true,\n        drawTicks: true,\n        tickLength: 8,\n        tickWidth: function tickWidth(_ctx, options) {\n          return options.lineWidth;\n        },\n        tickColor: function tickColor(_ctx, options) {\n          return options.color;\n        },\n        offset: false\n      },\n      border: {\n        display: true,\n        dash: [],\n        dashOffset: 0.0,\n        width: 1\n      },\n      title: {\n        display: false,\n        text: '',\n        padding: {\n          top: 4,\n          bottom: 4\n        }\n      },\n      ticks: {\n        minRotation: 0,\n        maxRotation: 50,\n        mirror: false,\n        textStrokeWidth: 0,\n        textStrokeColor: '',\n        padding: 3,\n        display: true,\n        autoSkip: true,\n        autoSkipPadding: 3,\n        labelOffset: 0,\n        callback: Ticks.formatters.values,\n        minor: {},\n        major: {},\n        align: 'center',\n        crossAlign: 'near',\n        showLabelBackdrop: false,\n        backdropColor: 'rgba(255, 255, 255, 0.75)',\n        backdropPadding: 2\n      }\n    });\n    defaults.route('scale.ticks', 'color', '', 'color');\n    defaults.route('scale.grid', 'color', '', 'borderColor');\n    defaults.route('scale.border', 'color', '', 'borderColor');\n    defaults.route('scale.title', 'color', '', 'color');\n    defaults.describe('scale', {\n      _fallback: false,\n      _scriptable: function _scriptable(name) {\n        return !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser';\n      },\n      _indexable: function _indexable(name) {\n        return name !== 'borderDash' && name !== 'tickBorderDash' && name !== 'dash';\n      }\n    });\n    defaults.describe('scales', {\n      _fallback: 'scale'\n    });\n    defaults.describe('scale.ticks', {\n      _scriptable: function _scriptable(name) {\n        return name !== 'backdropPadding' && name !== 'callback';\n      },\n      _indexable: function _indexable(name) {\n        return name !== 'backdropPadding';\n      }\n    });\n  }\n  var overrides = Object.create(null);\n  var descriptors = Object.create(null);\n  function getScope$1(node, key) {\n    if (!key) {\n      return node;\n    }\n    var keys = key.split('.');\n    for (var i = 0, n = keys.length; i < n; ++i) {\n      var k = keys[i];\n      node = node[k] || (node[k] = Object.create(null));\n    }\n    return node;\n  }\n  function _set(root, scope, values) {\n    if (typeof scope === 'string') {\n      return merge(getScope$1(root, scope), values);\n    }\n    return merge(getScope$1(root, ''), scope);\n  }\n  var Defaults = /*#__PURE__*/function () {\n    function Defaults(_descriptors, _appliers) {\n      _classCallCheck$x(this, Defaults);\n      this.animation = undefined;\n      this.backgroundColor = 'rgba(0,0,0,0.1)';\n      this.borderColor = 'rgba(0,0,0,0.1)';\n      this.color = '#666';\n      this.datasets = {};\n      this.devicePixelRatio = function (context) {\n        return context.chart.platform.getDevicePixelRatio();\n      };\n      this.elements = {};\n      this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'];\n      this.font = {\n        family: \"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif\",\n        size: 12,\n        style: 'normal',\n        lineHeight: 1.2,\n        weight: null\n      };\n      this.hover = {};\n      this.hoverBackgroundColor = function (ctx, options) {\n        return getHoverColor(options.backgroundColor);\n      };\n      this.hoverBorderColor = function (ctx, options) {\n        return getHoverColor(options.borderColor);\n      };\n      this.hoverColor = function (ctx, options) {\n        return getHoverColor(options.color);\n      };\n      this.indexAxis = 'x';\n      this.interaction = {\n        mode: 'nearest',\n        intersect: true,\n        includeInvisible: false\n      };\n      this.maintainAspectRatio = true;\n      this.onHover = null;\n      this.onClick = null;\n      this.parsing = true;\n      this.plugins = {};\n      this.responsive = true;\n      this.scale = undefined;\n      this.scales = {};\n      this.showLine = true;\n      this.drawActiveElementsOnTop = true;\n      this.describe(_descriptors);\n      this.apply(_appliers);\n    }\n    _createClass$x(Defaults, [{\n      key: \"set\",\n      value: function set(scope, values) {\n        return _set(this, scope, values);\n      }\n    }, {\n      key: \"get\",\n      value: function get(scope) {\n        return getScope$1(this, scope);\n      }\n    }, {\n      key: \"describe\",\n      value: function describe(scope, values) {\n        return _set(descriptors, scope, values);\n      }\n    }, {\n      key: \"override\",\n      value: function override(scope, values) {\n        return _set(overrides, scope, values);\n      }\n    }, {\n      key: \"route\",\n      value: function route(scope, name, targetScope, targetName) {\n        var _Object$definePropert;\n        var scopeObject = getScope$1(this, scope);\n        var targetScopeObject = getScope$1(this, targetScope);\n        var privateName = '_' + name;\n        Object.defineProperties(scopeObject, (_Object$definePropert = {}, _defineProperty$w(_Object$definePropert, privateName, {\n          value: scopeObject[name],\n          writable: true\n        }), _defineProperty$w(_Object$definePropert, name, {\n          enumerable: true,\n          get: function get() {\n            var local = this[privateName];\n            var target = targetScopeObject[targetName];\n            if (isObject(local)) {\n              return Object.assign({}, target, local);\n            }\n            return valueOrDefault(local, target);\n          },\n          set: function set(value) {\n            this[privateName] = value;\n          }\n        }), _Object$definePropert));\n      }\n    }, {\n      key: \"apply\",\n      value: function apply(appliers) {\n        var _this = this;\n        appliers.forEach(function (apply) {\n          return apply(_this);\n        });\n      }\n    }]);\n    return Defaults;\n  }();\n  var defaults = /* #__PURE__ */new Defaults({\n    _scriptable: function _scriptable(name) {\n      return !name.startsWith('on');\n    },\n    _indexable: function _indexable(name) {\n      return name !== 'events';\n    },\n    hover: {\n      _fallback: 'interaction'\n    },\n    interaction: {\n      _scriptable: false,\n      _indexable: false\n    }\n  }, [applyAnimationsDefaults, applyLayoutsDefaults, applyScaleDefaults]);\n  function toFontString(font) {\n    if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {\n      return null;\n    }\n    return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;\n  }\n  function _measureText(ctx, data, gc, longest, string) {\n    var textWidth = data[string];\n    if (!textWidth) {\n      textWidth = data[string] = ctx.measureText(string).width;\n      gc.push(string);\n    }\n    if (textWidth > longest) {\n      longest = textWidth;\n    }\n    return longest;\n  }\n  function _longestText(ctx, font, arrayOfThings, cache) {\n    cache = cache || {};\n    var data = cache.data = cache.data || {};\n    var gc = cache.garbageCollect = cache.garbageCollect || [];\n    if (cache.font !== font) {\n      data = cache.data = {};\n      gc = cache.garbageCollect = [];\n      cache.font = font;\n    }\n    ctx.save();\n    ctx.font = font;\n    var longest = 0;\n    var ilen = arrayOfThings.length;\n    var i, j, jlen, thing, nestedThing;\n    for (i = 0; i < ilen; i++) {\n      thing = arrayOfThings[i];\n      if (thing !== undefined && thing !== null && isArray(thing) !== true) {\n        longest = _measureText(ctx, data, gc, longest, thing);\n      } else if (isArray(thing)) {\n        for (j = 0, jlen = thing.length; j < jlen; j++) {\n          nestedThing = thing[j];\n          if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {\n            longest = _measureText(ctx, data, gc, longest, nestedThing);\n          }\n        }\n      }\n    }\n    ctx.restore();\n    var gcLen = gc.length / 2;\n    if (gcLen > arrayOfThings.length) {\n      for (i = 0; i < gcLen; i++) {\n        delete data[gc[i]];\n      }\n      gc.splice(0, gcLen);\n    }\n    return longest;\n  }\n  function _alignPixel(chart, pixel, width) {\n    var devicePixelRatio = chart.currentDevicePixelRatio;\n    var halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;\n    return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;\n  }\n  function clearCanvas(canvas, ctx) {\n    ctx = ctx || canvas.getContext('2d');\n    ctx.save();\n    ctx.resetTransform();\n    ctx.clearRect(0, 0, canvas.width, canvas.height);\n    ctx.restore();\n  }\n  function drawPoint(ctx, options, x, y) {\n    drawPointLegend(ctx, options, x, y, null);\n  }\n  function drawPointLegend(ctx, options, x, y, w) {\n    var type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;\n    var style = options.pointStyle;\n    var rotation = options.rotation;\n    var radius = options.radius;\n    var rad = (rotation || 0) * RAD_PER_DEG;\n    if (style && _typeof$z(style) === 'object') {\n      type = style.toString();\n      if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {\n        ctx.save();\n        ctx.translate(x, y);\n        ctx.rotate(rad);\n        ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height);\n        ctx.restore();\n        return;\n      }\n    }\n    if (isNaN(radius) || radius <= 0) {\n      return;\n    }\n    ctx.beginPath();\n    switch (style) {\n      default:\n        if (w) {\n          ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);\n        } else {\n          ctx.arc(x, y, radius, 0, TAU);\n        }\n        ctx.closePath();\n        break;\n      case 'triangle':\n        width = w ? w / 2 : radius;\n        ctx.moveTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n        rad += TWO_THIRDS_PI;\n        ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n        rad += TWO_THIRDS_PI;\n        ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n        ctx.closePath();\n        break;\n      case 'rectRounded':\n        cornerRadius = radius * 0.516;\n        size = radius - cornerRadius;\n        xOffset = Math.cos(rad + QUARTER_PI) * size;\n        xOffsetW = Math.cos(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n        yOffset = Math.sin(rad + QUARTER_PI) * size;\n        yOffsetW = Math.sin(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n        ctx.arc(x - xOffsetW, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI);\n        ctx.arc(x + yOffsetW, y - xOffset, cornerRadius, rad - HALF_PI, rad);\n        ctx.arc(x + xOffsetW, y + yOffset, cornerRadius, rad, rad + HALF_PI);\n        ctx.arc(x - yOffsetW, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI);\n        ctx.closePath();\n        break;\n      case 'rect':\n        if (!rotation) {\n          size = Math.SQRT1_2 * radius;\n          width = w ? w / 2 : size;\n          ctx.rect(x - width, y - size, 2 * width, 2 * size);\n          break;\n        }\n        rad += QUARTER_PI;\n      case 'rectRot':\n        xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n        xOffset = Math.cos(rad) * radius;\n        yOffset = Math.sin(rad) * radius;\n        yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n        ctx.moveTo(x - xOffsetW, y - yOffset);\n        ctx.lineTo(x + yOffsetW, y - xOffset);\n        ctx.lineTo(x + xOffsetW, y + yOffset);\n        ctx.lineTo(x - yOffsetW, y + xOffset);\n        ctx.closePath();\n        break;\n      case 'crossRot':\n        rad += QUARTER_PI;\n      case 'cross':\n        xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n        xOffset = Math.cos(rad) * radius;\n        yOffset = Math.sin(rad) * radius;\n        yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n        ctx.moveTo(x - xOffsetW, y - yOffset);\n        ctx.lineTo(x + xOffsetW, y + yOffset);\n        ctx.moveTo(x + yOffsetW, y - xOffset);\n        ctx.lineTo(x - yOffsetW, y + xOffset);\n        break;\n      case 'star':\n        xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n        xOffset = Math.cos(rad) * radius;\n        yOffset = Math.sin(rad) * radius;\n        yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n        ctx.moveTo(x - xOffsetW, y - yOffset);\n        ctx.lineTo(x + xOffsetW, y + yOffset);\n        ctx.moveTo(x + yOffsetW, y - xOffset);\n        ctx.lineTo(x - yOffsetW, y + xOffset);\n        rad += QUARTER_PI;\n        xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n        xOffset = Math.cos(rad) * radius;\n        yOffset = Math.sin(rad) * radius;\n        yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n        ctx.moveTo(x - xOffsetW, y - yOffset);\n        ctx.lineTo(x + xOffsetW, y + yOffset);\n        ctx.moveTo(x + yOffsetW, y - xOffset);\n        ctx.lineTo(x - yOffsetW, y + xOffset);\n        break;\n      case 'line':\n        xOffset = w ? w / 2 : Math.cos(rad) * radius;\n        yOffset = Math.sin(rad) * radius;\n        ctx.moveTo(x - xOffset, y - yOffset);\n        ctx.lineTo(x + xOffset, y + yOffset);\n        break;\n      case 'dash':\n        ctx.moveTo(x, y);\n        ctx.lineTo(x + Math.cos(rad) * (w ? w / 2 : radius), y + Math.sin(rad) * radius);\n        break;\n      case false:\n        ctx.closePath();\n        break;\n    }\n    ctx.fill();\n    if (options.borderWidth > 0) {\n      ctx.stroke();\n    }\n  }\n  function _isPointInArea(point, area, margin) {\n    margin = margin || 0.5;\n    return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;\n  }\n  function clipArea(ctx, area) {\n    ctx.save();\n    ctx.beginPath();\n    ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);\n    ctx.clip();\n  }\n  function unclipArea(ctx) {\n    ctx.restore();\n  }\n  function _steppedLineTo(ctx, previous, target, flip, mode) {\n    if (!previous) {\n      return ctx.lineTo(target.x, target.y);\n    }\n    if (mode === 'middle') {\n      var midpoint = (previous.x + target.x) / 2.0;\n      ctx.lineTo(midpoint, previous.y);\n      ctx.lineTo(midpoint, target.y);\n    } else if (mode === 'after' !== !!flip) {\n      ctx.lineTo(previous.x, target.y);\n    } else {\n      ctx.lineTo(target.x, previous.y);\n    }\n    ctx.lineTo(target.x, target.y);\n  }\n  function _bezierCurveTo(ctx, previous, target, flip) {\n    if (!previous) {\n      return ctx.lineTo(target.x, target.y);\n    }\n    ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);\n  }\n  function renderText(ctx, text, x, y, font) {\n    var opts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n    var lines = isArray(text) ? text : [text];\n    var stroke = opts.strokeWidth > 0 && opts.strokeColor !== '';\n    var i, line;\n    ctx.save();\n    ctx.font = font.string;\n    setRenderOpts(ctx, opts);\n    for (i = 0; i < lines.length; ++i) {\n      line = lines[i];\n      if (opts.backdrop) {\n        drawBackdrop(ctx, opts.backdrop);\n      }\n      if (stroke) {\n        if (opts.strokeColor) {\n          ctx.strokeStyle = opts.strokeColor;\n        }\n        if (!isNullOrUndef(opts.strokeWidth)) {\n          ctx.lineWidth = opts.strokeWidth;\n        }\n        ctx.strokeText(line, x, y, opts.maxWidth);\n      }\n      ctx.fillText(line, x, y, opts.maxWidth);\n      decorateText(ctx, x, y, line, opts);\n      y += font.lineHeight;\n    }\n    ctx.restore();\n  }\n  function setRenderOpts(ctx, opts) {\n    if (opts.translation) {\n      ctx.translate(opts.translation[0], opts.translation[1]);\n    }\n    if (!isNullOrUndef(opts.rotation)) {\n      ctx.rotate(opts.rotation);\n    }\n    if (opts.color) {\n      ctx.fillStyle = opts.color;\n    }\n    if (opts.textAlign) {\n      ctx.textAlign = opts.textAlign;\n    }\n    if (opts.textBaseline) {\n      ctx.textBaseline = opts.textBaseline;\n    }\n  }\n  function decorateText(ctx, x, y, line, opts) {\n    if (opts.strikethrough || opts.underline) {\n      var metrics = ctx.measureText(line);\n      var left = x - metrics.actualBoundingBoxLeft;\n      var right = x + metrics.actualBoundingBoxRight;\n      var top = y - metrics.actualBoundingBoxAscent;\n      var bottom = y + metrics.actualBoundingBoxDescent;\n      var yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;\n      ctx.strokeStyle = ctx.fillStyle;\n      ctx.beginPath();\n      ctx.lineWidth = opts.decorationWidth || 2;\n      ctx.moveTo(left, yDecoration);\n      ctx.lineTo(right, yDecoration);\n      ctx.stroke();\n    }\n  }\n  function drawBackdrop(ctx, opts) {\n    var oldColor = ctx.fillStyle;\n    ctx.fillStyle = opts.color;\n    ctx.fillRect(opts.left, opts.top, opts.width, opts.height);\n    ctx.fillStyle = oldColor;\n  }\n  function addRoundedRectPath(ctx, rect) {\n    var x = rect.x,\n      y = rect.y,\n      w = rect.w,\n      h = rect.h,\n      radius = rect.radius;\n    ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, -HALF_PI, PI, true);\n    ctx.lineTo(x, y + h - radius.bottomLeft);\n    ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);\n    ctx.lineTo(x + w - radius.bottomRight, y + h);\n    ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);\n    ctx.lineTo(x + w, y + radius.topRight);\n    ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);\n    ctx.lineTo(x + radius.topLeft, y);\n  }\n  var LINE_HEIGHT = /^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/;\n  var FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;\n  /**\n   * @alias Chart.helpers.options\n   * @namespace\n   */ /**\n      * Converts the given line height `value` in pixels for a specific font `size`.\n      * @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').\n      * @param size - The font size (in pixels) used to resolve relative `value`.\n      * @returns The effective line height in pixels (size * 1.2 if value is invalid).\n      * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height\n      * @since 2.7.0\n      */\n  function toLineHeight(value, size) {\n    var matches = ('' + value).match(LINE_HEIGHT);\n    if (!matches || matches[1] === 'normal') {\n      return size * 1.2;\n    }\n    value = +matches[2];\n    switch (matches[3]) {\n      case 'px':\n        return value;\n      case '%':\n        value /= 100;\n        break;\n    }\n    return size * value;\n  }\n  var numberOrZero = function numberOrZero(v) {\n    return +v || 0;\n  };\n  function _readValueToProps(value, props) {\n    var ret = {};\n    var objProps = isObject(props);\n    var keys = objProps ? Object.keys(props) : props;\n    var read = isObject(value) ? objProps ? function (prop) {\n      return valueOrDefault(value[prop], value[props[prop]]);\n    } : function (prop) {\n      return value[prop];\n    } : function () {\n      return value;\n    };\n    var _iterator4 = _createForOfIteratorHelper$1(keys),\n      _step4;\n    try {\n      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n        var prop = _step4.value;\n        ret[prop] = numberOrZero(read(prop));\n      }\n    } catch (err) {\n      _iterator4.e(err);\n    } finally {\n      _iterator4.f();\n    }\n    return ret;\n  }\n  /**\n   * Converts the given value into a TRBL object.\n   * @param value - If a number, set the value to all TRBL component,\n   *  else, if an object, use defined properties and sets undefined ones to 0.\n   *  x / y are shorthands for same value for left/right and top/bottom.\n   * @returns The padding values (top, right, bottom, left)\n   * @since 3.0.0\n   */\n  function toTRBL(value) {\n    return _readValueToProps(value, {\n      top: 'y',\n      right: 'x',\n      bottom: 'y',\n      left: 'x'\n    });\n  }\n  /**\n   * Converts the given value into a TRBL corners object (similar with css border-radius).\n   * @param value - If a number, set the value to all TRBL corner components,\n   *  else, if an object, use defined properties and sets undefined ones to 0.\n   * @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)\n   * @since 3.0.0\n   */\n  function toTRBLCorners(value) {\n    return _readValueToProps(value, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);\n  }\n  /**\n   * Converts the given value into a padding object with pre-computed width/height.\n   * @param value - If a number, set the value to all TRBL component,\n   *  else, if an object, use defined properties and sets undefined ones to 0.\n   *  x / y are shorthands for same value for left/right and top/bottom.\n   * @returns The padding values (top, right, bottom, left, width, height)\n   * @since 2.7.0\n   */\n  function toPadding(value) {\n    var obj = toTRBL(value);\n    obj.width = obj.left + obj.right;\n    obj.height = obj.top + obj.bottom;\n    return obj;\n  }\n  /**\n   * Parses font options and returns the font object.\n   * @param options - A object that contains font options to be parsed.\n   * @param fallback - A object that contains fallback font options.\n   * @return The font object.\n   * @private\n   */\n  function toFont(options, fallback) {\n    options = options || {};\n    fallback = fallback || defaults.font;\n    var size = valueOrDefault(options.size, fallback.size);\n    if (typeof size === 'string') {\n      size = parseInt(size, 10);\n    }\n    var style = valueOrDefault(options.style, fallback.style);\n    if (style && !('' + style).match(FONT_STYLE)) {\n      console.warn('Invalid font style specified: \"' + style + '\"');\n      style = undefined;\n    }\n    var font = {\n      family: valueOrDefault(options.family, fallback.family),\n      lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),\n      size: size,\n      style: style,\n      weight: valueOrDefault(options.weight, fallback.weight),\n      string: ''\n    };\n    font.string = toFontString(font);\n    return font;\n  }\n  /**\n   * Evaluates the given `inputs` sequentially and returns the first defined value.\n   * @param inputs - An array of values, falling back to the last value.\n   * @param context - If defined and the current value is a function, the value\n   * is called with `context` as first argument and the result becomes the new input.\n   * @param index - If defined and the current value is an array, the value\n   * at `index` become the new input.\n   * @param info - object to return information about resolution in\n   * @param info.cacheable - Will be set to `false` if option is not cacheable.\n   * @since 2.7.0\n   */\n  function resolve(inputs, context, index, info) {\n    var cacheable = true;\n    var i, ilen, value;\n    for (i = 0, ilen = inputs.length; i < ilen; ++i) {\n      value = inputs[i];\n      if (value === undefined) {\n        continue;\n      }\n      if (context !== undefined && typeof value === 'function') {\n        value = value(context);\n        cacheable = false;\n      }\n      if (index !== undefined && isArray(value)) {\n        value = value[index % value.length];\n        cacheable = false;\n      }\n      if (value !== undefined) {\n        if (info && !cacheable) {\n          info.cacheable = false;\n        }\n        return value;\n      }\n    }\n  }\n  /**\n   * @param minmax\n   * @param grace\n   * @param beginAtZero\n   * @private\n   */\n  function _addGrace(minmax, grace, beginAtZero) {\n    var min = minmax.min,\n      max = minmax.max;\n    var change = toDimension(grace, (max - min) / 2);\n    var keepZero = function keepZero(value, add) {\n      return beginAtZero && value === 0 ? 0 : value + add;\n    };\n    return {\n      min: keepZero(min, -Math.abs(change)),\n      max: keepZero(max, change)\n    };\n  }\n  function createContext(parentContext, context) {\n    return Object.assign(Object.create(parentContext), context);\n  }\n  function _createResolver(scopes) {\n    var _cache;\n    var prefixes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [''];\n    var rootScopes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : scopes;\n    var fallback = arguments.length > 3 ? arguments[3] : undefined;\n    var getTarget = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {\n      return scopes[0];\n    };\n    if (!defined(fallback)) {\n      fallback = _resolve('_fallback', scopes);\n    }\n    var cache = (_cache = {}, _defineProperty$w(_cache, Symbol.toStringTag, 'Object'), _defineProperty$w(_cache, \"_cacheable\", true), _defineProperty$w(_cache, \"_scopes\", scopes), _defineProperty$w(_cache, \"_rootScopes\", rootScopes), _defineProperty$w(_cache, \"_fallback\", fallback), _defineProperty$w(_cache, \"_getTarget\", getTarget), _defineProperty$w(_cache, \"override\", function override(scope) {\n      return _createResolver([scope].concat(_toConsumableArray(scopes)), prefixes, rootScopes, fallback);\n    }), _cache);\n    return new Proxy(cache, {\n      deleteProperty: function deleteProperty(target, prop) {\n        delete target[prop];\n        delete target._keys;\n        delete scopes[0][prop];\n        return true;\n      },\n      get: function get(target, prop) {\n        return _cached(target, prop, function () {\n          return _resolveWithPrefixes(prop, prefixes, scopes, target);\n        });\n      },\n      getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {\n        return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);\n      },\n      getPrototypeOf: function getPrototypeOf() {\n        return Reflect.getPrototypeOf(scopes[0]);\n      },\n      has: function has(target, prop) {\n        return getKeysFromAllScopes(target).includes(prop);\n      },\n      ownKeys: function ownKeys(target) {\n        return getKeysFromAllScopes(target);\n      },\n      set: function set(target, prop, value) {\n        var storage = target._storage || (target._storage = getTarget());\n        target[prop] = storage[prop] = value;\n        delete target._keys;\n        return true;\n      }\n    });\n  }\n  function _attachContext(proxy, context, subProxy, descriptorDefaults) {\n    var cache = {\n      _cacheable: false,\n      _proxy: proxy,\n      _context: context,\n      _subProxy: subProxy,\n      _stack: new Set(),\n      _descriptors: _descriptors(proxy, descriptorDefaults),\n      setContext: function setContext(ctx) {\n        return _attachContext(proxy, ctx, subProxy, descriptorDefaults);\n      },\n      override: function override(scope) {\n        return _attachContext(proxy.override(scope), context, subProxy, descriptorDefaults);\n      }\n    };\n    return new Proxy(cache, {\n      deleteProperty: function deleteProperty(target, prop) {\n        delete target[prop];\n        delete proxy[prop];\n        return true;\n      },\n      get: function get(target, prop, receiver) {\n        return _cached(target, prop, function () {\n          return _resolveWithContext(target, prop, receiver);\n        });\n      },\n      getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {\n        return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {\n          enumerable: true,\n          configurable: true\n        } : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);\n      },\n      getPrototypeOf: function getPrototypeOf() {\n        return Reflect.getPrototypeOf(proxy);\n      },\n      has: function has(target, prop) {\n        return Reflect.has(proxy, prop);\n      },\n      ownKeys: function ownKeys() {\n        return Reflect.ownKeys(proxy);\n      },\n      set: function set(target, prop, value) {\n        proxy[prop] = value;\n        delete target[prop];\n        return true;\n      }\n    });\n  }\n  function _descriptors(proxy) {\n    var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n      scriptable: true,\n      indexable: true\n    };\n    var _proxy$_scriptable = proxy._scriptable,\n      _scriptable = _proxy$_scriptable === void 0 ? defaults.scriptable : _proxy$_scriptable,\n      _proxy$_indexable = proxy._indexable,\n      _indexable = _proxy$_indexable === void 0 ? defaults.indexable : _proxy$_indexable,\n      _proxy$_allKeys = proxy._allKeys,\n      _allKeys = _proxy$_allKeys === void 0 ? defaults.allKeys : _proxy$_allKeys;\n    return {\n      allKeys: _allKeys,\n      scriptable: _scriptable,\n      indexable: _indexable,\n      isScriptable: isFunction(_scriptable) ? _scriptable : function () {\n        return _scriptable;\n      },\n      isIndexable: isFunction(_indexable) ? _indexable : function () {\n        return _indexable;\n      }\n    };\n  }\n  var readKey = function readKey(prefix, name) {\n    return prefix ? prefix + _capitalize(name) : name;\n  };\n  var needsSubResolver = function needsSubResolver(prop, value) {\n    return isObject(value) && prop !== 'adapters' && (Object.getPrototypeOf(value) === null || value.constructor === Object);\n  };\n  function _cached(target, prop, resolve) {\n    if (Object.prototype.hasOwnProperty.call(target, prop)) {\n      return target[prop];\n    }\n    var value = resolve();\n    target[prop] = value;\n    return value;\n  }\n  function _resolveWithContext(target, prop, receiver) {\n    var _proxy = target._proxy,\n      _context = target._context,\n      _subProxy = target._subProxy,\n      descriptors = target._descriptors;\n    var value = _proxy[prop];\n    if (isFunction(value) && descriptors.isScriptable(prop)) {\n      value = _resolveScriptable(prop, value, target, receiver);\n    }\n    if (isArray(value) && value.length) {\n      value = _resolveArray(prop, value, target, descriptors.isIndexable);\n    }\n    if (needsSubResolver(prop, value)) {\n      value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);\n    }\n    return value;\n  }\n  function _resolveScriptable(prop, value, target, receiver) {\n    var _proxy = target._proxy,\n      _context = target._context,\n      _subProxy = target._subProxy,\n      _stack = target._stack;\n    if (_stack.has(prop)) {\n      throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);\n    }\n    _stack.add(prop);\n    value = value(_context, _subProxy || receiver);\n    _stack[\"delete\"](prop);\n    if (needsSubResolver(prop, value)) {\n      value = createSubResolver(_proxy._scopes, _proxy, prop, value);\n    }\n    return value;\n  }\n  function _resolveArray(prop, value, target, isIndexable) {\n    var _proxy = target._proxy,\n      _context = target._context,\n      _subProxy = target._subProxy,\n      descriptors = target._descriptors;\n    if (defined(_context.index) && isIndexable(prop)) {\n      value = value[_context.index % value.length];\n    } else if (isObject(value[0])) {\n      var arr = value;\n      var scopes = _proxy._scopes.filter(function (s) {\n        return s !== arr;\n      });\n      value = [];\n      var _iterator5 = _createForOfIteratorHelper$1(arr),\n        _step5;\n      try {\n        for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n          var item = _step5.value;\n          var resolver = createSubResolver(scopes, _proxy, prop, item);\n          value.push(_attachContext(resolver, _context, _subProxy && _subProxy[prop], descriptors));\n        }\n      } catch (err) {\n        _iterator5.e(err);\n      } finally {\n        _iterator5.f();\n      }\n    }\n    return value;\n  }\n  function resolveFallback(fallback, prop, value) {\n    return isFunction(fallback) ? fallback(prop, value) : fallback;\n  }\n  var getScope = function getScope(key, parent) {\n    return key === true ? parent : typeof key === 'string' ? resolveObjectKey(parent, key) : undefined;\n  };\n  function addScopes(set, parentScopes, key, parentFallback, value) {\n    var _iterator6 = _createForOfIteratorHelper$1(parentScopes),\n      _step6;\n    try {\n      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n        var parent = _step6.value;\n        var scope = getScope(key, parent);\n        if (scope) {\n          set.add(scope);\n          var fallback = resolveFallback(scope._fallback, key, value);\n          if (defined(fallback) && fallback !== key && fallback !== parentFallback) {\n            return fallback;\n          }\n        } else if (scope === false && defined(parentFallback) && key !== parentFallback) {\n          return null;\n        }\n      }\n    } catch (err) {\n      _iterator6.e(err);\n    } finally {\n      _iterator6.f();\n    }\n    return false;\n  }\n  function createSubResolver(parentScopes, resolver, prop, value) {\n    var rootScopes = resolver._rootScopes;\n    var fallback = resolveFallback(resolver._fallback, prop, value);\n    var allScopes = [].concat(_toConsumableArray(parentScopes), _toConsumableArray(rootScopes));\n    var set = new Set();\n    set.add(value);\n    var key = addScopesFromKey(set, allScopes, prop, fallback || prop, value);\n    if (key === null) {\n      return false;\n    }\n    if (defined(fallback) && fallback !== prop) {\n      key = addScopesFromKey(set, allScopes, fallback, key, value);\n      if (key === null) {\n        return false;\n      }\n    }\n    return _createResolver(Array.from(set), [''], rootScopes, fallback, function () {\n      return subGetTarget(resolver, prop, value);\n    });\n  }\n  function addScopesFromKey(set, allScopes, key, fallback, item) {\n    while (key) {\n      key = addScopes(set, allScopes, key, fallback, item);\n    }\n    return key;\n  }\n  function subGetTarget(resolver, prop, value) {\n    var parent = resolver._getTarget();\n    if (!(prop in parent)) {\n      parent[prop] = {};\n    }\n    var target = parent[prop];\n    if (isArray(target) && isObject(value)) {\n      return value;\n    }\n    return target || {};\n  }\n  function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {\n    var value;\n    var _iterator7 = _createForOfIteratorHelper$1(prefixes),\n      _step7;\n    try {\n      for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n        var prefix = _step7.value;\n        value = _resolve(readKey(prefix, prop), scopes);\n        if (defined(value)) {\n          return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;\n        }\n      }\n    } catch (err) {\n      _iterator7.e(err);\n    } finally {\n      _iterator7.f();\n    }\n  }\n  function _resolve(key, scopes) {\n    var _iterator8 = _createForOfIteratorHelper$1(scopes),\n      _step8;\n    try {\n      for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n        var scope = _step8.value;\n        if (!scope) {\n          continue;\n        }\n        var value = scope[key];\n        if (defined(value)) {\n          return value;\n        }\n      }\n    } catch (err) {\n      _iterator8.e(err);\n    } finally {\n      _iterator8.f();\n    }\n  }\n  function getKeysFromAllScopes(target) {\n    var keys = target._keys;\n    if (!keys) {\n      keys = target._keys = resolveKeysFromAllScopes(target._scopes);\n    }\n    return keys;\n  }\n  function resolveKeysFromAllScopes(scopes) {\n    var set = new Set();\n    var _iterator9 = _createForOfIteratorHelper$1(scopes),\n      _step9;\n    try {\n      for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n        var scope = _step9.value;\n        var _iterator10 = _createForOfIteratorHelper$1(Object.keys(scope).filter(function (k) {\n            return !k.startsWith('_');\n          })),\n          _step10;\n        try {\n          for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n            var key = _step10.value;\n            set.add(key);\n          }\n        } catch (err) {\n          _iterator10.e(err);\n        } finally {\n          _iterator10.f();\n        }\n      }\n    } catch (err) {\n      _iterator9.e(err);\n    } finally {\n      _iterator9.f();\n    }\n    return Array.from(set);\n  }\n  function _parseObjectDataRadialScale(meta, data, start, count) {\n    var iScale = meta.iScale;\n    var _this$_parsing$key = this._parsing.key,\n      key = _this$_parsing$key === void 0 ? 'r' : _this$_parsing$key;\n    var parsed = new Array(count);\n    var i, ilen, index, item;\n    for (i = 0, ilen = count; i < ilen; ++i) {\n      index = i + start;\n      item = data[index];\n      parsed[i] = {\n        r: iScale.parse(resolveObjectKey(item, key), index)\n      };\n    }\n    return parsed;\n  }\n  var EPSILON = Number.EPSILON || 1e-14;\n  var getPoint = function getPoint(points, i) {\n    return i < points.length && !points[i].skip && points[i];\n  };\n  var getValueAxis = function getValueAxis(indexAxis) {\n    return indexAxis === 'x' ? 'y' : 'x';\n  };\n  function splineCurve(firstPoint, middlePoint, afterPoint, t) {\n    // Props to Rob Spencer at scaled innovation for his post on splining between points\n    // http://scaledinnovation.com/analytics/splines/aboutSplines.html\n    // This function must also respect \"skipped\" points\n    var previous = firstPoint.skip ? middlePoint : firstPoint;\n    var current = middlePoint;\n    var next = afterPoint.skip ? middlePoint : afterPoint;\n    var d01 = distanceBetweenPoints(current, previous);\n    var d12 = distanceBetweenPoints(next, current);\n    var s01 = d01 / (d01 + d12);\n    var s12 = d12 / (d01 + d12);\n    // If all points are the same, s01 & s02 will be inf\n    s01 = isNaN(s01) ? 0 : s01;\n    s12 = isNaN(s12) ? 0 : s12;\n    var fa = t * s01; // scaling factor for triangle Ta\n    var fb = t * s12;\n    return {\n      previous: {\n        x: current.x - fa * (next.x - previous.x),\n        y: current.y - fa * (next.y - previous.y)\n      },\n      next: {\n        x: current.x + fb * (next.x - previous.x),\n        y: current.y + fb * (next.y - previous.y)\n      }\n    };\n  }\n  /**\n   * Adjust tangents to ensure monotonic properties\n   */\n  function monotoneAdjust(points, deltaK, mK) {\n    var pointsLen = points.length;\n    var alphaK, betaK, tauK, squaredMagnitude, pointCurrent;\n    var pointAfter = getPoint(points, 0);\n    for (var i = 0; i < pointsLen - 1; ++i) {\n      pointCurrent = pointAfter;\n      pointAfter = getPoint(points, i + 1);\n      if (!pointCurrent || !pointAfter) {\n        continue;\n      }\n      if (almostEquals(deltaK[i], 0, EPSILON)) {\n        mK[i] = mK[i + 1] = 0;\n        continue;\n      }\n      alphaK = mK[i] / deltaK[i];\n      betaK = mK[i + 1] / deltaK[i];\n      squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);\n      if (squaredMagnitude <= 9) {\n        continue;\n      }\n      tauK = 3 / Math.sqrt(squaredMagnitude);\n      mK[i] = alphaK * tauK * deltaK[i];\n      mK[i + 1] = betaK * tauK * deltaK[i];\n    }\n  }\n  function monotoneCompute(points, mK) {\n    var indexAxis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'x';\n    var valueAxis = getValueAxis(indexAxis);\n    var pointsLen = points.length;\n    var delta, pointBefore, pointCurrent;\n    var pointAfter = getPoint(points, 0);\n    for (var i = 0; i < pointsLen; ++i) {\n      pointBefore = pointCurrent;\n      pointCurrent = pointAfter;\n      pointAfter = getPoint(points, i + 1);\n      if (!pointCurrent) {\n        continue;\n      }\n      var iPixel = pointCurrent[indexAxis];\n      var vPixel = pointCurrent[valueAxis];\n      if (pointBefore) {\n        delta = (iPixel - pointBefore[indexAxis]) / 3;\n        pointCurrent[\"cp1\".concat(indexAxis)] = iPixel - delta;\n        pointCurrent[\"cp1\".concat(valueAxis)] = vPixel - delta * mK[i];\n      }\n      if (pointAfter) {\n        delta = (pointAfter[indexAxis] - iPixel) / 3;\n        pointCurrent[\"cp2\".concat(indexAxis)] = iPixel + delta;\n        pointCurrent[\"cp2\".concat(valueAxis)] = vPixel + delta * mK[i];\n      }\n    }\n  }\n  /**\n   * This function calculates Bézier control points in a similar way than |splineCurve|,\n   * but preserves monotonicity of the provided data and ensures no local extremums are added\n   * between the dataset discrete points due to the interpolation.\n   * See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation\n   */\n  function splineCurveMonotone(points) {\n    var indexAxis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';\n    var valueAxis = getValueAxis(indexAxis);\n    var pointsLen = points.length;\n    var deltaK = Array(pointsLen).fill(0);\n    var mK = Array(pointsLen);\n    // Calculate slopes (deltaK) and initialize tangents (mK)\n    var i, pointBefore, pointCurrent;\n    var pointAfter = getPoint(points, 0);\n    for (i = 0; i < pointsLen; ++i) {\n      pointBefore = pointCurrent;\n      pointCurrent = pointAfter;\n      pointAfter = getPoint(points, i + 1);\n      if (!pointCurrent) {\n        continue;\n      }\n      if (pointAfter) {\n        var slopeDelta = pointAfter[indexAxis] - pointCurrent[indexAxis];\n        // In the case of two points that appear at the same x pixel, slopeDeltaX is 0\n        deltaK[i] = slopeDelta !== 0 ? (pointAfter[valueAxis] - pointCurrent[valueAxis]) / slopeDelta : 0;\n      }\n      mK[i] = !pointBefore ? deltaK[i] : !pointAfter ? deltaK[i - 1] : sign(deltaK[i - 1]) !== sign(deltaK[i]) ? 0 : (deltaK[i - 1] + deltaK[i]) / 2;\n    }\n    monotoneAdjust(points, deltaK, mK);\n    monotoneCompute(points, mK, indexAxis);\n  }\n  function capControlPoint(pt, min, max) {\n    return Math.max(Math.min(pt, max), min);\n  }\n  function capBezierPoints(points, area) {\n    var i, ilen, point, inArea, inAreaPrev;\n    var inAreaNext = _isPointInArea(points[0], area);\n    for (i = 0, ilen = points.length; i < ilen; ++i) {\n      inAreaPrev = inArea;\n      inArea = inAreaNext;\n      inAreaNext = i < ilen - 1 && _isPointInArea(points[i + 1], area);\n      if (!inArea) {\n        continue;\n      }\n      point = points[i];\n      if (inAreaPrev) {\n        point.cp1x = capControlPoint(point.cp1x, area.left, area.right);\n        point.cp1y = capControlPoint(point.cp1y, area.top, area.bottom);\n      }\n      if (inAreaNext) {\n        point.cp2x = capControlPoint(point.cp2x, area.left, area.right);\n        point.cp2y = capControlPoint(point.cp2y, area.top, area.bottom);\n      }\n    }\n  }\n  /**\n   * @private\n   */\n  function _updateBezierControlPoints(points, options, area, loop, indexAxis) {\n    var i, ilen, point, controlPoints;\n    // Only consider points that are drawn in case the spanGaps option is used\n    if (options.spanGaps) {\n      points = points.filter(function (pt) {\n        return !pt.skip;\n      });\n    }\n    if (options.cubicInterpolationMode === 'monotone') {\n      splineCurveMonotone(points, indexAxis);\n    } else {\n      var prev = loop ? points[points.length - 1] : points[0];\n      for (i = 0, ilen = points.length; i < ilen; ++i) {\n        point = points[i];\n        controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension);\n        point.cp1x = controlPoints.previous.x;\n        point.cp1y = controlPoints.previous.y;\n        point.cp2x = controlPoints.next.x;\n        point.cp2y = controlPoints.next.y;\n        prev = point;\n      }\n    }\n    if (options.capBezierPoints) {\n      capBezierPoints(points, area);\n    }\n  }\n\n  /**\n   * Note: typedefs are auto-exported, so use a made-up `dom` namespace where\n   * necessary to avoid duplicates with `export * from './helpers`; see\n   * https://github.com/microsoft/TypeScript/issues/46011\n   * @typedef { import('../core/core.controller.js').default } dom.Chart\n   * @typedef { import('../../types').ChartEvent } ChartEvent\n   */ /**\n      * @private\n      */\n  function _isDomSupported() {\n    return typeof window !== 'undefined' && typeof document !== 'undefined';\n  }\n  /**\n   * @private\n   */\n  function _getParentNode(domNode) {\n    var parent = domNode.parentNode;\n    if (parent && parent.toString() === '[object ShadowRoot]') {\n      parent = parent.host;\n    }\n    return parent;\n  }\n  /**\n   * convert max-width/max-height values that may be percentages into a number\n   * @private\n   */\n  function parseMaxStyle(styleValue, node, parentProperty) {\n    var valueInPixels;\n    if (typeof styleValue === 'string') {\n      valueInPixels = parseInt(styleValue, 10);\n      if (styleValue.indexOf('%') !== -1) {\n        // percentage * size in dimension\n        valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];\n      }\n    } else {\n      valueInPixels = styleValue;\n    }\n    return valueInPixels;\n  }\n  var getComputedStyle = function getComputedStyle(element) {\n    return element.ownerDocument.defaultView.getComputedStyle(element, null);\n  };\n  function getStyle(el, property) {\n    return getComputedStyle(el).getPropertyValue(property);\n  }\n  var positions = ['top', 'right', 'bottom', 'left'];\n  function getPositionedStyle(styles, style, suffix) {\n    var result = {};\n    suffix = suffix ? '-' + suffix : '';\n    for (var i = 0; i < 4; i++) {\n      var pos = positions[i];\n      result[pos] = parseFloat(styles[style + '-' + pos + suffix]) || 0;\n    }\n    result.width = result.left + result.right;\n    result.height = result.top + result.bottom;\n    return result;\n  }\n  var useOffsetPos = function useOffsetPos(x, y, target) {\n    return (x > 0 || y > 0) && (!target || !target.shadowRoot);\n  };\n  /**\n   * @param e\n   * @param canvas\n   * @returns Canvas position\n   */\n  function getCanvasPosition(e, canvas) {\n    var touches = e.touches;\n    var source = touches && touches.length ? touches[0] : e;\n    var offsetX = source.offsetX,\n      offsetY = source.offsetY;\n    var box = false;\n    var x, y;\n    if (useOffsetPos(offsetX, offsetY, e.target)) {\n      x = offsetX;\n      y = offsetY;\n    } else {\n      var rect = canvas.getBoundingClientRect();\n      x = source.clientX - rect.left;\n      y = source.clientY - rect.top;\n      box = true;\n    }\n    return {\n      x: x,\n      y: y,\n      box: box\n    };\n  }\n  /**\n   * Gets an event's x, y coordinates, relative to the chart area\n   * @param event\n   * @param chart\n   * @returns x and y coordinates of the event\n   */\n  function getRelativePosition(event, chart) {\n    if ('native' in event) {\n      return event;\n    }\n    var canvas = chart.canvas,\n      currentDevicePixelRatio = chart.currentDevicePixelRatio;\n    var style = getComputedStyle(canvas);\n    var borderBox = style.boxSizing === 'border-box';\n    var paddings = getPositionedStyle(style, 'padding');\n    var borders = getPositionedStyle(style, 'border', 'width');\n    var _getCanvasPosition = getCanvasPosition(event, canvas),\n      x = _getCanvasPosition.x,\n      y = _getCanvasPosition.y,\n      box = _getCanvasPosition.box;\n    var xOffset = paddings.left + (box && borders.left);\n    var yOffset = paddings.top + (box && borders.top);\n    var width = chart.width,\n      height = chart.height;\n    if (borderBox) {\n      width -= paddings.width + borders.width;\n      height -= paddings.height + borders.height;\n    }\n    return {\n      x: Math.round((x - xOffset) / width * canvas.width / currentDevicePixelRatio),\n      y: Math.round((y - yOffset) / height * canvas.height / currentDevicePixelRatio)\n    };\n  }\n  function getContainerSize(canvas, width, height) {\n    var maxWidth, maxHeight;\n    if (width === undefined || height === undefined) {\n      var container = _getParentNode(canvas);\n      if (!container) {\n        width = canvas.clientWidth;\n        height = canvas.clientHeight;\n      } else {\n        var rect = container.getBoundingClientRect(); // this is the border box of the container\n        var containerStyle = getComputedStyle(container);\n        var containerBorder = getPositionedStyle(containerStyle, 'border', 'width');\n        var containerPadding = getPositionedStyle(containerStyle, 'padding');\n        width = rect.width - containerPadding.width - containerBorder.width;\n        height = rect.height - containerPadding.height - containerBorder.height;\n        maxWidth = parseMaxStyle(containerStyle.maxWidth, container, 'clientWidth');\n        maxHeight = parseMaxStyle(containerStyle.maxHeight, container, 'clientHeight');\n      }\n    }\n    return {\n      width: width,\n      height: height,\n      maxWidth: maxWidth || INFINITY,\n      maxHeight: maxHeight || INFINITY\n    };\n  }\n  var round1 = function round1(v) {\n    return Math.round(v * 10) / 10;\n  };\n  // eslint-disable-next-line complexity\n  function getMaximumSize(canvas, bbWidth, bbHeight, aspectRatio) {\n    var style = getComputedStyle(canvas);\n    var margins = getPositionedStyle(style, 'margin');\n    var maxWidth = parseMaxStyle(style.maxWidth, canvas, 'clientWidth') || INFINITY;\n    var maxHeight = parseMaxStyle(style.maxHeight, canvas, 'clientHeight') || INFINITY;\n    var containerSize = getContainerSize(canvas, bbWidth, bbHeight);\n    var width = containerSize.width,\n      height = containerSize.height;\n    if (style.boxSizing === 'content-box') {\n      var borders = getPositionedStyle(style, 'border', 'width');\n      var paddings = getPositionedStyle(style, 'padding');\n      width -= paddings.width + borders.width;\n      height -= paddings.height + borders.height;\n    }\n    width = Math.max(0, width - margins.width);\n    height = Math.max(0, aspectRatio ? width / aspectRatio : height - margins.height);\n    width = round1(Math.min(width, maxWidth, containerSize.maxWidth));\n    height = round1(Math.min(height, maxHeight, containerSize.maxHeight));\n    if (width && !height) {\n      // https://github.com/chartjs/Chart.js/issues/4659\n      // If the canvas has width, but no height, default to aspectRatio of 2 (canvas default)\n      height = round1(width / 2);\n    }\n    var maintainHeight = bbWidth !== undefined || bbHeight !== undefined;\n    if (maintainHeight && aspectRatio && containerSize.height && height > containerSize.height) {\n      height = containerSize.height;\n      width = round1(Math.floor(height * aspectRatio));\n    }\n    return {\n      width: width,\n      height: height\n    };\n  }\n  /**\n   * @param chart\n   * @param forceRatio\n   * @param forceStyle\n   * @returns True if the canvas context size or transformation has changed.\n   */\n  function retinaScale(chart, forceRatio, forceStyle) {\n    var pixelRatio = forceRatio || 1;\n    var deviceHeight = Math.floor(chart.height * pixelRatio);\n    var deviceWidth = Math.floor(chart.width * pixelRatio);\n    chart.height = Math.floor(chart.height);\n    chart.width = Math.floor(chart.width);\n    var canvas = chart.canvas;\n    // If no style has been set on the canvas, the render size is used as display size,\n    // making the chart visually bigger, so let's enforce it to the \"correct\" values.\n    // See https://github.com/chartjs/Chart.js/issues/3575\n    if (canvas.style && (forceStyle || !canvas.style.height && !canvas.style.width)) {\n      canvas.style.height = \"\".concat(chart.height, \"px\");\n      canvas.style.width = \"\".concat(chart.width, \"px\");\n    }\n    if (chart.currentDevicePixelRatio !== pixelRatio || canvas.height !== deviceHeight || canvas.width !== deviceWidth) {\n      chart.currentDevicePixelRatio = pixelRatio;\n      canvas.height = deviceHeight;\n      canvas.width = deviceWidth;\n      chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n      return true;\n    }\n    return false;\n  }\n  /**\n   * Detects support for options object argument in addEventListener.\n   * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support\n   * @private\n   */\n  var supportsEventListenerOptions = function () {\n    var passiveSupported = false;\n    try {\n      var options = {\n        get passive() {\n          passiveSupported = true;\n          return false;\n        }\n      };\n      window.addEventListener('test', null, options);\n      window.removeEventListener('test', null, options);\n    } catch (e) {\n      // continue regardless of error\n    }\n    return passiveSupported;\n  }();\n  /**\n   * The \"used\" size is the final value of a dimension property after all calculations have\n   * been performed. This method uses the computed style of `element` but returns undefined\n   * if the computed style is not expressed in pixels. That can happen in some cases where\n   * `element` has a size relative to its parent and this last one is not yet displayed,\n   * for example because of `display: none` on a parent node.\n   * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value\n   * @returns Size in pixels or undefined if unknown.\n   */\n  function readUsedSize(element, property) {\n    var value = getStyle(element, property);\n    var matches = value && value.match(/^(\\d+)(\\.\\d+)?px$/);\n    return matches ? +matches[1] : undefined;\n  }\n\n  /**\n   * @private\n   */\n  function _pointInLine(p1, p2, t, mode) {\n    return {\n      x: p1.x + t * (p2.x - p1.x),\n      y: p1.y + t * (p2.y - p1.y)\n    };\n  }\n  /**\n   * @private\n   */\n  function _steppedInterpolation(p1, p2, t, mode) {\n    return {\n      x: p1.x + t * (p2.x - p1.x),\n      y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y\n    };\n  }\n  /**\n   * @private\n   */\n  function _bezierInterpolation(p1, p2, t, mode) {\n    var cp1 = {\n      x: p1.cp2x,\n      y: p1.cp2y\n    };\n    var cp2 = {\n      x: p2.cp1x,\n      y: p2.cp1y\n    };\n    var a = _pointInLine(p1, cp1, t);\n    var b = _pointInLine(cp1, cp2, t);\n    var c = _pointInLine(cp2, p2, t);\n    var d = _pointInLine(a, b, t);\n    var e = _pointInLine(b, c, t);\n    return _pointInLine(d, e, t);\n  }\n  var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) {\n    return {\n      x: function x(_x) {\n        return rectX + rectX + width - _x;\n      },\n      setWidth: function setWidth(w) {\n        width = w;\n      },\n      textAlign: function textAlign(align) {\n        if (align === 'center') {\n          return align;\n        }\n        return align === 'right' ? 'left' : 'right';\n      },\n      xPlus: function xPlus(x, value) {\n        return x - value;\n      },\n      leftForLtr: function leftForLtr(x, itemWidth) {\n        return x - itemWidth;\n      }\n    };\n  };\n  var getLeftToRightAdapter = function getLeftToRightAdapter() {\n    return {\n      x: function x(_x2) {\n        return _x2;\n      },\n      setWidth: function setWidth(w) {},\n      textAlign: function textAlign(align) {\n        return align;\n      },\n      xPlus: function xPlus(x, value) {\n        return x + value;\n      },\n      leftForLtr: function leftForLtr(x, _itemWidth) {\n        return x;\n      }\n    };\n  };\n  function getRtlAdapter(rtl, rectX, width) {\n    return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter();\n  }\n  function overrideTextDirection(ctx, direction) {\n    var style, original;\n    if (direction === 'ltr' || direction === 'rtl') {\n      style = ctx.canvas.style;\n      original = [style.getPropertyValue('direction'), style.getPropertyPriority('direction')];\n      style.setProperty('direction', direction, 'important');\n      ctx.prevTextDirection = original;\n    }\n  }\n  function restoreTextDirection(ctx, original) {\n    if (original !== undefined) {\n      delete ctx.prevTextDirection;\n      ctx.canvas.style.setProperty('direction', original[0], original[1]);\n    }\n  }\n  function propertyFn(property) {\n    if (property === 'angle') {\n      return {\n        between: _angleBetween,\n        compare: _angleDiff,\n        normalize: _normalizeAngle\n      };\n    }\n    return {\n      between: _isBetween,\n      compare: function compare(a, b) {\n        return a - b;\n      },\n      normalize: function normalize(x) {\n        return x;\n      }\n    };\n  }\n  function normalizeSegment(_ref) {\n    var start = _ref.start,\n      end = _ref.end,\n      count = _ref.count,\n      loop = _ref.loop,\n      style = _ref.style;\n    return {\n      start: start % count,\n      end: end % count,\n      loop: loop && (end - start + 1) % count === 0,\n      style: style\n    };\n  }\n  function getSegment(segment, points, bounds) {\n    var property = bounds.property,\n      startBound = bounds.start,\n      endBound = bounds.end;\n    var _propertyFn = propertyFn(property),\n      between = _propertyFn.between,\n      normalize = _propertyFn.normalize;\n    var count = points.length;\n    var start = segment.start,\n      end = segment.end,\n      loop = segment.loop;\n    var i, ilen;\n    if (loop) {\n      start += count;\n      end += count;\n      for (i = 0, ilen = count; i < ilen; ++i) {\n        if (!between(normalize(points[start % count][property]), startBound, endBound)) {\n          break;\n        }\n        start--;\n        end--;\n      }\n      start %= count;\n      end %= count;\n    }\n    if (end < start) {\n      end += count;\n    }\n    return {\n      start: start,\n      end: end,\n      loop: loop,\n      style: segment.style\n    };\n  }\n  function _boundSegment(segment, points, bounds) {\n    if (!bounds) {\n      return [segment];\n    }\n    var property = bounds.property,\n      startBound = bounds.start,\n      endBound = bounds.end;\n    var count = points.length;\n    var _propertyFn2 = propertyFn(property),\n      compare = _propertyFn2.compare,\n      between = _propertyFn2.between,\n      normalize = _propertyFn2.normalize;\n    var _getSegment = getSegment(segment, points, bounds),\n      start = _getSegment.start,\n      end = _getSegment.end,\n      loop = _getSegment.loop,\n      style = _getSegment.style;\n    var result = [];\n    var inside = false;\n    var subStart = null;\n    var value, point, prevValue;\n    var startIsBefore = function startIsBefore() {\n      return between(startBound, prevValue, value) && compare(startBound, prevValue) !== 0;\n    };\n    var endIsBefore = function endIsBefore() {\n      return compare(endBound, value) === 0 || between(endBound, prevValue, value);\n    };\n    var shouldStart = function shouldStart() {\n      return inside || startIsBefore();\n    };\n    var shouldStop = function shouldStop() {\n      return !inside || endIsBefore();\n    };\n    for (var i = start, prev = start; i <= end; ++i) {\n      point = points[i % count];\n      if (point.skip) {\n        continue;\n      }\n      value = normalize(point[property]);\n      if (value === prevValue) {\n        continue;\n      }\n      inside = between(value, startBound, endBound);\n      if (subStart === null && shouldStart()) {\n        subStart = compare(value, startBound) === 0 ? i : prev;\n      }\n      if (subStart !== null && shouldStop()) {\n        result.push(normalizeSegment({\n          start: subStart,\n          end: i,\n          loop: loop,\n          count: count,\n          style: style\n        }));\n        subStart = null;\n      }\n      prev = i;\n      prevValue = value;\n    }\n    if (subStart !== null) {\n      result.push(normalizeSegment({\n        start: subStart,\n        end: end,\n        loop: loop,\n        count: count,\n        style: style\n      }));\n    }\n    return result;\n  }\n  function _boundSegments(line, bounds) {\n    var result = [];\n    var segments = line.segments;\n    for (var i = 0; i < segments.length; i++) {\n      var sub = _boundSegment(segments[i], line.points, bounds);\n      if (sub.length) {\n        result.push.apply(result, _toConsumableArray(sub));\n      }\n    }\n    return result;\n  }\n  function findStartAndEnd(points, count, loop, spanGaps) {\n    var start = 0;\n    var end = count - 1;\n    if (loop && !spanGaps) {\n      while (start < count && !points[start].skip) {\n        start++;\n      }\n    }\n    while (start < count && points[start].skip) {\n      start++;\n    }\n    start %= count;\n    if (loop) {\n      end += start;\n    }\n    while (end > start && points[end % count].skip) {\n      end--;\n    }\n    end %= count;\n    return {\n      start: start,\n      end: end\n    };\n  }\n  function solidSegments(points, start, max, loop) {\n    var count = points.length;\n    var result = [];\n    var last = start;\n    var prev = points[start];\n    var end;\n    for (end = start + 1; end <= max; ++end) {\n      var cur = points[end % count];\n      if (cur.skip || cur.stop) {\n        if (!prev.skip) {\n          loop = false;\n          result.push({\n            start: start % count,\n            end: (end - 1) % count,\n            loop: loop\n          });\n          start = last = cur.stop ? end : null;\n        }\n      } else {\n        last = end;\n        if (prev.skip) {\n          start = end;\n        }\n      }\n      prev = cur;\n    }\n    if (last !== null) {\n      result.push({\n        start: start % count,\n        end: last % count,\n        loop: loop\n      });\n    }\n    return result;\n  }\n  function _computeSegments(line, segmentOptions) {\n    var points = line.points;\n    var spanGaps = line.options.spanGaps;\n    var count = points.length;\n    if (!count) {\n      return [];\n    }\n    var loop = !!line._loop;\n    var _findStartAndEnd = findStartAndEnd(points, count, loop, spanGaps),\n      start = _findStartAndEnd.start,\n      end = _findStartAndEnd.end;\n    if (spanGaps === true) {\n      return splitByStyles(line, [{\n        start: start,\n        end: end,\n        loop: loop\n      }], points, segmentOptions);\n    }\n    var max = end < start ? end + count : end;\n    var completeLoop = !!line._fullLoop && start === 0 && end === count - 1;\n    return splitByStyles(line, solidSegments(points, start, max, completeLoop), points, segmentOptions);\n  }\n  function splitByStyles(line, segments, points, segmentOptions) {\n    if (!segmentOptions || !segmentOptions.setContext || !points) {\n      return segments;\n    }\n    return doSplitByStyles(line, segments, points, segmentOptions);\n  }\n  function doSplitByStyles(line, segments, points, segmentOptions) {\n    var chartContext = line._chart.getContext();\n    var baseStyle = readStyle(line.options);\n    var datasetIndex = line._datasetIndex,\n      spanGaps = line.options.spanGaps;\n    var count = points.length;\n    var result = [];\n    var prevStyle = baseStyle;\n    var start = segments[0].start;\n    var i = start;\n    function addStyle(s, e, l, st) {\n      var dir = spanGaps ? -1 : 1;\n      if (s === e) {\n        return;\n      }\n      s += count;\n      while (points[s % count].skip) {\n        s -= dir;\n      }\n      while (points[e % count].skip) {\n        e += dir;\n      }\n      if (s % count !== e % count) {\n        result.push({\n          start: s % count,\n          end: e % count,\n          loop: l,\n          style: st\n        });\n        prevStyle = st;\n        start = e % count;\n      }\n    }\n    var _iterator11 = _createForOfIteratorHelper$1(segments),\n      _step11;\n    try {\n      for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {\n        var segment = _step11.value;\n        start = spanGaps ? start : segment.start;\n        var prev = points[start % count];\n        var style = void 0;\n        for (i = start + 1; i <= segment.end; i++) {\n          var pt = points[i % count];\n          style = readStyle(segmentOptions.setContext(createContext(chartContext, {\n            type: 'segment',\n            p0: prev,\n            p1: pt,\n            p0DataIndex: (i - 1) % count,\n            p1DataIndex: i % count,\n            datasetIndex: datasetIndex\n          })));\n          if (styleChanged(style, prevStyle)) {\n            addStyle(start, i - 1, segment.loop, prevStyle);\n          }\n          prev = pt;\n          prevStyle = style;\n        }\n        if (start < i - 1) {\n          addStyle(start, i - 1, segment.loop, prevStyle);\n        }\n      }\n    } catch (err) {\n      _iterator11.e(err);\n    } finally {\n      _iterator11.f();\n    }\n    return result;\n  }\n  function readStyle(options) {\n    return {\n      backgroundColor: options.backgroundColor,\n      borderCapStyle: options.borderCapStyle,\n      borderDash: options.borderDash,\n      borderDashOffset: options.borderDashOffset,\n      borderJoinStyle: options.borderJoinStyle,\n      borderWidth: options.borderWidth,\n      borderColor: options.borderColor\n    };\n  }\n  function styleChanged(style, prevStyle) {\n    return prevStyle && JSON.stringify(style) !== JSON.stringify(prevStyle);\n  }\n\n  var Animator = /*#__PURE__*/function () {\n    function Animator() {\n      _classCallCheck$x(this, Animator);\n      this._request = null;\n      this._charts = new Map();\n      this._running = false;\n      this._lastDate = undefined;\n    }\n    _createClass$x(Animator, [{\n      key: \"_notify\",\n      value: function _notify(chart, anims, date, type) {\n        var callbacks = anims.listeners[type];\n        var numSteps = anims.duration;\n        callbacks.forEach(function (fn) {\n          return fn({\n            chart: chart,\n            initial: anims.initial,\n            numSteps: numSteps,\n            currentStep: Math.min(date - anims.start, numSteps)\n          });\n        });\n      }\n    }, {\n      key: \"_refresh\",\n      value: function _refresh() {\n        var _this = this;\n        if (this._request) {\n          return;\n        }\n        this._running = true;\n        this._request = requestAnimFrame.call(window, function () {\n          _this._update();\n          _this._request = null;\n          if (_this._running) {\n            _this._refresh();\n          }\n        });\n      }\n    }, {\n      key: \"_update\",\n      value: function _update() {\n        var _this2 = this;\n        var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Date.now();\n        var remaining = 0;\n        this._charts.forEach(function (anims, chart) {\n          if (!anims.running || !anims.items.length) {\n            return;\n          }\n          var items = anims.items;\n          var i = items.length - 1;\n          var draw = false;\n          var item;\n          for (; i >= 0; --i) {\n            item = items[i];\n            if (item._active) {\n              if (item._total > anims.duration) {\n                anims.duration = item._total;\n              }\n              item.tick(date);\n              draw = true;\n            } else {\n              items[i] = items[items.length - 1];\n              items.pop();\n            }\n          }\n          if (draw) {\n            chart.draw();\n            _this2._notify(chart, anims, date, 'progress');\n          }\n          if (!items.length) {\n            anims.running = false;\n            _this2._notify(chart, anims, date, 'complete');\n            anims.initial = false;\n          }\n          remaining += items.length;\n        });\n        this._lastDate = date;\n        if (remaining === 0) {\n          this._running = false;\n        }\n      }\n    }, {\n      key: \"_getAnims\",\n      value: function _getAnims(chart) {\n        var charts = this._charts;\n        var anims = charts.get(chart);\n        if (!anims) {\n          anims = {\n            running: false,\n            initial: true,\n            items: [],\n            listeners: {\n              complete: [],\n              progress: []\n            }\n          };\n          charts.set(chart, anims);\n        }\n        return anims;\n      }\n    }, {\n      key: \"listen\",\n      value: function listen(chart, event, cb) {\n        this._getAnims(chart).listeners[event].push(cb);\n      }\n    }, {\n      key: \"add\",\n      value: function add(chart, items) {\n        var _this$_getAnims$items;\n        if (!items || !items.length) {\n          return;\n        }\n        (_this$_getAnims$items = this._getAnims(chart).items).push.apply(_this$_getAnims$items, _toConsumableArray(items));\n      }\n    }, {\n      key: \"has\",\n      value: function has(chart) {\n        return this._getAnims(chart).items.length > 0;\n      }\n    }, {\n      key: \"start\",\n      value: function start(chart) {\n        var anims = this._charts.get(chart);\n        if (!anims) {\n          return;\n        }\n        anims.running = true;\n        anims.start = Date.now();\n        anims.duration = anims.items.reduce(function (acc, cur) {\n          return Math.max(acc, cur._duration);\n        }, 0);\n        this._refresh();\n      }\n    }, {\n      key: \"running\",\n      value: function running(chart) {\n        if (!this._running) {\n          return false;\n        }\n        var anims = this._charts.get(chart);\n        if (!anims || !anims.running || !anims.items.length) {\n          return false;\n        }\n        return true;\n      }\n    }, {\n      key: \"stop\",\n      value: function stop(chart) {\n        var anims = this._charts.get(chart);\n        if (!anims || !anims.items.length) {\n          return;\n        }\n        var items = anims.items;\n        var i = items.length - 1;\n        for (; i >= 0; --i) {\n          items[i].cancel();\n        }\n        anims.items = [];\n        this._notify(chart, anims, Date.now(), 'complete');\n      }\n    }, {\n      key: \"remove\",\n      value: function remove(chart) {\n        return this._charts[\"delete\"](chart);\n      }\n    }]);\n    return Animator;\n  }();\n  var animator = /* #__PURE__ */new Animator();\n  var transparent = 'transparent';\n  var interpolators = {\n    \"boolean\": function boolean(from, to, factor) {\n      return factor > 0.5 ? to : from;\n    },\n    color: function color$1(from, to, factor) {\n      var c0 = color(from || transparent);\n      var c1 = c0.valid && color(to || transparent);\n      return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to;\n    },\n    number: function number(from, to, factor) {\n      return from + (to - from) * factor;\n    }\n  };\n  var Animation = /*#__PURE__*/function () {\n    function Animation(cfg, target, prop, to) {\n      _classCallCheck$x(this, Animation);\n      var currentValue = target[prop];\n      to = resolve([cfg.to, to, currentValue, cfg.from]);\n      var from = resolve([cfg.from, currentValue, to]);\n      this._active = true;\n      this._fn = cfg.fn || interpolators[cfg.type || _typeof$z(from)];\n      this._easing = effects[cfg.easing] || effects.linear;\n      this._start = Math.floor(Date.now() + (cfg.delay || 0));\n      this._duration = this._total = Math.floor(cfg.duration);\n      this._loop = !!cfg.loop;\n      this._target = target;\n      this._prop = prop;\n      this._from = from;\n      this._to = to;\n      this._promises = undefined;\n    }\n    _createClass$x(Animation, [{\n      key: \"active\",\n      value: function active() {\n        return this._active;\n      }\n    }, {\n      key: \"update\",\n      value: function update(cfg, to, date) {\n        if (this._active) {\n          this._notify(false);\n          var currentValue = this._target[this._prop];\n          var elapsed = date - this._start;\n          var remain = this._duration - elapsed;\n          this._start = date;\n          this._duration = Math.floor(Math.max(remain, cfg.duration));\n          this._total += elapsed;\n          this._loop = !!cfg.loop;\n          this._to = resolve([cfg.to, to, currentValue, cfg.from]);\n          this._from = resolve([cfg.from, currentValue, to]);\n        }\n      }\n    }, {\n      key: \"cancel\",\n      value: function cancel() {\n        if (this._active) {\n          this.tick(Date.now());\n          this._active = false;\n          this._notify(false);\n        }\n      }\n    }, {\n      key: \"tick\",\n      value: function tick(date) {\n        var elapsed = date - this._start;\n        var duration = this._duration;\n        var prop = this._prop;\n        var from = this._from;\n        var loop = this._loop;\n        var to = this._to;\n        var factor;\n        this._active = from !== to && (loop || elapsed < duration);\n        if (!this._active) {\n          this._target[prop] = to;\n          this._notify(true);\n          return;\n        }\n        if (elapsed < 0) {\n          this._target[prop] = from;\n          return;\n        }\n        factor = elapsed / duration % 2;\n        factor = loop && factor > 1 ? 2 - factor : factor;\n        factor = this._easing(Math.min(1, Math.max(0, factor)));\n        this._target[prop] = this._fn(from, to, factor);\n      }\n    }, {\n      key: \"wait\",\n      value: function wait() {\n        var promises = this._promises || (this._promises = []);\n        return new Promise(function (res, rej) {\n          promises.push({\n            res: res,\n            rej: rej\n          });\n        });\n      }\n    }, {\n      key: \"_notify\",\n      value: function _notify(resolved) {\n        var method = resolved ? 'res' : 'rej';\n        var promises = this._promises || [];\n        for (var i = 0; i < promises.length; i++) {\n          promises[i][method]();\n        }\n      }\n    }]);\n    return Animation;\n  }();\n  var Animations = /*#__PURE__*/function () {\n    function Animations(chart, config) {\n      _classCallCheck$x(this, Animations);\n      this._chart = chart;\n      this._properties = new Map();\n      this.configure(config);\n    }\n    _createClass$x(Animations, [{\n      key: \"configure\",\n      value: function configure(config) {\n        if (!isObject(config)) {\n          return;\n        }\n        var animationOptions = Object.keys(defaults.animation);\n        var animatedProps = this._properties;\n        Object.getOwnPropertyNames(config).forEach(function (key) {\n          var cfg = config[key];\n          if (!isObject(cfg)) {\n            return;\n          }\n          var resolved = {};\n          for (var _i = 0, _animationOptions = animationOptions; _i < _animationOptions.length; _i++) {\n            var option = _animationOptions[_i];\n            resolved[option] = cfg[option];\n          }\n          (isArray(cfg.properties) && cfg.properties || [key]).forEach(function (prop) {\n            if (prop === key || !animatedProps.has(prop)) {\n              animatedProps.set(prop, resolved);\n            }\n          });\n        });\n      }\n    }, {\n      key: \"_animateOptions\",\n      value: function _animateOptions(target, values) {\n        var newOptions = values.options;\n        var options = resolveTargetOptions(target, newOptions);\n        if (!options) {\n          return [];\n        }\n        var animations = this._createAnimations(options, newOptions);\n        if (newOptions.$shared) {\n          awaitAll(target.options.$animations, newOptions).then(function () {\n            target.options = newOptions;\n          }, function () {});\n        }\n        return animations;\n      }\n    }, {\n      key: \"_createAnimations\",\n      value: function _createAnimations(target, values) {\n        var animatedProps = this._properties;\n        var animations = [];\n        var running = target.$animations || (target.$animations = {});\n        var props = Object.keys(values);\n        var date = Date.now();\n        var i;\n        for (i = props.length - 1; i >= 0; --i) {\n          var prop = props[i];\n          if (prop.charAt(0) === '$') {\n            continue;\n          }\n          if (prop === 'options') {\n            animations.push.apply(animations, _toConsumableArray(this._animateOptions(target, values)));\n            continue;\n          }\n          var value = values[prop];\n          var animation = running[prop];\n          var cfg = animatedProps.get(prop);\n          if (animation) {\n            if (cfg && animation.active()) {\n              animation.update(cfg, value, date);\n              continue;\n            } else {\n              animation.cancel();\n            }\n          }\n          if (!cfg || !cfg.duration) {\n            target[prop] = value;\n            continue;\n          }\n          running[prop] = animation = new Animation(cfg, target, prop, value);\n          animations.push(animation);\n        }\n        return animations;\n      }\n    }, {\n      key: \"update\",\n      value: function update(target, values) {\n        if (this._properties.size === 0) {\n          Object.assign(target, values);\n          return;\n        }\n        var animations = this._createAnimations(target, values);\n        if (animations.length) {\n          animator.add(this._chart, animations);\n          return true;\n        }\n      }\n    }]);\n    return Animations;\n  }();\n  function awaitAll(animations, properties) {\n    var running = [];\n    var keys = Object.keys(properties);\n    for (var i = 0; i < keys.length; i++) {\n      var anim = animations[keys[i]];\n      if (anim && anim.active()) {\n        running.push(anim.wait());\n      }\n    }\n    return Promise.all(running);\n  }\n  function resolveTargetOptions(target, newOptions) {\n    if (!newOptions) {\n      return;\n    }\n    var options = target.options;\n    if (!options) {\n      target.options = newOptions;\n      return;\n    }\n    if (options.$shared) {\n      target.options = options = Object.assign({}, options, {\n        $shared: false,\n        $animations: {}\n      });\n    }\n    return options;\n  }\n  function scaleClip(scale, allowedOverflow) {\n    var opts = scale && scale.options || {};\n    var reverse = opts.reverse;\n    var min = opts.min === undefined ? allowedOverflow : 0;\n    var max = opts.max === undefined ? allowedOverflow : 0;\n    return {\n      start: reverse ? max : min,\n      end: reverse ? min : max\n    };\n  }\n  function defaultClip(xScale, yScale, allowedOverflow) {\n    if (allowedOverflow === false) {\n      return false;\n    }\n    var x = scaleClip(xScale, allowedOverflow);\n    var y = scaleClip(yScale, allowedOverflow);\n    return {\n      top: y.end,\n      right: x.end,\n      bottom: y.start,\n      left: x.start\n    };\n  }\n  function toClip(value) {\n    var t, r, b, l;\n    if (isObject(value)) {\n      t = value.top;\n      r = value.right;\n      b = value.bottom;\n      l = value.left;\n    } else {\n      t = r = b = l = value;\n    }\n    return {\n      top: t,\n      right: r,\n      bottom: b,\n      left: l,\n      disabled: value === false\n    };\n  }\n  function getSortedDatasetIndices(chart, filterVisible) {\n    var keys = [];\n    var metasets = chart._getSortedDatasetMetas(filterVisible);\n    var i, ilen;\n    for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n      keys.push(metasets[i].index);\n    }\n    return keys;\n  }\n  function _applyStack(stack, value, dsIndex) {\n    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n    var keys = stack.keys;\n    var singleMode = options.mode === 'single';\n    var i, ilen, datasetIndex, otherValue;\n    if (value === null) {\n      return;\n    }\n    for (i = 0, ilen = keys.length; i < ilen; ++i) {\n      datasetIndex = +keys[i];\n      if (datasetIndex === dsIndex) {\n        if (options.all) {\n          continue;\n        }\n        break;\n      }\n      otherValue = stack.values[datasetIndex];\n      if (isNumberFinite(otherValue) && (singleMode || value === 0 || sign(value) === sign(otherValue))) {\n        value += otherValue;\n      }\n    }\n    return value;\n  }\n  function convertObjectDataToArray(data) {\n    var keys = Object.keys(data);\n    var adata = new Array(keys.length);\n    var i, ilen, key;\n    for (i = 0, ilen = keys.length; i < ilen; ++i) {\n      key = keys[i];\n      adata[i] = {\n        x: key,\n        y: data[key]\n      };\n    }\n    return adata;\n  }\n  function isStacked(scale, meta) {\n    var stacked = scale && scale.options.stacked;\n    return stacked || stacked === undefined && meta.stack !== undefined;\n  }\n  function getStackKey(indexScale, valueScale, meta) {\n    return \"\".concat(indexScale.id, \".\").concat(valueScale.id, \".\").concat(meta.stack || meta.type);\n  }\n  function getUserBounds(scale) {\n    var _scale$getUserBounds = scale.getUserBounds(),\n      min = _scale$getUserBounds.min,\n      max = _scale$getUserBounds.max,\n      minDefined = _scale$getUserBounds.minDefined,\n      maxDefined = _scale$getUserBounds.maxDefined;\n    return {\n      min: minDefined ? min : Number.NEGATIVE_INFINITY,\n      max: maxDefined ? max : Number.POSITIVE_INFINITY\n    };\n  }\n  function getOrCreateStack(stacks, stackKey, indexValue) {\n    var subStack = stacks[stackKey] || (stacks[stackKey] = {});\n    return subStack[indexValue] || (subStack[indexValue] = {});\n  }\n  function getLastIndexInStack(stack, vScale, positive, type) {\n    var _iterator = _createForOfIteratorHelper$1(vScale.getMatchingVisibleMetas(type).reverse()),\n      _step;\n    try {\n      for (_iterator.s(); !(_step = _iterator.n()).done;) {\n        var meta = _step.value;\n        var value = stack[meta.index];\n        if (positive && value > 0 || !positive && value < 0) {\n          return meta.index;\n        }\n      }\n    } catch (err) {\n      _iterator.e(err);\n    } finally {\n      _iterator.f();\n    }\n    return null;\n  }\n  function updateStacks(controller, parsed) {\n    var chart = controller.chart,\n      meta = controller._cachedMeta;\n    var stacks = chart._stacks || (chart._stacks = {});\n    var iScale = meta.iScale,\n      vScale = meta.vScale,\n      datasetIndex = meta.index;\n    var iAxis = iScale.axis;\n    var vAxis = vScale.axis;\n    var key = getStackKey(iScale, vScale, meta);\n    var ilen = parsed.length;\n    var stack;\n    for (var i = 0; i < ilen; ++i) {\n      var item = parsed[i];\n      var _index = item[iAxis],\n        value = item[vAxis];\n      var itemStacks = item._stacks || (item._stacks = {});\n      stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, _index);\n      stack[datasetIndex] = value;\n      stack._top = getLastIndexInStack(stack, vScale, true, meta.type);\n      stack._bottom = getLastIndexInStack(stack, vScale, false, meta.type);\n      var visualValues = stack._visualValues || (stack._visualValues = {});\n      visualValues[datasetIndex] = value;\n    }\n  }\n  function getFirstScaleId(chart, axis) {\n    var scales = chart.scales;\n    return Object.keys(scales).filter(function (key) {\n      return scales[key].axis === axis;\n    }).shift();\n  }\n  function createDatasetContext(parent, index) {\n    return createContext(parent, {\n      active: false,\n      dataset: undefined,\n      datasetIndex: index,\n      index: index,\n      mode: 'default',\n      type: 'dataset'\n    });\n  }\n  function createDataContext(parent, index, element) {\n    return createContext(parent, {\n      active: false,\n      dataIndex: index,\n      parsed: undefined,\n      raw: undefined,\n      element: element,\n      index: index,\n      mode: 'default',\n      type: 'data'\n    });\n  }\n  function clearStacks(meta, items) {\n    var datasetIndex = meta.controller.index;\n    var axis = meta.vScale && meta.vScale.axis;\n    if (!axis) {\n      return;\n    }\n    items = items || meta._parsed;\n    var _iterator2 = _createForOfIteratorHelper$1(items),\n      _step2;\n    try {\n      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n        var parsed = _step2.value;\n        var stacks = parsed._stacks;\n        if (!stacks || stacks[axis] === undefined || stacks[axis][datasetIndex] === undefined) {\n          return;\n        }\n        delete stacks[axis][datasetIndex];\n        if (stacks[axis]._visualValues !== undefined && stacks[axis]._visualValues[datasetIndex] !== undefined) {\n          delete stacks[axis]._visualValues[datasetIndex];\n        }\n      }\n    } catch (err) {\n      _iterator2.e(err);\n    } finally {\n      _iterator2.f();\n    }\n  }\n  var isDirectUpdateMode = function isDirectUpdateMode(mode) {\n    return mode === 'reset' || mode === 'none';\n  };\n  var cloneIfNotShared = function cloneIfNotShared(cached, shared) {\n    return shared ? cached : Object.assign({}, cached);\n  };\n  var createStack = function createStack(canStack, meta, chart) {\n    return canStack && !meta.hidden && meta._stacked && {\n      keys: getSortedDatasetIndices(chart, true),\n      values: null\n    };\n  };\n  var DatasetController = /*#__PURE__*/function () {\n    function DatasetController(chart, datasetIndex) {\n      _classCallCheck$x(this, DatasetController);\n      this.chart = chart;\n      this._ctx = chart.ctx;\n      this.index = datasetIndex;\n      this._cachedDataOpts = {};\n      this._cachedMeta = this.getMeta();\n      this._type = this._cachedMeta.type;\n      this.options = undefined;\n      this._parsing = false;\n      this._data = undefined;\n      this._objectData = undefined;\n      this._sharedOptions = undefined;\n      this._drawStart = undefined;\n      this._drawCount = undefined;\n      this.enableOptionSharing = false;\n      this.supportsDecimation = false;\n      this.$context = undefined;\n      this._syncList = [];\n      this.datasetElementType = (this instanceof DatasetController ? this.constructor : void 0).datasetElementType;\n      this.dataElementType = (this instanceof DatasetController ? this.constructor : void 0).dataElementType;\n      this.initialize();\n    }\n    _createClass$x(DatasetController, [{\n      key: \"initialize\",\n      value: function initialize() {\n        var meta = this._cachedMeta;\n        this.configure();\n        this.linkScales();\n        meta._stacked = isStacked(meta.vScale, meta);\n        this.addElements();\n        if (this.options.fill && !this.chart.isPluginEnabled('filler')) {\n          console.warn(\"Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options\");\n        }\n      }\n    }, {\n      key: \"updateIndex\",\n      value: function updateIndex(datasetIndex) {\n        if (this.index !== datasetIndex) {\n          clearStacks(this._cachedMeta);\n        }\n        this.index = datasetIndex;\n      }\n    }, {\n      key: \"linkScales\",\n      value: function linkScales() {\n        var chart = this.chart;\n        var meta = this._cachedMeta;\n        var dataset = this.getDataset();\n        var chooseId = function chooseId(axis, x, y, r) {\n          return axis === 'x' ? x : axis === 'r' ? r : y;\n        };\n        var xid = meta.xAxisID = valueOrDefault(dataset.xAxisID, getFirstScaleId(chart, 'x'));\n        var yid = meta.yAxisID = valueOrDefault(dataset.yAxisID, getFirstScaleId(chart, 'y'));\n        var rid = meta.rAxisID = valueOrDefault(dataset.rAxisID, getFirstScaleId(chart, 'r'));\n        var indexAxis = meta.indexAxis;\n        var iid = meta.iAxisID = chooseId(indexAxis, xid, yid, rid);\n        var vid = meta.vAxisID = chooseId(indexAxis, yid, xid, rid);\n        meta.xScale = this.getScaleForId(xid);\n        meta.yScale = this.getScaleForId(yid);\n        meta.rScale = this.getScaleForId(rid);\n        meta.iScale = this.getScaleForId(iid);\n        meta.vScale = this.getScaleForId(vid);\n      }\n    }, {\n      key: \"getDataset\",\n      value: function getDataset() {\n        return this.chart.data.datasets[this.index];\n      }\n    }, {\n      key: \"getMeta\",\n      value: function getMeta() {\n        return this.chart.getDatasetMeta(this.index);\n      }\n    }, {\n      key: \"getScaleForId\",\n      value: function getScaleForId(scaleID) {\n        return this.chart.scales[scaleID];\n      }\n    }, {\n      key: \"_getOtherScale\",\n      value: function _getOtherScale(scale) {\n        var meta = this._cachedMeta;\n        return scale === meta.iScale ? meta.vScale : meta.iScale;\n      }\n    }, {\n      key: \"reset\",\n      value: function reset() {\n        this._update('reset');\n      }\n    }, {\n      key: \"_destroy\",\n      value: function _destroy() {\n        var meta = this._cachedMeta;\n        if (this._data) {\n          unlistenArrayEvents(this._data, this);\n        }\n        if (meta._stacked) {\n          clearStacks(meta);\n        }\n      }\n    }, {\n      key: \"_dataCheck\",\n      value: function _dataCheck() {\n        var dataset = this.getDataset();\n        var data = dataset.data || (dataset.data = []);\n        var _data = this._data;\n        if (isObject(data)) {\n          this._data = convertObjectDataToArray(data);\n        } else if (_data !== data) {\n          if (_data) {\n            unlistenArrayEvents(_data, this);\n            var meta = this._cachedMeta;\n            clearStacks(meta);\n            meta._parsed = [];\n          }\n          if (data && Object.isExtensible(data)) {\n            listenArrayEvents(data, this);\n          }\n          this._syncList = [];\n          this._data = data;\n        }\n      }\n    }, {\n      key: \"addElements\",\n      value: function addElements() {\n        var meta = this._cachedMeta;\n        this._dataCheck();\n        if (this.datasetElementType) {\n          meta.dataset = new this.datasetElementType();\n        }\n      }\n    }, {\n      key: \"buildOrUpdateElements\",\n      value: function buildOrUpdateElements(resetNewElements) {\n        var meta = this._cachedMeta;\n        var dataset = this.getDataset();\n        var stackChanged = false;\n        this._dataCheck();\n        var oldStacked = meta._stacked;\n        meta._stacked = isStacked(meta.vScale, meta);\n        if (meta.stack !== dataset.stack) {\n          stackChanged = true;\n          clearStacks(meta);\n          meta.stack = dataset.stack;\n        }\n        this._resyncElements(resetNewElements);\n        if (stackChanged || oldStacked !== meta._stacked) {\n          updateStacks(this, meta._parsed);\n        }\n      }\n    }, {\n      key: \"configure\",\n      value: function configure() {\n        var config = this.chart.config;\n        var scopeKeys = config.datasetScopeKeys(this._type);\n        var scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true);\n        this.options = config.createResolver(scopes, this.getContext());\n        this._parsing = this.options.parsing;\n        this._cachedDataOpts = {};\n      }\n    }, {\n      key: \"parse\",\n      value: function parse(start, count) {\n        var meta = this._cachedMeta,\n          data = this._data;\n        var iScale = meta.iScale,\n          _stacked = meta._stacked;\n        var iAxis = iScale.axis;\n        var sorted = start === 0 && count === data.length ? true : meta._sorted;\n        var prev = start > 0 && meta._parsed[start - 1];\n        var i, cur, parsed;\n        if (this._parsing === false) {\n          meta._parsed = data;\n          meta._sorted = true;\n          parsed = data;\n        } else {\n          if (isArray(data[start])) {\n            parsed = this.parseArrayData(meta, data, start, count);\n          } else if (isObject(data[start])) {\n            parsed = this.parseObjectData(meta, data, start, count);\n          } else {\n            parsed = this.parsePrimitiveData(meta, data, start, count);\n          }\n          var isNotInOrderComparedToPrev = function isNotInOrderComparedToPrev() {\n            return cur[iAxis] === null || prev && cur[iAxis] < prev[iAxis];\n          };\n          for (i = 0; i < count; ++i) {\n            meta._parsed[i + start] = cur = parsed[i];\n            if (sorted) {\n              if (isNotInOrderComparedToPrev()) {\n                sorted = false;\n              }\n              prev = cur;\n            }\n          }\n          meta._sorted = sorted;\n        }\n        if (_stacked) {\n          updateStacks(this, parsed);\n        }\n      }\n    }, {\n      key: \"parsePrimitiveData\",\n      value: function parsePrimitiveData(meta, data, start, count) {\n        var iScale = meta.iScale,\n          vScale = meta.vScale;\n        var iAxis = iScale.axis;\n        var vAxis = vScale.axis;\n        var labels = iScale.getLabels();\n        var singleScale = iScale === vScale;\n        var parsed = new Array(count);\n        var i, ilen, index;\n        for (i = 0, ilen = count; i < ilen; ++i) {\n          var _parsed$i;\n          index = i + start;\n          parsed[i] = (_parsed$i = {}, _defineProperty$w(_parsed$i, iAxis, singleScale || iScale.parse(labels[index], index)), _defineProperty$w(_parsed$i, vAxis, vScale.parse(data[index], index)), _parsed$i);\n        }\n        return parsed;\n      }\n    }, {\n      key: \"parseArrayData\",\n      value: function parseArrayData(meta, data, start, count) {\n        var xScale = meta.xScale,\n          yScale = meta.yScale;\n        var parsed = new Array(count);\n        var i, ilen, index, item;\n        for (i = 0, ilen = count; i < ilen; ++i) {\n          index = i + start;\n          item = data[index];\n          parsed[i] = {\n            x: xScale.parse(item[0], index),\n            y: yScale.parse(item[1], index)\n          };\n        }\n        return parsed;\n      }\n    }, {\n      key: \"parseObjectData\",\n      value: function parseObjectData(meta, data, start, count) {\n        var xScale = meta.xScale,\n          yScale = meta.yScale;\n        var _this$_parsing = this._parsing,\n          _this$_parsing$xAxisK = _this$_parsing.xAxisKey,\n          xAxisKey = _this$_parsing$xAxisK === void 0 ? 'x' : _this$_parsing$xAxisK,\n          _this$_parsing$yAxisK = _this$_parsing.yAxisKey,\n          yAxisKey = _this$_parsing$yAxisK === void 0 ? 'y' : _this$_parsing$yAxisK;\n        var parsed = new Array(count);\n        var i, ilen, index, item;\n        for (i = 0, ilen = count; i < ilen; ++i) {\n          index = i + start;\n          item = data[index];\n          parsed[i] = {\n            x: xScale.parse(resolveObjectKey(item, xAxisKey), index),\n            y: yScale.parse(resolveObjectKey(item, yAxisKey), index)\n          };\n        }\n        return parsed;\n      }\n    }, {\n      key: \"getParsed\",\n      value: function getParsed(index) {\n        return this._cachedMeta._parsed[index];\n      }\n    }, {\n      key: \"getDataElement\",\n      value: function getDataElement(index) {\n        return this._cachedMeta.data[index];\n      }\n    }, {\n      key: \"applyStack\",\n      value: function applyStack(scale, parsed, mode) {\n        var chart = this.chart;\n        var meta = this._cachedMeta;\n        var value = parsed[scale.axis];\n        var stack = {\n          keys: getSortedDatasetIndices(chart, true),\n          values: parsed._stacks[scale.axis]._visualValues\n        };\n        return _applyStack(stack, value, meta.index, {\n          mode: mode\n        });\n      }\n    }, {\n      key: \"updateRangeFromParsed\",\n      value: function updateRangeFromParsed(range, scale, parsed, stack) {\n        var parsedValue = parsed[scale.axis];\n        var value = parsedValue === null ? NaN : parsedValue;\n        var values = stack && parsed._stacks[scale.axis];\n        if (stack && values) {\n          stack.values = values;\n          value = _applyStack(stack, parsedValue, this._cachedMeta.index);\n        }\n        range.min = Math.min(range.min, value);\n        range.max = Math.max(range.max, value);\n      }\n    }, {\n      key: \"getMinMax\",\n      value: function getMinMax(scale, canStack) {\n        var meta = this._cachedMeta;\n        var _parsed = meta._parsed;\n        var sorted = meta._sorted && scale === meta.iScale;\n        var ilen = _parsed.length;\n        var otherScale = this._getOtherScale(scale);\n        var stack = createStack(canStack, meta, this.chart);\n        var range = {\n          min: Number.POSITIVE_INFINITY,\n          max: Number.NEGATIVE_INFINITY\n        };\n        var _getUserBounds = getUserBounds(otherScale),\n          otherMin = _getUserBounds.min,\n          otherMax = _getUserBounds.max;\n        var i, parsed;\n        function _skip() {\n          parsed = _parsed[i];\n          var otherValue = parsed[otherScale.axis];\n          return !isNumberFinite(parsed[scale.axis]) || otherMin > otherValue || otherMax < otherValue;\n        }\n        for (i = 0; i < ilen; ++i) {\n          if (_skip()) {\n            continue;\n          }\n          this.updateRangeFromParsed(range, scale, parsed, stack);\n          if (sorted) {\n            break;\n          }\n        }\n        if (sorted) {\n          for (i = ilen - 1; i >= 0; --i) {\n            if (_skip()) {\n              continue;\n            }\n            this.updateRangeFromParsed(range, scale, parsed, stack);\n            break;\n          }\n        }\n        return range;\n      }\n    }, {\n      key: \"getAllParsedValues\",\n      value: function getAllParsedValues(scale) {\n        var parsed = this._cachedMeta._parsed;\n        var values = [];\n        var i, ilen, value;\n        for (i = 0, ilen = parsed.length; i < ilen; ++i) {\n          value = parsed[i][scale.axis];\n          if (isNumberFinite(value)) {\n            values.push(value);\n          }\n        }\n        return values;\n      }\n    }, {\n      key: \"getMaxOverflow\",\n      value: function getMaxOverflow() {\n        return false;\n      }\n    }, {\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var iScale = meta.iScale;\n        var vScale = meta.vScale;\n        var parsed = this.getParsed(index);\n        return {\n          label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '',\n          value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : ''\n        };\n      }\n    }, {\n      key: \"_update\",\n      value: function _update(mode) {\n        var meta = this._cachedMeta;\n        this.update(mode || 'default');\n        meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow())));\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {}\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        var ctx = this._ctx;\n        var chart = this.chart;\n        var meta = this._cachedMeta;\n        var elements = meta.data || [];\n        var area = chart.chartArea;\n        var active = [];\n        var start = this._drawStart || 0;\n        var count = this._drawCount || elements.length - start;\n        var drawActiveElementsOnTop = this.options.drawActiveElementsOnTop;\n        var i;\n        if (meta.dataset) {\n          meta.dataset.draw(ctx, area, start, count);\n        }\n        for (i = start; i < start + count; ++i) {\n          var element = elements[i];\n          if (element.hidden) {\n            continue;\n          }\n          if (element.active && drawActiveElementsOnTop) {\n            active.push(element);\n          } else {\n            element.draw(ctx, area);\n          }\n        }\n        for (i = 0; i < active.length; ++i) {\n          active[i].draw(ctx, area);\n        }\n      }\n    }, {\n      key: \"getStyle\",\n      value: function getStyle(index, active) {\n        var mode = active ? 'active' : 'default';\n        return index === undefined && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(mode) : this.resolveDataElementOptions(index || 0, mode);\n      }\n    }, {\n      key: \"getContext\",\n      value: function getContext(index, active, mode) {\n        var dataset = this.getDataset();\n        var context;\n        if (index >= 0 && index < this._cachedMeta.data.length) {\n          var element = this._cachedMeta.data[index];\n          context = element.$context || (element.$context = createDataContext(this.getContext(), index, element));\n          context.parsed = this.getParsed(index);\n          context.raw = dataset.data[index];\n          context.index = context.dataIndex = index;\n        } else {\n          context = this.$context || (this.$context = createDatasetContext(this.chart.getContext(), this.index));\n          context.dataset = dataset;\n          context.index = context.datasetIndex = this.index;\n        }\n        context.active = !!active;\n        context.mode = mode;\n        return context;\n      }\n    }, {\n      key: \"resolveDatasetElementOptions\",\n      value: function resolveDatasetElementOptions(mode) {\n        return this._resolveElementOptions(this.datasetElementType.id, mode);\n      }\n    }, {\n      key: \"resolveDataElementOptions\",\n      value: function resolveDataElementOptions(index, mode) {\n        return this._resolveElementOptions(this.dataElementType.id, mode, index);\n      }\n    }, {\n      key: \"_resolveElementOptions\",\n      value: function _resolveElementOptions(elementType) {\n        var _this3 = this;\n        var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';\n        var index = arguments.length > 2 ? arguments[2] : undefined;\n        var active = mode === 'active';\n        var cache = this._cachedDataOpts;\n        var cacheKey = elementType + '-' + mode;\n        var cached = cache[cacheKey];\n        var sharing = this.enableOptionSharing && defined(index);\n        if (cached) {\n          return cloneIfNotShared(cached, sharing);\n        }\n        var config = this.chart.config;\n        var scopeKeys = config.datasetElementScopeKeys(this._type, elementType);\n        var prefixes = active ? [\"\".concat(elementType, \"Hover\"), 'hover', elementType, ''] : [elementType, ''];\n        var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n        var names = Object.keys(defaults.elements[elementType]);\n        var context = function context() {\n          return _this3.getContext(index, active, mode);\n        };\n        var values = config.resolveNamedOptions(scopes, names, context, prefixes);\n        if (values.$shared) {\n          values.$shared = sharing;\n          cache[cacheKey] = Object.freeze(cloneIfNotShared(values, sharing));\n        }\n        return values;\n      }\n    }, {\n      key: \"_resolveAnimations\",\n      value: function _resolveAnimations(index, transition, active) {\n        var chart = this.chart;\n        var cache = this._cachedDataOpts;\n        var cacheKey = \"animation-\".concat(transition);\n        var cached = cache[cacheKey];\n        if (cached) {\n          return cached;\n        }\n        var options;\n        if (chart.options.animation !== false) {\n          var config = this.chart.config;\n          var scopeKeys = config.datasetAnimationScopeKeys(this._type, transition);\n          var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n          options = config.createResolver(scopes, this.getContext(index, active, transition));\n        }\n        var animations = new Animations(chart, options && options.animations);\n        if (options && options._cacheable) {\n          cache[cacheKey] = Object.freeze(animations);\n        }\n        return animations;\n      }\n    }, {\n      key: \"getSharedOptions\",\n      value: function getSharedOptions(options) {\n        if (!options.$shared) {\n          return;\n        }\n        return this._sharedOptions || (this._sharedOptions = Object.assign({}, options));\n      }\n    }, {\n      key: \"includeOptions\",\n      value: function includeOptions(mode, sharedOptions) {\n        return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled;\n      }\n    }, {\n      key: \"_getSharedOptions\",\n      value: function _getSharedOptions(start, mode) {\n        var firstOpts = this.resolveDataElementOptions(start, mode);\n        var previouslySharedOptions = this._sharedOptions;\n        var sharedOptions = this.getSharedOptions(firstOpts);\n        var includeOptions = this.includeOptions(mode, sharedOptions) || sharedOptions !== previouslySharedOptions;\n        this.updateSharedOptions(sharedOptions, mode, firstOpts);\n        return {\n          sharedOptions: sharedOptions,\n          includeOptions: includeOptions\n        };\n      }\n    }, {\n      key: \"updateElement\",\n      value: function updateElement(element, index, properties, mode) {\n        if (isDirectUpdateMode(mode)) {\n          Object.assign(element, properties);\n        } else {\n          this._resolveAnimations(index, mode).update(element, properties);\n        }\n      }\n    }, {\n      key: \"updateSharedOptions\",\n      value: function updateSharedOptions(sharedOptions, mode, newOptions) {\n        if (sharedOptions && !isDirectUpdateMode(mode)) {\n          this._resolveAnimations(undefined, mode).update(sharedOptions, newOptions);\n        }\n      }\n    }, {\n      key: \"_setStyle\",\n      value: function _setStyle(element, index, mode, active) {\n        element.active = active;\n        var options = this.getStyle(index, active);\n        this._resolveAnimations(index, mode, active).update(element, {\n          options: !active && this.getSharedOptions(options) || options\n        });\n      }\n    }, {\n      key: \"removeHoverStyle\",\n      value: function removeHoverStyle(element, datasetIndex, index) {\n        this._setStyle(element, index, 'active', false);\n      }\n    }, {\n      key: \"setHoverStyle\",\n      value: function setHoverStyle(element, datasetIndex, index) {\n        this._setStyle(element, index, 'active', true);\n      }\n    }, {\n      key: \"_removeDatasetHoverStyle\",\n      value: function _removeDatasetHoverStyle() {\n        var element = this._cachedMeta.dataset;\n        if (element) {\n          this._setStyle(element, undefined, 'active', false);\n        }\n      }\n    }, {\n      key: \"_setDatasetHoverStyle\",\n      value: function _setDatasetHoverStyle() {\n        var element = this._cachedMeta.dataset;\n        if (element) {\n          this._setStyle(element, undefined, 'active', true);\n        }\n      }\n    }, {\n      key: \"_resyncElements\",\n      value: function _resyncElements(resetNewElements) {\n        var data = this._data;\n        var elements = this._cachedMeta.data;\n        var _iterator3 = _createForOfIteratorHelper$1(this._syncList),\n          _step3;\n        try {\n          for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n            var _step3$value = _slicedToArray(_step3.value, 3),\n              method = _step3$value[0],\n              arg1 = _step3$value[1],\n              arg2 = _step3$value[2];\n            this[method](arg1, arg2);\n          }\n        } catch (err) {\n          _iterator3.e(err);\n        } finally {\n          _iterator3.f();\n        }\n        this._syncList = [];\n        var numMeta = elements.length;\n        var numData = data.length;\n        var count = Math.min(numData, numMeta);\n        if (count) {\n          this.parse(0, count);\n        }\n        if (numData > numMeta) {\n          this._insertElements(numMeta, numData - numMeta, resetNewElements);\n        } else if (numData < numMeta) {\n          this._removeElements(numData, numMeta - numData);\n        }\n      }\n    }, {\n      key: \"_insertElements\",\n      value: function _insertElements(start, count) {\n        var resetNewElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n        var meta = this._cachedMeta;\n        var data = meta.data;\n        var end = start + count;\n        var i;\n        var move = function move(arr) {\n          arr.length += count;\n          for (i = arr.length - 1; i >= end; i--) {\n            arr[i] = arr[i - count];\n          }\n        };\n        move(data);\n        for (i = start; i < end; ++i) {\n          data[i] = new this.dataElementType();\n        }\n        if (this._parsing) {\n          move(meta._parsed);\n        }\n        this.parse(start, count);\n        if (resetNewElements) {\n          this.updateElements(data, start, count, 'reset');\n        }\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(element, start, count, mode) {}\n    }, {\n      key: \"_removeElements\",\n      value: function _removeElements(start, count) {\n        var meta = this._cachedMeta;\n        if (this._parsing) {\n          var removed = meta._parsed.splice(start, count);\n          if (meta._stacked) {\n            clearStacks(meta, removed);\n          }\n        }\n        meta.data.splice(start, count);\n      }\n    }, {\n      key: \"_sync\",\n      value: function _sync(args) {\n        if (this._parsing) {\n          this._syncList.push(args);\n        } else {\n          var _args2 = _slicedToArray(args, 3),\n            method = _args2[0],\n            arg1 = _args2[1],\n            arg2 = _args2[2];\n          this[method](arg1, arg2);\n        }\n        this.chart._dataChanges.push([this.index].concat(_toConsumableArray(args)));\n      }\n    }, {\n      key: \"_onDataPush\",\n      value: function _onDataPush() {\n        var count = arguments.length;\n        this._sync(['_insertElements', this.getDataset().data.length - count, count]);\n      }\n    }, {\n      key: \"_onDataPop\",\n      value: function _onDataPop() {\n        this._sync(['_removeElements', this._cachedMeta.data.length - 1, 1]);\n      }\n    }, {\n      key: \"_onDataShift\",\n      value: function _onDataShift() {\n        this._sync(['_removeElements', 0, 1]);\n      }\n    }, {\n      key: \"_onDataSplice\",\n      value: function _onDataSplice(start, count) {\n        if (count) {\n          this._sync(['_removeElements', start, count]);\n        }\n        var newCount = arguments.length - 2;\n        if (newCount) {\n          this._sync(['_insertElements', start, newCount]);\n        }\n      }\n    }, {\n      key: \"_onDataUnshift\",\n      value: function _onDataUnshift() {\n        this._sync(['_insertElements', 0, arguments.length]);\n      }\n    }]);\n    return DatasetController;\n  }();\n  _defineProperty$w(DatasetController, \"defaults\", {});\n  _defineProperty$w(DatasetController, \"datasetElementType\", null);\n  _defineProperty$w(DatasetController, \"dataElementType\", null);\n  function getAllScaleValues(scale, type) {\n    if (!scale._cache.$bar) {\n      var visibleMetas = scale.getMatchingVisibleMetas(type);\n      var values = [];\n      for (var i = 0, ilen = visibleMetas.length; i < ilen; i++) {\n        values = values.concat(visibleMetas[i].controller.getAllParsedValues(scale));\n      }\n      scale._cache.$bar = _arrayUnique(values.sort(function (a, b) {\n        return a - b;\n      }));\n    }\n    return scale._cache.$bar;\n  }\n  function computeMinSampleSize(meta) {\n    var scale = meta.iScale;\n    var values = getAllScaleValues(scale, meta.type);\n    var min = scale._length;\n    var i, ilen, curr, prev;\n    var updateMinAndPrev = function updateMinAndPrev() {\n      if (curr === 32767 || curr === -32768) {\n        return;\n      }\n      if (defined(prev)) {\n        min = Math.min(min, Math.abs(curr - prev) || min);\n      }\n      prev = curr;\n    };\n    for (i = 0, ilen = values.length; i < ilen; ++i) {\n      curr = scale.getPixelForValue(values[i]);\n      updateMinAndPrev();\n    }\n    prev = undefined;\n    for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) {\n      curr = scale.getPixelForTick(i);\n      updateMinAndPrev();\n    }\n    return min;\n  }\n  function computeFitCategoryTraits(index, ruler, options, stackCount) {\n    var thickness = options.barThickness;\n    var size, ratio;\n    if (isNullOrUndef(thickness)) {\n      size = ruler.min * options.categoryPercentage;\n      ratio = options.barPercentage;\n    } else {\n      size = thickness * stackCount;\n      ratio = 1;\n    }\n    return {\n      chunk: size / stackCount,\n      ratio: ratio,\n      start: ruler.pixels[index] - size / 2\n    };\n  }\n  function computeFlexCategoryTraits(index, ruler, options, stackCount) {\n    var pixels = ruler.pixels;\n    var curr = pixels[index];\n    var prev = index > 0 ? pixels[index - 1] : null;\n    var next = index < pixels.length - 1 ? pixels[index + 1] : null;\n    var percent = options.categoryPercentage;\n    if (prev === null) {\n      prev = curr - (next === null ? ruler.end - ruler.start : next - curr);\n    }\n    if (next === null) {\n      next = curr + curr - prev;\n    }\n    var start = curr - (curr - Math.min(prev, next)) / 2 * percent;\n    var size = Math.abs(next - prev) / 2 * percent;\n    return {\n      chunk: size / stackCount,\n      ratio: options.barPercentage,\n      start: start\n    };\n  }\n  function parseFloatBar(entry, item, vScale, i) {\n    var startValue = vScale.parse(entry[0], i);\n    var endValue = vScale.parse(entry[1], i);\n    var min = Math.min(startValue, endValue);\n    var max = Math.max(startValue, endValue);\n    var barStart = min;\n    var barEnd = max;\n    if (Math.abs(min) > Math.abs(max)) {\n      barStart = max;\n      barEnd = min;\n    }\n    item[vScale.axis] = barEnd;\n    item._custom = {\n      barStart: barStart,\n      barEnd: barEnd,\n      start: startValue,\n      end: endValue,\n      min: min,\n      max: max\n    };\n  }\n  function parseValue(entry, item, vScale, i) {\n    if (isArray(entry)) {\n      parseFloatBar(entry, item, vScale, i);\n    } else {\n      item[vScale.axis] = vScale.parse(entry, i);\n    }\n    return item;\n  }\n  function parseArrayOrPrimitive(meta, data, start, count) {\n    var iScale = meta.iScale;\n    var vScale = meta.vScale;\n    var labels = iScale.getLabels();\n    var singleScale = iScale === vScale;\n    var parsed = [];\n    var i, ilen, item, entry;\n    for (i = start, ilen = start + count; i < ilen; ++i) {\n      entry = data[i];\n      item = {};\n      item[iScale.axis] = singleScale || iScale.parse(labels[i], i);\n      parsed.push(parseValue(entry, item, vScale, i));\n    }\n    return parsed;\n  }\n  function isFloatBar(custom) {\n    return custom && custom.barStart !== undefined && custom.barEnd !== undefined;\n  }\n  function barSign(size, vScale, actualBase) {\n    if (size !== 0) {\n      return sign(size);\n    }\n    return (vScale.isHorizontal() ? 1 : -1) * (vScale.min >= actualBase ? 1 : -1);\n  }\n  function borderProps(properties) {\n    var reverse, start, end, top, bottom;\n    if (properties.horizontal) {\n      reverse = properties.base > properties.x;\n      start = 'left';\n      end = 'right';\n    } else {\n      reverse = properties.base < properties.y;\n      start = 'bottom';\n      end = 'top';\n    }\n    if (reverse) {\n      top = 'end';\n      bottom = 'start';\n    } else {\n      top = 'start';\n      bottom = 'end';\n    }\n    return {\n      start: start,\n      end: end,\n      reverse: reverse,\n      top: top,\n      bottom: bottom\n    };\n  }\n  function setBorderSkipped(properties, options, stack, index) {\n    var edge = options.borderSkipped;\n    var res = {};\n    if (!edge) {\n      properties.borderSkipped = res;\n      return;\n    }\n    if (edge === true) {\n      properties.borderSkipped = {\n        top: true,\n        right: true,\n        bottom: true,\n        left: true\n      };\n      return;\n    }\n    var _borderProps = borderProps(properties),\n      start = _borderProps.start,\n      end = _borderProps.end,\n      reverse = _borderProps.reverse,\n      top = _borderProps.top,\n      bottom = _borderProps.bottom;\n    if (edge === 'middle' && stack) {\n      properties.enableBorderRadius = true;\n      if ((stack._top || 0) === index) {\n        edge = top;\n      } else if ((stack._bottom || 0) === index) {\n        edge = bottom;\n      } else {\n        res[parseEdge(bottom, start, end, reverse)] = true;\n        edge = top;\n      }\n    }\n    res[parseEdge(edge, start, end, reverse)] = true;\n    properties.borderSkipped = res;\n  }\n  function parseEdge(edge, a, b, reverse) {\n    if (reverse) {\n      edge = swap(edge, a, b);\n      edge = startEnd(edge, b, a);\n    } else {\n      edge = startEnd(edge, a, b);\n    }\n    return edge;\n  }\n  function swap(orig, v1, v2) {\n    return orig === v1 ? v2 : orig === v2 ? v1 : orig;\n  }\n  function startEnd(v, start, end) {\n    return v === 'start' ? start : v === 'end' ? end : v;\n  }\n  function setInflateAmount(properties, _ref, ratio) {\n    var inflateAmount = _ref.inflateAmount;\n    properties.inflateAmount = inflateAmount === 'auto' ? ratio === 1 ? 0.33 : 0 : inflateAmount;\n  }\n  var BarController = /*#__PURE__*/function (_DatasetController) {\n    _inherits$w(BarController, _DatasetController);\n    var _super = _createSuper$w(BarController);\n    function BarController() {\n      _classCallCheck$x(this, BarController);\n      return _super.apply(this, arguments);\n    }\n    _createClass$x(BarController, [{\n      key: \"parsePrimitiveData\",\n      value: function parsePrimitiveData(meta, data, start, count) {\n        return parseArrayOrPrimitive(meta, data, start, count);\n      }\n    }, {\n      key: \"parseArrayData\",\n      value: function parseArrayData(meta, data, start, count) {\n        return parseArrayOrPrimitive(meta, data, start, count);\n      }\n    }, {\n      key: \"parseObjectData\",\n      value: function parseObjectData(meta, data, start, count) {\n        var iScale = meta.iScale,\n          vScale = meta.vScale;\n        var _this$_parsing2 = this._parsing,\n          _this$_parsing2$xAxis = _this$_parsing2.xAxisKey,\n          xAxisKey = _this$_parsing2$xAxis === void 0 ? 'x' : _this$_parsing2$xAxis,\n          _this$_parsing2$yAxis = _this$_parsing2.yAxisKey,\n          yAxisKey = _this$_parsing2$yAxis === void 0 ? 'y' : _this$_parsing2$yAxis;\n        var iAxisKey = iScale.axis === 'x' ? xAxisKey : yAxisKey;\n        var vAxisKey = vScale.axis === 'x' ? xAxisKey : yAxisKey;\n        var parsed = [];\n        var i, ilen, item, obj;\n        for (i = start, ilen = start + count; i < ilen; ++i) {\n          obj = data[i];\n          item = {};\n          item[iScale.axis] = iScale.parse(resolveObjectKey(obj, iAxisKey), i);\n          parsed.push(parseValue(resolveObjectKey(obj, vAxisKey), item, vScale, i));\n        }\n        return parsed;\n      }\n    }, {\n      key: \"updateRangeFromParsed\",\n      value: function updateRangeFromParsed(range, scale, parsed, stack) {\n        _get(_getPrototypeOf$w(BarController.prototype), \"updateRangeFromParsed\", this).call(this, range, scale, parsed, stack);\n        var custom = parsed._custom;\n        if (custom && scale === this._cachedMeta.vScale) {\n          range.min = Math.min(range.min, custom.min);\n          range.max = Math.max(range.max, custom.max);\n        }\n      }\n    }, {\n      key: \"getMaxOverflow\",\n      value: function getMaxOverflow() {\n        return 0;\n      }\n    }, {\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var iScale = meta.iScale,\n          vScale = meta.vScale;\n        var parsed = this.getParsed(index);\n        var custom = parsed._custom;\n        var value = isFloatBar(custom) ? '[' + custom.start + ', ' + custom.end + ']' : '' + vScale.getLabelForValue(parsed[vScale.axis]);\n        return {\n          label: '' + iScale.getLabelForValue(parsed[iScale.axis]),\n          value: value\n        };\n      }\n    }, {\n      key: \"initialize\",\n      value: function initialize() {\n        this.enableOptionSharing = true;\n        _get(_getPrototypeOf$w(BarController.prototype), \"initialize\", this).call(this);\n        var meta = this._cachedMeta;\n        meta.stack = this.getDataset().stack;\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var meta = this._cachedMeta;\n        this.updateElements(meta.data, 0, meta.data.length, mode);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(bars, start, count, mode) {\n        var reset = mode === 'reset';\n        var index = this.index,\n          vScale = this._cachedMeta.vScale;\n        var base = vScale.getBasePixel();\n        var horizontal = vScale.isHorizontal();\n        var ruler = this._getRuler();\n        var _this$_getSharedOptio = this._getSharedOptions(start, mode),\n          sharedOptions = _this$_getSharedOptio.sharedOptions,\n          includeOptions = _this$_getSharedOptio.includeOptions;\n        for (var i = start; i < start + count; i++) {\n          var parsed = this.getParsed(i);\n          var vpixels = reset || isNullOrUndef(parsed[vScale.axis]) ? {\n            base: base,\n            head: base\n          } : this._calculateBarValuePixels(i);\n          var ipixels = this._calculateBarIndexPixels(i, ruler);\n          var stack = (parsed._stacks || {})[vScale.axis];\n          var properties = {\n            horizontal: horizontal,\n            base: vpixels.base,\n            enableBorderRadius: !stack || isFloatBar(parsed._custom) || index === stack._top || index === stack._bottom,\n            x: horizontal ? vpixels.head : ipixels.center,\n            y: horizontal ? ipixels.center : vpixels.head,\n            height: horizontal ? ipixels.size : Math.abs(vpixels.size),\n            width: horizontal ? Math.abs(vpixels.size) : ipixels.size\n          };\n          if (includeOptions) {\n            properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? 'active' : mode);\n          }\n          var options = properties.options || bars[i].options;\n          setBorderSkipped(properties, options, stack, index);\n          setInflateAmount(properties, options, ruler.ratio);\n          this.updateElement(bars[i], i, properties, mode);\n        }\n      }\n    }, {\n      key: \"_getStacks\",\n      value: function _getStacks(last, dataIndex) {\n        var iScale = this._cachedMeta.iScale;\n        var metasets = iScale.getMatchingVisibleMetas(this._type).filter(function (meta) {\n          return meta.controller.options.grouped;\n        });\n        var stacked = iScale.options.stacked;\n        var stacks = [];\n        var skipNull = function skipNull(meta) {\n          var parsed = meta.controller.getParsed(dataIndex);\n          var val = parsed && parsed[meta.vScale.axis];\n          if (isNullOrUndef(val) || isNaN(val)) {\n            return true;\n          }\n        };\n        var _iterator4 = _createForOfIteratorHelper$1(metasets),\n          _step4;\n        try {\n          for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n            var meta = _step4.value;\n            if (dataIndex !== undefined && skipNull(meta)) {\n              continue;\n            }\n            if (stacked === false || stacks.indexOf(meta.stack) === -1 || stacked === undefined && meta.stack === undefined) {\n              stacks.push(meta.stack);\n            }\n            if (meta.index === last) {\n              break;\n            }\n          }\n        } catch (err) {\n          _iterator4.e(err);\n        } finally {\n          _iterator4.f();\n        }\n        if (!stacks.length) {\n          stacks.push(undefined);\n        }\n        return stacks;\n      }\n    }, {\n      key: \"_getStackCount\",\n      value: function _getStackCount(index) {\n        return this._getStacks(undefined, index).length;\n      }\n    }, {\n      key: \"_getStackIndex\",\n      value: function _getStackIndex(datasetIndex, name, dataIndex) {\n        var stacks = this._getStacks(datasetIndex, dataIndex);\n        var index = name !== undefined ? stacks.indexOf(name) : -1;\n        return index === -1 ? stacks.length - 1 : index;\n      }\n    }, {\n      key: \"_getRuler\",\n      value: function _getRuler() {\n        var opts = this.options;\n        var meta = this._cachedMeta;\n        var iScale = meta.iScale;\n        var pixels = [];\n        var i, ilen;\n        for (i = 0, ilen = meta.data.length; i < ilen; ++i) {\n          pixels.push(iScale.getPixelForValue(this.getParsed(i)[iScale.axis], i));\n        }\n        var barThickness = opts.barThickness;\n        var min = barThickness || computeMinSampleSize(meta);\n        return {\n          min: min,\n          pixels: pixels,\n          start: iScale._startPixel,\n          end: iScale._endPixel,\n          stackCount: this._getStackCount(),\n          scale: iScale,\n          grouped: opts.grouped,\n          ratio: barThickness ? 1 : opts.categoryPercentage * opts.barPercentage\n        };\n      }\n    }, {\n      key: \"_calculateBarValuePixels\",\n      value: function _calculateBarValuePixels(index) {\n        var _this$_cachedMeta = this._cachedMeta,\n          vScale = _this$_cachedMeta.vScale,\n          _stacked = _this$_cachedMeta._stacked,\n          datasetIndex = _this$_cachedMeta.index,\n          _this$options = this.options,\n          baseValue = _this$options.base,\n          minBarLength = _this$options.minBarLength;\n        var actualBase = baseValue || 0;\n        var parsed = this.getParsed(index);\n        var custom = parsed._custom;\n        var floating = isFloatBar(custom);\n        var value = parsed[vScale.axis];\n        var start = 0;\n        var length = _stacked ? this.applyStack(vScale, parsed, _stacked) : value;\n        var head, size;\n        if (length !== value) {\n          start = length - value;\n          length = value;\n        }\n        if (floating) {\n          value = custom.barStart;\n          length = custom.barEnd - custom.barStart;\n          if (value !== 0 && sign(value) !== sign(custom.barEnd)) {\n            start = 0;\n          }\n          start += value;\n        }\n        var startValue = !isNullOrUndef(baseValue) && !floating ? baseValue : start;\n        var base = vScale.getPixelForValue(startValue);\n        if (this.chart.getDataVisibility(index)) {\n          head = vScale.getPixelForValue(start + length);\n        } else {\n          head = base;\n        }\n        size = head - base;\n        if (Math.abs(size) < minBarLength) {\n          size = barSign(size, vScale, actualBase) * minBarLength;\n          if (value === actualBase) {\n            base -= size / 2;\n          }\n          var startPixel = vScale.getPixelForDecimal(0);\n          var endPixel = vScale.getPixelForDecimal(1);\n          var min = Math.min(startPixel, endPixel);\n          var max = Math.max(startPixel, endPixel);\n          base = Math.max(Math.min(base, max), min);\n          head = base + size;\n          if (_stacked && !floating) {\n            parsed._stacks[vScale.axis]._visualValues[datasetIndex] = vScale.getValueForPixel(head) - vScale.getValueForPixel(base);\n          }\n        }\n        if (base === vScale.getPixelForValue(actualBase)) {\n          var halfGrid = sign(size) * vScale.getLineWidthForValue(actualBase) / 2;\n          base += halfGrid;\n          size -= halfGrid;\n        }\n        return {\n          size: size,\n          base: base,\n          head: head,\n          center: head + size / 2\n        };\n      }\n    }, {\n      key: \"_calculateBarIndexPixels\",\n      value: function _calculateBarIndexPixels(index, ruler) {\n        var scale = ruler.scale;\n        var options = this.options;\n        var skipNull = options.skipNull;\n        var maxBarThickness = valueOrDefault(options.maxBarThickness, Infinity);\n        var center, size;\n        if (ruler.grouped) {\n          var stackCount = skipNull ? this._getStackCount(index) : ruler.stackCount;\n          var range = options.barThickness === 'flex' ? computeFlexCategoryTraits(index, ruler, options, stackCount) : computeFitCategoryTraits(index, ruler, options, stackCount);\n          var stackIndex = this._getStackIndex(this.index, this._cachedMeta.stack, skipNull ? index : undefined);\n          center = range.start + range.chunk * stackIndex + range.chunk / 2;\n          size = Math.min(maxBarThickness, range.chunk * range.ratio);\n        } else {\n          center = scale.getPixelForValue(this.getParsed(index)[scale.axis], index);\n          size = Math.min(maxBarThickness, ruler.min * ruler.ratio);\n        }\n        return {\n          base: center - size / 2,\n          head: center + size / 2,\n          center: center,\n          size: size\n        };\n      }\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        var meta = this._cachedMeta;\n        var vScale = meta.vScale;\n        var rects = meta.data;\n        var ilen = rects.length;\n        var i = 0;\n        for (; i < ilen; ++i) {\n          if (this.getParsed(i)[vScale.axis] !== null) {\n            rects[i].draw(this._ctx);\n          }\n        }\n      }\n    }]);\n    return BarController;\n  }(DatasetController);\n  _defineProperty$w(BarController, \"id\", 'bar');\n  _defineProperty$w(BarController, \"defaults\", {\n    datasetElementType: false,\n    dataElementType: 'bar',\n    categoryPercentage: 0.8,\n    barPercentage: 0.9,\n    grouped: true,\n    animations: {\n      numbers: {\n        type: 'number',\n        properties: ['x', 'y', 'base', 'width', 'height']\n      }\n    }\n  });\n  _defineProperty$w(BarController, \"overrides\", {\n    scales: {\n      _index_: {\n        type: 'category',\n        offset: true,\n        grid: {\n          offset: true\n        }\n      },\n      _value_: {\n        type: 'linear',\n        beginAtZero: true\n      }\n    }\n  });\n  var BubbleController = /*#__PURE__*/function (_DatasetController2) {\n    _inherits$w(BubbleController, _DatasetController2);\n    var _super2 = _createSuper$w(BubbleController);\n    function BubbleController() {\n      _classCallCheck$x(this, BubbleController);\n      return _super2.apply(this, arguments);\n    }\n    _createClass$x(BubbleController, [{\n      key: \"initialize\",\n      value: function initialize() {\n        this.enableOptionSharing = true;\n        _get(_getPrototypeOf$w(BubbleController.prototype), \"initialize\", this).call(this);\n      }\n    }, {\n      key: \"parsePrimitiveData\",\n      value: function parsePrimitiveData(meta, data, start, count) {\n        var parsed = _get(_getPrototypeOf$w(BubbleController.prototype), \"parsePrimitiveData\", this).call(this, meta, data, start, count);\n        for (var i = 0; i < parsed.length; i++) {\n          parsed[i]._custom = this.resolveDataElementOptions(i + start).radius;\n        }\n        return parsed;\n      }\n    }, {\n      key: \"parseArrayData\",\n      value: function parseArrayData(meta, data, start, count) {\n        var parsed = _get(_getPrototypeOf$w(BubbleController.prototype), \"parseArrayData\", this).call(this, meta, data, start, count);\n        for (var i = 0; i < parsed.length; i++) {\n          var item = data[start + i];\n          parsed[i]._custom = valueOrDefault(item[2], this.resolveDataElementOptions(i + start).radius);\n        }\n        return parsed;\n      }\n    }, {\n      key: \"parseObjectData\",\n      value: function parseObjectData(meta, data, start, count) {\n        var parsed = _get(_getPrototypeOf$w(BubbleController.prototype), \"parseObjectData\", this).call(this, meta, data, start, count);\n        for (var i = 0; i < parsed.length; i++) {\n          var item = data[start + i];\n          parsed[i]._custom = valueOrDefault(item && item.r && +item.r, this.resolveDataElementOptions(i + start).radius);\n        }\n        return parsed;\n      }\n    }, {\n      key: \"getMaxOverflow\",\n      value: function getMaxOverflow() {\n        var data = this._cachedMeta.data;\n        var max = 0;\n        for (var i = data.length - 1; i >= 0; --i) {\n          max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n        }\n        return max > 0 && max;\n      }\n    }, {\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var labels = this.chart.data.labels || [];\n        var xScale = meta.xScale,\n          yScale = meta.yScale;\n        var parsed = this.getParsed(index);\n        var x = xScale.getLabelForValue(parsed.x);\n        var y = yScale.getLabelForValue(parsed.y);\n        var r = parsed._custom;\n        return {\n          label: labels[index] || '',\n          value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')'\n        };\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var points = this._cachedMeta.data;\n        this.updateElements(points, 0, points.length, mode);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(points, start, count, mode) {\n        var reset = mode === 'reset';\n        var _this$_cachedMeta2 = this._cachedMeta,\n          iScale = _this$_cachedMeta2.iScale,\n          vScale = _this$_cachedMeta2.vScale;\n        var _this$_getSharedOptio2 = this._getSharedOptions(start, mode),\n          sharedOptions = _this$_getSharedOptio2.sharedOptions,\n          includeOptions = _this$_getSharedOptio2.includeOptions;\n        var iAxis = iScale.axis;\n        var vAxis = vScale.axis;\n        for (var i = start; i < start + count; i++) {\n          var point = points[i];\n          var parsed = !reset && this.getParsed(i);\n          var properties = {};\n          var iPixel = properties[iAxis] = reset ? iScale.getPixelForDecimal(0.5) : iScale.getPixelForValue(parsed[iAxis]);\n          var vPixel = properties[vAxis] = reset ? vScale.getBasePixel() : vScale.getPixelForValue(parsed[vAxis]);\n          properties.skip = isNaN(iPixel) || isNaN(vPixel);\n          if (includeOptions) {\n            properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n            if (reset) {\n              properties.options.radius = 0;\n            }\n          }\n          this.updateElement(point, i, properties, mode);\n        }\n      }\n    }, {\n      key: \"resolveDataElementOptions\",\n      value: function resolveDataElementOptions(index, mode) {\n        var parsed = this.getParsed(index);\n        var values = _get(_getPrototypeOf$w(BubbleController.prototype), \"resolveDataElementOptions\", this).call(this, index, mode);\n        if (values.$shared) {\n          values = Object.assign({}, values, {\n            $shared: false\n          });\n        }\n        var radius = values.radius;\n        if (mode !== 'active') {\n          values.radius = 0;\n        }\n        values.radius += valueOrDefault(parsed && parsed._custom, radius);\n        return values;\n      }\n    }]);\n    return BubbleController;\n  }(DatasetController);\n  _defineProperty$w(BubbleController, \"id\", 'bubble');\n  _defineProperty$w(BubbleController, \"defaults\", {\n    datasetElementType: false,\n    dataElementType: 'point',\n    animations: {\n      numbers: {\n        type: 'number',\n        properties: ['x', 'y', 'borderWidth', 'radius']\n      }\n    }\n  });\n  _defineProperty$w(BubbleController, \"overrides\", {\n    scales: {\n      x: {\n        type: 'linear'\n      },\n      y: {\n        type: 'linear'\n      }\n    }\n  });\n  function getRatioAndOffset(rotation, circumference, cutout) {\n    var ratioX = 1;\n    var ratioY = 1;\n    var offsetX = 0;\n    var offsetY = 0;\n    if (circumference < TAU) {\n      var startAngle = rotation;\n      var endAngle = startAngle + circumference;\n      var startX = Math.cos(startAngle);\n      var startY = Math.sin(startAngle);\n      var endX = Math.cos(endAngle);\n      var endY = Math.sin(endAngle);\n      var calcMax = function calcMax(angle, a, b) {\n        return _angleBetween(angle, startAngle, endAngle, true) ? 1 : Math.max(a, a * cutout, b, b * cutout);\n      };\n      var calcMin = function calcMin(angle, a, b) {\n        return _angleBetween(angle, startAngle, endAngle, true) ? -1 : Math.min(a, a * cutout, b, b * cutout);\n      };\n      var maxX = calcMax(0, startX, endX);\n      var maxY = calcMax(HALF_PI, startY, endY);\n      var minX = calcMin(PI, startX, endX);\n      var minY = calcMin(PI + HALF_PI, startY, endY);\n      ratioX = (maxX - minX) / 2;\n      ratioY = (maxY - minY) / 2;\n      offsetX = -(maxX + minX) / 2;\n      offsetY = -(maxY + minY) / 2;\n    }\n    return {\n      ratioX: ratioX,\n      ratioY: ratioY,\n      offsetX: offsetX,\n      offsetY: offsetY\n    };\n  }\n  var DoughnutController = /*#__PURE__*/function (_DatasetController3) {\n    _inherits$w(DoughnutController, _DatasetController3);\n    var _super3 = _createSuper$w(DoughnutController);\n    function DoughnutController(chart, datasetIndex) {\n      var _this4;\n      _classCallCheck$x(this, DoughnutController);\n      _this4 = _super3.call(this, chart, datasetIndex);\n      _this4.enableOptionSharing = true;\n      _this4.innerRadius = undefined;\n      _this4.outerRadius = undefined;\n      _this4.offsetX = undefined;\n      _this4.offsetY = undefined;\n      return _this4;\n    }\n    _createClass$x(DoughnutController, [{\n      key: \"linkScales\",\n      value: function linkScales() {}\n    }, {\n      key: \"parse\",\n      value: function parse(start, count) {\n        var data = this.getDataset().data;\n        var meta = this._cachedMeta;\n        if (this._parsing === false) {\n          meta._parsed = data;\n        } else {\n          var getter = function getter(i) {\n            return +data[i];\n          };\n          if (isObject(data[start])) {\n            var _this$_parsing$key = this._parsing.key,\n              key = _this$_parsing$key === void 0 ? 'value' : _this$_parsing$key;\n            getter = function getter(i) {\n              return +resolveObjectKey(data[i], key);\n            };\n          }\n          var i, ilen;\n          for (i = start, ilen = start + count; i < ilen; ++i) {\n            meta._parsed[i] = getter(i);\n          }\n        }\n      }\n    }, {\n      key: \"_getRotation\",\n      value: function _getRotation() {\n        return toRadians(this.options.rotation - 90);\n      }\n    }, {\n      key: \"_getCircumference\",\n      value: function _getCircumference() {\n        return toRadians(this.options.circumference);\n      }\n    }, {\n      key: \"_getRotationExtents\",\n      value: function _getRotationExtents() {\n        var min = TAU;\n        var max = -TAU;\n        for (var i = 0; i < this.chart.data.datasets.length; ++i) {\n          if (this.chart.isDatasetVisible(i) && this.chart.getDatasetMeta(i).type === this._type) {\n            var controller = this.chart.getDatasetMeta(i).controller;\n            var rotation = controller._getRotation();\n            var circumference = controller._getCircumference();\n            min = Math.min(min, rotation);\n            max = Math.max(max, rotation + circumference);\n          }\n        }\n        return {\n          rotation: min,\n          circumference: max - min\n        };\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var chart = this.chart;\n        var chartArea = chart.chartArea;\n        var meta = this._cachedMeta;\n        var arcs = meta.data;\n        var spacing = this.getMaxBorderWidth() + this.getMaxOffset(arcs) + this.options.spacing;\n        var maxSize = Math.max((Math.min(chartArea.width, chartArea.height) - spacing) / 2, 0);\n        var cutout = Math.min(toPercentage(this.options.cutout, maxSize), 1);\n        var chartWeight = this._getRingWeight(this.index);\n        var _this$_getRotationExt = this._getRotationExtents(),\n          circumference = _this$_getRotationExt.circumference,\n          rotation = _this$_getRotationExt.rotation;\n        var _getRatioAndOffset = getRatioAndOffset(rotation, circumference, cutout),\n          ratioX = _getRatioAndOffset.ratioX,\n          ratioY = _getRatioAndOffset.ratioY,\n          offsetX = _getRatioAndOffset.offsetX,\n          offsetY = _getRatioAndOffset.offsetY;\n        var maxWidth = (chartArea.width - spacing) / ratioX;\n        var maxHeight = (chartArea.height - spacing) / ratioY;\n        var maxRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0);\n        var outerRadius = toDimension(this.options.radius, maxRadius);\n        var innerRadius = Math.max(outerRadius * cutout, 0);\n        var radiusLength = (outerRadius - innerRadius) / this._getVisibleDatasetWeightTotal();\n        this.offsetX = offsetX * outerRadius;\n        this.offsetY = offsetY * outerRadius;\n        meta.total = this.calculateTotal();\n        this.outerRadius = outerRadius - radiusLength * this._getRingWeightOffset(this.index);\n        this.innerRadius = Math.max(this.outerRadius - radiusLength * chartWeight, 0);\n        this.updateElements(arcs, 0, arcs.length, mode);\n      }\n    }, {\n      key: \"_circumference\",\n      value: function _circumference(i, reset) {\n        var opts = this.options;\n        var meta = this._cachedMeta;\n        var circumference = this._getCircumference();\n        if (reset && opts.animation.animateRotate || !this.chart.getDataVisibility(i) || meta._parsed[i] === null || meta.data[i].hidden) {\n          return 0;\n        }\n        return this.calculateCircumference(meta._parsed[i] * circumference / TAU);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(arcs, start, count, mode) {\n        var reset = mode === 'reset';\n        var chart = this.chart;\n        var chartArea = chart.chartArea;\n        var opts = chart.options;\n        var animationOpts = opts.animation;\n        var centerX = (chartArea.left + chartArea.right) / 2;\n        var centerY = (chartArea.top + chartArea.bottom) / 2;\n        var animateScale = reset && animationOpts.animateScale;\n        var innerRadius = animateScale ? 0 : this.innerRadius;\n        var outerRadius = animateScale ? 0 : this.outerRadius;\n        var _this$_getSharedOptio3 = this._getSharedOptions(start, mode),\n          sharedOptions = _this$_getSharedOptio3.sharedOptions,\n          includeOptions = _this$_getSharedOptio3.includeOptions;\n        var startAngle = this._getRotation();\n        var i;\n        for (i = 0; i < start; ++i) {\n          startAngle += this._circumference(i, reset);\n        }\n        for (i = start; i < start + count; ++i) {\n          var circumference = this._circumference(i, reset);\n          var arc = arcs[i];\n          var properties = {\n            x: centerX + this.offsetX,\n            y: centerY + this.offsetY,\n            startAngle: startAngle,\n            endAngle: startAngle + circumference,\n            circumference: circumference,\n            outerRadius: outerRadius,\n            innerRadius: innerRadius\n          };\n          if (includeOptions) {\n            properties.options = sharedOptions || this.resolveDataElementOptions(i, arc.active ? 'active' : mode);\n          }\n          startAngle += circumference;\n          this.updateElement(arc, i, properties, mode);\n        }\n      }\n    }, {\n      key: \"calculateTotal\",\n      value: function calculateTotal() {\n        var meta = this._cachedMeta;\n        var metaData = meta.data;\n        var total = 0;\n        var i;\n        for (i = 0; i < metaData.length; i++) {\n          var value = meta._parsed[i];\n          if (value !== null && !isNaN(value) && this.chart.getDataVisibility(i) && !metaData[i].hidden) {\n            total += Math.abs(value);\n          }\n        }\n        return total;\n      }\n    }, {\n      key: \"calculateCircumference\",\n      value: function calculateCircumference(value) {\n        var total = this._cachedMeta.total;\n        if (total > 0 && !isNaN(value)) {\n          return TAU * (Math.abs(value) / total);\n        }\n        return 0;\n      }\n    }, {\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var chart = this.chart;\n        var labels = chart.data.labels || [];\n        var value = formatNumber(meta._parsed[index], chart.options.locale);\n        return {\n          label: labels[index] || '',\n          value: value\n        };\n      }\n    }, {\n      key: \"getMaxBorderWidth\",\n      value: function getMaxBorderWidth(arcs) {\n        var max = 0;\n        var chart = this.chart;\n        var i, ilen, meta, controller, options;\n        if (!arcs) {\n          for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) {\n            if (chart.isDatasetVisible(i)) {\n              meta = chart.getDatasetMeta(i);\n              arcs = meta.data;\n              controller = meta.controller;\n              break;\n            }\n          }\n        }\n        if (!arcs) {\n          return 0;\n        }\n        for (i = 0, ilen = arcs.length; i < ilen; ++i) {\n          options = controller.resolveDataElementOptions(i);\n          if (options.borderAlign !== 'inner') {\n            max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0);\n          }\n        }\n        return max;\n      }\n    }, {\n      key: \"getMaxOffset\",\n      value: function getMaxOffset(arcs) {\n        var max = 0;\n        for (var i = 0, ilen = arcs.length; i < ilen; ++i) {\n          var options = this.resolveDataElementOptions(i);\n          max = Math.max(max, options.offset || 0, options.hoverOffset || 0);\n        }\n        return max;\n      }\n    }, {\n      key: \"_getRingWeightOffset\",\n      value: function _getRingWeightOffset(datasetIndex) {\n        var ringWeightOffset = 0;\n        for (var i = 0; i < datasetIndex; ++i) {\n          if (this.chart.isDatasetVisible(i)) {\n            ringWeightOffset += this._getRingWeight(i);\n          }\n        }\n        return ringWeightOffset;\n      }\n    }, {\n      key: \"_getRingWeight\",\n      value: function _getRingWeight(datasetIndex) {\n        return Math.max(valueOrDefault(this.chart.data.datasets[datasetIndex].weight, 1), 0);\n      }\n    }, {\n      key: \"_getVisibleDatasetWeightTotal\",\n      value: function _getVisibleDatasetWeightTotal() {\n        return this._getRingWeightOffset(this.chart.data.datasets.length) || 1;\n      }\n    }]);\n    return DoughnutController;\n  }(DatasetController);\n  _defineProperty$w(DoughnutController, \"id\", 'doughnut');\n  _defineProperty$w(DoughnutController, \"defaults\", {\n    datasetElementType: false,\n    dataElementType: 'arc',\n    animation: {\n      animateRotate: true,\n      animateScale: false\n    },\n    animations: {\n      numbers: {\n        type: 'number',\n        properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth', 'spacing']\n      }\n    },\n    cutout: '50%',\n    rotation: 0,\n    circumference: 360,\n    radius: '100%',\n    spacing: 0,\n    indexAxis: 'r'\n  });\n  _defineProperty$w(DoughnutController, \"descriptors\", {\n    _scriptable: function _scriptable(name) {\n      return name !== 'spacing';\n    },\n    _indexable: function _indexable(name) {\n      return name !== 'spacing';\n    }\n  });\n  _defineProperty$w(DoughnutController, \"overrides\", {\n    aspectRatio: 1,\n    plugins: {\n      legend: {\n        labels: {\n          generateLabels: function generateLabels(chart) {\n            var data = chart.data;\n            if (data.labels.length && data.datasets.length) {\n              var _chart$legend$options2 = chart.legend.options.labels,\n                pointStyle = _chart$legend$options2.pointStyle,\n                color = _chart$legend$options2.color;\n              return data.labels.map(function (label, i) {\n                var meta = chart.getDatasetMeta(0);\n                var style = meta.controller.getStyle(i);\n                return {\n                  text: label,\n                  fillStyle: style.backgroundColor,\n                  strokeStyle: style.borderColor,\n                  fontColor: color,\n                  lineWidth: style.borderWidth,\n                  pointStyle: pointStyle,\n                  hidden: !chart.getDataVisibility(i),\n                  index: i\n                };\n              });\n            }\n            return [];\n          }\n        },\n        onClick: function onClick(e, legendItem, legend) {\n          legend.chart.toggleDataVisibility(legendItem.index);\n          legend.chart.update();\n        }\n      }\n    }\n  });\n  var LineController = /*#__PURE__*/function (_DatasetController4) {\n    _inherits$w(LineController, _DatasetController4);\n    var _super4 = _createSuper$w(LineController);\n    function LineController() {\n      _classCallCheck$x(this, LineController);\n      return _super4.apply(this, arguments);\n    }\n    _createClass$x(LineController, [{\n      key: \"initialize\",\n      value: function initialize() {\n        this.enableOptionSharing = true;\n        this.supportsDecimation = true;\n        _get(_getPrototypeOf$w(LineController.prototype), \"initialize\", this).call(this);\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var meta = this._cachedMeta;\n        var line = meta.dataset,\n          _meta$data = meta.data,\n          points = _meta$data === void 0 ? [] : _meta$data,\n          _dataset = meta._dataset;\n        var animationsDisabled = this.chart._animationsDisabled;\n        var _getStartAndCountOfVi = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled),\n          start = _getStartAndCountOfVi.start,\n          count = _getStartAndCountOfVi.count;\n        this._drawStart = start;\n        this._drawCount = count;\n        if (_scaleRangesChanged(meta)) {\n          start = 0;\n          count = points.length;\n        }\n        line._chart = this.chart;\n        line._datasetIndex = this.index;\n        line._decimated = !!_dataset._decimated;\n        line.points = points;\n        var options = this.resolveDatasetElementOptions(mode);\n        if (!this.options.showLine) {\n          options.borderWidth = 0;\n        }\n        options.segment = this.options.segment;\n        this.updateElement(line, undefined, {\n          animated: !animationsDisabled,\n          options: options\n        }, mode);\n        this.updateElements(points, start, count, mode);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(points, start, count, mode) {\n        var reset = mode === 'reset';\n        var _this$_cachedMeta3 = this._cachedMeta,\n          iScale = _this$_cachedMeta3.iScale,\n          vScale = _this$_cachedMeta3.vScale,\n          _stacked = _this$_cachedMeta3._stacked,\n          _dataset = _this$_cachedMeta3._dataset;\n        var _this$_getSharedOptio4 = this._getSharedOptions(start, mode),\n          sharedOptions = _this$_getSharedOptio4.sharedOptions,\n          includeOptions = _this$_getSharedOptio4.includeOptions;\n        var iAxis = iScale.axis;\n        var vAxis = vScale.axis;\n        var _this$options2 = this.options,\n          spanGaps = _this$options2.spanGaps,\n          segment = _this$options2.segment;\n        var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n        var directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n        var end = start + count;\n        var pointsCount = points.length;\n        var prevParsed = start > 0 && this.getParsed(start - 1);\n        for (var i = 0; i < pointsCount; ++i) {\n          var point = points[i];\n          var properties = directUpdate ? point : {};\n          if (i < start || i >= end) {\n            properties.skip = true;\n            continue;\n          }\n          var parsed = this.getParsed(i);\n          var nullData = isNullOrUndef(parsed[vAxis]);\n          var iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n          var vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n          properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n          properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n          if (segment) {\n            properties.parsed = parsed;\n            properties.raw = _dataset.data[i];\n          }\n          if (includeOptions) {\n            properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n          }\n          if (!directUpdate) {\n            this.updateElement(point, i, properties, mode);\n          }\n          prevParsed = parsed;\n        }\n      }\n    }, {\n      key: \"getMaxOverflow\",\n      value: function getMaxOverflow() {\n        var meta = this._cachedMeta;\n        var dataset = meta.dataset;\n        var border = dataset.options && dataset.options.borderWidth || 0;\n        var data = meta.data || [];\n        if (!data.length) {\n          return border;\n        }\n        var firstPoint = data[0].size(this.resolveDataElementOptions(0));\n        var lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n        return Math.max(border, firstPoint, lastPoint) / 2;\n      }\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        var meta = this._cachedMeta;\n        meta.dataset.updateControlPoints(this.chart.chartArea, meta.iScale.axis);\n        _get(_getPrototypeOf$w(LineController.prototype), \"draw\", this).call(this);\n      }\n    }]);\n    return LineController;\n  }(DatasetController);\n  _defineProperty$w(LineController, \"id\", 'line');\n  _defineProperty$w(LineController, \"defaults\", {\n    datasetElementType: 'line',\n    dataElementType: 'point',\n    showLine: true,\n    spanGaps: false\n  });\n  _defineProperty$w(LineController, \"overrides\", {\n    scales: {\n      _index_: {\n        type: 'category'\n      },\n      _value_: {\n        type: 'linear'\n      }\n    }\n  });\n  var PolarAreaController = /*#__PURE__*/function (_DatasetController5) {\n    _inherits$w(PolarAreaController, _DatasetController5);\n    var _super5 = _createSuper$w(PolarAreaController);\n    function PolarAreaController(chart, datasetIndex) {\n      var _this5;\n      _classCallCheck$x(this, PolarAreaController);\n      _this5 = _super5.call(this, chart, datasetIndex);\n      _this5.innerRadius = undefined;\n      _this5.outerRadius = undefined;\n      return _this5;\n    }\n    _createClass$x(PolarAreaController, [{\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var chart = this.chart;\n        var labels = chart.data.labels || [];\n        var value = formatNumber(meta._parsed[index].r, chart.options.locale);\n        return {\n          label: labels[index] || '',\n          value: value\n        };\n      }\n    }, {\n      key: \"parseObjectData\",\n      value: function parseObjectData(meta, data, start, count) {\n        return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var arcs = this._cachedMeta.data;\n        this._updateRadius();\n        this.updateElements(arcs, 0, arcs.length, mode);\n      }\n    }, {\n      key: \"getMinMax\",\n      value: function getMinMax() {\n        var _this6 = this;\n        var meta = this._cachedMeta;\n        var range = {\n          min: Number.POSITIVE_INFINITY,\n          max: Number.NEGATIVE_INFINITY\n        };\n        meta.data.forEach(function (element, index) {\n          var parsed = _this6.getParsed(index).r;\n          if (!isNaN(parsed) && _this6.chart.getDataVisibility(index)) {\n            if (parsed < range.min) {\n              range.min = parsed;\n            }\n            if (parsed > range.max) {\n              range.max = parsed;\n            }\n          }\n        });\n        return range;\n      }\n    }, {\n      key: \"_updateRadius\",\n      value: function _updateRadius() {\n        var chart = this.chart;\n        var chartArea = chart.chartArea;\n        var opts = chart.options;\n        var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);\n        var outerRadius = Math.max(minSize / 2, 0);\n        var innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0);\n        var radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount();\n        this.outerRadius = outerRadius - radiusLength * this.index;\n        this.innerRadius = this.outerRadius - radiusLength;\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(arcs, start, count, mode) {\n        var reset = mode === 'reset';\n        var chart = this.chart;\n        var opts = chart.options;\n        var animationOpts = opts.animation;\n        var scale = this._cachedMeta.rScale;\n        var centerX = scale.xCenter;\n        var centerY = scale.yCenter;\n        var datasetStartAngle = scale.getIndexAngle(0) - 0.5 * PI;\n        var angle = datasetStartAngle;\n        var i;\n        var defaultAngle = 360 / this.countVisibleElements();\n        for (i = 0; i < start; ++i) {\n          angle += this._computeAngle(i, mode, defaultAngle);\n        }\n        for (i = start; i < start + count; i++) {\n          var arc = arcs[i];\n          var startAngle = angle;\n          var endAngle = angle + this._computeAngle(i, mode, defaultAngle);\n          var outerRadius = chart.getDataVisibility(i) ? scale.getDistanceFromCenterForValue(this.getParsed(i).r) : 0;\n          angle = endAngle;\n          if (reset) {\n            if (animationOpts.animateScale) {\n              outerRadius = 0;\n            }\n            if (animationOpts.animateRotate) {\n              startAngle = endAngle = datasetStartAngle;\n            }\n          }\n          var properties = {\n            x: centerX,\n            y: centerY,\n            innerRadius: 0,\n            outerRadius: outerRadius,\n            startAngle: startAngle,\n            endAngle: endAngle,\n            options: this.resolveDataElementOptions(i, arc.active ? 'active' : mode)\n          };\n          this.updateElement(arc, i, properties, mode);\n        }\n      }\n    }, {\n      key: \"countVisibleElements\",\n      value: function countVisibleElements() {\n        var _this7 = this;\n        var meta = this._cachedMeta;\n        var count = 0;\n        meta.data.forEach(function (element, index) {\n          if (!isNaN(_this7.getParsed(index).r) && _this7.chart.getDataVisibility(index)) {\n            count++;\n          }\n        });\n        return count;\n      }\n    }, {\n      key: \"_computeAngle\",\n      value: function _computeAngle(index, mode, defaultAngle) {\n        return this.chart.getDataVisibility(index) ? toRadians(this.resolveDataElementOptions(index, mode).angle || defaultAngle) : 0;\n      }\n    }]);\n    return PolarAreaController;\n  }(DatasetController);\n  _defineProperty$w(PolarAreaController, \"id\", 'polarArea');\n  _defineProperty$w(PolarAreaController, \"defaults\", {\n    dataElementType: 'arc',\n    animation: {\n      animateRotate: true,\n      animateScale: true\n    },\n    animations: {\n      numbers: {\n        type: 'number',\n        properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius']\n      }\n    },\n    indexAxis: 'r',\n    startAngle: 0\n  });\n  _defineProperty$w(PolarAreaController, \"overrides\", {\n    aspectRatio: 1,\n    plugins: {\n      legend: {\n        labels: {\n          generateLabels: function generateLabels(chart) {\n            var data = chart.data;\n            if (data.labels.length && data.datasets.length) {\n              var _chart$legend$options3 = chart.legend.options.labels,\n                pointStyle = _chart$legend$options3.pointStyle,\n                color = _chart$legend$options3.color;\n              return data.labels.map(function (label, i) {\n                var meta = chart.getDatasetMeta(0);\n                var style = meta.controller.getStyle(i);\n                return {\n                  text: label,\n                  fillStyle: style.backgroundColor,\n                  strokeStyle: style.borderColor,\n                  fontColor: color,\n                  lineWidth: style.borderWidth,\n                  pointStyle: pointStyle,\n                  hidden: !chart.getDataVisibility(i),\n                  index: i\n                };\n              });\n            }\n            return [];\n          }\n        },\n        onClick: function onClick(e, legendItem, legend) {\n          legend.chart.toggleDataVisibility(legendItem.index);\n          legend.chart.update();\n        }\n      }\n    },\n    scales: {\n      r: {\n        type: 'radialLinear',\n        angleLines: {\n          display: false\n        },\n        beginAtZero: true,\n        grid: {\n          circular: true\n        },\n        pointLabels: {\n          display: false\n        },\n        startAngle: 0\n      }\n    }\n  });\n  var PieController = /*#__PURE__*/function (_DoughnutController) {\n    _inherits$w(PieController, _DoughnutController);\n    var _super6 = _createSuper$w(PieController);\n    function PieController() {\n      _classCallCheck$x(this, PieController);\n      return _super6.apply(this, arguments);\n    }\n    return _createClass$x(PieController);\n  }(DoughnutController);\n  _defineProperty$w(PieController, \"id\", 'pie');\n  _defineProperty$w(PieController, \"defaults\", {\n    cutout: 0,\n    rotation: 0,\n    circumference: 360,\n    radius: '100%'\n  });\n  var RadarController = /*#__PURE__*/function (_DatasetController6) {\n    _inherits$w(RadarController, _DatasetController6);\n    var _super7 = _createSuper$w(RadarController);\n    function RadarController() {\n      _classCallCheck$x(this, RadarController);\n      return _super7.apply(this, arguments);\n    }\n    _createClass$x(RadarController, [{\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var vScale = this._cachedMeta.vScale;\n        var parsed = this.getParsed(index);\n        return {\n          label: vScale.getLabels()[index],\n          value: '' + vScale.getLabelForValue(parsed[vScale.axis])\n        };\n      }\n    }, {\n      key: \"parseObjectData\",\n      value: function parseObjectData(meta, data, start, count) {\n        return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var meta = this._cachedMeta;\n        var line = meta.dataset;\n        var points = meta.data || [];\n        var labels = meta.iScale.getLabels();\n        line.points = points;\n        if (mode !== 'resize') {\n          var options = this.resolveDatasetElementOptions(mode);\n          if (!this.options.showLine) {\n            options.borderWidth = 0;\n          }\n          var properties = {\n            _loop: true,\n            _fullLoop: labels.length === points.length,\n            options: options\n          };\n          this.updateElement(line, undefined, properties, mode);\n        }\n        this.updateElements(points, 0, points.length, mode);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(points, start, count, mode) {\n        var scale = this._cachedMeta.rScale;\n        var reset = mode === 'reset';\n        for (var i = start; i < start + count; i++) {\n          var point = points[i];\n          var options = this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n          var pointPosition = scale.getPointPositionForValue(i, this.getParsed(i).r);\n          var x = reset ? scale.xCenter : pointPosition.x;\n          var y = reset ? scale.yCenter : pointPosition.y;\n          var properties = {\n            x: x,\n            y: y,\n            angle: pointPosition.angle,\n            skip: isNaN(x) || isNaN(y),\n            options: options\n          };\n          this.updateElement(point, i, properties, mode);\n        }\n      }\n    }]);\n    return RadarController;\n  }(DatasetController);\n  _defineProperty$w(RadarController, \"id\", 'radar');\n  _defineProperty$w(RadarController, \"defaults\", {\n    datasetElementType: 'line',\n    dataElementType: 'point',\n    indexAxis: 'r',\n    showLine: true,\n    elements: {\n      line: {\n        fill: 'start'\n      }\n    }\n  });\n  _defineProperty$w(RadarController, \"overrides\", {\n    aspectRatio: 1,\n    scales: {\n      r: {\n        type: 'radialLinear'\n      }\n    }\n  });\n  var ScatterController = /*#__PURE__*/function (_DatasetController7) {\n    _inherits$w(ScatterController, _DatasetController7);\n    var _super8 = _createSuper$w(ScatterController);\n    function ScatterController() {\n      _classCallCheck$x(this, ScatterController);\n      return _super8.apply(this, arguments);\n    }\n    _createClass$x(ScatterController, [{\n      key: \"getLabelAndValue\",\n      value: function getLabelAndValue(index) {\n        var meta = this._cachedMeta;\n        var labels = this.chart.data.labels || [];\n        var xScale = meta.xScale,\n          yScale = meta.yScale;\n        var parsed = this.getParsed(index);\n        var x = xScale.getLabelForValue(parsed.x);\n        var y = yScale.getLabelForValue(parsed.y);\n        return {\n          label: labels[index] || '',\n          value: '(' + x + ', ' + y + ')'\n        };\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var meta = this._cachedMeta;\n        var _meta$data2 = meta.data,\n          points = _meta$data2 === void 0 ? [] : _meta$data2;\n        var animationsDisabled = this.chart._animationsDisabled;\n        var _getStartAndCountOfVi2 = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled),\n          start = _getStartAndCountOfVi2.start,\n          count = _getStartAndCountOfVi2.count;\n        this._drawStart = start;\n        this._drawCount = count;\n        if (_scaleRangesChanged(meta)) {\n          start = 0;\n          count = points.length;\n        }\n        if (this.options.showLine) {\n          var line = meta.dataset,\n            _dataset = meta._dataset;\n          line._chart = this.chart;\n          line._datasetIndex = this.index;\n          line._decimated = !!_dataset._decimated;\n          line.points = points;\n          var options = this.resolveDatasetElementOptions(mode);\n          options.segment = this.options.segment;\n          this.updateElement(line, undefined, {\n            animated: !animationsDisabled,\n            options: options\n          }, mode);\n        }\n        this.updateElements(points, start, count, mode);\n      }\n    }, {\n      key: \"addElements\",\n      value: function addElements() {\n        var showLine = this.options.showLine;\n        if (!this.datasetElementType && showLine) {\n          this.datasetElementType = this.chart.registry.getElement('line');\n        }\n        _get(_getPrototypeOf$w(ScatterController.prototype), \"addElements\", this).call(this);\n      }\n    }, {\n      key: \"updateElements\",\n      value: function updateElements(points, start, count, mode) {\n        var reset = mode === 'reset';\n        var _this$_cachedMeta4 = this._cachedMeta,\n          iScale = _this$_cachedMeta4.iScale,\n          vScale = _this$_cachedMeta4.vScale,\n          _stacked = _this$_cachedMeta4._stacked,\n          _dataset = _this$_cachedMeta4._dataset;\n        var firstOpts = this.resolveDataElementOptions(start, mode);\n        var sharedOptions = this.getSharedOptions(firstOpts);\n        var includeOptions = this.includeOptions(mode, sharedOptions);\n        var iAxis = iScale.axis;\n        var vAxis = vScale.axis;\n        var _this$options3 = this.options,\n          spanGaps = _this$options3.spanGaps,\n          segment = _this$options3.segment;\n        var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n        var directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n        var prevParsed = start > 0 && this.getParsed(start - 1);\n        for (var i = start; i < start + count; ++i) {\n          var point = points[i];\n          var parsed = this.getParsed(i);\n          var properties = directUpdate ? point : {};\n          var nullData = isNullOrUndef(parsed[vAxis]);\n          var iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n          var vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n          properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n          properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n          if (segment) {\n            properties.parsed = parsed;\n            properties.raw = _dataset.data[i];\n          }\n          if (includeOptions) {\n            properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n          }\n          if (!directUpdate) {\n            this.updateElement(point, i, properties, mode);\n          }\n          prevParsed = parsed;\n        }\n        this.updateSharedOptions(sharedOptions, mode, firstOpts);\n      }\n    }, {\n      key: \"getMaxOverflow\",\n      value: function getMaxOverflow() {\n        var meta = this._cachedMeta;\n        var data = meta.data || [];\n        if (!this.options.showLine) {\n          var max = 0;\n          for (var i = data.length - 1; i >= 0; --i) {\n            max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n          }\n          return max > 0 && max;\n        }\n        var dataset = meta.dataset;\n        var border = dataset.options && dataset.options.borderWidth || 0;\n        if (!data.length) {\n          return border;\n        }\n        var firstPoint = data[0].size(this.resolveDataElementOptions(0));\n        var lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n        return Math.max(border, firstPoint, lastPoint) / 2;\n      }\n    }]);\n    return ScatterController;\n  }(DatasetController);\n  _defineProperty$w(ScatterController, \"id\", 'scatter');\n  _defineProperty$w(ScatterController, \"defaults\", {\n    datasetElementType: false,\n    dataElementType: 'point',\n    showLine: false,\n    fill: false\n  });\n  _defineProperty$w(ScatterController, \"overrides\", {\n    interaction: {\n      mode: 'point'\n    },\n    scales: {\n      x: {\n        type: 'linear'\n      },\n      y: {\n        type: 'linear'\n      }\n    }\n  });\n  var controllers = /*#__PURE__*/Object.freeze({\n    __proto__: null,\n    BarController: BarController,\n    BubbleController: BubbleController,\n    DoughnutController: DoughnutController,\n    LineController: LineController,\n    PolarAreaController: PolarAreaController,\n    PieController: PieController,\n    RadarController: RadarController,\n    ScatterController: ScatterController\n  });\n\n  /**\n   * @namespace Chart._adapters\n   * @since 2.8.0\n   * @private\n   */\n  function _abstract() {\n    throw new Error('This method is not implemented: Check that a complete date adapter is provided.');\n  }\n  /**\n   * Date adapter (current used by the time scale)\n   * @namespace Chart._adapters._date\n   * @memberof Chart._adapters\n   * @private\n   */\n  var DateAdapterBase = /*#__PURE__*/function () {\n    function DateAdapterBase(options) {\n      _classCallCheck$x(this, DateAdapterBase);\n      this.options = options || {};\n    }\n    // eslint-disable-next-line @typescript-eslint/no-empty-function\n    _createClass$x(DateAdapterBase, [{\n      key: \"init\",\n      value: function init() {}\n    }, {\n      key: \"formats\",\n      value: function formats() {\n        return _abstract();\n      }\n    }, {\n      key: \"parse\",\n      value: function parse() {\n        return _abstract();\n      }\n    }, {\n      key: \"format\",\n      value: function format() {\n        return _abstract();\n      }\n    }, {\n      key: \"add\",\n      value: function add() {\n        return _abstract();\n      }\n    }, {\n      key: \"diff\",\n      value: function diff() {\n        return _abstract();\n      }\n    }, {\n      key: \"startOf\",\n      value: function startOf() {\n        return _abstract();\n      }\n    }, {\n      key: \"endOf\",\n      value: function endOf() {\n        return _abstract();\n      }\n    }], [{\n      key: \"override\",\n      value:\n      /**\n      * Override default date adapter methods.\n      * Accepts type parameter to define options type.\n      * @example\n      * Chart._adapters._date.override<{myAdapterOption: string}>({\n      *   init() {\n      *     console.log(this.options.myAdapterOption);\n      *   }\n      * })\n      */\n      function override(members) {\n        Object.assign(DateAdapterBase.prototype, members);\n      }\n    }]);\n    return DateAdapterBase;\n  }();\n  var adapters = {\n    _date: DateAdapterBase\n  };\n  function binarySearch(metaset, axis, value, intersect) {\n    var controller = metaset.controller,\n      data = metaset.data,\n      _sorted = metaset._sorted;\n    var iScale = controller._cachedMeta.iScale;\n    if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {\n      var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;\n      if (!intersect) {\n        return lookupMethod(data, axis, value);\n      } else if (controller._sharedOptions) {\n        var el = data[0];\n        var range = typeof el.getRange === 'function' && el.getRange(axis);\n        if (range) {\n          var start = lookupMethod(data, axis, value - range);\n          var end = lookupMethod(data, axis, value + range);\n          return {\n            lo: start.lo,\n            hi: end.hi\n          };\n        }\n      }\n    }\n    return {\n      lo: 0,\n      hi: data.length - 1\n    };\n  }\n  function evaluateInteractionItems(chart, axis, position, handler, intersect) {\n    var metasets = chart.getSortedVisibleDatasetMetas();\n    var value = position[axis];\n    for (var i = 0, ilen = metasets.length; i < ilen; ++i) {\n      var _metasets$i = metasets[i],\n        _index2 = _metasets$i.index,\n        data = _metasets$i.data;\n      var _binarySearch = binarySearch(metasets[i], axis, value, intersect),\n        lo = _binarySearch.lo,\n        hi = _binarySearch.hi;\n      for (var j = lo; j <= hi; ++j) {\n        var element = data[j];\n        if (!element.skip) {\n          handler(element, _index2, j);\n        }\n      }\n    }\n  }\n  function getDistanceMetricForAxis(axis) {\n    var useX = axis.indexOf('x') !== -1;\n    var useY = axis.indexOf('y') !== -1;\n    return function (pt1, pt2) {\n      var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;\n      var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;\n      return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));\n    };\n  }\n  function getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) {\n    var items = [];\n    if (!includeInvisible && !chart.isPointInArea(position)) {\n      return items;\n    }\n    var evaluationFunc = function evaluationFunc(element, datasetIndex, index) {\n      if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) {\n        return;\n      }\n      if (element.inRange(position.x, position.y, useFinalPosition)) {\n        items.push({\n          element: element,\n          datasetIndex: datasetIndex,\n          index: index\n        });\n      }\n    };\n    evaluateInteractionItems(chart, axis, position, evaluationFunc, true);\n    return items;\n  }\n  function getNearestRadialItems(chart, position, axis, useFinalPosition) {\n    var items = [];\n    function evaluationFunc(element, datasetIndex, index) {\n      var _element$getProps = element.getProps(['startAngle', 'endAngle'], useFinalPosition),\n        startAngle = _element$getProps.startAngle,\n        endAngle = _element$getProps.endAngle;\n      var _getAngleFromPoint = getAngleFromPoint(element, {\n          x: position.x,\n          y: position.y\n        }),\n        angle = _getAngleFromPoint.angle;\n      if (_angleBetween(angle, startAngle, endAngle)) {\n        items.push({\n          element: element,\n          datasetIndex: datasetIndex,\n          index: index\n        });\n      }\n    }\n    evaluateInteractionItems(chart, axis, position, evaluationFunc);\n    return items;\n  }\n  function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n    var items = [];\n    var distanceMetric = getDistanceMetricForAxis(axis);\n    var minDistance = Number.POSITIVE_INFINITY;\n    function evaluationFunc(element, datasetIndex, index) {\n      var inRange = element.inRange(position.x, position.y, useFinalPosition);\n      if (intersect && !inRange) {\n        return;\n      }\n      var center = element.getCenterPoint(useFinalPosition);\n      var pointInArea = !!includeInvisible || chart.isPointInArea(center);\n      if (!pointInArea && !inRange) {\n        return;\n      }\n      var distance = distanceMetric(position, center);\n      if (distance < minDistance) {\n        items = [{\n          element: element,\n          datasetIndex: datasetIndex,\n          index: index\n        }];\n        minDistance = distance;\n      } else if (distance === minDistance) {\n        items.push({\n          element: element,\n          datasetIndex: datasetIndex,\n          index: index\n        });\n      }\n    }\n    evaluateInteractionItems(chart, axis, position, evaluationFunc);\n    return items;\n  }\n  function getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n    if (!includeInvisible && !chart.isPointInArea(position)) {\n      return [];\n    }\n    return axis === 'r' && !intersect ? getNearestRadialItems(chart, position, axis, useFinalPosition) : getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible);\n  }\n  function getAxisItems(chart, position, axis, intersect, useFinalPosition) {\n    var items = [];\n    var rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange';\n    var intersectsItem = false;\n    evaluateInteractionItems(chart, axis, position, function (element, datasetIndex, index) {\n      if (element[rangeMethod](position[axis], useFinalPosition)) {\n        items.push({\n          element: element,\n          datasetIndex: datasetIndex,\n          index: index\n        });\n        intersectsItem = intersectsItem || element.inRange(position.x, position.y, useFinalPosition);\n      }\n    });\n    if (intersect && !intersectsItem) {\n      return [];\n    }\n    return items;\n  }\n  var Interaction = {\n    evaluateInteractionItems: evaluateInteractionItems,\n    modes: {\n      index: function index(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        var axis = options.axis || 'x';\n        var includeInvisible = options.includeInvisible || false;\n        var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n        var elements = [];\n        if (!items.length) {\n          return [];\n        }\n        chart.getSortedVisibleDatasetMetas().forEach(function (meta) {\n          var index = items[0].index;\n          var element = meta.data[index];\n          if (element && !element.skip) {\n            elements.push({\n              element: element,\n              datasetIndex: meta.index,\n              index: index\n            });\n          }\n        });\n        return elements;\n      },\n      dataset: function dataset(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        var axis = options.axis || 'xy';\n        var includeInvisible = options.includeInvisible || false;\n        var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n        if (items.length > 0) {\n          var datasetIndex = items[0].datasetIndex;\n          var data = chart.getDatasetMeta(datasetIndex).data;\n          items = [];\n          for (var i = 0; i < data.length; ++i) {\n            items.push({\n              element: data[i],\n              datasetIndex: datasetIndex,\n              index: i\n            });\n          }\n        }\n        return items;\n      },\n      point: function point(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        var axis = options.axis || 'xy';\n        var includeInvisible = options.includeInvisible || false;\n        return getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible);\n      },\n      nearest: function nearest(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        var axis = options.axis || 'xy';\n        var includeInvisible = options.includeInvisible || false;\n        return getNearestItems(chart, position, axis, options.intersect, useFinalPosition, includeInvisible);\n      },\n      x: function x(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        return getAxisItems(chart, position, 'x', options.intersect, useFinalPosition);\n      },\n      y: function y(chart, e, options, useFinalPosition) {\n        var position = getRelativePosition(e, chart);\n        return getAxisItems(chart, position, 'y', options.intersect, useFinalPosition);\n      }\n    }\n  };\n  var STATIC_POSITIONS = ['left', 'top', 'right', 'bottom'];\n  function filterByPosition(array, position) {\n    return array.filter(function (v) {\n      return v.pos === position;\n    });\n  }\n  function filterDynamicPositionByAxis(array, axis) {\n    return array.filter(function (v) {\n      return STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis;\n    });\n  }\n  function sortByWeight(array, reverse) {\n    return array.sort(function (a, b) {\n      var v0 = reverse ? b : a;\n      var v1 = reverse ? a : b;\n      return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight;\n    });\n  }\n  function wrapBoxes(boxes) {\n    var layoutBoxes = [];\n    var i, ilen, box, pos, stack, stackWeight;\n    for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) {\n      box = boxes[i];\n      var _box = box;\n      pos = _box.position;\n      var _box$options = _box.options;\n      stack = _box$options.stack;\n      var _box$options$stackWei = _box$options.stackWeight;\n      stackWeight = _box$options$stackWei === void 0 ? 1 : _box$options$stackWei;\n      layoutBoxes.push({\n        index: i,\n        box: box,\n        pos: pos,\n        horizontal: box.isHorizontal(),\n        weight: box.weight,\n        stack: stack && pos + stack,\n        stackWeight: stackWeight\n      });\n    }\n    return layoutBoxes;\n  }\n  function buildStacks(layouts) {\n    var stacks = {};\n    var _iterator5 = _createForOfIteratorHelper$1(layouts),\n      _step5;\n    try {\n      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n        var wrap = _step5.value;\n        var stack = wrap.stack,\n          pos = wrap.pos,\n          stackWeight = wrap.stackWeight;\n        if (!stack || !STATIC_POSITIONS.includes(pos)) {\n          continue;\n        }\n        var _stack = stacks[stack] || (stacks[stack] = {\n          count: 0,\n          placed: 0,\n          weight: 0,\n          size: 0\n        });\n        _stack.count++;\n        _stack.weight += stackWeight;\n      }\n    } catch (err) {\n      _iterator5.e(err);\n    } finally {\n      _iterator5.f();\n    }\n    return stacks;\n  }\n  function setLayoutDims(layouts, params) {\n    var stacks = buildStacks(layouts);\n    var vBoxMaxWidth = params.vBoxMaxWidth,\n      hBoxMaxHeight = params.hBoxMaxHeight;\n    var i, ilen, layout;\n    for (i = 0, ilen = layouts.length; i < ilen; ++i) {\n      layout = layouts[i];\n      var fullSize = layout.box.fullSize;\n      var stack = stacks[layout.stack];\n      var factor = stack && layout.stackWeight / stack.weight;\n      if (layout.horizontal) {\n        layout.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;\n        layout.height = hBoxMaxHeight;\n      } else {\n        layout.width = vBoxMaxWidth;\n        layout.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;\n      }\n    }\n    return stacks;\n  }\n  function buildLayoutBoxes(boxes) {\n    var layoutBoxes = wrapBoxes(boxes);\n    var fullSize = sortByWeight(layoutBoxes.filter(function (wrap) {\n      return wrap.box.fullSize;\n    }), true);\n    var left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true);\n    var right = sortByWeight(filterByPosition(layoutBoxes, 'right'));\n    var top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true);\n    var bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom'));\n    var centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, 'x');\n    var centerVertical = filterDynamicPositionByAxis(layoutBoxes, 'y');\n    return {\n      fullSize: fullSize,\n      leftAndTop: left.concat(top),\n      rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal),\n      chartArea: filterByPosition(layoutBoxes, 'chartArea'),\n      vertical: left.concat(right).concat(centerVertical),\n      horizontal: top.concat(bottom).concat(centerHorizontal)\n    };\n  }\n  function getCombinedMax(maxPadding, chartArea, a, b) {\n    return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]);\n  }\n  function updateMaxPadding(maxPadding, boxPadding) {\n    maxPadding.top = Math.max(maxPadding.top, boxPadding.top);\n    maxPadding.left = Math.max(maxPadding.left, boxPadding.left);\n    maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom);\n    maxPadding.right = Math.max(maxPadding.right, boxPadding.right);\n  }\n  function updateDims(chartArea, params, layout, stacks) {\n    var pos = layout.pos,\n      box = layout.box;\n    var maxPadding = chartArea.maxPadding;\n    if (!isObject(pos)) {\n      if (layout.size) {\n        chartArea[pos] -= layout.size;\n      }\n      var stack = stacks[layout.stack] || {\n        size: 0,\n        count: 1\n      };\n      stack.size = Math.max(stack.size, layout.horizontal ? box.height : box.width);\n      layout.size = stack.size / stack.count;\n      chartArea[pos] += layout.size;\n    }\n    if (box.getPadding) {\n      updateMaxPadding(maxPadding, box.getPadding());\n    }\n    var newWidth = Math.max(0, params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'));\n    var newHeight = Math.max(0, params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'));\n    var widthChanged = newWidth !== chartArea.w;\n    var heightChanged = newHeight !== chartArea.h;\n    chartArea.w = newWidth;\n    chartArea.h = newHeight;\n    return layout.horizontal ? {\n      same: widthChanged,\n      other: heightChanged\n    } : {\n      same: heightChanged,\n      other: widthChanged\n    };\n  }\n  function handleMaxPadding(chartArea) {\n    var maxPadding = chartArea.maxPadding;\n    function updatePos(pos) {\n      var change = Math.max(maxPadding[pos] - chartArea[pos], 0);\n      chartArea[pos] += change;\n      return change;\n    }\n    chartArea.y += updatePos('top');\n    chartArea.x += updatePos('left');\n    updatePos('right');\n    updatePos('bottom');\n  }\n  function getMargins(horizontal, chartArea) {\n    var maxPadding = chartArea.maxPadding;\n    function marginForPositions(positions) {\n      var margin = {\n        left: 0,\n        top: 0,\n        right: 0,\n        bottom: 0\n      };\n      positions.forEach(function (pos) {\n        margin[pos] = Math.max(chartArea[pos], maxPadding[pos]);\n      });\n      return margin;\n    }\n    return horizontal ? marginForPositions(['left', 'right']) : marginForPositions(['top', 'bottom']);\n  }\n  function fitBoxes(boxes, chartArea, params, stacks) {\n    var refitBoxes = [];\n    var i, ilen, layout, box, refit, changed;\n    for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) {\n      layout = boxes[i];\n      box = layout.box;\n      box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea));\n      var _updateDims = updateDims(chartArea, params, layout, stacks),\n        same = _updateDims.same,\n        other = _updateDims.other;\n      refit |= same && refitBoxes.length;\n      changed = changed || other;\n      if (!box.fullSize) {\n        refitBoxes.push(layout);\n      }\n    }\n    return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;\n  }\n  function setBoxDims(box, left, top, width, height) {\n    box.top = top;\n    box.left = left;\n    box.right = left + width;\n    box.bottom = top + height;\n    box.width = width;\n    box.height = height;\n  }\n  function placeBoxes(boxes, chartArea, params, stacks) {\n    var userPadding = params.padding;\n    var x = chartArea.x,\n      y = chartArea.y;\n    var _iterator6 = _createForOfIteratorHelper$1(boxes),\n      _step6;\n    try {\n      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n        var layout = _step6.value;\n        var box = layout.box;\n        var stack = stacks[layout.stack] || {\n          count: 1,\n          placed: 0,\n          weight: 1\n        };\n        var weight = layout.stackWeight / stack.weight || 1;\n        if (layout.horizontal) {\n          var width = chartArea.w * weight;\n          var height = stack.size || box.height;\n          if (defined(stack.start)) {\n            y = stack.start;\n          }\n          if (box.fullSize) {\n            setBoxDims(box, userPadding.left, y, params.outerWidth - userPadding.right - userPadding.left, height);\n          } else {\n            setBoxDims(box, chartArea.left + stack.placed, y, width, height);\n          }\n          stack.start = y;\n          stack.placed += width;\n          y = box.bottom;\n        } else {\n          var height1 = chartArea.h * weight;\n          var width1 = stack.size || box.width;\n          if (defined(stack.start)) {\n            x = stack.start;\n          }\n          if (box.fullSize) {\n            setBoxDims(box, x, userPadding.top, width1, params.outerHeight - userPadding.bottom - userPadding.top);\n          } else {\n            setBoxDims(box, x, chartArea.top + stack.placed, width1, height1);\n          }\n          stack.start = x;\n          stack.placed += height1;\n          x = box.right;\n        }\n      }\n    } catch (err) {\n      _iterator6.e(err);\n    } finally {\n      _iterator6.f();\n    }\n    chartArea.x = x;\n    chartArea.y = y;\n  }\n  var layouts = {\n    addBox: function addBox(chart, item) {\n      if (!chart.boxes) {\n        chart.boxes = [];\n      }\n      item.fullSize = item.fullSize || false;\n      item.position = item.position || 'top';\n      item.weight = item.weight || 0;\n      item._layers = item._layers || function () {\n        return [{\n          z: 0,\n          draw: function draw(chartArea) {\n            item.draw(chartArea);\n          }\n        }];\n      };\n      chart.boxes.push(item);\n    },\n    removeBox: function removeBox(chart, layoutItem) {\n      var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;\n      if (index !== -1) {\n        chart.boxes.splice(index, 1);\n      }\n    },\n    configure: function configure(chart, item, options) {\n      item.fullSize = options.fullSize;\n      item.position = options.position;\n      item.weight = options.weight;\n    },\n    update: function update(chart, width, height, minPadding) {\n      if (!chart) {\n        return;\n      }\n      var padding = toPadding(chart.options.layout.padding);\n      var availableWidth = Math.max(width - padding.width, 0);\n      var availableHeight = Math.max(height - padding.height, 0);\n      var boxes = buildLayoutBoxes(chart.boxes);\n      var verticalBoxes = boxes.vertical;\n      var horizontalBoxes = boxes.horizontal;\n      each(chart.boxes, function (box) {\n        if (typeof box.beforeLayout === 'function') {\n          box.beforeLayout();\n        }\n      });\n      var visibleVerticalBoxCount = verticalBoxes.reduce(function (total, wrap) {\n        return wrap.box.options && wrap.box.options.display === false ? total : total + 1;\n      }, 0) || 1;\n      var params = Object.freeze({\n        outerWidth: width,\n        outerHeight: height,\n        padding: padding,\n        availableWidth: availableWidth,\n        availableHeight: availableHeight,\n        vBoxMaxWidth: availableWidth / 2 / visibleVerticalBoxCount,\n        hBoxMaxHeight: availableHeight / 2\n      });\n      var maxPadding = Object.assign({}, padding);\n      updateMaxPadding(maxPadding, toPadding(minPadding));\n      var chartArea = Object.assign({\n        maxPadding: maxPadding,\n        w: availableWidth,\n        h: availableHeight,\n        x: padding.left,\n        y: padding.top\n      }, padding);\n      var stacks = setLayoutDims(verticalBoxes.concat(horizontalBoxes), params);\n      fitBoxes(boxes.fullSize, chartArea, params, stacks);\n      fitBoxes(verticalBoxes, chartArea, params, stacks);\n      if (fitBoxes(horizontalBoxes, chartArea, params, stacks)) {\n        fitBoxes(verticalBoxes, chartArea, params, stacks);\n      }\n      handleMaxPadding(chartArea);\n      placeBoxes(boxes.leftAndTop, chartArea, params, stacks);\n      chartArea.x += chartArea.w;\n      chartArea.y += chartArea.h;\n      placeBoxes(boxes.rightAndBottom, chartArea, params, stacks);\n      chart.chartArea = {\n        left: chartArea.left,\n        top: chartArea.top,\n        right: chartArea.left + chartArea.w,\n        bottom: chartArea.top + chartArea.h,\n        height: chartArea.h,\n        width: chartArea.w\n      };\n      each(boxes.chartArea, function (layout) {\n        var box = layout.box;\n        Object.assign(box, chart.chartArea);\n        box.update(chartArea.w, chartArea.h, {\n          left: 0,\n          top: 0,\n          right: 0,\n          bottom: 0\n        });\n      });\n    }\n  };\n  var BasePlatform = /*#__PURE__*/function () {\n    function BasePlatform() {\n      _classCallCheck$x(this, BasePlatform);\n    }\n    _createClass$x(BasePlatform, [{\n      key: \"acquireContext\",\n      value: function acquireContext(canvas, aspectRatio) {}\n    }, {\n      key: \"releaseContext\",\n      value: function releaseContext(context) {\n        return false;\n      }\n    }, {\n      key: \"addEventListener\",\n      value: function addEventListener(chart, type, listener) {}\n    }, {\n      key: \"removeEventListener\",\n      value: function removeEventListener(chart, type, listener) {}\n    }, {\n      key: \"getDevicePixelRatio\",\n      value: function getDevicePixelRatio() {\n        return 1;\n      }\n    }, {\n      key: \"getMaximumSize\",\n      value: function getMaximumSize(element, width, height, aspectRatio) {\n        width = Math.max(0, width || element.width);\n        height = height || element.height;\n        return {\n          width: width,\n          height: Math.max(0, aspectRatio ? Math.floor(width / aspectRatio) : height)\n        };\n      }\n    }, {\n      key: \"isAttached\",\n      value: function isAttached(canvas) {\n        return true;\n      }\n    }, {\n      key: \"updateConfig\",\n      value: function updateConfig(config) {}\n    }]);\n    return BasePlatform;\n  }();\n  var BasicPlatform = /*#__PURE__*/function (_BasePlatform) {\n    _inherits$w(BasicPlatform, _BasePlatform);\n    var _super9 = _createSuper$w(BasicPlatform);\n    function BasicPlatform() {\n      _classCallCheck$x(this, BasicPlatform);\n      return _super9.apply(this, arguments);\n    }\n    _createClass$x(BasicPlatform, [{\n      key: \"acquireContext\",\n      value: function acquireContext(item) {\n        return item && item.getContext && item.getContext('2d') || null;\n      }\n    }, {\n      key: \"updateConfig\",\n      value: function updateConfig(config) {\n        config.options.animation = false;\n      }\n    }]);\n    return BasicPlatform;\n  }(BasePlatform);\n  var EXPANDO_KEY = '$chartjs';\n  var EVENT_TYPES = {\n    touchstart: 'mousedown',\n    touchmove: 'mousemove',\n    touchend: 'mouseup',\n    pointerenter: 'mouseenter',\n    pointerdown: 'mousedown',\n    pointermove: 'mousemove',\n    pointerup: 'mouseup',\n    pointerleave: 'mouseout',\n    pointerout: 'mouseout'\n  };\n  var isNullOrEmpty = function isNullOrEmpty(value) {\n    return value === null || value === '';\n  };\n  function initCanvas(canvas, aspectRatio) {\n    var style = canvas.style;\n    var renderHeight = canvas.getAttribute('height');\n    var renderWidth = canvas.getAttribute('width');\n    canvas[EXPANDO_KEY] = {\n      initial: {\n        height: renderHeight,\n        width: renderWidth,\n        style: {\n          display: style.display,\n          height: style.height,\n          width: style.width\n        }\n      }\n    };\n    style.display = style.display || 'block';\n    style.boxSizing = style.boxSizing || 'border-box';\n    if (isNullOrEmpty(renderWidth)) {\n      var displayWidth = readUsedSize(canvas, 'width');\n      if (displayWidth !== undefined) {\n        canvas.width = displayWidth;\n      }\n    }\n    if (isNullOrEmpty(renderHeight)) {\n      if (canvas.style.height === '') {\n        canvas.height = canvas.width / (aspectRatio || 2);\n      } else {\n        var displayHeight = readUsedSize(canvas, 'height');\n        if (displayHeight !== undefined) {\n          canvas.height = displayHeight;\n        }\n      }\n    }\n    return canvas;\n  }\n  var eventListenerOptions = supportsEventListenerOptions ? {\n    passive: true\n  } : false;\n  function addListener(node, type, listener) {\n    node.addEventListener(type, listener, eventListenerOptions);\n  }\n  function removeListener(chart, type, listener) {\n    chart.canvas.removeEventListener(type, listener, eventListenerOptions);\n  }\n  function fromNativeEvent(event, chart) {\n    var type = EVENT_TYPES[event.type] || event.type;\n    var _getRelativePosition = getRelativePosition(event, chart),\n      x = _getRelativePosition.x,\n      y = _getRelativePosition.y;\n    return {\n      type: type,\n      chart: chart,\n      \"native\": event,\n      x: x !== undefined ? x : null,\n      y: y !== undefined ? y : null\n    };\n  }\n  function nodeListContains(nodeList, canvas) {\n    var _iterator7 = _createForOfIteratorHelper$1(nodeList),\n      _step7;\n    try {\n      for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n        var node = _step7.value;\n        if (node === canvas || node.contains(canvas)) {\n          return true;\n        }\n      }\n    } catch (err) {\n      _iterator7.e(err);\n    } finally {\n      _iterator7.f();\n    }\n  }\n  function createAttachObserver(chart, type, listener) {\n    var canvas = chart.canvas;\n    var observer = new MutationObserver(function (entries) {\n      var trigger = false;\n      var _iterator8 = _createForOfIteratorHelper$1(entries),\n        _step8;\n      try {\n        for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n          var entry = _step8.value;\n          trigger = trigger || nodeListContains(entry.addedNodes, canvas);\n          trigger = trigger && !nodeListContains(entry.removedNodes, canvas);\n        }\n      } catch (err) {\n        _iterator8.e(err);\n      } finally {\n        _iterator8.f();\n      }\n      if (trigger) {\n        listener();\n      }\n    });\n    observer.observe(document, {\n      childList: true,\n      subtree: true\n    });\n    return observer;\n  }\n  function createDetachObserver(chart, type, listener) {\n    var canvas = chart.canvas;\n    var observer = new MutationObserver(function (entries) {\n      var trigger = false;\n      var _iterator9 = _createForOfIteratorHelper$1(entries),\n        _step9;\n      try {\n        for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n          var entry = _step9.value;\n          trigger = trigger || nodeListContains(entry.removedNodes, canvas);\n          trigger = trigger && !nodeListContains(entry.addedNodes, canvas);\n        }\n      } catch (err) {\n        _iterator9.e(err);\n      } finally {\n        _iterator9.f();\n      }\n      if (trigger) {\n        listener();\n      }\n    });\n    observer.observe(document, {\n      childList: true,\n      subtree: true\n    });\n    return observer;\n  }\n  var drpListeningCharts = new Map();\n  var oldDevicePixelRatio = 0;\n  function onWindowResize() {\n    var dpr = window.devicePixelRatio;\n    if (dpr === oldDevicePixelRatio) {\n      return;\n    }\n    oldDevicePixelRatio = dpr;\n    drpListeningCharts.forEach(function (resize, chart) {\n      if (chart.currentDevicePixelRatio !== dpr) {\n        resize();\n      }\n    });\n  }\n  function listenDevicePixelRatioChanges(chart, resize) {\n    if (!drpListeningCharts.size) {\n      window.addEventListener('resize', onWindowResize);\n    }\n    drpListeningCharts.set(chart, resize);\n  }\n  function unlistenDevicePixelRatioChanges(chart) {\n    drpListeningCharts[\"delete\"](chart);\n    if (!drpListeningCharts.size) {\n      window.removeEventListener('resize', onWindowResize);\n    }\n  }\n  function createResizeObserver(chart, type, listener) {\n    var canvas = chart.canvas;\n    var container = canvas && _getParentNode(canvas);\n    if (!container) {\n      return;\n    }\n    var resize = throttled(function (width, height) {\n      var w = container.clientWidth;\n      listener(width, height);\n      if (w < container.clientWidth) {\n        listener();\n      }\n    }, window);\n    var observer = new ResizeObserver(function (entries) {\n      var entry = entries[0];\n      var width = entry.contentRect.width;\n      var height = entry.contentRect.height;\n      if (width === 0 && height === 0) {\n        return;\n      }\n      resize(width, height);\n    });\n    observer.observe(container);\n    listenDevicePixelRatioChanges(chart, resize);\n    return observer;\n  }\n  function releaseObserver(chart, type, observer) {\n    if (observer) {\n      observer.disconnect();\n    }\n    if (type === 'resize') {\n      unlistenDevicePixelRatioChanges(chart);\n    }\n  }\n  function createProxyAndListen(chart, type, listener) {\n    var canvas = chart.canvas;\n    var proxy = throttled(function (event) {\n      if (chart.ctx !== null) {\n        listener(fromNativeEvent(event, chart));\n      }\n    }, chart);\n    addListener(canvas, type, proxy);\n    return proxy;\n  }\n  var DomPlatform = /*#__PURE__*/function (_BasePlatform2) {\n    _inherits$w(DomPlatform, _BasePlatform2);\n    var _super10 = _createSuper$w(DomPlatform);\n    function DomPlatform() {\n      _classCallCheck$x(this, DomPlatform);\n      return _super10.apply(this, arguments);\n    }\n    _createClass$x(DomPlatform, [{\n      key: \"acquireContext\",\n      value: function acquireContext(canvas, aspectRatio) {\n        var context = canvas && canvas.getContext && canvas.getContext('2d');\n        if (context && context.canvas === canvas) {\n          initCanvas(canvas, aspectRatio);\n          return context;\n        }\n        return null;\n      }\n    }, {\n      key: \"releaseContext\",\n      value: function releaseContext(context) {\n        var canvas = context.canvas;\n        if (!canvas[EXPANDO_KEY]) {\n          return false;\n        }\n        var initial = canvas[EXPANDO_KEY].initial;\n        ['height', 'width'].forEach(function (prop) {\n          var value = initial[prop];\n          if (isNullOrUndef(value)) {\n            canvas.removeAttribute(prop);\n          } else {\n            canvas.setAttribute(prop, value);\n          }\n        });\n        var style = initial.style || {};\n        Object.keys(style).forEach(function (key) {\n          canvas.style[key] = style[key];\n        });\n        canvas.width = canvas.width;\n        delete canvas[EXPANDO_KEY];\n        return true;\n      }\n    }, {\n      key: \"addEventListener\",\n      value: function addEventListener(chart, type, listener) {\n        this.removeEventListener(chart, type);\n        var proxies = chart.$proxies || (chart.$proxies = {});\n        var handlers = {\n          attach: createAttachObserver,\n          detach: createDetachObserver,\n          resize: createResizeObserver\n        };\n        var handler = handlers[type] || createProxyAndListen;\n        proxies[type] = handler(chart, type, listener);\n      }\n    }, {\n      key: \"removeEventListener\",\n      value: function removeEventListener(chart, type) {\n        var proxies = chart.$proxies || (chart.$proxies = {});\n        var proxy = proxies[type];\n        if (!proxy) {\n          return;\n        }\n        var handlers = {\n          attach: releaseObserver,\n          detach: releaseObserver,\n          resize: releaseObserver\n        };\n        var handler = handlers[type] || removeListener;\n        handler(chart, type, proxy);\n        proxies[type] = undefined;\n      }\n    }, {\n      key: \"getDevicePixelRatio\",\n      value: function getDevicePixelRatio() {\n        return window.devicePixelRatio;\n      }\n    }, {\n      key: \"getMaximumSize\",\n      value: function getMaximumSize$1(canvas, width, height, aspectRatio) {\n        return getMaximumSize(canvas, width, height, aspectRatio);\n      }\n    }, {\n      key: \"isAttached\",\n      value: function isAttached(canvas) {\n        var container = _getParentNode(canvas);\n        return !!(container && container.isConnected);\n      }\n    }]);\n    return DomPlatform;\n  }(BasePlatform);\n  function _detectPlatform(canvas) {\n    if (!_isDomSupported() || typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {\n      return BasicPlatform;\n    }\n    return DomPlatform;\n  }\n  var Element = /*#__PURE__*/function () {\n    function Element() {\n      _classCallCheck$x(this, Element);\n      _defineProperty$w(this, \"active\", false);\n    }\n    _createClass$x(Element, [{\n      key: \"tooltipPosition\",\n      value: function tooltipPosition(useFinalPosition) {\n        var _this$getProps = this.getProps(['x', 'y'], useFinalPosition),\n          x = _this$getProps.x,\n          y = _this$getProps.y;\n        return {\n          x: x,\n          y: y\n        };\n      }\n    }, {\n      key: \"hasValue\",\n      value: function hasValue() {\n        return isNumber(this.x) && isNumber(this.y);\n      }\n    }, {\n      key: \"getProps\",\n      value: function getProps(props, _final) {\n        var _this8 = this;\n        var anims = this.$animations;\n        if (!_final || !anims) {\n          // let's not create an object, if not needed\n          return this;\n        }\n        var ret = {};\n        props.forEach(function (prop) {\n          ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : _this8[prop];\n        });\n        return ret;\n      }\n    }]);\n    return Element;\n  }();\n  _defineProperty$w(Element, \"defaults\", {});\n  _defineProperty$w(Element, \"defaultRoutes\", undefined);\n  function autoSkip(scale, ticks) {\n    var tickOpts = scale.options.ticks;\n    var determinedMaxTicks = determineMaxTicks(scale);\n    var ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks);\n    var majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];\n    var numMajorIndices = majorIndices.length;\n    var first = majorIndices[0];\n    var last = majorIndices[numMajorIndices - 1];\n    var newTicks = [];\n    if (numMajorIndices > ticksLimit) {\n      skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit);\n      return newTicks;\n    }\n    var spacing = calculateSpacing(majorIndices, ticks, ticksLimit);\n    if (numMajorIndices > 0) {\n      var i, ilen;\n      var avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null;\n      skip(ticks, newTicks, spacing, isNullOrUndef(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first);\n      for (i = 0, ilen = numMajorIndices - 1; i < ilen; i++) {\n        skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]);\n      }\n      skip(ticks, newTicks, spacing, last, isNullOrUndef(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing);\n      return newTicks;\n    }\n    skip(ticks, newTicks, spacing);\n    return newTicks;\n  }\n  function determineMaxTicks(scale) {\n    var offset = scale.options.offset;\n    var tickLength = scale._tickSize();\n    var maxScale = scale._length / tickLength + (offset ? 0 : 1);\n    var maxChart = scale._maxLength / tickLength;\n    return Math.floor(Math.min(maxScale, maxChart));\n  }\n  function calculateSpacing(majorIndices, ticks, ticksLimit) {\n    var evenMajorSpacing = getEvenSpacing(majorIndices);\n    var spacing = ticks.length / ticksLimit;\n    if (!evenMajorSpacing) {\n      return Math.max(spacing, 1);\n    }\n    var factors = _factorize(evenMajorSpacing);\n    for (var i = 0, ilen = factors.length - 1; i < ilen; i++) {\n      var factor = factors[i];\n      if (factor > spacing) {\n        return factor;\n      }\n    }\n    return Math.max(spacing, 1);\n  }\n  function getMajorIndices(ticks) {\n    var result = [];\n    var i, ilen;\n    for (i = 0, ilen = ticks.length; i < ilen; i++) {\n      if (ticks[i].major) {\n        result.push(i);\n      }\n    }\n    return result;\n  }\n  function skipMajors(ticks, newTicks, majorIndices, spacing) {\n    var count = 0;\n    var next = majorIndices[0];\n    var i;\n    spacing = Math.ceil(spacing);\n    for (i = 0; i < ticks.length; i++) {\n      if (i === next) {\n        newTicks.push(ticks[i]);\n        count++;\n        next = majorIndices[count * spacing];\n      }\n    }\n  }\n  function skip(ticks, newTicks, spacing, majorStart, majorEnd) {\n    var start = valueOrDefault(majorStart, 0);\n    var end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length);\n    var count = 0;\n    var length, i, next;\n    spacing = Math.ceil(spacing);\n    if (majorEnd) {\n      length = majorEnd - majorStart;\n      spacing = length / Math.floor(length / spacing);\n    }\n    next = start;\n    while (next < 0) {\n      count++;\n      next = Math.round(start + count * spacing);\n    }\n    for (i = Math.max(start, 0); i < end; i++) {\n      if (i === next) {\n        newTicks.push(ticks[i]);\n        count++;\n        next = Math.round(start + count * spacing);\n      }\n    }\n  }\n  function getEvenSpacing(arr) {\n    var len = arr.length;\n    var i, diff;\n    if (len < 2) {\n      return false;\n    }\n    for (diff = arr[0], i = 1; i < len; ++i) {\n      if (arr[i] - arr[i - 1] !== diff) {\n        return false;\n      }\n    }\n    return diff;\n  }\n  var reverseAlign = function reverseAlign(align) {\n    return align === 'left' ? 'right' : align === 'right' ? 'left' : align;\n  };\n  var offsetFromEdge = function offsetFromEdge(scale, edge, offset) {\n    return edge === 'top' || edge === 'left' ? scale[edge] + offset : scale[edge] - offset;\n  };\n  function sample(arr, numItems) {\n    var result = [];\n    var increment = arr.length / numItems;\n    var len = arr.length;\n    var i = 0;\n    for (; i < len; i += increment) {\n      result.push(arr[Math.floor(i)]);\n    }\n    return result;\n  }\n  function getPixelForGridLine(scale, index, offsetGridLines) {\n    var length = scale.ticks.length;\n    var validIndex = Math.min(index, length - 1);\n    var start = scale._startPixel;\n    var end = scale._endPixel;\n    var epsilon = 1e-6;\n    var lineValue = scale.getPixelForTick(validIndex);\n    var offset;\n    if (offsetGridLines) {\n      if (length === 1) {\n        offset = Math.max(lineValue - start, end - lineValue);\n      } else if (index === 0) {\n        offset = (scale.getPixelForTick(1) - lineValue) / 2;\n      } else {\n        offset = (lineValue - scale.getPixelForTick(validIndex - 1)) / 2;\n      }\n      lineValue += validIndex < index ? offset : -offset;\n      if (lineValue < start - epsilon || lineValue > end + epsilon) {\n        return;\n      }\n    }\n    return lineValue;\n  }\n  function garbageCollect(caches, length) {\n    each(caches, function (cache) {\n      var gc = cache.gc;\n      var gcLen = gc.length / 2;\n      var i;\n      if (gcLen > length) {\n        for (i = 0; i < gcLen; ++i) {\n          delete cache.data[gc[i]];\n        }\n        gc.splice(0, gcLen);\n      }\n    });\n  }\n  function getTickMarkLength(options) {\n    return options.drawTicks ? options.tickLength : 0;\n  }\n  function getTitleHeight(options, fallback) {\n    if (!options.display) {\n      return 0;\n    }\n    var font = toFont(options.font, fallback);\n    var padding = toPadding(options.padding);\n    var lines = isArray(options.text) ? options.text.length : 1;\n    return lines * font.lineHeight + padding.height;\n  }\n  function createScaleContext(parent, scale) {\n    return createContext(parent, {\n      scale: scale,\n      type: 'scale'\n    });\n  }\n  function createTickContext(parent, index, tick) {\n    return createContext(parent, {\n      tick: tick,\n      index: index,\n      type: 'tick'\n    });\n  }\n  function titleAlign(align, position, reverse) {\n    var ret = _toLeftRightCenter(align);\n    if (reverse && position !== 'right' || !reverse && position === 'right') {\n      ret = reverseAlign(ret);\n    }\n    return ret;\n  }\n  function titleArgs(scale, offset, position, align) {\n    var top = scale.top,\n      left = scale.left,\n      bottom = scale.bottom,\n      right = scale.right,\n      chart = scale.chart;\n    var chartArea = chart.chartArea,\n      scales = chart.scales;\n    var rotation = 0;\n    var maxWidth, titleX, titleY;\n    var height = bottom - top;\n    var width = right - left;\n    if (scale.isHorizontal()) {\n      titleX = _alignStartEnd(align, left, right);\n      if (isObject(position)) {\n        var positionAxisID = Object.keys(position)[0];\n        var value = position[positionAxisID];\n        titleY = scales[positionAxisID].getPixelForValue(value) + height - offset;\n      } else if (position === 'center') {\n        titleY = (chartArea.bottom + chartArea.top) / 2 + height - offset;\n      } else {\n        titleY = offsetFromEdge(scale, position, offset);\n      }\n      maxWidth = right - left;\n    } else {\n      if (isObject(position)) {\n        var positionAxisID1 = Object.keys(position)[0];\n        var value1 = position[positionAxisID1];\n        titleX = scales[positionAxisID1].getPixelForValue(value1) - width + offset;\n      } else if (position === 'center') {\n        titleX = (chartArea.left + chartArea.right) / 2 - width + offset;\n      } else {\n        titleX = offsetFromEdge(scale, position, offset);\n      }\n      titleY = _alignStartEnd(align, bottom, top);\n      rotation = position === 'left' ? -HALF_PI : HALF_PI;\n    }\n    return {\n      titleX: titleX,\n      titleY: titleY,\n      maxWidth: maxWidth,\n      rotation: rotation\n    };\n  }\n  var Scale = /*#__PURE__*/function (_Element) {\n    _inherits$w(Scale, _Element);\n    var _super11 = _createSuper$w(Scale);\n    function Scale(cfg) {\n      var _this9;\n      _classCallCheck$x(this, Scale);\n      _this9 = _super11.call(this);\n      _this9.id = cfg.id;\n      _this9.type = cfg.type;\n      _this9.options = undefined;\n      _this9.ctx = cfg.ctx;\n      _this9.chart = cfg.chart;\n      _this9.top = undefined;\n      _this9.bottom = undefined;\n      _this9.left = undefined;\n      _this9.right = undefined;\n      _this9.width = undefined;\n      _this9.height = undefined;\n      _this9._margins = {\n        left: 0,\n        right: 0,\n        top: 0,\n        bottom: 0\n      };\n      _this9.maxWidth = undefined;\n      _this9.maxHeight = undefined;\n      _this9.paddingTop = undefined;\n      _this9.paddingBottom = undefined;\n      _this9.paddingLeft = undefined;\n      _this9.paddingRight = undefined;\n      _this9.axis = undefined;\n      _this9.labelRotation = undefined;\n      _this9.min = undefined;\n      _this9.max = undefined;\n      _this9._range = undefined;\n      _this9.ticks = [];\n      _this9._gridLineItems = null;\n      _this9._labelItems = null;\n      _this9._labelSizes = null;\n      _this9._length = 0;\n      _this9._maxLength = 0;\n      _this9._longestTextCache = {};\n      _this9._startPixel = undefined;\n      _this9._endPixel = undefined;\n      _this9._reversePixels = false;\n      _this9._userMax = undefined;\n      _this9._userMin = undefined;\n      _this9._suggestedMax = undefined;\n      _this9._suggestedMin = undefined;\n      _this9._ticksLength = 0;\n      _this9._borderValue = 0;\n      _this9._cache = {};\n      _this9._dataLimitsCached = false;\n      _this9.$context = undefined;\n      return _this9;\n    }\n    _createClass$x(Scale, [{\n      key: \"init\",\n      value: function init(options) {\n        this.options = options.setContext(this.getContext());\n        this.axis = options.axis;\n        this._userMin = this.parse(options.min);\n        this._userMax = this.parse(options.max);\n        this._suggestedMin = this.parse(options.suggestedMin);\n        this._suggestedMax = this.parse(options.suggestedMax);\n      }\n    }, {\n      key: \"parse\",\n      value: function parse(raw, index) {\n        return raw;\n      }\n    }, {\n      key: \"getUserBounds\",\n      value: function getUserBounds() {\n        var _userMin = this._userMin,\n          _userMax = this._userMax,\n          _suggestedMin = this._suggestedMin,\n          _suggestedMax = this._suggestedMax;\n        _userMin = finiteOrDefault(_userMin, Number.POSITIVE_INFINITY);\n        _userMax = finiteOrDefault(_userMax, Number.NEGATIVE_INFINITY);\n        _suggestedMin = finiteOrDefault(_suggestedMin, Number.POSITIVE_INFINITY);\n        _suggestedMax = finiteOrDefault(_suggestedMax, Number.NEGATIVE_INFINITY);\n        return {\n          min: finiteOrDefault(_userMin, _suggestedMin),\n          max: finiteOrDefault(_userMax, _suggestedMax),\n          minDefined: isNumberFinite(_userMin),\n          maxDefined: isNumberFinite(_userMax)\n        };\n      }\n    }, {\n      key: \"getMinMax\",\n      value: function getMinMax(canStack) {\n        var _this$getUserBounds = this.getUserBounds(),\n          min = _this$getUserBounds.min,\n          max = _this$getUserBounds.max,\n          minDefined = _this$getUserBounds.minDefined,\n          maxDefined = _this$getUserBounds.maxDefined;\n        var range;\n        if (minDefined && maxDefined) {\n          return {\n            min: min,\n            max: max\n          };\n        }\n        var metas = this.getMatchingVisibleMetas();\n        for (var i = 0, ilen = metas.length; i < ilen; ++i) {\n          range = metas[i].controller.getMinMax(this, canStack);\n          if (!minDefined) {\n            min = Math.min(min, range.min);\n          }\n          if (!maxDefined) {\n            max = Math.max(max, range.max);\n          }\n        }\n        min = maxDefined && min > max ? max : min;\n        max = minDefined && min > max ? min : max;\n        return {\n          min: finiteOrDefault(min, finiteOrDefault(max, min)),\n          max: finiteOrDefault(max, finiteOrDefault(min, max))\n        };\n      }\n    }, {\n      key: \"getPadding\",\n      value: function getPadding() {\n        return {\n          left: this.paddingLeft || 0,\n          top: this.paddingTop || 0,\n          right: this.paddingRight || 0,\n          bottom: this.paddingBottom || 0\n        };\n      }\n    }, {\n      key: \"getTicks\",\n      value: function getTicks() {\n        return this.ticks;\n      }\n    }, {\n      key: \"getLabels\",\n      value: function getLabels() {\n        var data = this.chart.data;\n        return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || [];\n      }\n    }, {\n      key: \"getLabelItems\",\n      value: function getLabelItems() {\n        var chartArea = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.chart.chartArea;\n        var items = this._labelItems || (this._labelItems = this._computeLabelItems(chartArea));\n        return items;\n      }\n    }, {\n      key: \"beforeLayout\",\n      value: function beforeLayout() {\n        this._cache = {};\n        this._dataLimitsCached = false;\n      }\n    }, {\n      key: \"beforeUpdate\",\n      value: function beforeUpdate() {\n        callback(this.options.beforeUpdate, [this]);\n      }\n    }, {\n      key: \"update\",\n      value: function update(maxWidth, maxHeight, margins) {\n        var _this$options4 = this.options,\n          beginAtZero = _this$options4.beginAtZero,\n          grace = _this$options4.grace,\n          tickOpts = _this$options4.ticks;\n        var sampleSize = tickOpts.sampleSize;\n        this.beforeUpdate();\n        this.maxWidth = maxWidth;\n        this.maxHeight = maxHeight;\n        this._margins = margins = Object.assign({\n          left: 0,\n          right: 0,\n          top: 0,\n          bottom: 0\n        }, margins);\n        this.ticks = null;\n        this._labelSizes = null;\n        this._gridLineItems = null;\n        this._labelItems = null;\n        this.beforeSetDimensions();\n        this.setDimensions();\n        this.afterSetDimensions();\n        this._maxLength = this.isHorizontal() ? this.width + margins.left + margins.right : this.height + margins.top + margins.bottom;\n        if (!this._dataLimitsCached) {\n          this.beforeDataLimits();\n          this.determineDataLimits();\n          this.afterDataLimits();\n          this._range = _addGrace(this, grace, beginAtZero);\n          this._dataLimitsCached = true;\n        }\n        this.beforeBuildTicks();\n        this.ticks = this.buildTicks() || [];\n        this.afterBuildTicks();\n        var samplingEnabled = sampleSize < this.ticks.length;\n        this._convertTicksToLabels(samplingEnabled ? sample(this.ticks, sampleSize) : this.ticks);\n        this.configure();\n        this.beforeCalculateLabelRotation();\n        this.calculateLabelRotation();\n        this.afterCalculateLabelRotation();\n        if (tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto')) {\n          this.ticks = autoSkip(this, this.ticks);\n          this._labelSizes = null;\n          this.afterAutoSkip();\n        }\n        if (samplingEnabled) {\n          this._convertTicksToLabels(this.ticks);\n        }\n        this.beforeFit();\n        this.fit();\n        this.afterFit();\n        this.afterUpdate();\n      }\n    }, {\n      key: \"configure\",\n      value: function configure() {\n        var reversePixels = this.options.reverse;\n        var startPixel, endPixel;\n        if (this.isHorizontal()) {\n          startPixel = this.left;\n          endPixel = this.right;\n        } else {\n          startPixel = this.top;\n          endPixel = this.bottom;\n          reversePixels = !reversePixels;\n        }\n        this._startPixel = startPixel;\n        this._endPixel = endPixel;\n        this._reversePixels = reversePixels;\n        this._length = endPixel - startPixel;\n        this._alignToPixels = this.options.alignToPixels;\n      }\n    }, {\n      key: \"afterUpdate\",\n      value: function afterUpdate() {\n        callback(this.options.afterUpdate, [this]);\n      }\n    }, {\n      key: \"beforeSetDimensions\",\n      value: function beforeSetDimensions() {\n        callback(this.options.beforeSetDimensions, [this]);\n      }\n    }, {\n      key: \"setDimensions\",\n      value: function setDimensions() {\n        if (this.isHorizontal()) {\n          this.width = this.maxWidth;\n          this.left = 0;\n          this.right = this.width;\n        } else {\n          this.height = this.maxHeight;\n          this.top = 0;\n          this.bottom = this.height;\n        }\n        this.paddingLeft = 0;\n        this.paddingTop = 0;\n        this.paddingRight = 0;\n        this.paddingBottom = 0;\n      }\n    }, {\n      key: \"afterSetDimensions\",\n      value: function afterSetDimensions() {\n        callback(this.options.afterSetDimensions, [this]);\n      }\n    }, {\n      key: \"_callHooks\",\n      value: function _callHooks(name) {\n        this.chart.notifyPlugins(name, this.getContext());\n        callback(this.options[name], [this]);\n      }\n    }, {\n      key: \"beforeDataLimits\",\n      value: function beforeDataLimits() {\n        this._callHooks('beforeDataLimits');\n      }\n    }, {\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {}\n    }, {\n      key: \"afterDataLimits\",\n      value: function afterDataLimits() {\n        this._callHooks('afterDataLimits');\n      }\n    }, {\n      key: \"beforeBuildTicks\",\n      value: function beforeBuildTicks() {\n        this._callHooks('beforeBuildTicks');\n      }\n    }, {\n      key: \"buildTicks\",\n      value: function buildTicks() {\n        return [];\n      }\n    }, {\n      key: \"afterBuildTicks\",\n      value: function afterBuildTicks() {\n        this._callHooks('afterBuildTicks');\n      }\n    }, {\n      key: \"beforeTickToLabelConversion\",\n      value: function beforeTickToLabelConversion() {\n        callback(this.options.beforeTickToLabelConversion, [this]);\n      }\n    }, {\n      key: \"generateTickLabels\",\n      value: function generateTickLabels(ticks) {\n        var tickOpts = this.options.ticks;\n        var i, ilen, tick;\n        for (i = 0, ilen = ticks.length; i < ilen; i++) {\n          tick = ticks[i];\n          tick.label = callback(tickOpts.callback, [tick.value, i, ticks], this);\n        }\n      }\n    }, {\n      key: \"afterTickToLabelConversion\",\n      value: function afterTickToLabelConversion() {\n        callback(this.options.afterTickToLabelConversion, [this]);\n      }\n    }, {\n      key: \"beforeCalculateLabelRotation\",\n      value: function beforeCalculateLabelRotation() {\n        callback(this.options.beforeCalculateLabelRotation, [this]);\n      }\n    }, {\n      key: \"calculateLabelRotation\",\n      value: function calculateLabelRotation() {\n        var options = this.options;\n        var tickOpts = options.ticks;\n        var numTicks = this.ticks.length;\n        var minRotation = tickOpts.minRotation || 0;\n        var maxRotation = tickOpts.maxRotation;\n        var labelRotation = minRotation;\n        var tickWidth, maxHeight, maxLabelDiagonal;\n        if (!this._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !this.isHorizontal()) {\n          this.labelRotation = minRotation;\n          return;\n        }\n        var labelSizes = this._getLabelSizes();\n        var maxLabelWidth = labelSizes.widest.width;\n        var maxLabelHeight = labelSizes.highest.height;\n        var maxWidth = _limitValue(this.chart.width - maxLabelWidth, 0, this.maxWidth);\n        tickWidth = options.offset ? this.maxWidth / numTicks : maxWidth / (numTicks - 1);\n        if (maxLabelWidth + 6 > tickWidth) {\n          tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1));\n          maxHeight = this.maxHeight - getTickMarkLength(options.grid) - tickOpts.padding - getTitleHeight(options.title, this.chart.options.font);\n          maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);\n          labelRotation = toDegrees(Math.min(Math.asin(_limitValue((labelSizes.highest.height + 6) / tickWidth, -1, 1)), Math.asin(_limitValue(maxHeight / maxLabelDiagonal, -1, 1)) - Math.asin(_limitValue(maxLabelHeight / maxLabelDiagonal, -1, 1))));\n          labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation));\n        }\n        this.labelRotation = labelRotation;\n      }\n    }, {\n      key: \"afterCalculateLabelRotation\",\n      value: function afterCalculateLabelRotation() {\n        callback(this.options.afterCalculateLabelRotation, [this]);\n      }\n    }, {\n      key: \"afterAutoSkip\",\n      value: function afterAutoSkip() {}\n    }, {\n      key: \"beforeFit\",\n      value: function beforeFit() {\n        callback(this.options.beforeFit, [this]);\n      }\n    }, {\n      key: \"fit\",\n      value: function fit() {\n        var minSize = {\n          width: 0,\n          height: 0\n        };\n        var chart = this.chart,\n          _this$options5 = this.options,\n          tickOpts = _this$options5.ticks,\n          titleOpts = _this$options5.title,\n          gridOpts = _this$options5.grid;\n        var display = this._isVisible();\n        var isHorizontal = this.isHorizontal();\n        if (display) {\n          var titleHeight = getTitleHeight(titleOpts, chart.options.font);\n          if (isHorizontal) {\n            minSize.width = this.maxWidth;\n            minSize.height = getTickMarkLength(gridOpts) + titleHeight;\n          } else {\n            minSize.height = this.maxHeight;\n            minSize.width = getTickMarkLength(gridOpts) + titleHeight;\n          }\n          if (tickOpts.display && this.ticks.length) {\n            var _this$_getLabelSizes = this._getLabelSizes(),\n              first = _this$_getLabelSizes.first,\n              last = _this$_getLabelSizes.last,\n              widest = _this$_getLabelSizes.widest,\n              highest = _this$_getLabelSizes.highest;\n            var tickPadding = tickOpts.padding * 2;\n            var angleRadians = toRadians(this.labelRotation);\n            var cos = Math.cos(angleRadians);\n            var sin = Math.sin(angleRadians);\n            if (isHorizontal) {\n              var labelHeight = tickOpts.mirror ? 0 : sin * widest.width + cos * highest.height;\n              minSize.height = Math.min(this.maxHeight, minSize.height + labelHeight + tickPadding);\n            } else {\n              var labelWidth = tickOpts.mirror ? 0 : cos * widest.width + sin * highest.height;\n              minSize.width = Math.min(this.maxWidth, minSize.width + labelWidth + tickPadding);\n            }\n            this._calculatePadding(first, last, sin, cos);\n          }\n        }\n        this._handleMargins();\n        if (isHorizontal) {\n          this.width = this._length = chart.width - this._margins.left - this._margins.right;\n          this.height = minSize.height;\n        } else {\n          this.width = minSize.width;\n          this.height = this._length = chart.height - this._margins.top - this._margins.bottom;\n        }\n      }\n    }, {\n      key: \"_calculatePadding\",\n      value: function _calculatePadding(first, last, sin, cos) {\n        var _this$options6 = this.options,\n          _this$options6$ticks = _this$options6.ticks,\n          align = _this$options6$ticks.align,\n          padding = _this$options6$ticks.padding,\n          position = _this$options6.position;\n        var isRotated = this.labelRotation !== 0;\n        var labelsBelowTicks = position !== 'top' && this.axis === 'x';\n        if (this.isHorizontal()) {\n          var offsetLeft = this.getPixelForTick(0) - this.left;\n          var offsetRight = this.right - this.getPixelForTick(this.ticks.length - 1);\n          var paddingLeft = 0;\n          var paddingRight = 0;\n          if (isRotated) {\n            if (labelsBelowTicks) {\n              paddingLeft = cos * first.width;\n              paddingRight = sin * last.height;\n            } else {\n              paddingLeft = sin * first.height;\n              paddingRight = cos * last.width;\n            }\n          } else if (align === 'start') {\n            paddingRight = last.width;\n          } else if (align === 'end') {\n            paddingLeft = first.width;\n          } else if (align !== 'inner') {\n            paddingLeft = first.width / 2;\n            paddingRight = last.width / 2;\n          }\n          this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);\n          this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);\n        } else {\n          var paddingTop = last.height / 2;\n          var paddingBottom = first.height / 2;\n          if (align === 'start') {\n            paddingTop = 0;\n            paddingBottom = first.height;\n          } else if (align === 'end') {\n            paddingTop = last.height;\n            paddingBottom = 0;\n          }\n          this.paddingTop = paddingTop + padding;\n          this.paddingBottom = paddingBottom + padding;\n        }\n      }\n    }, {\n      key: \"_handleMargins\",\n      value: function _handleMargins() {\n        if (this._margins) {\n          this._margins.left = Math.max(this.paddingLeft, this._margins.left);\n          this._margins.top = Math.max(this.paddingTop, this._margins.top);\n          this._margins.right = Math.max(this.paddingRight, this._margins.right);\n          this._margins.bottom = Math.max(this.paddingBottom, this._margins.bottom);\n        }\n      }\n    }, {\n      key: \"afterFit\",\n      value: function afterFit() {\n        callback(this.options.afterFit, [this]);\n      }\n    }, {\n      key: \"isHorizontal\",\n      value: function isHorizontal() {\n        var _this$options7 = this.options,\n          axis = _this$options7.axis,\n          position = _this$options7.position;\n        return position === 'top' || position === 'bottom' || axis === 'x';\n      }\n    }, {\n      key: \"isFullSize\",\n      value: function isFullSize() {\n        return this.options.fullSize;\n      }\n    }, {\n      key: \"_convertTicksToLabels\",\n      value: function _convertTicksToLabels(ticks) {\n        this.beforeTickToLabelConversion();\n        this.generateTickLabels(ticks);\n        var i, ilen;\n        for (i = 0, ilen = ticks.length; i < ilen; i++) {\n          if (isNullOrUndef(ticks[i].label)) {\n            ticks.splice(i, 1);\n            ilen--;\n            i--;\n          }\n        }\n        this.afterTickToLabelConversion();\n      }\n    }, {\n      key: \"_getLabelSizes\",\n      value: function _getLabelSizes() {\n        var labelSizes = this._labelSizes;\n        if (!labelSizes) {\n          var sampleSize = this.options.ticks.sampleSize;\n          var ticks = this.ticks;\n          if (sampleSize < ticks.length) {\n            ticks = sample(ticks, sampleSize);\n          }\n          this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length);\n        }\n        return labelSizes;\n      }\n    }, {\n      key: \"_computeLabelSizes\",\n      value: function _computeLabelSizes(ticks, length) {\n        var ctx = this.ctx,\n          caches = this._longestTextCache;\n        var widths = [];\n        var heights = [];\n        var widestLabelSize = 0;\n        var highestLabelSize = 0;\n        var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel;\n        for (i = 0; i < length; ++i) {\n          label = ticks[i].label;\n          tickFont = this._resolveTickFontOptions(i);\n          ctx.font = fontString = tickFont.string;\n          cache = caches[fontString] = caches[fontString] || {\n            data: {},\n            gc: []\n          };\n          lineHeight = tickFont.lineHeight;\n          width = height = 0;\n          if (!isNullOrUndef(label) && !isArray(label)) {\n            width = _measureText(ctx, cache.data, cache.gc, width, label);\n            height = lineHeight;\n          } else if (isArray(label)) {\n            for (j = 0, jlen = label.length; j < jlen; ++j) {\n              nestedLabel = label[j];\n              if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {\n                width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);\n                height += lineHeight;\n              }\n            }\n          }\n          widths.push(width);\n          heights.push(height);\n          widestLabelSize = Math.max(width, widestLabelSize);\n          highestLabelSize = Math.max(height, highestLabelSize);\n        }\n        garbageCollect(caches, length);\n        var widest = widths.indexOf(widestLabelSize);\n        var highest = heights.indexOf(highestLabelSize);\n        var valueAt = function valueAt(idx) {\n          return {\n            width: widths[idx] || 0,\n            height: heights[idx] || 0\n          };\n        };\n        return {\n          first: valueAt(0),\n          last: valueAt(length - 1),\n          widest: valueAt(widest),\n          highest: valueAt(highest),\n          widths: widths,\n          heights: heights\n        };\n      }\n    }, {\n      key: \"getLabelForValue\",\n      value: function getLabelForValue(value) {\n        return value;\n      }\n    }, {\n      key: \"getPixelForValue\",\n      value: function getPixelForValue(value, index) {\n        return NaN;\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {}\n    }, {\n      key: \"getPixelForTick\",\n      value: function getPixelForTick(index) {\n        var ticks = this.ticks;\n        if (index < 0 || index > ticks.length - 1) {\n          return null;\n        }\n        return this.getPixelForValue(ticks[index].value);\n      }\n    }, {\n      key: \"getPixelForDecimal\",\n      value: function getPixelForDecimal(decimal) {\n        if (this._reversePixels) {\n          decimal = 1 - decimal;\n        }\n        var pixel = this._startPixel + decimal * this._length;\n        return _int16Range(this._alignToPixels ? _alignPixel(this.chart, pixel, 0) : pixel);\n      }\n    }, {\n      key: \"getDecimalForPixel\",\n      value: function getDecimalForPixel(pixel) {\n        var decimal = (pixel - this._startPixel) / this._length;\n        return this._reversePixels ? 1 - decimal : decimal;\n      }\n    }, {\n      key: \"getBasePixel\",\n      value: function getBasePixel() {\n        return this.getPixelForValue(this.getBaseValue());\n      }\n    }, {\n      key: \"getBaseValue\",\n      value: function getBaseValue() {\n        var min = this.min,\n          max = this.max;\n        return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0;\n      }\n    }, {\n      key: \"getContext\",\n      value: function getContext(index) {\n        var ticks = this.ticks || [];\n        if (index >= 0 && index < ticks.length) {\n          var tick = ticks[index];\n          return tick.$context || (tick.$context = createTickContext(this.getContext(), index, tick));\n        }\n        return this.$context || (this.$context = createScaleContext(this.chart.getContext(), this));\n      }\n    }, {\n      key: \"_tickSize\",\n      value: function _tickSize() {\n        var optionTicks = this.options.ticks;\n        var rot = toRadians(this.labelRotation);\n        var cos = Math.abs(Math.cos(rot));\n        var sin = Math.abs(Math.sin(rot));\n        var labelSizes = this._getLabelSizes();\n        var padding = optionTicks.autoSkipPadding || 0;\n        var w = labelSizes ? labelSizes.widest.width + padding : 0;\n        var h = labelSizes ? labelSizes.highest.height + padding : 0;\n        return this.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin;\n      }\n    }, {\n      key: \"_isVisible\",\n      value: function _isVisible() {\n        var display = this.options.display;\n        if (display !== 'auto') {\n          return !!display;\n        }\n        return this.getMatchingVisibleMetas().length > 0;\n      }\n    }, {\n      key: \"_computeGridLineItems\",\n      value: function _computeGridLineItems(chartArea) {\n        var axis = this.axis;\n        var chart = this.chart;\n        var options = this.options;\n        var grid = options.grid,\n          position = options.position,\n          border = options.border;\n        var offset = grid.offset;\n        var isHorizontal = this.isHorizontal();\n        var ticks = this.ticks;\n        var ticksLength = ticks.length + (offset ? 1 : 0);\n        var tl = getTickMarkLength(grid);\n        var items = [];\n        var borderOpts = border.setContext(this.getContext());\n        var axisWidth = borderOpts.display ? borderOpts.width : 0;\n        var axisHalfWidth = axisWidth / 2;\n        var alignBorderValue = function alignBorderValue(pixel) {\n          return _alignPixel(chart, pixel, axisWidth);\n        };\n        var borderValue, i, lineValue, alignedLineValue;\n        var tx1, ty1, tx2, ty2, x1, y1, x2, y2;\n        if (position === 'top') {\n          borderValue = alignBorderValue(this.bottom);\n          ty1 = this.bottom - tl;\n          ty2 = borderValue - axisHalfWidth;\n          y1 = alignBorderValue(chartArea.top) + axisHalfWidth;\n          y2 = chartArea.bottom;\n        } else if (position === 'bottom') {\n          borderValue = alignBorderValue(this.top);\n          y1 = chartArea.top;\n          y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;\n          ty1 = borderValue + axisHalfWidth;\n          ty2 = this.top + tl;\n        } else if (position === 'left') {\n          borderValue = alignBorderValue(this.right);\n          tx1 = this.right - tl;\n          tx2 = borderValue - axisHalfWidth;\n          x1 = alignBorderValue(chartArea.left) + axisHalfWidth;\n          x2 = chartArea.right;\n        } else if (position === 'right') {\n          borderValue = alignBorderValue(this.left);\n          x1 = chartArea.left;\n          x2 = alignBorderValue(chartArea.right) - axisHalfWidth;\n          tx1 = borderValue + axisHalfWidth;\n          tx2 = this.left + tl;\n        } else if (axis === 'x') {\n          if (position === 'center') {\n            borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + 0.5);\n          } else if (isObject(position)) {\n            var positionAxisID = Object.keys(position)[0];\n            var value = position[positionAxisID];\n            borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));\n          }\n          y1 = chartArea.top;\n          y2 = chartArea.bottom;\n          ty1 = borderValue + axisHalfWidth;\n          ty2 = ty1 + tl;\n        } else if (axis === 'y') {\n          if (position === 'center') {\n            borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);\n          } else if (isObject(position)) {\n            var positionAxisID1 = Object.keys(position)[0];\n            var value1 = position[positionAxisID1];\n            borderValue = alignBorderValue(this.chart.scales[positionAxisID1].getPixelForValue(value1));\n          }\n          tx1 = borderValue - axisHalfWidth;\n          tx2 = tx1 - tl;\n          x1 = chartArea.left;\n          x2 = chartArea.right;\n        }\n        var limit = valueOrDefault(options.ticks.maxTicksLimit, ticksLength);\n        var step = Math.max(1, Math.ceil(ticksLength / limit));\n        for (i = 0; i < ticksLength; i += step) {\n          var context = this.getContext(i);\n          var optsAtIndex = grid.setContext(context);\n          var optsAtIndexBorder = border.setContext(context);\n          var lineWidth = optsAtIndex.lineWidth;\n          var lineColor = optsAtIndex.color;\n          var borderDash = optsAtIndexBorder.dash || [];\n          var borderDashOffset = optsAtIndexBorder.dashOffset;\n          var tickWidth = optsAtIndex.tickWidth;\n          var tickColor = optsAtIndex.tickColor;\n          var tickBorderDash = optsAtIndex.tickBorderDash || [];\n          var tickBorderDashOffset = optsAtIndex.tickBorderDashOffset;\n          lineValue = getPixelForGridLine(this, i, offset);\n          if (lineValue === undefined) {\n            continue;\n          }\n          alignedLineValue = _alignPixel(chart, lineValue, lineWidth);\n          if (isHorizontal) {\n            tx1 = tx2 = x1 = x2 = alignedLineValue;\n          } else {\n            ty1 = ty2 = y1 = y2 = alignedLineValue;\n          }\n          items.push({\n            tx1: tx1,\n            ty1: ty1,\n            tx2: tx2,\n            ty2: ty2,\n            x1: x1,\n            y1: y1,\n            x2: x2,\n            y2: y2,\n            width: lineWidth,\n            color: lineColor,\n            borderDash: borderDash,\n            borderDashOffset: borderDashOffset,\n            tickWidth: tickWidth,\n            tickColor: tickColor,\n            tickBorderDash: tickBorderDash,\n            tickBorderDashOffset: tickBorderDashOffset\n          });\n        }\n        this._ticksLength = ticksLength;\n        this._borderValue = borderValue;\n        return items;\n      }\n    }, {\n      key: \"_computeLabelItems\",\n      value: function _computeLabelItems(chartArea) {\n        var axis = this.axis;\n        var options = this.options;\n        var position = options.position,\n          optionTicks = options.ticks;\n        var isHorizontal = this.isHorizontal();\n        var ticks = this.ticks;\n        var align = optionTicks.align,\n          crossAlign = optionTicks.crossAlign,\n          padding = optionTicks.padding,\n          mirror = optionTicks.mirror;\n        var tl = getTickMarkLength(options.grid);\n        var tickAndPadding = tl + padding;\n        var hTickAndPadding = mirror ? -padding : tickAndPadding;\n        var rotation = -toRadians(this.labelRotation);\n        var items = [];\n        var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset;\n        var textBaseline = 'middle';\n        if (position === 'top') {\n          y = this.bottom - hTickAndPadding;\n          textAlign = this._getXAxisLabelAlignment();\n        } else if (position === 'bottom') {\n          y = this.top + hTickAndPadding;\n          textAlign = this._getXAxisLabelAlignment();\n        } else if (position === 'left') {\n          var ret = this._getYAxisLabelAlignment(tl);\n          textAlign = ret.textAlign;\n          x = ret.x;\n        } else if (position === 'right') {\n          var ret1 = this._getYAxisLabelAlignment(tl);\n          textAlign = ret1.textAlign;\n          x = ret1.x;\n        } else if (axis === 'x') {\n          if (position === 'center') {\n            y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;\n          } else if (isObject(position)) {\n            var positionAxisID = Object.keys(position)[0];\n            var value = position[positionAxisID];\n            y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding;\n          }\n          textAlign = this._getXAxisLabelAlignment();\n        } else if (axis === 'y') {\n          if (position === 'center') {\n            x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;\n          } else if (isObject(position)) {\n            var positionAxisID1 = Object.keys(position)[0];\n            var value1 = position[positionAxisID1];\n            x = this.chart.scales[positionAxisID1].getPixelForValue(value1);\n          }\n          textAlign = this._getYAxisLabelAlignment(tl).textAlign;\n        }\n        if (axis === 'y') {\n          if (align === 'start') {\n            textBaseline = 'top';\n          } else if (align === 'end') {\n            textBaseline = 'bottom';\n          }\n        }\n        var labelSizes = this._getLabelSizes();\n        for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n          tick = ticks[i];\n          label = tick.label;\n          var optsAtIndex = optionTicks.setContext(this.getContext(i));\n          pixel = this.getPixelForTick(i) + optionTicks.labelOffset;\n          font = this._resolveTickFontOptions(i);\n          lineHeight = font.lineHeight;\n          lineCount = isArray(label) ? label.length : 1;\n          var halfCount = lineCount / 2;\n          var color = optsAtIndex.color;\n          var strokeColor = optsAtIndex.textStrokeColor;\n          var strokeWidth = optsAtIndex.textStrokeWidth;\n          var tickTextAlign = textAlign;\n          if (isHorizontal) {\n            x = pixel;\n            if (textAlign === 'inner') {\n              if (i === ilen - 1) {\n                tickTextAlign = !this.options.reverse ? 'right' : 'left';\n              } else if (i === 0) {\n                tickTextAlign = !this.options.reverse ? 'left' : 'right';\n              } else {\n                tickTextAlign = 'center';\n              }\n            }\n            if (position === 'top') {\n              if (crossAlign === 'near' || rotation !== 0) {\n                textOffset = -lineCount * lineHeight + lineHeight / 2;\n              } else if (crossAlign === 'center') {\n                textOffset = -labelSizes.highest.height / 2 - halfCount * lineHeight + lineHeight;\n              } else {\n                textOffset = -labelSizes.highest.height + lineHeight / 2;\n              }\n            } else {\n              if (crossAlign === 'near' || rotation !== 0) {\n                textOffset = lineHeight / 2;\n              } else if (crossAlign === 'center') {\n                textOffset = labelSizes.highest.height / 2 - halfCount * lineHeight;\n              } else {\n                textOffset = labelSizes.highest.height - lineCount * lineHeight;\n              }\n            }\n            if (mirror) {\n              textOffset *= -1;\n            }\n            if (rotation !== 0 && !optsAtIndex.showLabelBackdrop) {\n              x += lineHeight / 2 * Math.sin(rotation);\n            }\n          } else {\n            y = pixel;\n            textOffset = (1 - lineCount) * lineHeight / 2;\n          }\n          var backdrop = void 0;\n          if (optsAtIndex.showLabelBackdrop) {\n            var labelPadding = toPadding(optsAtIndex.backdropPadding);\n            var height = labelSizes.heights[i];\n            var width = labelSizes.widths[i];\n            var top = textOffset - labelPadding.top;\n            var left = 0 - labelPadding.left;\n            switch (textBaseline) {\n              case 'middle':\n                top -= height / 2;\n                break;\n              case 'bottom':\n                top -= height;\n                break;\n            }\n            switch (textAlign) {\n              case 'center':\n                left -= width / 2;\n                break;\n              case 'right':\n                left -= width;\n                break;\n            }\n            backdrop = {\n              left: left,\n              top: top,\n              width: width + labelPadding.width,\n              height: height + labelPadding.height,\n              color: optsAtIndex.backdropColor\n            };\n          }\n          items.push({\n            label: label,\n            font: font,\n            textOffset: textOffset,\n            options: {\n              rotation: rotation,\n              color: color,\n              strokeColor: strokeColor,\n              strokeWidth: strokeWidth,\n              textAlign: tickTextAlign,\n              textBaseline: textBaseline,\n              translation: [x, y],\n              backdrop: backdrop\n            }\n          });\n        }\n        return items;\n      }\n    }, {\n      key: \"_getXAxisLabelAlignment\",\n      value: function _getXAxisLabelAlignment() {\n        var _this$options8 = this.options,\n          position = _this$options8.position,\n          ticks = _this$options8.ticks;\n        var rotation = -toRadians(this.labelRotation);\n        if (rotation) {\n          return position === 'top' ? 'left' : 'right';\n        }\n        var align = 'center';\n        if (ticks.align === 'start') {\n          align = 'left';\n        } else if (ticks.align === 'end') {\n          align = 'right';\n        } else if (ticks.align === 'inner') {\n          align = 'inner';\n        }\n        return align;\n      }\n    }, {\n      key: \"_getYAxisLabelAlignment\",\n      value: function _getYAxisLabelAlignment(tl) {\n        var _this$options9 = this.options,\n          position = _this$options9.position,\n          _this$options9$ticks = _this$options9.ticks,\n          crossAlign = _this$options9$ticks.crossAlign,\n          mirror = _this$options9$ticks.mirror,\n          padding = _this$options9$ticks.padding;\n        var labelSizes = this._getLabelSizes();\n        var tickAndPadding = tl + padding;\n        var widest = labelSizes.widest.width;\n        var textAlign;\n        var x;\n        if (position === 'left') {\n          if (mirror) {\n            x = this.right + padding;\n            if (crossAlign === 'near') {\n              textAlign = 'left';\n            } else if (crossAlign === 'center') {\n              textAlign = 'center';\n              x += widest / 2;\n            } else {\n              textAlign = 'right';\n              x += widest;\n            }\n          } else {\n            x = this.right - tickAndPadding;\n            if (crossAlign === 'near') {\n              textAlign = 'right';\n            } else if (crossAlign === 'center') {\n              textAlign = 'center';\n              x -= widest / 2;\n            } else {\n              textAlign = 'left';\n              x = this.left;\n            }\n          }\n        } else if (position === 'right') {\n          if (mirror) {\n            x = this.left + padding;\n            if (crossAlign === 'near') {\n              textAlign = 'right';\n            } else if (crossAlign === 'center') {\n              textAlign = 'center';\n              x -= widest / 2;\n            } else {\n              textAlign = 'left';\n              x -= widest;\n            }\n          } else {\n            x = this.left + tickAndPadding;\n            if (crossAlign === 'near') {\n              textAlign = 'left';\n            } else if (crossAlign === 'center') {\n              textAlign = 'center';\n              x += widest / 2;\n            } else {\n              textAlign = 'right';\n              x = this.right;\n            }\n          }\n        } else {\n          textAlign = 'right';\n        }\n        return {\n          textAlign: textAlign,\n          x: x\n        };\n      }\n    }, {\n      key: \"_computeLabelArea\",\n      value: function _computeLabelArea() {\n        if (this.options.ticks.mirror) {\n          return;\n        }\n        var chart = this.chart;\n        var position = this.options.position;\n        if (position === 'left' || position === 'right') {\n          return {\n            top: 0,\n            left: this.left,\n            bottom: chart.height,\n            right: this.right\n          };\n        }\n        if (position === 'top' || position === 'bottom') {\n          return {\n            top: this.top,\n            left: 0,\n            bottom: this.bottom,\n            right: chart.width\n          };\n        }\n      }\n    }, {\n      key: \"drawBackground\",\n      value: function drawBackground() {\n        var ctx = this.ctx,\n          backgroundColor = this.options.backgroundColor,\n          left = this.left,\n          top = this.top,\n          width = this.width,\n          height = this.height;\n        if (backgroundColor) {\n          ctx.save();\n          ctx.fillStyle = backgroundColor;\n          ctx.fillRect(left, top, width, height);\n          ctx.restore();\n        }\n      }\n    }, {\n      key: \"getLineWidthForValue\",\n      value: function getLineWidthForValue(value) {\n        var grid = this.options.grid;\n        if (!this._isVisible() || !grid.display) {\n          return 0;\n        }\n        var ticks = this.ticks;\n        var index = ticks.findIndex(function (t) {\n          return t.value === value;\n        });\n        if (index >= 0) {\n          var opts = grid.setContext(this.getContext(index));\n          return opts.lineWidth;\n        }\n        return 0;\n      }\n    }, {\n      key: \"drawGrid\",\n      value: function drawGrid(chartArea) {\n        var grid = this.options.grid;\n        var ctx = this.ctx;\n        var items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea));\n        var i, ilen;\n        var drawLine = function drawLine(p1, p2, style) {\n          if (!style.width || !style.color) {\n            return;\n          }\n          ctx.save();\n          ctx.lineWidth = style.width;\n          ctx.strokeStyle = style.color;\n          ctx.setLineDash(style.borderDash || []);\n          ctx.lineDashOffset = style.borderDashOffset;\n          ctx.beginPath();\n          ctx.moveTo(p1.x, p1.y);\n          ctx.lineTo(p2.x, p2.y);\n          ctx.stroke();\n          ctx.restore();\n        };\n        if (grid.display) {\n          for (i = 0, ilen = items.length; i < ilen; ++i) {\n            var item = items[i];\n            if (grid.drawOnChartArea) {\n              drawLine({\n                x: item.x1,\n                y: item.y1\n              }, {\n                x: item.x2,\n                y: item.y2\n              }, item);\n            }\n            if (grid.drawTicks) {\n              drawLine({\n                x: item.tx1,\n                y: item.ty1\n              }, {\n                x: item.tx2,\n                y: item.ty2\n              }, {\n                color: item.tickColor,\n                width: item.tickWidth,\n                borderDash: item.tickBorderDash,\n                borderDashOffset: item.tickBorderDashOffset\n              });\n            }\n          }\n        }\n      }\n    }, {\n      key: \"drawBorder\",\n      value: function drawBorder() {\n        var chart = this.chart,\n          ctx = this.ctx,\n          _this$options10 = this.options,\n          border = _this$options10.border,\n          grid = _this$options10.grid;\n        var borderOpts = border.setContext(this.getContext());\n        var axisWidth = border.display ? borderOpts.width : 0;\n        if (!axisWidth) {\n          return;\n        }\n        var lastLineWidth = grid.setContext(this.getContext(0)).lineWidth;\n        var borderValue = this._borderValue;\n        var x1, x2, y1, y2;\n        if (this.isHorizontal()) {\n          x1 = _alignPixel(chart, this.left, axisWidth) - axisWidth / 2;\n          x2 = _alignPixel(chart, this.right, lastLineWidth) + lastLineWidth / 2;\n          y1 = y2 = borderValue;\n        } else {\n          y1 = _alignPixel(chart, this.top, axisWidth) - axisWidth / 2;\n          y2 = _alignPixel(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;\n          x1 = x2 = borderValue;\n        }\n        ctx.save();\n        ctx.lineWidth = borderOpts.width;\n        ctx.strokeStyle = borderOpts.color;\n        ctx.beginPath();\n        ctx.moveTo(x1, y1);\n        ctx.lineTo(x2, y2);\n        ctx.stroke();\n        ctx.restore();\n      }\n    }, {\n      key: \"drawLabels\",\n      value: function drawLabels(chartArea) {\n        var optionTicks = this.options.ticks;\n        if (!optionTicks.display) {\n          return;\n        }\n        var ctx = this.ctx;\n        var area = this._computeLabelArea();\n        if (area) {\n          clipArea(ctx, area);\n        }\n        var items = this.getLabelItems(chartArea);\n        var _iterator10 = _createForOfIteratorHelper$1(items),\n          _step10;\n        try {\n          for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n            var item = _step10.value;\n            var renderTextOptions = item.options;\n            var tickFont = item.font;\n            var label = item.label;\n            var y = item.textOffset;\n            renderText(ctx, label, 0, y, tickFont, renderTextOptions);\n          }\n        } catch (err) {\n          _iterator10.e(err);\n        } finally {\n          _iterator10.f();\n        }\n        if (area) {\n          unclipArea(ctx);\n        }\n      }\n    }, {\n      key: \"drawTitle\",\n      value: function drawTitle() {\n        var ctx = this.ctx,\n          _this$options11 = this.options,\n          position = _this$options11.position,\n          title = _this$options11.title,\n          reverse = _this$options11.reverse;\n        if (!title.display) {\n          return;\n        }\n        var font = toFont(title.font);\n        var padding = toPadding(title.padding);\n        var align = title.align;\n        var offset = font.lineHeight / 2;\n        if (position === 'bottom' || position === 'center' || isObject(position)) {\n          offset += padding.bottom;\n          if (isArray(title.text)) {\n            offset += font.lineHeight * (title.text.length - 1);\n          }\n        } else {\n          offset += padding.top;\n        }\n        var _titleArgs = titleArgs(this, offset, position, align),\n          titleX = _titleArgs.titleX,\n          titleY = _titleArgs.titleY,\n          maxWidth = _titleArgs.maxWidth,\n          rotation = _titleArgs.rotation;\n        renderText(ctx, title.text, 0, 0, font, {\n          color: title.color,\n          maxWidth: maxWidth,\n          rotation: rotation,\n          textAlign: titleAlign(align, position, reverse),\n          textBaseline: 'middle',\n          translation: [titleX, titleY]\n        });\n      }\n    }, {\n      key: \"draw\",\n      value: function draw(chartArea) {\n        if (!this._isVisible()) {\n          return;\n        }\n        this.drawBackground();\n        this.drawGrid(chartArea);\n        this.drawBorder();\n        this.drawTitle();\n        this.drawLabels(chartArea);\n      }\n    }, {\n      key: \"_layers\",\n      value: function _layers() {\n        var _this10 = this;\n        var opts = this.options;\n        var tz = opts.ticks && opts.ticks.z || 0;\n        var gz = valueOrDefault(opts.grid && opts.grid.z, -1);\n        var bz = valueOrDefault(opts.border && opts.border.z, 0);\n        if (!this._isVisible() || this.draw !== Scale.prototype.draw) {\n          return [{\n            z: tz,\n            draw: function draw(chartArea) {\n              _this10.draw(chartArea);\n            }\n          }];\n        }\n        return [{\n          z: gz,\n          draw: function draw(chartArea) {\n            _this10.drawBackground();\n            _this10.drawGrid(chartArea);\n            _this10.drawTitle();\n          }\n        }, {\n          z: bz,\n          draw: function draw() {\n            _this10.drawBorder();\n          }\n        }, {\n          z: tz,\n          draw: function draw(chartArea) {\n            _this10.drawLabels(chartArea);\n          }\n        }];\n      }\n    }, {\n      key: \"getMatchingVisibleMetas\",\n      value: function getMatchingVisibleMetas(type) {\n        var metas = this.chart.getSortedVisibleDatasetMetas();\n        var axisID = this.axis + 'AxisID';\n        var result = [];\n        var i, ilen;\n        for (i = 0, ilen = metas.length; i < ilen; ++i) {\n          var meta = metas[i];\n          if (meta[axisID] === this.id && (!type || meta.type === type)) {\n            result.push(meta);\n          }\n        }\n        return result;\n      }\n    }, {\n      key: \"_resolveTickFontOptions\",\n      value: function _resolveTickFontOptions(index) {\n        var opts = this.options.ticks.setContext(this.getContext(index));\n        return toFont(opts.font);\n      }\n    }, {\n      key: \"_maxDigits\",\n      value: function _maxDigits() {\n        var fontSize = this._resolveTickFontOptions(0).lineHeight;\n        return (this.isHorizontal() ? this.width : this.height) / fontSize;\n      }\n    }]);\n    return Scale;\n  }(Element);\n  var TypedRegistry = /*#__PURE__*/function () {\n    function TypedRegistry(type, scope, override) {\n      _classCallCheck$x(this, TypedRegistry);\n      this.type = type;\n      this.scope = scope;\n      this.override = override;\n      this.items = Object.create(null);\n    }\n    _createClass$x(TypedRegistry, [{\n      key: \"isForType\",\n      value: function isForType(type) {\n        return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);\n      }\n    }, {\n      key: \"register\",\n      value: function register(item) {\n        var proto = Object.getPrototypeOf(item);\n        var parentScope;\n        if (isIChartComponent(proto)) {\n          parentScope = this.register(proto);\n        }\n        var items = this.items;\n        var id = item.id;\n        var scope = this.scope + '.' + id;\n        if (!id) {\n          throw new Error('class does not have id: ' + item);\n        }\n        if (id in items) {\n          return scope;\n        }\n        items[id] = item;\n        registerDefaults(item, scope, parentScope);\n        if (this.override) {\n          defaults.override(item.id, item.overrides);\n        }\n        return scope;\n      }\n    }, {\n      key: \"get\",\n      value: function get(id) {\n        return this.items[id];\n      }\n    }, {\n      key: \"unregister\",\n      value: function unregister(item) {\n        var items = this.items;\n        var id = item.id;\n        var scope = this.scope;\n        if (id in items) {\n          delete items[id];\n        }\n        if (scope && id in defaults[scope]) {\n          delete defaults[scope][id];\n          if (this.override) {\n            delete overrides[id];\n          }\n        }\n      }\n    }]);\n    return TypedRegistry;\n  }();\n  function registerDefaults(item, scope, parentScope) {\n    var itemDefaults = merge(Object.create(null), [parentScope ? defaults.get(parentScope) : {}, defaults.get(scope), item.defaults]);\n    defaults.set(scope, itemDefaults);\n    if (item.defaultRoutes) {\n      routeDefaults(scope, item.defaultRoutes);\n    }\n    if (item.descriptors) {\n      defaults.describe(scope, item.descriptors);\n    }\n  }\n  function routeDefaults(scope, routes) {\n    Object.keys(routes).forEach(function (property) {\n      var propertyParts = property.split('.');\n      var sourceName = propertyParts.pop();\n      var sourceScope = [scope].concat(propertyParts).join('.');\n      var parts = routes[property].split('.');\n      var targetName = parts.pop();\n      var targetScope = parts.join('.');\n      defaults.route(sourceScope, sourceName, targetScope, targetName);\n    });\n  }\n  function isIChartComponent(proto) {\n    return 'id' in proto && 'defaults' in proto;\n  }\n  var Registry = /*#__PURE__*/function () {\n    function Registry() {\n      _classCallCheck$x(this, Registry);\n      this.controllers = new TypedRegistry(DatasetController, 'datasets', true);\n      this.elements = new TypedRegistry(Element, 'elements');\n      this.plugins = new TypedRegistry(Object, 'plugins');\n      this.scales = new TypedRegistry(Scale, 'scales');\n      this._typedRegistries = [this.controllers, this.scales, this.elements];\n    }\n    _createClass$x(Registry, [{\n      key: \"add\",\n      value: function add() {\n        for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n          args[_key] = arguments[_key];\n        }\n        this._each('register', args);\n      }\n    }, {\n      key: \"remove\",\n      value: function remove() {\n        for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n          args[_key2] = arguments[_key2];\n        }\n        this._each('unregister', args);\n      }\n    }, {\n      key: \"addControllers\",\n      value: function addControllers() {\n        for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n          args[_key3] = arguments[_key3];\n        }\n        this._each('register', args, this.controllers);\n      }\n    }, {\n      key: \"addElements\",\n      value: function addElements() {\n        for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n          args[_key4] = arguments[_key4];\n        }\n        this._each('register', args, this.elements);\n      }\n    }, {\n      key: \"addPlugins\",\n      value: function addPlugins() {\n        for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n          args[_key5] = arguments[_key5];\n        }\n        this._each('register', args, this.plugins);\n      }\n    }, {\n      key: \"addScales\",\n      value: function addScales() {\n        for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n          args[_key6] = arguments[_key6];\n        }\n        this._each('register', args, this.scales);\n      }\n    }, {\n      key: \"getController\",\n      value: function getController(id) {\n        return this._get(id, this.controllers, 'controller');\n      }\n    }, {\n      key: \"getElement\",\n      value: function getElement(id) {\n        return this._get(id, this.elements, 'element');\n      }\n    }, {\n      key: \"getPlugin\",\n      value: function getPlugin(id) {\n        return this._get(id, this.plugins, 'plugin');\n      }\n    }, {\n      key: \"getScale\",\n      value: function getScale(id) {\n        return this._get(id, this.scales, 'scale');\n      }\n    }, {\n      key: \"removeControllers\",\n      value: function removeControllers() {\n        for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {\n          args[_key7] = arguments[_key7];\n        }\n        this._each('unregister', args, this.controllers);\n      }\n    }, {\n      key: \"removeElements\",\n      value: function removeElements() {\n        for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {\n          args[_key8] = arguments[_key8];\n        }\n        this._each('unregister', args, this.elements);\n      }\n    }, {\n      key: \"removePlugins\",\n      value: function removePlugins() {\n        for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {\n          args[_key9] = arguments[_key9];\n        }\n        this._each('unregister', args, this.plugins);\n      }\n    }, {\n      key: \"removeScales\",\n      value: function removeScales() {\n        for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {\n          args[_key10] = arguments[_key10];\n        }\n        this._each('unregister', args, this.scales);\n      }\n    }, {\n      key: \"_each\",\n      value: function _each(method, args, typedRegistry) {\n        var _this11 = this;\n        _toConsumableArray(args).forEach(function (arg) {\n          var reg = typedRegistry || _this11._getRegistryForType(arg);\n          if (typedRegistry || reg.isForType(arg) || reg === _this11.plugins && arg.id) {\n            _this11._exec(method, reg, arg);\n          } else {\n            each(arg, function (item) {\n              var itemReg = typedRegistry || _this11._getRegistryForType(item);\n              _this11._exec(method, itemReg, item);\n            });\n          }\n        });\n      }\n    }, {\n      key: \"_exec\",\n      value: function _exec(method, registry, component) {\n        var camelMethod = _capitalize(method);\n        callback(component['before' + camelMethod], [], component);\n        registry[method](component);\n        callback(component['after' + camelMethod], [], component);\n      }\n    }, {\n      key: \"_getRegistryForType\",\n      value: function _getRegistryForType(type) {\n        for (var i = 0; i < this._typedRegistries.length; i++) {\n          var reg = this._typedRegistries[i];\n          if (reg.isForType(type)) {\n            return reg;\n          }\n        }\n        return this.plugins;\n      }\n    }, {\n      key: \"_get\",\n      value: function _get(id, typedRegistry, type) {\n        var item = typedRegistry.get(id);\n        if (item === undefined) {\n          throw new Error('\"' + id + '\" is not a registered ' + type + '.');\n        }\n        return item;\n      }\n    }]);\n    return Registry;\n  }();\n  var registry = /* #__PURE__ */new Registry();\n  var PluginService = /*#__PURE__*/function () {\n    function PluginService() {\n      _classCallCheck$x(this, PluginService);\n      this._init = [];\n    }\n    _createClass$x(PluginService, [{\n      key: \"notify\",\n      value: function notify(chart, hook, args, filter) {\n        if (hook === 'beforeInit') {\n          this._init = this._createDescriptors(chart, true);\n          this._notify(this._init, chart, 'install');\n        }\n        var descriptors = filter ? this._descriptors(chart).filter(filter) : this._descriptors(chart);\n        var result = this._notify(descriptors, chart, hook, args);\n        if (hook === 'afterDestroy') {\n          this._notify(descriptors, chart, 'stop');\n          this._notify(this._init, chart, 'uninstall');\n        }\n        return result;\n      }\n    }, {\n      key: \"_notify\",\n      value: function _notify(descriptors, chart, hook, args) {\n        args = args || {};\n        var _iterator11 = _createForOfIteratorHelper$1(descriptors),\n          _step11;\n        try {\n          for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {\n            var descriptor = _step11.value;\n            var plugin = descriptor.plugin;\n            var method = plugin[hook];\n            var params = [chart, args, descriptor.options];\n            if (callback(method, params, plugin) === false && args.cancelable) {\n              return false;\n            }\n          }\n        } catch (err) {\n          _iterator11.e(err);\n        } finally {\n          _iterator11.f();\n        }\n        return true;\n      }\n    }, {\n      key: \"invalidate\",\n      value: function invalidate() {\n        if (!isNullOrUndef(this._cache)) {\n          this._oldCache = this._cache;\n          this._cache = undefined;\n        }\n      }\n    }, {\n      key: \"_descriptors\",\n      value: function _descriptors(chart) {\n        if (this._cache) {\n          return this._cache;\n        }\n        var descriptors = this._cache = this._createDescriptors(chart);\n        this._notifyStateChanges(chart);\n        return descriptors;\n      }\n    }, {\n      key: \"_createDescriptors\",\n      value: function _createDescriptors(chart, all) {\n        var config = chart && chart.config;\n        var options = valueOrDefault(config.options && config.options.plugins, {});\n        var plugins = allPlugins(config);\n        return options === false && !all ? [] : createDescriptors(chart, plugins, options, all);\n      }\n    }, {\n      key: \"_notifyStateChanges\",\n      value: function _notifyStateChanges(chart) {\n        var previousDescriptors = this._oldCache || [];\n        var descriptors = this._cache;\n        var diff = function diff(a, b) {\n          return a.filter(function (x) {\n            return !b.some(function (y) {\n              return x.plugin.id === y.plugin.id;\n            });\n          });\n        };\n        this._notify(diff(previousDescriptors, descriptors), chart, 'stop');\n        this._notify(diff(descriptors, previousDescriptors), chart, 'start');\n      }\n    }]);\n    return PluginService;\n  }();\n  function allPlugins(config) {\n    var localIds = {};\n    var plugins = [];\n    var keys = Object.keys(registry.plugins.items);\n    for (var i = 0; i < keys.length; i++) {\n      plugins.push(registry.getPlugin(keys[i]));\n    }\n    var local = config.plugins || [];\n    for (var i1 = 0; i1 < local.length; i1++) {\n      var plugin = local[i1];\n      if (plugins.indexOf(plugin) === -1) {\n        plugins.push(plugin);\n        localIds[plugin.id] = true;\n      }\n    }\n    return {\n      plugins: plugins,\n      localIds: localIds\n    };\n  }\n  function getOpts(options, all) {\n    if (!all && options === false) {\n      return null;\n    }\n    if (options === true) {\n      return {};\n    }\n    return options;\n  }\n  function createDescriptors(chart, _ref2, options, all) {\n    var plugins = _ref2.plugins,\n      localIds = _ref2.localIds;\n    var result = [];\n    var context = chart.getContext();\n    var _iterator12 = _createForOfIteratorHelper$1(plugins),\n      _step12;\n    try {\n      for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {\n        var plugin = _step12.value;\n        var id = plugin.id;\n        var opts = getOpts(options[id], all);\n        if (opts === null) {\n          continue;\n        }\n        result.push({\n          plugin: plugin,\n          options: pluginOpts(chart.config, {\n            plugin: plugin,\n            local: localIds[id]\n          }, opts, context)\n        });\n      }\n    } catch (err) {\n      _iterator12.e(err);\n    } finally {\n      _iterator12.f();\n    }\n    return result;\n  }\n  function pluginOpts(config, _ref3, opts, context) {\n    var plugin = _ref3.plugin,\n      local = _ref3.local;\n    var keys = config.pluginScopeKeys(plugin);\n    var scopes = config.getOptionScopes(opts, keys);\n    if (local && plugin.defaults) {\n      scopes.push(plugin.defaults);\n    }\n    return config.createResolver(scopes, context, [''], {\n      scriptable: false,\n      indexable: false,\n      allKeys: true\n    });\n  }\n  function getIndexAxis(type, options) {\n    var datasetDefaults = defaults.datasets[type] || {};\n    var datasetOptions = (options.datasets || {})[type] || {};\n    return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';\n  }\n  function getAxisFromDefaultScaleID(id, indexAxis) {\n    var axis = id;\n    if (id === '_index_') {\n      axis = indexAxis;\n    } else if (id === '_value_') {\n      axis = indexAxis === 'x' ? 'y' : 'x';\n    }\n    return axis;\n  }\n  function getDefaultScaleIDFromAxis(axis, indexAxis) {\n    return axis === indexAxis ? '_index_' : '_value_';\n  }\n  function axisFromPosition(position) {\n    if (position === 'top' || position === 'bottom') {\n      return 'x';\n    }\n    if (position === 'left' || position === 'right') {\n      return 'y';\n    }\n  }\n  function determineAxis(id, scaleOptions) {\n    if (id === 'x' || id === 'y' || id === 'r') {\n      return id;\n    }\n    id = scaleOptions.axis || axisFromPosition(scaleOptions.position) || id.length > 1 && determineAxis(id[0].toLowerCase(), scaleOptions);\n    if (id) {\n      return id;\n    }\n    throw new Error(\"Cannot determine type of '\".concat(name, \"' axis. Please provide 'axis' or 'position' option.\"));\n  }\n  function mergeScaleConfig(config, options) {\n    var chartDefaults = overrides[config.type] || {\n      scales: {}\n    };\n    var configScales = options.scales || {};\n    var chartIndexAxis = getIndexAxis(config.type, options);\n    var scales = Object.create(null);\n    Object.keys(configScales).forEach(function (id) {\n      var scaleConf = configScales[id];\n      if (!isObject(scaleConf)) {\n        return console.error(\"Invalid scale configuration for scale: \".concat(id));\n      }\n      if (scaleConf._proxy) {\n        return console.warn(\"Ignoring resolver passed as options for scale: \".concat(id));\n      }\n      var axis = determineAxis(id, scaleConf);\n      var defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);\n      var defaultScaleOptions = chartDefaults.scales || {};\n      scales[id] = mergeIf(Object.create(null), [{\n        axis: axis\n      }, scaleConf, defaultScaleOptions[axis], defaultScaleOptions[defaultId]]);\n    });\n    config.data.datasets.forEach(function (dataset) {\n      var type = dataset.type || config.type;\n      var indexAxis = dataset.indexAxis || getIndexAxis(type, options);\n      var datasetDefaults = overrides[type] || {};\n      var defaultScaleOptions = datasetDefaults.scales || {};\n      Object.keys(defaultScaleOptions).forEach(function (defaultID) {\n        var axis = getAxisFromDefaultScaleID(defaultID, indexAxis);\n        var id = dataset[axis + 'AxisID'] || axis;\n        scales[id] = scales[id] || Object.create(null);\n        mergeIf(scales[id], [{\n          axis: axis\n        }, configScales[id], defaultScaleOptions[defaultID]]);\n      });\n    });\n    Object.keys(scales).forEach(function (key) {\n      var scale = scales[key];\n      mergeIf(scale, [defaults.scales[scale.type], defaults.scale]);\n    });\n    return scales;\n  }\n  function initOptions(config) {\n    var options = config.options || (config.options = {});\n    options.plugins = valueOrDefault(options.plugins, {});\n    options.scales = mergeScaleConfig(config, options);\n  }\n  function initData(data) {\n    data = data || {};\n    data.datasets = data.datasets || [];\n    data.labels = data.labels || [];\n    return data;\n  }\n  function initConfig(config) {\n    config = config || {};\n    config.data = initData(config.data);\n    initOptions(config);\n    return config;\n  }\n  var keyCache = new Map();\n  var keysCached = new Set();\n  function cachedKeys(cacheKey, generate) {\n    var keys = keyCache.get(cacheKey);\n    if (!keys) {\n      keys = generate();\n      keyCache.set(cacheKey, keys);\n      keysCached.add(keys);\n    }\n    return keys;\n  }\n  var addIfFound = function addIfFound(set, obj, key) {\n    var opts = resolveObjectKey(obj, key);\n    if (opts !== undefined) {\n      set.add(opts);\n    }\n  };\n  var Config = /*#__PURE__*/function () {\n    function Config(config) {\n      _classCallCheck$x(this, Config);\n      this._config = initConfig(config);\n      this._scopeCache = new Map();\n      this._resolverCache = new Map();\n    }\n    _createClass$x(Config, [{\n      key: \"platform\",\n      get: function get() {\n        return this._config.platform;\n      }\n    }, {\n      key: \"type\",\n      get: function get() {\n        return this._config.type;\n      },\n      set: function set(type) {\n        this._config.type = type;\n      }\n    }, {\n      key: \"data\",\n      get: function get() {\n        return this._config.data;\n      },\n      set: function set(data) {\n        this._config.data = initData(data);\n      }\n    }, {\n      key: \"options\",\n      get: function get() {\n        return this._config.options;\n      },\n      set: function set(options) {\n        this._config.options = options;\n      }\n    }, {\n      key: \"plugins\",\n      get: function get() {\n        return this._config.plugins;\n      }\n    }, {\n      key: \"update\",\n      value: function update() {\n        var config = this._config;\n        this.clearCache();\n        initOptions(config);\n      }\n    }, {\n      key: \"clearCache\",\n      value: function clearCache() {\n        this._scopeCache.clear();\n        this._resolverCache.clear();\n      }\n    }, {\n      key: \"datasetScopeKeys\",\n      value: function datasetScopeKeys(datasetType) {\n        return cachedKeys(datasetType, function () {\n          return [[\"datasets.\".concat(datasetType), '']];\n        });\n      }\n    }, {\n      key: \"datasetAnimationScopeKeys\",\n      value: function datasetAnimationScopeKeys(datasetType, transition) {\n        return cachedKeys(\"\".concat(datasetType, \".transition.\").concat(transition), function () {\n          return [[\"datasets.\".concat(datasetType, \".transitions.\").concat(transition), \"transitions.\".concat(transition)], [\"datasets.\".concat(datasetType), '']];\n        });\n      }\n    }, {\n      key: \"datasetElementScopeKeys\",\n      value: function datasetElementScopeKeys(datasetType, elementType) {\n        return cachedKeys(\"\".concat(datasetType, \"-\").concat(elementType), function () {\n          return [[\"datasets.\".concat(datasetType, \".elements.\").concat(elementType), \"datasets.\".concat(datasetType), \"elements.\".concat(elementType), '']];\n        });\n      }\n    }, {\n      key: \"pluginScopeKeys\",\n      value: function pluginScopeKeys(plugin) {\n        var id = plugin.id;\n        var type = this.type;\n        return cachedKeys(\"\".concat(type, \"-plugin-\").concat(id), function () {\n          return [[\"plugins.\".concat(id)].concat(_toConsumableArray(plugin.additionalOptionScopes || []))];\n        });\n      }\n    }, {\n      key: \"_cachedScopes\",\n      value: function _cachedScopes(mainScope, resetCache) {\n        var _scopeCache = this._scopeCache;\n        var cache = _scopeCache.get(mainScope);\n        if (!cache || resetCache) {\n          cache = new Map();\n          _scopeCache.set(mainScope, cache);\n        }\n        return cache;\n      }\n    }, {\n      key: \"getOptionScopes\",\n      value: function getOptionScopes(mainScope, keyLists, resetCache) {\n        var options = this.options,\n          type = this.type;\n        var cache = this._cachedScopes(mainScope, resetCache);\n        var cached = cache.get(keyLists);\n        if (cached) {\n          return cached;\n        }\n        var scopes = new Set();\n        keyLists.forEach(function (keys) {\n          if (mainScope) {\n            scopes.add(mainScope);\n            keys.forEach(function (key) {\n              return addIfFound(scopes, mainScope, key);\n            });\n          }\n          keys.forEach(function (key) {\n            return addIfFound(scopes, options, key);\n          });\n          keys.forEach(function (key) {\n            return addIfFound(scopes, overrides[type] || {}, key);\n          });\n          keys.forEach(function (key) {\n            return addIfFound(scopes, defaults, key);\n          });\n          keys.forEach(function (key) {\n            return addIfFound(scopes, descriptors, key);\n          });\n        });\n        var array = Array.from(scopes);\n        if (array.length === 0) {\n          array.push(Object.create(null));\n        }\n        if (keysCached.has(keyLists)) {\n          cache.set(keyLists, array);\n        }\n        return array;\n      }\n    }, {\n      key: \"chartOptionScopes\",\n      value: function chartOptionScopes() {\n        var options = this.options,\n          type = this.type;\n        return [options, overrides[type] || {}, defaults.datasets[type] || {}, {\n          type: type\n        }, defaults, descriptors];\n      }\n    }, {\n      key: \"resolveNamedOptions\",\n      value: function resolveNamedOptions(scopes, names, context) {\n        var prefixes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [''];\n        var result = {\n          $shared: true\n        };\n        var _getResolver = getResolver(this._resolverCache, scopes, prefixes),\n          resolver = _getResolver.resolver,\n          subPrefixes = _getResolver.subPrefixes;\n        var options = resolver;\n        if (needContext(resolver, names)) {\n          result.$shared = false;\n          context = isFunction(context) ? context() : context;\n          var subResolver = this.createResolver(scopes, context, subPrefixes);\n          options = _attachContext(resolver, context, subResolver);\n        }\n        var _iterator13 = _createForOfIteratorHelper$1(names),\n          _step13;\n        try {\n          for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {\n            var prop = _step13.value;\n            result[prop] = options[prop];\n          }\n        } catch (err) {\n          _iterator13.e(err);\n        } finally {\n          _iterator13.f();\n        }\n        return result;\n      }\n    }, {\n      key: \"createResolver\",\n      value: function createResolver(scopes, context) {\n        var prefixes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [''];\n        var descriptorDefaults = arguments.length > 3 ? arguments[3] : undefined;\n        var _getResolver2 = getResolver(this._resolverCache, scopes, prefixes),\n          resolver = _getResolver2.resolver;\n        return isObject(context) ? _attachContext(resolver, context, undefined, descriptorDefaults) : resolver;\n      }\n    }]);\n    return Config;\n  }();\n  function getResolver(resolverCache, scopes, prefixes) {\n    var cache = resolverCache.get(scopes);\n    if (!cache) {\n      cache = new Map();\n      resolverCache.set(scopes, cache);\n    }\n    var cacheKey = prefixes.join();\n    var cached = cache.get(cacheKey);\n    if (!cached) {\n      var resolver = _createResolver(scopes, prefixes);\n      cached = {\n        resolver: resolver,\n        subPrefixes: prefixes.filter(function (p) {\n          return !p.toLowerCase().includes('hover');\n        })\n      };\n      cache.set(cacheKey, cached);\n    }\n    return cached;\n  }\n  var hasFunction = function hasFunction(value) {\n    return isObject(value) && Object.getOwnPropertyNames(value).reduce(function (acc, key) {\n      return acc || isFunction(value[key]);\n    }, false);\n  };\n  function needContext(proxy, names) {\n    var _descriptors2 = _descriptors(proxy),\n      isScriptable = _descriptors2.isScriptable,\n      isIndexable = _descriptors2.isIndexable;\n    var _iterator14 = _createForOfIteratorHelper$1(names),\n      _step14;\n    try {\n      for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {\n        var prop = _step14.value;\n        var scriptable = isScriptable(prop);\n        var indexable = isIndexable(prop);\n        var value = (indexable || scriptable) && proxy[prop];\n        if (scriptable && (isFunction(value) || hasFunction(value)) || indexable && isArray(value)) {\n          return true;\n        }\n      }\n    } catch (err) {\n      _iterator14.e(err);\n    } finally {\n      _iterator14.f();\n    }\n    return false;\n  }\n  var version = \"4.2.0\";\n  var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];\n  function positionIsHorizontal(position, axis) {\n    return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';\n  }\n  function compare2Level(l1, l2) {\n    return function (a, b) {\n      return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1];\n    };\n  }\n  function onAnimationsComplete(context) {\n    var chart = context.chart;\n    var animationOptions = chart.options.animation;\n    chart.notifyPlugins('afterRender');\n    callback(animationOptions && animationOptions.onComplete, [context], chart);\n  }\n  function onAnimationProgress(context) {\n    var chart = context.chart;\n    var animationOptions = chart.options.animation;\n    callback(animationOptions && animationOptions.onProgress, [context], chart);\n  }\n  function getCanvas(item) {\n    if (_isDomSupported() && typeof item === 'string') {\n      item = document.getElementById(item);\n    } else if (item && item.length) {\n      item = item[0];\n    }\n    if (item && item.canvas) {\n      item = item.canvas;\n    }\n    return item;\n  }\n  var instances = {};\n  var getChart = function getChart(key) {\n    var canvas = getCanvas(key);\n    return Object.values(instances).filter(function (c) {\n      return c.canvas === canvas;\n    }).pop();\n  };\n  function moveNumericKeys(obj, start, move) {\n    var keys = Object.keys(obj);\n    for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {\n      var key = _keys[_i2];\n      var intKey = +key;\n      if (intKey >= start) {\n        var value = obj[key];\n        delete obj[key];\n        if (move > 0 || intKey > start) {\n          obj[intKey + move] = value;\n        }\n      }\n    }\n  }\n  function determineLastEvent(e, lastEvent, inChartArea, isClick) {\n    if (!inChartArea || e.type === 'mouseout') {\n      return null;\n    }\n    if (isClick) {\n      return lastEvent;\n    }\n    return e;\n  }\n  function getDatasetArea(meta) {\n    var xScale = meta.xScale,\n      yScale = meta.yScale;\n    if (xScale && yScale) {\n      return {\n        left: xScale.left,\n        right: xScale.right,\n        top: yScale.top,\n        bottom: yScale.bottom\n      };\n    }\n  }\n  var Chart$1 = /*#__PURE__*/function () {\n    function Chart(item, userConfig) {\n      var _this12 = this;\n      _classCallCheck$x(this, Chart);\n      var config = this.config = new Config(userConfig);\n      var initialCanvas = getCanvas(item);\n      var existingChart = getChart(initialCanvas);\n      if (existingChart) {\n        throw new Error('Canvas is already in use. Chart with ID \\'' + existingChart.id + '\\'' + ' must be destroyed before the canvas with ID \\'' + existingChart.canvas.id + '\\' can be reused.');\n      }\n      var options = config.createResolver(config.chartOptionScopes(), this.getContext());\n      this.platform = new (config.platform || _detectPlatform(initialCanvas))();\n      this.platform.updateConfig(config);\n      var context = this.platform.acquireContext(initialCanvas, options.aspectRatio);\n      var canvas = context && context.canvas;\n      var height = canvas && canvas.height;\n      var width = canvas && canvas.width;\n      this.id = uid();\n      this.ctx = context;\n      this.canvas = canvas;\n      this.width = width;\n      this.height = height;\n      this._options = options;\n      this._aspectRatio = this.aspectRatio;\n      this._layers = [];\n      this._metasets = [];\n      this._stacks = undefined;\n      this.boxes = [];\n      this.currentDevicePixelRatio = undefined;\n      this.chartArea = undefined;\n      this._active = [];\n      this._lastEvent = undefined;\n      this._listeners = {};\n      this._responsiveListeners = undefined;\n      this._sortedMetasets = [];\n      this.scales = {};\n      this._plugins = new PluginService();\n      this.$proxies = {};\n      this._hiddenIndices = {};\n      this.attached = false;\n      this._animationsDisabled = undefined;\n      this.$context = undefined;\n      this._doResize = debounce(function (mode) {\n        return _this12.update(mode);\n      }, options.resizeDelay || 0);\n      this._dataChanges = [];\n      instances[this.id] = this;\n      if (!context || !canvas) {\n        console.error(\"Failed to create chart: can't acquire context from the given item\");\n        return;\n      }\n      animator.listen(this, 'complete', onAnimationsComplete);\n      animator.listen(this, 'progress', onAnimationProgress);\n      this._initialize();\n      if (this.attached) {\n        this.update();\n      }\n    }\n    _createClass$x(Chart, [{\n      key: \"aspectRatio\",\n      get: function get() {\n        var _this$options12 = this.options,\n          aspectRatio = _this$options12.aspectRatio,\n          maintainAspectRatio = _this$options12.maintainAspectRatio,\n          width = this.width,\n          height = this.height,\n          _aspectRatio = this._aspectRatio;\n        if (!isNullOrUndef(aspectRatio)) {\n          return aspectRatio;\n        }\n        if (maintainAspectRatio && _aspectRatio) {\n          return _aspectRatio;\n        }\n        return height ? width / height : null;\n      }\n    }, {\n      key: \"data\",\n      get: function get() {\n        return this.config.data;\n      },\n      set: function set(data) {\n        this.config.data = data;\n      }\n    }, {\n      key: \"options\",\n      get: function get() {\n        return this._options;\n      },\n      set: function set(options) {\n        this.config.options = options;\n      }\n    }, {\n      key: \"registry\",\n      get: function get() {\n        return registry;\n      }\n    }, {\n      key: \"_initialize\",\n      value: function _initialize() {\n        this.notifyPlugins('beforeInit');\n        if (this.options.responsive) {\n          this.resize();\n        } else {\n          retinaScale(this, this.options.devicePixelRatio);\n        }\n        this.bindEvents();\n        this.notifyPlugins('afterInit');\n        return this;\n      }\n    }, {\n      key: \"clear\",\n      value: function clear() {\n        clearCanvas(this.canvas, this.ctx);\n        return this;\n      }\n    }, {\n      key: \"stop\",\n      value: function stop() {\n        animator.stop(this);\n        return this;\n      }\n    }, {\n      key: \"resize\",\n      value: function resize(width, height) {\n        if (!animator.running(this)) {\n          this._resize(width, height);\n        } else {\n          this._resizeBeforeDraw = {\n            width: width,\n            height: height\n          };\n        }\n      }\n    }, {\n      key: \"_resize\",\n      value: function _resize(width, height) {\n        var options = this.options;\n        var canvas = this.canvas;\n        var aspectRatio = options.maintainAspectRatio && this.aspectRatio;\n        var newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio);\n        var newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();\n        var mode = this.width ? 'resize' : 'attach';\n        this.width = newSize.width;\n        this.height = newSize.height;\n        this._aspectRatio = this.aspectRatio;\n        if (!retinaScale(this, newRatio, true)) {\n          return;\n        }\n        this.notifyPlugins('resize', {\n          size: newSize\n        });\n        callback(options.onResize, [this, newSize], this);\n        if (this.attached) {\n          if (this._doResize(mode)) {\n            this.render();\n          }\n        }\n      }\n    }, {\n      key: \"ensureScalesHaveIDs\",\n      value: function ensureScalesHaveIDs() {\n        var options = this.options;\n        var scalesOptions = options.scales || {};\n        each(scalesOptions, function (axisOptions, axisID) {\n          axisOptions.id = axisID;\n        });\n      }\n    }, {\n      key: \"buildOrUpdateScales\",\n      value: function buildOrUpdateScales() {\n        var _this13 = this;\n        var options = this.options;\n        var scaleOpts = options.scales;\n        var scales = this.scales;\n        var updated = Object.keys(scales).reduce(function (obj, id) {\n          obj[id] = false;\n          return obj;\n        }, {});\n        var items = [];\n        if (scaleOpts) {\n          items = items.concat(Object.keys(scaleOpts).map(function (id) {\n            var scaleOptions = scaleOpts[id];\n            var axis = determineAxis(id, scaleOptions);\n            var isRadial = axis === 'r';\n            var isHorizontal = axis === 'x';\n            return {\n              options: scaleOptions,\n              dposition: isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left',\n              dtype: isRadial ? 'radialLinear' : isHorizontal ? 'category' : 'linear'\n            };\n          }));\n        }\n        each(items, function (item) {\n          var scaleOptions = item.options;\n          var id = scaleOptions.id;\n          var axis = determineAxis(id, scaleOptions);\n          var scaleType = valueOrDefault(scaleOptions.type, item.dtype);\n          if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, axis) !== positionIsHorizontal(item.dposition)) {\n            scaleOptions.position = item.dposition;\n          }\n          updated[id] = true;\n          var scale = null;\n          if (id in scales && scales[id].type === scaleType) {\n            scale = scales[id];\n          } else {\n            var scaleClass = registry.getScale(scaleType);\n            scale = new scaleClass({\n              id: id,\n              type: scaleType,\n              ctx: _this13.ctx,\n              chart: _this13\n            });\n            scales[scale.id] = scale;\n          }\n          scale.init(scaleOptions, options);\n        });\n        each(updated, function (hasUpdated, id) {\n          if (!hasUpdated) {\n            delete scales[id];\n          }\n        });\n        each(scales, function (scale) {\n          layouts.configure(_this13, scale, scale.options);\n          layouts.addBox(_this13, scale);\n        });\n      }\n    }, {\n      key: \"_updateMetasets\",\n      value: function _updateMetasets() {\n        var metasets = this._metasets;\n        var numData = this.data.datasets.length;\n        var numMeta = metasets.length;\n        metasets.sort(function (a, b) {\n          return a.index - b.index;\n        });\n        if (numMeta > numData) {\n          for (var i = numData; i < numMeta; ++i) {\n            this._destroyDatasetMeta(i);\n          }\n          metasets.splice(numData, numMeta - numData);\n        }\n        this._sortedMetasets = metasets.slice(0).sort(compare2Level('order', 'index'));\n      }\n    }, {\n      key: \"_removeUnreferencedMetasets\",\n      value: function _removeUnreferencedMetasets() {\n        var _this14 = this;\n        var metasets = this._metasets,\n          datasets = this.data.datasets;\n        if (metasets.length > datasets.length) {\n          delete this._stacks;\n        }\n        metasets.forEach(function (meta, index) {\n          if (datasets.filter(function (x) {\n            return x === meta._dataset;\n          }).length === 0) {\n            _this14._destroyDatasetMeta(index);\n          }\n        });\n      }\n    }, {\n      key: \"buildOrUpdateControllers\",\n      value: function buildOrUpdateControllers() {\n        var newControllers = [];\n        var datasets = this.data.datasets;\n        var i, ilen;\n        this._removeUnreferencedMetasets();\n        for (i = 0, ilen = datasets.length; i < ilen; i++) {\n          var dataset = datasets[i];\n          var meta = this.getDatasetMeta(i);\n          var type = dataset.type || this.config.type;\n          if (meta.type && meta.type !== type) {\n            this._destroyDatasetMeta(i);\n            meta = this.getDatasetMeta(i);\n          }\n          meta.type = type;\n          meta.indexAxis = dataset.indexAxis || getIndexAxis(type, this.options);\n          meta.order = dataset.order || 0;\n          meta.index = i;\n          meta.label = '' + dataset.label;\n          meta.visible = this.isDatasetVisible(i);\n          if (meta.controller) {\n            meta.controller.updateIndex(i);\n            meta.controller.linkScales();\n          } else {\n            var ControllerClass = registry.getController(type);\n            var _defaults$datasets$ty = defaults.datasets[type],\n              datasetElementType = _defaults$datasets$ty.datasetElementType,\n              dataElementType = _defaults$datasets$ty.dataElementType;\n            Object.assign(ControllerClass, {\n              dataElementType: registry.getElement(dataElementType),\n              datasetElementType: datasetElementType && registry.getElement(datasetElementType)\n            });\n            meta.controller = new ControllerClass(this, i);\n            newControllers.push(meta.controller);\n          }\n        }\n        this._updateMetasets();\n        return newControllers;\n      }\n    }, {\n      key: \"_resetElements\",\n      value: function _resetElements() {\n        var _this15 = this;\n        each(this.data.datasets, function (dataset, datasetIndex) {\n          _this15.getDatasetMeta(datasetIndex).controller.reset();\n        }, this);\n      }\n    }, {\n      key: \"reset\",\n      value: function reset() {\n        this._resetElements();\n        this.notifyPlugins('reset');\n      }\n    }, {\n      key: \"update\",\n      value: function update(mode) {\n        var config = this.config;\n        config.update();\n        var options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext());\n        var animsDisabled = this._animationsDisabled = !options.animation;\n        this._updateScales();\n        this._checkEventBindings();\n        this._updateHiddenIndices();\n        this._plugins.invalidate();\n        if (this.notifyPlugins('beforeUpdate', {\n          mode: mode,\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        var newControllers = this.buildOrUpdateControllers();\n        this.notifyPlugins('beforeElementsUpdate');\n        var minPadding = 0;\n        for (var i = 0, ilen = this.data.datasets.length; i < ilen; i++) {\n          var _this$getDatasetMeta = this.getDatasetMeta(i),\n            controller = _this$getDatasetMeta.controller;\n          var reset = !animsDisabled && newControllers.indexOf(controller) === -1;\n          controller.buildOrUpdateElements(reset);\n          minPadding = Math.max(+controller.getMaxOverflow(), minPadding);\n        }\n        minPadding = this._minPadding = options.layout.autoPadding ? minPadding : 0;\n        this._updateLayout(minPadding);\n        if (!animsDisabled) {\n          each(newControllers, function (controller) {\n            controller.reset();\n          });\n        }\n        this._updateDatasets(mode);\n        this.notifyPlugins('afterUpdate', {\n          mode: mode\n        });\n        this._layers.sort(compare2Level('z', '_idx'));\n        var _active = this._active,\n          _lastEvent = this._lastEvent;\n        if (_lastEvent) {\n          this._eventHandler(_lastEvent, true);\n        } else if (_active.length) {\n          this._updateHoverStyles(_active, _active, true);\n        }\n        this.render();\n      }\n    }, {\n      key: \"_updateScales\",\n      value: function _updateScales() {\n        var _this16 = this;\n        each(this.scales, function (scale) {\n          layouts.removeBox(_this16, scale);\n        });\n        this.ensureScalesHaveIDs();\n        this.buildOrUpdateScales();\n      }\n    }, {\n      key: \"_checkEventBindings\",\n      value: function _checkEventBindings() {\n        var options = this.options;\n        var existingEvents = new Set(Object.keys(this._listeners));\n        var newEvents = new Set(options.events);\n        if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) {\n          this.unbindEvents();\n          this.bindEvents();\n        }\n      }\n    }, {\n      key: \"_updateHiddenIndices\",\n      value: function _updateHiddenIndices() {\n        var _hiddenIndices = this._hiddenIndices;\n        var changes = this._getUniformDataChanges() || [];\n        var _iterator15 = _createForOfIteratorHelper$1(changes),\n          _step15;\n        try {\n          for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {\n            var _step15$value = _step15.value,\n              method = _step15$value.method,\n              start = _step15$value.start,\n              count = _step15$value.count;\n            var move = method === '_removeElements' ? -count : count;\n            moveNumericKeys(_hiddenIndices, start, move);\n          }\n        } catch (err) {\n          _iterator15.e(err);\n        } finally {\n          _iterator15.f();\n        }\n      }\n    }, {\n      key: \"_getUniformDataChanges\",\n      value: function _getUniformDataChanges() {\n        var _dataChanges = this._dataChanges;\n        if (!_dataChanges || !_dataChanges.length) {\n          return;\n        }\n        this._dataChanges = [];\n        var datasetCount = this.data.datasets.length;\n        var makeSet = function makeSet(idx) {\n          return new Set(_dataChanges.filter(function (c) {\n            return c[0] === idx;\n          }).map(function (c, i) {\n            return i + ',' + c.splice(1).join(',');\n          }));\n        };\n        var changeSet = makeSet(0);\n        for (var i = 1; i < datasetCount; i++) {\n          if (!setsEqual(changeSet, makeSet(i))) {\n            return;\n          }\n        }\n        return Array.from(changeSet).map(function (c) {\n          return c.split(',');\n        }).map(function (a) {\n          return {\n            method: a[1],\n            start: +a[2],\n            count: +a[3]\n          };\n        });\n      }\n    }, {\n      key: \"_updateLayout\",\n      value: function _updateLayout(minPadding) {\n        var _this17 = this;\n        if (this.notifyPlugins('beforeLayout', {\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        layouts.update(this, this.width, this.height, minPadding);\n        var area = this.chartArea;\n        var noArea = area.width <= 0 || area.height <= 0;\n        this._layers = [];\n        each(this.boxes, function (box) {\n          var _this17$_layers;\n          if (noArea && box.position === 'chartArea') {\n            return;\n          }\n          if (box.configure) {\n            box.configure();\n          }\n          (_this17$_layers = _this17._layers).push.apply(_this17$_layers, _toConsumableArray(box._layers()));\n        }, this);\n        this._layers.forEach(function (item, index) {\n          item._idx = index;\n        });\n        this.notifyPlugins('afterLayout');\n      }\n    }, {\n      key: \"_updateDatasets\",\n      value: function _updateDatasets(mode) {\n        if (this.notifyPlugins('beforeDatasetsUpdate', {\n          mode: mode,\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n          this.getDatasetMeta(i).controller.configure();\n        }\n        for (var i1 = 0, ilen1 = this.data.datasets.length; i1 < ilen1; ++i1) {\n          this._updateDataset(i1, isFunction(mode) ? mode({\n            datasetIndex: i1\n          }) : mode);\n        }\n        this.notifyPlugins('afterDatasetsUpdate', {\n          mode: mode\n        });\n      }\n    }, {\n      key: \"_updateDataset\",\n      value: function _updateDataset(index, mode) {\n        var meta = this.getDatasetMeta(index);\n        var args = {\n          meta: meta,\n          index: index,\n          mode: mode,\n          cancelable: true\n        };\n        if (this.notifyPlugins('beforeDatasetUpdate', args) === false) {\n          return;\n        }\n        meta.controller._update(mode);\n        args.cancelable = false;\n        this.notifyPlugins('afterDatasetUpdate', args);\n      }\n    }, {\n      key: \"render\",\n      value: function render() {\n        if (this.notifyPlugins('beforeRender', {\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        if (animator.has(this)) {\n          if (this.attached && !animator.running(this)) {\n            animator.start(this);\n          }\n        } else {\n          this.draw();\n          onAnimationsComplete({\n            chart: this\n          });\n        }\n      }\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        var i;\n        if (this._resizeBeforeDraw) {\n          var _this$_resizeBeforeDr = this._resizeBeforeDraw,\n            width = _this$_resizeBeforeDr.width,\n            height = _this$_resizeBeforeDr.height;\n          this._resize(width, height);\n          this._resizeBeforeDraw = null;\n        }\n        this.clear();\n        if (this.width <= 0 || this.height <= 0) {\n          return;\n        }\n        if (this.notifyPlugins('beforeDraw', {\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        var layers = this._layers;\n        for (i = 0; i < layers.length && layers[i].z <= 0; ++i) {\n          layers[i].draw(this.chartArea);\n        }\n        this._drawDatasets();\n        for (; i < layers.length; ++i) {\n          layers[i].draw(this.chartArea);\n        }\n        this.notifyPlugins('afterDraw');\n      }\n    }, {\n      key: \"_getSortedDatasetMetas\",\n      value: function _getSortedDatasetMetas(filterVisible) {\n        var metasets = this._sortedMetasets;\n        var result = [];\n        var i, ilen;\n        for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n          var meta = metasets[i];\n          if (!filterVisible || meta.visible) {\n            result.push(meta);\n          }\n        }\n        return result;\n      }\n    }, {\n      key: \"getSortedVisibleDatasetMetas\",\n      value: function getSortedVisibleDatasetMetas() {\n        return this._getSortedDatasetMetas(true);\n      }\n    }, {\n      key: \"_drawDatasets\",\n      value: function _drawDatasets() {\n        if (this.notifyPlugins('beforeDatasetsDraw', {\n          cancelable: true\n        }) === false) {\n          return;\n        }\n        var metasets = this.getSortedVisibleDatasetMetas();\n        for (var i = metasets.length - 1; i >= 0; --i) {\n          this._drawDataset(metasets[i]);\n        }\n        this.notifyPlugins('afterDatasetsDraw');\n      }\n    }, {\n      key: \"_drawDataset\",\n      value: function _drawDataset(meta) {\n        var ctx = this.ctx;\n        var clip = meta._clip;\n        var useClip = !clip.disabled;\n        var area = getDatasetArea(meta) || this.chartArea;\n        var args = {\n          meta: meta,\n          index: meta.index,\n          cancelable: true\n        };\n        if (this.notifyPlugins('beforeDatasetDraw', args) === false) {\n          return;\n        }\n        if (useClip) {\n          clipArea(ctx, {\n            left: clip.left === false ? 0 : area.left - clip.left,\n            right: clip.right === false ? this.width : area.right + clip.right,\n            top: clip.top === false ? 0 : area.top - clip.top,\n            bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom\n          });\n        }\n        meta.controller.draw();\n        if (useClip) {\n          unclipArea(ctx);\n        }\n        args.cancelable = false;\n        this.notifyPlugins('afterDatasetDraw', args);\n      }\n    }, {\n      key: \"isPointInArea\",\n      value: function isPointInArea(point) {\n        return _isPointInArea(point, this.chartArea, this._minPadding);\n      }\n    }, {\n      key: \"getElementsAtEventForMode\",\n      value: function getElementsAtEventForMode(e, mode, options, useFinalPosition) {\n        var method = Interaction.modes[mode];\n        if (typeof method === 'function') {\n          return method(this, e, options, useFinalPosition);\n        }\n        return [];\n      }\n    }, {\n      key: \"getDatasetMeta\",\n      value: function getDatasetMeta(datasetIndex) {\n        var dataset = this.data.datasets[datasetIndex];\n        var metasets = this._metasets;\n        var meta = metasets.filter(function (x) {\n          return x && x._dataset === dataset;\n        }).pop();\n        if (!meta) {\n          meta = {\n            type: null,\n            data: [],\n            dataset: null,\n            controller: null,\n            hidden: null,\n            xAxisID: null,\n            yAxisID: null,\n            order: dataset && dataset.order || 0,\n            index: datasetIndex,\n            _dataset: dataset,\n            _parsed: [],\n            _sorted: false\n          };\n          metasets.push(meta);\n        }\n        return meta;\n      }\n    }, {\n      key: \"getContext\",\n      value: function getContext() {\n        return this.$context || (this.$context = createContext(null, {\n          chart: this,\n          type: 'chart'\n        }));\n      }\n    }, {\n      key: \"getVisibleDatasetCount\",\n      value: function getVisibleDatasetCount() {\n        return this.getSortedVisibleDatasetMetas().length;\n      }\n    }, {\n      key: \"isDatasetVisible\",\n      value: function isDatasetVisible(datasetIndex) {\n        var dataset = this.data.datasets[datasetIndex];\n        if (!dataset) {\n          return false;\n        }\n        var meta = this.getDatasetMeta(datasetIndex);\n        return typeof meta.hidden === 'boolean' ? !meta.hidden : !dataset.hidden;\n      }\n    }, {\n      key: \"setDatasetVisibility\",\n      value: function setDatasetVisibility(datasetIndex, visible) {\n        var meta = this.getDatasetMeta(datasetIndex);\n        meta.hidden = !visible;\n      }\n    }, {\n      key: \"toggleDataVisibility\",\n      value: function toggleDataVisibility(index) {\n        this._hiddenIndices[index] = !this._hiddenIndices[index];\n      }\n    }, {\n      key: \"getDataVisibility\",\n      value: function getDataVisibility(index) {\n        return !this._hiddenIndices[index];\n      }\n    }, {\n      key: \"_updateVisibility\",\n      value: function _updateVisibility(datasetIndex, dataIndex, visible) {\n        var mode = visible ? 'show' : 'hide';\n        var meta = this.getDatasetMeta(datasetIndex);\n        var anims = meta.controller._resolveAnimations(undefined, mode);\n        if (defined(dataIndex)) {\n          meta.data[dataIndex].hidden = !visible;\n          this.update();\n        } else {\n          this.setDatasetVisibility(datasetIndex, visible);\n          anims.update(meta, {\n            visible: visible\n          });\n          this.update(function (ctx) {\n            return ctx.datasetIndex === datasetIndex ? mode : undefined;\n          });\n        }\n      }\n    }, {\n      key: \"hide\",\n      value: function hide(datasetIndex, dataIndex) {\n        this._updateVisibility(datasetIndex, dataIndex, false);\n      }\n    }, {\n      key: \"show\",\n      value: function show(datasetIndex, dataIndex) {\n        this._updateVisibility(datasetIndex, dataIndex, true);\n      }\n    }, {\n      key: \"_destroyDatasetMeta\",\n      value: function _destroyDatasetMeta(datasetIndex) {\n        var meta = this._metasets[datasetIndex];\n        if (meta && meta.controller) {\n          meta.controller._destroy();\n        }\n        delete this._metasets[datasetIndex];\n      }\n    }, {\n      key: \"_stop\",\n      value: function _stop() {\n        var i, ilen;\n        this.stop();\n        animator.remove(this);\n        for (i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n          this._destroyDatasetMeta(i);\n        }\n      }\n    }, {\n      key: \"destroy\",\n      value: function destroy() {\n        this.notifyPlugins('beforeDestroy');\n        var canvas = this.canvas,\n          ctx = this.ctx;\n        this._stop();\n        this.config.clearCache();\n        if (canvas) {\n          this.unbindEvents();\n          clearCanvas(canvas, ctx);\n          this.platform.releaseContext(ctx);\n          this.canvas = null;\n          this.ctx = null;\n        }\n        delete instances[this.id];\n        this.notifyPlugins('afterDestroy');\n      }\n    }, {\n      key: \"toBase64Image\",\n      value: function toBase64Image() {\n        var _this$canvas;\n        return (_this$canvas = this.canvas).toDataURL.apply(_this$canvas, arguments);\n      }\n    }, {\n      key: \"bindEvents\",\n      value: function bindEvents() {\n        this.bindUserEvents();\n        if (this.options.responsive) {\n          this.bindResponsiveEvents();\n        } else {\n          this.attached = true;\n        }\n      }\n    }, {\n      key: \"bindUserEvents\",\n      value: function bindUserEvents() {\n        var _this18 = this;\n        var listeners = this._listeners;\n        var platform = this.platform;\n        var _add = function _add(type, listener) {\n          platform.addEventListener(_this18, type, listener);\n          listeners[type] = listener;\n        };\n        var listener = function listener(e, x, y) {\n          e.offsetX = x;\n          e.offsetY = y;\n          _this18._eventHandler(e);\n        };\n        each(this.options.events, function (type) {\n          return _add(type, listener);\n        });\n      }\n    }, {\n      key: \"bindResponsiveEvents\",\n      value: function bindResponsiveEvents() {\n        var _this19 = this;\n        if (!this._responsiveListeners) {\n          this._responsiveListeners = {};\n        }\n        var listeners = this._responsiveListeners;\n        var platform = this.platform;\n        var _add = function _add(type, listener) {\n          platform.addEventListener(_this19, type, listener);\n          listeners[type] = listener;\n        };\n        var _remove = function _remove(type, listener) {\n          if (listeners[type]) {\n            platform.removeEventListener(_this19, type, listener);\n            delete listeners[type];\n          }\n        };\n        var listener = function listener(width, height) {\n          if (_this19.canvas) {\n            _this19.resize(width, height);\n          }\n        };\n        var detached;\n        var attached = function attached() {\n          _remove('attach', attached);\n          _this19.attached = true;\n          _this19.resize();\n          _add('resize', listener);\n          _add('detach', detached);\n        };\n        detached = function detached() {\n          _this19.attached = false;\n          _remove('resize', listener);\n          _this19._stop();\n          _this19._resize(0, 0);\n          _add('attach', attached);\n        };\n        if (platform.isAttached(this.canvas)) {\n          attached();\n        } else {\n          detached();\n        }\n      }\n    }, {\n      key: \"unbindEvents\",\n      value: function unbindEvents() {\n        var _this20 = this;\n        each(this._listeners, function (listener, type) {\n          _this20.platform.removeEventListener(_this20, type, listener);\n        });\n        this._listeners = {};\n        each(this._responsiveListeners, function (listener, type) {\n          _this20.platform.removeEventListener(_this20, type, listener);\n        });\n        this._responsiveListeners = undefined;\n      }\n    }, {\n      key: \"updateHoverStyle\",\n      value: function updateHoverStyle(items, mode, enabled) {\n        var prefix = enabled ? 'set' : 'remove';\n        var meta, item, i, ilen;\n        if (mode === 'dataset') {\n          meta = this.getDatasetMeta(items[0].datasetIndex);\n          meta.controller['_' + prefix + 'DatasetHoverStyle']();\n        }\n        for (i = 0, ilen = items.length; i < ilen; ++i) {\n          item = items[i];\n          var controller = item && this.getDatasetMeta(item.datasetIndex).controller;\n          if (controller) {\n            controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index);\n          }\n        }\n      }\n    }, {\n      key: \"getActiveElements\",\n      value: function getActiveElements() {\n        return this._active || [];\n      }\n    }, {\n      key: \"setActiveElements\",\n      value: function setActiveElements(activeElements) {\n        var _this21 = this;\n        var lastActive = this._active || [];\n        var active = activeElements.map(function (_ref4) {\n          var datasetIndex = _ref4.datasetIndex,\n            index = _ref4.index;\n          var meta = _this21.getDatasetMeta(datasetIndex);\n          if (!meta) {\n            throw new Error('No dataset found at index ' + datasetIndex);\n          }\n          return {\n            datasetIndex: datasetIndex,\n            element: meta.data[index],\n            index: index\n          };\n        });\n        var changed = !_elementsEqual(active, lastActive);\n        if (changed) {\n          this._active = active;\n          this._lastEvent = null;\n          this._updateHoverStyles(active, lastActive);\n        }\n      }\n    }, {\n      key: \"notifyPlugins\",\n      value: function notifyPlugins(hook, args, filter) {\n        return this._plugins.notify(this, hook, args, filter);\n      }\n    }, {\n      key: \"isPluginEnabled\",\n      value: function isPluginEnabled(pluginId) {\n        return this._plugins._cache.filter(function (p) {\n          return p.plugin.id === pluginId;\n        }).length === 1;\n      }\n    }, {\n      key: \"_updateHoverStyles\",\n      value: function _updateHoverStyles(active, lastActive, replay) {\n        var hoverOptions = this.options.hover;\n        var diff = function diff(a, b) {\n          return a.filter(function (x) {\n            return !b.some(function (y) {\n              return x.datasetIndex === y.datasetIndex && x.index === y.index;\n            });\n          });\n        };\n        var deactivated = diff(lastActive, active);\n        var activated = replay ? active : diff(active, lastActive);\n        if (deactivated.length) {\n          this.updateHoverStyle(deactivated, hoverOptions.mode, false);\n        }\n        if (activated.length && hoverOptions.mode) {\n          this.updateHoverStyle(activated, hoverOptions.mode, true);\n        }\n      }\n    }, {\n      key: \"_eventHandler\",\n      value: function _eventHandler(e, replay) {\n        var _this22 = this;\n        var args = {\n          event: e,\n          replay: replay,\n          cancelable: true,\n          inChartArea: this.isPointInArea(e)\n        };\n        var eventFilter = function eventFilter(plugin) {\n          return (plugin.options.events || _this22.options.events).includes(e[\"native\"].type);\n        };\n        if (this.notifyPlugins('beforeEvent', args, eventFilter) === false) {\n          return;\n        }\n        var changed = this._handleEvent(e, replay, args.inChartArea);\n        args.cancelable = false;\n        this.notifyPlugins('afterEvent', args, eventFilter);\n        if (changed || args.changed) {\n          this.render();\n        }\n        return this;\n      }\n    }, {\n      key: \"_handleEvent\",\n      value: function _handleEvent(e, replay, inChartArea) {\n        var _this$_active = this._active,\n          lastActive = _this$_active === void 0 ? [] : _this$_active,\n          options = this.options;\n        var useFinalPosition = replay;\n        var active = this._getActiveElements(e, lastActive, inChartArea, useFinalPosition);\n        var isClick = _isClickEvent(e);\n        var lastEvent = determineLastEvent(e, this._lastEvent, inChartArea, isClick);\n        if (inChartArea) {\n          this._lastEvent = null;\n          callback(options.onHover, [e, active, this], this);\n          if (isClick) {\n            callback(options.onClick, [e, active, this], this);\n          }\n        }\n        var changed = !_elementsEqual(active, lastActive);\n        if (changed || replay) {\n          this._active = active;\n          this._updateHoverStyles(active, lastActive, replay);\n        }\n        this._lastEvent = lastEvent;\n        return changed;\n      }\n    }, {\n      key: \"_getActiveElements\",\n      value: function _getActiveElements(e, lastActive, inChartArea, useFinalPosition) {\n        if (e.type === 'mouseout') {\n          return [];\n        }\n        if (!inChartArea) {\n          return lastActive;\n        }\n        var hoverOptions = this.options.hover;\n        return this.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition);\n      }\n    }], [{\n      key: \"register\",\n      value: function register() {\n        registry.add.apply(registry, arguments);\n        invalidatePlugins();\n      }\n    }, {\n      key: \"unregister\",\n      value: function unregister() {\n        registry.remove.apply(registry, arguments);\n        invalidatePlugins();\n      }\n    }]);\n    return Chart;\n  }();\n  _defineProperty$w(Chart$1, \"defaults\", defaults);\n  _defineProperty$w(Chart$1, \"instances\", instances);\n  _defineProperty$w(Chart$1, \"overrides\", overrides);\n  _defineProperty$w(Chart$1, \"registry\", registry);\n  _defineProperty$w(Chart$1, \"version\", version);\n  _defineProperty$w(Chart$1, \"getChart\", getChart);\n  function invalidatePlugins() {\n    return each(Chart$1.instances, function (chart) {\n      return chart._plugins.invalidate();\n    });\n  }\n  function clipArc(ctx, element, endAngle) {\n    var startAngle = element.startAngle,\n      pixelMargin = element.pixelMargin,\n      x = element.x,\n      y = element.y,\n      outerRadius = element.outerRadius,\n      innerRadius = element.innerRadius;\n    var angleMargin = pixelMargin / outerRadius;\n    // Draw an inner border by clipping the arc and drawing a double-width border\n    // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between borders\n    ctx.beginPath();\n    ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin);\n    if (innerRadius > pixelMargin) {\n      angleMargin = pixelMargin / innerRadius;\n      ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true);\n    } else {\n      ctx.arc(x, y, pixelMargin, endAngle + HALF_PI, startAngle - HALF_PI);\n    }\n    ctx.closePath();\n    ctx.clip();\n  }\n  function toRadiusCorners(value) {\n    return _readValueToProps(value, ['outerStart', 'outerEnd', 'innerStart', 'innerEnd']);\n  }\n  /**\n   * Parse border radius from the provided options\n   */\n  function parseBorderRadius$1(arc, innerRadius, outerRadius, angleDelta) {\n    var o = toRadiusCorners(arc.options.borderRadius);\n    var halfThickness = (outerRadius - innerRadius) / 2;\n    var innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);\n    // Outer limits are complicated. We want to compute the available angular distance at\n    // a radius of outerRadius - borderRadius because for small angular distances, this term limits.\n    // We compute at r = outerRadius - borderRadius because this circle defines the center of the border corners.\n    //\n    // If the borderRadius is large, that value can become negative.\n    // This causes the outer borders to lose their radius entirely, which is rather unexpected. To solve that, if borderRadius > outerRadius\n    // we know that the thickness term will dominate and compute the limits at that point\n    var computeOuterLimit = function computeOuterLimit(val) {\n      var outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2;\n      return _limitValue(val, 0, Math.min(halfThickness, outerArcLimit));\n    };\n    return {\n      outerStart: computeOuterLimit(o.outerStart),\n      outerEnd: computeOuterLimit(o.outerEnd),\n      innerStart: _limitValue(o.innerStart, 0, innerLimit),\n      innerEnd: _limitValue(o.innerEnd, 0, innerLimit)\n    };\n  }\n  /**\n   * Convert (r, 𝜃) to (x, y)\n   */\n  function rThetaToXY(r, theta, x, y) {\n    return {\n      x: x + r * Math.cos(theta),\n      y: y + r * Math.sin(theta)\n    };\n  }\n  /**\n   * Path the arc, respecting border radius by separating into left and right halves.\n   *\n   *   Start      End\n   *\n   *    1--->a--->2    Outer\n   *   /           \\\n   *   8           3\n   *   |           |\n   *   |           |\n   *   7           4\n   *   \\           /\n   *    6<---b<---5    Inner\n   */\n  function pathArc(ctx, element, offset, spacing, end, circular) {\n    var x = element.x,\n      y = element.y,\n      start = element.startAngle,\n      pixelMargin = element.pixelMargin,\n      innerR = element.innerRadius;\n    var outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);\n    var innerRadius = innerR > 0 ? innerR + spacing + offset + pixelMargin : 0;\n    var spacingOffset = 0;\n    var alpha = end - start;\n    if (spacing) {\n      // When spacing is present, it is the same for all items\n      // So we adjust the start and end angle of the arc such that\n      // the distance is the same as it would be without the spacing\n      var noSpacingInnerRadius = innerR > 0 ? innerR - spacing : 0;\n      var noSpacingOuterRadius = outerRadius > 0 ? outerRadius - spacing : 0;\n      var avNogSpacingRadius = (noSpacingInnerRadius + noSpacingOuterRadius) / 2;\n      var adjustedAngle = avNogSpacingRadius !== 0 ? alpha * avNogSpacingRadius / (avNogSpacingRadius + spacing) : alpha;\n      spacingOffset = (alpha - adjustedAngle) / 2;\n    }\n    var beta = Math.max(0.001, alpha * outerRadius - offset / PI) / outerRadius;\n    var angleOffset = (alpha - beta) / 2;\n    var startAngle = start + angleOffset + spacingOffset;\n    var endAngle = end - angleOffset - spacingOffset;\n    var _parseBorderRadius$ = parseBorderRadius$1(element, innerRadius, outerRadius, endAngle - startAngle),\n      outerStart = _parseBorderRadius$.outerStart,\n      outerEnd = _parseBorderRadius$.outerEnd,\n      innerStart = _parseBorderRadius$.innerStart,\n      innerEnd = _parseBorderRadius$.innerEnd;\n    var outerStartAdjustedRadius = outerRadius - outerStart;\n    var outerEndAdjustedRadius = outerRadius - outerEnd;\n    var outerStartAdjustedAngle = startAngle + outerStart / outerStartAdjustedRadius;\n    var outerEndAdjustedAngle = endAngle - outerEnd / outerEndAdjustedRadius;\n    var innerStartAdjustedRadius = innerRadius + innerStart;\n    var innerEndAdjustedRadius = innerRadius + innerEnd;\n    var innerStartAdjustedAngle = startAngle + innerStart / innerStartAdjustedRadius;\n    var innerEndAdjustedAngle = endAngle - innerEnd / innerEndAdjustedRadius;\n    ctx.beginPath();\n    if (circular) {\n      // The first arc segments from point 1 to point a to point 2\n      var outerMidAdjustedAngle = (outerStartAdjustedAngle + outerEndAdjustedAngle) / 2;\n      ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerMidAdjustedAngle);\n      ctx.arc(x, y, outerRadius, outerMidAdjustedAngle, outerEndAdjustedAngle);\n      // The corner segment from point 2 to point 3\n      if (outerEnd > 0) {\n        var pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);\n        ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + HALF_PI);\n      }\n      // The line from point 3 to point 4\n      var p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);\n      ctx.lineTo(p4.x, p4.y);\n      // The corner segment from point 4 to point 5\n      if (innerEnd > 0) {\n        var pCenter1 = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);\n        ctx.arc(pCenter1.x, pCenter1.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);\n      }\n      // The inner arc from point 5 to point b to point 6\n      var innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;\n      ctx.arc(x, y, innerRadius, endAngle - innerEnd / innerRadius, innerMidAdjustedAngle, true);\n      ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);\n      // The corner segment from point 6 to point 7\n      if (innerStart > 0) {\n        var pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);\n        ctx.arc(pCenter2.x, pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);\n      }\n      // The line from point 7 to point 8\n      var p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);\n      ctx.lineTo(p8.x, p8.y);\n      // The corner segment from point 8 to point 1\n      if (outerStart > 0) {\n        var pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);\n        ctx.arc(pCenter3.x, pCenter3.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);\n      }\n    } else {\n      ctx.moveTo(x, y);\n      var outerStartX = Math.cos(outerStartAdjustedAngle) * outerRadius + x;\n      var outerStartY = Math.sin(outerStartAdjustedAngle) * outerRadius + y;\n      ctx.lineTo(outerStartX, outerStartY);\n      var outerEndX = Math.cos(outerEndAdjustedAngle) * outerRadius + x;\n      var outerEndY = Math.sin(outerEndAdjustedAngle) * outerRadius + y;\n      ctx.lineTo(outerEndX, outerEndY);\n    }\n    ctx.closePath();\n  }\n  function drawArc(ctx, element, offset, spacing, circular) {\n    var fullCircles = element.fullCircles,\n      startAngle = element.startAngle,\n      circumference = element.circumference;\n    var endAngle = element.endAngle;\n    if (fullCircles) {\n      pathArc(ctx, element, offset, spacing, endAngle, circular);\n      for (var i = 0; i < fullCircles; ++i) {\n        ctx.fill();\n      }\n      if (!isNaN(circumference)) {\n        endAngle = startAngle + (circumference % TAU || TAU);\n      }\n    }\n    pathArc(ctx, element, offset, spacing, endAngle, circular);\n    ctx.fill();\n    return endAngle;\n  }\n  function drawBorder(ctx, element, offset, spacing, circular) {\n    var fullCircles = element.fullCircles,\n      startAngle = element.startAngle,\n      circumference = element.circumference,\n      options = element.options;\n    var borderWidth = options.borderWidth,\n      borderJoinStyle = options.borderJoinStyle;\n    var inner = options.borderAlign === 'inner';\n    if (!borderWidth) {\n      return;\n    }\n    if (inner) {\n      ctx.lineWidth = borderWidth * 2;\n      ctx.lineJoin = borderJoinStyle || 'round';\n    } else {\n      ctx.lineWidth = borderWidth;\n      ctx.lineJoin = borderJoinStyle || 'bevel';\n    }\n    var endAngle = element.endAngle;\n    if (fullCircles) {\n      pathArc(ctx, element, offset, spacing, endAngle, circular);\n      for (var i = 0; i < fullCircles; ++i) {\n        ctx.stroke();\n      }\n      if (!isNaN(circumference)) {\n        endAngle = startAngle + (circumference % TAU || TAU);\n      }\n    }\n    if (inner) {\n      clipArc(ctx, element, endAngle);\n    }\n    if (!fullCircles) {\n      pathArc(ctx, element, offset, spacing, endAngle, circular);\n      ctx.stroke();\n    }\n  }\n  var ArcElement = /*#__PURE__*/function (_Element2) {\n    _inherits$w(ArcElement, _Element2);\n    var _super12 = _createSuper$w(ArcElement);\n    function ArcElement(cfg) {\n      var _this23;\n      _classCallCheck$x(this, ArcElement);\n      _this23 = _super12.call(this);\n      _this23.options = undefined;\n      _this23.circumference = undefined;\n      _this23.startAngle = undefined;\n      _this23.endAngle = undefined;\n      _this23.innerRadius = undefined;\n      _this23.outerRadius = undefined;\n      _this23.pixelMargin = 0;\n      _this23.fullCircles = 0;\n      if (cfg) {\n        Object.assign(_assertThisInitialized$w(_this23), cfg);\n      }\n      return _this23;\n    }\n    _createClass$x(ArcElement, [{\n      key: \"inRange\",\n      value: function inRange(chartX, chartY, useFinalPosition) {\n        var point = this.getProps(['x', 'y'], useFinalPosition);\n        var _getAngleFromPoint2 = getAngleFromPoint(point, {\n            x: chartX,\n            y: chartY\n          }),\n          angle = _getAngleFromPoint2.angle,\n          distance = _getAngleFromPoint2.distance;\n        var _this$getProps2 = this.getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition),\n          startAngle = _this$getProps2.startAngle,\n          endAngle = _this$getProps2.endAngle,\n          innerRadius = _this$getProps2.innerRadius,\n          outerRadius = _this$getProps2.outerRadius,\n          circumference = _this$getProps2.circumference;\n        var rAdjust = this.options.spacing / 2;\n        var _circumference = valueOrDefault(circumference, endAngle - startAngle);\n        var betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);\n        var withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);\n        return betweenAngles && withinRadius;\n      }\n    }, {\n      key: \"getCenterPoint\",\n      value: function getCenterPoint(useFinalPosition) {\n        var _this$getProps3 = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition),\n          x = _this$getProps3.x,\n          y = _this$getProps3.y,\n          startAngle = _this$getProps3.startAngle,\n          endAngle = _this$getProps3.endAngle,\n          innerRadius = _this$getProps3.innerRadius,\n          outerRadius = _this$getProps3.outerRadius;\n        var _this$options13 = this.options,\n          offset = _this$options13.offset,\n          spacing = _this$options13.spacing;\n        var halfAngle = (startAngle + endAngle) / 2;\n        var halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;\n        return {\n          x: x + Math.cos(halfAngle) * halfRadius,\n          y: y + Math.sin(halfAngle) * halfRadius\n        };\n      }\n    }, {\n      key: \"tooltipPosition\",\n      value: function tooltipPosition(useFinalPosition) {\n        return this.getCenterPoint(useFinalPosition);\n      }\n    }, {\n      key: \"draw\",\n      value: function draw(ctx) {\n        var options = this.options,\n          circumference = this.circumference;\n        var offset = (options.offset || 0) / 4;\n        var spacing = (options.spacing || 0) / 2;\n        var circular = options.circular;\n        this.pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0;\n        this.fullCircles = circumference > TAU ? Math.floor(circumference / TAU) : 0;\n        if (circumference === 0 || this.innerRadius < 0 || this.outerRadius < 0) {\n          return;\n        }\n        ctx.save();\n        var halfAngle = (this.startAngle + this.endAngle) / 2;\n        ctx.translate(Math.cos(halfAngle) * offset, Math.sin(halfAngle) * offset);\n        var fix = 1 - Math.sin(Math.min(PI, circumference || 0));\n        var radiusOffset = offset * fix;\n        ctx.fillStyle = options.backgroundColor;\n        ctx.strokeStyle = options.borderColor;\n        drawArc(ctx, this, radiusOffset, spacing, circular);\n        drawBorder(ctx, this, radiusOffset, spacing, circular);\n        ctx.restore();\n      }\n    }]);\n    return ArcElement;\n  }(Element);\n  _defineProperty$w(ArcElement, \"id\", 'arc');\n  _defineProperty$w(ArcElement, \"defaults\", {\n    borderAlign: 'center',\n    borderColor: '#fff',\n    borderJoinStyle: undefined,\n    borderRadius: 0,\n    borderWidth: 2,\n    offset: 0,\n    spacing: 0,\n    angle: undefined,\n    circular: true\n  });\n  _defineProperty$w(ArcElement, \"defaultRoutes\", {\n    backgroundColor: 'backgroundColor'\n  });\n  function setStyle(ctx, options) {\n    var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : options;\n    ctx.lineCap = valueOrDefault(style.borderCapStyle, options.borderCapStyle);\n    ctx.setLineDash(valueOrDefault(style.borderDash, options.borderDash));\n    ctx.lineDashOffset = valueOrDefault(style.borderDashOffset, options.borderDashOffset);\n    ctx.lineJoin = valueOrDefault(style.borderJoinStyle, options.borderJoinStyle);\n    ctx.lineWidth = valueOrDefault(style.borderWidth, options.borderWidth);\n    ctx.strokeStyle = valueOrDefault(style.borderColor, options.borderColor);\n  }\n  function lineTo(ctx, previous, target) {\n    ctx.lineTo(target.x, target.y);\n  }\n  function getLineMethod(options) {\n    if (options.stepped) {\n      return _steppedLineTo;\n    }\n    if (options.tension || options.cubicInterpolationMode === 'monotone') {\n      return _bezierCurveTo;\n    }\n    return lineTo;\n  }\n  function pathVars(points, segment) {\n    var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n    var count = points.length;\n    var _params$start = params.start,\n      paramsStart = _params$start === void 0 ? 0 : _params$start,\n      _params$end = params.end,\n      paramsEnd = _params$end === void 0 ? count - 1 : _params$end;\n    var segmentStart = segment.start,\n      segmentEnd = segment.end;\n    var start = Math.max(paramsStart, segmentStart);\n    var end = Math.min(paramsEnd, segmentEnd);\n    var outside = paramsStart < segmentStart && paramsEnd < segmentStart || paramsStart > segmentEnd && paramsEnd > segmentEnd;\n    return {\n      count: count,\n      start: start,\n      loop: segment.loop,\n      ilen: end < start && !outside ? count + end - start : end - start\n    };\n  }\n  function pathSegment(ctx, line, segment, params) {\n    var points = line.points,\n      options = line.options;\n    var _pathVars = pathVars(points, segment, params),\n      count = _pathVars.count,\n      start = _pathVars.start,\n      loop = _pathVars.loop,\n      ilen = _pathVars.ilen;\n    var lineMethod = getLineMethod(options);\n    var _ref5 = params || {},\n      _ref5$move = _ref5.move,\n      move = _ref5$move === void 0 ? true : _ref5$move,\n      reverse = _ref5.reverse;\n    var i, point, prev;\n    for (i = 0; i <= ilen; ++i) {\n      point = points[(start + (reverse ? ilen - i : i)) % count];\n      if (point.skip) {\n        continue;\n      } else if (move) {\n        ctx.moveTo(point.x, point.y);\n        move = false;\n      } else {\n        lineMethod(ctx, prev, point, reverse, options.stepped);\n      }\n      prev = point;\n    }\n    if (loop) {\n      point = points[(start + (reverse ? ilen : 0)) % count];\n      lineMethod(ctx, prev, point, reverse, options.stepped);\n    }\n    return !!loop;\n  }\n  function fastPathSegment(ctx, line, segment, params) {\n    var points = line.points;\n    var _pathVars2 = pathVars(points, segment, params),\n      count = _pathVars2.count,\n      start = _pathVars2.start,\n      ilen = _pathVars2.ilen;\n    var _ref6 = params || {},\n      _ref6$move = _ref6.move,\n      move = _ref6$move === void 0 ? true : _ref6$move,\n      reverse = _ref6.reverse;\n    var avgX = 0;\n    var countX = 0;\n    var i, point, prevX, minY, maxY, lastY;\n    var pointIndex = function pointIndex(index) {\n      return (start + (reverse ? ilen - index : index)) % count;\n    };\n    var drawX = function drawX() {\n      if (minY !== maxY) {\n        ctx.lineTo(avgX, maxY);\n        ctx.lineTo(avgX, minY);\n        ctx.lineTo(avgX, lastY);\n      }\n    };\n    if (move) {\n      point = points[pointIndex(0)];\n      ctx.moveTo(point.x, point.y);\n    }\n    for (i = 0; i <= ilen; ++i) {\n      point = points[pointIndex(i)];\n      if (point.skip) {\n        continue;\n      }\n      var x = point.x;\n      var y = point.y;\n      var truncX = x | 0;\n      if (truncX === prevX) {\n        if (y < minY) {\n          minY = y;\n        } else if (y > maxY) {\n          maxY = y;\n        }\n        avgX = (countX * avgX + x) / ++countX;\n      } else {\n        drawX();\n        ctx.lineTo(x, y);\n        prevX = truncX;\n        countX = 0;\n        minY = maxY = y;\n      }\n      lastY = y;\n    }\n    drawX();\n  }\n  function _getSegmentMethod(line) {\n    var opts = line.options;\n    var borderDash = opts.borderDash && opts.borderDash.length;\n    var useFastPath = !line._decimated && !line._loop && !opts.tension && opts.cubicInterpolationMode !== 'monotone' && !opts.stepped && !borderDash;\n    return useFastPath ? fastPathSegment : pathSegment;\n  }\n  function _getInterpolationMethod(options) {\n    if (options.stepped) {\n      return _steppedInterpolation;\n    }\n    if (options.tension || options.cubicInterpolationMode === 'monotone') {\n      return _bezierInterpolation;\n    }\n    return _pointInLine;\n  }\n  function strokePathWithCache(ctx, line, start, count) {\n    var path = line._path;\n    if (!path) {\n      path = line._path = new Path2D();\n      if (line.path(path, start, count)) {\n        path.closePath();\n      }\n    }\n    setStyle(ctx, line.options);\n    ctx.stroke(path);\n  }\n  function strokePathDirect(ctx, line, start, count) {\n    var segments = line.segments,\n      options = line.options;\n    var segmentMethod = _getSegmentMethod(line);\n    var _iterator16 = _createForOfIteratorHelper$1(segments),\n      _step16;\n    try {\n      for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {\n        var segment = _step16.value;\n        setStyle(ctx, options, segment.style);\n        ctx.beginPath();\n        if (segmentMethod(ctx, line, segment, {\n          start: start,\n          end: start + count - 1\n        })) {\n          ctx.closePath();\n        }\n        ctx.stroke();\n      }\n    } catch (err) {\n      _iterator16.e(err);\n    } finally {\n      _iterator16.f();\n    }\n  }\n  var usePath2D = typeof Path2D === 'function';\n  function _draw(ctx, line, start, count) {\n    if (usePath2D && !line.options.segment) {\n      strokePathWithCache(ctx, line, start, count);\n    } else {\n      strokePathDirect(ctx, line, start, count);\n    }\n  }\n  var LineElement = /*#__PURE__*/function (_Element3) {\n    _inherits$w(LineElement, _Element3);\n    var _super13 = _createSuper$w(LineElement);\n    function LineElement(cfg) {\n      var _this24;\n      _classCallCheck$x(this, LineElement);\n      _this24 = _super13.call(this);\n      _this24.animated = true;\n      _this24.options = undefined;\n      _this24._chart = undefined;\n      _this24._loop = undefined;\n      _this24._fullLoop = undefined;\n      _this24._path = undefined;\n      _this24._points = undefined;\n      _this24._segments = undefined;\n      _this24._decimated = false;\n      _this24._pointsUpdated = false;\n      _this24._datasetIndex = undefined;\n      if (cfg) {\n        Object.assign(_assertThisInitialized$w(_this24), cfg);\n      }\n      return _this24;\n    }\n    _createClass$x(LineElement, [{\n      key: \"updateControlPoints\",\n      value: function updateControlPoints(chartArea, indexAxis) {\n        var options = this.options;\n        if ((options.tension || options.cubicInterpolationMode === 'monotone') && !options.stepped && !this._pointsUpdated) {\n          var loop = options.spanGaps ? this._loop : this._fullLoop;\n          _updateBezierControlPoints(this._points, options, chartArea, loop, indexAxis);\n          this._pointsUpdated = true;\n        }\n      }\n    }, {\n      key: \"points\",\n      get: function get() {\n        return this._points;\n      },\n      set: function set(points) {\n        this._points = points;\n        delete this._segments;\n        delete this._path;\n        this._pointsUpdated = false;\n      }\n    }, {\n      key: \"segments\",\n      get: function get() {\n        return this._segments || (this._segments = _computeSegments(this, this.options.segment));\n      }\n    }, {\n      key: \"first\",\n      value: function first() {\n        var segments = this.segments;\n        var points = this.points;\n        return segments.length && points[segments[0].start];\n      }\n    }, {\n      key: \"last\",\n      value: function last() {\n        var segments = this.segments;\n        var points = this.points;\n        var count = segments.length;\n        return count && points[segments[count - 1].end];\n      }\n    }, {\n      key: \"interpolate\",\n      value: function interpolate(point, property) {\n        var options = this.options;\n        var value = point[property];\n        var points = this.points;\n        var segments = _boundSegments(this, {\n          property: property,\n          start: value,\n          end: value\n        });\n        if (!segments.length) {\n          return;\n        }\n        var result = [];\n        var _interpolate = _getInterpolationMethod(options);\n        var i, ilen;\n        for (i = 0, ilen = segments.length; i < ilen; ++i) {\n          var _segments$i = segments[i],\n            start = _segments$i.start,\n            end = _segments$i.end;\n          var p1 = points[start];\n          var p2 = points[end];\n          if (p1 === p2) {\n            result.push(p1);\n            continue;\n          }\n          var t = Math.abs((value - p1[property]) / (p2[property] - p1[property]));\n          var interpolated = _interpolate(p1, p2, t, options.stepped);\n          interpolated[property] = point[property];\n          result.push(interpolated);\n        }\n        return result.length === 1 ? result[0] : result;\n      }\n    }, {\n      key: \"pathSegment\",\n      value: function pathSegment(ctx, segment, params) {\n        var segmentMethod = _getSegmentMethod(this);\n        return segmentMethod(ctx, this, segment, params);\n      }\n    }, {\n      key: \"path\",\n      value: function path(ctx, start, count) {\n        var segments = this.segments;\n        var segmentMethod = _getSegmentMethod(this);\n        var loop = this._loop;\n        start = start || 0;\n        count = count || this.points.length - start;\n        var _iterator17 = _createForOfIteratorHelper$1(segments),\n          _step17;\n        try {\n          for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {\n            var segment = _step17.value;\n            loop &= segmentMethod(ctx, this, segment, {\n              start: start,\n              end: start + count - 1\n            });\n          }\n        } catch (err) {\n          _iterator17.e(err);\n        } finally {\n          _iterator17.f();\n        }\n        return !!loop;\n      }\n    }, {\n      key: \"draw\",\n      value: function draw(ctx, chartArea, start, count) {\n        var options = this.options || {};\n        var points = this.points || [];\n        if (points.length && options.borderWidth) {\n          ctx.save();\n          _draw(ctx, this, start, count);\n          ctx.restore();\n        }\n        if (this.animated) {\n          this._pointsUpdated = false;\n          this._path = undefined;\n        }\n      }\n    }]);\n    return LineElement;\n  }(Element);\n  _defineProperty$w(LineElement, \"id\", 'line');\n  _defineProperty$w(LineElement, \"defaults\", {\n    borderCapStyle: 'butt',\n    borderDash: [],\n    borderDashOffset: 0,\n    borderJoinStyle: 'miter',\n    borderWidth: 3,\n    capBezierPoints: true,\n    cubicInterpolationMode: 'default',\n    fill: false,\n    spanGaps: false,\n    stepped: false,\n    tension: 0\n  });\n  _defineProperty$w(LineElement, \"defaultRoutes\", {\n    backgroundColor: 'backgroundColor',\n    borderColor: 'borderColor'\n  });\n  _defineProperty$w(LineElement, \"descriptors\", {\n    _scriptable: true,\n    _indexable: function _indexable(name) {\n      return name !== 'borderDash' && name !== 'fill';\n    }\n  });\n  function inRange$1(el, pos, axis, useFinalPosition) {\n    var options = el.options;\n    var _el$getProps = el.getProps([axis], useFinalPosition),\n      value = _el$getProps[axis];\n    return Math.abs(pos - value) < options.radius + options.hitRadius;\n  }\n  var PointElement = /*#__PURE__*/function (_Element4) {\n    _inherits$w(PointElement, _Element4);\n    var _super14 = _createSuper$w(PointElement);\n    /**\n    * @type {any}\n    */\n\n    /**\n    * @type {any}\n    */\n\n    function PointElement(cfg) {\n      var _this25;\n      _classCallCheck$x(this, PointElement);\n      _this25 = _super14.call(this);\n      _this25.options = undefined;\n      _this25.parsed = undefined;\n      _this25.skip = undefined;\n      _this25.stop = undefined;\n      if (cfg) {\n        Object.assign(_assertThisInitialized$w(_this25), cfg);\n      }\n      return _this25;\n    }\n    _createClass$x(PointElement, [{\n      key: \"inRange\",\n      value: function inRange(mouseX, mouseY, useFinalPosition) {\n        var options = this.options;\n        var _this$getProps4 = this.getProps(['x', 'y'], useFinalPosition),\n          x = _this$getProps4.x,\n          y = _this$getProps4.y;\n        return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2);\n      }\n    }, {\n      key: \"inXRange\",\n      value: function inXRange(mouseX, useFinalPosition) {\n        return inRange$1(this, mouseX, 'x', useFinalPosition);\n      }\n    }, {\n      key: \"inYRange\",\n      value: function inYRange(mouseY, useFinalPosition) {\n        return inRange$1(this, mouseY, 'y', useFinalPosition);\n      }\n    }, {\n      key: \"getCenterPoint\",\n      value: function getCenterPoint(useFinalPosition) {\n        var _this$getProps5 = this.getProps(['x', 'y'], useFinalPosition),\n          x = _this$getProps5.x,\n          y = _this$getProps5.y;\n        return {\n          x: x,\n          y: y\n        };\n      }\n    }, {\n      key: \"size\",\n      value: function size(options) {\n        options = options || this.options || {};\n        var radius = options.radius || 0;\n        radius = Math.max(radius, radius && options.hoverRadius || 0);\n        var borderWidth = radius && options.borderWidth || 0;\n        return (radius + borderWidth) * 2;\n      }\n    }, {\n      key: \"draw\",\n      value: function draw(ctx, area) {\n        var options = this.options;\n        if (this.skip || options.radius < 0.1 || !_isPointInArea(this, area, this.size(options) / 2)) {\n          return;\n        }\n        ctx.strokeStyle = options.borderColor;\n        ctx.lineWidth = options.borderWidth;\n        ctx.fillStyle = options.backgroundColor;\n        drawPoint(ctx, options, this.x, this.y);\n      }\n    }, {\n      key: \"getRange\",\n      value: function getRange() {\n        var options = this.options || {};\n        // @ts-expect-error Fallbacks should never be hit in practice\n        return options.radius + options.hitRadius;\n      }\n    }]);\n    return PointElement;\n  }(Element);\n  _defineProperty$w(PointElement, \"id\", 'point');\n  _defineProperty$w(PointElement, \"defaults\", {\n    borderWidth: 1,\n    hitRadius: 1,\n    hoverBorderWidth: 1,\n    hoverRadius: 4,\n    pointStyle: 'circle',\n    radius: 3,\n    rotation: 0\n  });\n  _defineProperty$w(PointElement, \"defaultRoutes\", {\n    backgroundColor: 'backgroundColor',\n    borderColor: 'borderColor'\n  });\n  function getBarBounds(bar, useFinalPosition) {\n    var _bar$getProps = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition),\n      x = _bar$getProps.x,\n      y = _bar$getProps.y,\n      base = _bar$getProps.base,\n      width = _bar$getProps.width,\n      height = _bar$getProps.height;\n    var left, right, top, bottom, half;\n    if (bar.horizontal) {\n      half = height / 2;\n      left = Math.min(x, base);\n      right = Math.max(x, base);\n      top = y - half;\n      bottom = y + half;\n    } else {\n      half = width / 2;\n      left = x - half;\n      right = x + half;\n      top = Math.min(y, base);\n      bottom = Math.max(y, base);\n    }\n    return {\n      left: left,\n      top: top,\n      right: right,\n      bottom: bottom\n    };\n  }\n  function skipOrLimit(skip, value, min, max) {\n    return skip ? 0 : _limitValue(value, min, max);\n  }\n  function parseBorderWidth(bar, maxW, maxH) {\n    var value = bar.options.borderWidth;\n    var skip = bar.borderSkipped;\n    var o = toTRBL(value);\n    return {\n      t: skipOrLimit(skip.top, o.top, 0, maxH),\n      r: skipOrLimit(skip.right, o.right, 0, maxW),\n      b: skipOrLimit(skip.bottom, o.bottom, 0, maxH),\n      l: skipOrLimit(skip.left, o.left, 0, maxW)\n    };\n  }\n  function parseBorderRadius(bar, maxW, maxH) {\n    var _bar$getProps2 = bar.getProps(['enableBorderRadius']),\n      enableBorderRadius = _bar$getProps2.enableBorderRadius;\n    var value = bar.options.borderRadius;\n    var o = toTRBLCorners(value);\n    var maxR = Math.min(maxW, maxH);\n    var skip = bar.borderSkipped;\n    var enableBorder = enableBorderRadius || isObject(value);\n    return {\n      topLeft: skipOrLimit(!enableBorder || skip.top || skip.left, o.topLeft, 0, maxR),\n      topRight: skipOrLimit(!enableBorder || skip.top || skip.right, o.topRight, 0, maxR),\n      bottomLeft: skipOrLimit(!enableBorder || skip.bottom || skip.left, o.bottomLeft, 0, maxR),\n      bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)\n    };\n  }\n  function boundingRects(bar) {\n    var bounds = getBarBounds(bar);\n    var width = bounds.right - bounds.left;\n    var height = bounds.bottom - bounds.top;\n    var border = parseBorderWidth(bar, width / 2, height / 2);\n    var radius = parseBorderRadius(bar, width / 2, height / 2);\n    return {\n      outer: {\n        x: bounds.left,\n        y: bounds.top,\n        w: width,\n        h: height,\n        radius: radius\n      },\n      inner: {\n        x: bounds.left + border.l,\n        y: bounds.top + border.t,\n        w: width - border.l - border.r,\n        h: height - border.t - border.b,\n        radius: {\n          topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),\n          topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),\n          bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),\n          bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r))\n        }\n      }\n    };\n  }\n  function _inRange(bar, x, y, useFinalPosition) {\n    var skipX = x === null;\n    var skipY = y === null;\n    var skipBoth = skipX && skipY;\n    var bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition);\n    return bounds && (skipX || _isBetween(x, bounds.left, bounds.right)) && (skipY || _isBetween(y, bounds.top, bounds.bottom));\n  }\n  function hasRadius(radius) {\n    return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight;\n  }\n  function addNormalRectPath(ctx, rect) {\n    ctx.rect(rect.x, rect.y, rect.w, rect.h);\n  }\n  function inflateRect(rect, amount) {\n    var refRect = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n    var x = rect.x !== refRect.x ? -amount : 0;\n    var y = rect.y !== refRect.y ? -amount : 0;\n    var w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x;\n    var h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y;\n    return {\n      x: rect.x + x,\n      y: rect.y + y,\n      w: rect.w + w,\n      h: rect.h + h,\n      radius: rect.radius\n    };\n  }\n  var BarElement = /*#__PURE__*/function (_Element5) {\n    _inherits$w(BarElement, _Element5);\n    var _super15 = _createSuper$w(BarElement);\n    function BarElement(cfg) {\n      var _this26;\n      _classCallCheck$x(this, BarElement);\n      _this26 = _super15.call(this);\n      _this26.options = undefined;\n      _this26.horizontal = undefined;\n      _this26.base = undefined;\n      _this26.width = undefined;\n      _this26.height = undefined;\n      _this26.inflateAmount = undefined;\n      if (cfg) {\n        Object.assign(_assertThisInitialized$w(_this26), cfg);\n      }\n      return _this26;\n    }\n    _createClass$x(BarElement, [{\n      key: \"draw\",\n      value: function draw(ctx) {\n        var inflateAmount = this.inflateAmount,\n          _this$options14 = this.options,\n          borderColor = _this$options14.borderColor,\n          backgroundColor = _this$options14.backgroundColor;\n        var _boundingRects = boundingRects(this),\n          inner = _boundingRects.inner,\n          outer = _boundingRects.outer;\n        var addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;\n        ctx.save();\n        if (outer.w !== inner.w || outer.h !== inner.h) {\n          ctx.beginPath();\n          addRectPath(ctx, inflateRect(outer, inflateAmount, inner));\n          ctx.clip();\n          addRectPath(ctx, inflateRect(inner, -inflateAmount, outer));\n          ctx.fillStyle = borderColor;\n          ctx.fill('evenodd');\n        }\n        ctx.beginPath();\n        addRectPath(ctx, inflateRect(inner, inflateAmount));\n        ctx.fillStyle = backgroundColor;\n        ctx.fill();\n        ctx.restore();\n      }\n    }, {\n      key: \"inRange\",\n      value: function inRange(mouseX, mouseY, useFinalPosition) {\n        return _inRange(this, mouseX, mouseY, useFinalPosition);\n      }\n    }, {\n      key: \"inXRange\",\n      value: function inXRange(mouseX, useFinalPosition) {\n        return _inRange(this, mouseX, null, useFinalPosition);\n      }\n    }, {\n      key: \"inYRange\",\n      value: function inYRange(mouseY, useFinalPosition) {\n        return _inRange(this, null, mouseY, useFinalPosition);\n      }\n    }, {\n      key: \"getCenterPoint\",\n      value: function getCenterPoint(useFinalPosition) {\n        var _this$getProps6 = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition),\n          x = _this$getProps6.x,\n          y = _this$getProps6.y,\n          base = _this$getProps6.base,\n          horizontal = _this$getProps6.horizontal;\n        return {\n          x: horizontal ? (x + base) / 2 : x,\n          y: horizontal ? y : (y + base) / 2\n        };\n      }\n    }, {\n      key: \"getRange\",\n      value: function getRange(axis) {\n        return axis === 'x' ? this.width / 2 : this.height / 2;\n      }\n    }]);\n    return BarElement;\n  }(Element);\n  _defineProperty$w(BarElement, \"id\", 'bar');\n  _defineProperty$w(BarElement, \"defaults\", {\n    borderSkipped: 'start',\n    borderWidth: 0,\n    borderRadius: 0,\n    inflateAmount: 'auto',\n    pointStyle: undefined\n  });\n  _defineProperty$w(BarElement, \"defaultRoutes\", {\n    backgroundColor: 'backgroundColor',\n    borderColor: 'borderColor'\n  });\n  var elements = /*#__PURE__*/Object.freeze({\n    __proto__: null,\n    ArcElement: ArcElement,\n    LineElement: LineElement,\n    PointElement: PointElement,\n    BarElement: BarElement\n  });\n  var BORDER_COLORS = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' // grey\n  ];\n  // Border colors with 50% transparency\n  var BACKGROUND_COLORS = /* #__PURE__ */BORDER_COLORS.map(function (color) {\n    return color.replace('rgb(', 'rgba(').replace(')', ', 0.5)');\n  });\n  function getBorderColor(i) {\n    return BORDER_COLORS[i % BORDER_COLORS.length];\n  }\n  function getBackgroundColor(i) {\n    return BACKGROUND_COLORS[i % BACKGROUND_COLORS.length];\n  }\n  function colorizeDefaultDataset(dataset, i) {\n    dataset.borderColor = getBorderColor(i);\n    dataset.backgroundColor = getBackgroundColor(i);\n    return ++i;\n  }\n  function colorizeDoughnutDataset(dataset, i) {\n    dataset.backgroundColor = dataset.data.map(function () {\n      return getBorderColor(i++);\n    });\n    return i;\n  }\n  function colorizePolarAreaDataset(dataset, i) {\n    dataset.backgroundColor = dataset.data.map(function () {\n      return getBackgroundColor(i++);\n    });\n    return i;\n  }\n  function getColorizer(chart) {\n    var i = 0;\n    return function (dataset, datasetIndex) {\n      var controller = chart.getDatasetMeta(datasetIndex).controller;\n      if (controller instanceof DoughnutController) {\n        i = colorizeDoughnutDataset(dataset, i);\n      } else if (controller instanceof PolarAreaController) {\n        i = colorizePolarAreaDataset(dataset, i);\n      } else if (controller) {\n        i = colorizeDefaultDataset(dataset, i);\n      }\n    };\n  }\n  function containsColorsDefinitions(descriptors) {\n    var k;\n    for (k in descriptors) {\n      if (descriptors[k].borderColor || descriptors[k].backgroundColor) {\n        return true;\n      }\n    }\n    return false;\n  }\n  function containsColorsDefinition(descriptor) {\n    return descriptor && (descriptor.borderColor || descriptor.backgroundColor);\n  }\n  var plugin_colors = {\n    id: 'colors',\n    defaults: {\n      enabled: true,\n      forceOverride: false\n    },\n    beforeLayout: function beforeLayout(chart, _args, options) {\n      if (!options.enabled) {\n        return;\n      }\n      var _chart$config = chart.config,\n        datasets = _chart$config.data.datasets,\n        chartOptions = _chart$config.options;\n      var elements = chartOptions.elements;\n      if (!options.forceOverride && (containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || elements && containsColorsDefinitions(elements))) {\n        return;\n      }\n      var colorizer = getColorizer(chart);\n      datasets.forEach(colorizer);\n    }\n  };\n  function lttbDecimation(data, start, count, availableWidth, options) {\n    var samples = options.samples || availableWidth;\n    if (samples >= count) {\n      return data.slice(start, start + count);\n    }\n    var decimated = [];\n    var bucketWidth = (count - 2) / (samples - 2);\n    var sampledIndex = 0;\n    var endIndex = start + count - 1;\n    var a = start;\n    var i, maxAreaPoint, maxArea, area, nextA;\n    decimated[sampledIndex++] = data[a];\n    for (i = 0; i < samples - 2; i++) {\n      var avgX = 0;\n      var avgY = 0;\n      var j = void 0;\n      var avgRangeStart = Math.floor((i + 1) * bucketWidth) + 1 + start;\n      var avgRangeEnd = Math.min(Math.floor((i + 2) * bucketWidth) + 1, count) + start;\n      var avgRangeLength = avgRangeEnd - avgRangeStart;\n      for (j = avgRangeStart; j < avgRangeEnd; j++) {\n        avgX += data[j].x;\n        avgY += data[j].y;\n      }\n      avgX /= avgRangeLength;\n      avgY /= avgRangeLength;\n      var rangeOffs = Math.floor(i * bucketWidth) + 1 + start;\n      var rangeTo = Math.min(Math.floor((i + 1) * bucketWidth) + 1, count) + start;\n      var _data$a = data[a],\n        pointAx = _data$a.x,\n        pointAy = _data$a.y;\n      maxArea = area = -1;\n      for (j = rangeOffs; j < rangeTo; j++) {\n        area = 0.5 * Math.abs((pointAx - avgX) * (data[j].y - pointAy) - (pointAx - data[j].x) * (avgY - pointAy));\n        if (area > maxArea) {\n          maxArea = area;\n          maxAreaPoint = data[j];\n          nextA = j;\n        }\n      }\n      decimated[sampledIndex++] = maxAreaPoint;\n      a = nextA;\n    }\n    decimated[sampledIndex++] = data[endIndex];\n    return decimated;\n  }\n  function minMaxDecimation(data, start, count, availableWidth) {\n    var avgX = 0;\n    var countX = 0;\n    var i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;\n    var decimated = [];\n    var endIndex = start + count - 1;\n    var xMin = data[start].x;\n    var xMax = data[endIndex].x;\n    var dx = xMax - xMin;\n    for (i = start; i < start + count; ++i) {\n      point = data[i];\n      x = (point.x - xMin) / dx * availableWidth;\n      y = point.y;\n      var truncX = x | 0;\n      if (truncX === prevX) {\n        if (y < minY) {\n          minY = y;\n          minIndex = i;\n        } else if (y > maxY) {\n          maxY = y;\n          maxIndex = i;\n        }\n        avgX = (countX * avgX + point.x) / ++countX;\n      } else {\n        var lastIndex = i - 1;\n        if (!isNullOrUndef(minIndex) && !isNullOrUndef(maxIndex)) {\n          var intermediateIndex1 = Math.min(minIndex, maxIndex);\n          var intermediateIndex2 = Math.max(minIndex, maxIndex);\n          if (intermediateIndex1 !== startIndex && intermediateIndex1 !== lastIndex) {\n            decimated.push(_objectSpread2(_objectSpread2({}, data[intermediateIndex1]), {}, {\n              x: avgX\n            }));\n          }\n          if (intermediateIndex2 !== startIndex && intermediateIndex2 !== lastIndex) {\n            decimated.push(_objectSpread2(_objectSpread2({}, data[intermediateIndex2]), {}, {\n              x: avgX\n            }));\n          }\n        }\n        if (i > 0 && lastIndex !== startIndex) {\n          decimated.push(data[lastIndex]);\n        }\n        decimated.push(point);\n        prevX = truncX;\n        countX = 0;\n        minY = maxY = y;\n        minIndex = maxIndex = startIndex = i;\n      }\n    }\n    return decimated;\n  }\n  function cleanDecimatedDataset(dataset) {\n    if (dataset._decimated) {\n      var data = dataset._data;\n      delete dataset._decimated;\n      delete dataset._data;\n      Object.defineProperty(dataset, 'data', {\n        value: data\n      });\n    }\n  }\n  function cleanDecimatedData(chart) {\n    chart.data.datasets.forEach(function (dataset) {\n      cleanDecimatedDataset(dataset);\n    });\n  }\n  function getStartAndCountOfVisiblePointsSimplified(meta, points) {\n    var pointCount = points.length;\n    var start = 0;\n    var count;\n    var iScale = meta.iScale;\n    var _iScale$getUserBounds = iScale.getUserBounds(),\n      min = _iScale$getUserBounds.min,\n      max = _iScale$getUserBounds.max,\n      minDefined = _iScale$getUserBounds.minDefined,\n      maxDefined = _iScale$getUserBounds.maxDefined;\n    if (minDefined) {\n      start = _limitValue(_lookupByKey(points, iScale.axis, min).lo, 0, pointCount - 1);\n    }\n    if (maxDefined) {\n      count = _limitValue(_lookupByKey(points, iScale.axis, max).hi + 1, start, pointCount) - start;\n    } else {\n      count = pointCount - start;\n    }\n    return {\n      start: start,\n      count: count\n    };\n  }\n  var plugin_decimation = {\n    id: 'decimation',\n    defaults: {\n      algorithm: 'min-max',\n      enabled: false\n    },\n    beforeElementsUpdate: function beforeElementsUpdate(chart, args, options) {\n      if (!options.enabled) {\n        cleanDecimatedData(chart);\n        return;\n      }\n      var availableWidth = chart.width;\n      chart.data.datasets.forEach(function (dataset, datasetIndex) {\n        var _data = dataset._data,\n          indexAxis = dataset.indexAxis;\n        var meta = chart.getDatasetMeta(datasetIndex);\n        var data = _data || dataset.data;\n        if (resolve([indexAxis, chart.options.indexAxis]) === 'y') {\n          return;\n        }\n        if (!meta.controller.supportsDecimation) {\n          return;\n        }\n        var xAxis = chart.scales[meta.xAxisID];\n        if (xAxis.type !== 'linear' && xAxis.type !== 'time') {\n          return;\n        }\n        if (chart.options.parsing) {\n          return;\n        }\n        var _getStartAndCountOfVi3 = getStartAndCountOfVisiblePointsSimplified(meta, data),\n          start = _getStartAndCountOfVi3.start,\n          count = _getStartAndCountOfVi3.count;\n        var threshold = options.threshold || 4 * availableWidth;\n        if (count <= threshold) {\n          cleanDecimatedDataset(dataset);\n          return;\n        }\n        if (isNullOrUndef(_data)) {\n          dataset._data = data;\n          delete dataset.data;\n          Object.defineProperty(dataset, 'data', {\n            configurable: true,\n            enumerable: true,\n            get: function get() {\n              return this._decimated;\n            },\n            set: function set(d) {\n              this._data = d;\n            }\n          });\n        }\n        var decimated;\n        switch (options.algorithm) {\n          case 'lttb':\n            decimated = lttbDecimation(data, start, count, availableWidth, options);\n            break;\n          case 'min-max':\n            decimated = minMaxDecimation(data, start, count, availableWidth);\n            break;\n          default:\n            throw new Error(\"Unsupported decimation algorithm '\".concat(options.algorithm, \"'\"));\n        }\n        dataset._decimated = decimated;\n      });\n    },\n    destroy: function destroy(chart) {\n      cleanDecimatedData(chart);\n    }\n  };\n  function _segments(line, target, property) {\n    var segments = line.segments;\n    var points = line.points;\n    var tpoints = target.points;\n    var parts = [];\n    var _iterator18 = _createForOfIteratorHelper$1(segments),\n      _step18;\n    try {\n      for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {\n        var segment = _step18.value;\n        var start = segment.start,\n          end = segment.end;\n        end = _findSegmentEnd(start, end, points);\n        var bounds = _getBounds(property, points[start], points[end], segment.loop);\n        if (!target.segments) {\n          parts.push({\n            source: segment,\n            target: bounds,\n            start: points[start],\n            end: points[end]\n          });\n          continue;\n        }\n        var targetSegments = _boundSegments(target, bounds);\n        var _iterator19 = _createForOfIteratorHelper$1(targetSegments),\n          _step19;\n        try {\n          for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {\n            var tgt = _step19.value;\n            var subBounds = _getBounds(property, tpoints[tgt.start], tpoints[tgt.end], tgt.loop);\n            var fillSources = _boundSegment(segment, points, subBounds);\n            var _iterator20 = _createForOfIteratorHelper$1(fillSources),\n              _step20;\n            try {\n              for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {\n                var fillSource = _step20.value;\n                parts.push({\n                  source: fillSource,\n                  target: tgt,\n                  start: _defineProperty$w({}, property, _getEdge(bounds, subBounds, 'start', Math.max)),\n                  end: _defineProperty$w({}, property, _getEdge(bounds, subBounds, 'end', Math.min))\n                });\n              }\n            } catch (err) {\n              _iterator20.e(err);\n            } finally {\n              _iterator20.f();\n            }\n          }\n        } catch (err) {\n          _iterator19.e(err);\n        } finally {\n          _iterator19.f();\n        }\n      }\n    } catch (err) {\n      _iterator18.e(err);\n    } finally {\n      _iterator18.f();\n    }\n    return parts;\n  }\n  function _getBounds(property, first, last, loop) {\n    if (loop) {\n      return;\n    }\n    var start = first[property];\n    var end = last[property];\n    if (property === 'angle') {\n      start = _normalizeAngle(start);\n      end = _normalizeAngle(end);\n    }\n    return {\n      property: property,\n      start: start,\n      end: end\n    };\n  }\n  function _pointsFromSegments(boundary, line) {\n    var _ref7 = boundary || {},\n      _ref7$x = _ref7.x,\n      x = _ref7$x === void 0 ? null : _ref7$x,\n      _ref7$y = _ref7.y,\n      y = _ref7$y === void 0 ? null : _ref7$y;\n    var linePoints = line.points;\n    var points = [];\n    line.segments.forEach(function (_ref8) {\n      var start = _ref8.start,\n        end = _ref8.end;\n      end = _findSegmentEnd(start, end, linePoints);\n      var first = linePoints[start];\n      var last = linePoints[end];\n      if (y !== null) {\n        points.push({\n          x: first.x,\n          y: y\n        });\n        points.push({\n          x: last.x,\n          y: y\n        });\n      } else if (x !== null) {\n        points.push({\n          x: x,\n          y: first.y\n        });\n        points.push({\n          x: x,\n          y: last.y\n        });\n      }\n    });\n    return points;\n  }\n  function _findSegmentEnd(start, end, points) {\n    for (; end > start; end--) {\n      var point = points[end];\n      if (!isNaN(point.x) && !isNaN(point.y)) {\n        break;\n      }\n    }\n    return end;\n  }\n  function _getEdge(a, b, prop, fn) {\n    if (a && b) {\n      return fn(a[prop], b[prop]);\n    }\n    return a ? a[prop] : b ? b[prop] : 0;\n  }\n  function _createBoundaryLine(boundary, line) {\n    var points = [];\n    var _loop = false;\n    if (isArray(boundary)) {\n      _loop = true;\n      points = boundary;\n    } else {\n      points = _pointsFromSegments(boundary, line);\n    }\n    return points.length ? new LineElement({\n      points: points,\n      options: {\n        tension: 0\n      },\n      _loop: _loop,\n      _fullLoop: _loop\n    }) : null;\n  }\n  function _shouldApplyFill(source) {\n    return source && source.fill !== false;\n  }\n  function _resolveTarget(sources, index, propagate) {\n    var source = sources[index];\n    var fill = source.fill;\n    var visited = [index];\n    var target;\n    if (!propagate) {\n      return fill;\n    }\n    while (fill !== false && visited.indexOf(fill) === -1) {\n      if (!isNumberFinite(fill)) {\n        return fill;\n      }\n      target = sources[fill];\n      if (!target) {\n        return false;\n      }\n      if (target.visible) {\n        return fill;\n      }\n      visited.push(fill);\n      fill = target.fill;\n    }\n    return false;\n  }\n  function _decodeFill(line, index, count) {\n    var fill = parseFillOption(line);\n    if (isObject(fill)) {\n      return isNaN(fill.value) ? false : fill;\n    }\n    var target = parseFloat(fill);\n    if (isNumberFinite(target) && Math.floor(target) === target) {\n      return decodeTargetIndex(fill[0], index, target, count);\n    }\n    return ['origin', 'start', 'end', 'stack', 'shape'].indexOf(fill) >= 0 && fill;\n  }\n  function decodeTargetIndex(firstCh, index, target, count) {\n    if (firstCh === '-' || firstCh === '+') {\n      target = index + target;\n    }\n    if (target === index || target < 0 || target >= count) {\n      return false;\n    }\n    return target;\n  }\n  function _getTargetPixel(fill, scale) {\n    var pixel = null;\n    if (fill === 'start') {\n      pixel = scale.bottom;\n    } else if (fill === 'end') {\n      pixel = scale.top;\n    } else if (isObject(fill)) {\n      pixel = scale.getPixelForValue(fill.value);\n    } else if (scale.getBasePixel) {\n      pixel = scale.getBasePixel();\n    }\n    return pixel;\n  }\n  function _getTargetValue(fill, scale, startValue) {\n    var value;\n    if (fill === 'start') {\n      value = startValue;\n    } else if (fill === 'end') {\n      value = scale.options.reverse ? scale.min : scale.max;\n    } else if (isObject(fill)) {\n      value = fill.value;\n    } else {\n      value = scale.getBaseValue();\n    }\n    return value;\n  }\n  function parseFillOption(line) {\n    var options = line.options;\n    var fillOption = options.fill;\n    var fill = valueOrDefault(fillOption && fillOption.target, fillOption);\n    if (fill === undefined) {\n      fill = !!options.backgroundColor;\n    }\n    if (fill === false || fill === null) {\n      return false;\n    }\n    if (fill === true) {\n      return 'origin';\n    }\n    return fill;\n  }\n  function _buildStackLine(source) {\n    var scale = source.scale,\n      index = source.index,\n      line = source.line;\n    var points = [];\n    var segments = line.segments;\n    var sourcePoints = line.points;\n    var linesBelow = getLinesBelow(scale, index);\n    linesBelow.push(_createBoundaryLine({\n      x: null,\n      y: scale.bottom\n    }, line));\n    for (var i = 0; i < segments.length; i++) {\n      var segment = segments[i];\n      for (var j = segment.start; j <= segment.end; j++) {\n        addPointsBelow(points, sourcePoints[j], linesBelow);\n      }\n    }\n    return new LineElement({\n      points: points,\n      options: {}\n    });\n  }\n  function getLinesBelow(scale, index) {\n    var below = [];\n    var metas = scale.getMatchingVisibleMetas('line');\n    for (var i = 0; i < metas.length; i++) {\n      var meta = metas[i];\n      if (meta.index === index) {\n        break;\n      }\n      if (!meta.hidden) {\n        below.unshift(meta.dataset);\n      }\n    }\n    return below;\n  }\n  function addPointsBelow(points, sourcePoint, linesBelow) {\n    var postponed = [];\n    for (var j = 0; j < linesBelow.length; j++) {\n      var line = linesBelow[j];\n      var _findPoint = findPoint(line, sourcePoint, 'x'),\n        first = _findPoint.first,\n        last = _findPoint.last,\n        point = _findPoint.point;\n      if (!point || first && last) {\n        continue;\n      }\n      if (first) {\n        postponed.unshift(point);\n      } else {\n        points.push(point);\n        if (!last) {\n          break;\n        }\n      }\n    }\n    points.push.apply(points, postponed);\n  }\n  function findPoint(line, sourcePoint, property) {\n    var point = line.interpolate(sourcePoint, property);\n    if (!point) {\n      return {};\n    }\n    var pointValue = point[property];\n    var segments = line.segments;\n    var linePoints = line.points;\n    var first = false;\n    var last = false;\n    for (var i = 0; i < segments.length; i++) {\n      var segment = segments[i];\n      var firstValue = linePoints[segment.start][property];\n      var lastValue = linePoints[segment.end][property];\n      if (_isBetween(pointValue, firstValue, lastValue)) {\n        first = pointValue === firstValue;\n        last = pointValue === lastValue;\n        break;\n      }\n    }\n    return {\n      first: first,\n      last: last,\n      point: point\n    };\n  }\n  var simpleArc = /*#__PURE__*/function () {\n    function simpleArc(opts) {\n      _classCallCheck$x(this, simpleArc);\n      this.x = opts.x;\n      this.y = opts.y;\n      this.radius = opts.radius;\n    }\n    _createClass$x(simpleArc, [{\n      key: \"pathSegment\",\n      value: function pathSegment(ctx, bounds, opts) {\n        var x = this.x,\n          y = this.y,\n          radius = this.radius;\n        bounds = bounds || {\n          start: 0,\n          end: TAU\n        };\n        ctx.arc(x, y, radius, bounds.end, bounds.start, true);\n        return !opts.bounds;\n      }\n    }, {\n      key: \"interpolate\",\n      value: function interpolate(point) {\n        var x = this.x,\n          y = this.y,\n          radius = this.radius;\n        var angle = point.angle;\n        return {\n          x: x + Math.cos(angle) * radius,\n          y: y + Math.sin(angle) * radius,\n          angle: angle\n        };\n      }\n    }]);\n    return simpleArc;\n  }();\n  function _getTarget(source) {\n    var chart = source.chart,\n      fill = source.fill,\n      line = source.line;\n    if (isNumberFinite(fill)) {\n      return getLineByIndex(chart, fill);\n    }\n    if (fill === 'stack') {\n      return _buildStackLine(source);\n    }\n    if (fill === 'shape') {\n      return true;\n    }\n    var boundary = computeBoundary(source);\n    if (boundary instanceof simpleArc) {\n      return boundary;\n    }\n    return _createBoundaryLine(boundary, line);\n  }\n  function getLineByIndex(chart, index) {\n    var meta = chart.getDatasetMeta(index);\n    var visible = meta && chart.isDatasetVisible(index);\n    return visible ? meta.dataset : null;\n  }\n  function computeBoundary(source) {\n    var scale = source.scale || {};\n    if (scale.getPointPositionForValue) {\n      return computeCircularBoundary(source);\n    }\n    return computeLinearBoundary(source);\n  }\n  function computeLinearBoundary(source) {\n    var _source$scale = source.scale,\n      scale = _source$scale === void 0 ? {} : _source$scale,\n      fill = source.fill;\n    var pixel = _getTargetPixel(fill, scale);\n    if (isNumberFinite(pixel)) {\n      var horizontal = scale.isHorizontal();\n      return {\n        x: horizontal ? pixel : null,\n        y: horizontal ? null : pixel\n      };\n    }\n    return null;\n  }\n  function computeCircularBoundary(source) {\n    var scale = source.scale,\n      fill = source.fill;\n    var options = scale.options;\n    var length = scale.getLabels().length;\n    var start = options.reverse ? scale.max : scale.min;\n    var value = _getTargetValue(fill, scale, start);\n    var target = [];\n    if (options.grid.circular) {\n      var center = scale.getPointPositionForValue(0, start);\n      return new simpleArc({\n        x: center.x,\n        y: center.y,\n        radius: scale.getDistanceFromCenterForValue(value)\n      });\n    }\n    for (var i = 0; i < length; ++i) {\n      target.push(scale.getPointPositionForValue(i, value));\n    }\n    return target;\n  }\n  function _drawfill(ctx, source, area) {\n    var target = _getTarget(source);\n    var line = source.line,\n      scale = source.scale,\n      axis = source.axis;\n    var lineOpts = line.options;\n    var fillOption = lineOpts.fill;\n    var color = lineOpts.backgroundColor;\n    var _ref9 = fillOption || {},\n      _ref9$above = _ref9.above,\n      above = _ref9$above === void 0 ? color : _ref9$above,\n      _ref9$below = _ref9.below,\n      below = _ref9$below === void 0 ? color : _ref9$below;\n    if (target && line.points.length) {\n      clipArea(ctx, area);\n      doFill(ctx, {\n        line: line,\n        target: target,\n        above: above,\n        below: below,\n        area: area,\n        scale: scale,\n        axis: axis\n      });\n      unclipArea(ctx);\n    }\n  }\n  function doFill(ctx, cfg) {\n    var line = cfg.line,\n      target = cfg.target,\n      above = cfg.above,\n      below = cfg.below,\n      area = cfg.area,\n      scale = cfg.scale;\n    var property = line._loop ? 'angle' : cfg.axis;\n    ctx.save();\n    if (property === 'x' && below !== above) {\n      clipVertical(ctx, target, area.top);\n      fill(ctx, {\n        line: line,\n        target: target,\n        color: above,\n        scale: scale,\n        property: property\n      });\n      ctx.restore();\n      ctx.save();\n      clipVertical(ctx, target, area.bottom);\n    }\n    fill(ctx, {\n      line: line,\n      target: target,\n      color: below,\n      scale: scale,\n      property: property\n    });\n    ctx.restore();\n  }\n  function clipVertical(ctx, target, clipY) {\n    var segments = target.segments,\n      points = target.points;\n    var first = true;\n    var lineLoop = false;\n    ctx.beginPath();\n    var _iterator21 = _createForOfIteratorHelper$1(segments),\n      _step21;\n    try {\n      for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {\n        var segment = _step21.value;\n        var start = segment.start,\n          end = segment.end;\n        var firstPoint = points[start];\n        var lastPoint = points[_findSegmentEnd(start, end, points)];\n        if (first) {\n          ctx.moveTo(firstPoint.x, firstPoint.y);\n          first = false;\n        } else {\n          ctx.lineTo(firstPoint.x, clipY);\n          ctx.lineTo(firstPoint.x, firstPoint.y);\n        }\n        lineLoop = !!target.pathSegment(ctx, segment, {\n          move: lineLoop\n        });\n        if (lineLoop) {\n          ctx.closePath();\n        } else {\n          ctx.lineTo(lastPoint.x, clipY);\n        }\n      }\n    } catch (err) {\n      _iterator21.e(err);\n    } finally {\n      _iterator21.f();\n    }\n    ctx.lineTo(target.first().x, clipY);\n    ctx.closePath();\n    ctx.clip();\n  }\n  function fill(ctx, cfg) {\n    var line = cfg.line,\n      target = cfg.target,\n      property = cfg.property,\n      color = cfg.color,\n      scale = cfg.scale;\n    var segments = _segments(line, target, property);\n    var _iterator22 = _createForOfIteratorHelper$1(segments),\n      _step22;\n    try {\n      for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {\n        var _step22$value = _step22.value,\n          src = _step22$value.source,\n          tgt = _step22$value.target,\n          start = _step22$value.start,\n          end = _step22$value.end;\n        var _src$style = src.style,\n          _src$style2 = _src$style === void 0 ? {} : _src$style,\n          _src$style2$backgroun = _src$style2.backgroundColor,\n          backgroundColor = _src$style2$backgroun === void 0 ? color : _src$style2$backgroun;\n        var notShape = target !== true;\n        ctx.save();\n        ctx.fillStyle = backgroundColor;\n        clipBounds(ctx, scale, notShape && _getBounds(property, start, end));\n        ctx.beginPath();\n        var lineLoop = !!line.pathSegment(ctx, src);\n        var loop = void 0;\n        if (notShape) {\n          if (lineLoop) {\n            ctx.closePath();\n          } else {\n            interpolatedLineTo(ctx, target, end, property);\n          }\n          var targetLoop = !!target.pathSegment(ctx, tgt, {\n            move: lineLoop,\n            reverse: true\n          });\n          loop = lineLoop && targetLoop;\n          if (!loop) {\n            interpolatedLineTo(ctx, target, start, property);\n          }\n        }\n        ctx.closePath();\n        ctx.fill(loop ? 'evenodd' : 'nonzero');\n        ctx.restore();\n      }\n    } catch (err) {\n      _iterator22.e(err);\n    } finally {\n      _iterator22.f();\n    }\n  }\n  function clipBounds(ctx, scale, bounds) {\n    var _scale$chart$chartAre = scale.chart.chartArea,\n      top = _scale$chart$chartAre.top,\n      bottom = _scale$chart$chartAre.bottom;\n    var _ref10 = bounds || {},\n      property = _ref10.property,\n      start = _ref10.start,\n      end = _ref10.end;\n    if (property === 'x') {\n      ctx.beginPath();\n      ctx.rect(start, top, end - start, bottom - top);\n      ctx.clip();\n    }\n  }\n  function interpolatedLineTo(ctx, target, point, property) {\n    var interpolatedPoint = target.interpolate(point, property);\n    if (interpolatedPoint) {\n      ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y);\n    }\n  }\n  var index = {\n    id: 'filler',\n    afterDatasetsUpdate: function afterDatasetsUpdate(chart, _args, options) {\n      var count = (chart.data.datasets || []).length;\n      var sources = [];\n      var meta, i, line, source;\n      for (i = 0; i < count; ++i) {\n        meta = chart.getDatasetMeta(i);\n        line = meta.dataset;\n        source = null;\n        if (line && line.options && line instanceof LineElement) {\n          source = {\n            visible: chart.isDatasetVisible(i),\n            index: i,\n            fill: _decodeFill(line, i, count),\n            chart: chart,\n            axis: meta.controller.options.indexAxis,\n            scale: meta.vScale,\n            line: line\n          };\n        }\n        meta.$filler = source;\n        sources.push(source);\n      }\n      for (i = 0; i < count; ++i) {\n        source = sources[i];\n        if (!source || source.fill === false) {\n          continue;\n        }\n        source.fill = _resolveTarget(sources, i, options.propagate);\n      }\n    },\n    beforeDraw: function beforeDraw(chart, _args, options) {\n      var draw = options.drawTime === 'beforeDraw';\n      var metasets = chart.getSortedVisibleDatasetMetas();\n      var area = chart.chartArea;\n      for (var i = metasets.length - 1; i >= 0; --i) {\n        var source = metasets[i].$filler;\n        if (!source) {\n          continue;\n        }\n        source.line.updateControlPoints(area, source.axis);\n        if (draw && source.fill) {\n          _drawfill(chart.ctx, source, area);\n        }\n      }\n    },\n    beforeDatasetsDraw: function beforeDatasetsDraw(chart, _args, options) {\n      if (options.drawTime !== 'beforeDatasetsDraw') {\n        return;\n      }\n      var metasets = chart.getSortedVisibleDatasetMetas();\n      for (var i = metasets.length - 1; i >= 0; --i) {\n        var source = metasets[i].$filler;\n        if (_shouldApplyFill(source)) {\n          _drawfill(chart.ctx, source, chart.chartArea);\n        }\n      }\n    },\n    beforeDatasetDraw: function beforeDatasetDraw(chart, args, options) {\n      var source = args.meta.$filler;\n      if (!_shouldApplyFill(source) || options.drawTime !== 'beforeDatasetDraw') {\n        return;\n      }\n      _drawfill(chart.ctx, source, chart.chartArea);\n    },\n    defaults: {\n      propagate: true,\n      drawTime: 'beforeDatasetDraw'\n    }\n  };\n  var getBoxSize = function getBoxSize(labelOpts, fontSize) {\n    var _labelOpts$boxHeight = labelOpts.boxHeight,\n      boxHeight = _labelOpts$boxHeight === void 0 ? fontSize : _labelOpts$boxHeight,\n      _labelOpts$boxWidth = labelOpts.boxWidth,\n      boxWidth = _labelOpts$boxWidth === void 0 ? fontSize : _labelOpts$boxWidth;\n    if (labelOpts.usePointStyle) {\n      boxHeight = Math.min(boxHeight, fontSize);\n      boxWidth = labelOpts.pointStyleWidth || Math.min(boxWidth, fontSize);\n    }\n    return {\n      boxWidth: boxWidth,\n      boxHeight: boxHeight,\n      itemHeight: Math.max(fontSize, boxHeight)\n    };\n  };\n  var itemsEqual = function itemsEqual(a, b) {\n    return a !== null && b !== null && a.datasetIndex === b.datasetIndex && a.index === b.index;\n  };\n  var Legend = /*#__PURE__*/function (_Element6) {\n    _inherits$w(Legend, _Element6);\n    var _super16 = _createSuper$w(Legend);\n    function Legend(config) {\n      var _this27;\n      _classCallCheck$x(this, Legend);\n      _this27 = _super16.call(this);\n      _this27._added = false;\n      _this27.legendHitBoxes = [];\n      _this27._hoveredItem = null;\n      _this27.doughnutMode = false;\n      _this27.chart = config.chart;\n      _this27.options = config.options;\n      _this27.ctx = config.ctx;\n      _this27.legendItems = undefined;\n      _this27.columnSizes = undefined;\n      _this27.lineWidths = undefined;\n      _this27.maxHeight = undefined;\n      _this27.maxWidth = undefined;\n      _this27.top = undefined;\n      _this27.bottom = undefined;\n      _this27.left = undefined;\n      _this27.right = undefined;\n      _this27.height = undefined;\n      _this27.width = undefined;\n      _this27._margins = undefined;\n      _this27.position = undefined;\n      _this27.weight = undefined;\n      _this27.fullSize = undefined;\n      return _this27;\n    }\n    _createClass$x(Legend, [{\n      key: \"update\",\n      value: function update(maxWidth, maxHeight, margins) {\n        this.maxWidth = maxWidth;\n        this.maxHeight = maxHeight;\n        this._margins = margins;\n        this.setDimensions();\n        this.buildLabels();\n        this.fit();\n      }\n    }, {\n      key: \"setDimensions\",\n      value: function setDimensions() {\n        if (this.isHorizontal()) {\n          this.width = this.maxWidth;\n          this.left = this._margins.left;\n          this.right = this.width;\n        } else {\n          this.height = this.maxHeight;\n          this.top = this._margins.top;\n          this.bottom = this.height;\n        }\n      }\n    }, {\n      key: \"buildLabels\",\n      value: function buildLabels() {\n        var _this28 = this;\n        var labelOpts = this.options.labels || {};\n        var legendItems = callback(labelOpts.generateLabels, [this.chart], this) || [];\n        if (labelOpts.filter) {\n          legendItems = legendItems.filter(function (item) {\n            return labelOpts.filter(item, _this28.chart.data);\n          });\n        }\n        if (labelOpts.sort) {\n          legendItems = legendItems.sort(function (a, b) {\n            return labelOpts.sort(a, b, _this28.chart.data);\n          });\n        }\n        if (this.options.reverse) {\n          legendItems.reverse();\n        }\n        this.legendItems = legendItems;\n      }\n    }, {\n      key: \"fit\",\n      value: function fit() {\n        var options = this.options,\n          ctx = this.ctx;\n        if (!options.display) {\n          this.width = this.height = 0;\n          return;\n        }\n        var labelOpts = options.labels;\n        var labelFont = toFont(labelOpts.font);\n        var fontSize = labelFont.size;\n        var titleHeight = this._computeTitleHeight();\n        var _getBoxSize = getBoxSize(labelOpts, fontSize),\n          boxWidth = _getBoxSize.boxWidth,\n          itemHeight = _getBoxSize.itemHeight;\n        var width, height;\n        ctx.font = labelFont.string;\n        if (this.isHorizontal()) {\n          width = this.maxWidth;\n          height = this._fitRows(titleHeight, fontSize, boxWidth, itemHeight) + 10;\n        } else {\n          height = this.maxHeight;\n          width = this._fitCols(titleHeight, labelFont, boxWidth, itemHeight) + 10;\n        }\n        this.width = Math.min(width, options.maxWidth || this.maxWidth);\n        this.height = Math.min(height, options.maxHeight || this.maxHeight);\n      }\n    }, {\n      key: \"_fitRows\",\n      value: function _fitRows(titleHeight, fontSize, boxWidth, itemHeight) {\n        var ctx = this.ctx,\n          maxWidth = this.maxWidth,\n          padding = this.options.labels.padding;\n        var hitboxes = this.legendHitBoxes = [];\n        var lineWidths = this.lineWidths = [0];\n        var lineHeight = itemHeight + padding;\n        var totalHeight = titleHeight;\n        ctx.textAlign = 'left';\n        ctx.textBaseline = 'middle';\n        var row = -1;\n        var top = -lineHeight;\n        this.legendItems.forEach(function (legendItem, i) {\n          var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width;\n          if (i === 0 || lineWidths[lineWidths.length - 1] + itemWidth + 2 * padding > maxWidth) {\n            totalHeight += lineHeight;\n            lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0;\n            top += lineHeight;\n            row++;\n          }\n          hitboxes[i] = {\n            left: 0,\n            top: top,\n            row: row,\n            width: itemWidth,\n            height: itemHeight\n          };\n          lineWidths[lineWidths.length - 1] += itemWidth + padding;\n        });\n        return totalHeight;\n      }\n    }, {\n      key: \"_fitCols\",\n      value: function _fitCols(titleHeight, labelFont, boxWidth, _itemHeight) {\n        var ctx = this.ctx,\n          maxHeight = this.maxHeight,\n          padding = this.options.labels.padding;\n        var hitboxes = this.legendHitBoxes = [];\n        var columnSizes = this.columnSizes = [];\n        var heightLimit = maxHeight - titleHeight;\n        var totalWidth = padding;\n        var currentColWidth = 0;\n        var currentColHeight = 0;\n        var left = 0;\n        var col = 0;\n        this.legendItems.forEach(function (legendItem, i) {\n          var _calculateItemSize = calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight),\n            itemWidth = _calculateItemSize.itemWidth,\n            itemHeight = _calculateItemSize.itemHeight;\n          if (i > 0 && currentColHeight + itemHeight + 2 * padding > heightLimit) {\n            totalWidth += currentColWidth + padding;\n            columnSizes.push({\n              width: currentColWidth,\n              height: currentColHeight\n            });\n            left += currentColWidth + padding;\n            col++;\n            currentColWidth = currentColHeight = 0;\n          }\n          hitboxes[i] = {\n            left: left,\n            top: currentColHeight,\n            col: col,\n            width: itemWidth,\n            height: itemHeight\n          };\n          currentColWidth = Math.max(currentColWidth, itemWidth);\n          currentColHeight += itemHeight + padding;\n        });\n        totalWidth += currentColWidth;\n        columnSizes.push({\n          width: currentColWidth,\n          height: currentColHeight\n        });\n        return totalWidth;\n      }\n    }, {\n      key: \"adjustHitBoxes\",\n      value: function adjustHitBoxes() {\n        if (!this.options.display) {\n          return;\n        }\n        var titleHeight = this._computeTitleHeight();\n        var hitboxes = this.legendHitBoxes,\n          _this$options15 = this.options,\n          align = _this$options15.align,\n          padding = _this$options15.labels.padding,\n          rtl = _this$options15.rtl;\n        var rtlHelper = getRtlAdapter(rtl, this.left, this.width);\n        if (this.isHorizontal()) {\n          var row = 0;\n          var left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n          var _iterator23 = _createForOfIteratorHelper$1(hitboxes),\n            _step23;\n          try {\n            for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {\n              var hitbox = _step23.value;\n              if (row !== hitbox.row) {\n                row = hitbox.row;\n                left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n              }\n              hitbox.top += this.top + titleHeight + padding;\n              hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(left), hitbox.width);\n              left += hitbox.width + padding;\n            }\n          } catch (err) {\n            _iterator23.e(err);\n          } finally {\n            _iterator23.f();\n          }\n        } else {\n          var col = 0;\n          var top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n          var _iterator24 = _createForOfIteratorHelper$1(hitboxes),\n            _step24;\n          try {\n            for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {\n              var hitbox1 = _step24.value;\n              if (hitbox1.col !== col) {\n                col = hitbox1.col;\n                top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n              }\n              hitbox1.top = top;\n              hitbox1.left += this.left + padding;\n              hitbox1.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox1.left), hitbox1.width);\n              top += hitbox1.height + padding;\n            }\n          } catch (err) {\n            _iterator24.e(err);\n          } finally {\n            _iterator24.f();\n          }\n        }\n      }\n    }, {\n      key: \"isHorizontal\",\n      value: function isHorizontal() {\n        return this.options.position === 'top' || this.options.position === 'bottom';\n      }\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        if (this.options.display) {\n          var ctx = this.ctx;\n          clipArea(ctx, this);\n          this._draw();\n          unclipArea(ctx);\n        }\n      }\n    }, {\n      key: \"_draw\",\n      value: function _draw() {\n        var _this29 = this;\n        var opts = this.options,\n          columnSizes = this.columnSizes,\n          lineWidths = this.lineWidths,\n          ctx = this.ctx;\n        var align = opts.align,\n          labelOpts = opts.labels;\n        var defaultColor = defaults.color;\n        var rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n        var labelFont = toFont(labelOpts.font);\n        var padding = labelOpts.padding;\n        var fontSize = labelFont.size;\n        var halfFontSize = fontSize / 2;\n        var cursor;\n        this.drawTitle();\n        ctx.textAlign = rtlHelper.textAlign('left');\n        ctx.textBaseline = 'middle';\n        ctx.lineWidth = 0.5;\n        ctx.font = labelFont.string;\n        var _getBoxSize2 = getBoxSize(labelOpts, fontSize),\n          boxWidth = _getBoxSize2.boxWidth,\n          boxHeight = _getBoxSize2.boxHeight,\n          itemHeight = _getBoxSize2.itemHeight;\n        var drawLegendBox = function drawLegendBox(x, y, legendItem) {\n          if (isNaN(boxWidth) || boxWidth <= 0 || isNaN(boxHeight) || boxHeight < 0) {\n            return;\n          }\n          ctx.save();\n          var lineWidth = valueOrDefault(legendItem.lineWidth, 1);\n          ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor);\n          ctx.lineCap = valueOrDefault(legendItem.lineCap, 'butt');\n          ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, 0);\n          ctx.lineJoin = valueOrDefault(legendItem.lineJoin, 'miter');\n          ctx.lineWidth = lineWidth;\n          ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor);\n          ctx.setLineDash(valueOrDefault(legendItem.lineDash, []));\n          if (labelOpts.usePointStyle) {\n            var drawOptions = {\n              radius: boxHeight * Math.SQRT2 / 2,\n              pointStyle: legendItem.pointStyle,\n              rotation: legendItem.rotation,\n              borderWidth: lineWidth\n            };\n            var centerX = rtlHelper.xPlus(x, boxWidth / 2);\n            var centerY = y + halfFontSize;\n            drawPointLegend(ctx, drawOptions, centerX, centerY, labelOpts.pointStyleWidth && boxWidth);\n          } else {\n            var yBoxTop = y + Math.max((fontSize - boxHeight) / 2, 0);\n            var xBoxLeft = rtlHelper.leftForLtr(x, boxWidth);\n            var borderRadius = toTRBLCorners(legendItem.borderRadius);\n            ctx.beginPath();\n            if (Object.values(borderRadius).some(function (v) {\n              return v !== 0;\n            })) {\n              addRoundedRectPath(ctx, {\n                x: xBoxLeft,\n                y: yBoxTop,\n                w: boxWidth,\n                h: boxHeight,\n                radius: borderRadius\n              });\n            } else {\n              ctx.rect(xBoxLeft, yBoxTop, boxWidth, boxHeight);\n            }\n            ctx.fill();\n            if (lineWidth !== 0) {\n              ctx.stroke();\n            }\n          }\n          ctx.restore();\n        };\n        var fillText = function fillText(x, y, legendItem) {\n          renderText(ctx, legendItem.text, x, y + itemHeight / 2, labelFont, {\n            strikethrough: legendItem.hidden,\n            textAlign: rtlHelper.textAlign(legendItem.textAlign)\n          });\n        };\n        var isHorizontal = this.isHorizontal();\n        var titleHeight = this._computeTitleHeight();\n        if (isHorizontal) {\n          cursor = {\n            x: _alignStartEnd(align, this.left + padding, this.right - lineWidths[0]),\n            y: this.top + padding + titleHeight,\n            line: 0\n          };\n        } else {\n          cursor = {\n            x: this.left + padding,\n            y: _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - columnSizes[0].height),\n            line: 0\n          };\n        }\n        overrideTextDirection(this.ctx, opts.textDirection);\n        var lineHeight = itemHeight + padding;\n        this.legendItems.forEach(function (legendItem, i) {\n          ctx.strokeStyle = legendItem.fontColor;\n          ctx.fillStyle = legendItem.fontColor;\n          var textWidth = ctx.measureText(legendItem.text).width;\n          var textAlign = rtlHelper.textAlign(legendItem.textAlign || (legendItem.textAlign = labelOpts.textAlign));\n          var width = boxWidth + halfFontSize + textWidth;\n          var x = cursor.x;\n          var y = cursor.y;\n          rtlHelper.setWidth(_this29.width);\n          if (isHorizontal) {\n            if (i > 0 && x + width + padding > _this29.right) {\n              y = cursor.y += lineHeight;\n              cursor.line++;\n              x = cursor.x = _alignStartEnd(align, _this29.left + padding, _this29.right - lineWidths[cursor.line]);\n            }\n          } else if (i > 0 && y + lineHeight > _this29.bottom) {\n            x = cursor.x = x + columnSizes[cursor.line].width + padding;\n            cursor.line++;\n            y = cursor.y = _alignStartEnd(align, _this29.top + titleHeight + padding, _this29.bottom - columnSizes[cursor.line].height);\n          }\n          var realX = rtlHelper.x(x);\n          drawLegendBox(realX, y, legendItem);\n          x = _textX(textAlign, x + boxWidth + halfFontSize, isHorizontal ? x + width : _this29.right, opts.rtl);\n          fillText(rtlHelper.x(x), y, legendItem);\n          if (isHorizontal) {\n            cursor.x += width + padding;\n          } else if (typeof legendItem.text !== 'string') {\n            var fontLineHeight = labelFont.lineHeight;\n            cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight);\n          } else {\n            cursor.y += lineHeight;\n          }\n        });\n        restoreTextDirection(this.ctx, opts.textDirection);\n      }\n    }, {\n      key: \"drawTitle\",\n      value: function drawTitle() {\n        var opts = this.options;\n        var titleOpts = opts.title;\n        var titleFont = toFont(titleOpts.font);\n        var titlePadding = toPadding(titleOpts.padding);\n        if (!titleOpts.display) {\n          return;\n        }\n        var rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n        var ctx = this.ctx;\n        var position = titleOpts.position;\n        var halfFontSize = titleFont.size / 2;\n        var topPaddingPlusHalfFontSize = titlePadding.top + halfFontSize;\n        var y;\n        var left = this.left;\n        var maxWidth = this.width;\n        if (this.isHorizontal()) {\n          maxWidth = Math.max.apply(Math, _toConsumableArray(this.lineWidths));\n          y = this.top + topPaddingPlusHalfFontSize;\n          left = _alignStartEnd(opts.align, left, this.right - maxWidth);\n        } else {\n          var maxHeight = this.columnSizes.reduce(function (acc, size) {\n            return Math.max(acc, size.height);\n          }, 0);\n          y = topPaddingPlusHalfFontSize + _alignStartEnd(opts.align, this.top, this.bottom - maxHeight - opts.labels.padding - this._computeTitleHeight());\n        }\n        var x = _alignStartEnd(position, left, left + maxWidth);\n        ctx.textAlign = rtlHelper.textAlign(_toLeftRightCenter(position));\n        ctx.textBaseline = 'middle';\n        ctx.strokeStyle = titleOpts.color;\n        ctx.fillStyle = titleOpts.color;\n        ctx.font = titleFont.string;\n        renderText(ctx, titleOpts.text, x, y, titleFont);\n      }\n    }, {\n      key: \"_computeTitleHeight\",\n      value: function _computeTitleHeight() {\n        var titleOpts = this.options.title;\n        var titleFont = toFont(titleOpts.font);\n        var titlePadding = toPadding(titleOpts.padding);\n        return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0;\n      }\n    }, {\n      key: \"_getLegendItemAt\",\n      value: function _getLegendItemAt(x, y) {\n        var i, hitBox, lh;\n        if (_isBetween(x, this.left, this.right) && _isBetween(y, this.top, this.bottom)) {\n          lh = this.legendHitBoxes;\n          for (i = 0; i < lh.length; ++i) {\n            hitBox = lh[i];\n            if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) {\n              return this.legendItems[i];\n            }\n          }\n        }\n        return null;\n      }\n    }, {\n      key: \"handleEvent\",\n      value: function handleEvent(e) {\n        var opts = this.options;\n        if (!isListened(e.type, opts)) {\n          return;\n        }\n        var hoveredItem = this._getLegendItemAt(e.x, e.y);\n        if (e.type === 'mousemove' || e.type === 'mouseout') {\n          var previous = this._hoveredItem;\n          var sameItem = itemsEqual(previous, hoveredItem);\n          if (previous && !sameItem) {\n            callback(opts.onLeave, [e, previous, this], this);\n          }\n          this._hoveredItem = hoveredItem;\n          if (hoveredItem && !sameItem) {\n            callback(opts.onHover, [e, hoveredItem, this], this);\n          }\n        } else if (hoveredItem) {\n          callback(opts.onClick, [e, hoveredItem, this], this);\n        }\n      }\n    }]);\n    return Legend;\n  }(Element);\n  function calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight) {\n    var itemWidth = calculateItemWidth(legendItem, boxWidth, labelFont, ctx);\n    var itemHeight = calculateItemHeight(_itemHeight, legendItem, labelFont.lineHeight);\n    return {\n      itemWidth: itemWidth,\n      itemHeight: itemHeight\n    };\n  }\n  function calculateItemWidth(legendItem, boxWidth, labelFont, ctx) {\n    var legendItemText = legendItem.text;\n    if (legendItemText && typeof legendItemText !== 'string') {\n      legendItemText = legendItemText.reduce(function (a, b) {\n        return a.length > b.length ? a : b;\n      });\n    }\n    return boxWidth + labelFont.size / 2 + ctx.measureText(legendItemText).width;\n  }\n  function calculateItemHeight(_itemHeight, legendItem, fontLineHeight) {\n    var itemHeight = _itemHeight;\n    if (typeof legendItem.text !== 'string') {\n      itemHeight = calculateLegendItemHeight(legendItem, fontLineHeight);\n    }\n    return itemHeight;\n  }\n  function calculateLegendItemHeight(legendItem, fontLineHeight) {\n    var labelHeight = legendItem.text ? legendItem.text.length + 0.5 : 0;\n    return fontLineHeight * labelHeight;\n  }\n  function isListened(type, opts) {\n    if ((type === 'mousemove' || type === 'mouseout') && (opts.onHover || opts.onLeave)) {\n      return true;\n    }\n    if (opts.onClick && (type === 'click' || type === 'mouseup')) {\n      return true;\n    }\n    return false;\n  }\n  var plugin_legend = {\n    id: 'legend',\n    _element: Legend,\n    start: function start(chart, _args, options) {\n      var legend = chart.legend = new Legend({\n        ctx: chart.ctx,\n        options: options,\n        chart: chart\n      });\n      layouts.configure(chart, legend, options);\n      layouts.addBox(chart, legend);\n    },\n    stop: function stop(chart) {\n      layouts.removeBox(chart, chart.legend);\n      delete chart.legend;\n    },\n    beforeUpdate: function beforeUpdate(chart, _args, options) {\n      var legend = chart.legend;\n      layouts.configure(chart, legend, options);\n      legend.options = options;\n    },\n    afterUpdate: function afterUpdate(chart) {\n      var legend = chart.legend;\n      legend.buildLabels();\n      legend.adjustHitBoxes();\n    },\n    afterEvent: function afterEvent(chart, args) {\n      if (!args.replay) {\n        chart.legend.handleEvent(args.event);\n      }\n    },\n    defaults: {\n      display: true,\n      position: 'top',\n      align: 'center',\n      fullSize: true,\n      reverse: false,\n      weight: 1000,\n      onClick: function onClick(e, legendItem, legend) {\n        var index = legendItem.datasetIndex;\n        var ci = legend.chart;\n        if (ci.isDatasetVisible(index)) {\n          ci.hide(index);\n          legendItem.hidden = true;\n        } else {\n          ci.show(index);\n          legendItem.hidden = false;\n        }\n      },\n      onHover: null,\n      onLeave: null,\n      labels: {\n        color: function color(ctx) {\n          return ctx.chart.options.color;\n        },\n        boxWidth: 40,\n        padding: 10,\n        generateLabels: function generateLabels(chart) {\n          var datasets = chart.data.datasets;\n          var _chart$legend$options = chart.legend.options.labels,\n            usePointStyle = _chart$legend$options.usePointStyle,\n            pointStyle = _chart$legend$options.pointStyle,\n            textAlign = _chart$legend$options.textAlign,\n            color = _chart$legend$options.color,\n            useBorderRadius = _chart$legend$options.useBorderRadius,\n            borderRadius = _chart$legend$options.borderRadius;\n          return chart._getSortedDatasetMetas().map(function (meta) {\n            var style = meta.controller.getStyle(usePointStyle ? 0 : undefined);\n            var borderWidth = toPadding(style.borderWidth);\n            return {\n              text: datasets[meta.index].label,\n              fillStyle: style.backgroundColor,\n              fontColor: color,\n              hidden: !meta.visible,\n              lineCap: style.borderCapStyle,\n              lineDash: style.borderDash,\n              lineDashOffset: style.borderDashOffset,\n              lineJoin: style.borderJoinStyle,\n              lineWidth: (borderWidth.width + borderWidth.height) / 4,\n              strokeStyle: style.borderColor,\n              pointStyle: pointStyle || style.pointStyle,\n              rotation: style.rotation,\n              textAlign: textAlign || style.textAlign,\n              borderRadius: useBorderRadius && (borderRadius || style.borderRadius),\n              datasetIndex: meta.index\n            };\n          }, this);\n        }\n      },\n      title: {\n        color: function color(ctx) {\n          return ctx.chart.options.color;\n        },\n        display: false,\n        position: 'center',\n        text: ''\n      }\n    },\n    descriptors: {\n      _scriptable: function _scriptable(name) {\n        return !name.startsWith('on');\n      },\n      labels: {\n        _scriptable: function _scriptable(name) {\n          return !['generateLabels', 'filter', 'sort'].includes(name);\n        }\n      }\n    }\n  };\n  var Title = /*#__PURE__*/function (_Element7) {\n    _inherits$w(Title, _Element7);\n    var _super17 = _createSuper$w(Title);\n    function Title(config) {\n      var _this30;\n      _classCallCheck$x(this, Title);\n      _this30 = _super17.call(this);\n      _this30.chart = config.chart;\n      _this30.options = config.options;\n      _this30.ctx = config.ctx;\n      _this30._padding = undefined;\n      _this30.top = undefined;\n      _this30.bottom = undefined;\n      _this30.left = undefined;\n      _this30.right = undefined;\n      _this30.width = undefined;\n      _this30.height = undefined;\n      _this30.position = undefined;\n      _this30.weight = undefined;\n      _this30.fullSize = undefined;\n      return _this30;\n    }\n    _createClass$x(Title, [{\n      key: \"update\",\n      value: function update(maxWidth, maxHeight) {\n        var opts = this.options;\n        this.left = 0;\n        this.top = 0;\n        if (!opts.display) {\n          this.width = this.height = this.right = this.bottom = 0;\n          return;\n        }\n        this.width = this.right = maxWidth;\n        this.height = this.bottom = maxHeight;\n        var lineCount = isArray(opts.text) ? opts.text.length : 1;\n        this._padding = toPadding(opts.padding);\n        var textSize = lineCount * toFont(opts.font).lineHeight + this._padding.height;\n        if (this.isHorizontal()) {\n          this.height = textSize;\n        } else {\n          this.width = textSize;\n        }\n      }\n    }, {\n      key: \"isHorizontal\",\n      value: function isHorizontal() {\n        var pos = this.options.position;\n        return pos === 'top' || pos === 'bottom';\n      }\n    }, {\n      key: \"_drawArgs\",\n      value: function _drawArgs(offset) {\n        var top = this.top,\n          left = this.left,\n          bottom = this.bottom,\n          right = this.right,\n          options = this.options;\n        var align = options.align;\n        var rotation = 0;\n        var maxWidth, titleX, titleY;\n        if (this.isHorizontal()) {\n          titleX = _alignStartEnd(align, left, right);\n          titleY = top + offset;\n          maxWidth = right - left;\n        } else {\n          if (options.position === 'left') {\n            titleX = left + offset;\n            titleY = _alignStartEnd(align, bottom, top);\n            rotation = PI * -0.5;\n          } else {\n            titleX = right - offset;\n            titleY = _alignStartEnd(align, top, bottom);\n            rotation = PI * 0.5;\n          }\n          maxWidth = bottom - top;\n        }\n        return {\n          titleX: titleX,\n          titleY: titleY,\n          maxWidth: maxWidth,\n          rotation: rotation\n        };\n      }\n    }, {\n      key: \"draw\",\n      value: function draw() {\n        var ctx = this.ctx;\n        var opts = this.options;\n        if (!opts.display) {\n          return;\n        }\n        var fontOpts = toFont(opts.font);\n        var lineHeight = fontOpts.lineHeight;\n        var offset = lineHeight / 2 + this._padding.top;\n        var _this$_drawArgs = this._drawArgs(offset),\n          titleX = _this$_drawArgs.titleX,\n          titleY = _this$_drawArgs.titleY,\n          maxWidth = _this$_drawArgs.maxWidth,\n          rotation = _this$_drawArgs.rotation;\n        renderText(ctx, opts.text, 0, 0, fontOpts, {\n          color: opts.color,\n          maxWidth: maxWidth,\n          rotation: rotation,\n          textAlign: _toLeftRightCenter(opts.align),\n          textBaseline: 'middle',\n          translation: [titleX, titleY]\n        });\n      }\n    }]);\n    return Title;\n  }(Element);\n  function createTitle(chart, titleOpts) {\n    var title = new Title({\n      ctx: chart.ctx,\n      options: titleOpts,\n      chart: chart\n    });\n    layouts.configure(chart, title, titleOpts);\n    layouts.addBox(chart, title);\n    chart.titleBlock = title;\n  }\n  var plugin_title = {\n    id: 'title',\n    _element: Title,\n    start: function start(chart, _args, options) {\n      createTitle(chart, options);\n    },\n    stop: function stop(chart) {\n      var titleBlock = chart.titleBlock;\n      layouts.removeBox(chart, titleBlock);\n      delete chart.titleBlock;\n    },\n    beforeUpdate: function beforeUpdate(chart, _args, options) {\n      var title = chart.titleBlock;\n      layouts.configure(chart, title, options);\n      title.options = options;\n    },\n    defaults: {\n      align: 'center',\n      display: false,\n      font: {\n        weight: 'bold'\n      },\n      fullSize: true,\n      padding: 10,\n      position: 'top',\n      text: '',\n      weight: 2000\n    },\n    defaultRoutes: {\n      color: 'color'\n    },\n    descriptors: {\n      _scriptable: true,\n      _indexable: false\n    }\n  };\n  var map = new WeakMap();\n  var plugin_subtitle = {\n    id: 'subtitle',\n    start: function start(chart, _args, options) {\n      var title = new Title({\n        ctx: chart.ctx,\n        options: options,\n        chart: chart\n      });\n      layouts.configure(chart, title, options);\n      layouts.addBox(chart, title);\n      map.set(chart, title);\n    },\n    stop: function stop(chart) {\n      layouts.removeBox(chart, map.get(chart));\n      map[\"delete\"](chart);\n    },\n    beforeUpdate: function beforeUpdate(chart, _args, options) {\n      var title = map.get(chart);\n      layouts.configure(chart, title, options);\n      title.options = options;\n    },\n    defaults: {\n      align: 'center',\n      display: false,\n      font: {\n        weight: 'normal'\n      },\n      fullSize: true,\n      padding: 0,\n      position: 'top',\n      text: '',\n      weight: 1500\n    },\n    defaultRoutes: {\n      color: 'color'\n    },\n    descriptors: {\n      _scriptable: true,\n      _indexable: false\n    }\n  };\n  var positioners = {\n    average: function average(items) {\n      if (!items.length) {\n        return false;\n      }\n      var i, len;\n      var x = 0;\n      var y = 0;\n      var count = 0;\n      for (i = 0, len = items.length; i < len; ++i) {\n        var el = items[i].element;\n        if (el && el.hasValue()) {\n          var pos = el.tooltipPosition();\n          x += pos.x;\n          y += pos.y;\n          ++count;\n        }\n      }\n      return {\n        x: x / count,\n        y: y / count\n      };\n    },\n    nearest: function nearest(items, eventPosition) {\n      if (!items.length) {\n        return false;\n      }\n      var x = eventPosition.x;\n      var y = eventPosition.y;\n      var minDistance = Number.POSITIVE_INFINITY;\n      var i, len, nearestElement;\n      for (i = 0, len = items.length; i < len; ++i) {\n        var el = items[i].element;\n        if (el && el.hasValue()) {\n          var center = el.getCenterPoint();\n          var d = distanceBetweenPoints(eventPosition, center);\n          if (d < minDistance) {\n            minDistance = d;\n            nearestElement = el;\n          }\n        }\n      }\n      if (nearestElement) {\n        var tp = nearestElement.tooltipPosition();\n        x = tp.x;\n        y = tp.y;\n      }\n      return {\n        x: x,\n        y: y\n      };\n    }\n  };\n  function pushOrConcat(base, toPush) {\n    if (toPush) {\n      if (isArray(toPush)) {\n        Array.prototype.push.apply(base, toPush);\n      } else {\n        base.push(toPush);\n      }\n    }\n    return base;\n  }\n  function splitNewlines(str) {\n    if ((typeof str === 'string' || str instanceof String) && str.indexOf('\\n') > -1) {\n      return str.split('\\n');\n    }\n    return str;\n  }\n  function createTooltipItem(chart, item) {\n    var element = item.element,\n      datasetIndex = item.datasetIndex,\n      index = item.index;\n    var controller = chart.getDatasetMeta(datasetIndex).controller;\n    var _controller$getLabelA = controller.getLabelAndValue(index),\n      label = _controller$getLabelA.label,\n      value = _controller$getLabelA.value;\n    return {\n      chart: chart,\n      label: label,\n      parsed: controller.getParsed(index),\n      raw: chart.data.datasets[datasetIndex].data[index],\n      formattedValue: value,\n      dataset: controller.getDataset(),\n      dataIndex: index,\n      datasetIndex: datasetIndex,\n      element: element\n    };\n  }\n  function getTooltipSize(tooltip, options) {\n    var ctx = tooltip.chart.ctx;\n    var body = tooltip.body,\n      footer = tooltip.footer,\n      title = tooltip.title;\n    var boxWidth = options.boxWidth,\n      boxHeight = options.boxHeight;\n    var bodyFont = toFont(options.bodyFont);\n    var titleFont = toFont(options.titleFont);\n    var footerFont = toFont(options.footerFont);\n    var titleLineCount = title.length;\n    var footerLineCount = footer.length;\n    var bodyLineItemCount = body.length;\n    var padding = toPadding(options.padding);\n    var height = padding.height;\n    var width = 0;\n    var combinedBodyLength = body.reduce(function (count, bodyItem) {\n      return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;\n    }, 0);\n    combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length;\n    if (titleLineCount) {\n      height += titleLineCount * titleFont.lineHeight + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom;\n    }\n    if (combinedBodyLength) {\n      var bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFont.lineHeight) : bodyFont.lineHeight;\n      height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFont.lineHeight + (combinedBodyLength - 1) * options.bodySpacing;\n    }\n    if (footerLineCount) {\n      height += options.footerMarginTop + footerLineCount * footerFont.lineHeight + (footerLineCount - 1) * options.footerSpacing;\n    }\n    var widthPadding = 0;\n    var maxLineWidth = function maxLineWidth(line) {\n      width = Math.max(width, ctx.measureText(line).width + widthPadding);\n    };\n    ctx.save();\n    ctx.font = titleFont.string;\n    each(tooltip.title, maxLineWidth);\n    ctx.font = bodyFont.string;\n    each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth);\n    widthPadding = options.displayColors ? boxWidth + 2 + options.boxPadding : 0;\n    each(body, function (bodyItem) {\n      each(bodyItem.before, maxLineWidth);\n      each(bodyItem.lines, maxLineWidth);\n      each(bodyItem.after, maxLineWidth);\n    });\n    widthPadding = 0;\n    ctx.font = footerFont.string;\n    each(tooltip.footer, maxLineWidth);\n    ctx.restore();\n    width += padding.width;\n    return {\n      width: width,\n      height: height\n    };\n  }\n  function determineYAlign(chart, size) {\n    var y = size.y,\n      height = size.height;\n    if (y < height / 2) {\n      return 'top';\n    } else if (y > chart.height - height / 2) {\n      return 'bottom';\n    }\n    return 'center';\n  }\n  function doesNotFitWithAlign(xAlign, chart, options, size) {\n    var x = size.x,\n      width = size.width;\n    var caret = options.caretSize + options.caretPadding;\n    if (xAlign === 'left' && x + width + caret > chart.width) {\n      return true;\n    }\n    if (xAlign === 'right' && x - width - caret < 0) {\n      return true;\n    }\n  }\n  function determineXAlign(chart, options, size, yAlign) {\n    var x = size.x,\n      width = size.width;\n    var chartWidth = chart.width,\n      _chart$chartArea = chart.chartArea,\n      left = _chart$chartArea.left,\n      right = _chart$chartArea.right;\n    var xAlign = 'center';\n    if (yAlign === 'center') {\n      xAlign = x <= (left + right) / 2 ? 'left' : 'right';\n    } else if (x <= width / 2) {\n      xAlign = 'left';\n    } else if (x >= chartWidth - width / 2) {\n      xAlign = 'right';\n    }\n    if (doesNotFitWithAlign(xAlign, chart, options, size)) {\n      xAlign = 'center';\n    }\n    return xAlign;\n  }\n  function determineAlignment(chart, options, size) {\n    var yAlign = size.yAlign || options.yAlign || determineYAlign(chart, size);\n    return {\n      xAlign: size.xAlign || options.xAlign || determineXAlign(chart, options, size, yAlign),\n      yAlign: yAlign\n    };\n  }\n  function alignX(size, xAlign) {\n    var x = size.x,\n      width = size.width;\n    if (xAlign === 'right') {\n      x -= width;\n    } else if (xAlign === 'center') {\n      x -= width / 2;\n    }\n    return x;\n  }\n  function alignY(size, yAlign, paddingAndSize) {\n    var y = size.y,\n      height = size.height;\n    if (yAlign === 'top') {\n      y += paddingAndSize;\n    } else if (yAlign === 'bottom') {\n      y -= height + paddingAndSize;\n    } else {\n      y -= height / 2;\n    }\n    return y;\n  }\n  function getBackgroundPoint(options, size, alignment, chart) {\n    var caretSize = options.caretSize,\n      caretPadding = options.caretPadding,\n      cornerRadius = options.cornerRadius;\n    var xAlign = alignment.xAlign,\n      yAlign = alignment.yAlign;\n    var paddingAndSize = caretSize + caretPadding;\n    var _toTRBLCorners = toTRBLCorners(cornerRadius),\n      topLeft = _toTRBLCorners.topLeft,\n      topRight = _toTRBLCorners.topRight,\n      bottomLeft = _toTRBLCorners.bottomLeft,\n      bottomRight = _toTRBLCorners.bottomRight;\n    var x = alignX(size, xAlign);\n    var y = alignY(size, yAlign, paddingAndSize);\n    if (yAlign === 'center') {\n      if (xAlign === 'left') {\n        x += paddingAndSize;\n      } else if (xAlign === 'right') {\n        x -= paddingAndSize;\n      }\n    } else if (xAlign === 'left') {\n      x -= Math.max(topLeft, bottomLeft) + caretSize;\n    } else if (xAlign === 'right') {\n      x += Math.max(topRight, bottomRight) + caretSize;\n    }\n    return {\n      x: _limitValue(x, 0, chart.width - size.width),\n      y: _limitValue(y, 0, chart.height - size.height)\n    };\n  }\n  function getAlignedX(tooltip, align, options) {\n    var padding = toPadding(options.padding);\n    return align === 'center' ? tooltip.x + tooltip.width / 2 : align === 'right' ? tooltip.x + tooltip.width - padding.right : tooltip.x + padding.left;\n  }\n  function getBeforeAfterBodyLines(callback) {\n    return pushOrConcat([], splitNewlines(callback));\n  }\n  function createTooltipContext(parent, tooltip, tooltipItems) {\n    return createContext(parent, {\n      tooltip: tooltip,\n      tooltipItems: tooltipItems,\n      type: 'tooltip'\n    });\n  }\n  function overrideCallbacks(callbacks, context) {\n    var override = context && context.dataset && context.dataset.tooltip && context.dataset.tooltip.callbacks;\n    return override ? callbacks.override(override) : callbacks;\n  }\n  var defaultCallbacks = {\n    beforeTitle: noop,\n    title: function title(tooltipItems) {\n      if (tooltipItems.length > 0) {\n        var item = tooltipItems[0];\n        var labels = item.chart.data.labels;\n        var labelCount = labels ? labels.length : 0;\n        if (this && this.options && this.options.mode === 'dataset') {\n          return item.dataset.label || '';\n        } else if (item.label) {\n          return item.label;\n        } else if (labelCount > 0 && item.dataIndex < labelCount) {\n          return labels[item.dataIndex];\n        }\n      }\n      return '';\n    },\n    afterTitle: noop,\n    beforeBody: noop,\n    beforeLabel: noop,\n    label: function label(tooltipItem) {\n      if (this && this.options && this.options.mode === 'dataset') {\n        return tooltipItem.label + ': ' + tooltipItem.formattedValue || tooltipItem.formattedValue;\n      }\n      var label = tooltipItem.dataset.label || '';\n      if (label) {\n        label += ': ';\n      }\n      var value = tooltipItem.formattedValue;\n      if (!isNullOrUndef(value)) {\n        label += value;\n      }\n      return label;\n    },\n    labelColor: function labelColor(tooltipItem) {\n      var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n      var options = meta.controller.getStyle(tooltipItem.dataIndex);\n      return {\n        borderColor: options.borderColor,\n        backgroundColor: options.backgroundColor,\n        borderWidth: options.borderWidth,\n        borderDash: options.borderDash,\n        borderDashOffset: options.borderDashOffset,\n        borderRadius: 0\n      };\n    },\n    labelTextColor: function labelTextColor() {\n      return this.options.bodyColor;\n    },\n    labelPointStyle: function labelPointStyle(tooltipItem) {\n      var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n      var options = meta.controller.getStyle(tooltipItem.dataIndex);\n      return {\n        pointStyle: options.pointStyle,\n        rotation: options.rotation\n      };\n    },\n    afterLabel: noop,\n    afterBody: noop,\n    beforeFooter: noop,\n    footer: noop,\n    afterFooter: noop\n  };\n  function invokeCallbackWithFallback(callbacks, name, ctx, arg) {\n    var result = callbacks[name].call(ctx, arg);\n    if (typeof result === 'undefined') {\n      return defaultCallbacks[name].call(ctx, arg);\n    }\n    return result;\n  }\n  var Tooltip = /*#__PURE__*/function (_Element8) {\n    _inherits$w(Tooltip, _Element8);\n    var _super18 = _createSuper$w(Tooltip);\n    function Tooltip(config) {\n      var _this31;\n      _classCallCheck$x(this, Tooltip);\n      _this31 = _super18.call(this);\n      _this31.opacity = 0;\n      _this31._active = [];\n      _this31._eventPosition = undefined;\n      _this31._size = undefined;\n      _this31._cachedAnimations = undefined;\n      _this31._tooltipItems = [];\n      _this31.$animations = undefined;\n      _this31.$context = undefined;\n      _this31.chart = config.chart;\n      _this31.options = config.options;\n      _this31.dataPoints = undefined;\n      _this31.title = undefined;\n      _this31.beforeBody = undefined;\n      _this31.body = undefined;\n      _this31.afterBody = undefined;\n      _this31.footer = undefined;\n      _this31.xAlign = undefined;\n      _this31.yAlign = undefined;\n      _this31.x = undefined;\n      _this31.y = undefined;\n      _this31.height = undefined;\n      _this31.width = undefined;\n      _this31.caretX = undefined;\n      _this31.caretY = undefined;\n      _this31.labelColors = undefined;\n      _this31.labelPointStyles = undefined;\n      _this31.labelTextColors = undefined;\n      return _this31;\n    }\n    _createClass$x(Tooltip, [{\n      key: \"initialize\",\n      value: function initialize(options) {\n        this.options = options;\n        this._cachedAnimations = undefined;\n        this.$context = undefined;\n      }\n    }, {\n      key: \"_resolveAnimations\",\n      value: function _resolveAnimations() {\n        var cached = this._cachedAnimations;\n        if (cached) {\n          return cached;\n        }\n        var chart = this.chart;\n        var options = this.options.setContext(this.getContext());\n        var opts = options.enabled && chart.options.animation && options.animations;\n        var animations = new Animations(this.chart, opts);\n        if (opts._cacheable) {\n          this._cachedAnimations = Object.freeze(animations);\n        }\n        return animations;\n      }\n    }, {\n      key: \"getContext\",\n      value: function getContext() {\n        return this.$context || (this.$context = createTooltipContext(this.chart.getContext(), this, this._tooltipItems));\n      }\n    }, {\n      key: \"getTitle\",\n      value: function getTitle(context, options) {\n        var callbacks = options.callbacks;\n        var beforeTitle = invokeCallbackWithFallback(callbacks, 'beforeTitle', this, context);\n        var title = invokeCallbackWithFallback(callbacks, 'title', this, context);\n        var afterTitle = invokeCallbackWithFallback(callbacks, 'afterTitle', this, context);\n        var lines = [];\n        lines = pushOrConcat(lines, splitNewlines(beforeTitle));\n        lines = pushOrConcat(lines, splitNewlines(title));\n        lines = pushOrConcat(lines, splitNewlines(afterTitle));\n        return lines;\n      }\n    }, {\n      key: \"getBeforeBody\",\n      value: function getBeforeBody(tooltipItems, options) {\n        return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'beforeBody', this, tooltipItems));\n      }\n    }, {\n      key: \"getBody\",\n      value: function getBody(tooltipItems, options) {\n        var _this32 = this;\n        var callbacks = options.callbacks;\n        var bodyItems = [];\n        each(tooltipItems, function (context) {\n          var bodyItem = {\n            before: [],\n            lines: [],\n            after: []\n          };\n          var scoped = overrideCallbacks(callbacks, context);\n          pushOrConcat(bodyItem.before, splitNewlines(invokeCallbackWithFallback(scoped, 'beforeLabel', _this32, context)));\n          pushOrConcat(bodyItem.lines, invokeCallbackWithFallback(scoped, 'label', _this32, context));\n          pushOrConcat(bodyItem.after, splitNewlines(invokeCallbackWithFallback(scoped, 'afterLabel', _this32, context)));\n          bodyItems.push(bodyItem);\n        });\n        return bodyItems;\n      }\n    }, {\n      key: \"getAfterBody\",\n      value: function getAfterBody(tooltipItems, options) {\n        return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'afterBody', this, tooltipItems));\n      }\n    }, {\n      key: \"getFooter\",\n      value: function getFooter(tooltipItems, options) {\n        var callbacks = options.callbacks;\n        var beforeFooter = invokeCallbackWithFallback(callbacks, 'beforeFooter', this, tooltipItems);\n        var footer = invokeCallbackWithFallback(callbacks, 'footer', this, tooltipItems);\n        var afterFooter = invokeCallbackWithFallback(callbacks, 'afterFooter', this, tooltipItems);\n        var lines = [];\n        lines = pushOrConcat(lines, splitNewlines(beforeFooter));\n        lines = pushOrConcat(lines, splitNewlines(footer));\n        lines = pushOrConcat(lines, splitNewlines(afterFooter));\n        return lines;\n      }\n    }, {\n      key: \"_createItems\",\n      value: function _createItems(options) {\n        var _this33 = this;\n        var active = this._active;\n        var data = this.chart.data;\n        var labelColors = [];\n        var labelPointStyles = [];\n        var labelTextColors = [];\n        var tooltipItems = [];\n        var i, len;\n        for (i = 0, len = active.length; i < len; ++i) {\n          tooltipItems.push(createTooltipItem(this.chart, active[i]));\n        }\n        if (options.filter) {\n          tooltipItems = tooltipItems.filter(function (element, index, array) {\n            return options.filter(element, index, array, data);\n          });\n        }\n        if (options.itemSort) {\n          tooltipItems = tooltipItems.sort(function (a, b) {\n            return options.itemSort(a, b, data);\n          });\n        }\n        each(tooltipItems, function (context) {\n          var scoped = overrideCallbacks(options.callbacks, context);\n          labelColors.push(invokeCallbackWithFallback(scoped, 'labelColor', _this33, context));\n          labelPointStyles.push(invokeCallbackWithFallback(scoped, 'labelPointStyle', _this33, context));\n          labelTextColors.push(invokeCallbackWithFallback(scoped, 'labelTextColor', _this33, context));\n        });\n        this.labelColors = labelColors;\n        this.labelPointStyles = labelPointStyles;\n        this.labelTextColors = labelTextColors;\n        this.dataPoints = tooltipItems;\n        return tooltipItems;\n      }\n    }, {\n      key: \"update\",\n      value: function update(changed, replay) {\n        var options = this.options.setContext(this.getContext());\n        var active = this._active;\n        var properties;\n        var tooltipItems = [];\n        if (!active.length) {\n          if (this.opacity !== 0) {\n            properties = {\n              opacity: 0\n            };\n          }\n        } else {\n          var position = positioners[options.position].call(this, active, this._eventPosition);\n          tooltipItems = this._createItems(options);\n          this.title = this.getTitle(tooltipItems, options);\n          this.beforeBody = this.getBeforeBody(tooltipItems, options);\n          this.body = this.getBody(tooltipItems, options);\n          this.afterBody = this.getAfterBody(tooltipItems, options);\n          this.footer = this.getFooter(tooltipItems, options);\n          var size = this._size = getTooltipSize(this, options);\n          var positionAndSize = Object.assign({}, position, size);\n          var alignment = determineAlignment(this.chart, options, positionAndSize);\n          var backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart);\n          this.xAlign = alignment.xAlign;\n          this.yAlign = alignment.yAlign;\n          properties = {\n            opacity: 1,\n            x: backgroundPoint.x,\n            y: backgroundPoint.y,\n            width: size.width,\n            height: size.height,\n            caretX: position.x,\n            caretY: position.y\n          };\n        }\n        this._tooltipItems = tooltipItems;\n        this.$context = undefined;\n        if (properties) {\n          this._resolveAnimations().update(this, properties);\n        }\n        if (changed && options.external) {\n          options.external.call(this, {\n            chart: this.chart,\n            tooltip: this,\n            replay: replay\n          });\n        }\n      }\n    }, {\n      key: \"drawCaret\",\n      value: function drawCaret(tooltipPoint, ctx, size, options) {\n        var caretPosition = this.getCaretPosition(tooltipPoint, size, options);\n        ctx.lineTo(caretPosition.x1, caretPosition.y1);\n        ctx.lineTo(caretPosition.x2, caretPosition.y2);\n        ctx.lineTo(caretPosition.x3, caretPosition.y3);\n      }\n    }, {\n      key: \"getCaretPosition\",\n      value: function getCaretPosition(tooltipPoint, size, options) {\n        var xAlign = this.xAlign,\n          yAlign = this.yAlign;\n        var caretSize = options.caretSize,\n          cornerRadius = options.cornerRadius;\n        var _toTRBLCorners2 = toTRBLCorners(cornerRadius),\n          topLeft = _toTRBLCorners2.topLeft,\n          topRight = _toTRBLCorners2.topRight,\n          bottomLeft = _toTRBLCorners2.bottomLeft,\n          bottomRight = _toTRBLCorners2.bottomRight;\n        var ptX = tooltipPoint.x,\n          ptY = tooltipPoint.y;\n        var width = size.width,\n          height = size.height;\n        var x1, x2, x3, y1, y2, y3;\n        if (yAlign === 'center') {\n          y2 = ptY + height / 2;\n          if (xAlign === 'left') {\n            x1 = ptX;\n            x2 = x1 - caretSize;\n            y1 = y2 + caretSize;\n            y3 = y2 - caretSize;\n          } else {\n            x1 = ptX + width;\n            x2 = x1 + caretSize;\n            y1 = y2 - caretSize;\n            y3 = y2 + caretSize;\n          }\n          x3 = x1;\n        } else {\n          if (xAlign === 'left') {\n            x2 = ptX + Math.max(topLeft, bottomLeft) + caretSize;\n          } else if (xAlign === 'right') {\n            x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize;\n          } else {\n            x2 = this.caretX;\n          }\n          if (yAlign === 'top') {\n            y1 = ptY;\n            y2 = y1 - caretSize;\n            x1 = x2 - caretSize;\n            x3 = x2 + caretSize;\n          } else {\n            y1 = ptY + height;\n            y2 = y1 + caretSize;\n            x1 = x2 + caretSize;\n            x3 = x2 - caretSize;\n          }\n          y3 = y1;\n        }\n        return {\n          x1: x1,\n          x2: x2,\n          x3: x3,\n          y1: y1,\n          y2: y2,\n          y3: y3\n        };\n      }\n    }, {\n      key: \"drawTitle\",\n      value: function drawTitle(pt, ctx, options) {\n        var title = this.title;\n        var length = title.length;\n        var titleFont, titleSpacing, i;\n        if (length) {\n          var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n          pt.x = getAlignedX(this, options.titleAlign, options);\n          ctx.textAlign = rtlHelper.textAlign(options.titleAlign);\n          ctx.textBaseline = 'middle';\n          titleFont = toFont(options.titleFont);\n          titleSpacing = options.titleSpacing;\n          ctx.fillStyle = options.titleColor;\n          ctx.font = titleFont.string;\n          for (i = 0; i < length; ++i) {\n            ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFont.lineHeight / 2);\n            pt.y += titleFont.lineHeight + titleSpacing;\n            if (i + 1 === length) {\n              pt.y += options.titleMarginBottom - titleSpacing;\n            }\n          }\n        }\n      }\n    }, {\n      key: \"_drawColorBox\",\n      value: function _drawColorBox(ctx, pt, i, rtlHelper, options) {\n        var labelColors = this.labelColors[i];\n        var labelPointStyle = this.labelPointStyles[i];\n        var boxHeight = options.boxHeight,\n          boxWidth = options.boxWidth,\n          boxPadding = options.boxPadding;\n        var bodyFont = toFont(options.bodyFont);\n        var colorX = getAlignedX(this, 'left', options);\n        var rtlColorX = rtlHelper.x(colorX);\n        var yOffSet = boxHeight < bodyFont.lineHeight ? (bodyFont.lineHeight - boxHeight) / 2 : 0;\n        var colorY = pt.y + yOffSet;\n        if (options.usePointStyle) {\n          var drawOptions = {\n            radius: Math.min(boxWidth, boxHeight) / 2,\n            pointStyle: labelPointStyle.pointStyle,\n            rotation: labelPointStyle.rotation,\n            borderWidth: 1\n          };\n          var centerX = rtlHelper.leftForLtr(rtlColorX, boxWidth) + boxWidth / 2;\n          var centerY = colorY + boxHeight / 2;\n          ctx.strokeStyle = options.multiKeyBackground;\n          ctx.fillStyle = options.multiKeyBackground;\n          drawPoint(ctx, drawOptions, centerX, centerY);\n          ctx.strokeStyle = labelColors.borderColor;\n          ctx.fillStyle = labelColors.backgroundColor;\n          drawPoint(ctx, drawOptions, centerX, centerY);\n        } else {\n          ctx.lineWidth = isObject(labelColors.borderWidth) ? Math.max.apply(Math, _toConsumableArray(Object.values(labelColors.borderWidth))) : labelColors.borderWidth || 1;\n          ctx.strokeStyle = labelColors.borderColor;\n          ctx.setLineDash(labelColors.borderDash || []);\n          ctx.lineDashOffset = labelColors.borderDashOffset || 0;\n          var outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth - boxPadding);\n          var innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - boxPadding - 2);\n          var borderRadius = toTRBLCorners(labelColors.borderRadius);\n          if (Object.values(borderRadius).some(function (v) {\n            return v !== 0;\n          })) {\n            ctx.beginPath();\n            ctx.fillStyle = options.multiKeyBackground;\n            addRoundedRectPath(ctx, {\n              x: outerX,\n              y: colorY,\n              w: boxWidth,\n              h: boxHeight,\n              radius: borderRadius\n            });\n            ctx.fill();\n            ctx.stroke();\n            ctx.fillStyle = labelColors.backgroundColor;\n            ctx.beginPath();\n            addRoundedRectPath(ctx, {\n              x: innerX,\n              y: colorY + 1,\n              w: boxWidth - 2,\n              h: boxHeight - 2,\n              radius: borderRadius\n            });\n            ctx.fill();\n          } else {\n            ctx.fillStyle = options.multiKeyBackground;\n            ctx.fillRect(outerX, colorY, boxWidth, boxHeight);\n            ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);\n            ctx.fillStyle = labelColors.backgroundColor;\n            ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);\n          }\n        }\n        ctx.fillStyle = this.labelTextColors[i];\n      }\n    }, {\n      key: \"drawBody\",\n      value: function drawBody(pt, ctx, options) {\n        var body = this.body;\n        var bodySpacing = options.bodySpacing,\n          bodyAlign = options.bodyAlign,\n          displayColors = options.displayColors,\n          boxHeight = options.boxHeight,\n          boxWidth = options.boxWidth,\n          boxPadding = options.boxPadding;\n        var bodyFont = toFont(options.bodyFont);\n        var bodyLineHeight = bodyFont.lineHeight;\n        var xLinePadding = 0;\n        var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n        var fillLineOfText = function fillLineOfText(line) {\n          ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2);\n          pt.y += bodyLineHeight + bodySpacing;\n        };\n        var bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign);\n        var bodyItem, textColor, lines, i, j, ilen, jlen;\n        ctx.textAlign = bodyAlign;\n        ctx.textBaseline = 'middle';\n        ctx.font = bodyFont.string;\n        pt.x = getAlignedX(this, bodyAlignForCalculation, options);\n        ctx.fillStyle = options.bodyColor;\n        each(this.beforeBody, fillLineOfText);\n        xLinePadding = displayColors && bodyAlignForCalculation !== 'right' ? bodyAlign === 'center' ? boxWidth / 2 + boxPadding : boxWidth + 2 + boxPadding : 0;\n        for (i = 0, ilen = body.length; i < ilen; ++i) {\n          bodyItem = body[i];\n          textColor = this.labelTextColors[i];\n          ctx.fillStyle = textColor;\n          each(bodyItem.before, fillLineOfText);\n          lines = bodyItem.lines;\n          if (displayColors && lines.length) {\n            this._drawColorBox(ctx, pt, i, rtlHelper, options);\n            bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight);\n          }\n          for (j = 0, jlen = lines.length; j < jlen; ++j) {\n            fillLineOfText(lines[j]);\n            bodyLineHeight = bodyFont.lineHeight;\n          }\n          each(bodyItem.after, fillLineOfText);\n        }\n        xLinePadding = 0;\n        bodyLineHeight = bodyFont.lineHeight;\n        each(this.afterBody, fillLineOfText);\n        pt.y -= bodySpacing;\n      }\n    }, {\n      key: \"drawFooter\",\n      value: function drawFooter(pt, ctx, options) {\n        var footer = this.footer;\n        var length = footer.length;\n        var footerFont, i;\n        if (length) {\n          var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n          pt.x = getAlignedX(this, options.footerAlign, options);\n          pt.y += options.footerMarginTop;\n          ctx.textAlign = rtlHelper.textAlign(options.footerAlign);\n          ctx.textBaseline = 'middle';\n          footerFont = toFont(options.footerFont);\n          ctx.fillStyle = options.footerColor;\n          ctx.font = footerFont.string;\n          for (i = 0; i < length; ++i) {\n            ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFont.lineHeight / 2);\n            pt.y += footerFont.lineHeight + options.footerSpacing;\n          }\n        }\n      }\n    }, {\n      key: \"drawBackground\",\n      value: function drawBackground(pt, ctx, tooltipSize, options) {\n        var xAlign = this.xAlign,\n          yAlign = this.yAlign;\n        var x = pt.x,\n          y = pt.y;\n        var width = tooltipSize.width,\n          height = tooltipSize.height;\n        var _toTRBLCorners3 = toTRBLCorners(options.cornerRadius),\n          topLeft = _toTRBLCorners3.topLeft,\n          topRight = _toTRBLCorners3.topRight,\n          bottomLeft = _toTRBLCorners3.bottomLeft,\n          bottomRight = _toTRBLCorners3.bottomRight;\n        ctx.fillStyle = options.backgroundColor;\n        ctx.strokeStyle = options.borderColor;\n        ctx.lineWidth = options.borderWidth;\n        ctx.beginPath();\n        ctx.moveTo(x + topLeft, y);\n        if (yAlign === 'top') {\n          this.drawCaret(pt, ctx, tooltipSize, options);\n        }\n        ctx.lineTo(x + width - topRight, y);\n        ctx.quadraticCurveTo(x + width, y, x + width, y + topRight);\n        if (yAlign === 'center' && xAlign === 'right') {\n          this.drawCaret(pt, ctx, tooltipSize, options);\n        }\n        ctx.lineTo(x + width, y + height - bottomRight);\n        ctx.quadraticCurveTo(x + width, y + height, x + width - bottomRight, y + height);\n        if (yAlign === 'bottom') {\n          this.drawCaret(pt, ctx, tooltipSize, options);\n        }\n        ctx.lineTo(x + bottomLeft, y + height);\n        ctx.quadraticCurveTo(x, y + height, x, y + height - bottomLeft);\n        if (yAlign === 'center' && xAlign === 'left') {\n          this.drawCaret(pt, ctx, tooltipSize, options);\n        }\n        ctx.lineTo(x, y + topLeft);\n        ctx.quadraticCurveTo(x, y, x + topLeft, y);\n        ctx.closePath();\n        ctx.fill();\n        if (options.borderWidth > 0) {\n          ctx.stroke();\n        }\n      }\n    }, {\n      key: \"_updateAnimationTarget\",\n      value: function _updateAnimationTarget(options) {\n        var chart = this.chart;\n        var anims = this.$animations;\n        var animX = anims && anims.x;\n        var animY = anims && anims.y;\n        if (animX || animY) {\n          var position = positioners[options.position].call(this, this._active, this._eventPosition);\n          if (!position) {\n            return;\n          }\n          var size = this._size = getTooltipSize(this, options);\n          var positionAndSize = Object.assign({}, position, this._size);\n          var alignment = determineAlignment(chart, options, positionAndSize);\n          var point = getBackgroundPoint(options, positionAndSize, alignment, chart);\n          if (animX._to !== point.x || animY._to !== point.y) {\n            this.xAlign = alignment.xAlign;\n            this.yAlign = alignment.yAlign;\n            this.width = size.width;\n            this.height = size.height;\n            this.caretX = position.x;\n            this.caretY = position.y;\n            this._resolveAnimations().update(this, point);\n          }\n        }\n      }\n    }, {\n      key: \"_willRender\",\n      value: function _willRender() {\n        return !!this.opacity;\n      }\n    }, {\n      key: \"draw\",\n      value: function draw(ctx) {\n        var options = this.options.setContext(this.getContext());\n        var opacity = this.opacity;\n        if (!opacity) {\n          return;\n        }\n        this._updateAnimationTarget(options);\n        var tooltipSize = {\n          width: this.width,\n          height: this.height\n        };\n        var pt = {\n          x: this.x,\n          y: this.y\n        };\n        opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity;\n        var padding = toPadding(options.padding);\n        var hasTooltipContent = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;\n        if (options.enabled && hasTooltipContent) {\n          ctx.save();\n          ctx.globalAlpha = opacity;\n          this.drawBackground(pt, ctx, tooltipSize, options);\n          overrideTextDirection(ctx, options.textDirection);\n          pt.y += padding.top;\n          this.drawTitle(pt, ctx, options);\n          this.drawBody(pt, ctx, options);\n          this.drawFooter(pt, ctx, options);\n          restoreTextDirection(ctx, options.textDirection);\n          ctx.restore();\n        }\n      }\n    }, {\n      key: \"getActiveElements\",\n      value: function getActiveElements() {\n        return this._active || [];\n      }\n    }, {\n      key: \"setActiveElements\",\n      value: function setActiveElements(activeElements, eventPosition) {\n        var _this34 = this;\n        var lastActive = this._active;\n        var active = activeElements.map(function (_ref11) {\n          var datasetIndex = _ref11.datasetIndex,\n            index = _ref11.index;\n          var meta = _this34.chart.getDatasetMeta(datasetIndex);\n          if (!meta) {\n            throw new Error('Cannot find a dataset at index ' + datasetIndex);\n          }\n          return {\n            datasetIndex: datasetIndex,\n            element: meta.data[index],\n            index: index\n          };\n        });\n        var changed = !_elementsEqual(lastActive, active);\n        var positionChanged = this._positionChanged(active, eventPosition);\n        if (changed || positionChanged) {\n          this._active = active;\n          this._eventPosition = eventPosition;\n          this._ignoreReplayEvents = true;\n          this.update(true);\n        }\n      }\n    }, {\n      key: \"handleEvent\",\n      value: function handleEvent(e, replay) {\n        var inChartArea = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n        if (replay && this._ignoreReplayEvents) {\n          return false;\n        }\n        this._ignoreReplayEvents = false;\n        var options = this.options;\n        var lastActive = this._active || [];\n        var active = this._getActiveElements(e, lastActive, replay, inChartArea);\n        var positionChanged = this._positionChanged(active, e);\n        var changed = replay || !_elementsEqual(active, lastActive) || positionChanged;\n        if (changed) {\n          this._active = active;\n          if (options.enabled || options.external) {\n            this._eventPosition = {\n              x: e.x,\n              y: e.y\n            };\n            this.update(true, replay);\n          }\n        }\n        return changed;\n      }\n    }, {\n      key: \"_getActiveElements\",\n      value: function _getActiveElements(e, lastActive, replay, inChartArea) {\n        var options = this.options;\n        if (e.type === 'mouseout') {\n          return [];\n        }\n        if (!inChartArea) {\n          return lastActive;\n        }\n        var active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);\n        if (options.reverse) {\n          active.reverse();\n        }\n        return active;\n      }\n    }, {\n      key: \"_positionChanged\",\n      value: function _positionChanged(active, e) {\n        var caretX = this.caretX,\n          caretY = this.caretY,\n          options = this.options;\n        var position = positioners[options.position].call(this, active, e);\n        return position !== false && (caretX !== position.x || caretY !== position.y);\n      }\n    }]);\n    return Tooltip;\n  }(Element);\n  _defineProperty$w(Tooltip, \"positioners\", positioners);\n  var plugin_tooltip = {\n    id: 'tooltip',\n    _element: Tooltip,\n    positioners: positioners,\n    afterInit: function afterInit(chart, _args, options) {\n      if (options) {\n        chart.tooltip = new Tooltip({\n          chart: chart,\n          options: options\n        });\n      }\n    },\n    beforeUpdate: function beforeUpdate(chart, _args, options) {\n      if (chart.tooltip) {\n        chart.tooltip.initialize(options);\n      }\n    },\n    reset: function reset(chart, _args, options) {\n      if (chart.tooltip) {\n        chart.tooltip.initialize(options);\n      }\n    },\n    afterDraw: function afterDraw(chart) {\n      var tooltip = chart.tooltip;\n      if (tooltip && tooltip._willRender()) {\n        var args = {\n          tooltip: tooltip\n        };\n        if (chart.notifyPlugins('beforeTooltipDraw', _objectSpread2(_objectSpread2({}, args), {}, {\n          cancelable: true\n        })) === false) {\n          return;\n        }\n        tooltip.draw(chart.ctx);\n        chart.notifyPlugins('afterTooltipDraw', args);\n      }\n    },\n    afterEvent: function afterEvent(chart, args) {\n      if (chart.tooltip) {\n        var useFinalPosition = args.replay;\n        if (chart.tooltip.handleEvent(args.event, useFinalPosition, args.inChartArea)) {\n          args.changed = true;\n        }\n      }\n    },\n    defaults: {\n      enabled: true,\n      external: null,\n      position: 'average',\n      backgroundColor: 'rgba(0,0,0,0.8)',\n      titleColor: '#fff',\n      titleFont: {\n        weight: 'bold'\n      },\n      titleSpacing: 2,\n      titleMarginBottom: 6,\n      titleAlign: 'left',\n      bodyColor: '#fff',\n      bodySpacing: 2,\n      bodyFont: {},\n      bodyAlign: 'left',\n      footerColor: '#fff',\n      footerSpacing: 2,\n      footerMarginTop: 6,\n      footerFont: {\n        weight: 'bold'\n      },\n      footerAlign: 'left',\n      padding: 6,\n      caretPadding: 2,\n      caretSize: 5,\n      cornerRadius: 6,\n      boxHeight: function boxHeight(ctx, opts) {\n        return opts.bodyFont.size;\n      },\n      boxWidth: function boxWidth(ctx, opts) {\n        return opts.bodyFont.size;\n      },\n      multiKeyBackground: '#fff',\n      displayColors: true,\n      boxPadding: 0,\n      borderColor: 'rgba(0,0,0,0)',\n      borderWidth: 0,\n      animation: {\n        duration: 400,\n        easing: 'easeOutQuart'\n      },\n      animations: {\n        numbers: {\n          type: 'number',\n          properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY']\n        },\n        opacity: {\n          easing: 'linear',\n          duration: 200\n        }\n      },\n      callbacks: defaultCallbacks\n    },\n    defaultRoutes: {\n      bodyFont: 'font',\n      footerFont: 'font',\n      titleFont: 'font'\n    },\n    descriptors: {\n      _scriptable: function _scriptable(name) {\n        return name !== 'filter' && name !== 'itemSort' && name !== 'external';\n      },\n      _indexable: false,\n      callbacks: {\n        _scriptable: false,\n        _indexable: false\n      },\n      animation: {\n        _fallback: false\n      },\n      animations: {\n        _fallback: 'animation'\n      }\n    },\n    additionalOptionScopes: ['interaction']\n  };\n  var plugins = /*#__PURE__*/Object.freeze({\n    __proto__: null,\n    Colors: plugin_colors,\n    Decimation: plugin_decimation,\n    Filler: index,\n    Legend: plugin_legend,\n    SubTitle: plugin_subtitle,\n    Title: plugin_title,\n    Tooltip: plugin_tooltip\n  });\n  var addIfString = function addIfString(labels, raw, index, addedLabels) {\n    if (typeof raw === 'string') {\n      index = labels.push(raw) - 1;\n      addedLabels.unshift({\n        index: index,\n        label: raw\n      });\n    } else if (isNaN(raw)) {\n      index = null;\n    }\n    return index;\n  };\n  function findOrAddLabel(labels, raw, index, addedLabels) {\n    var first = labels.indexOf(raw);\n    if (first === -1) {\n      return addIfString(labels, raw, index, addedLabels);\n    }\n    var last = labels.lastIndexOf(raw);\n    return first !== last ? index : first;\n  }\n  var validIndex = function validIndex(index, max) {\n    return index === null ? null : _limitValue(Math.round(index), 0, max);\n  };\n  function _getLabelForValue(value) {\n    var labels = this.getLabels();\n    if (value >= 0 && value < labels.length) {\n      return labels[value];\n    }\n    return value;\n  }\n  var CategoryScale = /*#__PURE__*/function (_Scale) {\n    _inherits$w(CategoryScale, _Scale);\n    var _super19 = _createSuper$w(CategoryScale);\n    function CategoryScale(cfg) {\n      var _this35;\n      _classCallCheck$x(this, CategoryScale);\n      _this35 = _super19.call(this, cfg);\n      _this35._startValue = undefined;\n      _this35._valueRange = 0;\n      _this35._addedLabels = [];\n      return _this35;\n    }\n    _createClass$x(CategoryScale, [{\n      key: \"init\",\n      value: function init(scaleOptions) {\n        var added = this._addedLabels;\n        if (added.length) {\n          var labels = this.getLabels();\n          var _iterator25 = _createForOfIteratorHelper$1(added),\n            _step25;\n          try {\n            for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {\n              var _step25$value = _step25.value,\n                _index3 = _step25$value.index,\n                label = _step25$value.label;\n              if (labels[_index3] === label) {\n                labels.splice(_index3, 1);\n              }\n            }\n          } catch (err) {\n            _iterator25.e(err);\n          } finally {\n            _iterator25.f();\n          }\n          this._addedLabels = [];\n        }\n        _get(_getPrototypeOf$w(CategoryScale.prototype), \"init\", this).call(this, scaleOptions);\n      }\n    }, {\n      key: \"parse\",\n      value: function parse(raw, index) {\n        if (isNullOrUndef(raw)) {\n          return null;\n        }\n        var labels = this.getLabels();\n        index = isFinite(index) && labels[index] === raw ? index : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels);\n        return validIndex(index, labels.length - 1);\n      }\n    }, {\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {\n        var _this$getUserBounds2 = this.getUserBounds(),\n          minDefined = _this$getUserBounds2.minDefined,\n          maxDefined = _this$getUserBounds2.maxDefined;\n        var _this$getMinMax = this.getMinMax(true),\n          min = _this$getMinMax.min,\n          max = _this$getMinMax.max;\n        if (this.options.bounds === 'ticks') {\n          if (!minDefined) {\n            min = 0;\n          }\n          if (!maxDefined) {\n            max = this.getLabels().length - 1;\n          }\n        }\n        this.min = min;\n        this.max = max;\n      }\n    }, {\n      key: \"buildTicks\",\n      value: function buildTicks() {\n        var min = this.min;\n        var max = this.max;\n        var offset = this.options.offset;\n        var ticks = [];\n        var labels = this.getLabels();\n        labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1);\n        this._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1);\n        this._startValue = this.min - (offset ? 0.5 : 0);\n        for (var value = min; value <= max; value++) {\n          ticks.push({\n            value: value\n          });\n        }\n        return ticks;\n      }\n    }, {\n      key: \"getLabelForValue\",\n      value: function getLabelForValue(value) {\n        return _getLabelForValue.call(this, value);\n      }\n    }, {\n      key: \"configure\",\n      value: function configure() {\n        _get(_getPrototypeOf$w(CategoryScale.prototype), \"configure\", this).call(this);\n        if (!this.isHorizontal()) {\n          this._reversePixels = !this._reversePixels;\n        }\n      }\n    }, {\n      key: \"getPixelForValue\",\n      value: function getPixelForValue(value) {\n        if (typeof value !== 'number') {\n          value = this.parse(value);\n        }\n        return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n      }\n    }, {\n      key: \"getPixelForTick\",\n      value: function getPixelForTick(index) {\n        var ticks = this.ticks;\n        if (index < 0 || index > ticks.length - 1) {\n          return null;\n        }\n        return this.getPixelForValue(ticks[index].value);\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {\n        return Math.round(this._startValue + this.getDecimalForPixel(pixel) * this._valueRange);\n      }\n    }, {\n      key: \"getBasePixel\",\n      value: function getBasePixel() {\n        return this.bottom;\n      }\n    }]);\n    return CategoryScale;\n  }(Scale);\n  _defineProperty$w(CategoryScale, \"id\", 'category');\n  _defineProperty$w(CategoryScale, \"defaults\", {\n    ticks: {\n      callback: _getLabelForValue\n    }\n  });\n  function generateTicks$1(generationOptions, dataRange) {\n    var ticks = [];\n    var MIN_SPACING = 1e-14;\n    var bounds = generationOptions.bounds,\n      step = generationOptions.step,\n      min = generationOptions.min,\n      max = generationOptions.max,\n      precision = generationOptions.precision,\n      count = generationOptions.count,\n      maxTicks = generationOptions.maxTicks,\n      maxDigits = generationOptions.maxDigits,\n      includeBounds = generationOptions.includeBounds;\n    var unit = step || 1;\n    var maxSpaces = maxTicks - 1;\n    var rmin = dataRange.min,\n      rmax = dataRange.max;\n    var minDefined = !isNullOrUndef(min);\n    var maxDefined = !isNullOrUndef(max);\n    var countDefined = !isNullOrUndef(count);\n    var minSpacing = (rmax - rmin) / (maxDigits + 1);\n    var spacing = niceNum((rmax - rmin) / maxSpaces / unit) * unit;\n    var factor, niceMin, niceMax, numSpaces;\n    if (spacing < MIN_SPACING && !minDefined && !maxDefined) {\n      return [{\n        value: rmin\n      }, {\n        value: rmax\n      }];\n    }\n    numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing);\n    if (numSpaces > maxSpaces) {\n      spacing = niceNum(numSpaces * spacing / maxSpaces / unit) * unit;\n    }\n    if (!isNullOrUndef(precision)) {\n      factor = Math.pow(10, precision);\n      spacing = Math.ceil(spacing * factor) / factor;\n    }\n    if (bounds === 'ticks') {\n      niceMin = Math.floor(rmin / spacing) * spacing;\n      niceMax = Math.ceil(rmax / spacing) * spacing;\n    } else {\n      niceMin = rmin;\n      niceMax = rmax;\n    }\n    if (minDefined && maxDefined && step && almostWhole((max - min) / step, spacing / 1000)) {\n      numSpaces = Math.round(Math.min((max - min) / spacing, maxTicks));\n      spacing = (max - min) / numSpaces;\n      niceMin = min;\n      niceMax = max;\n    } else if (countDefined) {\n      niceMin = minDefined ? min : niceMin;\n      niceMax = maxDefined ? max : niceMax;\n      numSpaces = count - 1;\n      spacing = (niceMax - niceMin) / numSpaces;\n    } else {\n      numSpaces = (niceMax - niceMin) / spacing;\n      if (almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {\n        numSpaces = Math.round(numSpaces);\n      } else {\n        numSpaces = Math.ceil(numSpaces);\n      }\n    }\n    var decimalPlaces = Math.max(_decimalPlaces(spacing), _decimalPlaces(niceMin));\n    factor = Math.pow(10, isNullOrUndef(precision) ? decimalPlaces : precision);\n    niceMin = Math.round(niceMin * factor) / factor;\n    niceMax = Math.round(niceMax * factor) / factor;\n    var j = 0;\n    if (minDefined) {\n      if (includeBounds && niceMin !== min) {\n        ticks.push({\n          value: min\n        });\n        if (niceMin < min) {\n          j++;\n        }\n        if (almostEquals(Math.round((niceMin + j * spacing) * factor) / factor, min, relativeLabelSize(min, minSpacing, generationOptions))) {\n          j++;\n        }\n      } else if (niceMin < min) {\n        j++;\n      }\n    }\n    for (; j < numSpaces; ++j) {\n      ticks.push({\n        value: Math.round((niceMin + j * spacing) * factor) / factor\n      });\n    }\n    if (maxDefined && includeBounds && niceMax !== max) {\n      if (ticks.length && almostEquals(ticks[ticks.length - 1].value, max, relativeLabelSize(max, minSpacing, generationOptions))) {\n        ticks[ticks.length - 1].value = max;\n      } else {\n        ticks.push({\n          value: max\n        });\n      }\n    } else if (!maxDefined || niceMax === max) {\n      ticks.push({\n        value: niceMax\n      });\n    }\n    return ticks;\n  }\n  function relativeLabelSize(value, minSpacing, _ref12) {\n    var horizontal = _ref12.horizontal,\n      minRotation = _ref12.minRotation;\n    var rad = toRadians(minRotation);\n    var ratio = (horizontal ? Math.sin(rad) : Math.cos(rad)) || 0.001;\n    var length = 0.75 * minSpacing * ('' + value).length;\n    return Math.min(minSpacing / ratio, length);\n  }\n  var LinearScaleBase = /*#__PURE__*/function (_Scale2) {\n    _inherits$w(LinearScaleBase, _Scale2);\n    var _super20 = _createSuper$w(LinearScaleBase);\n    function LinearScaleBase(cfg) {\n      var _this36;\n      _classCallCheck$x(this, LinearScaleBase);\n      _this36 = _super20.call(this, cfg);\n      _this36.start = undefined;\n      _this36.end = undefined;\n      _this36._startValue = undefined;\n      _this36._endValue = undefined;\n      _this36._valueRange = 0;\n      return _this36;\n    }\n    _createClass$x(LinearScaleBase, [{\n      key: \"parse\",\n      value: function parse(raw, index) {\n        if (isNullOrUndef(raw)) {\n          return null;\n        }\n        if ((typeof raw === 'number' || raw instanceof Number) && !isFinite(+raw)) {\n          return null;\n        }\n        return +raw;\n      }\n    }, {\n      key: \"handleTickRangeOptions\",\n      value: function handleTickRangeOptions() {\n        var beginAtZero = this.options.beginAtZero;\n        var _this$getUserBounds3 = this.getUserBounds(),\n          minDefined = _this$getUserBounds3.minDefined,\n          maxDefined = _this$getUserBounds3.maxDefined;\n        var min = this.min,\n          max = this.max;\n        var setMin = function setMin(v) {\n          return min = minDefined ? min : v;\n        };\n        var setMax = function setMax(v) {\n          return max = maxDefined ? max : v;\n        };\n        if (beginAtZero) {\n          var minSign = sign(min);\n          var maxSign = sign(max);\n          if (minSign < 0 && maxSign < 0) {\n            setMax(0);\n          } else if (minSign > 0 && maxSign > 0) {\n            setMin(0);\n          }\n        }\n        if (min === max) {\n          var offset = max === 0 ? 1 : Math.abs(max * 0.05);\n          setMax(max + offset);\n          if (!beginAtZero) {\n            setMin(min - offset);\n          }\n        }\n        this.min = min;\n        this.max = max;\n      }\n    }, {\n      key: \"getTickLimit\",\n      value: function getTickLimit() {\n        var tickOpts = this.options.ticks;\n        var maxTicksLimit = tickOpts.maxTicksLimit,\n          stepSize = tickOpts.stepSize;\n        var maxTicks;\n        if (stepSize) {\n          maxTicks = Math.ceil(this.max / stepSize) - Math.floor(this.min / stepSize) + 1;\n          if (maxTicks > 1000) {\n            console.warn(\"scales.\".concat(this.id, \".ticks.stepSize: \").concat(stepSize, \" would result generating up to \").concat(maxTicks, \" ticks. Limiting to 1000.\"));\n            maxTicks = 1000;\n          }\n        } else {\n          maxTicks = this.computeTickLimit();\n          maxTicksLimit = maxTicksLimit || 11;\n        }\n        if (maxTicksLimit) {\n          maxTicks = Math.min(maxTicksLimit, maxTicks);\n        }\n        return maxTicks;\n      }\n    }, {\n      key: \"computeTickLimit\",\n      value: function computeTickLimit() {\n        return Number.POSITIVE_INFINITY;\n      }\n    }, {\n      key: \"buildTicks\",\n      value: function buildTicks() {\n        var opts = this.options;\n        var tickOpts = opts.ticks;\n        var maxTicks = this.getTickLimit();\n        maxTicks = Math.max(2, maxTicks);\n        var numericGeneratorOptions = {\n          maxTicks: maxTicks,\n          bounds: opts.bounds,\n          min: opts.min,\n          max: opts.max,\n          precision: tickOpts.precision,\n          step: tickOpts.stepSize,\n          count: tickOpts.count,\n          maxDigits: this._maxDigits(),\n          horizontal: this.isHorizontal(),\n          minRotation: tickOpts.minRotation || 0,\n          includeBounds: tickOpts.includeBounds !== false\n        };\n        var dataRange = this._range || this;\n        var ticks = generateTicks$1(numericGeneratorOptions, dataRange);\n        if (opts.bounds === 'ticks') {\n          _setMinAndMaxByKey(ticks, this, 'value');\n        }\n        if (opts.reverse) {\n          ticks.reverse();\n          this.start = this.max;\n          this.end = this.min;\n        } else {\n          this.start = this.min;\n          this.end = this.max;\n        }\n        return ticks;\n      }\n    }, {\n      key: \"configure\",\n      value: function configure() {\n        var ticks = this.ticks;\n        var start = this.min;\n        var end = this.max;\n        _get(_getPrototypeOf$w(LinearScaleBase.prototype), \"configure\", this).call(this);\n        if (this.options.offset && ticks.length) {\n          var offset = (end - start) / Math.max(ticks.length - 1, 1) / 2;\n          start -= offset;\n          end += offset;\n        }\n        this._startValue = start;\n        this._endValue = end;\n        this._valueRange = end - start;\n      }\n    }, {\n      key: \"getLabelForValue\",\n      value: function getLabelForValue(value) {\n        return formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n      }\n    }]);\n    return LinearScaleBase;\n  }(Scale);\n  var LinearScale = /*#__PURE__*/function (_LinearScaleBase) {\n    _inherits$w(LinearScale, _LinearScaleBase);\n    var _super21 = _createSuper$w(LinearScale);\n    function LinearScale() {\n      _classCallCheck$x(this, LinearScale);\n      return _super21.apply(this, arguments);\n    }\n    _createClass$x(LinearScale, [{\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {\n        var _this$getMinMax2 = this.getMinMax(true),\n          min = _this$getMinMax2.min,\n          max = _this$getMinMax2.max;\n        this.min = isNumberFinite(min) ? min : 0;\n        this.max = isNumberFinite(max) ? max : 1;\n        this.handleTickRangeOptions();\n      }\n    }, {\n      key: \"computeTickLimit\",\n      value: function computeTickLimit() {\n        var horizontal = this.isHorizontal();\n        var length = horizontal ? this.width : this.height;\n        var minRotation = toRadians(this.options.ticks.minRotation);\n        var ratio = (horizontal ? Math.sin(minRotation) : Math.cos(minRotation)) || 0.001;\n        var tickFont = this._resolveTickFontOptions(0);\n        return Math.ceil(length / Math.min(40, tickFont.lineHeight / ratio));\n      }\n    }, {\n      key: \"getPixelForValue\",\n      value: function getPixelForValue(value) {\n        return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {\n        return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange;\n      }\n    }]);\n    return LinearScale;\n  }(LinearScaleBase);\n  _defineProperty$w(LinearScale, \"id\", 'linear');\n  _defineProperty$w(LinearScale, \"defaults\", {\n    ticks: {\n      callback: Ticks.formatters.numeric\n    }\n  });\n  var log10Floor = function log10Floor(v) {\n    return Math.floor(log10(v));\n  };\n  var changeExponent = function changeExponent(v, m) {\n    return Math.pow(10, log10Floor(v) + m);\n  };\n  function isMajor(tickVal) {\n    var remain = tickVal / Math.pow(10, log10Floor(tickVal));\n    return remain === 1;\n  }\n  function steps(min, max, rangeExp) {\n    var rangeStep = Math.pow(10, rangeExp);\n    var start = Math.floor(min / rangeStep);\n    var end = Math.ceil(max / rangeStep);\n    return end - start;\n  }\n  function startExp(min, max) {\n    var range = max - min;\n    var rangeExp = log10Floor(range);\n    while (steps(min, max, rangeExp) > 10) {\n      rangeExp++;\n    }\n    while (steps(min, max, rangeExp) < 10) {\n      rangeExp--;\n    }\n    return Math.min(rangeExp, log10Floor(min));\n  }\n  function generateTicks(generationOptions, _ref13) {\n    var min = _ref13.min,\n      max = _ref13.max;\n    min = finiteOrDefault(generationOptions.min, min);\n    var ticks = [];\n    var minExp = log10Floor(min);\n    var exp = startExp(min, max);\n    var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;\n    var stepSize = Math.pow(10, exp);\n    var base = minExp > exp ? Math.pow(10, minExp) : 0;\n    var start = Math.round((min - base) * precision) / precision;\n    var offset = Math.floor((min - base) / stepSize / 10) * stepSize * 10;\n    var significand = Math.floor((start - offset) / Math.pow(10, exp));\n    var value = finiteOrDefault(generationOptions.min, Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision);\n    while (value < max) {\n      ticks.push({\n        value: value,\n        major: isMajor(value),\n        significand: significand\n      });\n      if (significand >= 10) {\n        significand = significand < 15 ? 15 : 20;\n      } else {\n        significand++;\n      }\n      if (significand >= 20) {\n        exp++;\n        significand = 2;\n        precision = exp >= 0 ? 1 : precision;\n      }\n      value = Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision;\n    }\n    var lastTick = finiteOrDefault(generationOptions.max, value);\n    ticks.push({\n      value: lastTick,\n      major: isMajor(lastTick),\n      significand: significand\n    });\n    return ticks;\n  }\n  var LogarithmicScale = /*#__PURE__*/function (_Scale3) {\n    _inherits$w(LogarithmicScale, _Scale3);\n    var _super22 = _createSuper$w(LogarithmicScale);\n    function LogarithmicScale(cfg) {\n      var _this37;\n      _classCallCheck$x(this, LogarithmicScale);\n      _this37 = _super22.call(this, cfg);\n      _this37.start = undefined;\n      _this37.end = undefined;\n      _this37._startValue = undefined;\n      _this37._valueRange = 0;\n      return _this37;\n    }\n    _createClass$x(LogarithmicScale, [{\n      key: \"parse\",\n      value: function parse(raw, index) {\n        var value = LinearScaleBase.prototype.parse.apply(this, [raw, index]);\n        if (value === 0) {\n          this._zero = true;\n          return undefined;\n        }\n        return isNumberFinite(value) && value > 0 ? value : null;\n      }\n    }, {\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {\n        var _this$getMinMax3 = this.getMinMax(true),\n          min = _this$getMinMax3.min,\n          max = _this$getMinMax3.max;\n        this.min = isNumberFinite(min) ? Math.max(0, min) : null;\n        this.max = isNumberFinite(max) ? Math.max(0, max) : null;\n        if (this.options.beginAtZero) {\n          this._zero = true;\n        }\n        if (this._zero && this.min !== this._suggestedMin && !isNumberFinite(this._userMin)) {\n          this.min = min === changeExponent(this.min, 0) ? changeExponent(this.min, -1) : changeExponent(this.min, 0);\n        }\n        this.handleTickRangeOptions();\n      }\n    }, {\n      key: \"handleTickRangeOptions\",\n      value: function handleTickRangeOptions() {\n        var _this$getUserBounds4 = this.getUserBounds(),\n          minDefined = _this$getUserBounds4.minDefined,\n          maxDefined = _this$getUserBounds4.maxDefined;\n        var min = this.min;\n        var max = this.max;\n        var setMin = function setMin(v) {\n          return min = minDefined ? min : v;\n        };\n        var setMax = function setMax(v) {\n          return max = maxDefined ? max : v;\n        };\n        if (min === max) {\n          if (min <= 0) {\n            setMin(1);\n            setMax(10);\n          } else {\n            setMin(changeExponent(min, -1));\n            setMax(changeExponent(max, +1));\n          }\n        }\n        if (min <= 0) {\n          setMin(changeExponent(max, -1));\n        }\n        if (max <= 0) {\n          setMax(changeExponent(min, +1));\n        }\n        this.min = min;\n        this.max = max;\n      }\n    }, {\n      key: \"buildTicks\",\n      value: function buildTicks() {\n        var opts = this.options;\n        var generationOptions = {\n          min: this._userMin,\n          max: this._userMax\n        };\n        var ticks = generateTicks(generationOptions, this);\n        if (opts.bounds === 'ticks') {\n          _setMinAndMaxByKey(ticks, this, 'value');\n        }\n        if (opts.reverse) {\n          ticks.reverse();\n          this.start = this.max;\n          this.end = this.min;\n        } else {\n          this.start = this.min;\n          this.end = this.max;\n        }\n        return ticks;\n      }\n    }, {\n      key: \"getLabelForValue\",\n      value: function getLabelForValue(value) {\n        return value === undefined ? '0' : formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n      }\n    }, {\n      key: \"configure\",\n      value: function configure() {\n        var start = this.min;\n        _get(_getPrototypeOf$w(LogarithmicScale.prototype), \"configure\", this).call(this);\n        this._startValue = log10(start);\n        this._valueRange = log10(this.max) - log10(start);\n      }\n    }, {\n      key: \"getPixelForValue\",\n      value: function getPixelForValue(value) {\n        if (value === undefined || value === 0) {\n          value = this.min;\n        }\n        if (value === null || isNaN(value)) {\n          return NaN;\n        }\n        return this.getPixelForDecimal(value === this.min ? 0 : (log10(value) - this._startValue) / this._valueRange);\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {\n        var decimal = this.getDecimalForPixel(pixel);\n        return Math.pow(10, this._startValue + decimal * this._valueRange);\n      }\n    }]);\n    return LogarithmicScale;\n  }(Scale);\n  _defineProperty$w(LogarithmicScale, \"id\", 'logarithmic');\n  _defineProperty$w(LogarithmicScale, \"defaults\", {\n    ticks: {\n      callback: Ticks.formatters.logarithmic,\n      major: {\n        enabled: true\n      }\n    }\n  });\n  function getTickBackdropHeight(opts) {\n    var tickOpts = opts.ticks;\n    if (tickOpts.display && opts.display) {\n      var padding = toPadding(tickOpts.backdropPadding);\n      return valueOrDefault(tickOpts.font && tickOpts.font.size, defaults.font.size) + padding.height;\n    }\n    return 0;\n  }\n  function measureLabelSize(ctx, font, label) {\n    label = isArray(label) ? label : [label];\n    return {\n      w: _longestText(ctx, font.string, label),\n      h: label.length * font.lineHeight\n    };\n  }\n  function determineLimits(angle, pos, size, min, max) {\n    if (angle === min || angle === max) {\n      return {\n        start: pos - size / 2,\n        end: pos + size / 2\n      };\n    } else if (angle < min || angle > max) {\n      return {\n        start: pos - size,\n        end: pos\n      };\n    }\n    return {\n      start: pos,\n      end: pos + size\n    };\n  }\n  function fitWithPointLabels(scale) {\n    var orig = {\n      l: scale.left + scale._padding.left,\n      r: scale.right - scale._padding.right,\n      t: scale.top + scale._padding.top,\n      b: scale.bottom - scale._padding.bottom\n    };\n    var limits = Object.assign({}, orig);\n    var labelSizes = [];\n    var padding = [];\n    var valueCount = scale._pointLabels.length;\n    var pointLabelOpts = scale.options.pointLabels;\n    var additionalAngle = pointLabelOpts.centerPointLabels ? PI / valueCount : 0;\n    for (var i = 0; i < valueCount; i++) {\n      var opts = pointLabelOpts.setContext(scale.getPointLabelContext(i));\n      padding[i] = opts.padding;\n      var pointPosition = scale.getPointPosition(i, scale.drawingArea + padding[i], additionalAngle);\n      var plFont = toFont(opts.font);\n      var textSize = measureLabelSize(scale.ctx, plFont, scale._pointLabels[i]);\n      labelSizes[i] = textSize;\n      var angleRadians = _normalizeAngle(scale.getIndexAngle(i) + additionalAngle);\n      var angle = Math.round(toDegrees(angleRadians));\n      var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);\n      var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);\n      updateLimits(limits, orig, angleRadians, hLimits, vLimits);\n    }\n    scale.setCenterPoint(orig.l - limits.l, limits.r - orig.r, orig.t - limits.t, limits.b - orig.b);\n    scale._pointLabelItems = buildPointLabelItems(scale, labelSizes, padding);\n  }\n  function updateLimits(limits, orig, angle, hLimits, vLimits) {\n    var sin = Math.abs(Math.sin(angle));\n    var cos = Math.abs(Math.cos(angle));\n    var x = 0;\n    var y = 0;\n    if (hLimits.start < orig.l) {\n      x = (orig.l - hLimits.start) / sin;\n      limits.l = Math.min(limits.l, orig.l - x);\n    } else if (hLimits.end > orig.r) {\n      x = (hLimits.end - orig.r) / sin;\n      limits.r = Math.max(limits.r, orig.r + x);\n    }\n    if (vLimits.start < orig.t) {\n      y = (orig.t - vLimits.start) / cos;\n      limits.t = Math.min(limits.t, orig.t - y);\n    } else if (vLimits.end > orig.b) {\n      y = (vLimits.end - orig.b) / cos;\n      limits.b = Math.max(limits.b, orig.b + y);\n    }\n  }\n  function buildPointLabelItems(scale, labelSizes, padding) {\n    var items = [];\n    var valueCount = scale._pointLabels.length;\n    var opts = scale.options;\n    var extra = getTickBackdropHeight(opts) / 2;\n    var outerDistance = scale.drawingArea;\n    var additionalAngle = opts.pointLabels.centerPointLabels ? PI / valueCount : 0;\n    for (var i = 0; i < valueCount; i++) {\n      var pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + padding[i], additionalAngle);\n      var angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));\n      var size = labelSizes[i];\n      var y = yForAngle(pointLabelPosition.y, size.h, angle);\n      var textAlign = getTextAlignForAngle(angle);\n      var left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);\n      items.push({\n        x: pointLabelPosition.x,\n        y: y,\n        textAlign: textAlign,\n        left: left,\n        top: y,\n        right: left + size.w,\n        bottom: y + size.h\n      });\n    }\n    return items;\n  }\n  function getTextAlignForAngle(angle) {\n    if (angle === 0 || angle === 180) {\n      return 'center';\n    } else if (angle < 180) {\n      return 'left';\n    }\n    return 'right';\n  }\n  function leftForTextAlign(x, w, align) {\n    if (align === 'right') {\n      x -= w;\n    } else if (align === 'center') {\n      x -= w / 2;\n    }\n    return x;\n  }\n  function yForAngle(y, h, angle) {\n    if (angle === 90 || angle === 270) {\n      y -= h / 2;\n    } else if (angle > 270 || angle < 90) {\n      y -= h;\n    }\n    return y;\n  }\n  function drawPointLabels(scale, labelCount) {\n    var ctx = scale.ctx,\n      pointLabels = scale.options.pointLabels;\n    for (var i = labelCount - 1; i >= 0; i--) {\n      var optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));\n      var plFont = toFont(optsAtIndex.font);\n      var _scale$_pointLabelIte = scale._pointLabelItems[i],\n        x = _scale$_pointLabelIte.x,\n        y = _scale$_pointLabelIte.y,\n        textAlign = _scale$_pointLabelIte.textAlign,\n        left = _scale$_pointLabelIte.left,\n        top = _scale$_pointLabelIte.top,\n        right = _scale$_pointLabelIte.right,\n        bottom = _scale$_pointLabelIte.bottom;\n      var backdropColor = optsAtIndex.backdropColor;\n      if (!isNullOrUndef(backdropColor)) {\n        var borderRadius = toTRBLCorners(optsAtIndex.borderRadius);\n        var padding = toPadding(optsAtIndex.backdropPadding);\n        ctx.fillStyle = backdropColor;\n        var backdropLeft = left - padding.left;\n        var backdropTop = top - padding.top;\n        var backdropWidth = right - left + padding.width;\n        var backdropHeight = bottom - top + padding.height;\n        if (Object.values(borderRadius).some(function (v) {\n          return v !== 0;\n        })) {\n          ctx.beginPath();\n          addRoundedRectPath(ctx, {\n            x: backdropLeft,\n            y: backdropTop,\n            w: backdropWidth,\n            h: backdropHeight,\n            radius: borderRadius\n          });\n          ctx.fill();\n        } else {\n          ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);\n        }\n      }\n      renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {\n        color: optsAtIndex.color,\n        textAlign: textAlign,\n        textBaseline: 'middle'\n      });\n    }\n  }\n  function pathRadiusLine(scale, radius, circular, labelCount) {\n    var ctx = scale.ctx;\n    if (circular) {\n      ctx.arc(scale.xCenter, scale.yCenter, radius, 0, TAU);\n    } else {\n      var pointPosition = scale.getPointPosition(0, radius);\n      ctx.moveTo(pointPosition.x, pointPosition.y);\n      for (var i = 1; i < labelCount; i++) {\n        pointPosition = scale.getPointPosition(i, radius);\n        ctx.lineTo(pointPosition.x, pointPosition.y);\n      }\n    }\n  }\n  function drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) {\n    var ctx = scale.ctx;\n    var circular = gridLineOpts.circular;\n    var color = gridLineOpts.color,\n      lineWidth = gridLineOpts.lineWidth;\n    if (!circular && !labelCount || !color || !lineWidth || radius < 0) {\n      return;\n    }\n    ctx.save();\n    ctx.strokeStyle = color;\n    ctx.lineWidth = lineWidth;\n    ctx.setLineDash(borderOpts.dash);\n    ctx.lineDashOffset = borderOpts.dashOffset;\n    ctx.beginPath();\n    pathRadiusLine(scale, radius, circular, labelCount);\n    ctx.closePath();\n    ctx.stroke();\n    ctx.restore();\n  }\n  function createPointLabelContext(parent, index, label) {\n    return createContext(parent, {\n      label: label,\n      index: index,\n      type: 'pointLabel'\n    });\n  }\n  var RadialLinearScale = /*#__PURE__*/function (_LinearScaleBase2) {\n    _inherits$w(RadialLinearScale, _LinearScaleBase2);\n    var _super23 = _createSuper$w(RadialLinearScale);\n    function RadialLinearScale(cfg) {\n      var _this38;\n      _classCallCheck$x(this, RadialLinearScale);\n      _this38 = _super23.call(this, cfg);\n      _this38.xCenter = undefined;\n      _this38.yCenter = undefined;\n      _this38.drawingArea = undefined;\n      _this38._pointLabels = [];\n      _this38._pointLabelItems = [];\n      return _this38;\n    }\n    _createClass$x(RadialLinearScale, [{\n      key: \"setDimensions\",\n      value: function setDimensions() {\n        var padding = this._padding = toPadding(getTickBackdropHeight(this.options) / 2);\n        var w = this.width = this.maxWidth - padding.width;\n        var h = this.height = this.maxHeight - padding.height;\n        this.xCenter = Math.floor(this.left + w / 2 + padding.left);\n        this.yCenter = Math.floor(this.top + h / 2 + padding.top);\n        this.drawingArea = Math.floor(Math.min(w, h) / 2);\n      }\n    }, {\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {\n        var _this$getMinMax4 = this.getMinMax(false),\n          min = _this$getMinMax4.min,\n          max = _this$getMinMax4.max;\n        this.min = isNumberFinite(min) && !isNaN(min) ? min : 0;\n        this.max = isNumberFinite(max) && !isNaN(max) ? max : 0;\n        this.handleTickRangeOptions();\n      }\n    }, {\n      key: \"computeTickLimit\",\n      value: function computeTickLimit() {\n        return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));\n      }\n    }, {\n      key: \"generateTickLabels\",\n      value: function generateTickLabels(ticks) {\n        var _this39 = this;\n        LinearScaleBase.prototype.generateTickLabels.call(this, ticks);\n        this._pointLabels = this.getLabels().map(function (value, index) {\n          var label = callback(_this39.options.pointLabels.callback, [value, index], _this39);\n          return label || label === 0 ? label : '';\n        }).filter(function (v, i) {\n          return _this39.chart.getDataVisibility(i);\n        });\n      }\n    }, {\n      key: \"fit\",\n      value: function fit() {\n        var opts = this.options;\n        if (opts.display && opts.pointLabels.display) {\n          fitWithPointLabels(this);\n        } else {\n          this.setCenterPoint(0, 0, 0, 0);\n        }\n      }\n    }, {\n      key: \"setCenterPoint\",\n      value: function setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) {\n        this.xCenter += Math.floor((leftMovement - rightMovement) / 2);\n        this.yCenter += Math.floor((topMovement - bottomMovement) / 2);\n        this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(leftMovement, rightMovement, topMovement, bottomMovement));\n      }\n    }, {\n      key: \"getIndexAngle\",\n      value: function getIndexAngle(index) {\n        var angleMultiplier = TAU / (this._pointLabels.length || 1);\n        var startAngle = this.options.startAngle || 0;\n        return _normalizeAngle(index * angleMultiplier + toRadians(startAngle));\n      }\n    }, {\n      key: \"getDistanceFromCenterForValue\",\n      value: function getDistanceFromCenterForValue(value) {\n        if (isNullOrUndef(value)) {\n          return NaN;\n        }\n        var scalingFactor = this.drawingArea / (this.max - this.min);\n        if (this.options.reverse) {\n          return (this.max - value) * scalingFactor;\n        }\n        return (value - this.min) * scalingFactor;\n      }\n    }, {\n      key: \"getValueForDistanceFromCenter\",\n      value: function getValueForDistanceFromCenter(distance) {\n        if (isNullOrUndef(distance)) {\n          return NaN;\n        }\n        var scaledDistance = distance / (this.drawingArea / (this.max - this.min));\n        return this.options.reverse ? this.max - scaledDistance : this.min + scaledDistance;\n      }\n    }, {\n      key: \"getPointLabelContext\",\n      value: function getPointLabelContext(index) {\n        var pointLabels = this._pointLabels || [];\n        if (index >= 0 && index < pointLabels.length) {\n          var pointLabel = pointLabels[index];\n          return createPointLabelContext(this.getContext(), index, pointLabel);\n        }\n      }\n    }, {\n      key: \"getPointPosition\",\n      value: function getPointPosition(index, distanceFromCenter) {\n        var additionalAngle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n        var angle = this.getIndexAngle(index) - HALF_PI + additionalAngle;\n        return {\n          x: Math.cos(angle) * distanceFromCenter + this.xCenter,\n          y: Math.sin(angle) * distanceFromCenter + this.yCenter,\n          angle: angle\n        };\n      }\n    }, {\n      key: \"getPointPositionForValue\",\n      value: function getPointPositionForValue(index, value) {\n        return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));\n      }\n    }, {\n      key: \"getBasePosition\",\n      value: function getBasePosition(index) {\n        return this.getPointPositionForValue(index || 0, this.getBaseValue());\n      }\n    }, {\n      key: \"getPointLabelPosition\",\n      value: function getPointLabelPosition(index) {\n        var _this$_pointLabelItem = this._pointLabelItems[index],\n          left = _this$_pointLabelItem.left,\n          top = _this$_pointLabelItem.top,\n          right = _this$_pointLabelItem.right,\n          bottom = _this$_pointLabelItem.bottom;\n        return {\n          left: left,\n          top: top,\n          right: right,\n          bottom: bottom\n        };\n      }\n    }, {\n      key: \"drawBackground\",\n      value: function drawBackground() {\n        var _this$options16 = this.options,\n          backgroundColor = _this$options16.backgroundColor,\n          circular = _this$options16.grid.circular;\n        if (backgroundColor) {\n          var ctx = this.ctx;\n          ctx.save();\n          ctx.beginPath();\n          pathRadiusLine(this, this.getDistanceFromCenterForValue(this._endValue), circular, this._pointLabels.length);\n          ctx.closePath();\n          ctx.fillStyle = backgroundColor;\n          ctx.fill();\n          ctx.restore();\n        }\n      }\n    }, {\n      key: \"drawGrid\",\n      value: function drawGrid() {\n        var _this40 = this;\n        var ctx = this.ctx;\n        var opts = this.options;\n        var angleLines = opts.angleLines,\n          grid = opts.grid,\n          border = opts.border;\n        var labelCount = this._pointLabels.length;\n        var i, offset, position;\n        if (opts.pointLabels.display) {\n          drawPointLabels(this, labelCount);\n        }\n        if (grid.display) {\n          this.ticks.forEach(function (tick, index) {\n            if (index !== 0) {\n              offset = _this40.getDistanceFromCenterForValue(tick.value);\n              var context = _this40.getContext(index);\n              var optsAtIndex = grid.setContext(context);\n              var optsAtIndexBorder = border.setContext(context);\n              drawRadiusLine(_this40, optsAtIndex, offset, labelCount, optsAtIndexBorder);\n            }\n          });\n        }\n        if (angleLines.display) {\n          ctx.save();\n          for (i = labelCount - 1; i >= 0; i--) {\n            var optsAtIndex = angleLines.setContext(this.getPointLabelContext(i));\n            var color = optsAtIndex.color,\n              lineWidth = optsAtIndex.lineWidth;\n            if (!lineWidth || !color) {\n              continue;\n            }\n            ctx.lineWidth = lineWidth;\n            ctx.strokeStyle = color;\n            ctx.setLineDash(optsAtIndex.borderDash);\n            ctx.lineDashOffset = optsAtIndex.borderDashOffset;\n            offset = this.getDistanceFromCenterForValue(opts.ticks.reverse ? this.min : this.max);\n            position = this.getPointPosition(i, offset);\n            ctx.beginPath();\n            ctx.moveTo(this.xCenter, this.yCenter);\n            ctx.lineTo(position.x, position.y);\n            ctx.stroke();\n          }\n          ctx.restore();\n        }\n      }\n    }, {\n      key: \"drawBorder\",\n      value: function drawBorder() {}\n    }, {\n      key: \"drawLabels\",\n      value: function drawLabels() {\n        var _this41 = this;\n        var ctx = this.ctx;\n        var opts = this.options;\n        var tickOpts = opts.ticks;\n        if (!tickOpts.display) {\n          return;\n        }\n        var startAngle = this.getIndexAngle(0);\n        var offset, width;\n        ctx.save();\n        ctx.translate(this.xCenter, this.yCenter);\n        ctx.rotate(startAngle);\n        ctx.textAlign = 'center';\n        ctx.textBaseline = 'middle';\n        this.ticks.forEach(function (tick, index) {\n          if (index === 0 && !opts.reverse) {\n            return;\n          }\n          var optsAtIndex = tickOpts.setContext(_this41.getContext(index));\n          var tickFont = toFont(optsAtIndex.font);\n          offset = _this41.getDistanceFromCenterForValue(_this41.ticks[index].value);\n          if (optsAtIndex.showLabelBackdrop) {\n            ctx.font = tickFont.string;\n            width = ctx.measureText(tick.label).width;\n            ctx.fillStyle = optsAtIndex.backdropColor;\n            var padding = toPadding(optsAtIndex.backdropPadding);\n            ctx.fillRect(-width / 2 - padding.left, -offset - tickFont.size / 2 - padding.top, width + padding.width, tickFont.size + padding.height);\n          }\n          renderText(ctx, tick.label, 0, -offset, tickFont, {\n            color: optsAtIndex.color\n          });\n        });\n        ctx.restore();\n      }\n    }, {\n      key: \"drawTitle\",\n      value: function drawTitle() {}\n    }]);\n    return RadialLinearScale;\n  }(LinearScaleBase);\n  _defineProperty$w(RadialLinearScale, \"id\", 'radialLinear');\n  _defineProperty$w(RadialLinearScale, \"defaults\", {\n    display: true,\n    animate: true,\n    position: 'chartArea',\n    angleLines: {\n      display: true,\n      lineWidth: 1,\n      borderDash: [],\n      borderDashOffset: 0.0\n    },\n    grid: {\n      circular: false\n    },\n    startAngle: 0,\n    ticks: {\n      showLabelBackdrop: true,\n      callback: Ticks.formatters.numeric\n    },\n    pointLabels: {\n      backdropColor: undefined,\n      backdropPadding: 2,\n      display: true,\n      font: {\n        size: 10\n      },\n      callback: function callback(label) {\n        return label;\n      },\n      padding: 5,\n      centerPointLabels: false\n    }\n  });\n  _defineProperty$w(RadialLinearScale, \"defaultRoutes\", {\n    'angleLines.color': 'borderColor',\n    'pointLabels.color': 'color',\n    'ticks.color': 'color'\n  });\n  _defineProperty$w(RadialLinearScale, \"descriptors\", {\n    angleLines: {\n      _fallback: 'grid'\n    }\n  });\n  var INTERVALS = {\n    millisecond: {\n      common: true,\n      size: 1,\n      steps: 1000\n    },\n    second: {\n      common: true,\n      size: 1000,\n      steps: 60\n    },\n    minute: {\n      common: true,\n      size: 60000,\n      steps: 60\n    },\n    hour: {\n      common: true,\n      size: 3600000,\n      steps: 24\n    },\n    day: {\n      common: true,\n      size: 86400000,\n      steps: 30\n    },\n    week: {\n      common: false,\n      size: 604800000,\n      steps: 4\n    },\n    month: {\n      common: true,\n      size: 2.628e9,\n      steps: 12\n    },\n    quarter: {\n      common: false,\n      size: 7.884e9,\n      steps: 4\n    },\n    year: {\n      common: true,\n      size: 3.154e10\n    }\n  };\n  var UNITS = /* #__PURE__ */Object.keys(INTERVALS);\n  function sorter(a, b) {\n    return a - b;\n  }\n  function _parse(scale, input) {\n    if (isNullOrUndef(input)) {\n      return null;\n    }\n    var adapter = scale._adapter;\n    var _scale$_parseOpts = scale._parseOpts,\n      parser = _scale$_parseOpts.parser,\n      round = _scale$_parseOpts.round,\n      isoWeekday = _scale$_parseOpts.isoWeekday;\n    var value = input;\n    if (typeof parser === 'function') {\n      value = parser(value);\n    }\n    if (!isNumberFinite(value)) {\n      value = typeof parser === 'string' ? adapter.parse(value, parser) : adapter.parse(value);\n    }\n    if (value === null) {\n      return null;\n    }\n    if (round) {\n      value = round === 'week' && (isNumber(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, 'isoWeek', isoWeekday) : adapter.startOf(value, round);\n    }\n    return +value;\n  }\n  function determineUnitForAutoTicks(minUnit, min, max, capacity) {\n    var ilen = UNITS.length;\n    for (var i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {\n      var interval = INTERVALS[UNITS[i]];\n      var factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER;\n      if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {\n        return UNITS[i];\n      }\n    }\n    return UNITS[ilen - 1];\n  }\n  function determineUnitForFormatting(scale, numTicks, minUnit, min, max) {\n    for (var i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) {\n      var unit = UNITS[i];\n      if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) {\n        return unit;\n      }\n    }\n    return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];\n  }\n  function determineMajorUnit(unit) {\n    for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {\n      if (INTERVALS[UNITS[i]].common) {\n        return UNITS[i];\n      }\n    }\n  }\n  function addTick(ticks, time, timestamps) {\n    if (!timestamps) {\n      ticks[time] = true;\n    } else if (timestamps.length) {\n      var _lookup2 = _lookup(timestamps, time),\n        lo = _lookup2.lo,\n        hi = _lookup2.hi;\n      var timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi];\n      ticks[timestamp] = true;\n    }\n  }\n  function setMajorTicks(scale, ticks, map, majorUnit) {\n    var adapter = scale._adapter;\n    var first = +adapter.startOf(ticks[0].value, majorUnit);\n    var last = ticks[ticks.length - 1].value;\n    var major, index;\n    for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) {\n      index = map[major];\n      if (index >= 0) {\n        ticks[index].major = true;\n      }\n    }\n    return ticks;\n  }\n  function ticksFromTimestamps(scale, values, majorUnit) {\n    var ticks = [];\n    var map = {};\n    var ilen = values.length;\n    var i, value;\n    for (i = 0; i < ilen; ++i) {\n      value = values[i];\n      map[value] = i;\n      ticks.push({\n        value: value,\n        major: false\n      });\n    }\n    return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map, majorUnit);\n  }\n  var TimeScale = /*#__PURE__*/function (_Scale4) {\n    _inherits$w(TimeScale, _Scale4);\n    var _super24 = _createSuper$w(TimeScale);\n    function TimeScale(props) {\n      var _this42;\n      _classCallCheck$x(this, TimeScale);\n      _this42 = _super24.call(this, props);\n      _this42._cache = {\n        data: [],\n        labels: [],\n        all: []\n      };\n      _this42._unit = 'day';\n      _this42._majorUnit = undefined;\n      _this42._offsets = {};\n      _this42._normalized = false;\n      _this42._parseOpts = undefined;\n      return _this42;\n    }\n    _createClass$x(TimeScale, [{\n      key: \"init\",\n      value: function init(scaleOpts) {\n        var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n        var time = scaleOpts.time || (scaleOpts.time = {});\n        var adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);\n        adapter.init(opts);\n        mergeIf(time.displayFormats, adapter.formats());\n        this._parseOpts = {\n          parser: time.parser,\n          round: time.round,\n          isoWeekday: time.isoWeekday\n        };\n        _get(_getPrototypeOf$w(TimeScale.prototype), \"init\", this).call(this, scaleOpts);\n        this._normalized = opts.normalized;\n      }\n    }, {\n      key: \"parse\",\n      value: function parse(raw, index) {\n        if (raw === undefined) {\n          return null;\n        }\n        return _parse(this, raw);\n      }\n    }, {\n      key: \"beforeLayout\",\n      value: function beforeLayout() {\n        _get(_getPrototypeOf$w(TimeScale.prototype), \"beforeLayout\", this).call(this);\n        this._cache = {\n          data: [],\n          labels: [],\n          all: []\n        };\n      }\n    }, {\n      key: \"determineDataLimits\",\n      value: function determineDataLimits() {\n        var options = this.options;\n        var adapter = this._adapter;\n        var unit = options.time.unit || 'day';\n        var _this$getUserBounds5 = this.getUserBounds(),\n          min = _this$getUserBounds5.min,\n          max = _this$getUserBounds5.max,\n          minDefined = _this$getUserBounds5.minDefined,\n          maxDefined = _this$getUserBounds5.maxDefined;\n        function _applyBounds(bounds) {\n          if (!minDefined && !isNaN(bounds.min)) {\n            min = Math.min(min, bounds.min);\n          }\n          if (!maxDefined && !isNaN(bounds.max)) {\n            max = Math.max(max, bounds.max);\n          }\n        }\n        if (!minDefined || !maxDefined) {\n          _applyBounds(this._getLabelBounds());\n          if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') {\n            _applyBounds(this.getMinMax(false));\n          }\n        }\n        min = isNumberFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit);\n        max = isNumberFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;\n        this.min = Math.min(min, max - 1);\n        this.max = Math.max(min + 1, max);\n      }\n    }, {\n      key: \"_getLabelBounds\",\n      value: function _getLabelBounds() {\n        var arr = this.getLabelTimestamps();\n        var min = Number.POSITIVE_INFINITY;\n        var max = Number.NEGATIVE_INFINITY;\n        if (arr.length) {\n          min = arr[0];\n          max = arr[arr.length - 1];\n        }\n        return {\n          min: min,\n          max: max\n        };\n      }\n    }, {\n      key: \"buildTicks\",\n      value: function buildTicks() {\n        var options = this.options;\n        var timeOpts = options.time;\n        var tickOpts = options.ticks;\n        var timestamps = tickOpts.source === 'labels' ? this.getLabelTimestamps() : this._generate();\n        if (options.bounds === 'ticks' && timestamps.length) {\n          this.min = this._userMin || timestamps[0];\n          this.max = this._userMax || timestamps[timestamps.length - 1];\n        }\n        var min = this.min;\n        var max = this.max;\n        var ticks = _filterBetween(timestamps, min, max);\n        this._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, this.min, this.max, this._getLabelCapacity(min)) : determineUnitForFormatting(this, ticks.length, timeOpts.minUnit, this.min, this.max));\n        this._majorUnit = !tickOpts.major.enabled || this._unit === 'year' ? undefined : determineMajorUnit(this._unit);\n        this.initOffsets(timestamps);\n        if (options.reverse) {\n          ticks.reverse();\n        }\n        return ticksFromTimestamps(this, ticks, this._majorUnit);\n      }\n    }, {\n      key: \"afterAutoSkip\",\n      value: function afterAutoSkip() {\n        if (this.options.offsetAfterAutoskip) {\n          this.initOffsets(this.ticks.map(function (tick) {\n            return +tick.value;\n          }));\n        }\n      }\n    }, {\n      key: \"initOffsets\",\n      value: function initOffsets() {\n        var timestamps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n        var start = 0;\n        var end = 0;\n        var first, last;\n        if (this.options.offset && timestamps.length) {\n          first = this.getDecimalForValue(timestamps[0]);\n          if (timestamps.length === 1) {\n            start = 1 - first;\n          } else {\n            start = (this.getDecimalForValue(timestamps[1]) - first) / 2;\n          }\n          last = this.getDecimalForValue(timestamps[timestamps.length - 1]);\n          if (timestamps.length === 1) {\n            end = last;\n          } else {\n            end = (last - this.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;\n          }\n        }\n        var limit = timestamps.length < 3 ? 0.5 : 0.25;\n        start = _limitValue(start, 0, limit);\n        end = _limitValue(end, 0, limit);\n        this._offsets = {\n          start: start,\n          end: end,\n          factor: 1 / (start + 1 + end)\n        };\n      }\n    }, {\n      key: \"_generate\",\n      value: function _generate() {\n        var adapter = this._adapter;\n        var min = this.min;\n        var max = this.max;\n        var options = this.options;\n        var timeOpts = options.time;\n        var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));\n        var stepSize = valueOrDefault(options.ticks.stepSize, 1);\n        var weekday = minor === 'week' ? timeOpts.isoWeekday : false;\n        var hasWeekday = isNumber(weekday) || weekday === true;\n        var ticks = {};\n        var first = min;\n        var time, count;\n        if (hasWeekday) {\n          first = +adapter.startOf(first, 'isoWeek', weekday);\n        }\n        first = +adapter.startOf(first, hasWeekday ? 'day' : minor);\n        if (adapter.diff(max, min, minor) > 100000 * stepSize) {\n          throw new Error(min + ' and ' + max + ' are too far apart with stepSize of ' + stepSize + ' ' + minor);\n        }\n        var timestamps = options.ticks.source === 'data' && this.getDataTimestamps();\n        for (time = first, count = 0; time < max; time = +adapter.add(time, stepSize, minor), count++) {\n          addTick(ticks, time, timestamps);\n        }\n        if (time === max || options.bounds === 'ticks' || count === 1) {\n          addTick(ticks, time, timestamps);\n        }\n        return Object.keys(ticks).sort(function (a, b) {\n          return a - b;\n        }).map(function (x) {\n          return +x;\n        });\n      }\n    }, {\n      key: \"getLabelForValue\",\n      value: function getLabelForValue(value) {\n        var adapter = this._adapter;\n        var timeOpts = this.options.time;\n        if (timeOpts.tooltipFormat) {\n          return adapter.format(value, timeOpts.tooltipFormat);\n        }\n        return adapter.format(value, timeOpts.displayFormats.datetime);\n      }\n    }, {\n      key: \"format\",\n      value: function format(value, _format) {\n        var options = this.options;\n        var formats = options.time.displayFormats;\n        var unit = this._unit;\n        var fmt = _format || formats[unit];\n        return this._adapter.format(value, fmt);\n      }\n    }, {\n      key: \"_tickFormatFunction\",\n      value: function _tickFormatFunction(time, index, ticks, format) {\n        var options = this.options;\n        var formatter = options.ticks.callback;\n        if (formatter) {\n          return callback(formatter, [time, index, ticks], this);\n        }\n        var formats = options.time.displayFormats;\n        var unit = this._unit;\n        var majorUnit = this._majorUnit;\n        var minorFormat = unit && formats[unit];\n        var majorFormat = majorUnit && formats[majorUnit];\n        var tick = ticks[index];\n        var major = majorUnit && majorFormat && tick && tick.major;\n        return this._adapter.format(time, format || (major ? majorFormat : minorFormat));\n      }\n    }, {\n      key: \"generateTickLabels\",\n      value: function generateTickLabels(ticks) {\n        var i, ilen, tick;\n        for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n          tick = ticks[i];\n          tick.label = this._tickFormatFunction(tick.value, i, ticks);\n        }\n      }\n    }, {\n      key: \"getDecimalForValue\",\n      value: function getDecimalForValue(value) {\n        return value === null ? NaN : (value - this.min) / (this.max - this.min);\n      }\n    }, {\n      key: \"getPixelForValue\",\n      value: function getPixelForValue(value) {\n        var offsets = this._offsets;\n        var pos = this.getDecimalForValue(value);\n        return this.getPixelForDecimal((offsets.start + pos) * offsets.factor);\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {\n        var offsets = this._offsets;\n        var pos = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n        return this.min + pos * (this.max - this.min);\n      }\n    }, {\n      key: \"_getLabelSize\",\n      value: function _getLabelSize(label) {\n        var ticksOpts = this.options.ticks;\n        var tickLabelWidth = this.ctx.measureText(label).width;\n        var angle = toRadians(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation);\n        var cosRotation = Math.cos(angle);\n        var sinRotation = Math.sin(angle);\n        var tickFontSize = this._resolveTickFontOptions(0).size;\n        return {\n          w: tickLabelWidth * cosRotation + tickFontSize * sinRotation,\n          h: tickLabelWidth * sinRotation + tickFontSize * cosRotation\n        };\n      }\n    }, {\n      key: \"_getLabelCapacity\",\n      value: function _getLabelCapacity(exampleTime) {\n        var timeOpts = this.options.time;\n        var displayFormats = timeOpts.displayFormats;\n        var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;\n        var exampleLabel = this._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(this, [exampleTime], this._majorUnit), format);\n        var size = this._getLabelSize(exampleLabel);\n        var capacity = Math.floor(this.isHorizontal() ? this.width / size.w : this.height / size.h) - 1;\n        return capacity > 0 ? capacity : 1;\n      }\n    }, {\n      key: \"getDataTimestamps\",\n      value: function getDataTimestamps() {\n        var timestamps = this._cache.data || [];\n        var i, ilen;\n        if (timestamps.length) {\n          return timestamps;\n        }\n        var metas = this.getMatchingVisibleMetas();\n        if (this._normalized && metas.length) {\n          return this._cache.data = metas[0].controller.getAllParsedValues(this);\n        }\n        for (i = 0, ilen = metas.length; i < ilen; ++i) {\n          timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(this));\n        }\n        return this._cache.data = this.normalize(timestamps);\n      }\n    }, {\n      key: \"getLabelTimestamps\",\n      value: function getLabelTimestamps() {\n        var timestamps = this._cache.labels || [];\n        var i, ilen;\n        if (timestamps.length) {\n          return timestamps;\n        }\n        var labels = this.getLabels();\n        for (i = 0, ilen = labels.length; i < ilen; ++i) {\n          timestamps.push(_parse(this, labels[i]));\n        }\n        return this._cache.labels = this._normalized ? timestamps : this.normalize(timestamps);\n      }\n    }, {\n      key: \"normalize\",\n      value: function normalize(values) {\n        return _arrayUnique(values.sort(sorter));\n      }\n    }]);\n    return TimeScale;\n  }(Scale);\n  _defineProperty$w(TimeScale, \"id\", 'time');\n  _defineProperty$w(TimeScale, \"defaults\", {\n    bounds: 'data',\n    adapters: {},\n    time: {\n      parser: false,\n      unit: false,\n      round: false,\n      isoWeekday: false,\n      minUnit: 'millisecond',\n      displayFormats: {}\n    },\n    ticks: {\n      source: 'auto',\n      callback: false,\n      major: {\n        enabled: false\n      }\n    }\n  });\n  function interpolate(table, val, reverse) {\n    var lo = 0;\n    var hi = table.length - 1;\n    var prevSource, nextSource, prevTarget, nextTarget;\n    if (reverse) {\n      if (val >= table[lo].pos && val <= table[hi].pos) {\n        var _lookupByKey2 = _lookupByKey(table, 'pos', val);\n        lo = _lookupByKey2.lo;\n        hi = _lookupByKey2.hi;\n      }\n      var _table$lo = table[lo];\n      prevSource = _table$lo.pos;\n      prevTarget = _table$lo.time;\n      var _table$hi = table[hi];\n      nextSource = _table$hi.pos;\n      nextTarget = _table$hi.time;\n    } else {\n      if (val >= table[lo].time && val <= table[hi].time) {\n        var _lookupByKey3 = _lookupByKey(table, 'time', val);\n        lo = _lookupByKey3.lo;\n        hi = _lookupByKey3.hi;\n      }\n      var _table$lo2 = table[lo];\n      prevSource = _table$lo2.time;\n      prevTarget = _table$lo2.pos;\n      var _table$hi2 = table[hi];\n      nextSource = _table$hi2.time;\n      nextTarget = _table$hi2.pos;\n    }\n    var span = nextSource - prevSource;\n    return span ? prevTarget + (nextTarget - prevTarget) * (val - prevSource) / span : prevTarget;\n  }\n  var TimeSeriesScale = /*#__PURE__*/function (_TimeScale) {\n    _inherits$w(TimeSeriesScale, _TimeScale);\n    var _super25 = _createSuper$w(TimeSeriesScale);\n    function TimeSeriesScale(props) {\n      var _this43;\n      _classCallCheck$x(this, TimeSeriesScale);\n      _this43 = _super25.call(this, props);\n      _this43._table = [];\n      _this43._minPos = undefined;\n      _this43._tableRange = undefined;\n      return _this43;\n    }\n    _createClass$x(TimeSeriesScale, [{\n      key: \"initOffsets\",\n      value: function initOffsets() {\n        var timestamps = this._getTimestampsForTable();\n        var table = this._table = this.buildLookupTable(timestamps);\n        this._minPos = interpolate(table, this.min);\n        this._tableRange = interpolate(table, this.max) - this._minPos;\n        _get(_getPrototypeOf$w(TimeSeriesScale.prototype), \"initOffsets\", this).call(this, timestamps);\n      }\n    }, {\n      key: \"buildLookupTable\",\n      value: function buildLookupTable(timestamps) {\n        var min = this.min,\n          max = this.max;\n        var items = [];\n        var table = [];\n        var i, ilen, prev, curr, next;\n        for (i = 0, ilen = timestamps.length; i < ilen; ++i) {\n          curr = timestamps[i];\n          if (curr >= min && curr <= max) {\n            items.push(curr);\n          }\n        }\n        if (items.length < 2) {\n          return [{\n            time: min,\n            pos: 0\n          }, {\n            time: max,\n            pos: 1\n          }];\n        }\n        for (i = 0, ilen = items.length; i < ilen; ++i) {\n          next = items[i + 1];\n          prev = items[i - 1];\n          curr = items[i];\n          if (Math.round((next + prev) / 2) !== curr) {\n            table.push({\n              time: curr,\n              pos: i / (ilen - 1)\n            });\n          }\n        }\n        return table;\n      }\n    }, {\n      key: \"_getTimestampsForTable\",\n      value: function _getTimestampsForTable() {\n        var timestamps = this._cache.all || [];\n        if (timestamps.length) {\n          return timestamps;\n        }\n        var data = this.getDataTimestamps();\n        var label = this.getLabelTimestamps();\n        if (data.length && label.length) {\n          timestamps = this.normalize(data.concat(label));\n        } else {\n          timestamps = data.length ? data : label;\n        }\n        timestamps = this._cache.all = timestamps;\n        return timestamps;\n      }\n    }, {\n      key: \"getDecimalForValue\",\n      value: function getDecimalForValue(value) {\n        return (interpolate(this._table, value) - this._minPos) / this._tableRange;\n      }\n    }, {\n      key: \"getValueForPixel\",\n      value: function getValueForPixel(pixel) {\n        var offsets = this._offsets;\n        var decimal = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n        return interpolate(this._table, decimal * this._tableRange + this._minPos, true);\n      }\n    }]);\n    return TimeSeriesScale;\n  }(TimeScale);\n  _defineProperty$w(TimeSeriesScale, \"id\", 'timeseries');\n  _defineProperty$w(TimeSeriesScale, \"defaults\", TimeScale.defaults);\n  var scales = /*#__PURE__*/Object.freeze({\n    __proto__: null,\n    CategoryScale: CategoryScale,\n    LinearScale: LinearScale,\n    LogarithmicScale: LogarithmicScale,\n    RadialLinearScale: RadialLinearScale,\n    TimeScale: TimeScale,\n    TimeSeriesScale: TimeSeriesScale\n  });\n  var registerables = [controllers, elements, plugins, scales];\n\n  Chart$1.register.apply(Chart$1, _toConsumableArray(registerables));\n  var Chart = Chart$1;\n\n  var helpers = /*#__PURE__*/Object.freeze({\n    __proto__: null,\n    HALF_PI: HALF_PI,\n    INFINITY: INFINITY,\n    PI: PI,\n    PITAU: PITAU,\n    QUARTER_PI: QUARTER_PI,\n    RAD_PER_DEG: RAD_PER_DEG,\n    TAU: TAU,\n    TWO_THIRDS_PI: TWO_THIRDS_PI,\n    _addGrace: _addGrace,\n    _alignPixel: _alignPixel,\n    _alignStartEnd: _alignStartEnd,\n    _angleBetween: _angleBetween,\n    _angleDiff: _angleDiff,\n    _arrayUnique: _arrayUnique,\n    _attachContext: _attachContext,\n    _bezierCurveTo: _bezierCurveTo,\n    _bezierInterpolation: _bezierInterpolation,\n    _boundSegment: _boundSegment,\n    _boundSegments: _boundSegments,\n    _capitalize: _capitalize,\n    _computeSegments: _computeSegments,\n    _createResolver: _createResolver,\n    _decimalPlaces: _decimalPlaces,\n    _deprecated: _deprecated,\n    _descriptors: _descriptors,\n    _elementsEqual: _elementsEqual,\n    _factorize: _factorize,\n    _filterBetween: _filterBetween,\n    _getParentNode: _getParentNode,\n    _getStartAndCountOfVisiblePoints: _getStartAndCountOfVisiblePoints,\n    _int16Range: _int16Range,\n    _isBetween: _isBetween,\n    _isClickEvent: _isClickEvent,\n    _isDomSupported: _isDomSupported,\n    _isPointInArea: _isPointInArea,\n    _limitValue: _limitValue,\n    _longestText: _longestText,\n    _lookup: _lookup,\n    _lookupByKey: _lookupByKey,\n    _measureText: _measureText,\n    _merger: _merger,\n    _mergerIf: _mergerIf,\n    _normalizeAngle: _normalizeAngle,\n    _parseObjectDataRadialScale: _parseObjectDataRadialScale,\n    _pointInLine: _pointInLine,\n    _readValueToProps: _readValueToProps,\n    _rlookupByKey: _rlookupByKey,\n    _scaleRangesChanged: _scaleRangesChanged,\n    _setMinAndMaxByKey: _setMinAndMaxByKey,\n    _splitKey: _splitKey,\n    _steppedInterpolation: _steppedInterpolation,\n    _steppedLineTo: _steppedLineTo,\n    _textX: _textX,\n    _toLeftRightCenter: _toLeftRightCenter,\n    _updateBezierControlPoints: _updateBezierControlPoints,\n    addRoundedRectPath: addRoundedRectPath,\n    almostEquals: almostEquals,\n    almostWhole: almostWhole,\n    callback: callback,\n    clearCanvas: clearCanvas,\n    clipArea: clipArea,\n    clone: clone,\n    color: color,\n    createContext: createContext,\n    debounce: debounce,\n    defined: defined,\n    distanceBetweenPoints: distanceBetweenPoints,\n    drawPoint: drawPoint,\n    drawPointLegend: drawPointLegend,\n    each: each,\n    easingEffects: effects,\n    finiteOrDefault: finiteOrDefault,\n    fontString: fontString,\n    formatNumber: formatNumber,\n    getAngleFromPoint: getAngleFromPoint,\n    getHoverColor: getHoverColor,\n    getMaximumSize: getMaximumSize,\n    getRelativePosition: getRelativePosition,\n    getRtlAdapter: getRtlAdapter,\n    getStyle: getStyle,\n    isArray: isArray,\n    isFinite: isNumberFinite,\n    isFunction: isFunction,\n    isNullOrUndef: isNullOrUndef,\n    isNumber: isNumber,\n    isObject: isObject,\n    isPatternOrGradient: isPatternOrGradient,\n    listenArrayEvents: listenArrayEvents,\n    log10: log10,\n    merge: merge,\n    mergeIf: mergeIf,\n    niceNum: niceNum,\n    noop: noop,\n    overrideTextDirection: overrideTextDirection,\n    readUsedSize: readUsedSize,\n    renderText: renderText,\n    requestAnimFrame: requestAnimFrame,\n    resolve: resolve,\n    resolveObjectKey: resolveObjectKey,\n    restoreTextDirection: restoreTextDirection,\n    retinaScale: retinaScale,\n    setsEqual: setsEqual,\n    sign: sign,\n    splineCurve: splineCurve,\n    splineCurveMonotone: splineCurveMonotone,\n    supportsEventListenerOptions: supportsEventListenerOptions,\n    throttled: throttled,\n    toDegrees: toDegrees,\n    toDimension: toDimension,\n    toFont: toFont,\n    toFontString: toFontString,\n    toLineHeight: toLineHeight,\n    toPadding: toPadding,\n    toPercentage: toPercentage,\n    toRadians: toRadians,\n    toTRBL: toTRBL,\n    toTRBLCorners: toTRBLCorners,\n    uid: uid,\n    unclipArea: unclipArea,\n    unlistenArrayEvents: unlistenArrayEvents,\n    valueOrDefault: valueOrDefault\n  });\n\n  function toInteger(dirtyNumber) {\n    if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {\n      return NaN;\n    }\n    var number = Number(dirtyNumber);\n    if (isNaN(number)) {\n      return number;\n    }\n    return number < 0 ? Math.ceil(number) : Math.floor(number);\n  }\n\n  function requiredArgs(required, args) {\n    if (args.length < required) {\n      throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n    }\n  }\n\n  function _typeof$y(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$y = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$y = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$y(obj);\n  }\n  /**\n   * @name toDate\n   * @category Common Helpers\n   * @summary Convert the given argument to an instance of Date.\n   *\n   * @description\n   * Convert the given argument to an instance of Date.\n   *\n   * If the argument is an instance of Date, the function returns its clone.\n   *\n   * If the argument is a number, it is treated as a timestamp.\n   *\n   * If the argument is none of the above, the function returns Invalid Date.\n   *\n   * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n   *\n   * @param {Date|Number} argument - the value to convert\n   * @returns {Date} the parsed date in the local time zone\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // Clone the date:\n   * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n   * //=> Tue Feb 11 2014 11:30:30\n   *\n   * @example\n   * // Convert the timestamp to date:\n   * const result = toDate(1392098430000)\n   * //=> Tue Feb 11 2014 11:30:30\n   */\n\n  function toDate(argument) {\n    requiredArgs(1, arguments);\n    var argStr = Object.prototype.toString.call(argument); // Clone the date\n\n    if (argument instanceof Date || _typeof$y(argument) === 'object' && argStr === '[object Date]') {\n      // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n      return new Date(argument.getTime());\n    } else if (typeof argument === 'number' || argStr === '[object Number]') {\n      return new Date(argument);\n    } else {\n      if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n        // eslint-disable-next-line no-console\n        console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments\"); // eslint-disable-next-line no-console\n\n        console.warn(new Error().stack);\n      }\n      return new Date(NaN);\n    }\n  }\n\n  /**\n   * @name addDays\n   * @category Day Helpers\n   * @summary Add the specified number of days to the given date.\n   *\n   * @description\n   * Add the specified number of days to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} - the new date with the days added\n   * @throws {TypeError} - 2 arguments required\n   *\n   * @example\n   * // Add 10 days to 1 September 2014:\n   * const result = addDays(new Date(2014, 8, 1), 10)\n   * //=> Thu Sep 11 2014 00:00:00\n   */\n\n  function addDays(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var date = toDate(dirtyDate);\n    var amount = toInteger(dirtyAmount);\n    if (isNaN(amount)) {\n      return new Date(NaN);\n    }\n    if (!amount) {\n      // If 0 days, no-op to avoid changing times in the hour before end of DST\n      return date;\n    }\n    date.setDate(date.getDate() + amount);\n    return date;\n  }\n\n  /**\n   * @name addMonths\n   * @category Month Helpers\n   * @summary Add the specified number of months to the given date.\n   *\n   * @description\n   * Add the specified number of months to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the months added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 5 months to 1 September 2014:\n   * const result = addMonths(new Date(2014, 8, 1), 5)\n   * //=> Sun Feb 01 2015 00:00:00\n   */\n\n  function addMonths(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var date = toDate(dirtyDate);\n    var amount = toInteger(dirtyAmount);\n    if (isNaN(amount)) {\n      return new Date(NaN);\n    }\n    if (!amount) {\n      // If 0 months, no-op to avoid changing times in the hour before end of DST\n      return date;\n    }\n    var dayOfMonth = date.getDate(); // The JS Date object supports date math by accepting out-of-bounds values for\n    // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and\n    // new Date(2020, 13, 1) returns 1 Feb 2021.  This is *almost* the behavior we\n    // want except that dates will wrap around the end of a month, meaning that\n    // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So\n    // we'll default to the end of the desired month by adding 1 to the desired\n    // month and using a date of 0 to back up one day to the end of the desired\n    // month.\n\n    var endOfDesiredMonth = new Date(date.getTime());\n    endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);\n    var daysInMonth = endOfDesiredMonth.getDate();\n    if (dayOfMonth >= daysInMonth) {\n      // If we're already at the end of the month, then this is the correct date\n      // and we're done.\n      return endOfDesiredMonth;\n    } else {\n      // Otherwise, we now know that setting the original day-of-month value won't\n      // cause an overflow, so set the desired day-of-month. Note that we can't\n      // just set the date of `endOfDesiredMonth` because that object may have had\n      // its time changed in the unusual case where where a DST transition was on\n      // the last day of the month and its local time was in the hour skipped or\n      // repeated next to a DST transition.  So we use `date` instead which is\n      // guaranteed to still have the original time.\n      date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);\n      return date;\n    }\n  }\n\n  /**\n   * @name addMilliseconds\n   * @category Millisecond Helpers\n   * @summary Add the specified number of milliseconds to the given date.\n   *\n   * @description\n   * Add the specified number of milliseconds to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the milliseconds added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 750 milliseconds to 10 July 2014 12:45:30.000:\n   * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n   * //=> Thu Jul 10 2014 12:45:30.750\n   */\n\n  function addMilliseconds(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var timestamp = toDate(dirtyDate).getTime();\n    var amount = toInteger(dirtyAmount);\n    return new Date(timestamp + amount);\n  }\n\n  var MILLISECONDS_IN_HOUR = 3600000;\n  /**\n   * @name addHours\n   * @category Hour Helpers\n   * @summary Add the specified number of hours to the given date.\n   *\n   * @description\n   * Add the specified number of hours to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of hours to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the hours added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 2 hours to 10 July 2014 23:00:00:\n   * const result = addHours(new Date(2014, 6, 10, 23, 0), 2)\n   * //=> Fri Jul 11 2014 01:00:00\n   */\n\n  function addHours(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_HOUR);\n  }\n\n  var defaultOptions = {};\n  function getDefaultOptions() {\n    return defaultOptions;\n  }\n\n  /**\n   * @name startOfWeek\n   * @category Week Helpers\n   * @summary Return the start of a week for the given date.\n   *\n   * @description\n   * Return the start of a week for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @param {Object} [options] - an object with options.\n   * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n   * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n   * @returns {Date} the start of a week\n   * @throws {TypeError} 1 argument required\n   * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n   *\n   * @example\n   * // The start of a week for 2 September 2014 11:55:00:\n   * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Sun Aug 31 2014 00:00:00\n   *\n   * @example\n   * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:\n   * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })\n   * //=> Mon Sep 01 2014 00:00:00\n   */\n\n  function startOfWeek(dirtyDate, options) {\n    var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(1, arguments);\n    var defaultOptions = getDefaultOptions();\n    var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    var date = toDate(dirtyDate);\n    var day = date.getDay();\n    var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n    date.setDate(date.getDate() - diff);\n    date.setHours(0, 0, 0, 0);\n    return date;\n  }\n\n  /**\n   * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.\n   * They usually appear for dates that denote time before the timezones were introduced\n   * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891\n   * and GMT+01:00:00 after that date)\n   *\n   * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,\n   * which would lead to incorrect calculations.\n   *\n   * This function returns the timezone offset in milliseconds that takes seconds in account.\n   */\n  function getTimezoneOffsetInMilliseconds(date) {\n    var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));\n    utcDate.setUTCFullYear(date.getFullYear());\n    return date.getTime() - utcDate.getTime();\n  }\n\n  /**\n   * @name startOfDay\n   * @category Day Helpers\n   * @summary Return the start of a day for the given date.\n   *\n   * @description\n   * Return the start of a day for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a day\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a day for 2 September 2014 11:55:00:\n   * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Tue Sep 02 2014 00:00:00\n   */\n\n  function startOfDay(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setHours(0, 0, 0, 0);\n    return date;\n  }\n\n  var MILLISECONDS_IN_DAY$1 = 86400000;\n  /**\n   * @name differenceInCalendarDays\n   * @category Day Helpers\n   * @summary Get the number of calendar days between the given dates.\n   *\n   * @description\n   * Get the number of calendar days between the given dates. This means that the times are removed\n   * from the dates and then the difference in days is calculated.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of calendar days\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many calendar days are between\n   * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?\n   * const result = differenceInCalendarDays(\n   *   new Date(2012, 6, 2, 0, 0),\n   *   new Date(2011, 6, 2, 23, 0)\n   * )\n   * //=> 366\n   * // How many calendar days are between\n   * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?\n   * const result = differenceInCalendarDays(\n   *   new Date(2011, 6, 3, 0, 1),\n   *   new Date(2011, 6, 2, 23, 59)\n   * )\n   * //=> 1\n   */\n\n  function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var startOfDayLeft = startOfDay(dirtyDateLeft);\n    var startOfDayRight = startOfDay(dirtyDateRight);\n    var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);\n    var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); // Round the number of days to the nearest integer\n    // because the number of milliseconds in a day is not constant\n    // (e.g. it's different in the day of the daylight saving time clock shift)\n\n    return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY$1);\n  }\n\n  var MILLISECONDS_IN_MINUTE = 60000;\n  /**\n   * @name addMinutes\n   * @category Minute Helpers\n   * @summary Add the specified number of minutes to the given date.\n   *\n   * @description\n   * Add the specified number of minutes to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the minutes added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 30 minutes to 10 July 2014 12:00:00:\n   * const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)\n   * //=> Thu Jul 10 2014 12:30:00\n   */\n\n  function addMinutes(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE);\n  }\n\n  /**\n   * @name addQuarters\n   * @category Quarter Helpers\n   * @summary Add the specified number of year quarters to the given date.\n   *\n   * @description\n   * Add the specified number of year quarters to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of quarters to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the quarters added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 1 quarter to 1 September 2014:\n   * const result = addQuarters(new Date(2014, 8, 1), 1)\n   * //=> Mon Dec 01 2014 00:00:00\n   */\n\n  function addQuarters(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    var months = amount * 3;\n    return addMonths(dirtyDate, months);\n  }\n\n  /**\n   * @name addSeconds\n   * @category Second Helpers\n   * @summary Add the specified number of seconds to the given date.\n   *\n   * @description\n   * Add the specified number of seconds to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the seconds added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 30 seconds to 10 July 2014 12:45:00:\n   * const result = addSeconds(new Date(2014, 6, 10, 12, 45, 0), 30)\n   * //=> Thu Jul 10 2014 12:45:30\n   */\n\n  function addSeconds(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    return addMilliseconds(dirtyDate, amount * 1000);\n  }\n\n  /**\n   * @name addWeeks\n   * @category Week Helpers\n   * @summary Add the specified number of weeks to the given date.\n   *\n   * @description\n   * Add the specified number of week to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the weeks added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 4 weeks to 1 September 2014:\n   * const result = addWeeks(new Date(2014, 8, 1), 4)\n   * //=> Mon Sep 29 2014 00:00:00\n   */\n\n  function addWeeks(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    var days = amount * 7;\n    return addDays(dirtyDate, days);\n  }\n\n  /**\n   * @name addYears\n   * @category Year Helpers\n   * @summary Add the specified number of years to the given date.\n   *\n   * @description\n   * Add the specified number of years to the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the years added\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Add 5 years to 1 September 2014:\n   * const result = addYears(new Date(2014, 8, 1), 5)\n   * //=> Sun Sep 01 2019 00:00:00\n   */\n\n  function addYears(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    return addMonths(dirtyDate, amount * 12);\n  }\n\n  /**\n   * @name compareAsc\n   * @category Common Helpers\n   * @summary Compare the two dates and return -1, 0 or 1.\n   *\n   * @description\n   * Compare the two dates and return 1 if the first date is after the second,\n   * -1 if the first date is before the second or 0 if dates are equal.\n   *\n   * @param {Date|Number} dateLeft - the first date to compare\n   * @param {Date|Number} dateRight - the second date to compare\n   * @returns {Number} the result of the comparison\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Compare 11 February 1987 and 10 July 1989:\n   * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))\n   * //=> -1\n   *\n   * @example\n   * // Sort the array of dates:\n   * const result = [\n   *   new Date(1995, 6, 2),\n   *   new Date(1987, 1, 11),\n   *   new Date(1989, 6, 10)\n   * ].sort(compareAsc)\n   * //=> [\n   * //   Wed Feb 11 1987 00:00:00,\n   * //   Mon Jul 10 1989 00:00:00,\n   * //   Sun Jul 02 1995 00:00:00\n   * // ]\n   */\n\n  function compareAsc(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    var diff = dateLeft.getTime() - dateRight.getTime();\n    if (diff < 0) {\n      return -1;\n    } else if (diff > 0) {\n      return 1; // Return 0 if diff is 0; return NaN if diff is NaN\n    } else {\n      return diff;\n    }\n  }\n\n  /**\n   * Days in 1 week.\n   *\n   * @name daysInWeek\n   * @constant\n   * @type {number}\n   * @default\n   */\n  /**\n   * Milliseconds in 1 minute\n   *\n   * @name millisecondsInMinute\n   * @constant\n   * @type {number}\n   * @default\n   */\n\n  var millisecondsInMinute = 60000;\n  /**\n   * Milliseconds in 1 hour\n   *\n   * @name millisecondsInHour\n   * @constant\n   * @type {number}\n   * @default\n   */\n\n  var millisecondsInHour = 3600000;\n  /**\n   * Milliseconds in 1 second\n   *\n   * @name millisecondsInSecond\n   * @constant\n   * @type {number}\n   * @default\n   */\n\n  var millisecondsInSecond = 1000;\n\n  function _typeof$x(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$x = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$x = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$x(obj);\n  }\n  /**\n   * @name isDate\n   * @category Common Helpers\n   * @summary Is the given value a date?\n   *\n   * @description\n   * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.\n   *\n   * @param {*} value - the value to check\n   * @returns {boolean} true if the given value is a date\n   * @throws {TypeError} 1 arguments required\n   *\n   * @example\n   * // For a valid date:\n   * const result = isDate(new Date())\n   * //=> true\n   *\n   * @example\n   * // For an invalid date:\n   * const result = isDate(new Date(NaN))\n   * //=> true\n   *\n   * @example\n   * // For some value:\n   * const result = isDate('2014-02-31')\n   * //=> false\n   *\n   * @example\n   * // For an object:\n   * const result = isDate({})\n   * //=> false\n   */\n\n  function isDate(value) {\n    requiredArgs(1, arguments);\n    return value instanceof Date || _typeof$x(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';\n  }\n\n  /**\n   * @name isValid\n   * @category Common Helpers\n   * @summary Is the given date valid?\n   *\n   * @description\n   * Returns false if argument is Invalid Date and true otherwise.\n   * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}\n   * Invalid Date is a Date, whose time value is NaN.\n   *\n   * Time value of Date: http://es5.github.io/#x15.9.1.1\n   *\n   * @param {*} date - the date to check\n   * @returns {Boolean} the date is valid\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // For the valid date:\n   * const result = isValid(new Date(2014, 1, 31))\n   * //=> true\n   *\n   * @example\n   * // For the value, convertable into a date:\n   * const result = isValid(1393804800000)\n   * //=> true\n   *\n   * @example\n   * // For the invalid date:\n   * const result = isValid(new Date(''))\n   * //=> false\n   */\n\n  function isValid(dirtyDate) {\n    requiredArgs(1, arguments);\n    if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {\n      return false;\n    }\n    var date = toDate(dirtyDate);\n    return !isNaN(Number(date));\n  }\n\n  /**\n   * @name differenceInCalendarMonths\n   * @category Month Helpers\n   * @summary Get the number of calendar months between the given dates.\n   *\n   * @description\n   * Get the number of calendar months between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of calendar months\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many calendar months are between 31 January 2014 and 1 September 2014?\n   * const result = differenceInCalendarMonths(\n   *   new Date(2014, 8, 1),\n   *   new Date(2014, 0, 31)\n   * )\n   * //=> 8\n   */\n\n  function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();\n    var monthDiff = dateLeft.getMonth() - dateRight.getMonth();\n    return yearDiff * 12 + monthDiff;\n  }\n\n  /**\n   * @name differenceInCalendarYears\n   * @category Year Helpers\n   * @summary Get the number of calendar years between the given dates.\n   *\n   * @description\n   * Get the number of calendar years between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of calendar years\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many calendar years are between 31 December 2013 and 11 February 2015?\n   * const result = differenceInCalendarYears(\n   *   new Date(2015, 1, 11),\n   *   new Date(2013, 11, 31)\n   * )\n   * //=> 2\n   */\n\n  function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    return dateLeft.getFullYear() - dateRight.getFullYear();\n  }\n\n  // for accurate equality comparisons of UTC timestamps that end up\n  // having the same representation in local time, e.g. one hour before\n  // DST ends vs. the instant that DST ends.\n\n  function compareLocalAsc(dateLeft, dateRight) {\n    var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();\n    if (diff < 0) {\n      return -1;\n    } else if (diff > 0) {\n      return 1; // Return 0 if diff is 0; return NaN if diff is NaN\n    } else {\n      return diff;\n    }\n  }\n  /**\n   * @name differenceInDays\n   * @category Day Helpers\n   * @summary Get the number of full days between the given dates.\n   *\n   * @description\n   * Get the number of full day periods between two dates. Fractional days are\n   * truncated towards zero.\n   *\n   * One \"full day\" is the distance between a local time in one day to the same\n   * local time on the next or previous day. A full day can sometimes be less than\n   * or more than 24 hours if a daylight savings change happens between two dates.\n   *\n   * To ignore DST and only measure exact 24-hour periods, use this instead:\n   * `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.\n   *\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of full days according to the local timezone\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many full days are between\n   * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?\n   * const result = differenceInDays(\n   *   new Date(2012, 6, 2, 0, 0),\n   *   new Date(2011, 6, 2, 23, 0)\n   * )\n   * //=> 365\n   * // How many full days are between\n   * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?\n   * const result = differenceInDays(\n   *   new Date(2011, 6, 3, 0, 1),\n   *   new Date(2011, 6, 2, 23, 59)\n   * )\n   * //=> 0\n   * // How many full days are between\n   * // 1 March 2020 0:00 and 1 June 2020 0:00 ?\n   * // Note: because local time is used, the\n   * // result will always be 92 days, even in\n   * // time zones where DST starts and the\n   * // period has only 92*24-1 hours.\n   * const result = differenceInDays(\n   *   new Date(2020, 5, 1),\n   *   new Date(2020, 2, 1)\n   * )\n  //=> 92\n   */\n\n  function differenceInDays(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    var sign = compareLocalAsc(dateLeft, dateRight);\n    var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));\n    dateLeft.setDate(dateLeft.getDate() - sign * difference); // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full\n    // If so, result must be decreased by 1 in absolute value\n\n    var isLastDayNotFull = Number(compareLocalAsc(dateLeft, dateRight) === -sign);\n    var result = sign * (difference - isLastDayNotFull); // Prevent negative zero\n\n    return result === 0 ? 0 : result;\n  }\n\n  /**\n   * @name differenceInMilliseconds\n   * @category Millisecond Helpers\n   * @summary Get the number of milliseconds between the given dates.\n   *\n   * @description\n   * Get the number of milliseconds between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of milliseconds\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many milliseconds are between\n   * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?\n   * const result = differenceInMilliseconds(\n   *   new Date(2014, 6, 2, 12, 30, 21, 700),\n   *   new Date(2014, 6, 2, 12, 30, 20, 600)\n   * )\n   * //=> 1100\n   */\n\n  function differenceInMilliseconds(dateLeft, dateRight) {\n    requiredArgs(2, arguments);\n    return toDate(dateLeft).getTime() - toDate(dateRight).getTime();\n  }\n\n  var roundingMap = {\n    ceil: Math.ceil,\n    round: Math.round,\n    floor: Math.floor,\n    trunc: function trunc(value) {\n      return value < 0 ? Math.ceil(value) : Math.floor(value);\n    } // Math.trunc is not supported by IE\n  };\n\n  var defaultRoundingMethod = 'trunc';\n  function getRoundingMethod(method) {\n    return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];\n  }\n\n  /**\n   * @name differenceInHours\n   * @category Hour Helpers\n   * @summary Get the number of hours between the given dates.\n   *\n   * @description\n   * Get the number of hours between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @param {Object} [options] - an object with options.\n   * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n   * @returns {Number} the number of hours\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?\n   * const result = differenceInHours(\n   *   new Date(2014, 6, 2, 19, 0),\n   *   new Date(2014, 6, 2, 6, 50)\n   * )\n   * //=> 12\n   */\n\n  function differenceInHours(dateLeft, dateRight, options) {\n    requiredArgs(2, arguments);\n    var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;\n    return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n  }\n\n  /**\n   * @name differenceInMinutes\n   * @category Minute Helpers\n   * @summary Get the number of minutes between the given dates.\n   *\n   * @description\n   * Get the signed number of full (rounded towards 0) minutes between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @param {Object} [options] - an object with options.\n   * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n   * @returns {Number} the number of minutes\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?\n   * const result = differenceInMinutes(\n   *   new Date(2014, 6, 2, 12, 20, 0),\n   *   new Date(2014, 6, 2, 12, 7, 59)\n   * )\n   * //=> 12\n   *\n   * @example\n   * // How many minutes are between 10:01:59 and 10:00:00\n   * const result = differenceInMinutes(\n   *   new Date(2000, 0, 1, 10, 0, 0),\n   *   new Date(2000, 0, 1, 10, 1, 59)\n   * )\n   * //=> -1\n   */\n\n  function differenceInMinutes(dateLeft, dateRight, options) {\n    requiredArgs(2, arguments);\n    var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;\n    return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n  }\n\n  /**\n   * @name endOfDay\n   * @category Day Helpers\n   * @summary Return the end of a day for the given date.\n   *\n   * @description\n   * Return the end of a day for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a day\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a day for 2 September 2014 11:55:00:\n   * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Tue Sep 02 2014 23:59:59.999\n   */\n\n  function endOfDay(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setHours(23, 59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name endOfMonth\n   * @category Month Helpers\n   * @summary Return the end of a month for the given date.\n   *\n   * @description\n   * Return the end of a month for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a month\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a month for 2 September 2014 11:55:00:\n   * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Tue Sep 30 2014 23:59:59.999\n   */\n\n  function endOfMonth(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var month = date.getMonth();\n    date.setFullYear(date.getFullYear(), month + 1, 0);\n    date.setHours(23, 59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name isLastDayOfMonth\n   * @category Month Helpers\n   * @summary Is the given date the last day of a month?\n   *\n   * @description\n   * Is the given date the last day of a month?\n   *\n   * @param {Date|Number} date - the date to check\n   * @returns {Boolean} the date is the last day of a month\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // Is 28 February 2014 the last day of a month?\n   * const result = isLastDayOfMonth(new Date(2014, 1, 28))\n   * //=> true\n   */\n\n  function isLastDayOfMonth(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    return endOfDay(date).getTime() === endOfMonth(date).getTime();\n  }\n\n  /**\n   * @name differenceInMonths\n   * @category Month Helpers\n   * @summary Get the number of full months between the given dates.\n   *\n   * @description\n   * Get the number of full months between the given dates using trunc as a default rounding method.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of full months\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many full months are between 31 January 2014 and 1 September 2014?\n   * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))\n   * //=> 7\n   */\n\n  function differenceInMonths(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    var sign = compareAsc(dateLeft, dateRight);\n    var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));\n    var result; // Check for the difference of less than month\n\n    if (difference < 1) {\n      result = 0;\n    } else {\n      if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {\n        // This will check if the date is end of Feb and assign a higher end of month date\n        // to compare it with Jan\n        dateLeft.setDate(30);\n      }\n      dateLeft.setMonth(dateLeft.getMonth() - sign * difference); // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full\n      // If so, result must be decreased by 1 in absolute value\n\n      var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; // Check for cases of one full calendar month\n\n      if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {\n        isLastMonthNotFull = false;\n      }\n      result = sign * (difference - Number(isLastMonthNotFull));\n    } // Prevent negative zero\n\n    return result === 0 ? 0 : result;\n  }\n\n  /**\n   * @name differenceInQuarters\n   * @category Quarter Helpers\n   * @summary Get the number of quarters between the given dates.\n   *\n   * @description\n   * Get the number of quarters between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @param {Object} [options] - an object with options.\n   * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n   * @returns {Number} the number of full quarters\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many full quarters are between 31 December 2013 and 2 July 2014?\n   * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31))\n   * //=> 2\n   */\n\n  function differenceInQuarters(dateLeft, dateRight, options) {\n    requiredArgs(2, arguments);\n    var diff = differenceInMonths(dateLeft, dateRight) / 3;\n    return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n  }\n\n  /**\n   * @name differenceInSeconds\n   * @category Second Helpers\n   * @summary Get the number of seconds between the given dates.\n   *\n   * @description\n   * Get the number of seconds between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @param {Object} [options] - an object with options.\n   * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n   * @returns {Number} the number of seconds\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many seconds are between\n   * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?\n   * const result = differenceInSeconds(\n   *   new Date(2014, 6, 2, 12, 30, 20, 0),\n   *   new Date(2014, 6, 2, 12, 30, 7, 999)\n   * )\n   * //=> 12\n   */\n\n  function differenceInSeconds(dateLeft, dateRight, options) {\n    requiredArgs(2, arguments);\n    var diff = differenceInMilliseconds(dateLeft, dateRight) / 1000;\n    return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n  }\n\n  /**\n   * @name differenceInWeeks\n   * @category Week Helpers\n   * @summary Get the number of full weeks between the given dates.\n   *\n   * @description\n   * Get the number of full weeks between two dates. Fractional weeks are\n   * truncated towards zero by default.\n   *\n   * One \"full week\" is the distance between a local time in one day to the same\n   * local time 7 days earlier or later. A full week can sometimes be less than\n   * or more than 7*24 hours if a daylight savings change happens between two dates.\n   *\n   * To ignore DST and only measure exact 7*24-hour periods, use this instead:\n   * `Math.floor(differenceInHours(dateLeft, dateRight)/(7*24))|0`.\n   *\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @param {Object} [options] - an object with options.\n   * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n   * @returns {Number} the number of full weeks\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many full weeks are between 5 July 2014 and 20 July 2014?\n   * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5))\n   * //=> 2\n   *\n   * // How many full weeks are between\n   * // 1 March 2020 0:00 and 6 June 2020 0:00 ?\n   * // Note: because local time is used, the\n   * // result will always be 8 weeks (54 days),\n   * // even if DST starts and the period has\n   * // only 54*24-1 hours.\n   * const result = differenceInWeeks(\n   *   new Date(2020, 5, 1),\n   *   new Date(2020, 2, 6)\n   * )\n   * //=> 8\n   */\n\n  function differenceInWeeks(dateLeft, dateRight, options) {\n    requiredArgs(2, arguments);\n    var diff = differenceInDays(dateLeft, dateRight) / 7;\n    return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n  }\n\n  /**\n   * @name differenceInYears\n   * @category Year Helpers\n   * @summary Get the number of full years between the given dates.\n   *\n   * @description\n   * Get the number of full years between the given dates.\n   *\n   * @param {Date|Number} dateLeft - the later date\n   * @param {Date|Number} dateRight - the earlier date\n   * @returns {Number} the number of full years\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // How many full years are between 31 December 2013 and 11 February 2015?\n   * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31))\n   * //=> 1\n   */\n\n  function differenceInYears(dirtyDateLeft, dirtyDateRight) {\n    requiredArgs(2, arguments);\n    var dateLeft = toDate(dirtyDateLeft);\n    var dateRight = toDate(dirtyDateRight);\n    var sign = compareAsc(dateLeft, dateRight);\n    var difference = Math.abs(differenceInCalendarYears(dateLeft, dateRight)); // Set both dates to a valid leap year for accurate comparison when dealing\n    // with leap days\n\n    dateLeft.setFullYear(1584);\n    dateRight.setFullYear(1584); // Math.abs(diff in full years - diff in calendar years) === 1 if last calendar year is not full\n    // If so, result must be decreased by 1 in absolute value\n\n    var isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;\n    var result = sign * (difference - Number(isLastYearNotFull)); // Prevent negative zero\n\n    return result === 0 ? 0 : result;\n  }\n\n  /**\n   * @name startOfMinute\n   * @category Minute Helpers\n   * @summary Return the start of a minute for the given date.\n   *\n   * @description\n   * Return the start of a minute for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a minute\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a minute for 1 December 2014 22:15:45.400:\n   * const result = startOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400))\n   * //=> Mon Dec 01 2014 22:15:00\n   */\n\n  function startOfMinute(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setSeconds(0, 0);\n    return date;\n  }\n\n  /**\n   * @name startOfQuarter\n   * @category Quarter Helpers\n   * @summary Return the start of a year quarter for the given date.\n   *\n   * @description\n   * Return the start of a year quarter for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a quarter\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a quarter for 2 September 2014 11:55:00:\n   * const result = startOfQuarter(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Tue Jul 01 2014 00:00:00\n   */\n\n  function startOfQuarter(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var currentMonth = date.getMonth();\n    var month = currentMonth - currentMonth % 3;\n    date.setMonth(month, 1);\n    date.setHours(0, 0, 0, 0);\n    return date;\n  }\n\n  /**\n   * @name startOfMonth\n   * @category Month Helpers\n   * @summary Return the start of a month for the given date.\n   *\n   * @description\n   * Return the start of a month for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a month\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a month for 2 September 2014 11:55:00:\n   * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Mon Sep 01 2014 00:00:00\n   */\n\n  function startOfMonth(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setDate(1);\n    date.setHours(0, 0, 0, 0);\n    return date;\n  }\n\n  /**\n   * @name endOfYear\n   * @category Year Helpers\n   * @summary Return the end of a year for the given date.\n   *\n   * @description\n   * Return the end of a year for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a year\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a year for 2 September 2014 11:55:00:\n   * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))\n   * //=> Wed Dec 31 2014 23:59:59.999\n   */\n\n  function endOfYear(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var year = date.getFullYear();\n    date.setFullYear(year + 1, 0, 0);\n    date.setHours(23, 59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name startOfYear\n   * @category Year Helpers\n   * @summary Return the start of a year for the given date.\n   *\n   * @description\n   * Return the start of a year for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a year\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a year for 2 September 2014 11:55:00:\n   * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))\n   * //=> Wed Jan 01 2014 00:00:00\n   */\n\n  function startOfYear(dirtyDate) {\n    requiredArgs(1, arguments);\n    var cleanDate = toDate(dirtyDate);\n    var date = new Date(0);\n    date.setFullYear(cleanDate.getFullYear(), 0, 1);\n    date.setHours(0, 0, 0, 0);\n    return date;\n  }\n\n  /**\n   * @name endOfHour\n   * @category Hour Helpers\n   * @summary Return the end of an hour for the given date.\n   *\n   * @description\n   * Return the end of an hour for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of an hour\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of an hour for 2 September 2014 11:55:00:\n   * const result = endOfHour(new Date(2014, 8, 2, 11, 55))\n   * //=> Tue Sep 02 2014 11:59:59.999\n   */\n\n  function endOfHour(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setMinutes(59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name endOfWeek\n   * @category Week Helpers\n   * @summary Return the end of a week for the given date.\n   *\n   * @description\n   * Return the end of a week for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @param {Object} [options] - an object with options.\n   * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n   * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n   * @returns {Date} the end of a week\n   * @throws {TypeError} 1 argument required\n   * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n   *\n   * @example\n   * // The end of a week for 2 September 2014 11:55:00:\n   * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Sat Sep 06 2014 23:59:59.999\n   *\n   * @example\n   * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:\n   * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })\n   * //=> Sun Sep 07 2014 23:59:59.999\n   */\n  function endOfWeek(dirtyDate, options) {\n    var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(1, arguments);\n    var defaultOptions = getDefaultOptions();\n    var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    var date = toDate(dirtyDate);\n    var day = date.getDay();\n    var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);\n    date.setDate(date.getDate() + diff);\n    date.setHours(23, 59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name endOfMinute\n   * @category Minute Helpers\n   * @summary Return the end of a minute for the given date.\n   *\n   * @description\n   * Return the end of a minute for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a minute\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a minute for 1 December 2014 22:15:45.400:\n   * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400))\n   * //=> Mon Dec 01 2014 22:15:59.999\n   */\n\n  function endOfMinute(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setSeconds(59, 999);\n    return date;\n  }\n\n  /**\n   * @name endOfQuarter\n   * @category Quarter Helpers\n   * @summary Return the end of a year quarter for the given date.\n   *\n   * @description\n   * Return the end of a year quarter for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a quarter\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a quarter for 2 September 2014 11:55:00:\n   * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0))\n   * //=> Tue Sep 30 2014 23:59:59.999\n   */\n\n  function endOfQuarter(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var currentMonth = date.getMonth();\n    var month = currentMonth - currentMonth % 3 + 3;\n    date.setMonth(month, 0);\n    date.setHours(23, 59, 59, 999);\n    return date;\n  }\n\n  /**\n   * @name endOfSecond\n   * @category Second Helpers\n   * @summary Return the end of a second for the given date.\n   *\n   * @description\n   * Return the end of a second for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the end of a second\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The end of a second for 1 December 2014 22:15:45.400:\n   * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))\n   * //=> Mon Dec 01 2014 22:15:45.999\n   */\n\n  function endOfSecond(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setMilliseconds(999);\n    return date;\n  }\n\n  /**\n   * @name subMilliseconds\n   * @category Millisecond Helpers\n   * @summary Subtract the specified number of milliseconds from the given date.\n   *\n   * @description\n   * Subtract the specified number of milliseconds from the given date.\n   *\n   * @param {Date|Number} date - the date to be changed\n   * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n   * @returns {Date} the new date with the milliseconds subtracted\n   * @throws {TypeError} 2 arguments required\n   *\n   * @example\n   * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:\n   * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n   * //=> Thu Jul 10 2014 12:45:29.250\n   */\n\n  function subMilliseconds(dirtyDate, dirtyAmount) {\n    requiredArgs(2, arguments);\n    var amount = toInteger(dirtyAmount);\n    return addMilliseconds(dirtyDate, -amount);\n  }\n\n  var MILLISECONDS_IN_DAY = 86400000;\n  function getUTCDayOfYear(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var timestamp = date.getTime();\n    date.setUTCMonth(0, 1);\n    date.setUTCHours(0, 0, 0, 0);\n    var startOfYearTimestamp = date.getTime();\n    var difference = timestamp - startOfYearTimestamp;\n    return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;\n  }\n\n  function startOfUTCISOWeek(dirtyDate) {\n    requiredArgs(1, arguments);\n    var weekStartsOn = 1;\n    var date = toDate(dirtyDate);\n    var day = date.getUTCDay();\n    var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n    date.setUTCDate(date.getUTCDate() - diff);\n    date.setUTCHours(0, 0, 0, 0);\n    return date;\n  }\n\n  function getUTCISOWeekYear(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var year = date.getUTCFullYear();\n    var fourthOfJanuaryOfNextYear = new Date(0);\n    fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);\n    fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);\n    var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);\n    var fourthOfJanuaryOfThisYear = new Date(0);\n    fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);\n    fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);\n    var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);\n    if (date.getTime() >= startOfNextYear.getTime()) {\n      return year + 1;\n    } else if (date.getTime() >= startOfThisYear.getTime()) {\n      return year;\n    } else {\n      return year - 1;\n    }\n  }\n\n  function startOfUTCISOWeekYear(dirtyDate) {\n    requiredArgs(1, arguments);\n    var year = getUTCISOWeekYear(dirtyDate);\n    var fourthOfJanuary = new Date(0);\n    fourthOfJanuary.setUTCFullYear(year, 0, 4);\n    fourthOfJanuary.setUTCHours(0, 0, 0, 0);\n    var date = startOfUTCISOWeek(fourthOfJanuary);\n    return date;\n  }\n\n  var MILLISECONDS_IN_WEEK$1 = 604800000;\n  function getUTCISOWeek(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer\n    // because the number of milliseconds in a week is not constant\n    // (e.g. it's different in the week of the daylight saving time clock shift)\n\n    return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;\n  }\n\n  function startOfUTCWeek(dirtyDate, options) {\n    var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(1, arguments);\n    var defaultOptions = getDefaultOptions();\n    var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    var date = toDate(dirtyDate);\n    var day = date.getUTCDay();\n    var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n    date.setUTCDate(date.getUTCDate() - diff);\n    date.setUTCHours(0, 0, 0, 0);\n    return date;\n  }\n\n  function getUTCWeekYear(dirtyDate, options) {\n    var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var year = date.getUTCFullYear();\n    var defaultOptions = getDefaultOptions();\n    var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n\n    if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n      throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n    }\n    var firstWeekOfNextYear = new Date(0);\n    firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);\n    firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);\n    var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);\n    var firstWeekOfThisYear = new Date(0);\n    firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);\n    firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);\n    var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);\n    if (date.getTime() >= startOfNextYear.getTime()) {\n      return year + 1;\n    } else if (date.getTime() >= startOfThisYear.getTime()) {\n      return year;\n    } else {\n      return year - 1;\n    }\n  }\n\n  function startOfUTCWeekYear(dirtyDate, options) {\n    var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(1, arguments);\n    var defaultOptions = getDefaultOptions();\n    var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);\n    var year = getUTCWeekYear(dirtyDate, options);\n    var firstWeek = new Date(0);\n    firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);\n    firstWeek.setUTCHours(0, 0, 0, 0);\n    var date = startOfUTCWeek(firstWeek, options);\n    return date;\n  }\n\n  var MILLISECONDS_IN_WEEK = 604800000;\n  function getUTCWeek(dirtyDate, options) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer\n    // because the number of milliseconds in a week is not constant\n    // (e.g. it's different in the week of the daylight saving time clock shift)\n\n    return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;\n  }\n\n  function addLeadingZeros(number, targetLength) {\n    var sign = number < 0 ? '-' : '';\n    var output = Math.abs(number).toString();\n    while (output.length < targetLength) {\n      output = '0' + output;\n    }\n    return sign + output;\n  }\n\n  /*\n   * |     | Unit                           |     | Unit                           |\n   * |-----|--------------------------------|-----|--------------------------------|\n   * |  a  | AM, PM                         |  A* |                                |\n   * |  d  | Day of month                   |  D  |                                |\n   * |  h  | Hour [1-12]                    |  H  | Hour [0-23]                    |\n   * |  m  | Minute                         |  M  | Month                          |\n   * |  s  | Second                         |  S  | Fraction of second             |\n   * |  y  | Year (abs)                     |  Y  |                                |\n   *\n   * Letters marked by * are not implemented but reserved by Unicode standard.\n   */\n\n  var formatters$2 = {\n    // Year\n    y: function y(date, token) {\n      // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens\n      // | Year     |     y | yy |   yyy |  yyyy | yyyyy |\n      // |----------|-------|----|-------|-------|-------|\n      // | AD 1     |     1 | 01 |   001 |  0001 | 00001 |\n      // | AD 12    |    12 | 12 |   012 |  0012 | 00012 |\n      // | AD 123   |   123 | 23 |   123 |  0123 | 00123 |\n      // | AD 1234  |  1234 | 34 |  1234 |  1234 | 01234 |\n      // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n      var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)\n\n      var year = signedYear > 0 ? signedYear : 1 - signedYear;\n      return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);\n    },\n    // Month\n    M: function M(date, token) {\n      var month = date.getUTCMonth();\n      return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);\n    },\n    // Day of the month\n    d: function d(date, token) {\n      return addLeadingZeros(date.getUTCDate(), token.length);\n    },\n    // AM or PM\n    a: function a(date, token) {\n      var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';\n      switch (token) {\n        case 'a':\n        case 'aa':\n          return dayPeriodEnumValue.toUpperCase();\n        case 'aaa':\n          return dayPeriodEnumValue;\n        case 'aaaaa':\n          return dayPeriodEnumValue[0];\n        case 'aaaa':\n        default:\n          return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';\n      }\n    },\n    // Hour [1-12]\n    h: function h(date, token) {\n      return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);\n    },\n    // Hour [0-23]\n    H: function H(date, token) {\n      return addLeadingZeros(date.getUTCHours(), token.length);\n    },\n    // Minute\n    m: function m(date, token) {\n      return addLeadingZeros(date.getUTCMinutes(), token.length);\n    },\n    // Second\n    s: function s(date, token) {\n      return addLeadingZeros(date.getUTCSeconds(), token.length);\n    },\n    // Fraction of second\n    S: function S(date, token) {\n      var numberOfDigits = token.length;\n      var milliseconds = date.getUTCMilliseconds();\n      var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));\n      return addLeadingZeros(fractionalSeconds, token.length);\n    }\n  };\n  var formatters$3 = formatters$2;\n\n  var dayPeriodEnum = {\n    am: 'am',\n    pm: 'pm',\n    midnight: 'midnight',\n    noon: 'noon',\n    morning: 'morning',\n    afternoon: 'afternoon',\n    evening: 'evening',\n    night: 'night'\n  };\n\n  /*\n   * |     | Unit                           |     | Unit                           |\n   * |-----|--------------------------------|-----|--------------------------------|\n   * |  a  | AM, PM                         |  A* | Milliseconds in day            |\n   * |  b  | AM, PM, noon, midnight         |  B  | Flexible day period            |\n   * |  c  | Stand-alone local day of week  |  C* | Localized hour w/ day period   |\n   * |  d  | Day of month                   |  D  | Day of year                    |\n   * |  e  | Local day of week              |  E  | Day of week                    |\n   * |  f  |                                |  F* | Day of week in month           |\n   * |  g* | Modified Julian day            |  G  | Era                            |\n   * |  h  | Hour [1-12]                    |  H  | Hour [0-23]                    |\n   * |  i! | ISO day of week                |  I! | ISO week of year               |\n   * |  j* | Localized hour w/ day period   |  J* | Localized hour w/o day period  |\n   * |  k  | Hour [1-24]                    |  K  | Hour [0-11]                    |\n   * |  l* | (deprecated)                   |  L  | Stand-alone month              |\n   * |  m  | Minute                         |  M  | Month                          |\n   * |  n  |                                |  N  |                                |\n   * |  o! | Ordinal number modifier        |  O  | Timezone (GMT)                 |\n   * |  p! | Long localized time            |  P! | Long localized date            |\n   * |  q  | Stand-alone quarter            |  Q  | Quarter                        |\n   * |  r* | Related Gregorian year         |  R! | ISO week-numbering year        |\n   * |  s  | Second                         |  S  | Fraction of second             |\n   * |  t! | Seconds timestamp              |  T! | Milliseconds timestamp         |\n   * |  u  | Extended year                  |  U* | Cyclic year                    |\n   * |  v* | Timezone (generic non-locat.)  |  V* | Timezone (location)            |\n   * |  w  | Local week of year             |  W* | Week of month                  |\n   * |  x  | Timezone (ISO-8601 w/o Z)      |  X  | Timezone (ISO-8601)            |\n   * |  y  | Year (abs)                     |  Y  | Local week-numbering year      |\n   * |  z  | Timezone (specific non-locat.) |  Z* | Timezone (aliases)             |\n   *\n   * Letters marked by * are not implemented but reserved by Unicode standard.\n   *\n   * Letters marked by ! are non-standard, but implemented by date-fns:\n   * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)\n   * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,\n   *   i.e. 7 for Sunday, 1 for Monday, etc.\n   * - `I` is ISO week of year, as opposed to `w` which is local week of year.\n   * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.\n   *   `R` is supposed to be used in conjunction with `I` and `i`\n   *   for universal ISO week-numbering date, whereas\n   *   `Y` is supposed to be used in conjunction with `w` and `e`\n   *   for week-numbering date specific to the locale.\n   * - `P` is long localized date format\n   * - `p` is long localized time format\n   */\n  var formatters = {\n    // Era\n    G: function G(date, token, localize) {\n      var era = date.getUTCFullYear() > 0 ? 1 : 0;\n      switch (token) {\n        // AD, BC\n        case 'G':\n        case 'GG':\n        case 'GGG':\n          return localize.era(era, {\n            width: 'abbreviated'\n          });\n        // A, B\n\n        case 'GGGGG':\n          return localize.era(era, {\n            width: 'narrow'\n          });\n        // Anno Domini, Before Christ\n\n        case 'GGGG':\n        default:\n          return localize.era(era, {\n            width: 'wide'\n          });\n      }\n    },\n    // Year\n    y: function y(date, token, localize) {\n      // Ordinal number\n      if (token === 'yo') {\n        var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)\n\n        var year = signedYear > 0 ? signedYear : 1 - signedYear;\n        return localize.ordinalNumber(year, {\n          unit: 'year'\n        });\n      }\n      return formatters$3.y(date, token);\n    },\n    // Local week-numbering year\n    Y: function Y(date, token, localize, options) {\n      var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)\n\n      var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year\n\n      if (token === 'YY') {\n        var twoDigitYear = weekYear % 100;\n        return addLeadingZeros(twoDigitYear, 2);\n      } // Ordinal number\n\n      if (token === 'Yo') {\n        return localize.ordinalNumber(weekYear, {\n          unit: 'year'\n        });\n      } // Padding\n\n      return addLeadingZeros(weekYear, token.length);\n    },\n    // ISO week-numbering year\n    R: function R(date, token) {\n      var isoWeekYear = getUTCISOWeekYear(date); // Padding\n\n      return addLeadingZeros(isoWeekYear, token.length);\n    },\n    // Extended year. This is a single number designating the year of this calendar system.\n    // The main difference between `y` and `u` localizers are B.C. years:\n    // | Year | `y` | `u` |\n    // |------|-----|-----|\n    // | AC 1 |   1 |   1 |\n    // | BC 1 |   1 |   0 |\n    // | BC 2 |   2 |  -1 |\n    // Also `yy` always returns the last two digits of a year,\n    // while `uu` pads single digit years to 2 characters and returns other years unchanged.\n    u: function u(date, token) {\n      var year = date.getUTCFullYear();\n      return addLeadingZeros(year, token.length);\n    },\n    // Quarter\n    Q: function Q(date, token, localize) {\n      var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);\n      switch (token) {\n        // 1, 2, 3, 4\n        case 'Q':\n          return String(quarter);\n        // 01, 02, 03, 04\n\n        case 'QQ':\n          return addLeadingZeros(quarter, 2);\n        // 1st, 2nd, 3rd, 4th\n\n        case 'Qo':\n          return localize.ordinalNumber(quarter, {\n            unit: 'quarter'\n          });\n        // Q1, Q2, Q3, Q4\n\n        case 'QQQ':\n          return localize.quarter(quarter, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n\n        case 'QQQQQ':\n          return localize.quarter(quarter, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        // 1st quarter, 2nd quarter, ...\n\n        case 'QQQQ':\n        default:\n          return localize.quarter(quarter, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // Stand-alone quarter\n    q: function q(date, token, localize) {\n      var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);\n      switch (token) {\n        // 1, 2, 3, 4\n        case 'q':\n          return String(quarter);\n        // 01, 02, 03, 04\n\n        case 'qq':\n          return addLeadingZeros(quarter, 2);\n        // 1st, 2nd, 3rd, 4th\n\n        case 'qo':\n          return localize.ordinalNumber(quarter, {\n            unit: 'quarter'\n          });\n        // Q1, Q2, Q3, Q4\n\n        case 'qqq':\n          return localize.quarter(quarter, {\n            width: 'abbreviated',\n            context: 'standalone'\n          });\n        // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n\n        case 'qqqqq':\n          return localize.quarter(quarter, {\n            width: 'narrow',\n            context: 'standalone'\n          });\n        // 1st quarter, 2nd quarter, ...\n\n        case 'qqqq':\n        default:\n          return localize.quarter(quarter, {\n            width: 'wide',\n            context: 'standalone'\n          });\n      }\n    },\n    // Month\n    M: function M(date, token, localize) {\n      var month = date.getUTCMonth();\n      switch (token) {\n        case 'M':\n        case 'MM':\n          return formatters$3.M(date, token);\n        // 1st, 2nd, ..., 12th\n\n        case 'Mo':\n          return localize.ordinalNumber(month + 1, {\n            unit: 'month'\n          });\n        // Jan, Feb, ..., Dec\n\n        case 'MMM':\n          return localize.month(month, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        // J, F, ..., D\n\n        case 'MMMMM':\n          return localize.month(month, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        // January, February, ..., December\n\n        case 'MMMM':\n        default:\n          return localize.month(month, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // Stand-alone month\n    L: function L(date, token, localize) {\n      var month = date.getUTCMonth();\n      switch (token) {\n        // 1, 2, ..., 12\n        case 'L':\n          return String(month + 1);\n        // 01, 02, ..., 12\n\n        case 'LL':\n          return addLeadingZeros(month + 1, 2);\n        // 1st, 2nd, ..., 12th\n\n        case 'Lo':\n          return localize.ordinalNumber(month + 1, {\n            unit: 'month'\n          });\n        // Jan, Feb, ..., Dec\n\n        case 'LLL':\n          return localize.month(month, {\n            width: 'abbreviated',\n            context: 'standalone'\n          });\n        // J, F, ..., D\n\n        case 'LLLLL':\n          return localize.month(month, {\n            width: 'narrow',\n            context: 'standalone'\n          });\n        // January, February, ..., December\n\n        case 'LLLL':\n        default:\n          return localize.month(month, {\n            width: 'wide',\n            context: 'standalone'\n          });\n      }\n    },\n    // Local week of year\n    w: function w(date, token, localize, options) {\n      var week = getUTCWeek(date, options);\n      if (token === 'wo') {\n        return localize.ordinalNumber(week, {\n          unit: 'week'\n        });\n      }\n      return addLeadingZeros(week, token.length);\n    },\n    // ISO week of year\n    I: function I(date, token, localize) {\n      var isoWeek = getUTCISOWeek(date);\n      if (token === 'Io') {\n        return localize.ordinalNumber(isoWeek, {\n          unit: 'week'\n        });\n      }\n      return addLeadingZeros(isoWeek, token.length);\n    },\n    // Day of the month\n    d: function d(date, token, localize) {\n      if (token === 'do') {\n        return localize.ordinalNumber(date.getUTCDate(), {\n          unit: 'date'\n        });\n      }\n      return formatters$3.d(date, token);\n    },\n    // Day of year\n    D: function D(date, token, localize) {\n      var dayOfYear = getUTCDayOfYear(date);\n      if (token === 'Do') {\n        return localize.ordinalNumber(dayOfYear, {\n          unit: 'dayOfYear'\n        });\n      }\n      return addLeadingZeros(dayOfYear, token.length);\n    },\n    // Day of week\n    E: function E(date, token, localize) {\n      var dayOfWeek = date.getUTCDay();\n      switch (token) {\n        // Tue\n        case 'E':\n        case 'EE':\n        case 'EEE':\n          return localize.day(dayOfWeek, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        // T\n\n        case 'EEEEE':\n          return localize.day(dayOfWeek, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        // Tu\n\n        case 'EEEEEE':\n          return localize.day(dayOfWeek, {\n            width: 'short',\n            context: 'formatting'\n          });\n        // Tuesday\n\n        case 'EEEE':\n        default:\n          return localize.day(dayOfWeek, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // Local day of week\n    e: function e(date, token, localize, options) {\n      var dayOfWeek = date.getUTCDay();\n      var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n      switch (token) {\n        // Numerical value (Nth day of week with current locale or weekStartsOn)\n        case 'e':\n          return String(localDayOfWeek);\n        // Padded numerical value\n\n        case 'ee':\n          return addLeadingZeros(localDayOfWeek, 2);\n        // 1st, 2nd, ..., 7th\n\n        case 'eo':\n          return localize.ordinalNumber(localDayOfWeek, {\n            unit: 'day'\n          });\n        case 'eee':\n          return localize.day(dayOfWeek, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        // T\n\n        case 'eeeee':\n          return localize.day(dayOfWeek, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        // Tu\n\n        case 'eeeeee':\n          return localize.day(dayOfWeek, {\n            width: 'short',\n            context: 'formatting'\n          });\n        // Tuesday\n\n        case 'eeee':\n        default:\n          return localize.day(dayOfWeek, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // Stand-alone local day of week\n    c: function c(date, token, localize, options) {\n      var dayOfWeek = date.getUTCDay();\n      var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n      switch (token) {\n        // Numerical value (same as in `e`)\n        case 'c':\n          return String(localDayOfWeek);\n        // Padded numerical value\n\n        case 'cc':\n          return addLeadingZeros(localDayOfWeek, token.length);\n        // 1st, 2nd, ..., 7th\n\n        case 'co':\n          return localize.ordinalNumber(localDayOfWeek, {\n            unit: 'day'\n          });\n        case 'ccc':\n          return localize.day(dayOfWeek, {\n            width: 'abbreviated',\n            context: 'standalone'\n          });\n        // T\n\n        case 'ccccc':\n          return localize.day(dayOfWeek, {\n            width: 'narrow',\n            context: 'standalone'\n          });\n        // Tu\n\n        case 'cccccc':\n          return localize.day(dayOfWeek, {\n            width: 'short',\n            context: 'standalone'\n          });\n        // Tuesday\n\n        case 'cccc':\n        default:\n          return localize.day(dayOfWeek, {\n            width: 'wide',\n            context: 'standalone'\n          });\n      }\n    },\n    // ISO day of week\n    i: function i(date, token, localize) {\n      var dayOfWeek = date.getUTCDay();\n      var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;\n      switch (token) {\n        // 2\n        case 'i':\n          return String(isoDayOfWeek);\n        // 02\n\n        case 'ii':\n          return addLeadingZeros(isoDayOfWeek, token.length);\n        // 2nd\n\n        case 'io':\n          return localize.ordinalNumber(isoDayOfWeek, {\n            unit: 'day'\n          });\n        // Tue\n\n        case 'iii':\n          return localize.day(dayOfWeek, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        // T\n\n        case 'iiiii':\n          return localize.day(dayOfWeek, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        // Tu\n\n        case 'iiiiii':\n          return localize.day(dayOfWeek, {\n            width: 'short',\n            context: 'formatting'\n          });\n        // Tuesday\n\n        case 'iiii':\n        default:\n          return localize.day(dayOfWeek, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // AM or PM\n    a: function a(date, token, localize) {\n      var hours = date.getUTCHours();\n      var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';\n      switch (token) {\n        case 'a':\n        case 'aa':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        case 'aaa':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'abbreviated',\n            context: 'formatting'\n          }).toLowerCase();\n        case 'aaaaa':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        case 'aaaa':\n        default:\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // AM, PM, midnight, noon\n    b: function b(date, token, localize) {\n      var hours = date.getUTCHours();\n      var dayPeriodEnumValue;\n      if (hours === 12) {\n        dayPeriodEnumValue = dayPeriodEnum.noon;\n      } else if (hours === 0) {\n        dayPeriodEnumValue = dayPeriodEnum.midnight;\n      } else {\n        dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';\n      }\n      switch (token) {\n        case 'b':\n        case 'bb':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        case 'bbb':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'abbreviated',\n            context: 'formatting'\n          }).toLowerCase();\n        case 'bbbbb':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        case 'bbbb':\n        default:\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // in the morning, in the afternoon, in the evening, at night\n    B: function B(date, token, localize) {\n      var hours = date.getUTCHours();\n      var dayPeriodEnumValue;\n      if (hours >= 17) {\n        dayPeriodEnumValue = dayPeriodEnum.evening;\n      } else if (hours >= 12) {\n        dayPeriodEnumValue = dayPeriodEnum.afternoon;\n      } else if (hours >= 4) {\n        dayPeriodEnumValue = dayPeriodEnum.morning;\n      } else {\n        dayPeriodEnumValue = dayPeriodEnum.night;\n      }\n      switch (token) {\n        case 'B':\n        case 'BB':\n        case 'BBB':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'abbreviated',\n            context: 'formatting'\n          });\n        case 'BBBBB':\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'narrow',\n            context: 'formatting'\n          });\n        case 'BBBB':\n        default:\n          return localize.dayPeriod(dayPeriodEnumValue, {\n            width: 'wide',\n            context: 'formatting'\n          });\n      }\n    },\n    // Hour [1-12]\n    h: function h(date, token, localize) {\n      if (token === 'ho') {\n        var hours = date.getUTCHours() % 12;\n        if (hours === 0) hours = 12;\n        return localize.ordinalNumber(hours, {\n          unit: 'hour'\n        });\n      }\n      return formatters$3.h(date, token);\n    },\n    // Hour [0-23]\n    H: function H(date, token, localize) {\n      if (token === 'Ho') {\n        return localize.ordinalNumber(date.getUTCHours(), {\n          unit: 'hour'\n        });\n      }\n      return formatters$3.H(date, token);\n    },\n    // Hour [0-11]\n    K: function K(date, token, localize) {\n      var hours = date.getUTCHours() % 12;\n      if (token === 'Ko') {\n        return localize.ordinalNumber(hours, {\n          unit: 'hour'\n        });\n      }\n      return addLeadingZeros(hours, token.length);\n    },\n    // Hour [1-24]\n    k: function k(date, token, localize) {\n      var hours = date.getUTCHours();\n      if (hours === 0) hours = 24;\n      if (token === 'ko') {\n        return localize.ordinalNumber(hours, {\n          unit: 'hour'\n        });\n      }\n      return addLeadingZeros(hours, token.length);\n    },\n    // Minute\n    m: function m(date, token, localize) {\n      if (token === 'mo') {\n        return localize.ordinalNumber(date.getUTCMinutes(), {\n          unit: 'minute'\n        });\n      }\n      return formatters$3.m(date, token);\n    },\n    // Second\n    s: function s(date, token, localize) {\n      if (token === 'so') {\n        return localize.ordinalNumber(date.getUTCSeconds(), {\n          unit: 'second'\n        });\n      }\n      return formatters$3.s(date, token);\n    },\n    // Fraction of second\n    S: function S(date, token) {\n      return formatters$3.S(date, token);\n    },\n    // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)\n    X: function X(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timezoneOffset = originalDate.getTimezoneOffset();\n      if (timezoneOffset === 0) {\n        return 'Z';\n      }\n      switch (token) {\n        // Hours and optional minutes\n        case 'X':\n          return formatTimezoneWithOptionalMinutes(timezoneOffset);\n        // Hours, minutes and optional seconds without `:` delimiter\n        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n        // so this token always has the same output as `XX`\n\n        case 'XXXX':\n        case 'XX':\n          // Hours and minutes without `:` delimiter\n          return formatTimezone(timezoneOffset);\n        // Hours, minutes and optional seconds with `:` delimiter\n        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n        // so this token always has the same output as `XXX`\n\n        case 'XXXXX':\n        case 'XXX': // Hours and minutes with `:` delimiter\n\n        default:\n          return formatTimezone(timezoneOffset, ':');\n      }\n    },\n    // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)\n    x: function x(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timezoneOffset = originalDate.getTimezoneOffset();\n      switch (token) {\n        // Hours and optional minutes\n        case 'x':\n          return formatTimezoneWithOptionalMinutes(timezoneOffset);\n        // Hours, minutes and optional seconds without `:` delimiter\n        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n        // so this token always has the same output as `xx`\n\n        case 'xxxx':\n        case 'xx':\n          // Hours and minutes without `:` delimiter\n          return formatTimezone(timezoneOffset);\n        // Hours, minutes and optional seconds with `:` delimiter\n        // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n        // so this token always has the same output as `xxx`\n\n        case 'xxxxx':\n        case 'xxx': // Hours and minutes with `:` delimiter\n\n        default:\n          return formatTimezone(timezoneOffset, ':');\n      }\n    },\n    // Timezone (GMT)\n    O: function O(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timezoneOffset = originalDate.getTimezoneOffset();\n      switch (token) {\n        // Short\n        case 'O':\n        case 'OO':\n        case 'OOO':\n          return 'GMT' + formatTimezoneShort(timezoneOffset, ':');\n        // Long\n\n        case 'OOOO':\n        default:\n          return 'GMT' + formatTimezone(timezoneOffset, ':');\n      }\n    },\n    // Timezone (specific non-location)\n    z: function z(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timezoneOffset = originalDate.getTimezoneOffset();\n      switch (token) {\n        // Short\n        case 'z':\n        case 'zz':\n        case 'zzz':\n          return 'GMT' + formatTimezoneShort(timezoneOffset, ':');\n        // Long\n\n        case 'zzzz':\n        default:\n          return 'GMT' + formatTimezone(timezoneOffset, ':');\n      }\n    },\n    // Seconds timestamp\n    t: function t(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timestamp = Math.floor(originalDate.getTime() / 1000);\n      return addLeadingZeros(timestamp, token.length);\n    },\n    // Milliseconds timestamp\n    T: function T(date, token, _localize, options) {\n      var originalDate = options._originalDate || date;\n      var timestamp = originalDate.getTime();\n      return addLeadingZeros(timestamp, token.length);\n    }\n  };\n  function formatTimezoneShort(offset, dirtyDelimiter) {\n    var sign = offset > 0 ? '-' : '+';\n    var absOffset = Math.abs(offset);\n    var hours = Math.floor(absOffset / 60);\n    var minutes = absOffset % 60;\n    if (minutes === 0) {\n      return sign + String(hours);\n    }\n    var delimiter = dirtyDelimiter || '';\n    return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);\n  }\n  function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {\n    if (offset % 60 === 0) {\n      var sign = offset > 0 ? '-' : '+';\n      return sign + addLeadingZeros(Math.abs(offset) / 60, 2);\n    }\n    return formatTimezone(offset, dirtyDelimiter);\n  }\n  function formatTimezone(offset, dirtyDelimiter) {\n    var delimiter = dirtyDelimiter || '';\n    var sign = offset > 0 ? '-' : '+';\n    var absOffset = Math.abs(offset);\n    var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);\n    var minutes = addLeadingZeros(absOffset % 60, 2);\n    return sign + hours + delimiter + minutes;\n  }\n  var formatters$1 = formatters;\n\n  var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {\n    switch (pattern) {\n      case 'P':\n        return formatLong.date({\n          width: 'short'\n        });\n      case 'PP':\n        return formatLong.date({\n          width: 'medium'\n        });\n      case 'PPP':\n        return formatLong.date({\n          width: 'long'\n        });\n      case 'PPPP':\n      default:\n        return formatLong.date({\n          width: 'full'\n        });\n    }\n  };\n  var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {\n    switch (pattern) {\n      case 'p':\n        return formatLong.time({\n          width: 'short'\n        });\n      case 'pp':\n        return formatLong.time({\n          width: 'medium'\n        });\n      case 'ppp':\n        return formatLong.time({\n          width: 'long'\n        });\n      case 'pppp':\n      default:\n        return formatLong.time({\n          width: 'full'\n        });\n    }\n  };\n  var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {\n    var matchResult = pattern.match(/(P+)(p+)?/) || [];\n    var datePattern = matchResult[1];\n    var timePattern = matchResult[2];\n    if (!timePattern) {\n      return dateLongFormatter(pattern, formatLong);\n    }\n    var dateTimeFormat;\n    switch (datePattern) {\n      case 'P':\n        dateTimeFormat = formatLong.dateTime({\n          width: 'short'\n        });\n        break;\n      case 'PP':\n        dateTimeFormat = formatLong.dateTime({\n          width: 'medium'\n        });\n        break;\n      case 'PPP':\n        dateTimeFormat = formatLong.dateTime({\n          width: 'long'\n        });\n        break;\n      case 'PPPP':\n      default:\n        dateTimeFormat = formatLong.dateTime({\n          width: 'full'\n        });\n        break;\n    }\n    return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));\n  };\n  var longFormatters = {\n    p: timeLongFormatter,\n    P: dateTimeLongFormatter\n  };\n  var longFormatters$1 = longFormatters;\n\n  var protectedDayOfYearTokens = ['D', 'DD'];\n  var protectedWeekYearTokens = ['YY', 'YYYY'];\n  function isProtectedDayOfYearToken(token) {\n    return protectedDayOfYearTokens.indexOf(token) !== -1;\n  }\n  function isProtectedWeekYearToken(token) {\n    return protectedWeekYearTokens.indexOf(token) !== -1;\n  }\n  function throwProtectedError(token, format, input) {\n    if (token === 'YYYY') {\n      throw new RangeError(\"Use `yyyy` instead of `YYYY` (in `\".concat(format, \"`) for formatting years to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n    } else if (token === 'YY') {\n      throw new RangeError(\"Use `yy` instead of `YY` (in `\".concat(format, \"`) for formatting years to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n    } else if (token === 'D') {\n      throw new RangeError(\"Use `d` instead of `D` (in `\".concat(format, \"`) for formatting days of the month to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n    } else if (token === 'DD') {\n      throw new RangeError(\"Use `dd` instead of `DD` (in `\".concat(format, \"`) for formatting days of the month to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n    }\n  }\n\n  var formatDistanceLocale = {\n    lessThanXSeconds: {\n      one: 'less than a second',\n      other: 'less than {{count}} seconds'\n    },\n    xSeconds: {\n      one: '1 second',\n      other: '{{count}} seconds'\n    },\n    halfAMinute: 'half a minute',\n    lessThanXMinutes: {\n      one: 'less than a minute',\n      other: 'less than {{count}} minutes'\n    },\n    xMinutes: {\n      one: '1 minute',\n      other: '{{count}} minutes'\n    },\n    aboutXHours: {\n      one: 'about 1 hour',\n      other: 'about {{count}} hours'\n    },\n    xHours: {\n      one: '1 hour',\n      other: '{{count}} hours'\n    },\n    xDays: {\n      one: '1 day',\n      other: '{{count}} days'\n    },\n    aboutXWeeks: {\n      one: 'about 1 week',\n      other: 'about {{count}} weeks'\n    },\n    xWeeks: {\n      one: '1 week',\n      other: '{{count}} weeks'\n    },\n    aboutXMonths: {\n      one: 'about 1 month',\n      other: 'about {{count}} months'\n    },\n    xMonths: {\n      one: '1 month',\n      other: '{{count}} months'\n    },\n    aboutXYears: {\n      one: 'about 1 year',\n      other: 'about {{count}} years'\n    },\n    xYears: {\n      one: '1 year',\n      other: '{{count}} years'\n    },\n    overXYears: {\n      one: 'over 1 year',\n      other: 'over {{count}} years'\n    },\n    almostXYears: {\n      one: 'almost 1 year',\n      other: 'almost {{count}} years'\n    }\n  };\n  var formatDistance = function formatDistance(token, count, options) {\n    var result;\n    var tokenValue = formatDistanceLocale[token];\n    if (typeof tokenValue === 'string') {\n      result = tokenValue;\n    } else if (count === 1) {\n      result = tokenValue.one;\n    } else {\n      result = tokenValue.other.replace('{{count}}', count.toString());\n    }\n    if (options !== null && options !== void 0 && options.addSuffix) {\n      if (options.comparison && options.comparison > 0) {\n        return 'in ' + result;\n      } else {\n        return result + ' ago';\n      }\n    }\n    return result;\n  };\n  var formatDistance$1 = formatDistance;\n\n  function buildFormatLongFn(args) {\n    return function () {\n      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n      // TODO: Remove String()\n      var width = options.width ? String(options.width) : args.defaultWidth;\n      var format = args.formats[width] || args.formats[args.defaultWidth];\n      return format;\n    };\n  }\n\n  var dateFormats = {\n    full: 'EEEE, MMMM do, y',\n    \"long\": 'MMMM do, y',\n    medium: 'MMM d, y',\n    \"short\": 'MM/dd/yyyy'\n  };\n  var timeFormats = {\n    full: 'h:mm:ss a zzzz',\n    \"long\": 'h:mm:ss a z',\n    medium: 'h:mm:ss a',\n    \"short\": 'h:mm a'\n  };\n  var dateTimeFormats = {\n    full: \"{{date}} 'at' {{time}}\",\n    \"long\": \"{{date}} 'at' {{time}}\",\n    medium: '{{date}}, {{time}}',\n    \"short\": '{{date}}, {{time}}'\n  };\n  var formatLong = {\n    date: buildFormatLongFn({\n      formats: dateFormats,\n      defaultWidth: 'full'\n    }),\n    time: buildFormatLongFn({\n      formats: timeFormats,\n      defaultWidth: 'full'\n    }),\n    dateTime: buildFormatLongFn({\n      formats: dateTimeFormats,\n      defaultWidth: 'full'\n    })\n  };\n  var formatLong$1 = formatLong;\n\n  var formatRelativeLocale = {\n    lastWeek: \"'last' eeee 'at' p\",\n    yesterday: \"'yesterday at' p\",\n    today: \"'today at' p\",\n    tomorrow: \"'tomorrow at' p\",\n    nextWeek: \"eeee 'at' p\",\n    other: 'P'\n  };\n  var formatRelative = function formatRelative(token, _date, _baseDate, _options) {\n    return formatRelativeLocale[token];\n  };\n  var formatRelative$1 = formatRelative;\n\n  function buildLocalizeFn(args) {\n    return function (dirtyIndex, options) {\n      var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';\n      var valuesArray;\n      if (context === 'formatting' && args.formattingValues) {\n        var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;\n        var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;\n        valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];\n      } else {\n        var _defaultWidth = args.defaultWidth;\n        var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;\n        valuesArray = args.values[_width] || args.values[_defaultWidth];\n      }\n      var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!\n\n      return valuesArray[index];\n    };\n  }\n\n  var eraValues = {\n    narrow: ['B', 'A'],\n    abbreviated: ['BC', 'AD'],\n    wide: ['Before Christ', 'Anno Domini']\n  };\n  var quarterValues = {\n    narrow: ['1', '2', '3', '4'],\n    abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],\n    wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']\n  }; // Note: in English, the names of days of the week and months are capitalized.\n  // If you are making a new locale based on this one, check if the same is true for the language you're working on.\n  // Generally, formatted dates should look like they are in the middle of a sentence,\n  // e.g. in Spanish language the weekdays and months should be in the lowercase.\n\n  var monthValues = {\n    narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],\n    abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n    wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n  };\n  var dayValues = {\n    narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n    \"short\": ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],\n    abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n    wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\n  };\n  var dayPeriodValues = {\n    narrow: {\n      am: 'a',\n      pm: 'p',\n      midnight: 'mi',\n      noon: 'n',\n      morning: 'morning',\n      afternoon: 'afternoon',\n      evening: 'evening',\n      night: 'night'\n    },\n    abbreviated: {\n      am: 'AM',\n      pm: 'PM',\n      midnight: 'midnight',\n      noon: 'noon',\n      morning: 'morning',\n      afternoon: 'afternoon',\n      evening: 'evening',\n      night: 'night'\n    },\n    wide: {\n      am: 'a.m.',\n      pm: 'p.m.',\n      midnight: 'midnight',\n      noon: 'noon',\n      morning: 'morning',\n      afternoon: 'afternoon',\n      evening: 'evening',\n      night: 'night'\n    }\n  };\n  var formattingDayPeriodValues = {\n    narrow: {\n      am: 'a',\n      pm: 'p',\n      midnight: 'mi',\n      noon: 'n',\n      morning: 'in the morning',\n      afternoon: 'in the afternoon',\n      evening: 'in the evening',\n      night: 'at night'\n    },\n    abbreviated: {\n      am: 'AM',\n      pm: 'PM',\n      midnight: 'midnight',\n      noon: 'noon',\n      morning: 'in the morning',\n      afternoon: 'in the afternoon',\n      evening: 'in the evening',\n      night: 'at night'\n    },\n    wide: {\n      am: 'a.m.',\n      pm: 'p.m.',\n      midnight: 'midnight',\n      noon: 'noon',\n      morning: 'in the morning',\n      afternoon: 'in the afternoon',\n      evening: 'in the evening',\n      night: 'at night'\n    }\n  };\n  var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {\n    var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,\n    // if they are different for different grammatical genders,\n    // use `options.unit`.\n    //\n    // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',\n    // 'day', 'hour', 'minute', 'second'.\n\n    var rem100 = number % 100;\n    if (rem100 > 20 || rem100 < 10) {\n      switch (rem100 % 10) {\n        case 1:\n          return number + 'st';\n        case 2:\n          return number + 'nd';\n        case 3:\n          return number + 'rd';\n      }\n    }\n    return number + 'th';\n  };\n  var localize = {\n    ordinalNumber: ordinalNumber,\n    era: buildLocalizeFn({\n      values: eraValues,\n      defaultWidth: 'wide'\n    }),\n    quarter: buildLocalizeFn({\n      values: quarterValues,\n      defaultWidth: 'wide',\n      argumentCallback: function argumentCallback(quarter) {\n        return quarter - 1;\n      }\n    }),\n    month: buildLocalizeFn({\n      values: monthValues,\n      defaultWidth: 'wide'\n    }),\n    day: buildLocalizeFn({\n      values: dayValues,\n      defaultWidth: 'wide'\n    }),\n    dayPeriod: buildLocalizeFn({\n      values: dayPeriodValues,\n      defaultWidth: 'wide',\n      formattingValues: formattingDayPeriodValues,\n      defaultFormattingWidth: 'wide'\n    })\n  };\n  var localize$1 = localize;\n\n  function buildMatchFn(args) {\n    return function (string) {\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var width = options.width;\n      var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];\n      var matchResult = string.match(matchPattern);\n      if (!matchResult) {\n        return null;\n      }\n      var matchedString = matchResult[0];\n      var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];\n      var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {\n        return pattern.test(matchedString);\n      }) : findKey(parsePatterns, function (pattern) {\n        return pattern.test(matchedString);\n      });\n      var value;\n      value = args.valueCallback ? args.valueCallback(key) : key;\n      value = options.valueCallback ? options.valueCallback(value) : value;\n      var rest = string.slice(matchedString.length);\n      return {\n        value: value,\n        rest: rest\n      };\n    };\n  }\n  function findKey(object, predicate) {\n    for (var key in object) {\n      if (object.hasOwnProperty(key) && predicate(object[key])) {\n        return key;\n      }\n    }\n    return undefined;\n  }\n  function findIndex(array, predicate) {\n    for (var key = 0; key < array.length; key++) {\n      if (predicate(array[key])) {\n        return key;\n      }\n    }\n    return undefined;\n  }\n\n  function buildMatchPatternFn(args) {\n    return function (string) {\n      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      var matchResult = string.match(args.matchPattern);\n      if (!matchResult) return null;\n      var matchedString = matchResult[0];\n      var parseResult = string.match(args.parsePattern);\n      if (!parseResult) return null;\n      var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];\n      value = options.valueCallback ? options.valueCallback(value) : value;\n      var rest = string.slice(matchedString.length);\n      return {\n        value: value,\n        rest: rest\n      };\n    };\n  }\n\n  var matchOrdinalNumberPattern = /^(\\d+)(th|st|nd|rd)?/i;\n  var parseOrdinalNumberPattern = /\\d+/i;\n  var matchEraPatterns = {\n    narrow: /^(b|a)/i,\n    abbreviated: /^(b\\.?\\s?c\\.?|b\\.?\\s?c\\.?\\s?e\\.?|a\\.?\\s?d\\.?|c\\.?\\s?e\\.?)/i,\n    wide: /^(before christ|before common era|anno domini|common era)/i\n  };\n  var parseEraPatterns = {\n    any: [/^b/i, /^(a|c)/i]\n  };\n  var matchQuarterPatterns = {\n    narrow: /^[1234]/i,\n    abbreviated: /^q[1234]/i,\n    wide: /^[1234](th|st|nd|rd)? quarter/i\n  };\n  var parseQuarterPatterns = {\n    any: [/1/i, /2/i, /3/i, /4/i]\n  };\n  var matchMonthPatterns = {\n    narrow: /^[jfmasond]/i,\n    abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,\n    wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i\n  };\n  var parseMonthPatterns = {\n    narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],\n    any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]\n  };\n  var matchDayPatterns = {\n    narrow: /^[smtwf]/i,\n    \"short\": /^(su|mo|tu|we|th|fr|sa)/i,\n    abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,\n    wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i\n  };\n  var parseDayPatterns = {\n    narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],\n    any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]\n  };\n  var matchDayPeriodPatterns = {\n    narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,\n    any: /^([ap]\\.?\\s?m\\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i\n  };\n  var parseDayPeriodPatterns = {\n    any: {\n      am: /^a/i,\n      pm: /^p/i,\n      midnight: /^mi/i,\n      noon: /^no/i,\n      morning: /morning/i,\n      afternoon: /afternoon/i,\n      evening: /evening/i,\n      night: /night/i\n    }\n  };\n  var match = {\n    ordinalNumber: buildMatchPatternFn({\n      matchPattern: matchOrdinalNumberPattern,\n      parsePattern: parseOrdinalNumberPattern,\n      valueCallback: function valueCallback(value) {\n        return parseInt(value, 10);\n      }\n    }),\n    era: buildMatchFn({\n      matchPatterns: matchEraPatterns,\n      defaultMatchWidth: 'wide',\n      parsePatterns: parseEraPatterns,\n      defaultParseWidth: 'any'\n    }),\n    quarter: buildMatchFn({\n      matchPatterns: matchQuarterPatterns,\n      defaultMatchWidth: 'wide',\n      parsePatterns: parseQuarterPatterns,\n      defaultParseWidth: 'any',\n      valueCallback: function valueCallback(index) {\n        return index + 1;\n      }\n    }),\n    month: buildMatchFn({\n      matchPatterns: matchMonthPatterns,\n      defaultMatchWidth: 'wide',\n      parsePatterns: parseMonthPatterns,\n      defaultParseWidth: 'any'\n    }),\n    day: buildMatchFn({\n      matchPatterns: matchDayPatterns,\n      defaultMatchWidth: 'wide',\n      parsePatterns: parseDayPatterns,\n      defaultParseWidth: 'any'\n    }),\n    dayPeriod: buildMatchFn({\n      matchPatterns: matchDayPeriodPatterns,\n      defaultMatchWidth: 'any',\n      parsePatterns: parseDayPeriodPatterns,\n      defaultParseWidth: 'any'\n    })\n  };\n  var match$1 = match;\n\n  /**\n   * @type {Locale}\n   * @category Locales\n   * @summary English locale (United States).\n   * @language English\n   * @iso-639-2 eng\n   * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}\n   * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}\n   */\n  var locale = {\n    code: 'en-US',\n    formatDistance: formatDistance$1,\n    formatLong: formatLong$1,\n    formatRelative: formatRelative$1,\n    localize: localize$1,\n    match: match$1,\n    options: {\n      weekStartsOn: 0\n      /* Sunday */,\n\n      firstWeekContainsDate: 1\n    }\n  };\n  var defaultLocale = locale;\n\n  // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token\n  //   (one of the certain letters followed by `o`)\n  // - (\\w)\\1* matches any sequences of the same letter\n  // - '' matches two quote characters in a row\n  // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n  //   except a single quote symbol, which ends the sequence.\n  //   Two quote characters do not end the sequence.\n  //   If there is no matching single quote\n  //   then the sequence will continue until the end of the string.\n  // - . matches any single character unmatched by previous parts of the RegExps\n\n  var formattingTokensRegExp$1 = /[yYQqMLwIdDecihHKkms]o|(\\w)\\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also\n  // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`\n\n  var longFormattingTokensRegExp$1 = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;\n  var escapedStringRegExp$1 = /^'([^]*?)'?$/;\n  var doubleQuoteRegExp$1 = /''/g;\n  var unescapedLatinCharacterRegExp$1 = /[a-zA-Z]/;\n  /**\n   * @name format\n   * @category Common Helpers\n   * @summary Format the date.\n   *\n   * @description\n   * Return the formatted date string in the given format. The result may vary by locale.\n   *\n   * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.\n   * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * The characters wrapped between two single quotes characters (') are escaped.\n   * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n   * (see the last example)\n   *\n   * Format of the string is based on Unicode Technical Standard #35:\n   * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n   * with a few additions (see note 7 below the table).\n   *\n   * Accepted patterns:\n   * | Unit                            | Pattern | Result examples                   | Notes |\n   * |---------------------------------|---------|-----------------------------------|-------|\n   * | Era                             | G..GGG  | AD, BC                            |       |\n   * |                                 | GGGG    | Anno Domini, Before Christ        | 2     |\n   * |                                 | GGGGG   | A, B                              |       |\n   * | Calendar year                   | y       | 44, 1, 1900, 2017                 | 5     |\n   * |                                 | yo      | 44th, 1st, 0th, 17th              | 5,7   |\n   * |                                 | yy      | 44, 01, 00, 17                    | 5     |\n   * |                                 | yyy     | 044, 001, 1900, 2017              | 5     |\n   * |                                 | yyyy    | 0044, 0001, 1900, 2017            | 5     |\n   * |                                 | yyyyy   | ...                               | 3,5   |\n   * | Local week-numbering year       | Y       | 44, 1, 1900, 2017                 | 5     |\n   * |                                 | Yo      | 44th, 1st, 1900th, 2017th         | 5,7   |\n   * |                                 | YY      | 44, 01, 00, 17                    | 5,8   |\n   * |                                 | YYY     | 044, 001, 1900, 2017              | 5     |\n   * |                                 | YYYY    | 0044, 0001, 1900, 2017            | 5,8   |\n   * |                                 | YYYYY   | ...                               | 3,5   |\n   * | ISO week-numbering year         | R       | -43, 0, 1, 1900, 2017             | 5,7   |\n   * |                                 | RR      | -43, 00, 01, 1900, 2017           | 5,7   |\n   * |                                 | RRR     | -043, 000, 001, 1900, 2017        | 5,7   |\n   * |                                 | RRRR    | -0043, 0000, 0001, 1900, 2017     | 5,7   |\n   * |                                 | RRRRR   | ...                               | 3,5,7 |\n   * | Extended year                   | u       | -43, 0, 1, 1900, 2017             | 5     |\n   * |                                 | uu      | -43, 01, 1900, 2017               | 5     |\n   * |                                 | uuu     | -043, 001, 1900, 2017             | 5     |\n   * |                                 | uuuu    | -0043, 0001, 1900, 2017           | 5     |\n   * |                                 | uuuuu   | ...                               | 3,5   |\n   * | Quarter (formatting)            | Q       | 1, 2, 3, 4                        |       |\n   * |                                 | Qo      | 1st, 2nd, 3rd, 4th                | 7     |\n   * |                                 | QQ      | 01, 02, 03, 04                    |       |\n   * |                                 | QQQ     | Q1, Q2, Q3, Q4                    |       |\n   * |                                 | QQQQ    | 1st quarter, 2nd quarter, ...     | 2     |\n   * |                                 | QQQQQ   | 1, 2, 3, 4                        | 4     |\n   * | Quarter (stand-alone)           | q       | 1, 2, 3, 4                        |       |\n   * |                                 | qo      | 1st, 2nd, 3rd, 4th                | 7     |\n   * |                                 | qq      | 01, 02, 03, 04                    |       |\n   * |                                 | qqq     | Q1, Q2, Q3, Q4                    |       |\n   * |                                 | qqqq    | 1st quarter, 2nd quarter, ...     | 2     |\n   * |                                 | qqqqq   | 1, 2, 3, 4                        | 4     |\n   * | Month (formatting)              | M       | 1, 2, ..., 12                     |       |\n   * |                                 | Mo      | 1st, 2nd, ..., 12th               | 7     |\n   * |                                 | MM      | 01, 02, ..., 12                   |       |\n   * |                                 | MMM     | Jan, Feb, ..., Dec                |       |\n   * |                                 | MMMM    | January, February, ..., December  | 2     |\n   * |                                 | MMMMM   | J, F, ..., D                      |       |\n   * | Month (stand-alone)             | L       | 1, 2, ..., 12                     |       |\n   * |                                 | Lo      | 1st, 2nd, ..., 12th               | 7     |\n   * |                                 | LL      | 01, 02, ..., 12                   |       |\n   * |                                 | LLL     | Jan, Feb, ..., Dec                |       |\n   * |                                 | LLLL    | January, February, ..., December  | 2     |\n   * |                                 | LLLLL   | J, F, ..., D                      |       |\n   * | Local week of year              | w       | 1, 2, ..., 53                     |       |\n   * |                                 | wo      | 1st, 2nd, ..., 53th               | 7     |\n   * |                                 | ww      | 01, 02, ..., 53                   |       |\n   * | ISO week of year                | I       | 1, 2, ..., 53                     | 7     |\n   * |                                 | Io      | 1st, 2nd, ..., 53th               | 7     |\n   * |                                 | II      | 01, 02, ..., 53                   | 7     |\n   * | Day of month                    | d       | 1, 2, ..., 31                     |       |\n   * |                                 | do      | 1st, 2nd, ..., 31st               | 7     |\n   * |                                 | dd      | 01, 02, ..., 31                   |       |\n   * | Day of year                     | D       | 1, 2, ..., 365, 366               | 9     |\n   * |                                 | Do      | 1st, 2nd, ..., 365th, 366th       | 7     |\n   * |                                 | DD      | 01, 02, ..., 365, 366             | 9     |\n   * |                                 | DDD     | 001, 002, ..., 365, 366           |       |\n   * |                                 | DDDD    | ...                               | 3     |\n   * | Day of week (formatting)        | E..EEE  | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 | EEEE    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 | EEEEE   | M, T, W, T, F, S, S               |       |\n   * |                                 | EEEEEE  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | ISO day of week (formatting)    | i       | 1, 2, 3, ..., 7                   | 7     |\n   * |                                 | io      | 1st, 2nd, ..., 7th                | 7     |\n   * |                                 | ii      | 01, 02, ..., 07                   | 7     |\n   * |                                 | iii     | Mon, Tue, Wed, ..., Sun           | 7     |\n   * |                                 | iiii    | Monday, Tuesday, ..., Sunday      | 2,7   |\n   * |                                 | iiiii   | M, T, W, T, F, S, S               | 7     |\n   * |                                 | iiiiii  | Mo, Tu, We, Th, Fr, Sa, Su        | 7     |\n   * | Local day of week (formatting)  | e       | 2, 3, 4, ..., 1                   |       |\n   * |                                 | eo      | 2nd, 3rd, ..., 1st                | 7     |\n   * |                                 | ee      | 02, 03, ..., 01                   |       |\n   * |                                 | eee     | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 | eeee    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 | eeeee   | M, T, W, T, F, S, S               |       |\n   * |                                 | eeeeee  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | Local day of week (stand-alone) | c       | 2, 3, 4, ..., 1                   |       |\n   * |                                 | co      | 2nd, 3rd, ..., 1st                | 7     |\n   * |                                 | cc      | 02, 03, ..., 01                   |       |\n   * |                                 | ccc     | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 | cccc    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 | ccccc   | M, T, W, T, F, S, S               |       |\n   * |                                 | cccccc  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | AM, PM                          | a..aa   | AM, PM                            |       |\n   * |                                 | aaa     | am, pm                            |       |\n   * |                                 | aaaa    | a.m., p.m.                        | 2     |\n   * |                                 | aaaaa   | a, p                              |       |\n   * | AM, PM, noon, midnight          | b..bb   | AM, PM, noon, midnight            |       |\n   * |                                 | bbb     | am, pm, noon, midnight            |       |\n   * |                                 | bbbb    | a.m., p.m., noon, midnight        | 2     |\n   * |                                 | bbbbb   | a, p, n, mi                       |       |\n   * | Flexible day period             | B..BBB  | at night, in the morning, ...     |       |\n   * |                                 | BBBB    | at night, in the morning, ...     | 2     |\n   * |                                 | BBBBB   | at night, in the morning, ...     |       |\n   * | Hour [1-12]                     | h       | 1, 2, ..., 11, 12                 |       |\n   * |                                 | ho      | 1st, 2nd, ..., 11th, 12th         | 7     |\n   * |                                 | hh      | 01, 02, ..., 11, 12               |       |\n   * | Hour [0-23]                     | H       | 0, 1, 2, ..., 23                  |       |\n   * |                                 | Ho      | 0th, 1st, 2nd, ..., 23rd          | 7     |\n   * |                                 | HH      | 00, 01, 02, ..., 23               |       |\n   * | Hour [0-11]                     | K       | 1, 2, ..., 11, 0                  |       |\n   * |                                 | Ko      | 1st, 2nd, ..., 11th, 0th          | 7     |\n   * |                                 | KK      | 01, 02, ..., 11, 00               |       |\n   * | Hour [1-24]                     | k       | 24, 1, 2, ..., 23                 |       |\n   * |                                 | ko      | 24th, 1st, 2nd, ..., 23rd         | 7     |\n   * |                                 | kk      | 24, 01, 02, ..., 23               |       |\n   * | Minute                          | m       | 0, 1, ..., 59                     |       |\n   * |                                 | mo      | 0th, 1st, ..., 59th               | 7     |\n   * |                                 | mm      | 00, 01, ..., 59                   |       |\n   * | Second                          | s       | 0, 1, ..., 59                     |       |\n   * |                                 | so      | 0th, 1st, ..., 59th               | 7     |\n   * |                                 | ss      | 00, 01, ..., 59                   |       |\n   * | Fraction of second              | S       | 0, 1, ..., 9                      |       |\n   * |                                 | SS      | 00, 01, ..., 99                   |       |\n   * |                                 | SSS     | 000, 001, ..., 999                |       |\n   * |                                 | SSSS    | ...                               | 3     |\n   * | Timezone (ISO-8601 w/ Z)        | X       | -08, +0530, Z                     |       |\n   * |                                 | XX      | -0800, +0530, Z                   |       |\n   * |                                 | XXX     | -08:00, +05:30, Z                 |       |\n   * |                                 | XXXX    | -0800, +0530, Z, +123456          | 2     |\n   * |                                 | XXXXX   | -08:00, +05:30, Z, +12:34:56      |       |\n   * | Timezone (ISO-8601 w/o Z)       | x       | -08, +0530, +00                   |       |\n   * |                                 | xx      | -0800, +0530, +0000               |       |\n   * |                                 | xxx     | -08:00, +05:30, +00:00            | 2     |\n   * |                                 | xxxx    | -0800, +0530, +0000, +123456      |       |\n   * |                                 | xxxxx   | -08:00, +05:30, +00:00, +12:34:56 |       |\n   * | Timezone (GMT)                  | O...OOO | GMT-8, GMT+5:30, GMT+0            |       |\n   * |                                 | OOOO    | GMT-08:00, GMT+05:30, GMT+00:00   | 2     |\n   * | Timezone (specific non-locat.)  | z...zzz | GMT-8, GMT+5:30, GMT+0            | 6     |\n   * |                                 | zzzz    | GMT-08:00, GMT+05:30, GMT+00:00   | 2,6   |\n   * | Seconds timestamp               | t       | 512969520                         | 7     |\n   * |                                 | tt      | ...                               | 3,7   |\n   * | Milliseconds timestamp          | T       | 512969520900                      | 7     |\n   * |                                 | TT      | ...                               | 3,7   |\n   * | Long localized date             | P       | 04/29/1453                        | 7     |\n   * |                                 | PP      | Apr 29, 1453                      | 7     |\n   * |                                 | PPP     | April 29th, 1453                  | 7     |\n   * |                                 | PPPP    | Friday, April 29th, 1453          | 2,7   |\n   * | Long localized time             | p       | 12:00 AM                          | 7     |\n   * |                                 | pp      | 12:00:00 AM                       | 7     |\n   * |                                 | ppp     | 12:00:00 AM GMT+2                 | 7     |\n   * |                                 | pppp    | 12:00:00 AM GMT+02:00             | 2,7   |\n   * | Combination of date and time    | Pp      | 04/29/1453, 12:00 AM              | 7     |\n   * |                                 | PPpp    | Apr 29, 1453, 12:00:00 AM         | 7     |\n   * |                                 | PPPppp  | April 29th, 1453 at ...           | 7     |\n   * |                                 | PPPPpppp| Friday, April 29th, 1453 at ...   | 2,7   |\n   * Notes:\n   * 1. \"Formatting\" units (e.g. formatting quarter) in the default en-US locale\n   *    are the same as \"stand-alone\" units, but are different in some languages.\n   *    \"Formatting\" units are declined according to the rules of the language\n   *    in the context of a date. \"Stand-alone\" units are always nominative singular:\n   *\n   *    `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`\n   *\n   *    `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`\n   *\n   * 2. Any sequence of the identical letters is a pattern, unless it is escaped by\n   *    the single quote characters (see below).\n   *    If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)\n   *    the output will be the same as default pattern for this unit, usually\n   *    the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units\n   *    are marked with \"2\" in the last column of the table.\n   *\n   *    `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`\n   *\n   *    `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`\n   *\n   *    `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`\n   *\n   *    `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`\n   *\n   *    `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`\n   *\n   * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).\n   *    The output will be padded with zeros to match the length of the pattern.\n   *\n   *    `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`\n   *\n   * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.\n   *    These tokens represent the shortest form of the quarter.\n   *\n   * 5. The main difference between `y` and `u` patterns are B.C. years:\n   *\n   *    | Year | `y` | `u` |\n   *    |------|-----|-----|\n   *    | AC 1 |   1 |   1 |\n   *    | BC 1 |   1 |   0 |\n   *    | BC 2 |   2 |  -1 |\n   *\n   *    Also `yy` always returns the last two digits of a year,\n   *    while `uu` pads single digit years to 2 characters and returns other years unchanged:\n   *\n   *    | Year | `yy` | `uu` |\n   *    |------|------|------|\n   *    | 1    |   01 |   01 |\n   *    | 14   |   14 |   14 |\n   *    | 376  |   76 |  376 |\n   *    | 1453 |   53 | 1453 |\n   *\n   *    The same difference is true for local and ISO week-numbering years (`Y` and `R`),\n   *    except local week-numbering years are dependent on `options.weekStartsOn`\n   *    and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}\n   *    and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).\n   *\n   * 6. Specific non-location timezones are currently unavailable in `date-fns`,\n   *    so right now these tokens fall back to GMT timezones.\n   *\n   * 7. These patterns are not in the Unicode Technical Standard #35:\n   *    - `i`: ISO day of week\n   *    - `I`: ISO week of year\n   *    - `R`: ISO week-numbering year\n   *    - `t`: seconds timestamp\n   *    - `T`: milliseconds timestamp\n   *    - `o`: ordinal number modifier\n   *    - `P`: long localized date\n   *    - `p`: long localized time\n   *\n   * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.\n   *    You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.\n   *    You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * @param {Date|Number} date - the original date\n   * @param {String} format - the string of tokens\n   * @param {Object} [options] - an object with options.\n   * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n   * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n   * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is\n   * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;\n   *   see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;\n   *   see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @returns {String} the formatted date string\n   * @throws {TypeError} 2 arguments required\n   * @throws {RangeError} `date` must not be Invalid Date\n   * @throws {RangeError} `options.locale` must contain `localize` property\n   * @throws {RangeError} `options.locale` must contain `formatLong` property\n   * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n   * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7\n   * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} format string contains an unescaped latin alphabet character\n   *\n   * @example\n   * // Represent 11 February 2014 in middle-endian format:\n   * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')\n   * //=> '02/11/2014'\n   *\n   * @example\n   * // Represent 2 July 2014 in Esperanto:\n   * import { eoLocale } from 'date-fns/locale/eo'\n   * const result = format(new Date(2014, 6, 2), \"do 'de' MMMM yyyy\", {\n   *   locale: eoLocale\n   * })\n   * //=> '2-a de julio 2014'\n   *\n   * @example\n   * // Escape string by single quote characters:\n   * const result = format(new Date(2014, 6, 2, 15), \"h 'o''clock'\")\n   * //=> \"3 o'clock\"\n   */\n\n  function format(dirtyDate, dirtyFormatStr, options) {\n    var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;\n    requiredArgs(2, arguments);\n    var formatStr = String(dirtyFormatStr);\n    var defaultOptions = getDefaultOptions();\n    var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;\n    var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n\n    if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n      throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n    }\n    var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    if (!locale.localize) {\n      throw new RangeError('locale must contain localize property');\n    }\n    if (!locale.formatLong) {\n      throw new RangeError('locale must contain formatLong property');\n    }\n    var originalDate = toDate(dirtyDate);\n    if (!isValid(originalDate)) {\n      throw new RangeError('Invalid time value');\n    } // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n    // This ensures that when UTC functions will be implemented, locales will be compatible with them.\n    // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376\n\n    var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);\n    var utcDate = subMilliseconds(originalDate, timezoneOffset);\n    var formatterOptions = {\n      firstWeekContainsDate: firstWeekContainsDate,\n      weekStartsOn: weekStartsOn,\n      locale: locale,\n      _originalDate: originalDate\n    };\n    var result = formatStr.match(longFormattingTokensRegExp$1).map(function (substring) {\n      var firstCharacter = substring[0];\n      if (firstCharacter === 'p' || firstCharacter === 'P') {\n        var longFormatter = longFormatters$1[firstCharacter];\n        return longFormatter(substring, locale.formatLong);\n      }\n      return substring;\n    }).join('').match(formattingTokensRegExp$1).map(function (substring) {\n      // Replace two single quote characters with one single quote character\n      if (substring === \"''\") {\n        return \"'\";\n      }\n      var firstCharacter = substring[0];\n      if (firstCharacter === \"'\") {\n        return cleanEscapedString$1(substring);\n      }\n      var formatter = formatters$1[firstCharacter];\n      if (formatter) {\n        if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {\n          throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));\n        }\n        if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {\n          throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));\n        }\n        return formatter(utcDate, substring, locale.localize, formatterOptions);\n      }\n      if (firstCharacter.match(unescapedLatinCharacterRegExp$1)) {\n        throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n      }\n      return substring;\n    }).join('');\n    return result;\n  }\n  function cleanEscapedString$1(input) {\n    var matched = input.match(escapedStringRegExp$1);\n    if (!matched) {\n      return input;\n    }\n    return matched[1].replace(doubleQuoteRegExp$1, \"'\");\n  }\n\n  function assign(target, object) {\n    if (target == null) {\n      throw new TypeError('assign requires that input parameter not be null or undefined');\n    }\n    for (var property in object) {\n      if (Object.prototype.hasOwnProperty.call(object, property)) {\n        target[property] = object[property];\n      }\n    }\n    return target;\n  }\n\n  function _typeof$w(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$w = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$w = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$w(obj);\n  }\n  function _inherits$v(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$v(subClass, superClass);\n  }\n  function _setPrototypeOf$v(o, p) {\n    _setPrototypeOf$v = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$v(o, p);\n  }\n  function _createSuper$v(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$v();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$v(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$v(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$v(this, result);\n    };\n  }\n  function _possibleConstructorReturn$v(self, call) {\n    if (call && (_typeof$w(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$v(self);\n  }\n  function _assertThisInitialized$v(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$v() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$v(o) {\n    _getPrototypeOf$v = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$v(o);\n  }\n  function _classCallCheck$w(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$w(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$w(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$w(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$w(Constructor, staticProps);\n    return Constructor;\n  }\n  function _defineProperty$v(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var TIMEZONE_UNIT_PRIORITY = 10;\n  var Setter = /*#__PURE__*/function () {\n    function Setter() {\n      _classCallCheck$w(this, Setter);\n      _defineProperty$v(this, \"subPriority\", 0);\n    }\n    _createClass$w(Setter, [{\n      key: \"validate\",\n      value: function validate(_utcDate, _options) {\n        return true;\n      }\n    }]);\n    return Setter;\n  }();\n  var ValueSetter = /*#__PURE__*/function (_Setter) {\n    _inherits$v(ValueSetter, _Setter);\n    var _super = _createSuper$v(ValueSetter);\n    function ValueSetter(value, validateValue, setValue, priority, subPriority) {\n      var _this;\n      _classCallCheck$w(this, ValueSetter);\n      _this = _super.call(this);\n      _this.value = value;\n      _this.validateValue = validateValue;\n      _this.setValue = setValue;\n      _this.priority = priority;\n      if (subPriority) {\n        _this.subPriority = subPriority;\n      }\n      return _this;\n    }\n    _createClass$w(ValueSetter, [{\n      key: \"validate\",\n      value: function validate(utcDate, options) {\n        return this.validateValue(utcDate, this.value, options);\n      }\n    }, {\n      key: \"set\",\n      value: function set(utcDate, flags, options) {\n        return this.setValue(utcDate, flags, this.value, options);\n      }\n    }]);\n    return ValueSetter;\n  }(Setter);\n  var DateToSystemTimezoneSetter = /*#__PURE__*/function (_Setter2) {\n    _inherits$v(DateToSystemTimezoneSetter, _Setter2);\n    var _super2 = _createSuper$v(DateToSystemTimezoneSetter);\n    function DateToSystemTimezoneSetter() {\n      var _this2;\n      _classCallCheck$w(this, DateToSystemTimezoneSetter);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this2 = _super2.call.apply(_super2, [this].concat(args));\n      _defineProperty$v(_assertThisInitialized$v(_this2), \"priority\", TIMEZONE_UNIT_PRIORITY);\n      _defineProperty$v(_assertThisInitialized$v(_this2), \"subPriority\", -1);\n      return _this2;\n    }\n    _createClass$w(DateToSystemTimezoneSetter, [{\n      key: \"set\",\n      value: function set(date, flags) {\n        if (flags.timestampIsSet) {\n          return date;\n        }\n        var convertedDate = new Date(0);\n        convertedDate.setFullYear(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());\n        convertedDate.setHours(date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());\n        return convertedDate;\n      }\n    }]);\n    return DateToSystemTimezoneSetter;\n  }(Setter);\n\n  function _classCallCheck$v(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$v(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$v(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$v(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$v(Constructor, staticProps);\n    return Constructor;\n  }\n  var Parser = /*#__PURE__*/function () {\n    function Parser() {\n      _classCallCheck$v(this, Parser);\n    }\n    _createClass$v(Parser, [{\n      key: \"run\",\n      value: function run(dateString, token, match, options) {\n        var result = this.parse(dateString, token, match, options);\n        if (!result) {\n          return null;\n        }\n        return {\n          setter: new ValueSetter(result.value, this.validate, this.set, this.priority, this.subPriority),\n          rest: result.rest\n        };\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_utcDate, _value, _options) {\n        return true;\n      }\n    }]);\n    return Parser;\n  }();\n\n  function _typeof$v(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$v = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$v = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$v(obj);\n  }\n  function _classCallCheck$u(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$u(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$u(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$u(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$u(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$u(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$u(subClass, superClass);\n  }\n  function _setPrototypeOf$u(o, p) {\n    _setPrototypeOf$u = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$u(o, p);\n  }\n  function _createSuper$u(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$u();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$u(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$u(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$u(this, result);\n    };\n  }\n  function _possibleConstructorReturn$u(self, call) {\n    if (call && (_typeof$v(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$u(self);\n  }\n  function _assertThisInitialized$u(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$u() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$u(o) {\n    _getPrototypeOf$u = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$u(o);\n  }\n  function _defineProperty$u(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var EraParser = /*#__PURE__*/function (_Parser) {\n    _inherits$u(EraParser, _Parser);\n    var _super = _createSuper$u(EraParser);\n    function EraParser() {\n      var _this;\n      _classCallCheck$u(this, EraParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$u(_assertThisInitialized$u(_this), \"priority\", 140);\n      _defineProperty$u(_assertThisInitialized$u(_this), \"incompatibleTokens\", ['R', 'u', 't', 'T']);\n      return _this;\n    }\n    _createClass$u(EraParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          // AD, BC\n          case 'G':\n          case 'GG':\n          case 'GGG':\n            return match.era(dateString, {\n              width: 'abbreviated'\n            }) || match.era(dateString, {\n              width: 'narrow'\n            });\n          // A, B\n\n          case 'GGGGG':\n            return match.era(dateString, {\n              width: 'narrow'\n            });\n          // Anno Domini, Before Christ\n\n          case 'GGGG':\n          default:\n            return match.era(dateString, {\n              width: 'wide'\n            }) || match.era(dateString, {\n              width: 'abbreviated'\n            }) || match.era(dateString, {\n              width: 'narrow'\n            });\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, flags, value) {\n        flags.era = value;\n        date.setUTCFullYear(value, 0, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return EraParser;\n  }(Parser);\n\n  var numericPatterns = {\n    month: /^(1[0-2]|0?\\d)/,\n    // 0 to 12\n    date: /^(3[0-1]|[0-2]?\\d)/,\n    // 0 to 31\n    dayOfYear: /^(36[0-6]|3[0-5]\\d|[0-2]?\\d?\\d)/,\n    // 0 to 366\n    week: /^(5[0-3]|[0-4]?\\d)/,\n    // 0 to 53\n    hour23h: /^(2[0-3]|[0-1]?\\d)/,\n    // 0 to 23\n    hour24h: /^(2[0-4]|[0-1]?\\d)/,\n    // 0 to 24\n    hour11h: /^(1[0-1]|0?\\d)/,\n    // 0 to 11\n    hour12h: /^(1[0-2]|0?\\d)/,\n    // 0 to 12\n    minute: /^[0-5]?\\d/,\n    // 0 to 59\n    second: /^[0-5]?\\d/,\n    // 0 to 59\n    singleDigit: /^\\d/,\n    // 0 to 9\n    twoDigits: /^\\d{1,2}/,\n    // 0 to 99\n    threeDigits: /^\\d{1,3}/,\n    // 0 to 999\n    fourDigits: /^\\d{1,4}/,\n    // 0 to 9999\n    anyDigitsSigned: /^-?\\d+/,\n    singleDigitSigned: /^-?\\d/,\n    // 0 to 9, -0 to -9\n    twoDigitsSigned: /^-?\\d{1,2}/,\n    // 0 to 99, -0 to -99\n    threeDigitsSigned: /^-?\\d{1,3}/,\n    // 0 to 999, -0 to -999\n    fourDigitsSigned: /^-?\\d{1,4}/ // 0 to 9999, -0 to -9999\n  };\n\n  var timezonePatterns = {\n    basicOptionalMinutes: /^([+-])(\\d{2})(\\d{2})?|Z/,\n    basic: /^([+-])(\\d{2})(\\d{2})|Z/,\n    basicOptionalSeconds: /^([+-])(\\d{2})(\\d{2})((\\d{2}))?|Z/,\n    extended: /^([+-])(\\d{2}):(\\d{2})|Z/,\n    extendedOptionalSeconds: /^([+-])(\\d{2}):(\\d{2})(:(\\d{2}))?|Z/\n  };\n\n  function mapValue(parseFnResult, mapFn) {\n    if (!parseFnResult) {\n      return parseFnResult;\n    }\n    return {\n      value: mapFn(parseFnResult.value),\n      rest: parseFnResult.rest\n    };\n  }\n  function parseNumericPattern(pattern, dateString) {\n    var matchResult = dateString.match(pattern);\n    if (!matchResult) {\n      return null;\n    }\n    return {\n      value: parseInt(matchResult[0], 10),\n      rest: dateString.slice(matchResult[0].length)\n    };\n  }\n  function parseTimezonePattern(pattern, dateString) {\n    var matchResult = dateString.match(pattern);\n    if (!matchResult) {\n      return null;\n    } // Input is 'Z'\n\n    if (matchResult[0] === 'Z') {\n      return {\n        value: 0,\n        rest: dateString.slice(1)\n      };\n    }\n    var sign = matchResult[1] === '+' ? 1 : -1;\n    var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;\n    var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;\n    var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;\n    return {\n      value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond),\n      rest: dateString.slice(matchResult[0].length)\n    };\n  }\n  function parseAnyDigitsSigned(dateString) {\n    return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString);\n  }\n  function parseNDigits(n, dateString) {\n    switch (n) {\n      case 1:\n        return parseNumericPattern(numericPatterns.singleDigit, dateString);\n      case 2:\n        return parseNumericPattern(numericPatterns.twoDigits, dateString);\n      case 3:\n        return parseNumericPattern(numericPatterns.threeDigits, dateString);\n      case 4:\n        return parseNumericPattern(numericPatterns.fourDigits, dateString);\n      default:\n        return parseNumericPattern(new RegExp('^\\\\d{1,' + n + '}'), dateString);\n    }\n  }\n  function parseNDigitsSigned(n, dateString) {\n    switch (n) {\n      case 1:\n        return parseNumericPattern(numericPatterns.singleDigitSigned, dateString);\n      case 2:\n        return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString);\n      case 3:\n        return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString);\n      case 4:\n        return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString);\n      default:\n        return parseNumericPattern(new RegExp('^-?\\\\d{1,' + n + '}'), dateString);\n    }\n  }\n  function dayPeriodEnumToHours(dayPeriod) {\n    switch (dayPeriod) {\n      case 'morning':\n        return 4;\n      case 'evening':\n        return 17;\n      case 'pm':\n      case 'noon':\n      case 'afternoon':\n        return 12;\n      case 'am':\n      case 'midnight':\n      case 'night':\n      default:\n        return 0;\n    }\n  }\n  function normalizeTwoDigitYear(twoDigitYear, currentYear) {\n    var isCommonEra = currentYear > 0; // Absolute number of the current year:\n    // 1 -> 1 AC\n    // 0 -> 1 BC\n    // -1 -> 2 BC\n\n    var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;\n    var result;\n    if (absCurrentYear <= 50) {\n      result = twoDigitYear || 100;\n    } else {\n      var rangeEnd = absCurrentYear + 50;\n      var rangeEndCentury = Math.floor(rangeEnd / 100) * 100;\n      var isPreviousCentury = twoDigitYear >= rangeEnd % 100;\n      result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);\n    }\n    return isCommonEra ? result : 1 - result;\n  }\n  function isLeapYearIndex$1(year) {\n    return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;\n  }\n\n  function _typeof$u(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$u = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$u = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$u(obj);\n  }\n  function _classCallCheck$t(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$t(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$t(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$t(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$t(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$t(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$t(subClass, superClass);\n  }\n  function _setPrototypeOf$t(o, p) {\n    _setPrototypeOf$t = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$t(o, p);\n  }\n  function _createSuper$t(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$t();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$t(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$t(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$t(this, result);\n    };\n  }\n  function _possibleConstructorReturn$t(self, call) {\n    if (call && (_typeof$u(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$t(self);\n  }\n  function _assertThisInitialized$t(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$t() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$t(o) {\n    _getPrototypeOf$t = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$t(o);\n  }\n  function _defineProperty$t(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns\n  // | Year     |     y | yy |   yyy |  yyyy | yyyyy |\n  // |----------|-------|----|-------|-------|-------|\n  // | AD 1     |     1 | 01 |   001 |  0001 | 00001 |\n  // | AD 12    |    12 | 12 |   012 |  0012 | 00012 |\n  // | AD 123   |   123 | 23 |   123 |  0123 | 00123 |\n  // | AD 1234  |  1234 | 34 |  1234 |  1234 | 01234 |\n  // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n  var YearParser = /*#__PURE__*/function (_Parser) {\n    _inherits$t(YearParser, _Parser);\n    var _super = _createSuper$t(YearParser);\n    function YearParser() {\n      var _this;\n      _classCallCheck$t(this, YearParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$t(_assertThisInitialized$t(_this), \"priority\", 130);\n      _defineProperty$t(_assertThisInitialized$t(_this), \"incompatibleTokens\", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$t(YearParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        var valueCallback = function valueCallback(year) {\n          return {\n            year: year,\n            isTwoDigitYear: token === 'yy'\n          };\n        };\n        switch (token) {\n          case 'y':\n            return mapValue(parseNDigits(4, dateString), valueCallback);\n          case 'yo':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'year'\n            }), valueCallback);\n          default:\n            return mapValue(parseNDigits(token.length, dateString), valueCallback);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value.isTwoDigitYear || value.year > 0;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, flags, value) {\n        var currentYear = date.getUTCFullYear();\n        if (value.isTwoDigitYear) {\n          var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);\n          date.setUTCFullYear(normalizedTwoDigitYear, 0, 1);\n          date.setUTCHours(0, 0, 0, 0);\n          return date;\n        }\n        var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;\n        date.setUTCFullYear(year, 0, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return YearParser;\n  }(Parser);\n\n  function _typeof$t(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$t = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$t = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$t(obj);\n  }\n  function _classCallCheck$s(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$s(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$s(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$s(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$s(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$s(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$s(subClass, superClass);\n  }\n  function _setPrototypeOf$s(o, p) {\n    _setPrototypeOf$s = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$s(o, p);\n  }\n  function _createSuper$s(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$s();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$s(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$s(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$s(this, result);\n    };\n  }\n  function _possibleConstructorReturn$s(self, call) {\n    if (call && (_typeof$t(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$s(self);\n  }\n  function _assertThisInitialized$s(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$s() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$s(o) {\n    _getPrototypeOf$s = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$s(o);\n  }\n  function _defineProperty$s(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  // Local week-numbering year\n  var LocalWeekYearParser = /*#__PURE__*/function (_Parser) {\n    _inherits$s(LocalWeekYearParser, _Parser);\n    var _super = _createSuper$s(LocalWeekYearParser);\n    function LocalWeekYearParser() {\n      var _this;\n      _classCallCheck$s(this, LocalWeekYearParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$s(_assertThisInitialized$s(_this), \"priority\", 130);\n      _defineProperty$s(_assertThisInitialized$s(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'Q', 'q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);\n      return _this;\n    }\n    _createClass$s(LocalWeekYearParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        var valueCallback = function valueCallback(year) {\n          return {\n            year: year,\n            isTwoDigitYear: token === 'YY'\n          };\n        };\n        switch (token) {\n          case 'Y':\n            return mapValue(parseNDigits(4, dateString), valueCallback);\n          case 'Yo':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'year'\n            }), valueCallback);\n          default:\n            return mapValue(parseNDigits(token.length, dateString), valueCallback);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value.isTwoDigitYear || value.year > 0;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, flags, value, options) {\n        var currentYear = getUTCWeekYear(date, options);\n        if (value.isTwoDigitYear) {\n          var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);\n          date.setUTCFullYear(normalizedTwoDigitYear, 0, options.firstWeekContainsDate);\n          date.setUTCHours(0, 0, 0, 0);\n          return startOfUTCWeek(date, options);\n        }\n        var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;\n        date.setUTCFullYear(year, 0, options.firstWeekContainsDate);\n        date.setUTCHours(0, 0, 0, 0);\n        return startOfUTCWeek(date, options);\n      }\n    }]);\n    return LocalWeekYearParser;\n  }(Parser);\n\n  function _typeof$s(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$s = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$s = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$s(obj);\n  }\n  function _classCallCheck$r(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$r(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$r(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$r(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$r(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$r(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$r(subClass, superClass);\n  }\n  function _setPrototypeOf$r(o, p) {\n    _setPrototypeOf$r = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$r(o, p);\n  }\n  function _createSuper$r(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$r();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$r(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$r(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$r(this, result);\n    };\n  }\n  function _possibleConstructorReturn$r(self, call) {\n    if (call && (_typeof$s(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$r(self);\n  }\n  function _assertThisInitialized$r(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$r() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$r(o) {\n    _getPrototypeOf$r = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$r(o);\n  }\n  function _defineProperty$r(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var ISOWeekYearParser = /*#__PURE__*/function (_Parser) {\n    _inherits$r(ISOWeekYearParser, _Parser);\n    var _super = _createSuper$r(ISOWeekYearParser);\n    function ISOWeekYearParser() {\n      var _this;\n      _classCallCheck$r(this, ISOWeekYearParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$r(_assertThisInitialized$r(_this), \"priority\", 130);\n      _defineProperty$r(_assertThisInitialized$r(_this), \"incompatibleTokens\", ['G', 'y', 'Y', 'u', 'Q', 'q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$r(ISOWeekYearParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token) {\n        if (token === 'R') {\n          return parseNDigitsSigned(4, dateString);\n        }\n        return parseNDigitsSigned(token.length, dateString);\n      }\n    }, {\n      key: \"set\",\n      value: function set(_date, _flags, value) {\n        var firstWeekOfYear = new Date(0);\n        firstWeekOfYear.setUTCFullYear(value, 0, 4);\n        firstWeekOfYear.setUTCHours(0, 0, 0, 0);\n        return startOfUTCISOWeek(firstWeekOfYear);\n      }\n    }]);\n    return ISOWeekYearParser;\n  }(Parser);\n\n  function _typeof$r(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$r = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$r = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$r(obj);\n  }\n  function _classCallCheck$q(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$q(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$q(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$q(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$q(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$q(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$q(subClass, superClass);\n  }\n  function _setPrototypeOf$q(o, p) {\n    _setPrototypeOf$q = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$q(o, p);\n  }\n  function _createSuper$q(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$q();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$q(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$q(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$q(this, result);\n    };\n  }\n  function _possibleConstructorReturn$q(self, call) {\n    if (call && (_typeof$r(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$q(self);\n  }\n  function _assertThisInitialized$q(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$q() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$q(o) {\n    _getPrototypeOf$q = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$q(o);\n  }\n  function _defineProperty$q(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var ExtendedYearParser = /*#__PURE__*/function (_Parser) {\n    _inherits$q(ExtendedYearParser, _Parser);\n    var _super = _createSuper$q(ExtendedYearParser);\n    function ExtendedYearParser() {\n      var _this;\n      _classCallCheck$q(this, ExtendedYearParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$q(_assertThisInitialized$q(_this), \"priority\", 130);\n      _defineProperty$q(_assertThisInitialized$q(_this), \"incompatibleTokens\", ['G', 'y', 'Y', 'R', 'w', 'I', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$q(ExtendedYearParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token) {\n        if (token === 'u') {\n          return parseNDigitsSigned(4, dateString);\n        }\n        return parseNDigitsSigned(token.length, dateString);\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCFullYear(value, 0, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return ExtendedYearParser;\n  }(Parser);\n\n  function _typeof$q(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$q = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$q = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$q(obj);\n  }\n  function _classCallCheck$p(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$p(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$p(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$p(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$p(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$p(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$p(subClass, superClass);\n  }\n  function _setPrototypeOf$p(o, p) {\n    _setPrototypeOf$p = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$p(o, p);\n  }\n  function _createSuper$p(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$p();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$p(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$p(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$p(this, result);\n    };\n  }\n  function _possibleConstructorReturn$p(self, call) {\n    if (call && (_typeof$q(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$p(self);\n  }\n  function _assertThisInitialized$p(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$p() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$p(o) {\n    _getPrototypeOf$p = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$p(o);\n  }\n  function _defineProperty$p(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var QuarterParser = /*#__PURE__*/function (_Parser) {\n    _inherits$p(QuarterParser, _Parser);\n    var _super = _createSuper$p(QuarterParser);\n    function QuarterParser() {\n      var _this;\n      _classCallCheck$p(this, QuarterParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$p(_assertThisInitialized$p(_this), \"priority\", 120);\n      _defineProperty$p(_assertThisInitialized$p(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$p(QuarterParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          // 1, 2, 3, 4\n          case 'Q':\n          case 'QQ':\n            // 01, 02, 03, 04\n            return parseNDigits(token.length, dateString);\n          // 1st, 2nd, 3rd, 4th\n\n          case 'Qo':\n            return match.ordinalNumber(dateString, {\n              unit: 'quarter'\n            });\n          // Q1, Q2, Q3, Q4\n\n          case 'QQQ':\n            return match.quarter(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.quarter(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n\n          case 'QQQQQ':\n            return match.quarter(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // 1st quarter, 2nd quarter, ...\n\n          case 'QQQQ':\n          default:\n            return match.quarter(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.quarter(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.quarter(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 4;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMonth((value - 1) * 3, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return QuarterParser;\n  }(Parser);\n\n  function _typeof$p(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$p = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$p = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$p(obj);\n  }\n  function _classCallCheck$o(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$o(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$o(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$o(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$o(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$o(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$o(subClass, superClass);\n  }\n  function _setPrototypeOf$o(o, p) {\n    _setPrototypeOf$o = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$o(o, p);\n  }\n  function _createSuper$o(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$o();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$o(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$o(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$o(this, result);\n    };\n  }\n  function _possibleConstructorReturn$o(self, call) {\n    if (call && (_typeof$p(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$o(self);\n  }\n  function _assertThisInitialized$o(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$o() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$o(o) {\n    _getPrototypeOf$o = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$o(o);\n  }\n  function _defineProperty$o(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var StandAloneQuarterParser = /*#__PURE__*/function (_Parser) {\n    _inherits$o(StandAloneQuarterParser, _Parser);\n    var _super = _createSuper$o(StandAloneQuarterParser);\n    function StandAloneQuarterParser() {\n      var _this;\n      _classCallCheck$o(this, StandAloneQuarterParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$o(_assertThisInitialized$o(_this), \"priority\", 120);\n      _defineProperty$o(_assertThisInitialized$o(_this), \"incompatibleTokens\", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$o(StandAloneQuarterParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          // 1, 2, 3, 4\n          case 'q':\n          case 'qq':\n            // 01, 02, 03, 04\n            return parseNDigits(token.length, dateString);\n          // 1st, 2nd, 3rd, 4th\n\n          case 'qo':\n            return match.ordinalNumber(dateString, {\n              unit: 'quarter'\n            });\n          // Q1, Q2, Q3, Q4\n\n          case 'qqq':\n            return match.quarter(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.quarter(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n\n          case 'qqqqq':\n            return match.quarter(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // 1st quarter, 2nd quarter, ...\n\n          case 'qqqq':\n          default:\n            return match.quarter(dateString, {\n              width: 'wide',\n              context: 'standalone'\n            }) || match.quarter(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.quarter(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 4;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMonth((value - 1) * 3, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return StandAloneQuarterParser;\n  }(Parser);\n\n  function _typeof$o(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$o = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$o = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$o(obj);\n  }\n  function _classCallCheck$n(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$n(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$n(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$n(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$n(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$n(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$n(subClass, superClass);\n  }\n  function _setPrototypeOf$n(o, p) {\n    _setPrototypeOf$n = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$n(o, p);\n  }\n  function _createSuper$n(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$n();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$n(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$n(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$n(this, result);\n    };\n  }\n  function _possibleConstructorReturn$n(self, call) {\n    if (call && (_typeof$o(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$n(self);\n  }\n  function _assertThisInitialized$n(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$n() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$n(o) {\n    _getPrototypeOf$n = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$n(o);\n  }\n  function _defineProperty$n(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var MonthParser = /*#__PURE__*/function (_Parser) {\n    _inherits$n(MonthParser, _Parser);\n    var _super = _createSuper$n(MonthParser);\n    function MonthParser() {\n      var _this;\n      _classCallCheck$n(this, MonthParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$n(_assertThisInitialized$n(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'L', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n      _defineProperty$n(_assertThisInitialized$n(_this), \"priority\", 110);\n      return _this;\n    }\n    _createClass$n(MonthParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        var valueCallback = function valueCallback(value) {\n          return value - 1;\n        };\n        switch (token) {\n          // 1, 2, ..., 12\n          case 'M':\n            return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);\n          // 01, 02, ..., 12\n\n          case 'MM':\n            return mapValue(parseNDigits(2, dateString), valueCallback);\n          // 1st, 2nd, ..., 12th\n\n          case 'Mo':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'month'\n            }), valueCallback);\n          // Jan, Feb, ..., Dec\n\n          case 'MMM':\n            return match.month(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.month(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // J, F, ..., D\n\n          case 'MMMMM':\n            return match.month(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // January, February, ..., December\n\n          case 'MMMM':\n          default:\n            return match.month(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.month(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.month(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 11;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMonth(value, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return MonthParser;\n  }(Parser);\n\n  function _typeof$n(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$n = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$n = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$n(obj);\n  }\n  function _classCallCheck$m(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$m(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$m(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$m(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$m(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$m(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$m(subClass, superClass);\n  }\n  function _setPrototypeOf$m(o, p) {\n    _setPrototypeOf$m = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$m(o, p);\n  }\n  function _createSuper$m(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$m();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$m(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$m(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$m(this, result);\n    };\n  }\n  function _possibleConstructorReturn$m(self, call) {\n    if (call && (_typeof$n(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$m(self);\n  }\n  function _assertThisInitialized$m(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$m() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$m(o) {\n    _getPrototypeOf$m = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$m(o);\n  }\n  function _defineProperty$m(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var StandAloneMonthParser = /*#__PURE__*/function (_Parser) {\n    _inherits$m(StandAloneMonthParser, _Parser);\n    var _super = _createSuper$m(StandAloneMonthParser);\n    function StandAloneMonthParser() {\n      var _this;\n      _classCallCheck$m(this, StandAloneMonthParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$m(_assertThisInitialized$m(_this), \"priority\", 110);\n      _defineProperty$m(_assertThisInitialized$m(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$m(StandAloneMonthParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        var valueCallback = function valueCallback(value) {\n          return value - 1;\n        };\n        switch (token) {\n          // 1, 2, ..., 12\n          case 'L':\n            return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);\n          // 01, 02, ..., 12\n\n          case 'LL':\n            return mapValue(parseNDigits(2, dateString), valueCallback);\n          // 1st, 2nd, ..., 12th\n\n          case 'Lo':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'month'\n            }), valueCallback);\n          // Jan, Feb, ..., Dec\n\n          case 'LLL':\n            return match.month(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.month(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // J, F, ..., D\n\n          case 'LLLLL':\n            return match.month(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // January, February, ..., December\n\n          case 'LLLL':\n          default:\n            return match.month(dateString, {\n              width: 'wide',\n              context: 'standalone'\n            }) || match.month(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.month(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 11;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMonth(value, 1);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return StandAloneMonthParser;\n  }(Parser);\n\n  function setUTCWeek(dirtyDate, dirtyWeek, options) {\n    requiredArgs(2, arguments);\n    var date = toDate(dirtyDate);\n    var week = toInteger(dirtyWeek);\n    var diff = getUTCWeek(date, options) - week;\n    date.setUTCDate(date.getUTCDate() - diff * 7);\n    return date;\n  }\n\n  function _typeof$m(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$m = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$m = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$m(obj);\n  }\n  function _classCallCheck$l(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$l(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$l(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$l(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$l(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$l(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$l(subClass, superClass);\n  }\n  function _setPrototypeOf$l(o, p) {\n    _setPrototypeOf$l = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$l(o, p);\n  }\n  function _createSuper$l(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$l();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$l(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$l(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$l(this, result);\n    };\n  }\n  function _possibleConstructorReturn$l(self, call) {\n    if (call && (_typeof$m(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$l(self);\n  }\n  function _assertThisInitialized$l(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$l() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$l(o) {\n    _getPrototypeOf$l = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$l(o);\n  }\n  function _defineProperty$l(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var LocalWeekParser = /*#__PURE__*/function (_Parser) {\n    _inherits$l(LocalWeekParser, _Parser);\n    var _super = _createSuper$l(LocalWeekParser);\n    function LocalWeekParser() {\n      var _this;\n      _classCallCheck$l(this, LocalWeekParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$l(_assertThisInitialized$l(_this), \"priority\", 100);\n      _defineProperty$l(_assertThisInitialized$l(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);\n      return _this;\n    }\n    _createClass$l(LocalWeekParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'w':\n            return parseNumericPattern(numericPatterns.week, dateString);\n          case 'wo':\n            return match.ordinalNumber(dateString, {\n              unit: 'week'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 53;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value, options) {\n        return startOfUTCWeek(setUTCWeek(date, value, options), options);\n      }\n    }]);\n    return LocalWeekParser;\n  }(Parser);\n\n  function setUTCISOWeek(dirtyDate, dirtyISOWeek) {\n    requiredArgs(2, arguments);\n    var date = toDate(dirtyDate);\n    var isoWeek = toInteger(dirtyISOWeek);\n    var diff = getUTCISOWeek(date) - isoWeek;\n    date.setUTCDate(date.getUTCDate() - diff * 7);\n    return date;\n  }\n\n  function _typeof$l(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$l = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$l = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$l(obj);\n  }\n  function _classCallCheck$k(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$k(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$k(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$k(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$k(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$k(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$k(subClass, superClass);\n  }\n  function _setPrototypeOf$k(o, p) {\n    _setPrototypeOf$k = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$k(o, p);\n  }\n  function _createSuper$k(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$k();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$k(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$k(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$k(this, result);\n    };\n  }\n  function _possibleConstructorReturn$k(self, call) {\n    if (call && (_typeof$l(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$k(self);\n  }\n  function _assertThisInitialized$k(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$k() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$k(o) {\n    _getPrototypeOf$k = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$k(o);\n  }\n  function _defineProperty$k(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var ISOWeekParser = /*#__PURE__*/function (_Parser) {\n    _inherits$k(ISOWeekParser, _Parser);\n    var _super = _createSuper$k(ISOWeekParser);\n    function ISOWeekParser() {\n      var _this;\n      _classCallCheck$k(this, ISOWeekParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$k(_assertThisInitialized$k(_this), \"priority\", 100);\n      _defineProperty$k(_assertThisInitialized$k(_this), \"incompatibleTokens\", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$k(ISOWeekParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'I':\n            return parseNumericPattern(numericPatterns.week, dateString);\n          case 'Io':\n            return match.ordinalNumber(dateString, {\n              unit: 'week'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 53;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        return startOfUTCISOWeek(setUTCISOWeek(date, value));\n      }\n    }]);\n    return ISOWeekParser;\n  }(Parser);\n\n  function _typeof$k(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$k = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$k = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$k(obj);\n  }\n  function _classCallCheck$j(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$j(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$j(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$j(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$j(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$j(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$j(subClass, superClass);\n  }\n  function _setPrototypeOf$j(o, p) {\n    _setPrototypeOf$j = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$j(o, p);\n  }\n  function _createSuper$j(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$j();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$j(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$j(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$j(this, result);\n    };\n  }\n  function _possibleConstructorReturn$j(self, call) {\n    if (call && (_typeof$k(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$j(self);\n  }\n  function _assertThisInitialized$j(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$j() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$j(o) {\n    _getPrototypeOf$j = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$j(o);\n  }\n  function _defineProperty$j(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n  var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // Day of the month\n\n  var DateParser = /*#__PURE__*/function (_Parser) {\n    _inherits$j(DateParser, _Parser);\n    var _super = _createSuper$j(DateParser);\n    function DateParser() {\n      var _this;\n      _classCallCheck$j(this, DateParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$j(_assertThisInitialized$j(_this), \"priority\", 90);\n      _defineProperty$j(_assertThisInitialized$j(_this), \"subPriority\", 1);\n      _defineProperty$j(_assertThisInitialized$j(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$j(DateParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'd':\n            return parseNumericPattern(numericPatterns.date, dateString);\n          case 'do':\n            return match.ordinalNumber(dateString, {\n              unit: 'date'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(date, value) {\n        var year = date.getUTCFullYear();\n        var isLeapYear = isLeapYearIndex$1(year);\n        var month = date.getUTCMonth();\n        if (isLeapYear) {\n          return value >= 1 && value <= DAYS_IN_MONTH_LEAP_YEAR[month];\n        } else {\n          return value >= 1 && value <= DAYS_IN_MONTH[month];\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCDate(value);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return DateParser;\n  }(Parser);\n\n  function _typeof$j(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$j = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$j = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$j(obj);\n  }\n  function _classCallCheck$i(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$i(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$i(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$i(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$i(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$i(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$i(subClass, superClass);\n  }\n  function _setPrototypeOf$i(o, p) {\n    _setPrototypeOf$i = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$i(o, p);\n  }\n  function _createSuper$i(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$i();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$i(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$i(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$i(this, result);\n    };\n  }\n  function _possibleConstructorReturn$i(self, call) {\n    if (call && (_typeof$j(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$i(self);\n  }\n  function _assertThisInitialized$i(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$i() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$i(o) {\n    _getPrototypeOf$i = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$i(o);\n  }\n  function _defineProperty$i(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var DayOfYearParser = /*#__PURE__*/function (_Parser) {\n    _inherits$i(DayOfYearParser, _Parser);\n    var _super = _createSuper$i(DayOfYearParser);\n    function DayOfYearParser() {\n      var _this;\n      _classCallCheck$i(this, DayOfYearParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$i(_assertThisInitialized$i(_this), \"priority\", 90);\n      _defineProperty$i(_assertThisInitialized$i(_this), \"subpriority\", 1);\n      _defineProperty$i(_assertThisInitialized$i(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'M', 'L', 'w', 'I', 'd', 'E', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$i(DayOfYearParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'D':\n          case 'DD':\n            return parseNumericPattern(numericPatterns.dayOfYear, dateString);\n          case 'Do':\n            return match.ordinalNumber(dateString, {\n              unit: 'date'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(date, value) {\n        var year = date.getUTCFullYear();\n        var isLeapYear = isLeapYearIndex$1(year);\n        if (isLeapYear) {\n          return value >= 1 && value <= 366;\n        } else {\n          return value >= 1 && value <= 365;\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMonth(0, value);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return DayOfYearParser;\n  }(Parser);\n\n  function setUTCDay(dirtyDate, dirtyDay, options) {\n    var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n    requiredArgs(2, arguments);\n    var defaultOptions = getDefaultOptions();\n    var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    var date = toDate(dirtyDate);\n    var day = toInteger(dirtyDay);\n    var currentDay = date.getUTCDay();\n    var remainder = day % 7;\n    var dayIndex = (remainder + 7) % 7;\n    var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;\n    date.setUTCDate(date.getUTCDate() + diff);\n    return date;\n  }\n\n  function _typeof$i(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$i = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$i = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$i(obj);\n  }\n  function _classCallCheck$h(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$h(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$h(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$h(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$h(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$h(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$h(subClass, superClass);\n  }\n  function _setPrototypeOf$h(o, p) {\n    _setPrototypeOf$h = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$h(o, p);\n  }\n  function _createSuper$h(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$h();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$h(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$h(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$h(this, result);\n    };\n  }\n  function _possibleConstructorReturn$h(self, call) {\n    if (call && (_typeof$i(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$h(self);\n  }\n  function _assertThisInitialized$h(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$h() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$h(o) {\n    _getPrototypeOf$h = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$h(o);\n  }\n  function _defineProperty$h(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var DayParser = /*#__PURE__*/function (_Parser) {\n    _inherits$h(DayParser, _Parser);\n    var _super = _createSuper$h(DayParser);\n    function DayParser() {\n      var _this;\n      _classCallCheck$h(this, DayParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$h(_assertThisInitialized$h(_this), \"priority\", 90);\n      _defineProperty$h(_assertThisInitialized$h(_this), \"incompatibleTokens\", ['D', 'i', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$h(DayParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          // Tue\n          case 'E':\n          case 'EE':\n          case 'EEE':\n            return match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // T\n\n          case 'EEEEE':\n            return match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // Tu\n\n          case 'EEEEEE':\n            return match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // Tuesday\n\n          case 'EEEE':\n          default:\n            return match.day(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 6;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value, options) {\n        date = setUTCDay(date, value, options);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return DayParser;\n  }(Parser);\n\n  function _typeof$h(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$h = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$h = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$h(obj);\n  }\n  function _classCallCheck$g(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$g(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$g(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$g(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$g(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$g(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$g(subClass, superClass);\n  }\n  function _setPrototypeOf$g(o, p) {\n    _setPrototypeOf$g = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$g(o, p);\n  }\n  function _createSuper$g(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$g();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$g(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$g(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$g(this, result);\n    };\n  }\n  function _possibleConstructorReturn$g(self, call) {\n    if (call && (_typeof$h(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$g(self);\n  }\n  function _assertThisInitialized$g(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$g() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$g(o) {\n    _getPrototypeOf$g = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$g(o);\n  }\n  function _defineProperty$g(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var LocalDayParser = /*#__PURE__*/function (_Parser) {\n    _inherits$g(LocalDayParser, _Parser);\n    var _super = _createSuper$g(LocalDayParser);\n    function LocalDayParser() {\n      var _this;\n      _classCallCheck$g(this, LocalDayParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$g(_assertThisInitialized$g(_this), \"priority\", 90);\n      _defineProperty$g(_assertThisInitialized$g(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$g(LocalDayParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match, options) {\n        var valueCallback = function valueCallback(value) {\n          var wholeWeekDays = Math.floor((value - 1) / 7) * 7;\n          return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;\n        };\n        switch (token) {\n          // 3\n          case 'e':\n          case 'ee':\n            // 03\n            return mapValue(parseNDigits(token.length, dateString), valueCallback);\n          // 3rd\n\n          case 'eo':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'day'\n            }), valueCallback);\n          // Tue\n\n          case 'eee':\n            return match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // T\n\n          case 'eeeee':\n            return match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // Tu\n\n          case 'eeeeee':\n            return match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          // Tuesday\n\n          case 'eeee':\n          default:\n            return match.day(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 6;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value, options) {\n        date = setUTCDay(date, value, options);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return LocalDayParser;\n  }(Parser);\n\n  function _typeof$g(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$g = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$g = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$g(obj);\n  }\n  function _classCallCheck$f(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$f(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$f(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$f(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$f(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$f(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$f(subClass, superClass);\n  }\n  function _setPrototypeOf$f(o, p) {\n    _setPrototypeOf$f = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$f(o, p);\n  }\n  function _createSuper$f(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$f();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$f(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$f(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$f(this, result);\n    };\n  }\n  function _possibleConstructorReturn$f(self, call) {\n    if (call && (_typeof$g(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$f(self);\n  }\n  function _assertThisInitialized$f(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$f() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$f(o) {\n    _getPrototypeOf$f = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$f(o);\n  }\n  function _defineProperty$f(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var StandAloneLocalDayParser = /*#__PURE__*/function (_Parser) {\n    _inherits$f(StandAloneLocalDayParser, _Parser);\n    var _super = _createSuper$f(StandAloneLocalDayParser);\n    function StandAloneLocalDayParser() {\n      var _this;\n      _classCallCheck$f(this, StandAloneLocalDayParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$f(_assertThisInitialized$f(_this), \"priority\", 90);\n      _defineProperty$f(_assertThisInitialized$f(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']);\n      return _this;\n    }\n    _createClass$f(StandAloneLocalDayParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match, options) {\n        var valueCallback = function valueCallback(value) {\n          var wholeWeekDays = Math.floor((value - 1) / 7) * 7;\n          return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;\n        };\n        switch (token) {\n          // 3\n          case 'c':\n          case 'cc':\n            // 03\n            return mapValue(parseNDigits(token.length, dateString), valueCallback);\n          // 3rd\n\n          case 'co':\n            return mapValue(match.ordinalNumber(dateString, {\n              unit: 'day'\n            }), valueCallback);\n          // Tue\n\n          case 'ccc':\n            return match.day(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // T\n\n          case 'ccccc':\n            return match.day(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // Tu\n\n          case 'cccccc':\n            return match.day(dateString, {\n              width: 'short',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n          // Tuesday\n\n          case 'cccc':\n          default:\n            return match.day(dateString, {\n              width: 'wide',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'abbreviated',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'standalone'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'standalone'\n            });\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 6;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value, options) {\n        date = setUTCDay(date, value, options);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return StandAloneLocalDayParser;\n  }(Parser);\n\n  function setUTCISODay(dirtyDate, dirtyDay) {\n    requiredArgs(2, arguments);\n    var day = toInteger(dirtyDay);\n    if (day % 7 === 0) {\n      day = day - 7;\n    }\n    var weekStartsOn = 1;\n    var date = toDate(dirtyDate);\n    var currentDay = date.getUTCDay();\n    var remainder = day % 7;\n    var dayIndex = (remainder + 7) % 7;\n    var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;\n    date.setUTCDate(date.getUTCDate() + diff);\n    return date;\n  }\n\n  function _typeof$f(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$f = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$f = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$f(obj);\n  }\n  function _classCallCheck$e(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$e(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$e(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$e(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$e(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$e(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$e(subClass, superClass);\n  }\n  function _setPrototypeOf$e(o, p) {\n    _setPrototypeOf$e = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$e(o, p);\n  }\n  function _createSuper$e(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$e();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$e(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$e(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$e(this, result);\n    };\n  }\n  function _possibleConstructorReturn$e(self, call) {\n    if (call && (_typeof$f(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$e(self);\n  }\n  function _assertThisInitialized$e(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$e() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$e(o) {\n    _getPrototypeOf$e = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$e(o);\n  }\n  function _defineProperty$e(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var ISODayParser = /*#__PURE__*/function (_Parser) {\n    _inherits$e(ISODayParser, _Parser);\n    var _super = _createSuper$e(ISODayParser);\n    function ISODayParser() {\n      var _this;\n      _classCallCheck$e(this, ISODayParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$e(_assertThisInitialized$e(_this), \"priority\", 90);\n      _defineProperty$e(_assertThisInitialized$e(_this), \"incompatibleTokens\", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'E', 'e', 'c', 't', 'T']);\n      return _this;\n    }\n    _createClass$e(ISODayParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        var valueCallback = function valueCallback(value) {\n          if (value === 0) {\n            return 7;\n          }\n          return value;\n        };\n        switch (token) {\n          // 2\n          case 'i':\n          case 'ii':\n            // 02\n            return parseNDigits(token.length, dateString);\n          // 2nd\n\n          case 'io':\n            return match.ordinalNumber(dateString, {\n              unit: 'day'\n            });\n          // Tue\n\n          case 'iii':\n            return mapValue(match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            }), valueCallback);\n          // T\n\n          case 'iiiii':\n            return mapValue(match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            }), valueCallback);\n          // Tu\n\n          case 'iiiiii':\n            return mapValue(match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            }), valueCallback);\n          // Tuesday\n\n          case 'iiii':\n          default:\n            return mapValue(match.day(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'short',\n              context: 'formatting'\n            }) || match.day(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            }), valueCallback);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 7;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date = setUTCISODay(date, value);\n        date.setUTCHours(0, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return ISODayParser;\n  }(Parser);\n\n  function _typeof$e(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$e = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$e = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$e(obj);\n  }\n  function _classCallCheck$d(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$d(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$d(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$d(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$d(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$d(subClass, superClass);\n  }\n  function _setPrototypeOf$d(o, p) {\n    _setPrototypeOf$d = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$d(o, p);\n  }\n  function _createSuper$d(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$d();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$d(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$d(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$d(this, result);\n    };\n  }\n  function _possibleConstructorReturn$d(self, call) {\n    if (call && (_typeof$e(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$d(self);\n  }\n  function _assertThisInitialized$d(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$d() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$d(o) {\n    _getPrototypeOf$d = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$d(o);\n  }\n  function _defineProperty$d(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var AMPMParser = /*#__PURE__*/function (_Parser) {\n    _inherits$d(AMPMParser, _Parser);\n    var _super = _createSuper$d(AMPMParser);\n    function AMPMParser() {\n      var _this;\n      _classCallCheck$d(this, AMPMParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$d(_assertThisInitialized$d(_this), \"priority\", 80);\n      _defineProperty$d(_assertThisInitialized$d(_this), \"incompatibleTokens\", ['b', 'B', 'H', 'k', 't', 'T']);\n      return _this;\n    }\n    _createClass$d(AMPMParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'a':\n          case 'aa':\n          case 'aaa':\n            return match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'aaaaa':\n            return match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'aaaa':\n          default:\n            return match.dayPeriod(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n        return date;\n      }\n    }]);\n    return AMPMParser;\n  }(Parser);\n\n  function _typeof$d(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$d = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$d = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$d(obj);\n  }\n  function _classCallCheck$c(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$c(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$c(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$c(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$c(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$c(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$c(subClass, superClass);\n  }\n  function _setPrototypeOf$c(o, p) {\n    _setPrototypeOf$c = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$c(o, p);\n  }\n  function _createSuper$c(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$c();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$c(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$c(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$c(this, result);\n    };\n  }\n  function _possibleConstructorReturn$c(self, call) {\n    if (call && (_typeof$d(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$c(self);\n  }\n  function _assertThisInitialized$c(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$c() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$c(o) {\n    _getPrototypeOf$c = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$c(o);\n  }\n  function _defineProperty$c(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var AMPMMidnightParser = /*#__PURE__*/function (_Parser) {\n    _inherits$c(AMPMMidnightParser, _Parser);\n    var _super = _createSuper$c(AMPMMidnightParser);\n    function AMPMMidnightParser() {\n      var _this;\n      _classCallCheck$c(this, AMPMMidnightParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$c(_assertThisInitialized$c(_this), \"priority\", 80);\n      _defineProperty$c(_assertThisInitialized$c(_this), \"incompatibleTokens\", ['a', 'B', 'H', 'k', 't', 'T']);\n      return _this;\n    }\n    _createClass$c(AMPMMidnightParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'b':\n          case 'bb':\n          case 'bbb':\n            return match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'bbbbb':\n            return match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'bbbb':\n          default:\n            return match.dayPeriod(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n        return date;\n      }\n    }]);\n    return AMPMMidnightParser;\n  }(Parser);\n\n  function _typeof$c(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$c = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$c = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$c(obj);\n  }\n  function _classCallCheck$b(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$b(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$b(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$b(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$b(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$b(subClass, superClass);\n  }\n  function _setPrototypeOf$b(o, p) {\n    _setPrototypeOf$b = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$b(o, p);\n  }\n  function _createSuper$b(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$b();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$b(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$b(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$b(this, result);\n    };\n  }\n  function _possibleConstructorReturn$b(self, call) {\n    if (call && (_typeof$c(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$b(self);\n  }\n  function _assertThisInitialized$b(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$b() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$b(o) {\n    _getPrototypeOf$b = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$b(o);\n  }\n  function _defineProperty$b(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var DayPeriodParser = /*#__PURE__*/function (_Parser) {\n    _inherits$b(DayPeriodParser, _Parser);\n    var _super = _createSuper$b(DayPeriodParser);\n    function DayPeriodParser() {\n      var _this;\n      _classCallCheck$b(this, DayPeriodParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$b(_assertThisInitialized$b(_this), \"priority\", 80);\n      _defineProperty$b(_assertThisInitialized$b(_this), \"incompatibleTokens\", ['a', 'b', 't', 'T']);\n      return _this;\n    }\n    _createClass$b(DayPeriodParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'B':\n          case 'BB':\n          case 'BBB':\n            return match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'BBBBB':\n            return match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n          case 'BBBB':\n          default:\n            return match.dayPeriod(dateString, {\n              width: 'wide',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'abbreviated',\n              context: 'formatting'\n            }) || match.dayPeriod(dateString, {\n              width: 'narrow',\n              context: 'formatting'\n            });\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n        return date;\n      }\n    }]);\n    return DayPeriodParser;\n  }(Parser);\n\n  function _typeof$b(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$b = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$b = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$b(obj);\n  }\n  function _classCallCheck$a(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$a(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$a(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$a(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$a(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$a(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$a(subClass, superClass);\n  }\n  function _setPrototypeOf$a(o, p) {\n    _setPrototypeOf$a = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$a(o, p);\n  }\n  function _createSuper$a(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$a();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$a(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$a(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$a(this, result);\n    };\n  }\n  function _possibleConstructorReturn$a(self, call) {\n    if (call && (_typeof$b(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$a(self);\n  }\n  function _assertThisInitialized$a(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$a() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$a(o) {\n    _getPrototypeOf$a = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$a(o);\n  }\n  function _defineProperty$a(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var Hour1to12Parser = /*#__PURE__*/function (_Parser) {\n    _inherits$a(Hour1to12Parser, _Parser);\n    var _super = _createSuper$a(Hour1to12Parser);\n    function Hour1to12Parser() {\n      var _this;\n      _classCallCheck$a(this, Hour1to12Parser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$a(_assertThisInitialized$a(_this), \"priority\", 70);\n      _defineProperty$a(_assertThisInitialized$a(_this), \"incompatibleTokens\", ['H', 'K', 'k', 't', 'T']);\n      return _this;\n    }\n    _createClass$a(Hour1to12Parser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'h':\n            return parseNumericPattern(numericPatterns.hour12h, dateString);\n          case 'ho':\n            return match.ordinalNumber(dateString, {\n              unit: 'hour'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 12;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        var isPM = date.getUTCHours() >= 12;\n        if (isPM && value < 12) {\n          date.setUTCHours(value + 12, 0, 0, 0);\n        } else if (!isPM && value === 12) {\n          date.setUTCHours(0, 0, 0, 0);\n        } else {\n          date.setUTCHours(value, 0, 0, 0);\n        }\n        return date;\n      }\n    }]);\n    return Hour1to12Parser;\n  }(Parser);\n\n  function _typeof$a(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$a = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$a = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$a(obj);\n  }\n  function _classCallCheck$9(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$9(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$9(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$9(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$9(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$9(subClass, superClass);\n  }\n  function _setPrototypeOf$9(o, p) {\n    _setPrototypeOf$9 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$9(o, p);\n  }\n  function _createSuper$9(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$9();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$9(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$9(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$9(this, result);\n    };\n  }\n  function _possibleConstructorReturn$9(self, call) {\n    if (call && (_typeof$a(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$9(self);\n  }\n  function _assertThisInitialized$9(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$9() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$9(o) {\n    _getPrototypeOf$9 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$9(o);\n  }\n  function _defineProperty$9(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var Hour0to23Parser = /*#__PURE__*/function (_Parser) {\n    _inherits$9(Hour0to23Parser, _Parser);\n    var _super = _createSuper$9(Hour0to23Parser);\n    function Hour0to23Parser() {\n      var _this;\n      _classCallCheck$9(this, Hour0to23Parser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$9(_assertThisInitialized$9(_this), \"priority\", 70);\n      _defineProperty$9(_assertThisInitialized$9(_this), \"incompatibleTokens\", ['a', 'b', 'h', 'K', 'k', 't', 'T']);\n      return _this;\n    }\n    _createClass$9(Hour0to23Parser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'H':\n            return parseNumericPattern(numericPatterns.hour23h, dateString);\n          case 'Ho':\n            return match.ordinalNumber(dateString, {\n              unit: 'hour'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 23;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCHours(value, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return Hour0to23Parser;\n  }(Parser);\n\n  function _typeof$9(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$9 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$9 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$9(obj);\n  }\n  function _classCallCheck$8(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$8(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$8(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$8(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$8(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$8(subClass, superClass);\n  }\n  function _setPrototypeOf$8(o, p) {\n    _setPrototypeOf$8 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$8(o, p);\n  }\n  function _createSuper$8(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$8();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$8(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$8(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$8(this, result);\n    };\n  }\n  function _possibleConstructorReturn$8(self, call) {\n    if (call && (_typeof$9(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$8(self);\n  }\n  function _assertThisInitialized$8(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$8() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$8(o) {\n    _getPrototypeOf$8 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$8(o);\n  }\n  function _defineProperty$8(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var Hour0To11Parser = /*#__PURE__*/function (_Parser) {\n    _inherits$8(Hour0To11Parser, _Parser);\n    var _super = _createSuper$8(Hour0To11Parser);\n    function Hour0To11Parser() {\n      var _this;\n      _classCallCheck$8(this, Hour0To11Parser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$8(_assertThisInitialized$8(_this), \"priority\", 70);\n      _defineProperty$8(_assertThisInitialized$8(_this), \"incompatibleTokens\", ['h', 'H', 'k', 't', 'T']);\n      return _this;\n    }\n    _createClass$8(Hour0To11Parser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'K':\n            return parseNumericPattern(numericPatterns.hour11h, dateString);\n          case 'Ko':\n            return match.ordinalNumber(dateString, {\n              unit: 'hour'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 11;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        var isPM = date.getUTCHours() >= 12;\n        if (isPM && value < 12) {\n          date.setUTCHours(value + 12, 0, 0, 0);\n        } else {\n          date.setUTCHours(value, 0, 0, 0);\n        }\n        return date;\n      }\n    }]);\n    return Hour0To11Parser;\n  }(Parser);\n\n  function _typeof$8(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$8 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$8 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$8(obj);\n  }\n  function _classCallCheck$7(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$7(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$7(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$7(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$7(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$7(subClass, superClass);\n  }\n  function _setPrototypeOf$7(o, p) {\n    _setPrototypeOf$7 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$7(o, p);\n  }\n  function _createSuper$7(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$7();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$7(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$7(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$7(this, result);\n    };\n  }\n  function _possibleConstructorReturn$7(self, call) {\n    if (call && (_typeof$8(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$7(self);\n  }\n  function _assertThisInitialized$7(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$7() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$7(o) {\n    _getPrototypeOf$7 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$7(o);\n  }\n  function _defineProperty$7(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var Hour1To24Parser = /*#__PURE__*/function (_Parser) {\n    _inherits$7(Hour1To24Parser, _Parser);\n    var _super = _createSuper$7(Hour1To24Parser);\n    function Hour1To24Parser() {\n      var _this;\n      _classCallCheck$7(this, Hour1To24Parser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$7(_assertThisInitialized$7(_this), \"priority\", 70);\n      _defineProperty$7(_assertThisInitialized$7(_this), \"incompatibleTokens\", ['a', 'b', 'h', 'H', 'K', 't', 'T']);\n      return _this;\n    }\n    _createClass$7(Hour1To24Parser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'k':\n            return parseNumericPattern(numericPatterns.hour24h, dateString);\n          case 'ko':\n            return match.ordinalNumber(dateString, {\n              unit: 'hour'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 1 && value <= 24;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        var hours = value <= 24 ? value % 24 : value;\n        date.setUTCHours(hours, 0, 0, 0);\n        return date;\n      }\n    }]);\n    return Hour1To24Parser;\n  }(Parser);\n\n  function _typeof$7(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$7 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$7 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$7(obj);\n  }\n  function _classCallCheck$6(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$6(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$6(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$6(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$6(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$6(subClass, superClass);\n  }\n  function _setPrototypeOf$6(o, p) {\n    _setPrototypeOf$6 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$6(o, p);\n  }\n  function _createSuper$6(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$6();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$6(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$6(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$6(this, result);\n    };\n  }\n  function _possibleConstructorReturn$6(self, call) {\n    if (call && (_typeof$7(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$6(self);\n  }\n  function _assertThisInitialized$6(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$6() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$6(o) {\n    _getPrototypeOf$6 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$6(o);\n  }\n  function _defineProperty$6(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var MinuteParser = /*#__PURE__*/function (_Parser) {\n    _inherits$6(MinuteParser, _Parser);\n    var _super = _createSuper$6(MinuteParser);\n    function MinuteParser() {\n      var _this;\n      _classCallCheck$6(this, MinuteParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$6(_assertThisInitialized$6(_this), \"priority\", 60);\n      _defineProperty$6(_assertThisInitialized$6(_this), \"incompatibleTokens\", ['t', 'T']);\n      return _this;\n    }\n    _createClass$6(MinuteParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 'm':\n            return parseNumericPattern(numericPatterns.minute, dateString);\n          case 'mo':\n            return match.ordinalNumber(dateString, {\n              unit: 'minute'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 59;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMinutes(value, 0, 0);\n        return date;\n      }\n    }]);\n    return MinuteParser;\n  }(Parser);\n\n  function _typeof$6(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$6 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$6 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$6(obj);\n  }\n  function _classCallCheck$5(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$5(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$5(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$5(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$5(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$5(subClass, superClass);\n  }\n  function _setPrototypeOf$5(o, p) {\n    _setPrototypeOf$5 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$5(o, p);\n  }\n  function _createSuper$5(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$5();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$5(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$5(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$5(this, result);\n    };\n  }\n  function _possibleConstructorReturn$5(self, call) {\n    if (call && (_typeof$6(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$5(self);\n  }\n  function _assertThisInitialized$5(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$5() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$5(o) {\n    _getPrototypeOf$5 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$5(o);\n  }\n  function _defineProperty$5(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var SecondParser = /*#__PURE__*/function (_Parser) {\n    _inherits$5(SecondParser, _Parser);\n    var _super = _createSuper$5(SecondParser);\n    function SecondParser() {\n      var _this;\n      _classCallCheck$5(this, SecondParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$5(_assertThisInitialized$5(_this), \"priority\", 50);\n      _defineProperty$5(_assertThisInitialized$5(_this), \"incompatibleTokens\", ['t', 'T']);\n      return _this;\n    }\n    _createClass$5(SecondParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token, match) {\n        switch (token) {\n          case 's':\n            return parseNumericPattern(numericPatterns.second, dateString);\n          case 'so':\n            return match.ordinalNumber(dateString, {\n              unit: 'second'\n            });\n          default:\n            return parseNDigits(token.length, dateString);\n        }\n      }\n    }, {\n      key: \"validate\",\n      value: function validate(_date, value) {\n        return value >= 0 && value <= 59;\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCSeconds(value, 0);\n        return date;\n      }\n    }]);\n    return SecondParser;\n  }(Parser);\n\n  function _typeof$5(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$5 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$5 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$5(obj);\n  }\n  function _classCallCheck$4(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$4(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$4(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$4(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$4(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$4(subClass, superClass);\n  }\n  function _setPrototypeOf$4(o, p) {\n    _setPrototypeOf$4 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$4(o, p);\n  }\n  function _createSuper$4(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$4();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$4(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$4(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$4(this, result);\n    };\n  }\n  function _possibleConstructorReturn$4(self, call) {\n    if (call && (_typeof$5(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$4(self);\n  }\n  function _assertThisInitialized$4(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$4() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$4(o) {\n    _getPrototypeOf$4 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$4(o);\n  }\n  function _defineProperty$4(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var FractionOfSecondParser = /*#__PURE__*/function (_Parser) {\n    _inherits$4(FractionOfSecondParser, _Parser);\n    var _super = _createSuper$4(FractionOfSecondParser);\n    function FractionOfSecondParser() {\n      var _this;\n      _classCallCheck$4(this, FractionOfSecondParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$4(_assertThisInitialized$4(_this), \"priority\", 30);\n      _defineProperty$4(_assertThisInitialized$4(_this), \"incompatibleTokens\", ['t', 'T']);\n      return _this;\n    }\n    _createClass$4(FractionOfSecondParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token) {\n        var valueCallback = function valueCallback(value) {\n          return Math.floor(value * Math.pow(10, -token.length + 3));\n        };\n        return mapValue(parseNDigits(token.length, dateString), valueCallback);\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, _flags, value) {\n        date.setUTCMilliseconds(value);\n        return date;\n      }\n    }]);\n    return FractionOfSecondParser;\n  }(Parser);\n\n  function _typeof$4(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$4 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$4 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$4(obj);\n  }\n  function _classCallCheck$3(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$3(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$3(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$3(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$3(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$3(subClass, superClass);\n  }\n  function _setPrototypeOf$3(o, p) {\n    _setPrototypeOf$3 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$3(o, p);\n  }\n  function _createSuper$3(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$3();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$3(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$3(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$3(this, result);\n    };\n  }\n  function _possibleConstructorReturn$3(self, call) {\n    if (call && (_typeof$4(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$3(self);\n  }\n  function _assertThisInitialized$3(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$3() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$3(o) {\n    _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$3(o);\n  }\n  function _defineProperty$3(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var ISOTimezoneWithZParser = /*#__PURE__*/function (_Parser) {\n    _inherits$3(ISOTimezoneWithZParser, _Parser);\n    var _super = _createSuper$3(ISOTimezoneWithZParser);\n    function ISOTimezoneWithZParser() {\n      var _this;\n      _classCallCheck$3(this, ISOTimezoneWithZParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$3(_assertThisInitialized$3(_this), \"priority\", 10);\n      _defineProperty$3(_assertThisInitialized$3(_this), \"incompatibleTokens\", ['t', 'T', 'x']);\n      return _this;\n    }\n    _createClass$3(ISOTimezoneWithZParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token) {\n        switch (token) {\n          case 'X':\n            return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);\n          case 'XX':\n            return parseTimezonePattern(timezonePatterns.basic, dateString);\n          case 'XXXX':\n            return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);\n          case 'XXXXX':\n            return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);\n          case 'XXX':\n          default:\n            return parseTimezonePattern(timezonePatterns.extended, dateString);\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, flags, value) {\n        if (flags.timestampIsSet) {\n          return date;\n        }\n        return new Date(date.getTime() - value);\n      }\n    }]);\n    return ISOTimezoneWithZParser;\n  }(Parser);\n\n  function _typeof$3(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$3 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$3 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$3(obj);\n  }\n  function _classCallCheck$2(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$2(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$2(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$2(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$2(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$2(subClass, superClass);\n  }\n  function _setPrototypeOf$2(o, p) {\n    _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$2(o, p);\n  }\n  function _createSuper$2(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$2();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$2(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$2(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$2(this, result);\n    };\n  }\n  function _possibleConstructorReturn$2(self, call) {\n    if (call && (_typeof$3(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$2(self);\n  }\n  function _assertThisInitialized$2(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$2() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$2(o) {\n    _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$2(o);\n  }\n  function _defineProperty$2(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n\n  var ISOTimezoneParser = /*#__PURE__*/function (_Parser) {\n    _inherits$2(ISOTimezoneParser, _Parser);\n    var _super = _createSuper$2(ISOTimezoneParser);\n    function ISOTimezoneParser() {\n      var _this;\n      _classCallCheck$2(this, ISOTimezoneParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$2(_assertThisInitialized$2(_this), \"priority\", 10);\n      _defineProperty$2(_assertThisInitialized$2(_this), \"incompatibleTokens\", ['t', 'T', 'X']);\n      return _this;\n    }\n    _createClass$2(ISOTimezoneParser, [{\n      key: \"parse\",\n      value: function parse(dateString, token) {\n        switch (token) {\n          case 'x':\n            return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);\n          case 'xx':\n            return parseTimezonePattern(timezonePatterns.basic, dateString);\n          case 'xxxx':\n            return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);\n          case 'xxxxx':\n            return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);\n          case 'xxx':\n          default:\n            return parseTimezonePattern(timezonePatterns.extended, dateString);\n        }\n      }\n    }, {\n      key: \"set\",\n      value: function set(date, flags, value) {\n        if (flags.timestampIsSet) {\n          return date;\n        }\n        return new Date(date.getTime() - value);\n      }\n    }]);\n    return ISOTimezoneParser;\n  }(Parser);\n\n  function _typeof$2(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$2 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$2 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$2(obj);\n  }\n  function _classCallCheck$1(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties$1(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass$1(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties$1(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits$1(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf$1(subClass, superClass);\n  }\n  function _setPrototypeOf$1(o, p) {\n    _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf$1(o, p);\n  }\n  function _createSuper$1(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct$1();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf$1(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf$1(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn$1(this, result);\n    };\n  }\n  function _possibleConstructorReturn$1(self, call) {\n    if (call && (_typeof$2(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized$1(self);\n  }\n  function _assertThisInitialized$1(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct$1() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf$1(o) {\n    _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf$1(o);\n  }\n  function _defineProperty$1(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var TimestampSecondsParser = /*#__PURE__*/function (_Parser) {\n    _inherits$1(TimestampSecondsParser, _Parser);\n    var _super = _createSuper$1(TimestampSecondsParser);\n    function TimestampSecondsParser() {\n      var _this;\n      _classCallCheck$1(this, TimestampSecondsParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty$1(_assertThisInitialized$1(_this), \"priority\", 40);\n      _defineProperty$1(_assertThisInitialized$1(_this), \"incompatibleTokens\", '*');\n      return _this;\n    }\n    _createClass$1(TimestampSecondsParser, [{\n      key: \"parse\",\n      value: function parse(dateString) {\n        return parseAnyDigitsSigned(dateString);\n      }\n    }, {\n      key: \"set\",\n      value: function set(_date, _flags, value) {\n        return [new Date(value * 1000), {\n          timestampIsSet: true\n        }];\n      }\n    }]);\n    return TimestampSecondsParser;\n  }(Parser);\n\n  function _typeof$1(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof$1 = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof$1 = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof$1(obj);\n  }\n  function _classCallCheck(instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  }\n  function _defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  function _createClass(Constructor, protoProps, staticProps) {\n    if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) _defineProperties(Constructor, staticProps);\n    return Constructor;\n  }\n  function _inherits(subClass, superClass) {\n    if (typeof superClass !== \"function\" && superClass !== null) {\n      throw new TypeError(\"Super expression must either be null or a function\");\n    }\n    subClass.prototype = Object.create(superClass && superClass.prototype, {\n      constructor: {\n        value: subClass,\n        writable: true,\n        configurable: true\n      }\n    });\n    if (superClass) _setPrototypeOf(subClass, superClass);\n  }\n  function _setPrototypeOf(o, p) {\n    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n      o.__proto__ = p;\n      return o;\n    };\n    return _setPrototypeOf(o, p);\n  }\n  function _createSuper(Derived) {\n    var hasNativeReflectConstruct = _isNativeReflectConstruct();\n    return function _createSuperInternal() {\n      var Super = _getPrototypeOf(Derived),\n        result;\n      if (hasNativeReflectConstruct) {\n        var NewTarget = _getPrototypeOf(this).constructor;\n        result = Reflect.construct(Super, arguments, NewTarget);\n      } else {\n        result = Super.apply(this, arguments);\n      }\n      return _possibleConstructorReturn(this, result);\n    };\n  }\n  function _possibleConstructorReturn(self, call) {\n    if (call && (_typeof$1(call) === \"object\" || typeof call === \"function\")) {\n      return call;\n    }\n    return _assertThisInitialized(self);\n  }\n  function _assertThisInitialized(self) {\n    if (self === void 0) {\n      throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n    }\n    return self;\n  }\n  function _isNativeReflectConstruct() {\n    if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n    if (Reflect.construct.sham) return false;\n    if (typeof Proxy === \"function\") return true;\n    try {\n      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n      return true;\n    } catch (e) {\n      return false;\n    }\n  }\n  function _getPrototypeOf(o) {\n    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n      return o.__proto__ || Object.getPrototypeOf(o);\n    };\n    return _getPrototypeOf(o);\n  }\n  function _defineProperty(obj, key, value) {\n    if (key in obj) {\n      Object.defineProperty(obj, key, {\n        value: value,\n        enumerable: true,\n        configurable: true,\n        writable: true\n      });\n    } else {\n      obj[key] = value;\n    }\n    return obj;\n  }\n  var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) {\n    _inherits(TimestampMillisecondsParser, _Parser);\n    var _super = _createSuper(TimestampMillisecondsParser);\n    function TimestampMillisecondsParser() {\n      var _this;\n      _classCallCheck(this, TimestampMillisecondsParser);\n      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n        args[_key] = arguments[_key];\n      }\n      _this = _super.call.apply(_super, [this].concat(args));\n      _defineProperty(_assertThisInitialized(_this), \"priority\", 20);\n      _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", '*');\n      return _this;\n    }\n    _createClass(TimestampMillisecondsParser, [{\n      key: \"parse\",\n      value: function parse(dateString) {\n        return parseAnyDigitsSigned(dateString);\n      }\n    }, {\n      key: \"set\",\n      value: function set(_date, _flags, value) {\n        return [new Date(value), {\n          timestampIsSet: true\n        }];\n      }\n    }]);\n    return TimestampMillisecondsParser;\n  }(Parser);\n\n  /*\n   * |     | Unit                           |     | Unit                           |\n   * |-----|--------------------------------|-----|--------------------------------|\n   * |  a  | AM, PM                         |  A* | Milliseconds in day            |\n   * |  b  | AM, PM, noon, midnight         |  B  | Flexible day period            |\n   * |  c  | Stand-alone local day of week  |  C* | Localized hour w/ day period   |\n   * |  d  | Day of month                   |  D  | Day of year                    |\n   * |  e  | Local day of week              |  E  | Day of week                    |\n   * |  f  |                                |  F* | Day of week in month           |\n   * |  g* | Modified Julian day            |  G  | Era                            |\n   * |  h  | Hour [1-12]                    |  H  | Hour [0-23]                    |\n   * |  i! | ISO day of week                |  I! | ISO week of year               |\n   * |  j* | Localized hour w/ day period   |  J* | Localized hour w/o day period  |\n   * |  k  | Hour [1-24]                    |  K  | Hour [0-11]                    |\n   * |  l* | (deprecated)                   |  L  | Stand-alone month              |\n   * |  m  | Minute                         |  M  | Month                          |\n   * |  n  |                                |  N  |                                |\n   * |  o! | Ordinal number modifier        |  O* | Timezone (GMT)                 |\n   * |  p  |                                |  P  |                                |\n   * |  q  | Stand-alone quarter            |  Q  | Quarter                        |\n   * |  r* | Related Gregorian year         |  R! | ISO week-numbering year        |\n   * |  s  | Second                         |  S  | Fraction of second             |\n   * |  t! | Seconds timestamp              |  T! | Milliseconds timestamp         |\n   * |  u  | Extended year                  |  U* | Cyclic year                    |\n   * |  v* | Timezone (generic non-locat.)  |  V* | Timezone (location)            |\n   * |  w  | Local week of year             |  W* | Week of month                  |\n   * |  x  | Timezone (ISO-8601 w/o Z)      |  X  | Timezone (ISO-8601)            |\n   * |  y  | Year (abs)                     |  Y  | Local week-numbering year      |\n   * |  z* | Timezone (specific non-locat.) |  Z* | Timezone (aliases)             |\n   *\n   * Letters marked by * are not implemented but reserved by Unicode standard.\n   *\n   * Letters marked by ! are non-standard, but implemented by date-fns:\n   * - `o` modifies the previous token to turn it into an ordinal (see `parse` docs)\n   * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,\n   *   i.e. 7 for Sunday, 1 for Monday, etc.\n   * - `I` is ISO week of year, as opposed to `w` which is local week of year.\n   * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.\n   *   `R` is supposed to be used in conjunction with `I` and `i`\n   *   for universal ISO week-numbering date, whereas\n   *   `Y` is supposed to be used in conjunction with `w` and `e`\n   *   for week-numbering date specific to the locale.\n   */\n\n  var parsers = {\n    G: new EraParser(),\n    y: new YearParser(),\n    Y: new LocalWeekYearParser(),\n    R: new ISOWeekYearParser(),\n    u: new ExtendedYearParser(),\n    Q: new QuarterParser(),\n    q: new StandAloneQuarterParser(),\n    M: new MonthParser(),\n    L: new StandAloneMonthParser(),\n    w: new LocalWeekParser(),\n    I: new ISOWeekParser(),\n    d: new DateParser(),\n    D: new DayOfYearParser(),\n    E: new DayParser(),\n    e: new LocalDayParser(),\n    c: new StandAloneLocalDayParser(),\n    i: new ISODayParser(),\n    a: new AMPMParser(),\n    b: new AMPMMidnightParser(),\n    B: new DayPeriodParser(),\n    h: new Hour1to12Parser(),\n    H: new Hour0to23Parser(),\n    K: new Hour0To11Parser(),\n    k: new Hour1To24Parser(),\n    m: new MinuteParser(),\n    s: new SecondParser(),\n    S: new FractionOfSecondParser(),\n    X: new ISOTimezoneWithZParser(),\n    x: new ISOTimezoneParser(),\n    t: new TimestampSecondsParser(),\n    T: new TimestampMillisecondsParser()\n  };\n\n  function _typeof(obj) {\n    \"@babel/helpers - typeof\";\n\n    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n      _typeof = function _typeof(obj) {\n        return typeof obj;\n      };\n    } else {\n      _typeof = function _typeof(obj) {\n        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n      };\n    }\n    return _typeof(obj);\n  }\n  function _createForOfIteratorHelper(o, allowArrayLike) {\n    var it;\n    if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) {\n      if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n        if (it) o = it;\n        var i = 0;\n        var F = function F() {};\n        return {\n          s: F,\n          n: function n() {\n            if (i >= o.length) return {\n              done: true\n            };\n            return {\n              done: false,\n              value: o[i++]\n            };\n          },\n          e: function e(_e) {\n            throw _e;\n          },\n          f: F\n        };\n      }\n      throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n    }\n    var normalCompletion = true,\n      didErr = false,\n      err;\n    return {\n      s: function s() {\n        it = o[Symbol.iterator]();\n      },\n      n: function n() {\n        var step = it.next();\n        normalCompletion = step.done;\n        return step;\n      },\n      e: function e(_e2) {\n        didErr = true;\n        err = _e2;\n      },\n      f: function f() {\n        try {\n          if (!normalCompletion && it[\"return\"] != null) it[\"return\"]();\n        } finally {\n          if (didErr) throw err;\n        }\n      }\n    };\n  }\n  function _unsupportedIterableToArray(o, minLen) {\n    if (!o) return;\n    if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n    var n = Object.prototype.toString.call(o).slice(8, -1);\n    if (n === \"Object\" && o.constructor) n = o.constructor.name;\n    if (n === \"Map\" || n === \"Set\") return Array.from(o);\n    if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n  }\n  function _arrayLikeToArray(arr, len) {\n    if (len == null || len > arr.length) len = arr.length;\n    for (var i = 0, arr2 = new Array(len); i < len; i++) {\n      arr2[i] = arr[i];\n    }\n    return arr2;\n  }\n  // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token\n  //   (one of the certain letters followed by `o`)\n  // - (\\w)\\1* matches any sequences of the same letter\n  // - '' matches two quote characters in a row\n  // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n  //   except a single quote symbol, which ends the sequence.\n  //   Two quote characters do not end the sequence.\n  //   If there is no matching single quote\n  //   then the sequence will continue until the end of the string.\n  // - . matches any single character unmatched by previous parts of the RegExps\n\n  var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\\w)\\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also\n  // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`\n\n  var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;\n  var escapedStringRegExp = /^'([^]*?)'?$/;\n  var doubleQuoteRegExp = /''/g;\n  var notWhitespaceRegExp = /\\S/;\n  var unescapedLatinCharacterRegExp = /[a-zA-Z]/;\n  /**\n   * @name parse\n   * @category Common Helpers\n   * @summary Parse the date.\n   *\n   * @description\n   * Return the date parsed from string using the given format string.\n   *\n   * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.\n   * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * The characters in the format string wrapped between two single quotes characters (') are escaped.\n   * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n   *\n   * Format of the format string is based on Unicode Technical Standard #35:\n   * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n   * with a few additions (see note 5 below the table).\n   *\n   * Not all tokens are compatible. Combinations that don't make sense or could lead to bugs are prohibited\n   * and will throw `RangeError`. For example usage of 24-hour format token with AM/PM token will throw an exception:\n   *\n   * ```javascript\n   * parse('23 AM', 'HH a', new Date())\n   * //=> RangeError: The format string mustn't contain `HH` and `a` at the same time\n   * ```\n   *\n   * See the compatibility table: https://docs.google.com/spreadsheets/d/e/2PACX-1vQOPU3xUhplll6dyoMmVUXHKl_8CRDs6_ueLmex3SoqwhuolkuN3O05l4rqx5h1dKX8eb46Ul-CCSrq/pubhtml?gid=0&single=true\n   *\n   * Accepted format string patterns:\n   * | Unit                            |Prior| Pattern | Result examples                   | Notes |\n   * |---------------------------------|-----|---------|-----------------------------------|-------|\n   * | Era                             | 140 | G..GGG  | AD, BC                            |       |\n   * |                                 |     | GGGG    | Anno Domini, Before Christ        | 2     |\n   * |                                 |     | GGGGG   | A, B                              |       |\n   * | Calendar year                   | 130 | y       | 44, 1, 1900, 2017, 9999           | 4     |\n   * |                                 |     | yo      | 44th, 1st, 1900th, 9999999th      | 4,5   |\n   * |                                 |     | yy      | 44, 01, 00, 17                    | 4     |\n   * |                                 |     | yyy     | 044, 001, 123, 999                | 4     |\n   * |                                 |     | yyyy    | 0044, 0001, 1900, 2017            | 4     |\n   * |                                 |     | yyyyy   | ...                               | 2,4   |\n   * | Local week-numbering year       | 130 | Y       | 44, 1, 1900, 2017, 9000           | 4     |\n   * |                                 |     | Yo      | 44th, 1st, 1900th, 9999999th      | 4,5   |\n   * |                                 |     | YY      | 44, 01, 00, 17                    | 4,6   |\n   * |                                 |     | YYY     | 044, 001, 123, 999                | 4     |\n   * |                                 |     | YYYY    | 0044, 0001, 1900, 2017            | 4,6   |\n   * |                                 |     | YYYYY   | ...                               | 2,4   |\n   * | ISO week-numbering year         | 130 | R       | -43, 1, 1900, 2017, 9999, -9999   | 4,5   |\n   * |                                 |     | RR      | -43, 01, 00, 17                   | 4,5   |\n   * |                                 |     | RRR     | -043, 001, 123, 999, -999         | 4,5   |\n   * |                                 |     | RRRR    | -0043, 0001, 2017, 9999, -9999    | 4,5   |\n   * |                                 |     | RRRRR   | ...                               | 2,4,5 |\n   * | Extended year                   | 130 | u       | -43, 1, 1900, 2017, 9999, -999    | 4     |\n   * |                                 |     | uu      | -43, 01, 99, -99                  | 4     |\n   * |                                 |     | uuu     | -043, 001, 123, 999, -999         | 4     |\n   * |                                 |     | uuuu    | -0043, 0001, 2017, 9999, -9999    | 4     |\n   * |                                 |     | uuuuu   | ...                               | 2,4   |\n   * | Quarter (formatting)            | 120 | Q       | 1, 2, 3, 4                        |       |\n   * |                                 |     | Qo      | 1st, 2nd, 3rd, 4th                | 5     |\n   * |                                 |     | QQ      | 01, 02, 03, 04                    |       |\n   * |                                 |     | QQQ     | Q1, Q2, Q3, Q4                    |       |\n   * |                                 |     | QQQQ    | 1st quarter, 2nd quarter, ...     | 2     |\n   * |                                 |     | QQQQQ   | 1, 2, 3, 4                        | 4     |\n   * | Quarter (stand-alone)           | 120 | q       | 1, 2, 3, 4                        |       |\n   * |                                 |     | qo      | 1st, 2nd, 3rd, 4th                | 5     |\n   * |                                 |     | qq      | 01, 02, 03, 04                    |       |\n   * |                                 |     | qqq     | Q1, Q2, Q3, Q4                    |       |\n   * |                                 |     | qqqq    | 1st quarter, 2nd quarter, ...     | 2     |\n   * |                                 |     | qqqqq   | 1, 2, 3, 4                        | 3     |\n   * | Month (formatting)              | 110 | M       | 1, 2, ..., 12                     |       |\n   * |                                 |     | Mo      | 1st, 2nd, ..., 12th               | 5     |\n   * |                                 |     | MM      | 01, 02, ..., 12                   |       |\n   * |                                 |     | MMM     | Jan, Feb, ..., Dec                |       |\n   * |                                 |     | MMMM    | January, February, ..., December  | 2     |\n   * |                                 |     | MMMMM   | J, F, ..., D                      |       |\n   * | Month (stand-alone)             | 110 | L       | 1, 2, ..., 12                     |       |\n   * |                                 |     | Lo      | 1st, 2nd, ..., 12th               | 5     |\n   * |                                 |     | LL      | 01, 02, ..., 12                   |       |\n   * |                                 |     | LLL     | Jan, Feb, ..., Dec                |       |\n   * |                                 |     | LLLL    | January, February, ..., December  | 2     |\n   * |                                 |     | LLLLL   | J, F, ..., D                      |       |\n   * | Local week of year              | 100 | w       | 1, 2, ..., 53                     |       |\n   * |                                 |     | wo      | 1st, 2nd, ..., 53th               | 5     |\n   * |                                 |     | ww      | 01, 02, ..., 53                   |       |\n   * | ISO week of year                | 100 | I       | 1, 2, ..., 53                     | 5     |\n   * |                                 |     | Io      | 1st, 2nd, ..., 53th               | 5     |\n   * |                                 |     | II      | 01, 02, ..., 53                   | 5     |\n   * | Day of month                    |  90 | d       | 1, 2, ..., 31                     |       |\n   * |                                 |     | do      | 1st, 2nd, ..., 31st               | 5     |\n   * |                                 |     | dd      | 01, 02, ..., 31                   |       |\n   * | Day of year                     |  90 | D       | 1, 2, ..., 365, 366               | 7     |\n   * |                                 |     | Do      | 1st, 2nd, ..., 365th, 366th       | 5     |\n   * |                                 |     | DD      | 01, 02, ..., 365, 366             | 7     |\n   * |                                 |     | DDD     | 001, 002, ..., 365, 366           |       |\n   * |                                 |     | DDDD    | ...                               | 2     |\n   * | Day of week (formatting)        |  90 | E..EEE  | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 |     | EEEE    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 |     | EEEEE   | M, T, W, T, F, S, S               |       |\n   * |                                 |     | EEEEEE  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | ISO day of week (formatting)    |  90 | i       | 1, 2, 3, ..., 7                   | 5     |\n   * |                                 |     | io      | 1st, 2nd, ..., 7th                | 5     |\n   * |                                 |     | ii      | 01, 02, ..., 07                   | 5     |\n   * |                                 |     | iii     | Mon, Tue, Wed, ..., Sun           | 5     |\n   * |                                 |     | iiii    | Monday, Tuesday, ..., Sunday      | 2,5   |\n   * |                                 |     | iiiii   | M, T, W, T, F, S, S               | 5     |\n   * |                                 |     | iiiiii  | Mo, Tu, We, Th, Fr, Sa, Su        | 5     |\n   * | Local day of week (formatting)  |  90 | e       | 2, 3, 4, ..., 1                   |       |\n   * |                                 |     | eo      | 2nd, 3rd, ..., 1st                | 5     |\n   * |                                 |     | ee      | 02, 03, ..., 01                   |       |\n   * |                                 |     | eee     | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 |     | eeee    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 |     | eeeee   | M, T, W, T, F, S, S               |       |\n   * |                                 |     | eeeeee  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | Local day of week (stand-alone) |  90 | c       | 2, 3, 4, ..., 1                   |       |\n   * |                                 |     | co      | 2nd, 3rd, ..., 1st                | 5     |\n   * |                                 |     | cc      | 02, 03, ..., 01                   |       |\n   * |                                 |     | ccc     | Mon, Tue, Wed, ..., Sun           |       |\n   * |                                 |     | cccc    | Monday, Tuesday, ..., Sunday      | 2     |\n   * |                                 |     | ccccc   | M, T, W, T, F, S, S               |       |\n   * |                                 |     | cccccc  | Mo, Tu, We, Th, Fr, Sa, Su        |       |\n   * | AM, PM                          |  80 | a..aaa  | AM, PM                            |       |\n   * |                                 |     | aaaa    | a.m., p.m.                        | 2     |\n   * |                                 |     | aaaaa   | a, p                              |       |\n   * | AM, PM, noon, midnight          |  80 | b..bbb  | AM, PM, noon, midnight            |       |\n   * |                                 |     | bbbb    | a.m., p.m., noon, midnight        | 2     |\n   * |                                 |     | bbbbb   | a, p, n, mi                       |       |\n   * | Flexible day period             |  80 | B..BBB  | at night, in the morning, ...     |       |\n   * |                                 |     | BBBB    | at night, in the morning, ...     | 2     |\n   * |                                 |     | BBBBB   | at night, in the morning, ...     |       |\n   * | Hour [1-12]                     |  70 | h       | 1, 2, ..., 11, 12                 |       |\n   * |                                 |     | ho      | 1st, 2nd, ..., 11th, 12th         | 5     |\n   * |                                 |     | hh      | 01, 02, ..., 11, 12               |       |\n   * | Hour [0-23]                     |  70 | H       | 0, 1, 2, ..., 23                  |       |\n   * |                                 |     | Ho      | 0th, 1st, 2nd, ..., 23rd          | 5     |\n   * |                                 |     | HH      | 00, 01, 02, ..., 23               |       |\n   * | Hour [0-11]                     |  70 | K       | 1, 2, ..., 11, 0                  |       |\n   * |                                 |     | Ko      | 1st, 2nd, ..., 11th, 0th          | 5     |\n   * |                                 |     | KK      | 01, 02, ..., 11, 00               |       |\n   * | Hour [1-24]                     |  70 | k       | 24, 1, 2, ..., 23                 |       |\n   * |                                 |     | ko      | 24th, 1st, 2nd, ..., 23rd         | 5     |\n   * |                                 |     | kk      | 24, 01, 02, ..., 23               |       |\n   * | Minute                          |  60 | m       | 0, 1, ..., 59                     |       |\n   * |                                 |     | mo      | 0th, 1st, ..., 59th               | 5     |\n   * |                                 |     | mm      | 00, 01, ..., 59                   |       |\n   * | Second                          |  50 | s       | 0, 1, ..., 59                     |       |\n   * |                                 |     | so      | 0th, 1st, ..., 59th               | 5     |\n   * |                                 |     | ss      | 00, 01, ..., 59                   |       |\n   * | Seconds timestamp               |  40 | t       | 512969520                         |       |\n   * |                                 |     | tt      | ...                               | 2     |\n   * | Fraction of second              |  30 | S       | 0, 1, ..., 9                      |       |\n   * |                                 |     | SS      | 00, 01, ..., 99                   |       |\n   * |                                 |     | SSS     | 000, 001, ..., 999                |       |\n   * |                                 |     | SSSS    | ...                               | 2     |\n   * | Milliseconds timestamp          |  20 | T       | 512969520900                      |       |\n   * |                                 |     | TT      | ...                               | 2     |\n   * | Timezone (ISO-8601 w/ Z)        |  10 | X       | -08, +0530, Z                     |       |\n   * |                                 |     | XX      | -0800, +0530, Z                   |       |\n   * |                                 |     | XXX     | -08:00, +05:30, Z                 |       |\n   * |                                 |     | XXXX    | -0800, +0530, Z, +123456          | 2     |\n   * |                                 |     | XXXXX   | -08:00, +05:30, Z, +12:34:56      |       |\n   * | Timezone (ISO-8601 w/o Z)       |  10 | x       | -08, +0530, +00                   |       |\n   * |                                 |     | xx      | -0800, +0530, +0000               |       |\n   * |                                 |     | xxx     | -08:00, +05:30, +00:00            | 2     |\n   * |                                 |     | xxxx    | -0800, +0530, +0000, +123456      |       |\n   * |                                 |     | xxxxx   | -08:00, +05:30, +00:00, +12:34:56 |       |\n   * | Long localized date             |  NA | P       | 05/29/1453                        | 5,8   |\n   * |                                 |     | PP      | May 29, 1453                      |       |\n   * |                                 |     | PPP     | May 29th, 1453                    |       |\n   * |                                 |     | PPPP    | Sunday, May 29th, 1453            | 2,5,8 |\n   * | Long localized time             |  NA | p       | 12:00 AM                          | 5,8   |\n   * |                                 |     | pp      | 12:00:00 AM                       |       |\n   * | Combination of date and time    |  NA | Pp      | 05/29/1453, 12:00 AM              |       |\n   * |                                 |     | PPpp    | May 29, 1453, 12:00:00 AM         |       |\n   * |                                 |     | PPPpp   | May 29th, 1453 at ...             |       |\n   * |                                 |     | PPPPpp  | Sunday, May 29th, 1453 at ...     | 2,5,8 |\n   * Notes:\n   * 1. \"Formatting\" units (e.g. formatting quarter) in the default en-US locale\n   *    are the same as \"stand-alone\" units, but are different in some languages.\n   *    \"Formatting\" units are declined according to the rules of the language\n   *    in the context of a date. \"Stand-alone\" units are always nominative singular.\n   *    In `format` function, they will produce different result:\n   *\n   *    `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`\n   *\n   *    `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`\n   *\n   *    `parse` will try to match both formatting and stand-alone units interchangably.\n   *\n   * 2. Any sequence of the identical letters is a pattern, unless it is escaped by\n   *    the single quote characters (see below).\n   *    If the sequence is longer than listed in table:\n   *    - for numerical units (`yyyyyyyy`) `parse` will try to match a number\n   *      as wide as the sequence\n   *    - for text units (`MMMMMMMM`) `parse` will try to match the widest variation of the unit.\n   *      These variations are marked with \"2\" in the last column of the table.\n   *\n   * 3. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.\n   *    These tokens represent the shortest form of the quarter.\n   *\n   * 4. The main difference between `y` and `u` patterns are B.C. years:\n   *\n   *    | Year | `y` | `u` |\n   *    |------|-----|-----|\n   *    | AC 1 |   1 |   1 |\n   *    | BC 1 |   1 |   0 |\n   *    | BC 2 |   2 |  -1 |\n   *\n   *    Also `yy` will try to guess the century of two digit year by proximity with `referenceDate`:\n   *\n   *    `parse('50', 'yy', new Date(2018, 0, 1)) //=> Sat Jan 01 2050 00:00:00`\n   *\n   *    `parse('75', 'yy', new Date(2018, 0, 1)) //=> Wed Jan 01 1975 00:00:00`\n   *\n   *    while `uu` will just assign the year as is:\n   *\n   *    `parse('50', 'uu', new Date(2018, 0, 1)) //=> Sat Jan 01 0050 00:00:00`\n   *\n   *    `parse('75', 'uu', new Date(2018, 0, 1)) //=> Tue Jan 01 0075 00:00:00`\n   *\n   *    The same difference is true for local and ISO week-numbering years (`Y` and `R`),\n   *    except local week-numbering years are dependent on `options.weekStartsOn`\n   *    and `options.firstWeekContainsDate` (compare [setISOWeekYear]{@link https://date-fns.org/docs/setISOWeekYear}\n   *    and [setWeekYear]{@link https://date-fns.org/docs/setWeekYear}).\n   *\n   * 5. These patterns are not in the Unicode Technical Standard #35:\n   *    - `i`: ISO day of week\n   *    - `I`: ISO week of year\n   *    - `R`: ISO week-numbering year\n   *    - `o`: ordinal number modifier\n   *    - `P`: long localized date\n   *    - `p`: long localized time\n   *\n   * 6. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.\n   *    You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * 7. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.\n   *    You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   *\n   * 8. `P+` tokens do not have a defined priority since they are merely aliases to other tokens based\n   *    on the given locale.\n   *\n   *    using `en-US` locale: `P` => `MM/dd/yyyy`\n   *    using `en-US` locale: `p` => `hh:mm a`\n   *    using `pt-BR` locale: `P` => `dd/MM/yyyy`\n   *    using `pt-BR` locale: `p` => `HH:mm`\n   *\n   * Values will be assigned to the date in the descending order of its unit's priority.\n   * Units of an equal priority overwrite each other in the order of appearance.\n   *\n   * If no values of higher priority are parsed (e.g. when parsing string 'January 1st' without a year),\n   * the values will be taken from 3rd argument `referenceDate` which works as a context of parsing.\n   *\n   * `referenceDate` must be passed for correct work of the function.\n   * If you're not sure which `referenceDate` to supply, create a new instance of Date:\n   * `parse('02/11/2014', 'MM/dd/yyyy', new Date())`\n   * In this case parsing will be done in the context of the current date.\n   * If `referenceDate` is `Invalid Date` or a value not convertible to valid `Date`,\n   * then `Invalid Date` will be returned.\n   *\n   * The result may vary by locale.\n   *\n   * If `formatString` matches with `dateString` but does not provides tokens, `referenceDate` will be returned.\n   *\n   * If parsing failed, `Invalid Date` will be returned.\n   * Invalid Date is a Date, whose time value is NaN.\n   * Time value of Date: http://es5.github.io/#x15.9.1.1\n   *\n   * @param {String} dateString - the string to parse\n   * @param {String} formatString - the string of tokens\n   * @param {Date|Number} referenceDate - defines values missing from the parsed dateString\n   * @param {Object} [options] - an object with options.\n   * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n   * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n   * @param {1|2|3|4|5|6|7} [options.firstWeekContainsDate=1] - the day of January, which is always in the first week of the year\n   * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;\n   *   see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;\n   *   see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @returns {Date} the parsed date\n   * @throws {TypeError} 3 arguments required\n   * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n   * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7\n   * @throws {RangeError} `options.locale` must contain `match` property\n   * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n   * @throws {RangeError} format string contains an unescaped latin alphabet character\n   *\n   * @example\n   * // Parse 11 February 2014 from middle-endian format:\n   * var result = parse('02/11/2014', 'MM/dd/yyyy', new Date())\n   * //=> Tue Feb 11 2014 00:00:00\n   *\n   * @example\n   * // Parse 28th of February in Esperanto locale in the context of 2010 year:\n   * import eo from 'date-fns/locale/eo'\n   * var result = parse('28-a de februaro', \"do 'de' MMMM\", new Date(2010, 0, 1), {\n   *   locale: eo\n   * })\n   * //=> Sun Feb 28 2010 00:00:00\n   */\n\n  function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, options) {\n    var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;\n    requiredArgs(3, arguments);\n    var dateString = String(dirtyDateString);\n    var formatString = String(dirtyFormatString);\n    var defaultOptions = getDefaultOptions();\n    var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;\n    if (!locale.match) {\n      throw new RangeError('locale must contain match property');\n    }\n    var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n\n    if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n      throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n    }\n    var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n\n    if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n      throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n    }\n    if (formatString === '') {\n      if (dateString === '') {\n        return toDate(dirtyReferenceDate);\n      } else {\n        return new Date(NaN);\n      }\n    }\n    var subFnOptions = {\n      firstWeekContainsDate: firstWeekContainsDate,\n      weekStartsOn: weekStartsOn,\n      locale: locale\n    }; // If timezone isn't specified, it will be set to the system timezone\n\n    var setters = [new DateToSystemTimezoneSetter()];\n    var tokens = formatString.match(longFormattingTokensRegExp).map(function (substring) {\n      var firstCharacter = substring[0];\n      if (firstCharacter in longFormatters$1) {\n        var longFormatter = longFormatters$1[firstCharacter];\n        return longFormatter(substring, locale.formatLong);\n      }\n      return substring;\n    }).join('').match(formattingTokensRegExp);\n    var usedTokens = [];\n    var _iterator = _createForOfIteratorHelper(tokens),\n      _step;\n    try {\n      var _loop = function _loop() {\n        var token = _step.value;\n        if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token)) {\n          throwProtectedError(token, formatString, dirtyDateString);\n        }\n        if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) {\n          throwProtectedError(token, formatString, dirtyDateString);\n        }\n        var firstCharacter = token[0];\n        var parser = parsers[firstCharacter];\n        if (parser) {\n          var incompatibleTokens = parser.incompatibleTokens;\n          if (Array.isArray(incompatibleTokens)) {\n            var incompatibleToken = usedTokens.find(function (usedToken) {\n              return incompatibleTokens.includes(usedToken.token) || usedToken.token === firstCharacter;\n            });\n            if (incompatibleToken) {\n              throw new RangeError(\"The format string mustn't contain `\".concat(incompatibleToken.fullToken, \"` and `\").concat(token, \"` at the same time\"));\n            }\n          } else if (parser.incompatibleTokens === '*' && usedTokens.length > 0) {\n            throw new RangeError(\"The format string mustn't contain `\".concat(token, \"` and any other token at the same time\"));\n          }\n          usedTokens.push({\n            token: firstCharacter,\n            fullToken: token\n          });\n          var parseResult = parser.run(dateString, token, locale.match, subFnOptions);\n          if (!parseResult) {\n            return {\n              v: new Date(NaN)\n            };\n          }\n          setters.push(parseResult.setter);\n          dateString = parseResult.rest;\n        } else {\n          if (firstCharacter.match(unescapedLatinCharacterRegExp)) {\n            throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n          } // Replace two single quote characters with one single quote character\n\n          if (token === \"''\") {\n            token = \"'\";\n          } else if (firstCharacter === \"'\") {\n            token = cleanEscapedString(token);\n          } // Cut token from string, or, if string doesn't match the token, return Invalid Date\n\n          if (dateString.indexOf(token) === 0) {\n            dateString = dateString.slice(token.length);\n          } else {\n            return {\n              v: new Date(NaN)\n            };\n          }\n        }\n      };\n      for (_iterator.s(); !(_step = _iterator.n()).done;) {\n        var _ret = _loop();\n        if (_typeof(_ret) === \"object\") return _ret.v;\n      } // Check if the remaining input contains something other than whitespace\n    } catch (err) {\n      _iterator.e(err);\n    } finally {\n      _iterator.f();\n    }\n    if (dateString.length > 0 && notWhitespaceRegExp.test(dateString)) {\n      return new Date(NaN);\n    }\n    var uniquePrioritySetters = setters.map(function (setter) {\n      return setter.priority;\n    }).sort(function (a, b) {\n      return b - a;\n    }).filter(function (priority, index, array) {\n      return array.indexOf(priority) === index;\n    }).map(function (priority) {\n      return setters.filter(function (setter) {\n        return setter.priority === priority;\n      }).sort(function (a, b) {\n        return b.subPriority - a.subPriority;\n      });\n    }).map(function (setterArray) {\n      return setterArray[0];\n    });\n    var date = toDate(dirtyReferenceDate);\n    if (isNaN(date.getTime())) {\n      return new Date(NaN);\n    } // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n\n    var utcDate = subMilliseconds(date, getTimezoneOffsetInMilliseconds(date));\n    var flags = {};\n    var _iterator2 = _createForOfIteratorHelper(uniquePrioritySetters),\n      _step2;\n    try {\n      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n        var setter = _step2.value;\n        if (!setter.validate(utcDate, subFnOptions)) {\n          return new Date(NaN);\n        }\n        var result = setter.set(utcDate, flags, subFnOptions); // Result is tuple (date, flags)\n\n        if (Array.isArray(result)) {\n          utcDate = result[0];\n          assign(flags, result[1]); // Result is date\n        } else {\n          utcDate = result;\n        }\n      }\n    } catch (err) {\n      _iterator2.e(err);\n    } finally {\n      _iterator2.f();\n    }\n    return utcDate;\n  }\n  function cleanEscapedString(input) {\n    return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, \"'\");\n  }\n\n  /**\n   * @name startOfHour\n   * @category Hour Helpers\n   * @summary Return the start of an hour for the given date.\n   *\n   * @description\n   * Return the start of an hour for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of an hour\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of an hour for 2 September 2014 11:55:00:\n   * const result = startOfHour(new Date(2014, 8, 2, 11, 55))\n   * //=> Tue Sep 02 2014 11:00:00\n   */\n\n  function startOfHour(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setMinutes(0, 0, 0);\n    return date;\n  }\n\n  /**\n   * @name startOfSecond\n   * @category Second Helpers\n   * @summary Return the start of a second for the given date.\n   *\n   * @description\n   * Return the start of a second for the given date.\n   * The result will be in the local timezone.\n   *\n   * @param {Date|Number} date - the original date\n   * @returns {Date} the start of a second\n   * @throws {TypeError} 1 argument required\n   *\n   * @example\n   * // The start of a second for 1 December 2014 22:15:45.400:\n   * const result = startOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))\n   * //=> Mon Dec 01 2014 22:15:45.000\n   */\n\n  function startOfSecond(dirtyDate) {\n    requiredArgs(1, arguments);\n    var date = toDate(dirtyDate);\n    date.setMilliseconds(0);\n    return date;\n  }\n\n  /**\n   * @name parseISO\n   * @category Common Helpers\n   * @summary Parse ISO string\n   *\n   * @description\n   * Parse the given string in ISO 8601 format and return an instance of Date.\n   *\n   * Function accepts complete ISO 8601 formats as well as partial implementations.\n   * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601\n   *\n   * If the argument isn't a string, the function cannot parse the string or\n   * the values are invalid, it returns Invalid Date.\n   *\n   * @param {String} argument - the value to convert\n   * @param {Object} [options] - an object with options.\n   * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format\n   * @returns {Date} the parsed date in the local time zone\n   * @throws {TypeError} 1 argument required\n   * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2\n   *\n   * @example\n   * // Convert string '2014-02-11T11:30:30' to date:\n   * const result = parseISO('2014-02-11T11:30:30')\n   * //=> Tue Feb 11 2014 11:30:30\n   *\n   * @example\n   * // Convert string '+02014101' to date,\n   * // if the additional number of digits in the extended year format is 1:\n   * const result = parseISO('+02014101', { additionalDigits: 1 })\n   * //=> Fri Apr 11 2014 00:00:00\n   */\n\n  function parseISO(argument, options) {\n    var _options$additionalDi;\n    requiredArgs(1, arguments);\n    var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);\n    if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {\n      throw new RangeError('additionalDigits must be 0, 1 or 2');\n    }\n    if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {\n      return new Date(NaN);\n    }\n    var dateStrings = splitDateString(argument);\n    var date;\n    if (dateStrings.date) {\n      var parseYearResult = parseYear(dateStrings.date, additionalDigits);\n      date = parseDate(parseYearResult.restDateString, parseYearResult.year);\n    }\n    if (!date || isNaN(date.getTime())) {\n      return new Date(NaN);\n    }\n    var timestamp = date.getTime();\n    var time = 0;\n    var offset;\n    if (dateStrings.time) {\n      time = parseTime(dateStrings.time);\n      if (isNaN(time)) {\n        return new Date(NaN);\n      }\n    }\n    if (dateStrings.timezone) {\n      offset = parseTimezone(dateStrings.timezone);\n      if (isNaN(offset)) {\n        return new Date(NaN);\n      }\n    } else {\n      var dirtyDate = new Date(timestamp + time); // js parsed string assuming it's in UTC timezone\n      // but we need it to be parsed in our timezone\n      // so we use utc values to build date in our timezone.\n      // Year values from 0 to 99 map to the years 1900 to 1999\n      // so set year explicitly with setFullYear.\n\n      var result = new Date(0);\n      result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());\n      result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());\n      return result;\n    }\n    return new Date(timestamp + time + offset);\n  }\n  var patterns = {\n    dateTimeDelimiter: /[T ]/,\n    timeZoneDelimiter: /[Z ]/i,\n    timezone: /([Z+-].*)$/\n  };\n  var dateRegex = /^-?(?:(\\d{3})|(\\d{2})(?:-?(\\d{2}))?|W(\\d{2})(?:-?(\\d{1}))?|)$/;\n  var timeRegex = /^(\\d{2}(?:[.,]\\d*)?)(?::?(\\d{2}(?:[.,]\\d*)?))?(?::?(\\d{2}(?:[.,]\\d*)?))?$/;\n  var timezoneRegex = /^([+-])(\\d{2})(?::?(\\d{2}))?$/;\n  function splitDateString(dateString) {\n    var dateStrings = {};\n    var array = dateString.split(patterns.dateTimeDelimiter);\n    var timeString; // The regex match should only return at maximum two array elements.\n    // [date], [time], or [date, time].\n\n    if (array.length > 2) {\n      return dateStrings;\n    }\n    if (/:/.test(array[0])) {\n      timeString = array[0];\n    } else {\n      dateStrings.date = array[0];\n      timeString = array[1];\n      if (patterns.timeZoneDelimiter.test(dateStrings.date)) {\n        dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];\n        timeString = dateString.substr(dateStrings.date.length, dateString.length);\n      }\n    }\n    if (timeString) {\n      var token = patterns.timezone.exec(timeString);\n      if (token) {\n        dateStrings.time = timeString.replace(token[1], '');\n        dateStrings.timezone = token[1];\n      } else {\n        dateStrings.time = timeString;\n      }\n    }\n    return dateStrings;\n  }\n  function parseYear(dateString, additionalDigits) {\n    var regex = new RegExp('^(?:(\\\\d{4}|[+-]\\\\d{' + (4 + additionalDigits) + '})|(\\\\d{2}|[+-]\\\\d{' + (2 + additionalDigits) + '})$)');\n    var captures = dateString.match(regex); // Invalid ISO-formatted year\n\n    if (!captures) return {\n      year: NaN,\n      restDateString: ''\n    };\n    var year = captures[1] ? parseInt(captures[1]) : null;\n    var century = captures[2] ? parseInt(captures[2]) : null; // either year or century is null, not both\n\n    return {\n      year: century === null ? year : century * 100,\n      restDateString: dateString.slice((captures[1] || captures[2]).length)\n    };\n  }\n  function parseDate(dateString, year) {\n    // Invalid ISO-formatted year\n    if (year === null) return new Date(NaN);\n    var captures = dateString.match(dateRegex); // Invalid ISO-formatted string\n\n    if (!captures) return new Date(NaN);\n    var isWeekDate = !!captures[4];\n    var dayOfYear = parseDateUnit(captures[1]);\n    var month = parseDateUnit(captures[2]) - 1;\n    var day = parseDateUnit(captures[3]);\n    var week = parseDateUnit(captures[4]);\n    var dayOfWeek = parseDateUnit(captures[5]) - 1;\n    if (isWeekDate) {\n      if (!validateWeekDate(year, week, dayOfWeek)) {\n        return new Date(NaN);\n      }\n      return dayOfISOWeekYear(year, week, dayOfWeek);\n    } else {\n      var date = new Date(0);\n      if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {\n        return new Date(NaN);\n      }\n      date.setUTCFullYear(year, month, Math.max(dayOfYear, day));\n      return date;\n    }\n  }\n  function parseDateUnit(value) {\n    return value ? parseInt(value) : 1;\n  }\n  function parseTime(timeString) {\n    var captures = timeString.match(timeRegex);\n    if (!captures) return NaN; // Invalid ISO-formatted time\n\n    var hours = parseTimeUnit(captures[1]);\n    var minutes = parseTimeUnit(captures[2]);\n    var seconds = parseTimeUnit(captures[3]);\n    if (!validateTime(hours, minutes, seconds)) {\n      return NaN;\n    }\n    return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;\n  }\n  function parseTimeUnit(value) {\n    return value && parseFloat(value.replace(',', '.')) || 0;\n  }\n  function parseTimezone(timezoneString) {\n    if (timezoneString === 'Z') return 0;\n    var captures = timezoneString.match(timezoneRegex);\n    if (!captures) return 0;\n    var sign = captures[1] === '+' ? -1 : 1;\n    var hours = parseInt(captures[2]);\n    var minutes = captures[3] && parseInt(captures[3]) || 0;\n    if (!validateTimezone(hours, minutes)) {\n      return NaN;\n    }\n    return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);\n  }\n  function dayOfISOWeekYear(isoWeekYear, week, day) {\n    var date = new Date(0);\n    date.setUTCFullYear(isoWeekYear, 0, 4);\n    var fourthOfJanuaryDay = date.getUTCDay() || 7;\n    var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;\n    date.setUTCDate(date.getUTCDate() + diff);\n    return date;\n  } // Validation functions\n  // February is null to handle the leap year (using ||)\n\n  var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n  function isLeapYearIndex(year) {\n    return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;\n  }\n  function validateDate(year, month, date) {\n    return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));\n  }\n  function validateDayOfYearDate(year, dayOfYear) {\n    return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);\n  }\n  function validateWeekDate(_year, week, day) {\n    return week >= 1 && week <= 53 && day >= 0 && day <= 6;\n  }\n  function validateTime(hours, minutes, seconds) {\n    if (hours === 24) {\n      return minutes === 0 && seconds === 0;\n    }\n    return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;\n  }\n  function validateTimezone(_hours, minutes) {\n    return minutes >= 0 && minutes <= 59;\n  }\n\n  var FORMATS = {\n    datetime: 'MMM d, yyyy, h:mm:ss aaaa',\n    millisecond: 'h:mm:ss.SSS aaaa',\n    second: 'h:mm:ss aaaa',\n    minute: 'h:mm aaaa',\n    hour: 'ha',\n    day: 'MMM d',\n    week: 'PP',\n    month: 'MMM yyyy',\n    quarter: 'qqq - yyyy',\n    year: 'yyyy'\n  };\n  adapters._date.override({\n    _id: 'date-fns',\n    // DEBUG\n\n    formats: function formats() {\n      return FORMATS;\n    },\n    parse: function parse$1(value, fmt) {\n      if (value === null || typeof value === 'undefined') {\n        return null;\n      }\n      var type = _typeof$z(value);\n      if (type === 'number' || value instanceof Date) {\n        value = toDate(value);\n      } else if (type === 'string') {\n        if (typeof fmt === 'string') {\n          value = parse(value, fmt, new Date(), this.options);\n        } else {\n          value = parseISO(value, this.options);\n        }\n      }\n      return isValid(value) ? value.getTime() : null;\n    },\n    format: function format$1(time, fmt) {\n      return format(time, fmt, this.options);\n    },\n    add: function add(time, amount, unit) {\n      switch (unit) {\n        case 'millisecond':\n          return addMilliseconds(time, amount);\n        case 'second':\n          return addSeconds(time, amount);\n        case 'minute':\n          return addMinutes(time, amount);\n        case 'hour':\n          return addHours(time, amount);\n        case 'day':\n          return addDays(time, amount);\n        case 'week':\n          return addWeeks(time, amount);\n        case 'month':\n          return addMonths(time, amount);\n        case 'quarter':\n          return addQuarters(time, amount);\n        case 'year':\n          return addYears(time, amount);\n        default:\n          return time;\n      }\n    },\n    diff: function diff(max, min, unit) {\n      switch (unit) {\n        case 'millisecond':\n          return differenceInMilliseconds(max, min);\n        case 'second':\n          return differenceInSeconds(max, min);\n        case 'minute':\n          return differenceInMinutes(max, min);\n        case 'hour':\n          return differenceInHours(max, min);\n        case 'day':\n          return differenceInDays(max, min);\n        case 'week':\n          return differenceInWeeks(max, min);\n        case 'month':\n          return differenceInMonths(max, min);\n        case 'quarter':\n          return differenceInQuarters(max, min);\n        case 'year':\n          return differenceInYears(max, min);\n        default:\n          return 0;\n      }\n    },\n    startOf: function startOf(time, unit, weekday) {\n      switch (unit) {\n        case 'second':\n          return startOfSecond(time);\n        case 'minute':\n          return startOfMinute(time);\n        case 'hour':\n          return startOfHour(time);\n        case 'day':\n          return startOfDay(time);\n        case 'week':\n          return startOfWeek(time);\n        case 'isoWeek':\n          return startOfWeek(time, {\n            weekStartsOn: +weekday\n          });\n        case 'month':\n          return startOfMonth(time);\n        case 'quarter':\n          return startOfQuarter(time);\n        case 'year':\n          return startOfYear(time);\n        default:\n          return time;\n      }\n    },\n    endOf: function endOf(time, unit) {\n      switch (unit) {\n        case 'second':\n          return endOfSecond(time);\n        case 'minute':\n          return endOfMinute(time);\n        case 'hour':\n          return endOfHour(time);\n        case 'day':\n          return endOfDay(time);\n        case 'week':\n          return endOfWeek(time);\n        case 'month':\n          return endOfMonth(time);\n        case 'quarter':\n          return endOfQuarter(time);\n        case 'year':\n          return endOfYear(time);\n        default:\n          return time;\n      }\n    }\n  });\n\n  // for plugins\n  // match src/index.umd.ts in Chart.js\n  // except for platforms (not exported)\n  Chart.helpers = _objectSpread2({}, helpers);\n  Chart._adapters = adapters;\n  Chart.Animation = Animation;\n  Chart.Animations = Animations;\n  Chart.animator = animator;\n  Chart.controllers = registry.controllers.items;\n  Chart.DatasetController = DatasetController;\n  Chart.Element = Element;\n  Chart.elements = elements;\n  Chart.Interaction = Interaction;\n  Chart.layouts = layouts;\n  Chart.Scale = Scale;\n  Chart.Ticks = Ticks;\n  Object.assign(Chart, controllers, scales, elements, plugins);\n  Chart.Chart = Chart;\n\n  return Chart;\n\n}));\n"
  },
  {
    "path": "app/assets/javascripts/pghero/application.js",
    "content": "//= require ./jquery\n//= require ./nouislider\n//= require ./Chart.bundle\n//= require ./chartkick\n//= require ./highlight.min\n\nfunction highlightQueries() {\n  $(\"pre code\").each(function (i, block) {\n    $(block).addClass(\"language-pgsql\");\n    hljs.highlightElement(block);\n  });\n}\n\nfunction initSlider() {\n  function roundTime(time) {\n    var period = 1000 * 60 * 5;\n    return new Date(Math.ceil(time.getTime() / period) * period);\n  }\n\n  function pad(num) {\n    return (num < 10) ? \"0\" + num : num;\n  }\n\n  var months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n  var days = 1;\n  var now = new Date();\n  var sliderStartAt = roundTime(now) - days * 24 * 60 * 60 * 1000;\n  var sliderMax = 24 * 12 * days;\n\n  startAt = startAt || sliderStartAt;\n  var min = (startAt > 0) ? (startAt - sliderStartAt) / (1000 * 60 * 5) : 0;\n\n  var max = (endAt > 0) ? (endAt - sliderStartAt) / (1000 * 60 * 5) : sliderMax;\n\n  var slider = document.getElementById(\"slider\");\n\n  noUiSlider.create(slider, {\n    range: {\n      min: 0,\n      max: sliderMax\n    },\n    step: 1,\n    connect: true,\n    start: [min, max]\n  });\n\n  // remove outline for mouse only\n  $(\".noUi-handle\").mousedown(function () {\n    $(this).addClass(\"no-outline\");\n  }).blur(function () {\n    $(this).removeClass(\"no-outline\");\n  });\n\n  function updateText() {\n    var values = slider.noUiSlider.get();\n    setText(\"#range-start\", values[0]);\n    setText(\"#range-end\", values[1]);\n  }\n\n  function setText(selector, offset) {\n    var time = timeAt(offset);\n\n    var html = \"\";\n    if (time === now) {\n      if (selector === \"#range-end\") {\n        html = \"Now\";\n      }\n    } else {\n      html = time.getDate() + \" \" + months[time.getMonth()] + \" \" + pad(time.getHours()) + \":\" + pad(time.getMinutes());\n    }\n    $(selector).text(html);\n  }\n\n  function timeAt(offset) {\n    var time = new Date(sliderStartAt + (offset * 5) * 60 * 1000);\n    return (time > now) ? now : time;\n  }\n\n  function timeParam(time) {\n    return time.toISOString().replace(/\\.000Z$/, \"Z\");\n  }\n\n  function queriesPath(params) {\n    var path = \"queries\";\n    if (params.start_at || params.end_at || params.sort || params.min_average_time || params.min_calls || params.debug) {\n      path += \"?\" + $.param(params);\n    }\n    return path;\n  }\n\n  function refreshStats(push) {\n    var values = slider.noUiSlider.get();\n    var startAt = push ? timeAt(values[0]) : new Date(window.startAt);\n    var endAt = timeAt(values[1]);\n\n    var params = {}\n    if (startAt.getTime() != sliderStartAt) {\n      params.start_at = timeParam(startAt);\n    }\n    if (endAt < now) {\n      params.end_at = timeParam(endAt);\n    }\n    if (sort) {\n      params.sort = sort;\n    }\n    if (minAverageTime) {\n      params.min_average_time = minAverageTime;\n    }\n    if (minCalls) {\n      params.min_calls = minCalls;\n    }\n    if (debug) {\n      params.debug = debug;\n    }\n\n    var path = queriesPath(params);\n\n    $(\".queries-table th a\").each(function () {\n      var p = $.extend({}, params, {sort: $(this).data(\"sort\"), min_average_time: minAverageTime, min_calls: minCalls, debug: debug});\n      if (!p.sort) {\n        delete p.sort;\n      }\n      if (!p.min_average_time) {\n        delete p.min_average_time;\n      }\n      if (!p.min_calls) {\n        delete p.min_calls;\n      }\n      if (!p.debug) {\n        delete p.debug;\n      }\n      $(this).attr(\"href\", queriesPath(p));\n    });\n\n\n    var callback = function (response, status, xhr) {\n      if (status === \"error\" ) {\n        $(\".queries-info\").css(\"color\", \"red\").text(xhr.status + \" \" + xhr.statusText);\n      } else {\n        highlightQueries();\n      }\n    };\n    $(\"#queries\").html('<tr><td colspan=\"3\"><p class=\"queries-info text-muted\">...</p></td></tr>').load(path, callback);\n\n    if (push && history.pushState) {\n      history.pushState(null, null, path);\n    }\n  }\n\n  slider.noUiSlider.on(\"slide\", updateText);\n  slider.noUiSlider.on(\"change\", function () {\n    refreshStats(true);\n  });\n  updateText();\n  $(function () {\n    refreshStats(false);\n  });\n}\n\n$(document).on(\"click\", \".query-code\", function () {\n  this.style.maxHeight = \"none\";\n});\n\n$(document).on(\"click\", \".migration-link\", function (e) {\n  e.preventDefault();\n  $(this).parent().next(\".migration\").css(\"display\", \"block\");\n});\n\n$(document).on(\"click\", \".show-details\", function () {\n  $(this).nextAll(\".details\").css(\"display\", \"block\");\n  $(this).css(\"display\", \"none\");\n});\n"
  },
  {
    "path": "app/assets/javascripts/pghero/chartkick.js",
    "content": "/*!\n * Chartkick.js v5.0.1\n * Create beautiful charts with one line of JavaScript\n * https://github.com/ankane/chartkick.js\n * MIT License\n */\n\n(function (global, factory) {\n  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n  typeof define === 'function' && define.amd ? define(factory) :\n  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chartkick = factory());\n})(this, (function () { 'use strict';\n\n  function isArray(variable) {\n    return Object.prototype.toString.call(variable) === \"[object Array]\";\n  }\n\n  function isFunction(variable) {\n    return variable instanceof Function;\n  }\n\n  function isPlainObject(variable) {\n    // protect against prototype pollution, defense 2\n    return Object.prototype.toString.call(variable) === \"[object Object]\" && !isFunction(variable) && variable instanceof Object;\n  }\n\n  // https://github.com/madrobby/zepto/blob/master/src/zepto.js\n  function extend(target, source) {\n    for (var key in source) {\n      // protect against prototype pollution, defense 1\n      if (key === \"__proto__\") { continue; }\n\n      if (isPlainObject(source[key]) || isArray(source[key])) {\n        if (isPlainObject(source[key]) && !isPlainObject(target[key])) {\n          target[key] = {};\n        }\n        if (isArray(source[key]) && !isArray(target[key])) {\n          target[key] = [];\n        }\n        extend(target[key], source[key]);\n      } else if (source[key] !== undefined) {\n        target[key] = source[key];\n      }\n    }\n  }\n\n  function merge(obj1, obj2) {\n    var target = {};\n    extend(target, obj1);\n    extend(target, obj2);\n    return target;\n  }\n\n  var DATE_PATTERN = /^(\\d\\d\\d\\d)(?:-)?(\\d\\d)(?:-)?(\\d\\d)$/i;\n\n  function negativeValues(series) {\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n      for (var j = 0; j < data.length; j++) {\n        if (data[j][1] < 0) {\n          return true;\n        }\n      }\n    }\n    return false;\n  }\n\n  function toStr(obj) {\n    return \"\" + obj;\n  }\n\n  function toFloat(obj) {\n    return parseFloat(obj);\n  }\n\n  function toDate(obj) {\n    if (obj instanceof Date) {\n      return obj;\n    } else if (typeof obj === \"number\") {\n      return new Date(obj * 1000); // ms\n    } else {\n      var s = toStr(obj);\n      var matches = s.match(DATE_PATTERN);\n      if (matches) {\n        var year = parseInt(matches[1], 10);\n        var month = parseInt(matches[2], 10) - 1;\n        var day = parseInt(matches[3], 10);\n        return new Date(year, month, day);\n      } else {\n        // try our best to get the str into iso8601\n        // TODO be smarter about this\n        var str = s.replace(/ /, \"T\").replace(\" \", \"\").replace(\"UTC\", \"Z\");\n        // Date.parse returns milliseconds if valid and NaN if invalid\n        return new Date(Date.parse(str) || s);\n      }\n    }\n  }\n\n  function toArr(obj) {\n    if (isArray(obj)) {\n      return obj;\n    } else {\n      var arr = [];\n      for (var i in obj) {\n        if (Object.prototype.hasOwnProperty.call(obj, i)) {\n          arr.push([i, obj[i]]);\n        }\n      }\n      return arr;\n    }\n  }\n\n  function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {\n    return function (chart, opts, chartOptions) {\n      var series = chart.data;\n      var options = merge({}, defaultOptions);\n      options = merge(options, chartOptions || {});\n\n      if (chart.singleSeriesFormat || \"legend\" in opts) {\n        hideLegend(options, opts.legend, chart.singleSeriesFormat);\n      }\n\n      if (opts.title) {\n        setTitle(options, opts.title);\n      }\n\n      // min\n      if (\"min\" in opts) {\n        setMin(options, opts.min);\n      } else if (!negativeValues(series)) {\n        setMin(options, 0);\n      }\n\n      // max\n      if (opts.max) {\n        setMax(options, opts.max);\n      }\n\n      if (\"stacked\" in opts) {\n        setStacked(options, opts.stacked);\n      }\n\n      if (opts.colors) {\n        options.colors = opts.colors;\n      }\n\n      if (opts.xtitle) {\n        setXtitle(options, opts.xtitle);\n      }\n\n      if (opts.ytitle) {\n        setYtitle(options, opts.ytitle);\n      }\n\n      // merge library last\n      options = merge(options, opts.library || {});\n\n      return options;\n    };\n  }\n\n  function sortByTime(a, b) {\n    return a[0].getTime() - b[0].getTime();\n  }\n\n  function sortByNumberSeries(a, b) {\n    return a[0] - b[0];\n  }\n\n  // needed since sort() without arguments does string comparison\n  function sortByNumber(a, b) {\n    return a - b;\n  }\n\n  function every(values, fn) {\n    for (var i = 0; i < values.length; i++) {\n      if (!fn(values[i])) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  function isDay(timeUnit) {\n    return timeUnit === \"day\" || timeUnit === \"week\" || timeUnit === \"month\" || timeUnit === \"year\";\n  }\n\n  function calculateTimeUnit(values, maxDay) {\n    if ( maxDay === void 0 ) maxDay = false;\n\n    if (values.length === 0) {\n      return null;\n    }\n\n    var minute = every(values, function (d) { return d.getMilliseconds() === 0 && d.getSeconds() === 0; });\n    if (!minute) {\n      return null;\n    }\n\n    var hour = every(values, function (d) { return d.getMinutes() === 0; });\n    if (!hour) {\n      return \"minute\";\n    }\n\n    var day = every(values, function (d) { return d.getHours() === 0; });\n    if (!day) {\n      return \"hour\";\n    }\n\n    if (maxDay) {\n      return \"day\";\n    }\n\n    var month = every(values, function (d) { return d.getDate() === 1; });\n    if (!month) {\n      var dayOfWeek = values[0].getDay();\n      var week = every(values, function (d) { return d.getDay() === dayOfWeek; });\n      return (week ? \"week\" : \"day\");\n    }\n\n    var year = every(values, function (d) { return d.getMonth() === 0; });\n    if (!year) {\n      return \"month\";\n    }\n\n    return \"year\";\n  }\n\n  function isDate(obj) {\n    return !isNaN(toDate(obj)) && toStr(obj).length >= 6;\n  }\n\n  function isNumber(obj) {\n    return typeof obj === \"number\";\n  }\n\n  var byteSuffixes = [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\"];\n\n  function formatValue(pre, value, options, axis) {\n    pre = pre || \"\";\n    if (options.prefix) {\n      if (value < 0) {\n        value = value * -1;\n        pre += \"-\";\n      }\n      pre += options.prefix;\n    }\n\n    var suffix = options.suffix || \"\";\n    var precision = options.precision;\n    var round = options.round;\n\n    if (options.byteScale) {\n      var positive = value >= 0;\n      if (!positive) {\n        value *= -1;\n      }\n\n      var baseValue = axis ? options.byteScale : value;\n\n      var suffixIdx;\n      if (baseValue >= 1152921504606846976) {\n        value /= 1152921504606846976;\n        suffixIdx = 6;\n      } else if (baseValue >= 1125899906842624) {\n        value /= 1125899906842624;\n        suffixIdx = 5;\n      } else if (baseValue >= 1099511627776) {\n        value /= 1099511627776;\n        suffixIdx = 4;\n      } else if (baseValue >= 1073741824) {\n        value /= 1073741824;\n        suffixIdx = 3;\n      } else if (baseValue >= 1048576) {\n        value /= 1048576;\n        suffixIdx = 2;\n      } else if (baseValue >= 1024) {\n        value /= 1024;\n        suffixIdx = 1;\n      } else {\n        suffixIdx = 0;\n      }\n\n      // TODO handle manual precision case\n      if (precision === undefined && round === undefined) {\n        if (value >= 1023.5) {\n          if (suffixIdx < byteSuffixes.length - 1) {\n            value = 1.0;\n            suffixIdx += 1;\n          }\n        }\n        precision = value >= 1000 ? 4 : 3;\n      }\n      suffix = \" \" + byteSuffixes[suffixIdx];\n\n      // flip value back\n      if (!positive) {\n        value *= -1;\n      }\n    }\n\n    if (precision !== undefined && round !== undefined) {\n      throw Error(\"Use either round or precision, not both\");\n    }\n\n    if (!axis) {\n      if (precision !== undefined) {\n        value = value.toPrecision(precision);\n        if (!options.zeros) {\n          value = parseFloat(value);\n        }\n      }\n\n      if (round !== undefined) {\n        if (round < 0) {\n          var num = Math.pow(10, -1 * round);\n          value = parseInt((1.0 * value / num).toFixed(0)) * num;\n        } else {\n          value = value.toFixed(round);\n          if (!options.zeros) {\n            value = parseFloat(value);\n          }\n        }\n      }\n    }\n\n    if (options.thousands || options.decimal) {\n      value = toStr(value);\n      var parts = value.split(\".\");\n      value = parts[0];\n      if (options.thousands) {\n        value = value.replace(/\\B(?=(\\d{3})+(?!\\d))/g, options.thousands);\n      }\n      if (parts.length > 1) {\n        value += (options.decimal || \".\") + parts[1];\n      }\n    }\n\n    return pre + value + suffix;\n  }\n\n  function seriesOption(chart, series, option) {\n    if (option in series) {\n      return series[option];\n    } else if (option in chart.options) {\n      return chart.options[option];\n    }\n    return null;\n  }\n\n  var baseOptions = {\n    maintainAspectRatio: false,\n    animation: false,\n    plugins: {\n      legend: {},\n      tooltip: {\n        displayColors: false,\n        callbacks: {}\n      },\n      title: {\n        font: {\n          size: 20\n        },\n        color: \"#333\"\n      }\n    },\n    interaction: {}\n  };\n\n  var defaultOptions$2 = {\n    scales: {\n      y: {\n        ticks: {\n          maxTicksLimit: 4\n        },\n        title: {\n          font: {\n            size: 16\n          },\n          color: \"#333\"\n        },\n        grid: {}\n      },\n      x: {\n        grid: {\n          drawOnChartArea: false\n        },\n        title: {\n          font: {\n            size: 16\n          },\n          color: \"#333\"\n        },\n        time: {},\n        ticks: {}\n      }\n    }\n  };\n\n  // http://there4.io/2012/05/02/google-chart-color-list/\n  var defaultColors = [\n    \"#3366CC\", \"#DC3912\", \"#FF9900\", \"#109618\", \"#990099\", \"#3B3EAC\", \"#0099C6\",\n    \"#DD4477\", \"#66AA00\", \"#B82E2E\", \"#316395\", \"#994499\", \"#22AA99\", \"#AAAA11\",\n    \"#6633CC\", \"#E67300\", \"#8B0707\", \"#329262\", \"#5574A6\", \"#651067\"\n  ];\n\n  function hideLegend$2(options, legend, hideLegend) {\n    if (legend !== undefined) {\n      options.plugins.legend.display = !!legend;\n      if (legend && legend !== true) {\n        options.plugins.legend.position = legend;\n      }\n    } else if (hideLegend) {\n      options.plugins.legend.display = false;\n    }\n  }\n\n  function setTitle$2(options, title) {\n    options.plugins.title.display = true;\n    options.plugins.title.text = title;\n  }\n\n  function setMin$2(options, min) {\n    if (min !== null) {\n      options.scales.y.min = toFloat(min);\n    }\n  }\n\n  function setMax$2(options, max) {\n    options.scales.y.max = toFloat(max);\n  }\n\n  function setBarMin$1(options, min) {\n    if (min !== null) {\n      options.scales.x.min = toFloat(min);\n    }\n  }\n\n  function setBarMax$1(options, max) {\n    options.scales.x.max = toFloat(max);\n  }\n\n  function setStacked$2(options, stacked) {\n    options.scales.x.stacked = !!stacked;\n    options.scales.y.stacked = !!stacked;\n  }\n\n  function setXtitle$2(options, title) {\n    options.scales.x.title.display = true;\n    options.scales.x.title.text = title;\n  }\n\n  function setYtitle$2(options, title) {\n    options.scales.y.title.display = true;\n    options.scales.y.title.text = title;\n  }\n\n  // https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb\n  function addOpacity(hex, opacity) {\n    var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n    return result ? \"rgba(\" + parseInt(result[1], 16) + \", \" + parseInt(result[2], 16) + \", \" + parseInt(result[3], 16) + \", \" + opacity + \")\" : hex;\n  }\n\n  function notnull(x) {\n    return x !== null && x !== undefined;\n  }\n\n  function setLabelSize(chart, data, options) {\n    var maxLabelSize = Math.ceil(chart.element.offsetWidth / 4.0 / data.labels.length);\n    if (maxLabelSize > 25) {\n      maxLabelSize = 25;\n    } else if (maxLabelSize < 10) {\n      maxLabelSize = 10;\n    }\n    if (!options.scales.x.ticks.callback) {\n      options.scales.x.ticks.callback = function (value) {\n        value = toStr(this.getLabelForValue(value));\n        if (value.length > maxLabelSize) {\n          return value.substring(0, maxLabelSize - 2) + \"...\";\n        } else {\n          return value;\n        }\n      };\n    }\n  }\n\n  function calculateScale(series) {\n    var scale = 1;\n    var max = maxAbsY(series);\n    while (max >= 1024) {\n      scale *= 1024;\n      max /= 1024;\n    }\n    return scale;\n  }\n\n  function setFormatOptions$1(chart, options, chartType) {\n    // options to apply to x and r values for scatter and bubble\n    var numericOptions = {\n      thousands: chart.options.thousands,\n      decimal: chart.options.decimal\n    };\n\n    // options to apply to y value\n    var formatOptions = merge({\n      prefix: chart.options.prefix,\n      suffix: chart.options.suffix,\n      precision: chart.options.precision,\n      round: chart.options.round,\n      zeros: chart.options.zeros\n    }, numericOptions);\n\n    if (chart.options.bytes) {\n      var series = chart.data;\n      if (chartType === \"pie\") {\n        series = [{data: series}];\n      }\n\n      // set step size\n      formatOptions.byteScale = calculateScale(series);\n    }\n\n    if (chartType !== \"pie\") {\n      var axis = options.scales.y;\n      if (chartType === \"bar\") {\n        axis = options.scales.x;\n      }\n\n      if (formatOptions.byteScale) {\n        if (!axis.ticks.stepSize) {\n          axis.ticks.stepSize = formatOptions.byteScale / 2;\n        }\n        if (!axis.ticks.maxTicksLimit) {\n          axis.ticks.maxTicksLimit = 4;\n        }\n      }\n\n      if (!axis.ticks.callback) {\n        axis.ticks.callback = function (value) {\n          return formatValue(\"\", value, formatOptions, true);\n        };\n      }\n\n      if ((chartType === \"scatter\" || chartType === \"bubble\") && !options.scales.x.ticks.callback) {\n        options.scales.x.ticks.callback = function (value) {\n          return formatValue(\"\", value, numericOptions, true);\n        };\n      }\n    }\n\n    if (!options.plugins.tooltip.callbacks.label) {\n      if (chartType === \"scatter\") {\n        options.plugins.tooltip.callbacks.label = function (context) {\n          var label = context.dataset.label || '';\n          if (label) {\n            label += ': ';\n          }\n\n          var dataPoint = context.parsed;\n          return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ')';\n        };\n      } else if (chartType === \"bubble\") {\n        options.plugins.tooltip.callbacks.label = function (context) {\n          var label = context.dataset.label || '';\n          if (label) {\n            label += ': ';\n          }\n          var dataPoint = context.raw;\n          return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ', ' + formatValue('', dataPoint.v, numericOptions) + ')';\n        };\n      } else if (chartType === \"pie\") {\n        // need to use separate label for pie charts\n        options.plugins.tooltip.callbacks.label = function (context) {\n          return formatValue('', context.parsed, formatOptions);\n        };\n      } else {\n        var valueLabel = chartType === \"bar\" ? \"x\" : \"y\";\n        options.plugins.tooltip.callbacks.label = function (context) {\n          // don't show null values for stacked charts\n          if (context.parsed[valueLabel] === null) {\n            return;\n          }\n\n          var label = context.dataset.label || '';\n          if (label) {\n            label += ': ';\n          }\n          return formatValue(label, context.parsed[valueLabel], formatOptions);\n        };\n      }\n    }\n\n    // avoid formatting x-axis labels\n    // by default, Chart.js applies locale\n    if ((chartType === \"line\" || chartType === \"area\") && chart.xtype === \"number\") {\n      if (!options.scales.x.ticks.callback) {\n        options.scales.x.ticks.callback = function (value) {\n          return toStr(value);\n        };\n      }\n\n      if (!options.plugins.tooltip.callbacks.title) {\n        options.plugins.tooltip.callbacks.title = function (context) {\n          return toStr(context[0].parsed.x);\n        };\n      }\n    }\n  }\n\n  function maxAbsY(series) {\n    var max = 0;\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n      for (var j = 0; j < data.length; j++) {\n        var v = Math.abs(data[j][1]);\n        if (v > max) {\n          max = v;\n        }\n      }\n    }\n    return max;\n  }\n\n  function maxR(series) {\n    // start at zero since radius must be positive\n    var max = 0;\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n      for (var j = 0; j < data.length; j++) {\n        var v = data[j][2];\n        if (v > max) {\n          max = v;\n        }\n      }\n    }\n    return max;\n  }\n\n  var jsOptions$2 = jsOptionsFunc(merge(baseOptions, defaultOptions$2), hideLegend$2, setTitle$2, setMin$2, setMax$2, setStacked$2, setXtitle$2, setYtitle$2);\n\n  function prepareDefaultData(chart) {\n    var series = chart.data;\n    var rows = {};\n    var keys = [];\n    var labels = [];\n    var values = [];\n\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n\n      for (var j = 0; j < data.length; j++) {\n        var d = data[j];\n        var key = chart.xtype === \"datetime\" ? d[0].getTime() : d[0];\n        if (!rows[key]) {\n          rows[key] = new Array(series.length);\n          keys.push(key);\n        }\n        rows[key][i] = d[1];\n      }\n    }\n\n    if (chart.xtype === \"datetime\" || chart.xtype === \"number\") {\n      keys.sort(sortByNumber);\n    }\n\n    for (var i$1 = 0; i$1 < series.length; i$1++) {\n      values.push([]);\n    }\n\n    for (var i$2 = 0; i$2 < keys.length; i$2++) {\n      var key$1 = keys[i$2];\n\n      var label = chart.xtype === \"datetime\" ? new Date(key$1) : key$1;\n      labels.push(label);\n\n      var row = rows[key$1];\n      for (var j$1 = 0; j$1 < series.length; j$1++) {\n        var v = row[j$1];\n        // Chart.js doesn't like undefined\n        values[j$1].push(v === undefined ? null : v);\n      }\n    }\n\n    return {\n      labels: labels,\n      values: values\n    };\n  }\n\n  function prepareBubbleData(chart) {\n    var series = chart.data;\n    var values = [];\n    var max = maxR(series);\n\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n      var points = [];\n      for (var j = 0; j < data.length; j++) {\n        var v = data[j];\n        points.push({\n          x: v[0],\n          y: v[1],\n          r: v[2] * 20 / max,\n          // custom attribute, for tooltip\n          v: v[2]\n        });\n      }\n      values.push(points);\n    }\n\n    return {\n      labels: [],\n      values: values\n    };\n  }\n\n  // scatter or numeric line/area\n  function prepareNumberData(chart) {\n    var series = chart.data;\n    var values = [];\n\n    for (var i = 0; i < series.length; i++) {\n      var data = series[i].data;\n\n      data.sort(sortByNumberSeries);\n\n      var points = [];\n      for (var j = 0; j < data.length; j++) {\n        var v = data[j];\n        points.push({\n          x: v[0],\n          y: v[1]\n        });\n      }\n      values.push(points);\n    }\n\n    return {\n      labels: [],\n      values: values\n    };\n  }\n\n  function prepareData(chart, chartType) {\n    if (chartType === \"bubble\") {\n      return prepareBubbleData(chart);\n    } else if (chart.xtype === \"number\" && chartType !== \"bar\" && chartType !== \"column\") {\n      return prepareNumberData(chart);\n    } else {\n      return prepareDefaultData(chart);\n    }\n  }\n\n  function createDataTable(chart, options, chartType) {\n    var ref = prepareData(chart, chartType);\n    var labels = ref.labels;\n    var values = ref.values;\n\n    var series = chart.data;\n    var datasets = [];\n    var colors = chart.options.colors || defaultColors;\n    for (var i = 0; i < series.length; i++) {\n      var s = series[i];\n\n      // use colors for each bar for single series format\n      var color = (void 0);\n      var backgroundColor = (void 0);\n      if (chart.options.colors && chart.singleSeriesFormat && (chartType === \"bar\" || chartType === \"column\") && !s.color && isArray(chart.options.colors) && !isArray(chart.options.colors[0])) {\n        color = colors;\n        backgroundColor = [];\n        for (var j = 0; j < colors.length; j++) {\n          backgroundColor[j] = addOpacity(color[j], 0.5);\n        }\n      } else {\n        color = s.color || colors[i];\n        backgroundColor = chartType !== \"line\" ? addOpacity(color, 0.5) : color;\n      }\n\n      var dataset = {\n        label: s.name || \"\",\n        data: values[i],\n        fill: chartType === \"area\",\n        borderColor: color,\n        backgroundColor: backgroundColor,\n        borderWidth: 2\n      };\n\n      var pointChart = chartType === \"line\" || chartType === \"area\" || chartType === \"scatter\" || chartType === \"bubble\";\n      if (pointChart) {\n        dataset.pointBackgroundColor = color;\n        dataset.pointHoverBackgroundColor = color;\n        dataset.pointHitRadius = 50;\n      }\n\n      if (chartType === \"bubble\") {\n        dataset.pointBackgroundColor = backgroundColor;\n        dataset.pointHoverBackgroundColor = backgroundColor;\n        dataset.pointHoverBorderWidth = 2;\n      }\n\n      if (s.stack) {\n        dataset.stack = s.stack;\n      }\n\n      var curve = seriesOption(chart, s, \"curve\");\n      if (curve === false) {\n        dataset.tension = 0;\n      } else if (pointChart) {\n        dataset.tension = 0.4;\n      }\n\n      var points = seriesOption(chart, s, \"points\");\n      if (points === false) {\n        dataset.pointRadius = 0;\n        dataset.pointHoverRadius = 0;\n      }\n\n      dataset = merge(dataset, chart.options.dataset || {});\n      dataset = merge(dataset, s.library || {});\n      dataset = merge(dataset, s.dataset || {});\n\n      datasets.push(dataset);\n    }\n\n    var xmin = chart.options.xmin;\n    var xmax = chart.options.xmax;\n\n    if (chart.xtype === \"datetime\") {\n      if (notnull(xmin)) {\n        options.scales.x.min = toDate(xmin).getTime();\n      }\n      if (notnull(xmax)) {\n        options.scales.x.max = toDate(xmax).getTime();\n      }\n    } else if (chart.xtype === \"number\") {\n      if (notnull(xmin)) {\n        options.scales.x.min = xmin;\n      }\n      if (notnull(xmax)) {\n        options.scales.x.max = xmax;\n      }\n    }\n\n    if (chart.xtype === \"datetime\") {\n      var timeUnit = calculateTimeUnit(labels);\n\n      // for empty datetime chart\n      if (labels.length === 0) {\n        if (notnull(xmin)) {\n          labels.push(toDate(xmin));\n        }\n        if (notnull(xmax)) {\n          labels.push(toDate(xmax));\n        }\n      }\n\n      if (labels.length > 0) {\n        var minTime = (notnull(xmin) ? toDate(xmin) : labels[0]).getTime();\n        var maxTime = (notnull(xmax) ? toDate(xmax) : labels[0]).getTime();\n\n        for (var i$1 = 1; i$1 < labels.length; i$1++) {\n          var value = labels[i$1].getTime();\n          if (value < minTime) {\n            minTime = value;\n          }\n          if (value > maxTime) {\n            maxTime = value;\n          }\n        }\n\n        var timeDiff = (maxTime - minTime) / (86400 * 1000.0);\n\n        if (!options.scales.x.time.unit) {\n          var step;\n          if (timeUnit === \"year\" || timeDiff > 365 * 10) {\n            options.scales.x.time.unit = \"year\";\n            step = 365;\n          } else if (timeUnit === \"month\" || timeDiff > 30 * 10) {\n            options.scales.x.time.unit = \"month\";\n            step = 30;\n          } else if (timeUnit === \"week\" || timeUnit === \"day\" || timeDiff > 10) {\n            options.scales.x.time.unit = \"day\";\n            step = 1;\n          } else if (timeUnit === \"hour\" || timeDiff > 0.5) {\n            options.scales.x.time.displayFormats = {hour: \"MMM d, h a\"};\n            options.scales.x.time.unit = \"hour\";\n            step = 1 / 24.0;\n          } else if (timeUnit === \"minute\") {\n            options.scales.x.time.displayFormats = {minute: \"h:mm a\"};\n            options.scales.x.time.unit = \"minute\";\n            step = 1 / 24.0 / 60.0;\n          }\n\n          if (step && timeDiff > 0) {\n            // width not available for hidden elements\n            var width = chart.element.offsetWidth;\n            if (width > 0) {\n              var unitStepSize = Math.ceil(timeDiff / step / (width / 100.0));\n              if (timeUnit === \"week\" && step === 1) {\n                unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;\n              }\n              options.scales.x.ticks.stepSize = unitStepSize;\n            }\n          }\n        }\n\n        if (!options.scales.x.time.tooltipFormat) {\n          if (timeUnit === \"year\") {\n            options.scales.x.time.tooltipFormat = \"yyyy\";\n          } else if (timeUnit === \"month\") {\n            options.scales.x.time.tooltipFormat = \"MMM yyyy\";\n          } else if (timeUnit === \"week\" || timeUnit === \"day\") {\n            options.scales.x.time.tooltipFormat = \"PP\";\n          } else if (timeUnit === \"hour\") {\n            options.scales.x.time.tooltipFormat = \"MMM d, h a\";\n          } else if (timeUnit === \"minute\") {\n            options.scales.x.time.tooltipFormat = \"h:mm a\";\n          }\n        }\n      }\n    }\n\n    return {\n      labels: labels,\n      datasets: datasets\n    };\n  }\n\n  var defaultExport$2 = function defaultExport(library) {\n    this.name = \"chartjs\";\n    this.library = library;\n  };\n\n  defaultExport$2.prototype.renderLineChart = function renderLineChart (chart, chartType) {\n    if (!chartType) {\n      chartType = \"line\";\n    }\n\n    var chartOptions = {};\n\n    var options = jsOptions$2(chart, merge(chartOptions, chart.options));\n    setFormatOptions$1(chart, options, chartType);\n\n    var data = createDataTable(chart, options, chartType);\n\n    if (chart.xtype === \"number\") {\n      options.scales.x.type = options.scales.x.type || \"linear\";\n      options.scales.x.position = options.scales.x.position || \"bottom\";\n    } else {\n      options.scales.x.type = chart.xtype === \"string\" ? \"category\" : \"time\";\n    }\n\n    this.drawChart(chart, \"line\", data, options);\n  };\n\n  defaultExport$2.prototype.renderPieChart = function renderPieChart (chart) {\n    var options = merge({}, baseOptions);\n    if (chart.options.donut) {\n      options.cutout = \"50%\";\n    }\n\n    if (\"legend\" in chart.options) {\n      hideLegend$2(options, chart.options.legend);\n    }\n\n    if (chart.options.title) {\n      setTitle$2(options, chart.options.title);\n    }\n\n    options = merge(options, chart.options.library || {});\n    setFormatOptions$1(chart, options, \"pie\");\n\n    var labels = [];\n    var values = [];\n    for (var i = 0; i < chart.data.length; i++) {\n      var point = chart.data[i];\n      labels.push(point[0]);\n      values.push(point[1]);\n    }\n\n    var dataset = {\n      data: values,\n      backgroundColor: chart.options.colors || defaultColors\n    };\n    dataset = merge(dataset, chart.options.dataset || {});\n\n    var data = {\n      labels: labels,\n      datasets: [dataset]\n    };\n\n    this.drawChart(chart, \"pie\", data, options);\n  };\n\n  defaultExport$2.prototype.renderColumnChart = function renderColumnChart (chart, chartType) {\n    var options;\n    if (chartType === \"bar\") {\n      var barOptions = merge(baseOptions, defaultOptions$2);\n      barOptions.indexAxis = \"y\";\n\n      // ensure gridlines have proper orientation\n      barOptions.scales.x.grid.drawOnChartArea = true;\n      barOptions.scales.y.grid.drawOnChartArea = false;\n      delete barOptions.scales.y.ticks.maxTicksLimit;\n\n      options = jsOptionsFunc(barOptions, hideLegend$2, setTitle$2, setBarMin$1, setBarMax$1, setStacked$2, setXtitle$2, setYtitle$2)(chart, chart.options);\n    } else {\n      options = jsOptions$2(chart, chart.options);\n    }\n    setFormatOptions$1(chart, options, chartType);\n    var data = createDataTable(chart, options, \"column\");\n    if (chartType !== \"bar\") {\n      setLabelSize(chart, data, options);\n    }\n    if (!(\"mode\" in options.interaction)) {\n      options.interaction.mode = \"index\";\n    }\n    this.drawChart(chart, \"bar\", data, options);\n  };\n\n  defaultExport$2.prototype.renderAreaChart = function renderAreaChart (chart) {\n    this.renderLineChart(chart, \"area\");\n  };\n\n  defaultExport$2.prototype.renderBarChart = function renderBarChart (chart) {\n    this.renderColumnChart(chart, \"bar\");\n  };\n\n  defaultExport$2.prototype.renderScatterChart = function renderScatterChart (chart, chartType) {\n    chartType = chartType || \"scatter\";\n\n    var options = jsOptions$2(chart, chart.options);\n    setFormatOptions$1(chart, options, chartType);\n\n    if (!(\"showLine\" in options)) {\n      options.showLine = false;\n    }\n\n    var data = createDataTable(chart, options, chartType);\n\n    options.scales.x.type = options.scales.x.type || \"linear\";\n    options.scales.x.position = options.scales.x.position || \"bottom\";\n\n    // prevent grouping hover and tooltips\n    if (!(\"mode\" in options.interaction)) {\n      options.interaction.mode = \"nearest\";\n    }\n\n    this.drawChart(chart, chartType, data, options);\n  };\n\n  defaultExport$2.prototype.renderBubbleChart = function renderBubbleChart (chart) {\n    this.renderScatterChart(chart, \"bubble\");\n  };\n\n  defaultExport$2.prototype.destroy = function destroy (chart) {\n    if (chart.chart) {\n      chart.chart.destroy();\n    }\n  };\n\n  defaultExport$2.prototype.drawChart = function drawChart (chart, type, data, options) {\n    this.destroy(chart);\n    if (chart.destroyed) { return; }\n\n    var chartOptions = {\n      type: type,\n      data: data,\n      options: options\n    };\n\n    if (chart.options.code) {\n      window.console.log(\"new Chart(ctx, \" + JSON.stringify(chartOptions) + \");\");\n    }\n\n    chart.element.innerHTML = \"<canvas></canvas>\";\n    var ctx = chart.element.getElementsByTagName(\"CANVAS\")[0];\n    chart.chart = new this.library(ctx, chartOptions);\n  };\n\n  var defaultOptions$1 = {\n    chart: {},\n    xAxis: {\n      title: {\n        text: null\n      },\n      labels: {\n        style: {\n          fontSize: \"12px\"\n        }\n      }\n    },\n    yAxis: {\n      title: {\n        text: null\n      },\n      labels: {\n        style: {\n          fontSize: \"12px\"\n        }\n      }\n    },\n    title: {\n      text: null\n    },\n    credits: {\n      enabled: false\n    },\n    legend: {\n      borderWidth: 0\n    },\n    tooltip: {\n      style: {\n        fontSize: \"12px\"\n      }\n    },\n    plotOptions: {\n      areaspline: {},\n      area: {},\n      series: {\n        marker: {}\n      }\n    },\n    time: {\n      useUTC: false\n    }\n  };\n\n  function hideLegend$1(options, legend, hideLegend) {\n    if (legend !== undefined) {\n      options.legend.enabled = !!legend;\n      if (legend && legend !== true) {\n        if (legend === \"top\" || legend === \"bottom\") {\n          options.legend.verticalAlign = legend;\n        } else {\n          options.legend.layout = \"vertical\";\n          options.legend.verticalAlign = \"middle\";\n          options.legend.align = legend;\n        }\n      }\n    } else if (hideLegend) {\n      options.legend.enabled = false;\n    }\n  }\n\n  function setTitle$1(options, title) {\n    options.title.text = title;\n  }\n\n  function setMin$1(options, min) {\n    options.yAxis.min = min;\n  }\n\n  function setMax$1(options, max) {\n    options.yAxis.max = max;\n  }\n\n  function setStacked$1(options, stacked) {\n    var stackedValue = stacked ? (stacked === true ? \"normal\" : stacked) : null;\n    options.plotOptions.series.stacking = stackedValue;\n    options.plotOptions.area.stacking = stackedValue;\n    options.plotOptions.areaspline.stacking = stackedValue;\n  }\n\n  function setXtitle$1(options, title) {\n    options.xAxis.title.text = title;\n  }\n\n  function setYtitle$1(options, title) {\n    options.yAxis.title.text = title;\n  }\n\n  var jsOptions$1 = jsOptionsFunc(defaultOptions$1, hideLegend$1, setTitle$1, setMin$1, setMax$1, setStacked$1, setXtitle$1, setYtitle$1);\n\n  function setFormatOptions(chart, options, chartType) {\n    var formatOptions = {\n      prefix: chart.options.prefix,\n      suffix: chart.options.suffix,\n      thousands: chart.options.thousands,\n      decimal: chart.options.decimal,\n      precision: chart.options.precision,\n      round: chart.options.round,\n      zeros: chart.options.zeros\n    };\n\n    // skip when axis is an array (like with min/max)\n    if (chartType !== \"pie\" && !isArray(options.yAxis) && !options.yAxis.labels.formatter) {\n      options.yAxis.labels.formatter = function () {\n        return formatValue(\"\", this.value, formatOptions);\n      };\n    }\n\n    if (!options.tooltip.pointFormatter && !options.tooltip.pointFormat) {\n      options.tooltip.pointFormatter = function () {\n        return '<span style=\"color:' + this.color + '\">\\u25CF</span> ' + formatValue(this.series.name + ': <b>', this.y, formatOptions) + '</b><br/>';\n      };\n    }\n  }\n\n  var defaultExport$1 = function defaultExport(library) {\n    this.name = \"highcharts\";\n    this.library = library;\n  };\n\n  defaultExport$1.prototype.renderLineChart = function renderLineChart (chart, chartType) {\n    chartType = chartType || \"spline\";\n    var chartOptions = {};\n    if (chartType === \"areaspline\") {\n      chartOptions = {\n        plotOptions: {\n          areaspline: {\n            stacking: \"normal\"\n          },\n          area: {\n            stacking: \"normal\"\n          },\n          series: {\n            marker: {\n              enabled: false\n            }\n          }\n        }\n      };\n    }\n\n    if (chart.options.curve === false) {\n      if (chartType === \"areaspline\") {\n        chartType = \"area\";\n      } else if (chartType === \"spline\") {\n        chartType = \"line\";\n      }\n    }\n\n    var options = jsOptions$1(chart, chart.options, chartOptions);\n    if (chart.xtype === \"number\") {\n      options.xAxis.type = options.xAxis.type || \"linear\";\n    } else {\n      options.xAxis.type = chart.xtype === \"string\" ? \"category\" : \"datetime\";\n    }\n    if (!options.chart.type) {\n      options.chart.type = chartType;\n    }\n    setFormatOptions(chart, options, chartType);\n\n    var series = chart.data;\n    for (var i = 0; i < series.length; i++) {\n      series[i].name = series[i].name || \"Value\";\n      var data = series[i].data;\n      if (chart.xtype === \"datetime\") {\n        for (var j = 0; j < data.length; j++) {\n          data[j][0] = data[j][0].getTime();\n        }\n      } else if (chart.xtype === \"number\") {\n        data.sort(sortByNumberSeries);\n      }\n      series[i].marker = {symbol: \"circle\"};\n      if (chart.options.points === false) {\n        series[i].marker.enabled = false;\n      }\n    }\n\n    this.drawChart(chart, series, options);\n  };\n\n  defaultExport$1.prototype.renderScatterChart = function renderScatterChart (chart) {\n    var options = jsOptions$1(chart, chart.options, {});\n    options.chart.type = \"scatter\";\n    this.drawChart(chart, chart.data, options);\n  };\n\n  defaultExport$1.prototype.renderPieChart = function renderPieChart (chart) {\n    var chartOptions = merge(defaultOptions$1, {});\n\n    if (chart.options.colors) {\n      chartOptions.colors = chart.options.colors;\n    }\n    if (chart.options.donut) {\n      chartOptions.plotOptions = {pie: {innerSize: \"50%\"}};\n    }\n\n    if (\"legend\" in chart.options) {\n      hideLegend$1(chartOptions, chart.options.legend);\n    }\n\n    if (chart.options.title) {\n      setTitle$1(chartOptions, chart.options.title);\n    }\n\n    var options = merge(chartOptions, chart.options.library || {});\n    setFormatOptions(chart, options, \"pie\");\n    var series = [{\n      type: \"pie\",\n      name: chart.options.label || \"Value\",\n      data: chart.data\n    }];\n\n    this.drawChart(chart, series, options);\n  };\n\n  defaultExport$1.prototype.renderColumnChart = function renderColumnChart (chart, chartType) {\n    chartType = chartType || \"column\";\n    var series = chart.data;\n    var options = jsOptions$1(chart, chart.options);\n    var rows = [];\n    var categories = [];\n    options.chart.type = chartType;\n    setFormatOptions(chart, options, chartType);\n\n    for (var i = 0; i < series.length; i++) {\n      var s = series[i];\n\n      for (var j = 0; j < s.data.length; j++) {\n        var d = s.data[j];\n        if (!rows[d[0]]) {\n          rows[d[0]] = new Array(series.length);\n          categories.push(d[0]);\n        }\n        rows[d[0]][i] = d[1];\n      }\n    }\n\n    if (chart.xtype === \"number\") {\n      categories.sort(sortByNumber);\n    }\n\n    options.xAxis.categories = categories;\n\n    var newSeries = [];\n    for (var i$1 = 0; i$1 < series.length; i$1++) {\n      var d$1 = [];\n      for (var j$1 = 0; j$1 < categories.length; j$1++) {\n        d$1.push(rows[categories[j$1]][i$1] || 0);\n      }\n\n      var d2 = {\n        name: series[i$1].name || \"Value\",\n        data: d$1\n      };\n      if (series[i$1].stack) {\n        d2.stack = series[i$1].stack;\n      }\n\n      newSeries.push(d2);\n    }\n\n    this.drawChart(chart, newSeries, options);\n  };\n\n  defaultExport$1.prototype.renderBarChart = function renderBarChart (chart) {\n    this.renderColumnChart(chart, \"bar\");\n  };\n\n  defaultExport$1.prototype.renderAreaChart = function renderAreaChart (chart) {\n    this.renderLineChart(chart, \"areaspline\");\n  };\n\n  defaultExport$1.prototype.destroy = function destroy (chart) {\n    if (chart.chart) {\n      chart.chart.destroy();\n    }\n  };\n\n  defaultExport$1.prototype.drawChart = function drawChart (chart, data, options) {\n    this.destroy(chart);\n    if (chart.destroyed) { return; }\n\n    options.chart.renderTo = chart.element.id;\n    options.series = data;\n\n    if (chart.options.code) {\n      window.console.log(\"new Highcharts.Chart(\" + JSON.stringify(options) + \");\");\n    }\n\n    chart.chart = new this.library.Chart(options);\n  };\n\n  var loaded = {};\n  var callbacks = [];\n\n  // Set chart options\n  var defaultOptions = {\n    chartArea: {},\n    fontName: \"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif\",\n    pointSize: 6,\n    legend: {\n      textStyle: {\n        fontSize: 12,\n        color: \"#444\"\n      },\n      alignment: \"center\",\n      position: \"right\"\n    },\n    curveType: \"function\",\n    hAxis: {\n      textStyle: {\n        color: \"#666\",\n        fontSize: 12\n      },\n      titleTextStyle: {},\n      gridlines: {\n        color: \"transparent\"\n      },\n      baselineColor: \"#ccc\",\n      viewWindow: {}\n    },\n    vAxis: {\n      textStyle: {\n        color: \"#666\",\n        fontSize: 12\n      },\n      titleTextStyle: {},\n      baselineColor: \"#ccc\",\n      viewWindow: {}\n    },\n    tooltip: {\n      textStyle: {\n        color: \"#666\",\n        fontSize: 12\n      }\n    }\n  };\n\n  function hideLegend(options, legend, hideLegend) {\n    if (legend !== undefined) {\n      var position;\n      if (!legend) {\n        position = \"none\";\n      } else if (legend === true) {\n        position = \"right\";\n      } else {\n        position = legend;\n      }\n      options.legend.position = position;\n    } else if (hideLegend) {\n      options.legend.position = \"none\";\n    }\n  }\n\n  function setTitle(options, title) {\n    options.title = title;\n    options.titleTextStyle = {color: \"#333\", fontSize: \"20px\"};\n  }\n\n  function setMin(options, min) {\n    options.vAxis.viewWindow.min = min;\n  }\n\n  function setMax(options, max) {\n    options.vAxis.viewWindow.max = max;\n  }\n\n  function setBarMin(options, min) {\n    options.hAxis.viewWindow.min = min;\n  }\n\n  function setBarMax(options, max) {\n    options.hAxis.viewWindow.max = max;\n  }\n\n  function setStacked(options, stacked) {\n    options.isStacked = stacked || false;\n  }\n\n  function setXtitle(options, title) {\n    options.hAxis.title = title;\n    options.hAxis.titleTextStyle.italic = false;\n  }\n\n  function setYtitle(options, title) {\n    options.vAxis.title = title;\n    options.vAxis.titleTextStyle.italic = false;\n  }\n\n  var jsOptions = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);\n\n  function resize(callback) {\n    if (window.attachEvent) {\n      window.attachEvent(\"onresize\", callback);\n    } else if (window.addEventListener) {\n      window.addEventListener(\"resize\", callback, true);\n    }\n    callback();\n  }\n\n  var defaultExport = function defaultExport(library) {\n    this.name = \"google\";\n    this.library = library;\n  };\n\n  defaultExport.prototype.renderLineChart = function renderLineChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var chartOptions = {};\n\n      if (chart.options.curve === false) {\n        chartOptions.curveType = \"none\";\n      }\n\n      if (chart.options.points === false) {\n        chartOptions.pointSize = 0;\n      }\n\n      var options = jsOptions(chart, chart.options, chartOptions);\n      var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n      this$1$1.drawChart(chart, \"LineChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderPieChart = function renderPieChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var chartOptions = {\n        chartArea: {\n          top: \"10%\",\n          height: \"80%\"\n        },\n        legend: {}\n      };\n      if (chart.options.colors) {\n        chartOptions.colors = chart.options.colors;\n      }\n      if (chart.options.donut) {\n        chartOptions.pieHole = 0.5;\n      }\n      if (\"legend\" in chart.options) {\n        hideLegend(chartOptions, chart.options.legend);\n      }\n      if (chart.options.title) {\n        setTitle(chartOptions, chart.options.title);\n      }\n      var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n      var data = new this$1$1.library.visualization.DataTable();\n      data.addColumn(\"string\", \"\");\n      data.addColumn(\"number\", \"Value\");\n      data.addRows(chart.data);\n\n      this$1$1.drawChart(chart, \"PieChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderColumnChart = function renderColumnChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var options = jsOptions(chart, chart.options);\n      var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n      this$1$1.drawChart(chart, \"ColumnChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderBarChart = function renderBarChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var chartOptions = {\n        hAxis: {\n          gridlines: {\n            color: \"#ccc\"\n          }\n        }\n      };\n      var options = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options, chartOptions);\n      var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n      this$1$1.drawChart(chart, \"BarChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderAreaChart = function renderAreaChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var chartOptions = {\n        isStacked: true,\n        pointSize: 0,\n        areaOpacity: 0.5\n      };\n\n      var options = jsOptions(chart, chart.options, chartOptions);\n      var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n      this$1$1.drawChart(chart, \"AreaChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderGeoChart = function renderGeoChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, \"geochart\", function () {\n      var chartOptions = {\n        legend: \"none\",\n        colorAxis: {\n          colors: chart.options.colors || [\"#f6c7b6\", \"#ce502d\"]\n        }\n      };\n      var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n      var data = new this$1$1.library.visualization.DataTable();\n      data.addColumn(\"string\", \"\");\n      data.addColumn(\"number\", chart.options.label || \"Value\");\n      data.addRows(chart.data);\n\n      this$1$1.drawChart(chart, \"GeoChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderScatterChart = function renderScatterChart (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, function () {\n      var chartOptions = {};\n      var options = jsOptions(chart, chart.options, chartOptions);\n\n      var series = chart.data;\n      var rows2 = [];\n      for (var i = 0; i < series.length; i++) {\n        series[i].name = series[i].name || \"Value\";\n        var d = series[i].data;\n        for (var j = 0; j < d.length; j++) {\n          var row = new Array(series.length + 1);\n          row[0] = d[j][0];\n          row[i + 1] = d[j][1];\n          rows2.push(row);\n        }\n      }\n\n      var data = new this$1$1.library.visualization.DataTable();\n      data.addColumn(\"number\", \"\");\n      for (var i$1 = 0; i$1 < series.length; i$1++) {\n        data.addColumn(\"number\", series[i$1].name);\n      }\n      data.addRows(rows2);\n\n      this$1$1.drawChart(chart, \"ScatterChart\", data, options);\n    });\n  };\n\n  defaultExport.prototype.renderTimeline = function renderTimeline (chart) {\n      var this$1$1 = this;\n\n    this.waitForLoaded(chart, \"timeline\", function () {\n      var chartOptions = {\n        legend: \"none\"\n      };\n\n      if (chart.options.colors) {\n        chartOptions.colors = chart.options.colors;\n      }\n      var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n      var data = new this$1$1.library.visualization.DataTable();\n      data.addColumn({type: \"string\", id: \"Name\"});\n      data.addColumn({type: \"date\", id: \"Start\"});\n      data.addColumn({type: \"date\", id: \"End\"});\n      data.addRows(chart.data);\n\n      chart.element.style.lineHeight = \"normal\";\n\n      this$1$1.drawChart(chart, \"Timeline\", data, options);\n    });\n  };\n\n  // TODO remove resize events\n  defaultExport.prototype.destroy = function destroy (chart) {\n    if (chart.chart) {\n      chart.chart.clearChart();\n    }\n  };\n\n  defaultExport.prototype.drawChart = function drawChart (chart, type, data, options) {\n    this.destroy(chart);\n    if (chart.destroyed) { return; }\n\n    if (chart.options.code) {\n      window.console.log(\"var data = new google.visualization.DataTable(\" + data.toJSON() + \");\\nvar chart = new google.visualization.\" + type + \"(element);\\nchart.draw(data, \" + JSON.stringify(options) + \");\");\n    }\n\n    chart.chart = new this.library.visualization[type](chart.element);\n    resize(function () {\n      chart.chart.draw(data, options);\n    });\n  };\n\n  defaultExport.prototype.waitForLoaded = function waitForLoaded (chart, pack, callback) {\n      var this$1$1 = this;\n\n    if (!callback) {\n      callback = pack;\n      pack = \"corechart\";\n    }\n\n    callbacks.push({pack: pack, callback: callback});\n\n    if (loaded[pack]) {\n      this.runCallbacks();\n    } else {\n      loaded[pack] = true;\n\n      // https://groups.google.com/forum/#!topic/google-visualization-api/fMKJcyA2yyI\n      var loadOptions = {\n        packages: [pack],\n        callback: function () { this$1$1.runCallbacks(); }\n      };\n      var config = chart.__config();\n      if (config.language) {\n        loadOptions.language = config.language;\n      }\n      if (pack === \"geochart\" && config.mapsApiKey) {\n        loadOptions.mapsApiKey = config.mapsApiKey;\n      }\n\n      this.library.charts.load(\"current\", loadOptions);\n    }\n  };\n\n  defaultExport.prototype.runCallbacks = function runCallbacks () {\n    for (var i = 0; i < callbacks.length; i++) {\n      var cb = callbacks[i];\n      var call = this.library.visualization && ((cb.pack === \"corechart\" && this.library.visualization.LineChart) || (cb.pack === \"timeline\" && this.library.visualization.Timeline) || (cb.pack === \"geochart\" && this.library.visualization.GeoChart));\n      if (call) {\n        cb.callback();\n        callbacks.splice(i, 1);\n        i--;\n      }\n    }\n  };\n\n  // cant use object as key\n  defaultExport.prototype.createDataTable = function createDataTable (series, columnType) {\n    var rows = [];\n    var sortedLabels = [];\n    for (var i = 0; i < series.length; i++) {\n      var s = series[i];\n      series[i].name = series[i].name || \"Value\";\n\n      for (var j = 0; j < s.data.length; j++) {\n        var d = s.data[j];\n        var key = columnType === \"datetime\" ? d[0].getTime() : d[0];\n        if (!rows[key]) {\n          rows[key] = new Array(series.length);\n          sortedLabels.push(key);\n        }\n        rows[key][i] = d[1];\n      }\n    }\n\n    var rows2 = [];\n    var values = [];\n    for (var j$1 = 0; j$1 < sortedLabels.length; j$1++) {\n      var i$1 = sortedLabels[j$1];\n      var value = (void 0);\n      if (columnType === \"datetime\") {\n        value = new Date(i$1);\n        values.push(value);\n      } else {\n        value = i$1;\n      }\n      rows2.push([value].concat(rows[i$1]));\n    }\n\n    var day = true;\n    if (columnType === \"datetime\") {\n      rows2.sort(sortByTime);\n\n      var timeUnit = calculateTimeUnit(values, true);\n      day = isDay(timeUnit);\n    } else if (columnType === \"number\") {\n      rows2.sort(sortByNumberSeries);\n\n      for (var i$2 = 0; i$2 < rows2.length; i$2++) {\n        rows2[i$2][0] = toStr(rows2[i$2][0]);\n      }\n\n      columnType = \"string\";\n    }\n\n    // create datatable\n    var data = new this.library.visualization.DataTable();\n    columnType = columnType === \"datetime\" && day ? \"date\" : columnType;\n    data.addColumn(columnType, \"\");\n    for (var i$3 = 0; i$3 < series.length; i$3++) {\n      data.addColumn(\"number\", series[i$3].name);\n    }\n    data.addRows(rows2);\n\n    return data;\n  };\n\n  var adapters = [];\n\n  function getAdapterType(library) {\n    if (library) {\n      if (library.product === \"Highcharts\") {\n        return defaultExport$1;\n      } else if (library.charts) {\n        return defaultExport;\n      } else if (isFunction(library)) {\n        return defaultExport$2;\n      }\n    }\n    throw new Error(\"Unknown adapter\");\n  }\n\n  function addAdapter(library) {\n    var adapterType = getAdapterType(library);\n\n    for (var i = 0; i < adapters.length; i++) {\n      if (adapters[i].library === library) {\n        return;\n      }\n    }\n\n    adapters.push(new adapterType(library));\n  }\n\n  function loadAdapters() {\n    if (\"Chart\" in window) {\n      addAdapter(window.Chart);\n    }\n\n    if (\"Highcharts\" in window) {\n      addAdapter(window.Highcharts);\n    }\n\n    if (window.google && window.google.charts) {\n      addAdapter(window.google);\n    }\n  }\n\n  // TODO remove chartType if cross-browser way\n  // to get the name of the chart class\n  function callAdapter(chartType, chart) {\n    var fnName = \"render\" + chartType;\n    var adapterName = chart.options.adapter;\n\n    loadAdapters();\n\n    for (var i = 0; i < adapters.length; i++) {\n      var adapter = adapters[i];\n      if ((!adapterName || adapterName === adapter.name) && isFunction(adapter[fnName])) {\n        chart.adapter = adapter.name;\n        chart.__adapterObject = adapter;\n        return adapter[fnName](chart);\n      }\n    }\n\n    if (adapters.length > 0) {\n      throw new Error(\"No charting library found for \" + chartType);\n    } else {\n      throw new Error(\"No charting libraries found - be sure to include one before your charts\");\n    }\n  }\n\n  var Chartkick = {\n    charts: {},\n    configure: function (options) {\n      for (var key in options) {\n        if (Object.prototype.hasOwnProperty.call(options, key)) {\n          Chartkick.config[key] = options[key];\n        }\n      }\n    },\n    setDefaultOptions: function (opts) {\n      Chartkick.options = opts;\n    },\n    eachChart: function (callback) {\n      for (var chartId in Chartkick.charts) {\n        if (Object.prototype.hasOwnProperty.call(Chartkick.charts, chartId)) {\n          callback(Chartkick.charts[chartId]);\n        }\n      }\n    },\n    destroyAll: function () {\n      for (var chartId in Chartkick.charts) {\n        if (Object.prototype.hasOwnProperty.call(Chartkick.charts, chartId)) {\n          Chartkick.charts[chartId].destroy();\n          delete Chartkick.charts[chartId];\n        }\n      }\n    },\n    config: {},\n    options: {},\n    adapters: adapters,\n    addAdapter: addAdapter,\n    use: function (adapter) {\n      addAdapter(adapter);\n      return Chartkick;\n    }\n  };\n\n  function formatSeriesBubble(data) {\n    var r = [];\n    for (var i = 0; i < data.length; i++) {\n      r.push([toFloat(data[i][0]), toFloat(data[i][1]), toFloat(data[i][2])]);\n    }\n    return r;\n  }\n\n  // casts data to proper type\n  // sorting is left to adapters\n  function formatSeriesData(data, keyType) {\n    if (keyType === \"bubble\") {\n      return formatSeriesBubble(data);\n    }\n\n    var keyFunc;\n    if (keyType === \"number\") {\n      keyFunc = toFloat;\n    } else if (keyType === \"datetime\") {\n      keyFunc = toDate;\n    } else {\n      keyFunc = toStr;\n    }\n\n    var r = [];\n    for (var i = 0; i < data.length; i++) {\n      r.push([keyFunc(data[i][0]), toFloat(data[i][1])]);\n    }\n    return r;\n  }\n\n  function detectXType(series, noDatetime, options) {\n    if (dataEmpty(series)) {\n      if ((options.xmin || options.xmax) && (!options.xmin || isDate(options.xmin)) && (!options.xmax || isDate(options.xmax))) {\n        return \"datetime\";\n      } else {\n        return \"number\";\n      }\n    } else if (detectXTypeWithFunction(series, isNumber)) {\n      return \"number\";\n    } else if (!noDatetime && detectXTypeWithFunction(series, isDate)) {\n      return \"datetime\";\n    } else {\n      return \"string\";\n    }\n  }\n\n  function detectXTypeWithFunction(series, func) {\n    for (var i = 0; i < series.length; i++) {\n      var data = toArr(series[i].data);\n      for (var j = 0; j < data.length; j++) {\n        if (!func(data[j][0])) {\n          return false;\n        }\n      }\n    }\n    return true;\n  }\n\n  // creates a shallow copy of each element of the array\n  // elements are expected to be objects\n  function copySeries(series) {\n    var newSeries = [];\n    for (var i = 0; i < series.length; i++) {\n      var copy = {};\n      for (var j in series[i]) {\n        if (Object.prototype.hasOwnProperty.call(series[i], j)) {\n          copy[j] = series[i][j];\n        }\n      }\n      newSeries.push(copy);\n    }\n    return newSeries;\n  }\n\n  function processSeries(chart, keyType, noDatetime) {\n    var opts = chart.options;\n    var series = chart.rawData;\n\n    // see if one series or multiple\n    chart.singleSeriesFormat = !isArray(series) || !isPlainObject(series[0]);\n    if (chart.singleSeriesFormat) {\n      series = [{name: opts.label, data: series}];\n    }\n\n    // convert to array\n    // must come before dataEmpty check\n    series = copySeries(series);\n    for (var i = 0; i < series.length; i++) {\n      series[i].data = toArr(series[i].data);\n    }\n\n    chart.xtype = keyType || (opts.discrete ? \"string\" : detectXType(series, noDatetime, opts));\n\n    // right format\n    for (var i$1 = 0; i$1 < series.length; i$1++) {\n      series[i$1].data = formatSeriesData(series[i$1].data, chart.xtype);\n    }\n\n    return series;\n  }\n\n  function processSimple(chart) {\n    var perfectData = toArr(chart.rawData);\n    for (var i = 0; i < perfectData.length; i++) {\n      perfectData[i] = [toStr(perfectData[i][0]), toFloat(perfectData[i][1])];\n    }\n    return perfectData;\n  }\n\n  function dataEmpty(data, chartType) {\n    if (chartType === \"PieChart\" || chartType === \"GeoChart\" || chartType === \"Timeline\") {\n      return data.length === 0;\n    } else {\n      for (var i = 0; i < data.length; i++) {\n        if (data[i].data.length > 0) {\n          return false;\n        }\n      }\n      return true;\n    }\n  }\n\n  function addDownloadButton(chart) {\n    var download = chart.options.download;\n    if (download === true) {\n      download = {};\n    } else if (typeof download === \"string\") {\n      download = {filename: download};\n    }\n\n    var link = document.createElement(\"a\");\n    link.download = download.filename || \"chart.png\";\n    link.style.position = \"absolute\";\n    link.style.top = \"20px\";\n    link.style.right = \"20px\";\n    link.style.zIndex = 1000;\n    link.style.lineHeight = \"20px\";\n    link.target = \"_blank\"; // for safari\n\n    var image = document.createElement(\"img\");\n    // icon from Font Awesome, modified to set fill color\n    var svg = \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><!--! Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path fill=\\\"#CCCCCC\\\" d=\\\"M344 240h-56L287.1 152c0-13.25-10.75-24-24-24h-16C234.7 128 223.1 138.8 223.1 152L224 240h-56c-9.531 0-18.16 5.656-22 14.38C142.2 263.1 143.9 273.3 150.4 280.3l88.75 96C243.7 381.2 250.1 384 256.8 384c7.781-.3125 13.25-2.875 17.75-7.844l87.25-96c6.406-7.031 8.031-17.19 4.188-25.88S353.5 240 344 240zM256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 464c-114.7 0-208-93.31-208-208S141.3 48 256 48s208 93.31 208 208S370.7 464 256 464z\\\"/></svg>\";\n    image.src = \"data:image/svg+xml;utf8,\" + (encodeURIComponent(svg));\n    image.alt = \"Download\";\n    image.style.width = \"20px\";\n    image.style.height = \"20px\";\n    image.style.border = \"none\";\n    link.appendChild(image);\n\n    var element = chart.element;\n    element.style.position = \"relative\";\n\n    chart.__downloadAttached = true;\n\n    // mouseenter\n    chart.__enterEvent = element.addEventListener(\"mouseover\", function (e) {\n      var related = e.relatedTarget;\n      // check download option again to ensure it wasn't changed\n      if ((!related || (related !== this && !this.contains(related))) && chart.options.download) {\n        link.href = chart.toImage(download);\n        element.appendChild(link);\n      }\n    });\n\n    // mouseleave\n    chart.__leaveEvent = element.addEventListener(\"mouseout\", function (e) {\n      var related = e.relatedTarget;\n      if (!related || (related !== this && !this.contains(related))) {\n        if (link.parentNode) {\n          link.parentNode.removeChild(link);\n        }\n      }\n    });\n  }\n\n  var pendingRequests = [];\n  var runningRequests = 0;\n  var maxRequests = 4;\n\n  function pushRequest(url, success, error) {\n    pendingRequests.push([url, success, error]);\n    runNext();\n  }\n\n  function runNext() {\n    if (runningRequests < maxRequests) {\n      var request = pendingRequests.shift();\n      if (request) {\n        runningRequests++;\n        getJSON(request[0], request[1], request[2]);\n        runNext();\n      }\n    }\n  }\n\n  function requestComplete() {\n    runningRequests--;\n    runNext();\n  }\n\n  function getJSON(url, success, error) {\n    var xhr = new XMLHttpRequest();\n    xhr.open(\"GET\", url, true);\n    xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n    xhr.onload = function () {\n      requestComplete();\n      if (xhr.status === 200) {\n        success(JSON.parse(xhr.responseText));\n      } else {\n        error(xhr.statusText);\n      }\n    };\n    xhr.send();\n  }\n\n  // helpers\n\n  function setText(element, text) {\n    element.textContent = text;\n  }\n\n  // TODO remove prefix for all messages\n  function chartError(element, message, noPrefix) {\n    if (!noPrefix) {\n      message = \"Error Loading Chart: \" + message;\n    }\n    setText(element, message);\n    element.style.color = \"#ff0000\";\n  }\n\n  function errorCatcher(chart) {\n    try {\n      chart.__render();\n    } catch (err) {\n      chartError(chart.element, err.message);\n      throw err;\n    }\n  }\n\n  function fetchDataSource(chart, dataSource, showLoading) {\n    // only show loading message for urls and callbacks\n    if (showLoading && chart.options.loading && (typeof dataSource === \"string\" || typeof dataSource === \"function\")) {\n      setText(chart.element, chart.options.loading);\n    }\n\n    if (typeof dataSource === \"string\") {\n      pushRequest(dataSource, function (data) {\n        chart.rawData = data;\n        errorCatcher(chart);\n      }, function (message) {\n        chartError(chart.element, message);\n      });\n    } else if (typeof dataSource === \"function\") {\n      try {\n        dataSource(function (data) {\n          chart.rawData = data;\n          errorCatcher(chart);\n        }, function (message) {\n          chartError(chart.element, message, true);\n        });\n      } catch (err) {\n        chartError(chart.element, err, true);\n      }\n    } else {\n      chart.rawData = dataSource;\n      errorCatcher(chart);\n    }\n  }\n\n  function renderChart(chartType, chart) {\n    if (dataEmpty(chart.data, chartType)) {\n      var message = chart.options.empty || (chart.options.messages && chart.options.messages.empty) || \"No data\";\n      setText(chart.element, message);\n    } else {\n      callAdapter(chartType, chart);\n      // TODO add downloadSupported method to adapter\n      if (chart.options.download && !chart.__downloadAttached && chart.adapter === \"chartjs\") {\n        addDownloadButton(chart);\n      }\n    }\n  }\n\n  function getElement(element) {\n    if (typeof element === \"string\") {\n      var elementId = element;\n      element = document.getElementById(element);\n      if (!element) {\n        throw new Error(\"No element with id \" + elementId);\n      }\n    }\n    return element;\n  }\n\n  // define classes\n\n  var Chart = function Chart(element, dataSource, options) {\n    this.element = getElement(element);\n    this.options = merge(Chartkick.options, options || {});\n    this.dataSource = dataSource;\n\n    // TODO handle charts without an id for eachChart and destroyAll\n    if (this.element.id) {\n      Chartkick.charts[this.element.id] = this;\n    }\n\n    fetchDataSource(this, dataSource, true);\n\n    if (this.options.refresh) {\n      this.startRefresh();\n    }\n  };\n\n  Chart.prototype.getElement = function getElement () {\n    return this.element;\n  };\n\n  Chart.prototype.getDataSource = function getDataSource () {\n    return this.dataSource;\n  };\n\n  Chart.prototype.getData = function getData () {\n    return this.data;\n  };\n\n  Chart.prototype.getOptions = function getOptions () {\n    return this.options;\n  };\n\n  Chart.prototype.getChartObject = function getChartObject () {\n    return this.chart;\n  };\n\n  Chart.prototype.getAdapter = function getAdapter () {\n    return this.adapter;\n  };\n\n  Chart.prototype.updateData = function updateData (dataSource, options) {\n    this.dataSource = dataSource;\n    if (options) {\n      this.__updateOptions(options);\n    }\n    fetchDataSource(this, dataSource, true);\n  };\n\n  Chart.prototype.setOptions = function setOptions (options) {\n    this.__updateOptions(options);\n    this.redraw();\n  };\n\n  Chart.prototype.redraw = function redraw () {\n    fetchDataSource(this, this.rawData);\n  };\n\n  Chart.prototype.refreshData = function refreshData () {\n    if (typeof this.dataSource === \"string\") {\n      // prevent browser from caching\n      var sep = this.dataSource.indexOf(\"?\") === -1 ? \"?\" : \"&\";\n      var url = this.dataSource + sep + \"_=\" + (new Date()).getTime();\n      fetchDataSource(this, url);\n    } else if (typeof this.dataSource === \"function\") {\n      fetchDataSource(this, this.dataSource);\n    }\n  };\n\n  Chart.prototype.startRefresh = function startRefresh () {\n      var this$1$1 = this;\n\n    var refresh = this.options.refresh;\n\n    if (refresh && typeof this.dataSource !== \"string\" && typeof this.dataSource !== \"function\") {\n      throw new Error(\"Data source must be a URL or callback for refresh\");\n    }\n\n    if (!this.intervalId) {\n      if (refresh) {\n        this.intervalId = setInterval(function () {\n          this$1$1.refreshData();\n        }, refresh * 1000);\n      } else {\n        throw new Error(\"No refresh interval\");\n      }\n    }\n  };\n\n  Chart.prototype.stopRefresh = function stopRefresh () {\n    if (this.intervalId) {\n      clearInterval(this.intervalId);\n      this.intervalId = null;\n    }\n  };\n\n  Chart.prototype.toImage = function toImage (download) {\n    // TODO move logic to adapter\n    if (this.adapter === \"chartjs\") {\n      if (download && download.background && download.background !== \"transparent\") {\n        // https://stackoverflow.com/questions/30464750/chartjs-line-chart-set-background-color\n        var canvas = this.chart.canvas;\n        var ctx = this.chart.ctx;\n        var tmpCanvas = document.createElement(\"canvas\");\n        var tmpCtx = tmpCanvas.getContext(\"2d\");\n        tmpCanvas.width = ctx.canvas.width;\n        tmpCanvas.height = ctx.canvas.height;\n        tmpCtx.fillStyle = download.background;\n        tmpCtx.fillRect(0, 0, tmpCanvas.width, tmpCanvas.height);\n        tmpCtx.drawImage(canvas, 0, 0);\n        return tmpCanvas.toDataURL(\"image/png\");\n      } else {\n        return this.chart.toBase64Image();\n      }\n    } else {\n      throw new Error(\"Feature only available for Chart.js\");\n    }\n  };\n\n  Chart.prototype.destroy = function destroy () {\n    this.destroyed = true;\n    this.stopRefresh();\n\n    if (this.__adapterObject) {\n      this.__adapterObject.destroy(this);\n    }\n\n    if (this.__enterEvent) {\n      this.element.removeEventListener(\"mouseover\", this.__enterEvent);\n    }\n\n    if (this.__leaveEvent) {\n      this.element.removeEventListener(\"mouseout\", this.__leaveEvent);\n    }\n  };\n\n  Chart.prototype.__updateOptions = function __updateOptions (options) {\n    var updateRefresh = options.refresh && options.refresh !== this.options.refresh;\n    this.options = merge(Chartkick.options, options);\n    if (updateRefresh) {\n      this.stopRefresh();\n      this.startRefresh();\n    }\n  };\n\n  Chart.prototype.__render = function __render () {\n    this.data = this.__processData();\n    renderChart(this.__chartName(), this);\n  };\n\n  Chart.prototype.__config = function __config () {\n    return Chartkick.config;\n  };\n\n  var LineChart = /*@__PURE__*/(function (Chart) {\n    function LineChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) LineChart.__proto__ = Chart;\n    LineChart.prototype = Object.create( Chart && Chart.prototype );\n    LineChart.prototype.constructor = LineChart;\n\n    LineChart.prototype.__processData = function __processData () {\n      return processSeries(this);\n    };\n\n    LineChart.prototype.__chartName = function __chartName () {\n      return \"LineChart\";\n    };\n\n    return LineChart;\n  }(Chart));\n\n  var PieChart = /*@__PURE__*/(function (Chart) {\n    function PieChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) PieChart.__proto__ = Chart;\n    PieChart.prototype = Object.create( Chart && Chart.prototype );\n    PieChart.prototype.constructor = PieChart;\n\n    PieChart.prototype.__processData = function __processData () {\n      return processSimple(this);\n    };\n\n    PieChart.prototype.__chartName = function __chartName () {\n      return \"PieChart\";\n    };\n\n    return PieChart;\n  }(Chart));\n\n  var ColumnChart = /*@__PURE__*/(function (Chart) {\n    function ColumnChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) ColumnChart.__proto__ = Chart;\n    ColumnChart.prototype = Object.create( Chart && Chart.prototype );\n    ColumnChart.prototype.constructor = ColumnChart;\n\n    ColumnChart.prototype.__processData = function __processData () {\n      return processSeries(this, null, true);\n    };\n\n    ColumnChart.prototype.__chartName = function __chartName () {\n      return \"ColumnChart\";\n    };\n\n    return ColumnChart;\n  }(Chart));\n\n  var BarChart = /*@__PURE__*/(function (Chart) {\n    function BarChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) BarChart.__proto__ = Chart;\n    BarChart.prototype = Object.create( Chart && Chart.prototype );\n    BarChart.prototype.constructor = BarChart;\n\n    BarChart.prototype.__processData = function __processData () {\n      return processSeries(this, null, true);\n    };\n\n    BarChart.prototype.__chartName = function __chartName () {\n      return \"BarChart\";\n    };\n\n    return BarChart;\n  }(Chart));\n\n  var AreaChart = /*@__PURE__*/(function (Chart) {\n    function AreaChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) AreaChart.__proto__ = Chart;\n    AreaChart.prototype = Object.create( Chart && Chart.prototype );\n    AreaChart.prototype.constructor = AreaChart;\n\n    AreaChart.prototype.__processData = function __processData () {\n      return processSeries(this);\n    };\n\n    AreaChart.prototype.__chartName = function __chartName () {\n      return \"AreaChart\";\n    };\n\n    return AreaChart;\n  }(Chart));\n\n  var GeoChart = /*@__PURE__*/(function (Chart) {\n    function GeoChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) GeoChart.__proto__ = Chart;\n    GeoChart.prototype = Object.create( Chart && Chart.prototype );\n    GeoChart.prototype.constructor = GeoChart;\n\n    GeoChart.prototype.__processData = function __processData () {\n      return processSimple(this);\n    };\n\n    GeoChart.prototype.__chartName = function __chartName () {\n      return \"GeoChart\";\n    };\n\n    return GeoChart;\n  }(Chart));\n\n  var ScatterChart = /*@__PURE__*/(function (Chart) {\n    function ScatterChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) ScatterChart.__proto__ = Chart;\n    ScatterChart.prototype = Object.create( Chart && Chart.prototype );\n    ScatterChart.prototype.constructor = ScatterChart;\n\n    ScatterChart.prototype.__processData = function __processData () {\n      return processSeries(this, \"number\");\n    };\n\n    ScatterChart.prototype.__chartName = function __chartName () {\n      return \"ScatterChart\";\n    };\n\n    return ScatterChart;\n  }(Chart));\n\n  var BubbleChart = /*@__PURE__*/(function (Chart) {\n    function BubbleChart () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) BubbleChart.__proto__ = Chart;\n    BubbleChart.prototype = Object.create( Chart && Chart.prototype );\n    BubbleChart.prototype.constructor = BubbleChart;\n\n    BubbleChart.prototype.__processData = function __processData () {\n      return processSeries(this, \"bubble\");\n    };\n\n    BubbleChart.prototype.__chartName = function __chartName () {\n      return \"BubbleChart\";\n    };\n\n    return BubbleChart;\n  }(Chart));\n\n  var Timeline = /*@__PURE__*/(function (Chart) {\n    function Timeline () {\n      Chart.apply(this, arguments);\n    }\n\n    if ( Chart ) Timeline.__proto__ = Chart;\n    Timeline.prototype = Object.create( Chart && Chart.prototype );\n    Timeline.prototype.constructor = Timeline;\n\n    Timeline.prototype.__processData = function __processData () {\n      var data = this.rawData;\n      for (var i = 0; i < data.length; i++) {\n        data[i][1] = toDate(data[i][1]);\n        data[i][2] = toDate(data[i][2]);\n      }\n      return data;\n    };\n\n    Timeline.prototype.__chartName = function __chartName () {\n      return \"Timeline\";\n    };\n\n    return Timeline;\n  }(Chart));\n\n  Chartkick.LineChart = LineChart;\n  Chartkick.PieChart = PieChart;\n  Chartkick.ColumnChart = ColumnChart;\n  Chartkick.BarChart = BarChart;\n  Chartkick.AreaChart = AreaChart;\n  Chartkick.GeoChart = GeoChart;\n  Chartkick.ScatterChart = ScatterChart;\n  Chartkick.BubbleChart = BubbleChart;\n  Chartkick.Timeline = Timeline;\n\n  // not ideal, but allows for simpler integration\n  if (typeof window !== \"undefined\" && !window.Chartkick) {\n    window.Chartkick = Chartkick;\n\n    // clean up previous charts before Turbolinks loads new page\n    document.addEventListener(\"turbolinks:before-render\", function () {\n      if (Chartkick.config.autoDestroy !== false) {\n        Chartkick.destroyAll();\n      }\n    });\n\n    // clean up previous charts before Turbo loads new page\n    document.addEventListener(\"turbo:before-render\", function () {\n      if (Chartkick.config.autoDestroy !== false) {\n        Chartkick.destroyAll();\n      }\n    });\n\n    // use setTimeout so charting library can come later in same JS file\n    setTimeout(function () {\n      window.dispatchEvent(new Event(\"chartkick:load\"));\n    }, 0);\n  }\n\n  // backwards compatibility for esm require\n  Chartkick.default = Chartkick;\n\n  return Chartkick;\n\n}));\n"
  },
  {
    "path": "app/assets/javascripts/pghero/jquery.js",
    "content": "/*!\n * jQuery JavaScript Library v3.6.3\n * https://jquery.com/\n *\n * Includes Sizzle.js\n * https://sizzlejs.com/\n *\n * Copyright OpenJS Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2022-12-20T21:28Z\n */\n( function( global, factory ) {\n\n\t\"use strict\";\n\n\tif ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\n\n\t\t// For CommonJS and CommonJS-like environments where a proper `window`\n\t\t// is present, execute the factory and get jQuery.\n\t\t// For environments that do not have a `window` with a `document`\n\t\t// (such as Node.js), expose a factory as module.exports.\n\t\t// This accentuates the need for the creation of a real `window`.\n\t\t// e.g. var jQuery = require(\"jquery\")(window);\n\t\t// See ticket trac-14549 for more info.\n\t\tmodule.exports = global.document ?\n\t\t\tfactory( global, true ) :\n\t\t\tfunction( w ) {\n\t\t\t\tif ( !w.document ) {\n\t\t\t\t\tthrow new Error( \"jQuery requires a window with a document\" );\n\t\t\t\t}\n\t\t\t\treturn factory( w );\n\t\t\t};\n\t} else {\n\t\tfactory( global );\n\t}\n\n// Pass this if window is not defined yet\n} )( typeof window !== \"undefined\" ? window : this, function( window, noGlobal ) {\n\n// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1\n// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode\n// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common\n// enough that all such attempts are guarded in a try block.\n\"use strict\";\n\nvar arr = [];\n\nvar getProto = Object.getPrototypeOf;\n\nvar slice = arr.slice;\n\nvar flat = arr.flat ? function( array ) {\n\treturn arr.flat.call( array );\n} : function( array ) {\n\treturn arr.concat.apply( [], array );\n};\n\n\nvar push = arr.push;\n\nvar indexOf = arr.indexOf;\n\nvar class2type = {};\n\nvar toString = class2type.toString;\n\nvar hasOwn = class2type.hasOwnProperty;\n\nvar fnToString = hasOwn.toString;\n\nvar ObjectFunctionString = fnToString.call( Object );\n\nvar support = {};\n\nvar isFunction = function isFunction( obj ) {\n\n\t\t// Support: Chrome <=57, Firefox <=52\n\t\t// In some browsers, typeof returns \"function\" for HTML <object> elements\n\t\t// (i.e., `typeof document.createElement( \"object\" ) === \"function\"`).\n\t\t// We don't want to classify *any* DOM node as a function.\n\t\t// Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5\n\t\t// Plus for old WebKit, typeof returns \"function\" for HTML collections\n\t\t// (e.g., `typeof document.getElementsByTagName(\"div\") === \"function\"`). (gh-4756)\n\t\treturn typeof obj === \"function\" && typeof obj.nodeType !== \"number\" &&\n\t\t\ttypeof obj.item !== \"function\";\n\t};\n\n\nvar isWindow = function isWindow( obj ) {\n\t\treturn obj != null && obj === obj.window;\n\t};\n\n\nvar document = window.document;\n\n\n\n\tvar preservedScriptAttributes = {\n\t\ttype: true,\n\t\tsrc: true,\n\t\tnonce: true,\n\t\tnoModule: true\n\t};\n\n\tfunction DOMEval( code, node, doc ) {\n\t\tdoc = doc || document;\n\n\t\tvar i, val,\n\t\t\tscript = doc.createElement( \"script\" );\n\n\t\tscript.text = code;\n\t\tif ( node ) {\n\t\t\tfor ( i in preservedScriptAttributes ) {\n\n\t\t\t\t// Support: Firefox 64+, Edge 18+\n\t\t\t\t// Some browsers don't support the \"nonce\" property on scripts.\n\t\t\t\t// On the other hand, just using `getAttribute` is not enough as\n\t\t\t\t// the `nonce` attribute is reset to an empty string whenever it\n\t\t\t\t// becomes browsing-context connected.\n\t\t\t\t// See https://github.com/whatwg/html/issues/2369\n\t\t\t\t// See https://html.spec.whatwg.org/#nonce-attributes\n\t\t\t\t// The `node.getAttribute` check was added for the sake of\n\t\t\t\t// `jQuery.globalEval` so that it can fake a nonce-containing node\n\t\t\t\t// via an object.\n\t\t\t\tval = node[ i ] || node.getAttribute && node.getAttribute( i );\n\t\t\t\tif ( val ) {\n\t\t\t\t\tscript.setAttribute( i, val );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdoc.head.appendChild( script ).parentNode.removeChild( script );\n\t}\n\n\nfunction toType( obj ) {\n\tif ( obj == null ) {\n\t\treturn obj + \"\";\n\t}\n\n\t// Support: Android <=2.3 only (functionish RegExp)\n\treturn typeof obj === \"object\" || typeof obj === \"function\" ?\n\t\tclass2type[ toString.call( obj ) ] || \"object\" :\n\t\ttypeof obj;\n}\n/* global Symbol */\n// Defining this global in .eslintrc.json would create a danger of using the global\n// unguarded in another place, it seems safer to define global only for this module\n\n\n\nvar\n\tversion = \"3.6.3\",\n\n\t// Define a local copy of jQuery\n\tjQuery = function( selector, context ) {\n\n\t\t// The jQuery object is actually just the init constructor 'enhanced'\n\t\t// Need init if jQuery is called (just allow error to be thrown if not included)\n\t\treturn new jQuery.fn.init( selector, context );\n\t};\n\njQuery.fn = jQuery.prototype = {\n\n\t// The current version of jQuery being used\n\tjquery: version,\n\n\tconstructor: jQuery,\n\n\t// The default length of a jQuery object is 0\n\tlength: 0,\n\n\ttoArray: function() {\n\t\treturn slice.call( this );\n\t},\n\n\t// Get the Nth element in the matched element set OR\n\t// Get the whole matched element set as a clean array\n\tget: function( num ) {\n\n\t\t// Return all the elements in a clean array\n\t\tif ( num == null ) {\n\t\t\treturn slice.call( this );\n\t\t}\n\n\t\t// Return just the one element from the set\n\t\treturn num < 0 ? this[ num + this.length ] : this[ num ];\n\t},\n\n\t// Take an array of elements and push it onto the stack\n\t// (returning the new matched element set)\n\tpushStack: function( elems ) {\n\n\t\t// Build a new jQuery matched element set\n\t\tvar ret = jQuery.merge( this.constructor(), elems );\n\n\t\t// Add the old object onto the stack (as a reference)\n\t\tret.prevObject = this;\n\n\t\t// Return the newly-formed element set\n\t\treturn ret;\n\t},\n\n\t// Execute a callback for every element in the matched set.\n\teach: function( callback ) {\n\t\treturn jQuery.each( this, callback );\n\t},\n\n\tmap: function( callback ) {\n\t\treturn this.pushStack( jQuery.map( this, function( elem, i ) {\n\t\t\treturn callback.call( elem, i, elem );\n\t\t} ) );\n\t},\n\n\tslice: function() {\n\t\treturn this.pushStack( slice.apply( this, arguments ) );\n\t},\n\n\tfirst: function() {\n\t\treturn this.eq( 0 );\n\t},\n\n\tlast: function() {\n\t\treturn this.eq( -1 );\n\t},\n\n\teven: function() {\n\t\treturn this.pushStack( jQuery.grep( this, function( _elem, i ) {\n\t\t\treturn ( i + 1 ) % 2;\n\t\t} ) );\n\t},\n\n\todd: function() {\n\t\treturn this.pushStack( jQuery.grep( this, function( _elem, i ) {\n\t\t\treturn i % 2;\n\t\t} ) );\n\t},\n\n\teq: function( i ) {\n\t\tvar len = this.length,\n\t\t\tj = +i + ( i < 0 ? len : 0 );\n\t\treturn this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );\n\t},\n\n\tend: function() {\n\t\treturn this.prevObject || this.constructor();\n\t},\n\n\t// For internal use only.\n\t// Behaves like an Array's method, not like a jQuery method.\n\tpush: push,\n\tsort: arr.sort,\n\tsplice: arr.splice\n};\n\njQuery.extend = jQuery.fn.extend = function() {\n\tvar options, name, src, copy, copyIsArray, clone,\n\t\ttarget = arguments[ 0 ] || {},\n\t\ti = 1,\n\t\tlength = arguments.length,\n\t\tdeep = false;\n\n\t// Handle a deep copy situation\n\tif ( typeof target === \"boolean\" ) {\n\t\tdeep = target;\n\n\t\t// Skip the boolean and the target\n\t\ttarget = arguments[ i ] || {};\n\t\ti++;\n\t}\n\n\t// Handle case when target is a string or something (possible in deep copy)\n\tif ( typeof target !== \"object\" && !isFunction( target ) ) {\n\t\ttarget = {};\n\t}\n\n\t// Extend jQuery itself if only one argument is passed\n\tif ( i === length ) {\n\t\ttarget = this;\n\t\ti--;\n\t}\n\n\tfor ( ; i < length; i++ ) {\n\n\t\t// Only deal with non-null/undefined values\n\t\tif ( ( options = arguments[ i ] ) != null ) {\n\n\t\t\t// Extend the base object\n\t\t\tfor ( name in options ) {\n\t\t\t\tcopy = options[ name ];\n\n\t\t\t\t// Prevent Object.prototype pollution\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif ( name === \"__proto__\" || target === copy ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\tif ( deep && copy && ( jQuery.isPlainObject( copy ) ||\n\t\t\t\t\t( copyIsArray = Array.isArray( copy ) ) ) ) {\n\t\t\t\t\tsrc = target[ name ];\n\n\t\t\t\t\t// Ensure proper type for the source value\n\t\t\t\t\tif ( copyIsArray && !Array.isArray( src ) ) {\n\t\t\t\t\t\tclone = [];\n\t\t\t\t\t} else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {\n\t\t\t\t\t\tclone = {};\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclone = src;\n\t\t\t\t\t}\n\t\t\t\t\tcopyIsArray = false;\n\n\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\ttarget[ name ] = jQuery.extend( deep, clone, copy );\n\n\t\t\t\t// Don't bring in undefined values\n\t\t\t\t} else if ( copy !== undefined ) {\n\t\t\t\t\ttarget[ name ] = copy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n\njQuery.extend( {\n\n\t// Unique for each copy of jQuery on the page\n\texpando: \"jQuery\" + ( version + Math.random() ).replace( /\\D/g, \"\" ),\n\n\t// Assume jQuery is ready without the ready module\n\tisReady: true,\n\n\terror: function( msg ) {\n\t\tthrow new Error( msg );\n\t},\n\n\tnoop: function() {},\n\n\tisPlainObject: function( obj ) {\n\t\tvar proto, Ctor;\n\n\t\t// Detect obvious negatives\n\t\t// Use toString instead of jQuery.type to catch host objects\n\t\tif ( !obj || toString.call( obj ) !== \"[object Object]\" ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tproto = getProto( obj );\n\n\t\t// Objects with no prototype (e.g., `Object.create( null )`) are plain\n\t\tif ( !proto ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Objects with prototype are plain iff they were constructed by a global Object function\n\t\tCtor = hasOwn.call( proto, \"constructor\" ) && proto.constructor;\n\t\treturn typeof Ctor === \"function\" && fnToString.call( Ctor ) === ObjectFunctionString;\n\t},\n\n\tisEmptyObject: function( obj ) {\n\t\tvar name;\n\n\t\tfor ( name in obj ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t},\n\n\t// Evaluates a script in a provided context; falls back to the global one\n\t// if not specified.\n\tglobalEval: function( code, options, doc ) {\n\t\tDOMEval( code, { nonce: options && options.nonce }, doc );\n\t},\n\n\teach: function( obj, callback ) {\n\t\tvar length, i = 0;\n\n\t\tif ( isArrayLike( obj ) ) {\n\t\t\tlength = obj.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i in obj ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn obj;\n\t},\n\n\t// results is for internal usage only\n\tmakeArray: function( arr, results ) {\n\t\tvar ret = results || [];\n\n\t\tif ( arr != null ) {\n\t\t\tif ( isArrayLike( Object( arr ) ) ) {\n\t\t\t\tjQuery.merge( ret,\n\t\t\t\t\ttypeof arr === \"string\" ?\n\t\t\t\t\t\t[ arr ] : arr\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tpush.call( ret, arr );\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\tinArray: function( elem, arr, i ) {\n\t\treturn arr == null ? -1 : indexOf.call( arr, elem, i );\n\t},\n\n\t// Support: Android <=4.0 only, PhantomJS 1 only\n\t// push.apply(_, arraylike) throws on ancient WebKit\n\tmerge: function( first, second ) {\n\t\tvar len = +second.length,\n\t\t\tj = 0,\n\t\t\ti = first.length;\n\n\t\tfor ( ; j < len; j++ ) {\n\t\t\tfirst[ i++ ] = second[ j ];\n\t\t}\n\n\t\tfirst.length = i;\n\n\t\treturn first;\n\t},\n\n\tgrep: function( elems, callback, invert ) {\n\t\tvar callbackInverse,\n\t\t\tmatches = [],\n\t\t\ti = 0,\n\t\t\tlength = elems.length,\n\t\t\tcallbackExpect = !invert;\n\n\t\t// Go through the array, only saving the items\n\t\t// that pass the validator function\n\t\tfor ( ; i < length; i++ ) {\n\t\t\tcallbackInverse = !callback( elems[ i ], i );\n\t\t\tif ( callbackInverse !== callbackExpect ) {\n\t\t\t\tmatches.push( elems[ i ] );\n\t\t\t}\n\t\t}\n\n\t\treturn matches;\n\t},\n\n\t// arg is for internal usage only\n\tmap: function( elems, callback, arg ) {\n\t\tvar length, value,\n\t\t\ti = 0,\n\t\t\tret = [];\n\n\t\t// Go through the array, translating each of the items to their new values\n\t\tif ( isArrayLike( elems ) ) {\n\t\t\tlength = elems.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Go through every key on the object,\n\t\t} else {\n\t\t\tfor ( i in elems ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Flatten any nested arrays\n\t\treturn flat( ret );\n\t},\n\n\t// A global GUID counter for objects\n\tguid: 1,\n\n\t// jQuery.support is not used in Core but other projects attach their\n\t// properties to it so it needs to exist.\n\tsupport: support\n} );\n\nif ( typeof Symbol === \"function\" ) {\n\tjQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];\n}\n\n// Populate the class2type map\njQuery.each( \"Boolean Number String Function Array Date RegExp Object Error Symbol\".split( \" \" ),\n\tfunction( _i, name ) {\n\t\tclass2type[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n\t} );\n\nfunction isArrayLike( obj ) {\n\n\t// Support: real iOS 8.2 only (not reproducible in simulator)\n\t// `in` check used to prevent JIT error (gh-2145)\n\t// hasOwn isn't used here due to false negatives\n\t// regarding Nodelist length in IE\n\tvar length = !!obj && \"length\" in obj && obj.length,\n\t\ttype = toType( obj );\n\n\tif ( isFunction( obj ) || isWindow( obj ) ) {\n\t\treturn false;\n\t}\n\n\treturn type === \"array\" || length === 0 ||\n\t\ttypeof length === \"number\" && length > 0 && ( length - 1 ) in obj;\n}\nvar Sizzle =\n/*!\n * Sizzle CSS Selector Engine v2.3.9\n * https://sizzlejs.com/\n *\n * Copyright JS Foundation and other contributors\n * Released under the MIT license\n * https://js.foundation/\n *\n * Date: 2022-12-19\n */\n( function( window ) {\nvar i,\n\tsupport,\n\tExpr,\n\tgetText,\n\tisXML,\n\ttokenize,\n\tcompile,\n\tselect,\n\toutermostContext,\n\tsortInput,\n\thasDuplicate,\n\n\t// Local document vars\n\tsetDocument,\n\tdocument,\n\tdocElem,\n\tdocumentIsHTML,\n\trbuggyQSA,\n\trbuggyMatches,\n\tmatches,\n\tcontains,\n\n\t// Instance-specific data\n\texpando = \"sizzle\" + 1 * new Date(),\n\tpreferredDoc = window.document,\n\tdirruns = 0,\n\tdone = 0,\n\tclassCache = createCache(),\n\ttokenCache = createCache(),\n\tcompilerCache = createCache(),\n\tnonnativeSelectorCache = createCache(),\n\tsortOrder = function( a, b ) {\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t}\n\t\treturn 0;\n\t},\n\n\t// Instance methods\n\thasOwn = ( {} ).hasOwnProperty,\n\tarr = [],\n\tpop = arr.pop,\n\tpushNative = arr.push,\n\tpush = arr.push,\n\tslice = arr.slice,\n\n\t// Use a stripped-down indexOf as it's faster than native\n\t// https://jsperf.com/thor-indexof-vs-for/5\n\tindexOf = function( list, elem ) {\n\t\tvar i = 0,\n\t\t\tlen = list.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( list[ i ] === elem ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t},\n\n\tbooleans = \"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|\" +\n\t\t\"ismap|loop|multiple|open|readonly|required|scoped\",\n\n\t// Regular expressions\n\n\t// http://www.w3.org/TR/css3-selectors/#whitespace\n\twhitespace = \"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\",\n\n\t// https://www.w3.org/TR/css-syntax-3/#ident-token-diagram\n\tidentifier = \"(?:\\\\\\\\[\\\\da-fA-F]{1,6}\" + whitespace +\n\t\t\"?|\\\\\\\\[^\\\\r\\\\n\\\\f]|[\\\\w-]|[^\\0-\\\\x7f])+\",\n\n\t// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors\n\tattributes = \"\\\\[\" + whitespace + \"*(\" + identifier + \")(?:\" + whitespace +\n\n\t\t// Operator (capture 2)\n\t\t\"*([*^$|!~]?=)\" + whitespace +\n\n\t\t// \"Attribute values must be CSS identifiers [capture 5]\n\t\t// or strings [capture 3 or capture 4]\"\n\t\t\"*(?:'((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\"|(\" + identifier + \"))|)\" +\n\t\twhitespace + \"*\\\\]\",\n\n\tpseudos = \":(\" + identifier + \")(?:\\\\((\" +\n\n\t\t// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:\n\t\t// 1. quoted (capture 3; capture 4 or capture 5)\n\t\t\"('((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\")|\" +\n\n\t\t// 2. simple (capture 6)\n\t\t\"((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|\" + attributes + \")*)|\" +\n\n\t\t// 3. anything else (capture 2)\n\t\t\".*\" +\n\t\t\")\\\\)|)\",\n\n\t// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter\n\trwhitespace = new RegExp( whitespace + \"+\", \"g\" ),\n\trtrim = new RegExp( \"^\" + whitespace + \"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\" +\n\t\twhitespace + \"+$\", \"g\" ),\n\n\trcomma = new RegExp( \"^\" + whitespace + \"*,\" + whitespace + \"*\" ),\n\trcombinators = new RegExp( \"^\" + whitespace + \"*([>+~]|\" + whitespace + \")\" + whitespace +\n\t\t\"*\" ),\n\trdescend = new RegExp( whitespace + \"|>\" ),\n\n\trpseudo = new RegExp( pseudos ),\n\tridentifier = new RegExp( \"^\" + identifier + \"$\" ),\n\n\tmatchExpr = {\n\t\t\"ID\": new RegExp( \"^#(\" + identifier + \")\" ),\n\t\t\"CLASS\": new RegExp( \"^\\\\.(\" + identifier + \")\" ),\n\t\t\"TAG\": new RegExp( \"^(\" + identifier + \"|[*])\" ),\n\t\t\"ATTR\": new RegExp( \"^\" + attributes ),\n\t\t\"PSEUDO\": new RegExp( \"^\" + pseudos ),\n\t\t\"CHILD\": new RegExp( \"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\" +\n\t\t\twhitespace + \"*(even|odd|(([+-]|)(\\\\d*)n|)\" + whitespace + \"*(?:([+-]|)\" +\n\t\t\twhitespace + \"*(\\\\d+)|))\" + whitespace + \"*\\\\)|)\", \"i\" ),\n\t\t\"bool\": new RegExp( \"^(?:\" + booleans + \")$\", \"i\" ),\n\n\t\t// For use in libraries implementing .is()\n\t\t// We use this for POS matching in `select`\n\t\t\"needsContext\": new RegExp( \"^\" + whitespace +\n\t\t\t\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\" + whitespace +\n\t\t\t\"*((?:-\\\\d)?\\\\d*)\" + whitespace + \"*\\\\)|)(?=[^-]|$)\", \"i\" )\n\t},\n\n\trhtml = /HTML$/i,\n\trinputs = /^(?:input|select|textarea|button)$/i,\n\trheader = /^h\\d$/i,\n\n\trnative = /^[^{]+\\{\\s*\\[native \\w/,\n\n\t// Easily-parseable/retrievable ID or TAG or CLASS selectors\n\trquickExpr = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,\n\n\trsibling = /[+~]/,\n\n\t// CSS escapes\n\t// http://www.w3.org/TR/CSS21/syndata.html#escaped-characters\n\trunescape = new RegExp( \"\\\\\\\\[\\\\da-fA-F]{1,6}\" + whitespace + \"?|\\\\\\\\([^\\\\r\\\\n\\\\f])\", \"g\" ),\n\tfunescape = function( escape, nonHex ) {\n\t\tvar high = \"0x\" + escape.slice( 1 ) - 0x10000;\n\n\t\treturn nonHex ?\n\n\t\t\t// Strip the backslash prefix from a non-hex escape sequence\n\t\t\tnonHex :\n\n\t\t\t// Replace a hexadecimal escape sequence with the encoded Unicode code point\n\t\t\t// Support: IE <=11+\n\t\t\t// For values outside the Basic Multilingual Plane (BMP), manually construct a\n\t\t\t// surrogate pair\n\t\t\thigh < 0 ?\n\t\t\t\tString.fromCharCode( high + 0x10000 ) :\n\t\t\t\tString.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );\n\t},\n\n\t// CSS string/identifier serialization\n\t// https://drafts.csswg.org/cssom/#common-serializing-idioms\n\trcssescape = /([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\0-\\x1f\\x7f-\\uFFFF\\w-]/g,\n\tfcssescape = function( ch, asCodePoint ) {\n\t\tif ( asCodePoint ) {\n\n\t\t\t// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER\n\t\t\tif ( ch === \"\\0\" ) {\n\t\t\t\treturn \"\\uFFFD\";\n\t\t\t}\n\n\t\t\t// Control characters and (dependent upon position) numbers get escaped as code points\n\t\t\treturn ch.slice( 0, -1 ) + \"\\\\\" +\n\t\t\t\tch.charCodeAt( ch.length - 1 ).toString( 16 ) + \" \";\n\t\t}\n\n\t\t// Other potentially-special ASCII characters get backslash-escaped\n\t\treturn \"\\\\\" + ch;\n\t},\n\n\t// Used for iframes\n\t// See setDocument()\n\t// Removing the function wrapper causes a \"Permission Denied\"\n\t// error in IE\n\tunloadHandler = function() {\n\t\tsetDocument();\n\t},\n\n\tinDisabledFieldset = addCombinator(\n\t\tfunction( elem ) {\n\t\t\treturn elem.disabled === true && elem.nodeName.toLowerCase() === \"fieldset\";\n\t\t},\n\t\t{ dir: \"parentNode\", next: \"legend\" }\n\t);\n\n// Optimize for push.apply( _, NodeList )\ntry {\n\tpush.apply(\n\t\t( arr = slice.call( preferredDoc.childNodes ) ),\n\t\tpreferredDoc.childNodes\n\t);\n\n\t// Support: Android<4.0\n\t// Detect silently failing push.apply\n\t// eslint-disable-next-line no-unused-expressions\n\tarr[ preferredDoc.childNodes.length ].nodeType;\n} catch ( e ) {\n\tpush = { apply: arr.length ?\n\n\t\t// Leverage slice if possible\n\t\tfunction( target, els ) {\n\t\t\tpushNative.apply( target, slice.call( els ) );\n\t\t} :\n\n\t\t// Support: IE<9\n\t\t// Otherwise append directly\n\t\tfunction( target, els ) {\n\t\t\tvar j = target.length,\n\t\t\t\ti = 0;\n\n\t\t\t// Can't trust NodeList.length\n\t\t\twhile ( ( target[ j++ ] = els[ i++ ] ) ) {}\n\t\t\ttarget.length = j - 1;\n\t\t}\n\t};\n}\n\nfunction Sizzle( selector, context, results, seed ) {\n\tvar m, i, elem, nid, match, groups, newSelector,\n\t\tnewContext = context && context.ownerDocument,\n\n\t\t// nodeType defaults to 9, since context defaults to document\n\t\tnodeType = context ? context.nodeType : 9;\n\n\tresults = results || [];\n\n\t// Return early from calls with invalid selector or context\n\tif ( typeof selector !== \"string\" || !selector ||\n\t\tnodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {\n\n\t\treturn results;\n\t}\n\n\t// Try to shortcut find operations (as opposed to filters) in HTML documents\n\tif ( !seed ) {\n\t\tsetDocument( context );\n\t\tcontext = context || document;\n\n\t\tif ( documentIsHTML ) {\n\n\t\t\t// If the selector is sufficiently simple, try using a \"get*By*\" DOM method\n\t\t\t// (excepting DocumentFragment context, where the methods don't exist)\n\t\t\tif ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {\n\n\t\t\t\t// ID selector\n\t\t\t\tif ( ( m = match[ 1 ] ) ) {\n\n\t\t\t\t\t// Document context\n\t\t\t\t\tif ( nodeType === 9 ) {\n\t\t\t\t\t\tif ( ( elem = context.getElementById( m ) ) ) {\n\n\t\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\t\tif ( elem.id === m ) {\n\t\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t// Element context\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\tif ( newContext && ( elem = newContext.getElementById( m ) ) &&\n\t\t\t\t\t\t\tcontains( context, elem ) &&\n\t\t\t\t\t\t\telem.id === m ) {\n\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t// Type selector\n\t\t\t\t} else if ( match[ 2 ] ) {\n\t\t\t\t\tpush.apply( results, context.getElementsByTagName( selector ) );\n\t\t\t\t\treturn results;\n\n\t\t\t\t// Class selector\n\t\t\t\t} else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&\n\t\t\t\t\tcontext.getElementsByClassName ) {\n\n\t\t\t\t\tpush.apply( results, context.getElementsByClassName( m ) );\n\t\t\t\t\treturn results;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Take advantage of querySelectorAll\n\t\t\tif ( support.qsa &&\n\t\t\t\t!nonnativeSelectorCache[ selector + \" \" ] &&\n\t\t\t\t( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&\n\n\t\t\t\t// Support: IE 8 only\n\t\t\t\t// Exclude object elements\n\t\t\t\t( nodeType !== 1 || context.nodeName.toLowerCase() !== \"object\" ) ) {\n\n\t\t\t\tnewSelector = selector;\n\t\t\t\tnewContext = context;\n\n\t\t\t\t// qSA considers elements outside a scoping root when evaluating child or\n\t\t\t\t// descendant combinators, which is not what we want.\n\t\t\t\t// In such cases, we work around the behavior by prefixing every selector in the\n\t\t\t\t// list with an ID selector referencing the scope context.\n\t\t\t\t// The technique has to be used as well when a leading combinator is used\n\t\t\t\t// as such selectors are not recognized by querySelectorAll.\n\t\t\t\t// Thanks to Andrew Dupont for this technique.\n\t\t\t\tif ( nodeType === 1 &&\n\t\t\t\t\t( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {\n\n\t\t\t\t\t// Expand context for sibling selectors\n\t\t\t\t\tnewContext = rsibling.test( selector ) && testContext( context.parentNode ) ||\n\t\t\t\t\t\tcontext;\n\n\t\t\t\t\t// We can use :scope instead of the ID hack if the browser\n\t\t\t\t\t// supports it & if we're not changing the context.\n\t\t\t\t\tif ( newContext !== context || !support.scope ) {\n\n\t\t\t\t\t\t// Capture the context ID, setting it first if necessary\n\t\t\t\t\t\tif ( ( nid = context.getAttribute( \"id\" ) ) ) {\n\t\t\t\t\t\t\tnid = nid.replace( rcssescape, fcssescape );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontext.setAttribute( \"id\", ( nid = expando ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prefix every selector in the list\n\t\t\t\t\tgroups = tokenize( selector );\n\t\t\t\t\ti = groups.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tgroups[ i ] = ( nid ? \"#\" + nid : \":scope\" ) + \" \" +\n\t\t\t\t\t\t\ttoSelector( groups[ i ] );\n\t\t\t\t\t}\n\t\t\t\t\tnewSelector = groups.join( \",\" );\n\t\t\t\t}\n\n\t\t\t\ttry {\n\n\t\t\t\t\t// `qSA` may not throw for unrecognized parts using forgiving parsing:\n\t\t\t\t\t// https://drafts.csswg.org/selectors/#forgiving-selector\n\t\t\t\t\t// like the `:has()` pseudo-class:\n\t\t\t\t\t// https://drafts.csswg.org/selectors/#relational\n\t\t\t\t\t// `CSS.supports` is still expected to return `false` then:\n\t\t\t\t\t// https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn\n\t\t\t\t\t// https://drafts.csswg.org/css-conditional-4/#dfn-support-selector\n\t\t\t\t\tif ( support.cssSupportsSelector &&\n\n\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t!CSS.supports( \"selector(:is(\" + newSelector + \"))\" ) ) {\n\n\t\t\t\t\t\t// Support: IE 11+\n\t\t\t\t\t\t// Throw to get to the same code path as an error directly in qSA.\n\t\t\t\t\t\t// Note: once we only support browser supporting\n\t\t\t\t\t\t// `CSS.supports('selector(...)')`, we can most likely drop\n\t\t\t\t\t\t// the `try-catch`. IE doesn't implement the API.\n\t\t\t\t\t\tthrow new Error();\n\t\t\t\t\t}\n\n\t\t\t\t\tpush.apply( results,\n\t\t\t\t\t\tnewContext.querySelectorAll( newSelector )\n\t\t\t\t\t);\n\t\t\t\t\treturn results;\n\t\t\t\t} catch ( qsaError ) {\n\t\t\t\t\tnonnativeSelectorCache( selector, true );\n\t\t\t\t} finally {\n\t\t\t\t\tif ( nid === expando ) {\n\t\t\t\t\t\tcontext.removeAttribute( \"id\" );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// All others\n\treturn select( selector.replace( rtrim, \"$1\" ), context, results, seed );\n}\n\n/**\n * Create key-value caches of limited size\n * @returns {function(string, object)} Returns the Object data after storing it on itself with\n *\tproperty name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)\n *\tdeleting the oldest entry\n */\nfunction createCache() {\n\tvar keys = [];\n\n\tfunction cache( key, value ) {\n\n\t\t// Use (key + \" \") to avoid collision with native prototype properties (see Issue #157)\n\t\tif ( keys.push( key + \" \" ) > Expr.cacheLength ) {\n\n\t\t\t// Only keep the most recent entries\n\t\t\tdelete cache[ keys.shift() ];\n\t\t}\n\t\treturn ( cache[ key + \" \" ] = value );\n\t}\n\treturn cache;\n}\n\n/**\n * Mark a function for special use by Sizzle\n * @param {Function} fn The function to mark\n */\nfunction markFunction( fn ) {\n\tfn[ expando ] = true;\n\treturn fn;\n}\n\n/**\n * Support testing using an element\n * @param {Function} fn Passed the created element and returns a boolean result\n */\nfunction assert( fn ) {\n\tvar el = document.createElement( \"fieldset\" );\n\n\ttry {\n\t\treturn !!fn( el );\n\t} catch ( e ) {\n\t\treturn false;\n\t} finally {\n\n\t\t// Remove from its parent by default\n\t\tif ( el.parentNode ) {\n\t\t\tel.parentNode.removeChild( el );\n\t\t}\n\n\t\t// release memory in IE\n\t\tel = null;\n\t}\n}\n\n/**\n * Adds the same handler for all of the specified attrs\n * @param {String} attrs Pipe-separated list of attributes\n * @param {Function} handler The method that will be applied\n */\nfunction addHandle( attrs, handler ) {\n\tvar arr = attrs.split( \"|\" ),\n\t\ti = arr.length;\n\n\twhile ( i-- ) {\n\t\tExpr.attrHandle[ arr[ i ] ] = handler;\n\t}\n}\n\n/**\n * Checks document order of two siblings\n * @param {Element} a\n * @param {Element} b\n * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b\n */\nfunction siblingCheck( a, b ) {\n\tvar cur = b && a,\n\t\tdiff = cur && a.nodeType === 1 && b.nodeType === 1 &&\n\t\t\ta.sourceIndex - b.sourceIndex;\n\n\t// Use IE sourceIndex if available on both nodes\n\tif ( diff ) {\n\t\treturn diff;\n\t}\n\n\t// Check if b follows a\n\tif ( cur ) {\n\t\twhile ( ( cur = cur.nextSibling ) ) {\n\t\t\tif ( cur === b ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a ? 1 : -1;\n}\n\n/**\n * Returns a function to use in pseudos for input types\n * @param {String} type\n */\nfunction createInputPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn name === \"input\" && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for buttons\n * @param {String} type\n */\nfunction createButtonPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn ( name === \"input\" || name === \"button\" ) && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for :enabled/:disabled\n * @param {Boolean} disabled true for :disabled; false for :enabled\n */\nfunction createDisabledPseudo( disabled ) {\n\n\t// Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable\n\treturn function( elem ) {\n\n\t\t// Only certain elements can match :enabled or :disabled\n\t\t// https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled\n\t\t// https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled\n\t\tif ( \"form\" in elem ) {\n\n\t\t\t// Check for inherited disabledness on relevant non-disabled elements:\n\t\t\t// * listed form-associated elements in a disabled fieldset\n\t\t\t//   https://html.spec.whatwg.org/multipage/forms.html#category-listed\n\t\t\t//   https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled\n\t\t\t// * option elements in a disabled optgroup\n\t\t\t//   https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled\n\t\t\t// All such elements have a \"form\" property.\n\t\t\tif ( elem.parentNode && elem.disabled === false ) {\n\n\t\t\t\t// Option elements defer to a parent optgroup if present\n\t\t\t\tif ( \"label\" in elem ) {\n\t\t\t\t\tif ( \"label\" in elem.parentNode ) {\n\t\t\t\t\t\treturn elem.parentNode.disabled === disabled;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn elem.disabled === disabled;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Support: IE 6 - 11\n\t\t\t\t// Use the isDisabled shortcut property to check for disabled fieldset ancestors\n\t\t\t\treturn elem.isDisabled === disabled ||\n\n\t\t\t\t\t// Where there is no isDisabled, check manually\n\t\t\t\t\t/* jshint -W018 */\n\t\t\t\t\telem.isDisabled !== !disabled &&\n\t\t\t\t\tinDisabledFieldset( elem ) === disabled;\n\t\t\t}\n\n\t\t\treturn elem.disabled === disabled;\n\n\t\t// Try to winnow out elements that can't be disabled before trusting the disabled property.\n\t\t// Some victims get caught in our net (label, legend, menu, track), but it shouldn't\n\t\t// even exist on them, let alone have a boolean value.\n\t\t} else if ( \"label\" in elem ) {\n\t\t\treturn elem.disabled === disabled;\n\t\t}\n\n\t\t// Remaining elements are neither :enabled nor :disabled\n\t\treturn false;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for positionals\n * @param {Function} fn\n */\nfunction createPositionalPseudo( fn ) {\n\treturn markFunction( function( argument ) {\n\t\targument = +argument;\n\t\treturn markFunction( function( seed, matches ) {\n\t\t\tvar j,\n\t\t\t\tmatchIndexes = fn( [], seed.length, argument ),\n\t\t\t\ti = matchIndexes.length;\n\n\t\t\t// Match elements found at the specified indexes\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( seed[ ( j = matchIndexes[ i ] ) ] ) {\n\t\t\t\t\tseed[ j ] = !( matches[ j ] = seed[ j ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n}\n\n/**\n * Checks a node for validity as a Sizzle context\n * @param {Element|Object=} context\n * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value\n */\nfunction testContext( context ) {\n\treturn context && typeof context.getElementsByTagName !== \"undefined\" && context;\n}\n\n// Expose support vars for convenience\nsupport = Sizzle.support = {};\n\n/**\n * Detects XML nodes\n * @param {Element|Object} elem An element or a document\n * @returns {Boolean} True iff elem is a non-HTML XML node\n */\nisXML = Sizzle.isXML = function( elem ) {\n\tvar namespace = elem && elem.namespaceURI,\n\t\tdocElem = elem && ( elem.ownerDocument || elem ).documentElement;\n\n\t// Support: IE <=8\n\t// Assume HTML when documentElement doesn't yet exist, such as inside loading iframes\n\t// https://bugs.jquery.com/ticket/4833\n\treturn !rhtml.test( namespace || docElem && docElem.nodeName || \"HTML\" );\n};\n\n/**\n * Sets document-related variables once based on the current document\n * @param {Element|Object} [doc] An element or document object to use to set the document\n * @returns {Object} Returns the current document\n */\nsetDocument = Sizzle.setDocument = function( node ) {\n\tvar hasCompare, subWindow,\n\t\tdoc = node ? node.ownerDocument || node : preferredDoc;\n\n\t// Return early if doc is invalid or already selected\n\t// Support: IE 11+, Edge 17 - 18+\n\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t// two documents; shallow comparisons work.\n\t// eslint-disable-next-line eqeqeq\n\tif ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {\n\t\treturn document;\n\t}\n\n\t// Update global variables\n\tdocument = doc;\n\tdocElem = document.documentElement;\n\tdocumentIsHTML = !isXML( document );\n\n\t// Support: IE 9 - 11+, Edge 12 - 18+\n\t// Accessing iframe documents after unload throws \"permission denied\" errors (jQuery #13936)\n\t// Support: IE 11+, Edge 17 - 18+\n\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t// two documents; shallow comparisons work.\n\t// eslint-disable-next-line eqeqeq\n\tif ( preferredDoc != document &&\n\t\t( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {\n\n\t\t// Support: IE 11, Edge\n\t\tif ( subWindow.addEventListener ) {\n\t\t\tsubWindow.addEventListener( \"unload\", unloadHandler, false );\n\n\t\t// Support: IE 9 - 10 only\n\t\t} else if ( subWindow.attachEvent ) {\n\t\t\tsubWindow.attachEvent( \"onunload\", unloadHandler );\n\t\t}\n\t}\n\n\t// Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,\n\t// Safari 4 - 5 only, Opera <=11.6 - 12.x only\n\t// IE/Edge & older browsers don't support the :scope pseudo-class.\n\t// Support: Safari 6.0 only\n\t// Safari 6.0 supports :scope but it's an alias of :root there.\n\tsupport.scope = assert( function( el ) {\n\t\tdocElem.appendChild( el ).appendChild( document.createElement( \"div\" ) );\n\t\treturn typeof el.querySelectorAll !== \"undefined\" &&\n\t\t\t!el.querySelectorAll( \":scope fieldset div\" ).length;\n\t} );\n\n\t// Support: Chrome 105+, Firefox 104+, Safari 15.4+\n\t// Make sure forgiving mode is not used in `CSS.supports( \"selector(...)\" )`.\n\t//\n\t// `:is()` uses a forgiving selector list as an argument and is widely\n\t// implemented, so it's a good one to test against.\n\tsupport.cssSupportsSelector = assert( function() {\n\t\t/* eslint-disable no-undef */\n\n\t\treturn CSS.supports( \"selector(*)\" ) &&\n\n\t\t\t// Support: Firefox 78-81 only\n\t\t\t// In old Firefox, `:is()` didn't use forgiving parsing. In that case,\n\t\t\t// fail this test as there's no selector to test against that.\n\t\t\t// `CSS.supports` uses unforgiving parsing\n\t\t\tdocument.querySelectorAll( \":is(:jqfake)\" ) &&\n\n\t\t\t// `*` is needed as Safari & newer Chrome implemented something in between\n\t\t\t// for `:has()` - it throws in `qSA` if it only contains an unsupported\n\t\t\t// argument but multiple ones, one of which is supported, are fine.\n\t\t\t// We want to play safe in case `:is()` gets the same treatment.\n\t\t\t!CSS.supports( \"selector(:is(*,:jqfake))\" );\n\n\t\t/* eslint-enable */\n\t} );\n\n\t/* Attributes\n\t---------------------------------------------------------------------- */\n\n\t// Support: IE<8\n\t// Verify that getAttribute really returns attributes and not properties\n\t// (excepting IE8 booleans)\n\tsupport.attributes = assert( function( el ) {\n\t\tel.className = \"i\";\n\t\treturn !el.getAttribute( \"className\" );\n\t} );\n\n\t/* getElement(s)By*\n\t---------------------------------------------------------------------- */\n\n\t// Check if getElementsByTagName(\"*\") returns only elements\n\tsupport.getElementsByTagName = assert( function( el ) {\n\t\tel.appendChild( document.createComment( \"\" ) );\n\t\treturn !el.getElementsByTagName( \"*\" ).length;\n\t} );\n\n\t// Support: IE<9\n\tsupport.getElementsByClassName = rnative.test( document.getElementsByClassName );\n\n\t// Support: IE<10\n\t// Check if getElementById returns elements by name\n\t// The broken getElementById methods don't pick up programmatically-set names,\n\t// so use a roundabout getElementsByName test\n\tsupport.getById = assert( function( el ) {\n\t\tdocElem.appendChild( el ).id = expando;\n\t\treturn !document.getElementsByName || !document.getElementsByName( expando ).length;\n\t} );\n\n\t// ID filter and find\n\tif ( support.getById ) {\n\t\tExpr.filter[ \"ID\" ] = function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn elem.getAttribute( \"id\" ) === attrId;\n\t\t\t};\n\t\t};\n\t\tExpr.find[ \"ID\" ] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== \"undefined\" && documentIsHTML ) {\n\t\t\t\tvar elem = context.getElementById( id );\n\t\t\t\treturn elem ? [ elem ] : [];\n\t\t\t}\n\t\t};\n\t} else {\n\t\tExpr.filter[ \"ID\" ] =  function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\tvar node = typeof elem.getAttributeNode !== \"undefined\" &&\n\t\t\t\t\telem.getAttributeNode( \"id\" );\n\t\t\t\treturn node && node.value === attrId;\n\t\t\t};\n\t\t};\n\n\t\t// Support: IE 6 - 7 only\n\t\t// getElementById is not reliable as a find shortcut\n\t\tExpr.find[ \"ID\" ] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== \"undefined\" && documentIsHTML ) {\n\t\t\t\tvar node, i, elems,\n\t\t\t\t\telem = context.getElementById( id );\n\n\t\t\t\tif ( elem ) {\n\n\t\t\t\t\t// Verify the id attribute\n\t\t\t\t\tnode = elem.getAttributeNode( \"id\" );\n\t\t\t\t\tif ( node && node.value === id ) {\n\t\t\t\t\t\treturn [ elem ];\n\t\t\t\t\t}\n\n\t\t\t\t\t// Fall back on getElementsByName\n\t\t\t\t\telems = context.getElementsByName( id );\n\t\t\t\t\ti = 0;\n\t\t\t\t\twhile ( ( elem = elems[ i++ ] ) ) {\n\t\t\t\t\t\tnode = elem.getAttributeNode( \"id\" );\n\t\t\t\t\t\tif ( node && node.value === id ) {\n\t\t\t\t\t\t\treturn [ elem ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn [];\n\t\t\t}\n\t\t};\n\t}\n\n\t// Tag\n\tExpr.find[ \"TAG\" ] = support.getElementsByTagName ?\n\t\tfunction( tag, context ) {\n\t\t\tif ( typeof context.getElementsByTagName !== \"undefined\" ) {\n\t\t\t\treturn context.getElementsByTagName( tag );\n\n\t\t\t// DocumentFragment nodes don't have gEBTN\n\t\t\t} else if ( support.qsa ) {\n\t\t\t\treturn context.querySelectorAll( tag );\n\t\t\t}\n\t\t} :\n\n\t\tfunction( tag, context ) {\n\t\t\tvar elem,\n\t\t\t\ttmp = [],\n\t\t\t\ti = 0,\n\n\t\t\t\t// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too\n\t\t\t\tresults = context.getElementsByTagName( tag );\n\n\t\t\t// Filter out possible comments\n\t\t\tif ( tag === \"*\" ) {\n\t\t\t\twhile ( ( elem = results[ i++ ] ) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\ttmp.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t// Class\n\tExpr.find[ \"CLASS\" ] = support.getElementsByClassName && function( className, context ) {\n\t\tif ( typeof context.getElementsByClassName !== \"undefined\" && documentIsHTML ) {\n\t\t\treturn context.getElementsByClassName( className );\n\t\t}\n\t};\n\n\t/* QSA/matchesSelector\n\t---------------------------------------------------------------------- */\n\n\t// QSA and matchesSelector support\n\n\t// matchesSelector(:active) reports false when true (IE9/Opera 11.5)\n\trbuggyMatches = [];\n\n\t// qSa(:focus) reports false when true (Chrome 21)\n\t// We allow this because of a bug in IE8/9 that throws an error\n\t// whenever `document.activeElement` is accessed on an iframe\n\t// So, we allow :focus to pass through QSA all the time to avoid the IE error\n\t// See https://bugs.jquery.com/ticket/13378\n\trbuggyQSA = [];\n\n\tif ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {\n\n\t\t// Build QSA regex\n\t\t// Regex strategy adopted from Diego Perini\n\t\tassert( function( el ) {\n\n\t\t\tvar input;\n\n\t\t\t// Select is set to empty string on purpose\n\t\t\t// This is to test IE's treatment of not explicitly\n\t\t\t// setting a boolean content attribute,\n\t\t\t// since its presence should be enough\n\t\t\t// https://bugs.jquery.com/ticket/12359\n\t\t\tdocElem.appendChild( el ).innerHTML = \"<a id='\" + expando + \"'></a>\" +\n\t\t\t\t\"<select id='\" + expando + \"-\\r\\\\' msallowcapture=''>\" +\n\t\t\t\t\"<option selected=''></option></select>\";\n\n\t\t\t// Support: IE8, Opera 11-12.16\n\t\t\t// Nothing should be selected when empty strings follow ^= or $= or *=\n\t\t\t// The test attribute must be unknown in Opera but \"safe\" for WinRT\n\t\t\t// https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section\n\t\t\tif ( el.querySelectorAll( \"[msallowcapture^='']\" ).length ) {\n\t\t\t\trbuggyQSA.push( \"[*^$]=\" + whitespace + \"*(?:''|\\\"\\\")\" );\n\t\t\t}\n\n\t\t\t// Support: IE8\n\t\t\t// Boolean attributes and \"value\" are not treated correctly\n\t\t\tif ( !el.querySelectorAll( \"[selected]\" ).length ) {\n\t\t\t\trbuggyQSA.push( \"\\\\[\" + whitespace + \"*(?:value|\" + booleans + \")\" );\n\t\t\t}\n\n\t\t\t// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+\n\t\t\tif ( !el.querySelectorAll( \"[id~=\" + expando + \"-]\" ).length ) {\n\t\t\t\trbuggyQSA.push( \"~=\" );\n\t\t\t}\n\n\t\t\t// Support: IE 11+, Edge 15 - 18+\n\t\t\t// IE 11/Edge don't find elements on a `[name='']` query in some cases.\n\t\t\t// Adding a temporary attribute to the document before the selection works\n\t\t\t// around the issue.\n\t\t\t// Interestingly, IE 10 & older don't seem to have the issue.\n\t\t\tinput = document.createElement( \"input\" );\n\t\t\tinput.setAttribute( \"name\", \"\" );\n\t\t\tel.appendChild( input );\n\t\t\tif ( !el.querySelectorAll( \"[name='']\" ).length ) {\n\t\t\t\trbuggyQSA.push( \"\\\\[\" + whitespace + \"*name\" + whitespace + \"*=\" +\n\t\t\t\t\twhitespace + \"*(?:''|\\\"\\\")\" );\n\t\t\t}\n\n\t\t\t// Webkit/Opera - :checked should return selected option elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !el.querySelectorAll( \":checked\" ).length ) {\n\t\t\t\trbuggyQSA.push( \":checked\" );\n\t\t\t}\n\n\t\t\t// Support: Safari 8+, iOS 8+\n\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=136851\n\t\t\t// In-page `selector#id sibling-combinator selector` fails\n\t\t\tif ( !el.querySelectorAll( \"a#\" + expando + \"+*\" ).length ) {\n\t\t\t\trbuggyQSA.push( \".#.+[+~]\" );\n\t\t\t}\n\n\t\t\t// Support: Firefox <=3.6 - 5 only\n\t\t\t// Old Firefox doesn't throw on a badly-escaped identifier.\n\t\t\tel.querySelectorAll( \"\\\\\\f\" );\n\t\t\trbuggyQSA.push( \"[\\\\r\\\\n\\\\f]\" );\n\t\t} );\n\n\t\tassert( function( el ) {\n\t\t\tel.innerHTML = \"<a href='' disabled='disabled'></a>\" +\n\t\t\t\t\"<select disabled='disabled'><option/></select>\";\n\n\t\t\t// Support: Windows 8 Native Apps\n\t\t\t// The type and name attributes are restricted during .innerHTML assignment\n\t\t\tvar input = document.createElement( \"input\" );\n\t\t\tinput.setAttribute( \"type\", \"hidden\" );\n\t\t\tel.appendChild( input ).setAttribute( \"name\", \"D\" );\n\n\t\t\t// Support: IE8\n\t\t\t// Enforce case-sensitivity of name attribute\n\t\t\tif ( el.querySelectorAll( \"[name=d]\" ).length ) {\n\t\t\t\trbuggyQSA.push( \"name\" + whitespace + \"*[*^$|!~]?=\" );\n\t\t\t}\n\n\t\t\t// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( el.querySelectorAll( \":enabled\" ).length !== 2 ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Support: IE9-11+\n\t\t\t// IE's :disabled selector does not pick up the children of disabled fieldsets\n\t\t\tdocElem.appendChild( el ).disabled = true;\n\t\t\tif ( el.querySelectorAll( \":disabled\" ).length !== 2 ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Support: Opera 10 - 11 only\n\t\t\t// Opera 10-11 does not throw on post-comma invalid pseudos\n\t\t\tel.querySelectorAll( \"*,:x\" );\n\t\t\trbuggyQSA.push( \",.*:\" );\n\t\t} );\n\t}\n\n\tif ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||\n\t\tdocElem.webkitMatchesSelector ||\n\t\tdocElem.mozMatchesSelector ||\n\t\tdocElem.oMatchesSelector ||\n\t\tdocElem.msMatchesSelector ) ) ) ) {\n\n\t\tassert( function( el ) {\n\n\t\t\t// Check to see if it's possible to do matchesSelector\n\t\t\t// on a disconnected node (IE 9)\n\t\t\tsupport.disconnectedMatch = matches.call( el, \"*\" );\n\n\t\t\t// This should fail with an exception\n\t\t\t// Gecko does not error, returns false instead\n\t\t\tmatches.call( el, \"[s!='']:x\" );\n\t\t\trbuggyMatches.push( \"!=\", pseudos );\n\t\t} );\n\t}\n\n\tif ( !support.cssSupportsSelector ) {\n\n\t\t// Support: Chrome 105+, Safari 15.4+\n\t\t// `:has()` uses a forgiving selector list as an argument so our regular\n\t\t// `try-catch` mechanism fails to catch `:has()` with arguments not supported\n\t\t// natively like `:has(:contains(\"Foo\"))`. Where supported & spec-compliant,\n\t\t// we now use `CSS.supports(\"selector(:is(SELECTOR_TO_BE_TESTED))\")`, but\n\t\t// outside that we mark `:has` as buggy.\n\t\trbuggyQSA.push( \":has\" );\n\t}\n\n\trbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( \"|\" ) );\n\trbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( \"|\" ) );\n\n\t/* Contains\n\t---------------------------------------------------------------------- */\n\thasCompare = rnative.test( docElem.compareDocumentPosition );\n\n\t// Element contains another\n\t// Purposefully self-exclusive\n\t// As in, an element does not contain itself\n\tcontains = hasCompare || rnative.test( docElem.contains ) ?\n\t\tfunction( a, b ) {\n\n\t\t\t// Support: IE <9 only\n\t\t\t// IE doesn't have `contains` on `document` so we need to check for\n\t\t\t// `documentElement` presence.\n\t\t\t// We need to fall back to `a` when `documentElement` is missing\n\t\t\t// as `ownerDocument` of elements within `<template/>` may have\n\t\t\t// a null one - a default behavior of all modern browsers.\n\t\t\tvar adown = a.nodeType === 9 && a.documentElement || a,\n\t\t\t\tbup = b && b.parentNode;\n\t\t\treturn a === bup || !!( bup && bup.nodeType === 1 && (\n\t\t\t\tadown.contains ?\n\t\t\t\t\tadown.contains( bup ) :\n\t\t\t\t\ta.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16\n\t\t\t) );\n\t\t} :\n\t\tfunction( a, b ) {\n\t\t\tif ( b ) {\n\t\t\t\twhile ( ( b = b.parentNode ) ) {\n\t\t\t\t\tif ( b === a ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t/* Sorting\n\t---------------------------------------------------------------------- */\n\n\t// Document order sorting\n\tsortOrder = hasCompare ?\n\tfunction( a, b ) {\n\n\t\t// Flag for duplicate removal\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Sort on method existence if only one input has compareDocumentPosition\n\t\tvar compare = !a.compareDocumentPosition - !b.compareDocumentPosition;\n\t\tif ( compare ) {\n\t\t\treturn compare;\n\t\t}\n\n\t\t// Calculate position if both inputs belong to the same document\n\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t// two documents; shallow comparisons work.\n\t\t// eslint-disable-next-line eqeqeq\n\t\tcompare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?\n\t\t\ta.compareDocumentPosition( b ) :\n\n\t\t\t// Otherwise we know they are disconnected\n\t\t\t1;\n\n\t\t// Disconnected nodes\n\t\tif ( compare & 1 ||\n\t\t\t( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {\n\n\t\t\t// Choose the first element that is related to our preferred document\n\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t// two documents; shallow comparisons work.\n\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\tif ( a == document || a.ownerDocument == preferredDoc &&\n\t\t\t\tcontains( preferredDoc, a ) ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t// two documents; shallow comparisons work.\n\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\tif ( b == document || b.ownerDocument == preferredDoc &&\n\t\t\t\tcontains( preferredDoc, b ) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// Maintain original order\n\t\t\treturn sortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\t\t}\n\n\t\treturn compare & 4 ? -1 : 1;\n\t} :\n\tfunction( a, b ) {\n\n\t\t// Exit early if the nodes are identical\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\taup = a.parentNode,\n\t\t\tbup = b.parentNode,\n\t\t\tap = [ a ],\n\t\t\tbp = [ b ];\n\n\t\t// Parentless nodes are either documents or disconnected\n\t\tif ( !aup || !bup ) {\n\n\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t// two documents; shallow comparisons work.\n\t\t\t/* eslint-disable eqeqeq */\n\t\t\treturn a == document ? -1 :\n\t\t\t\tb == document ? 1 :\n\t\t\t\t/* eslint-enable eqeqeq */\n\t\t\t\taup ? -1 :\n\t\t\t\tbup ? 1 :\n\t\t\t\tsortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\n\t\t// If the nodes are siblings, we can do a quick check\n\t\t} else if ( aup === bup ) {\n\t\t\treturn siblingCheck( a, b );\n\t\t}\n\n\t\t// Otherwise we need full lists of their ancestors for comparison\n\t\tcur = a;\n\t\twhile ( ( cur = cur.parentNode ) ) {\n\t\t\tap.unshift( cur );\n\t\t}\n\t\tcur = b;\n\t\twhile ( ( cur = cur.parentNode ) ) {\n\t\t\tbp.unshift( cur );\n\t\t}\n\n\t\t// Walk down the tree looking for a discrepancy\n\t\twhile ( ap[ i ] === bp[ i ] ) {\n\t\t\ti++;\n\t\t}\n\n\t\treturn i ?\n\n\t\t\t// Do a sibling check if the nodes have a common ancestor\n\t\t\tsiblingCheck( ap[ i ], bp[ i ] ) :\n\n\t\t\t// Otherwise nodes in our document sort first\n\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t// two documents; shallow comparisons work.\n\t\t\t/* eslint-disable eqeqeq */\n\t\t\tap[ i ] == preferredDoc ? -1 :\n\t\t\tbp[ i ] == preferredDoc ? 1 :\n\t\t\t/* eslint-enable eqeqeq */\n\t\t\t0;\n\t};\n\n\treturn document;\n};\n\nSizzle.matches = function( expr, elements ) {\n\treturn Sizzle( expr, null, null, elements );\n};\n\nSizzle.matchesSelector = function( elem, expr ) {\n\tsetDocument( elem );\n\n\tif ( support.matchesSelector && documentIsHTML &&\n\t\t!nonnativeSelectorCache[ expr + \" \" ] &&\n\t\t( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&\n\t\t( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {\n\n\t\ttry {\n\t\t\tvar ret = matches.call( elem, expr );\n\n\t\t\t// IE 9's matchesSelector returns false on disconnected nodes\n\t\t\tif ( ret || support.disconnectedMatch ||\n\n\t\t\t\t// As well, disconnected nodes are said to be in a document\n\t\t\t\t// fragment in IE 9\n\t\t\t\telem.document && elem.document.nodeType !== 11 ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} catch ( e ) {\n\t\t\tnonnativeSelectorCache( expr, true );\n\t\t}\n\t}\n\n\treturn Sizzle( expr, document, null, [ elem ] ).length > 0;\n};\n\nSizzle.contains = function( context, elem ) {\n\n\t// Set document vars if needed\n\t// Support: IE 11+, Edge 17 - 18+\n\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t// two documents; shallow comparisons work.\n\t// eslint-disable-next-line eqeqeq\n\tif ( ( context.ownerDocument || context ) != document ) {\n\t\tsetDocument( context );\n\t}\n\treturn contains( context, elem );\n};\n\nSizzle.attr = function( elem, name ) {\n\n\t// Set document vars if needed\n\t// Support: IE 11+, Edge 17 - 18+\n\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t// two documents; shallow comparisons work.\n\t// eslint-disable-next-line eqeqeq\n\tif ( ( elem.ownerDocument || elem ) != document ) {\n\t\tsetDocument( elem );\n\t}\n\n\tvar fn = Expr.attrHandle[ name.toLowerCase() ],\n\n\t\t// Don't get fooled by Object.prototype properties (jQuery #13807)\n\t\tval = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?\n\t\t\tfn( elem, name, !documentIsHTML ) :\n\t\t\tundefined;\n\n\treturn val !== undefined ?\n\t\tval :\n\t\tsupport.attributes || !documentIsHTML ?\n\t\t\telem.getAttribute( name ) :\n\t\t\t( val = elem.getAttributeNode( name ) ) && val.specified ?\n\t\t\t\tval.value :\n\t\t\t\tnull;\n};\n\nSizzle.escape = function( sel ) {\n\treturn ( sel + \"\" ).replace( rcssescape, fcssescape );\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n/**\n * Document sorting and removing duplicates\n * @param {ArrayLike} results\n */\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {\n\t\twhile ( ( elem = results[ i++ ] ) ) {\n\t\t\tif ( elem === results[ i ] ) {\n\t\t\t\tj = duplicates.push( i );\n\t\t\t}\n\t\t}\n\t\twhile ( j-- ) {\n\t\t\tresults.splice( duplicates[ j ], 1 );\n\t\t}\n\t}\n\n\t// Clear input after sorting to release objects\n\t// See https://github.com/jquery/sizzle/pull/225\n\tsortInput = null;\n\n\treturn results;\n};\n\n/**\n * Utility function for retrieving the text value of an array of DOM nodes\n * @param {Array|Element} elem\n */\ngetText = Sizzle.getText = function( elem ) {\n\tvar node,\n\t\tret = \"\",\n\t\ti = 0,\n\t\tnodeType = elem.nodeType;\n\n\tif ( !nodeType ) {\n\n\t\t// If no nodeType, this is expected to be an array\n\t\twhile ( ( node = elem[ i++ ] ) ) {\n\n\t\t\t// Do not traverse comment nodes\n\t\t\tret += getText( node );\n\t\t}\n\t} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {\n\n\t\t// Use textContent for elements\n\t\t// innerText usage removed for consistency of new lines (jQuery #11153)\n\t\tif ( typeof elem.textContent === \"string\" ) {\n\t\t\treturn elem.textContent;\n\t\t} else {\n\n\t\t\t// Traverse its children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tret += getText( elem );\n\t\t\t}\n\t\t}\n\t} else if ( nodeType === 3 || nodeType === 4 ) {\n\t\treturn elem.nodeValue;\n\t}\n\n\t// Do not include comment or processing instruction nodes\n\n\treturn ret;\n};\n\nExpr = Sizzle.selectors = {\n\n\t// Can be adjusted by the user\n\tcacheLength: 50,\n\n\tcreatePseudo: markFunction,\n\n\tmatch: matchExpr,\n\n\tattrHandle: {},\n\n\tfind: {},\n\n\trelative: {\n\t\t\">\": { dir: \"parentNode\", first: true },\n\t\t\" \": { dir: \"parentNode\" },\n\t\t\"+\": { dir: \"previousSibling\", first: true },\n\t\t\"~\": { dir: \"previousSibling\" }\n\t},\n\n\tpreFilter: {\n\t\t\"ATTR\": function( match ) {\n\t\t\tmatch[ 1 ] = match[ 1 ].replace( runescape, funescape );\n\n\t\t\t// Move the given value to match[3] whether quoted or unquoted\n\t\t\tmatch[ 3 ] = ( match[ 3 ] || match[ 4 ] ||\n\t\t\t\tmatch[ 5 ] || \"\" ).replace( runescape, funescape );\n\n\t\t\tif ( match[ 2 ] === \"~=\" ) {\n\t\t\t\tmatch[ 3 ] = \" \" + match[ 3 ] + \" \";\n\t\t\t}\n\n\t\t\treturn match.slice( 0, 4 );\n\t\t},\n\n\t\t\"CHILD\": function( match ) {\n\n\t\t\t/* matches from matchExpr[\"CHILD\"]\n\t\t\t\t1 type (only|nth|...)\n\t\t\t\t2 what (child|of-type)\n\t\t\t\t3 argument (even|odd|\\d*|\\d*n([+-]\\d+)?|...)\n\t\t\t\t4 xn-component of xn+y argument ([+-]?\\d*n|)\n\t\t\t\t5 sign of xn-component\n\t\t\t\t6 x of xn-component\n\t\t\t\t7 sign of y-component\n\t\t\t\t8 y of y-component\n\t\t\t*/\n\t\t\tmatch[ 1 ] = match[ 1 ].toLowerCase();\n\n\t\t\tif ( match[ 1 ].slice( 0, 3 ) === \"nth\" ) {\n\n\t\t\t\t// nth-* requires argument\n\t\t\t\tif ( !match[ 3 ] ) {\n\t\t\t\t\tSizzle.error( match[ 0 ] );\n\t\t\t\t}\n\n\t\t\t\t// numeric x and y parameters for Expr.filter.CHILD\n\t\t\t\t// remember that false/true cast respectively to 0/1\n\t\t\t\tmatch[ 4 ] = +( match[ 4 ] ?\n\t\t\t\t\tmatch[ 5 ] + ( match[ 6 ] || 1 ) :\n\t\t\t\t\t2 * ( match[ 3 ] === \"even\" || match[ 3 ] === \"odd\" ) );\n\t\t\t\tmatch[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === \"odd\" );\n\n\t\t\t\t// other types prohibit arguments\n\t\t\t} else if ( match[ 3 ] ) {\n\t\t\t\tSizzle.error( match[ 0 ] );\n\t\t\t}\n\n\t\t\treturn match;\n\t\t},\n\n\t\t\"PSEUDO\": function( match ) {\n\t\t\tvar excess,\n\t\t\t\tunquoted = !match[ 6 ] && match[ 2 ];\n\n\t\t\tif ( matchExpr[ \"CHILD\" ].test( match[ 0 ] ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Accept quoted arguments as-is\n\t\t\tif ( match[ 3 ] ) {\n\t\t\t\tmatch[ 2 ] = match[ 4 ] || match[ 5 ] || \"\";\n\n\t\t\t// Strip excess characters from unquoted arguments\n\t\t\t} else if ( unquoted && rpseudo.test( unquoted ) &&\n\n\t\t\t\t// Get excess from tokenize (recursively)\n\t\t\t\t( excess = tokenize( unquoted, true ) ) &&\n\n\t\t\t\t// advance to the next closing parenthesis\n\t\t\t\t( excess = unquoted.indexOf( \")\", unquoted.length - excess ) - unquoted.length ) ) {\n\n\t\t\t\t// excess is a negative index\n\t\t\t\tmatch[ 0 ] = match[ 0 ].slice( 0, excess );\n\t\t\t\tmatch[ 2 ] = unquoted.slice( 0, excess );\n\t\t\t}\n\n\t\t\t// Return only captures needed by the pseudo filter method (type and argument)\n\t\t\treturn match.slice( 0, 3 );\n\t\t}\n\t},\n\n\tfilter: {\n\n\t\t\"TAG\": function( nodeNameSelector ) {\n\t\t\tvar nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn nodeNameSelector === \"*\" ?\n\t\t\t\tfunction() {\n\t\t\t\t\treturn true;\n\t\t\t\t} :\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\n\t\t\t\t};\n\t\t},\n\n\t\t\"CLASS\": function( className ) {\n\t\t\tvar pattern = classCache[ className + \" \" ];\n\n\t\t\treturn pattern ||\n\t\t\t\t( pattern = new RegExp( \"(^|\" + whitespace +\n\t\t\t\t\t\")\" + className + \"(\" + whitespace + \"|$)\" ) ) && classCache(\n\t\t\t\t\t\tclassName, function( elem ) {\n\t\t\t\t\t\t\treturn pattern.test(\n\t\t\t\t\t\t\t\ttypeof elem.className === \"string\" && elem.className ||\n\t\t\t\t\t\t\t\ttypeof elem.getAttribute !== \"undefined\" &&\n\t\t\t\t\t\t\t\t\telem.getAttribute( \"class\" ) ||\n\t\t\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t);\n\t\t\t\t} );\n\t\t},\n\n\t\t\"ATTR\": function( name, operator, check ) {\n\t\t\treturn function( elem ) {\n\t\t\t\tvar result = Sizzle.attr( elem, name );\n\n\t\t\t\tif ( result == null ) {\n\t\t\t\t\treturn operator === \"!=\";\n\t\t\t\t}\n\t\t\t\tif ( !operator ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tresult += \"\";\n\n\t\t\t\t/* eslint-disable max-len */\n\n\t\t\t\treturn operator === \"=\" ? result === check :\n\t\t\t\t\toperator === \"!=\" ? result !== check :\n\t\t\t\t\toperator === \"^=\" ? check && result.indexOf( check ) === 0 :\n\t\t\t\t\toperator === \"*=\" ? check && result.indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"$=\" ? check && result.slice( -check.length ) === check :\n\t\t\t\t\toperator === \"~=\" ? ( \" \" + result.replace( rwhitespace, \" \" ) + \" \" ).indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"|=\" ? result === check || result.slice( 0, check.length + 1 ) === check + \"-\" :\n\t\t\t\t\tfalse;\n\t\t\t\t/* eslint-enable max-len */\n\n\t\t\t};\n\t\t},\n\n\t\t\"CHILD\": function( type, what, _argument, first, last ) {\n\t\t\tvar simple = type.slice( 0, 3 ) !== \"nth\",\n\t\t\t\tforward = type.slice( -4 ) !== \"last\",\n\t\t\t\tofType = what === \"of-type\";\n\n\t\t\treturn first === 1 && last === 0 ?\n\n\t\t\t\t// Shortcut for :nth-*(n)\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn !!elem.parentNode;\n\t\t\t\t} :\n\n\t\t\t\tfunction( elem, _context, xml ) {\n\t\t\t\t\tvar cache, uniqueCache, outerCache, node, nodeIndex, start,\n\t\t\t\t\t\tdir = simple !== forward ? \"nextSibling\" : \"previousSibling\",\n\t\t\t\t\t\tparent = elem.parentNode,\n\t\t\t\t\t\tname = ofType && elem.nodeName.toLowerCase(),\n\t\t\t\t\t\tuseCache = !xml && !ofType,\n\t\t\t\t\t\tdiff = false;\n\n\t\t\t\t\tif ( parent ) {\n\n\t\t\t\t\t\t// :(first|last|only)-(child|of-type)\n\t\t\t\t\t\tif ( simple ) {\n\t\t\t\t\t\t\twhile ( dir ) {\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\twhile ( ( node = node[ dir ] ) ) {\n\t\t\t\t\t\t\t\t\tif ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) {\n\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Reverse direction for :only-* (if we haven't yet done so)\n\t\t\t\t\t\t\t\tstart = dir = type === \"only\" && !start && \"nextSibling\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstart = [ forward ? parent.firstChild : parent.lastChild ];\n\n\t\t\t\t\t\t// non-xml :nth-child(...) stores cache data on `parent`\n\t\t\t\t\t\tif ( forward && useCache ) {\n\n\t\t\t\t\t\t\t// Seek `elem` from a previously-cached index\n\n\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\tnode = parent;\n\t\t\t\t\t\t\touterCache = node[ expando ] || ( node[ expando ] = {} );\n\n\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t( outerCache[ node.uniqueID ] = {} );\n\n\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\tdiff = nodeIndex && cache[ 2 ];\n\t\t\t\t\t\t\tnode = nodeIndex && parent.childNodes[ nodeIndex ];\n\n\t\t\t\t\t\t\twhile ( ( node = ++nodeIndex && node && node[ dir ] ||\n\n\t\t\t\t\t\t\t\t// Fallback to seeking `elem` from the start\n\t\t\t\t\t\t\t\t( diff = nodeIndex = 0 ) || start.pop() ) ) {\n\n\t\t\t\t\t\t\t\t// When found, cache indexes on `parent` and break\n\t\t\t\t\t\t\t\tif ( node.nodeType === 1 && ++diff && node === elem ) {\n\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, nodeIndex, diff ];\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// Use previously-cached element index if available\n\t\t\t\t\t\t\tif ( useCache ) {\n\n\t\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\touterCache = node[ expando ] || ( node[ expando ] = {} );\n\n\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t( outerCache[ node.uniqueID ] = {} );\n\n\t\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\t\tdiff = nodeIndex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// xml :nth-child(...)\n\t\t\t\t\t\t\t// or :nth-last-child(...) or :nth(-last)?-of-type(...)\n\t\t\t\t\t\t\tif ( diff === false ) {\n\n\t\t\t\t\t\t\t\t// Use the same loop as above to seek `elem` from the start\n\t\t\t\t\t\t\t\twhile ( ( node = ++nodeIndex && node && node[ dir ] ||\n\t\t\t\t\t\t\t\t\t( diff = nodeIndex = 0 ) || start.pop() ) ) {\n\n\t\t\t\t\t\t\t\t\tif ( ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) &&\n\t\t\t\t\t\t\t\t\t\t++diff ) {\n\n\t\t\t\t\t\t\t\t\t\t// Cache the index of each encountered element\n\t\t\t\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t\t\t\touterCache = node[ expando ] ||\n\t\t\t\t\t\t\t\t\t\t\t\t( node[ expando ] = {} );\n\n\t\t\t\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t\t\t\t( outerCache[ node.uniqueID ] = {} );\n\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, diff ];\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif ( node === elem ) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Incorporate the offset, then check against cycle size\n\t\t\t\t\t\tdiff -= last;\n\t\t\t\t\t\treturn diff === first || ( diff % first === 0 && diff / first >= 0 );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t},\n\n\t\t\"PSEUDO\": function( pseudo, argument ) {\n\n\t\t\t// pseudo-class names are case-insensitive\n\t\t\t// http://www.w3.org/TR/selectors/#pseudo-classes\n\t\t\t// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters\n\t\t\t// Remember that setFilters inherits from pseudos\n\t\t\tvar args,\n\t\t\t\tfn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||\n\t\t\t\t\tSizzle.error( \"unsupported pseudo: \" + pseudo );\n\n\t\t\t// The user may use createPseudo to indicate that\n\t\t\t// arguments are needed to create the filter function\n\t\t\t// just as Sizzle does\n\t\t\tif ( fn[ expando ] ) {\n\t\t\t\treturn fn( argument );\n\t\t\t}\n\n\t\t\t// But maintain support for old signatures\n\t\t\tif ( fn.length > 1 ) {\n\t\t\t\targs = [ pseudo, pseudo, \"\", argument ];\n\t\t\t\treturn Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?\n\t\t\t\t\tmarkFunction( function( seed, matches ) {\n\t\t\t\t\t\tvar idx,\n\t\t\t\t\t\t\tmatched = fn( seed, argument ),\n\t\t\t\t\t\t\ti = matched.length;\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tidx = indexOf( seed, matched[ i ] );\n\t\t\t\t\t\t\tseed[ idx ] = !( matches[ idx ] = matched[ i ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t} ) :\n\t\t\t\t\tfunction( elem ) {\n\t\t\t\t\t\treturn fn( elem, 0, args );\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn fn;\n\t\t}\n\t},\n\n\tpseudos: {\n\n\t\t// Potentially complex pseudos\n\t\t\"not\": markFunction( function( selector ) {\n\n\t\t\t// Trim the selector passed to compile\n\t\t\t// to avoid treating leading and trailing\n\t\t\t// spaces as combinators\n\t\t\tvar input = [],\n\t\t\t\tresults = [],\n\t\t\t\tmatcher = compile( selector.replace( rtrim, \"$1\" ) );\n\n\t\t\treturn matcher[ expando ] ?\n\t\t\t\tmarkFunction( function( seed, matches, _context, xml ) {\n\t\t\t\t\tvar elem,\n\t\t\t\t\t\tunmatched = matcher( seed, null, xml, [] ),\n\t\t\t\t\t\ti = seed.length;\n\n\t\t\t\t\t// Match elements unmatched by `matcher`\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( ( elem = unmatched[ i ] ) ) {\n\t\t\t\t\t\t\tseed[ i ] = !( matches[ i ] = elem );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} ) :\n\t\t\t\tfunction( elem, _context, xml ) {\n\t\t\t\t\tinput[ 0 ] = elem;\n\t\t\t\t\tmatcher( input, null, xml, results );\n\n\t\t\t\t\t// Don't keep the element (issue #299)\n\t\t\t\t\tinput[ 0 ] = null;\n\t\t\t\t\treturn !results.pop();\n\t\t\t\t};\n\t\t} ),\n\n\t\t\"has\": markFunction( function( selector ) {\n\t\t\treturn function( elem ) {\n\t\t\t\treturn Sizzle( selector, elem ).length > 0;\n\t\t\t};\n\t\t} ),\n\n\t\t\"contains\": markFunction( function( text ) {\n\t\t\ttext = text.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;\n\t\t\t};\n\t\t} ),\n\n\t\t// \"Whether an element is represented by a :lang() selector\n\t\t// is based solely on the element's language value\n\t\t// being equal to the identifier C,\n\t\t// or beginning with the identifier C immediately followed by \"-\".\n\t\t// The matching of C against the element's language value is performed case-insensitively.\n\t\t// The identifier C does not have to be a valid language name.\"\n\t\t// http://www.w3.org/TR/selectors/#lang-pseudo\n\t\t\"lang\": markFunction( function( lang ) {\n\n\t\t\t// lang value must be a valid identifier\n\t\t\tif ( !ridentifier.test( lang || \"\" ) ) {\n\t\t\t\tSizzle.error( \"unsupported lang: \" + lang );\n\t\t\t}\n\t\t\tlang = lang.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn function( elem ) {\n\t\t\t\tvar elemLang;\n\t\t\t\tdo {\n\t\t\t\t\tif ( ( elemLang = documentIsHTML ?\n\t\t\t\t\t\telem.lang :\n\t\t\t\t\t\telem.getAttribute( \"xml:lang\" ) || elem.getAttribute( \"lang\" ) ) ) {\n\n\t\t\t\t\t\telemLang = elemLang.toLowerCase();\n\t\t\t\t\t\treturn elemLang === lang || elemLang.indexOf( lang + \"-\" ) === 0;\n\t\t\t\t\t}\n\t\t\t\t} while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );\n\t\t\t\treturn false;\n\t\t\t};\n\t\t} ),\n\n\t\t// Miscellaneous\n\t\t\"target\": function( elem ) {\n\t\t\tvar hash = window.location && window.location.hash;\n\t\t\treturn hash && hash.slice( 1 ) === elem.id;\n\t\t},\n\n\t\t\"root\": function( elem ) {\n\t\t\treturn elem === docElem;\n\t\t},\n\n\t\t\"focus\": function( elem ) {\n\t\t\treturn elem === document.activeElement &&\n\t\t\t\t( !document.hasFocus || document.hasFocus() ) &&\n\t\t\t\t!!( elem.type || elem.href || ~elem.tabIndex );\n\t\t},\n\n\t\t// Boolean properties\n\t\t\"enabled\": createDisabledPseudo( false ),\n\t\t\"disabled\": createDisabledPseudo( true ),\n\n\t\t\"checked\": function( elem ) {\n\n\t\t\t// In CSS3, :checked should return both checked and selected elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\tvar nodeName = elem.nodeName.toLowerCase();\n\t\t\treturn ( nodeName === \"input\" && !!elem.checked ) ||\n\t\t\t\t( nodeName === \"option\" && !!elem.selected );\n\t\t},\n\n\t\t\"selected\": function( elem ) {\n\n\t\t\t// Accessing this property makes selected-by-default\n\t\t\t// options in Safari work properly\n\t\t\tif ( elem.parentNode ) {\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\telem.parentNode.selectedIndex;\n\t\t\t}\n\n\t\t\treturn elem.selected === true;\n\t\t},\n\n\t\t// Contents\n\t\t\"empty\": function( elem ) {\n\n\t\t\t// http://www.w3.org/TR/selectors/#empty-pseudo\n\t\t\t// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),\n\t\t\t//   but not by others (comment: 8; processing instruction: 7; etc.)\n\t\t\t// nodeType < 6 works because attributes (2) do not appear as children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tif ( elem.nodeType < 6 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\n\t\t\"parent\": function( elem ) {\n\t\t\treturn !Expr.pseudos[ \"empty\" ]( elem );\n\t\t},\n\n\t\t// Element/input types\n\t\t\"header\": function( elem ) {\n\t\t\treturn rheader.test( elem.nodeName );\n\t\t},\n\n\t\t\"input\": function( elem ) {\n\t\t\treturn rinputs.test( elem.nodeName );\n\t\t},\n\n\t\t\"button\": function( elem ) {\n\t\t\tvar name = elem.nodeName.toLowerCase();\n\t\t\treturn name === \"input\" && elem.type === \"button\" || name === \"button\";\n\t\t},\n\n\t\t\"text\": function( elem ) {\n\t\t\tvar attr;\n\t\t\treturn elem.nodeName.toLowerCase() === \"input\" &&\n\t\t\t\telem.type === \"text\" &&\n\n\t\t\t\t// Support: IE <10 only\n\t\t\t\t// New HTML5 attribute values (e.g., \"search\") appear with elem.type === \"text\"\n\t\t\t\t( ( attr = elem.getAttribute( \"type\" ) ) == null ||\n\t\t\t\t\tattr.toLowerCase() === \"text\" );\n\t\t},\n\n\t\t// Position-in-collection\n\t\t\"first\": createPositionalPseudo( function() {\n\t\t\treturn [ 0 ];\n\t\t} ),\n\n\t\t\"last\": createPositionalPseudo( function( _matchIndexes, length ) {\n\t\t\treturn [ length - 1 ];\n\t\t} ),\n\n\t\t\"eq\": createPositionalPseudo( function( _matchIndexes, length, argument ) {\n\t\t\treturn [ argument < 0 ? argument + length : argument ];\n\t\t} ),\n\n\t\t\"even\": createPositionalPseudo( function( matchIndexes, length ) {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t} ),\n\n\t\t\"odd\": createPositionalPseudo( function( matchIndexes, length ) {\n\t\t\tvar i = 1;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t} ),\n\n\t\t\"lt\": createPositionalPseudo( function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ?\n\t\t\t\targument + length :\n\t\t\t\targument > length ?\n\t\t\t\t\tlength :\n\t\t\t\t\targument;\n\t\t\tfor ( ; --i >= 0; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t} ),\n\n\t\t\"gt\": createPositionalPseudo( function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; ++i < length; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t} )\n\t}\n};\n\nExpr.pseudos[ \"nth\" ] = Expr.pseudos[ \"eq\" ];\n\n// Add button/input type pseudos\nfor ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {\n\tExpr.pseudos[ i ] = createInputPseudo( i );\n}\nfor ( i in { submit: true, reset: true } ) {\n\tExpr.pseudos[ i ] = createButtonPseudo( i );\n}\n\n// Easy API for creating new setFilters\nfunction setFilters() {}\nsetFilters.prototype = Expr.filters = Expr.pseudos;\nExpr.setFilters = new setFilters();\n\ntokenize = Sizzle.tokenize = function( selector, parseOnly ) {\n\tvar matched, match, tokens, type,\n\t\tsoFar, groups, preFilters,\n\t\tcached = tokenCache[ selector + \" \" ];\n\n\tif ( cached ) {\n\t\treturn parseOnly ? 0 : cached.slice( 0 );\n\t}\n\n\tsoFar = selector;\n\tgroups = [];\n\tpreFilters = Expr.preFilter;\n\n\twhile ( soFar ) {\n\n\t\t// Comma and first run\n\t\tif ( !matched || ( match = rcomma.exec( soFar ) ) ) {\n\t\t\tif ( match ) {\n\n\t\t\t\t// Don't consume trailing commas as valid\n\t\t\t\tsoFar = soFar.slice( match[ 0 ].length ) || soFar;\n\t\t\t}\n\t\t\tgroups.push( ( tokens = [] ) );\n\t\t}\n\n\t\tmatched = false;\n\n\t\t// Combinators\n\t\tif ( ( match = rcombinators.exec( soFar ) ) ) {\n\t\t\tmatched = match.shift();\n\t\t\ttokens.push( {\n\t\t\t\tvalue: matched,\n\n\t\t\t\t// Cast descendant combinators to space\n\t\t\t\ttype: match[ 0 ].replace( rtrim, \" \" )\n\t\t\t} );\n\t\t\tsoFar = soFar.slice( matched.length );\n\t\t}\n\n\t\t// Filters\n\t\tfor ( type in Expr.filter ) {\n\t\t\tif ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||\n\t\t\t\t( match = preFilters[ type ]( match ) ) ) ) {\n\t\t\t\tmatched = match.shift();\n\t\t\t\ttokens.push( {\n\t\t\t\t\tvalue: matched,\n\t\t\t\t\ttype: type,\n\t\t\t\t\tmatches: match\n\t\t\t\t} );\n\t\t\t\tsoFar = soFar.slice( matched.length );\n\t\t\t}\n\t\t}\n\n\t\tif ( !matched ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Return the length of the invalid excess\n\t// if we're just parsing\n\t// Otherwise, throw an error or return tokens\n\treturn parseOnly ?\n\t\tsoFar.length :\n\t\tsoFar ?\n\t\t\tSizzle.error( selector ) :\n\n\t\t\t// Cache the tokens\n\t\t\ttokenCache( selector, groups ).slice( 0 );\n};\n\nfunction toSelector( tokens ) {\n\tvar i = 0,\n\t\tlen = tokens.length,\n\t\tselector = \"\";\n\tfor ( ; i < len; i++ ) {\n\t\tselector += tokens[ i ].value;\n\t}\n\treturn selector;\n}\n\nfunction addCombinator( matcher, combinator, base ) {\n\tvar dir = combinator.dir,\n\t\tskip = combinator.next,\n\t\tkey = skip || dir,\n\t\tcheckNonElements = base && key === \"parentNode\",\n\t\tdoneName = done++;\n\n\treturn combinator.first ?\n\n\t\t// Check against closest ancestor/preceding element\n\t\tfunction( elem, context, xml ) {\n\t\t\twhile ( ( elem = elem[ dir ] ) ) {\n\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\treturn matcher( elem, context, xml );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t} :\n\n\t\t// Check against all ancestor/preceding elements\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar oldCache, uniqueCache, outerCache,\n\t\t\t\tnewCache = [ dirruns, doneName ];\n\n\t\t\t// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching\n\t\t\tif ( xml ) {\n\t\t\t\twhile ( ( elem = elem[ dir ] ) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\tif ( matcher( elem, context, xml ) ) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile ( ( elem = elem[ dir ] ) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\touterCache = elem[ expando ] || ( elem[ expando ] = {} );\n\n\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\tuniqueCache = outerCache[ elem.uniqueID ] ||\n\t\t\t\t\t\t\t( outerCache[ elem.uniqueID ] = {} );\n\n\t\t\t\t\t\tif ( skip && skip === elem.nodeName.toLowerCase() ) {\n\t\t\t\t\t\t\telem = elem[ dir ] || elem;\n\t\t\t\t\t\t} else if ( ( oldCache = uniqueCache[ key ] ) &&\n\t\t\t\t\t\t\toldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {\n\n\t\t\t\t\t\t\t// Assign to newCache so results back-propagate to previous elements\n\t\t\t\t\t\t\treturn ( newCache[ 2 ] = oldCache[ 2 ] );\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// Reuse newcache so results back-propagate to previous elements\n\t\t\t\t\t\t\tuniqueCache[ key ] = newCache;\n\n\t\t\t\t\t\t\t// A match means we're done; a fail means we have to keep checking\n\t\t\t\t\t\t\tif ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n}\n\nfunction elementMatcher( matchers ) {\n\treturn matchers.length > 1 ?\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar i = matchers.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( !matchers[ i ]( elem, context, xml ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t} :\n\t\tmatchers[ 0 ];\n}\n\nfunction multipleContexts( selector, contexts, results ) {\n\tvar i = 0,\n\t\tlen = contexts.length;\n\tfor ( ; i < len; i++ ) {\n\t\tSizzle( selector, contexts[ i ], results );\n\t}\n\treturn results;\n}\n\nfunction condense( unmatched, map, filter, context, xml ) {\n\tvar elem,\n\t\tnewUnmatched = [],\n\t\ti = 0,\n\t\tlen = unmatched.length,\n\t\tmapped = map != null;\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( ( elem = unmatched[ i ] ) ) {\n\t\t\tif ( !filter || filter( elem, context, xml ) ) {\n\t\t\t\tnewUnmatched.push( elem );\n\t\t\t\tif ( mapped ) {\n\t\t\t\t\tmap.push( i );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn newUnmatched;\n}\n\nfunction setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {\n\tif ( postFilter && !postFilter[ expando ] ) {\n\t\tpostFilter = setMatcher( postFilter );\n\t}\n\tif ( postFinder && !postFinder[ expando ] ) {\n\t\tpostFinder = setMatcher( postFinder, postSelector );\n\t}\n\treturn markFunction( function( seed, results, context, xml ) {\n\t\tvar temp, i, elem,\n\t\t\tpreMap = [],\n\t\t\tpostMap = [],\n\t\t\tpreexisting = results.length,\n\n\t\t\t// Get initial elements from seed or context\n\t\t\telems = seed || multipleContexts(\n\t\t\t\tselector || \"*\",\n\t\t\t\tcontext.nodeType ? [ context ] : context,\n\t\t\t\t[]\n\t\t\t),\n\n\t\t\t// Prefilter to get matcher input, preserving a map for seed-results synchronization\n\t\t\tmatcherIn = preFilter && ( seed || !selector ) ?\n\t\t\t\tcondense( elems, preMap, preFilter, context, xml ) :\n\t\t\t\telems,\n\n\t\t\tmatcherOut = matcher ?\n\n\t\t\t\t// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,\n\t\t\t\tpostFinder || ( seed ? preFilter : preexisting || postFilter ) ?\n\n\t\t\t\t\t// ...intermediate processing is necessary\n\t\t\t\t\t[] :\n\n\t\t\t\t\t// ...otherwise use results directly\n\t\t\t\t\tresults :\n\t\t\t\tmatcherIn;\n\n\t\t// Find primary matches\n\t\tif ( matcher ) {\n\t\t\tmatcher( matcherIn, matcherOut, context, xml );\n\t\t}\n\n\t\t// Apply postFilter\n\t\tif ( postFilter ) {\n\t\t\ttemp = condense( matcherOut, postMap );\n\t\t\tpostFilter( temp, [], context, xml );\n\n\t\t\t// Un-match failing elements by moving them back to matcherIn\n\t\t\ti = temp.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( ( elem = temp[ i ] ) ) {\n\t\t\t\t\tmatcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( seed ) {\n\t\t\tif ( postFinder || preFilter ) {\n\t\t\t\tif ( postFinder ) {\n\n\t\t\t\t\t// Get the final matcherOut by condensing this intermediate into postFinder contexts\n\t\t\t\t\ttemp = [];\n\t\t\t\t\ti = matcherOut.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( ( elem = matcherOut[ i ] ) ) {\n\n\t\t\t\t\t\t\t// Restore matcherIn since elem is not yet a final match\n\t\t\t\t\t\t\ttemp.push( ( matcherIn[ i ] = elem ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpostFinder( null, ( matcherOut = [] ), temp, xml );\n\t\t\t\t}\n\n\t\t\t\t// Move matched elements from seed to results to keep them synchronized\n\t\t\t\ti = matcherOut.length;\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tif ( ( elem = matcherOut[ i ] ) &&\n\t\t\t\t\t\t( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {\n\n\t\t\t\t\t\tseed[ temp ] = !( results[ temp ] = elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Add elements to results, through postFinder if defined\n\t\t} else {\n\t\t\tmatcherOut = condense(\n\t\t\t\tmatcherOut === results ?\n\t\t\t\t\tmatcherOut.splice( preexisting, matcherOut.length ) :\n\t\t\t\t\tmatcherOut\n\t\t\t);\n\t\t\tif ( postFinder ) {\n\t\t\t\tpostFinder( null, results, matcherOut, xml );\n\t\t\t} else {\n\t\t\t\tpush.apply( results, matcherOut );\n\t\t\t}\n\t\t}\n\t} );\n}\n\nfunction matcherFromTokens( tokens ) {\n\tvar checkContext, matcher, j,\n\t\tlen = tokens.length,\n\t\tleadingRelative = Expr.relative[ tokens[ 0 ].type ],\n\t\timplicitRelative = leadingRelative || Expr.relative[ \" \" ],\n\t\ti = leadingRelative ? 1 : 0,\n\n\t\t// The foundational matcher ensures that elements are reachable from top-level context(s)\n\t\tmatchContext = addCombinator( function( elem ) {\n\t\t\treturn elem === checkContext;\n\t\t}, implicitRelative, true ),\n\t\tmatchAnyContext = addCombinator( function( elem ) {\n\t\t\treturn indexOf( checkContext, elem ) > -1;\n\t\t}, implicitRelative, true ),\n\t\tmatchers = [ function( elem, context, xml ) {\n\t\t\tvar ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (\n\t\t\t\t( checkContext = context ).nodeType ?\n\t\t\t\t\tmatchContext( elem, context, xml ) :\n\t\t\t\t\tmatchAnyContext( elem, context, xml ) );\n\n\t\t\t// Avoid hanging onto element (issue #299)\n\t\t\tcheckContext = null;\n\t\t\treturn ret;\n\t\t} ];\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {\n\t\t\tmatchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];\n\t\t} else {\n\t\t\tmatcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );\n\n\t\t\t// Return special upon seeing a positional matcher\n\t\t\tif ( matcher[ expando ] ) {\n\n\t\t\t\t// Find the next relative operator (if any) for proper handling\n\t\t\t\tj = ++i;\n\t\t\t\tfor ( ; j < len; j++ ) {\n\t\t\t\t\tif ( Expr.relative[ tokens[ j ].type ] ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn setMatcher(\n\t\t\t\t\ti > 1 && elementMatcher( matchers ),\n\t\t\t\t\ti > 1 && toSelector(\n\n\t\t\t\t\t// If the preceding token was a descendant combinator, insert an implicit any-element `*`\n\t\t\t\t\ttokens\n\t\t\t\t\t\t.slice( 0, i - 1 )\n\t\t\t\t\t\t.concat( { value: tokens[ i - 2 ].type === \" \" ? \"*\" : \"\" } )\n\t\t\t\t\t).replace( rtrim, \"$1\" ),\n\t\t\t\t\tmatcher,\n\t\t\t\t\ti < j && matcherFromTokens( tokens.slice( i, j ) ),\n\t\t\t\t\tj < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),\n\t\t\t\t\tj < len && toSelector( tokens )\n\t\t\t\t);\n\t\t\t}\n\t\t\tmatchers.push( matcher );\n\t\t}\n\t}\n\n\treturn elementMatcher( matchers );\n}\n\nfunction matcherFromGroupMatchers( elementMatchers, setMatchers ) {\n\tvar bySet = setMatchers.length > 0,\n\t\tbyElement = elementMatchers.length > 0,\n\t\tsuperMatcher = function( seed, context, xml, results, outermost ) {\n\t\t\tvar elem, j, matcher,\n\t\t\t\tmatchedCount = 0,\n\t\t\t\ti = \"0\",\n\t\t\t\tunmatched = seed && [],\n\t\t\t\tsetMatched = [],\n\t\t\t\tcontextBackup = outermostContext,\n\n\t\t\t\t// We must always have either seed elements or outermost context\n\t\t\t\telems = seed || byElement && Expr.find[ \"TAG\" ]( \"*\", outermost ),\n\n\t\t\t\t// Use integer dirruns iff this is the outermost matcher\n\t\t\t\tdirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),\n\t\t\t\tlen = elems.length;\n\n\t\t\tif ( outermost ) {\n\n\t\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t\t// two documents; shallow comparisons work.\n\t\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\t\toutermostContext = context == document || context || outermost;\n\t\t\t}\n\n\t\t\t// Add elements passing elementMatchers directly to results\n\t\t\t// Support: IE<9, Safari\n\t\t\t// Tolerate NodeList properties (IE: \"length\"; Safari: <number>) matching elements by id\n\t\t\tfor ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {\n\t\t\t\tif ( byElement && elem ) {\n\t\t\t\t\tj = 0;\n\n\t\t\t\t\t// Support: IE 11+, Edge 17 - 18+\n\t\t\t\t\t// IE/Edge sometimes throw a \"Permission denied\" error when strict-comparing\n\t\t\t\t\t// two documents; shallow comparisons work.\n\t\t\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\t\t\tif ( !context && elem.ownerDocument != document ) {\n\t\t\t\t\t\tsetDocument( elem );\n\t\t\t\t\t\txml = !documentIsHTML;\n\t\t\t\t\t}\n\t\t\t\t\twhile ( ( matcher = elementMatchers[ j++ ] ) ) {\n\t\t\t\t\t\tif ( matcher( elem, context || document, xml ) ) {\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( outermost ) {\n\t\t\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Track unmatched elements for set filters\n\t\t\t\tif ( bySet ) {\n\n\t\t\t\t\t// They will have gone through all possible matchers\n\t\t\t\t\tif ( ( elem = !matcher && elem ) ) {\n\t\t\t\t\t\tmatchedCount--;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Lengthen the array for every element, matched or not\n\t\t\t\t\tif ( seed ) {\n\t\t\t\t\t\tunmatched.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// `i` is now the count of elements visited above, and adding it to `matchedCount`\n\t\t\t// makes the latter nonnegative.\n\t\t\tmatchedCount += i;\n\n\t\t\t// Apply set filters to unmatched elements\n\t\t\t// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`\n\t\t\t// equals `i`), unless we didn't visit _any_ elements in the above loop because we have\n\t\t\t// no element matchers and no seed.\n\t\t\t// Incrementing an initially-string \"0\" `i` allows `i` to remain a string only in that\n\t\t\t// case, which will result in a \"00\" `matchedCount` that differs from `i` but is also\n\t\t\t// numerically zero.\n\t\t\tif ( bySet && i !== matchedCount ) {\n\t\t\t\tj = 0;\n\t\t\t\twhile ( ( matcher = setMatchers[ j++ ] ) ) {\n\t\t\t\t\tmatcher( unmatched, setMatched, context, xml );\n\t\t\t\t}\n\n\t\t\t\tif ( seed ) {\n\n\t\t\t\t\t// Reintegrate element matches to eliminate the need for sorting\n\t\t\t\t\tif ( matchedCount > 0 ) {\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tif ( !( unmatched[ i ] || setMatched[ i ] ) ) {\n\t\t\t\t\t\t\t\tsetMatched[ i ] = pop.call( results );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Discard index placeholder values to get only actual matches\n\t\t\t\t\tsetMatched = condense( setMatched );\n\t\t\t\t}\n\n\t\t\t\t// Add matches to results\n\t\t\t\tpush.apply( results, setMatched );\n\n\t\t\t\t// Seedless set matches succeeding multiple successful matchers stipulate sorting\n\t\t\t\tif ( outermost && !seed && setMatched.length > 0 &&\n\t\t\t\t\t( matchedCount + setMatchers.length ) > 1 ) {\n\n\t\t\t\t\tSizzle.uniqueSort( results );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Override manipulation of globals by nested matchers\n\t\t\tif ( outermost ) {\n\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\toutermostContext = contextBackup;\n\t\t\t}\n\n\t\t\treturn unmatched;\n\t\t};\n\n\treturn bySet ?\n\t\tmarkFunction( superMatcher ) :\n\t\tsuperMatcher;\n}\n\ncompile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {\n\tvar i,\n\t\tsetMatchers = [],\n\t\telementMatchers = [],\n\t\tcached = compilerCache[ selector + \" \" ];\n\n\tif ( !cached ) {\n\n\t\t// Generate a function of recursive functions that can be used to check each element\n\t\tif ( !match ) {\n\t\t\tmatch = tokenize( selector );\n\t\t}\n\t\ti = match.length;\n\t\twhile ( i-- ) {\n\t\t\tcached = matcherFromTokens( match[ i ] );\n\t\t\tif ( cached[ expando ] ) {\n\t\t\t\tsetMatchers.push( cached );\n\t\t\t} else {\n\t\t\t\telementMatchers.push( cached );\n\t\t\t}\n\t\t}\n\n\t\t// Cache the compiled function\n\t\tcached = compilerCache(\n\t\t\tselector,\n\t\t\tmatcherFromGroupMatchers( elementMatchers, setMatchers )\n\t\t);\n\n\t\t// Save selector and tokenization\n\t\tcached.selector = selector;\n\t}\n\treturn cached;\n};\n\n/**\n * A low-level selection function that works with Sizzle's compiled\n *  selector functions\n * @param {String|Function} selector A selector or a pre-compiled\n *  selector function built with Sizzle.compile\n * @param {Element} context\n * @param {Array} [results]\n * @param {Array} [seed] A set of elements to match against\n */\nselect = Sizzle.select = function( selector, context, results, seed ) {\n\tvar i, tokens, token, type, find,\n\t\tcompiled = typeof selector === \"function\" && selector,\n\t\tmatch = !seed && tokenize( ( selector = compiled.selector || selector ) );\n\n\tresults = results || [];\n\n\t// Try to minimize operations if there is only one selector in the list and no seed\n\t// (the latter of which guarantees us context)\n\tif ( match.length === 1 ) {\n\n\t\t// Reduce context if the leading compound selector is an ID\n\t\ttokens = match[ 0 ] = match[ 0 ].slice( 0 );\n\t\tif ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === \"ID\" &&\n\t\t\tcontext.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {\n\n\t\t\tcontext = ( Expr.find[ \"ID\" ]( token.matches[ 0 ]\n\t\t\t\t.replace( runescape, funescape ), context ) || [] )[ 0 ];\n\t\t\tif ( !context ) {\n\t\t\t\treturn results;\n\n\t\t\t// Precompiled matchers will still verify ancestry, so step up a level\n\t\t\t} else if ( compiled ) {\n\t\t\t\tcontext = context.parentNode;\n\t\t\t}\n\n\t\t\tselector = selector.slice( tokens.shift().value.length );\n\t\t}\n\n\t\t// Fetch a seed set for right-to-left matching\n\t\ti = matchExpr[ \"needsContext\" ].test( selector ) ? 0 : tokens.length;\n\t\twhile ( i-- ) {\n\t\t\ttoken = tokens[ i ];\n\n\t\t\t// Abort if we hit a combinator\n\t\t\tif ( Expr.relative[ ( type = token.type ) ] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( ( find = Expr.find[ type ] ) ) {\n\n\t\t\t\t// Search, expanding context for leading sibling combinators\n\t\t\t\tif ( ( seed = find(\n\t\t\t\t\ttoken.matches[ 0 ].replace( runescape, funescape ),\n\t\t\t\t\trsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||\n\t\t\t\t\t\tcontext\n\t\t\t\t) ) ) {\n\n\t\t\t\t\t// If seed is empty or no tokens remain, we can return early\n\t\t\t\t\ttokens.splice( i, 1 );\n\t\t\t\t\tselector = seed.length && toSelector( tokens );\n\t\t\t\t\tif ( !selector ) {\n\t\t\t\t\t\tpush.apply( results, seed );\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compile and execute a filtering function if one is not provided\n\t// Provide `match` to avoid retokenization if we modified the selector above\n\t( compiled || compile( selector, match ) )(\n\t\tseed,\n\t\tcontext,\n\t\t!documentIsHTML,\n\t\tresults,\n\t\t!context || rsibling.test( selector ) && testContext( context.parentNode ) || context\n\t);\n\treturn results;\n};\n\n// One-time assignments\n\n// Sort stability\nsupport.sortStable = expando.split( \"\" ).sort( sortOrder ).join( \"\" ) === expando;\n\n// Support: Chrome 14-35+\n// Always assume duplicates if they aren't passed to the comparison function\nsupport.detectDuplicates = !!hasDuplicate;\n\n// Initialize against the default document\nsetDocument();\n\n// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)\n// Detached nodes confoundingly follow *each other*\nsupport.sortDetached = assert( function( el ) {\n\n\t// Should return 1, but returns 4 (following)\n\treturn el.compareDocumentPosition( document.createElement( \"fieldset\" ) ) & 1;\n} );\n\n// Support: IE<8\n// Prevent attribute/property \"interpolation\"\n// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx\nif ( !assert( function( el ) {\n\tel.innerHTML = \"<a href='#'></a>\";\n\treturn el.firstChild.getAttribute( \"href\" ) === \"#\";\n} ) ) {\n\taddHandle( \"type|href|height|width\", function( elem, name, isXML ) {\n\t\tif ( !isXML ) {\n\t\t\treturn elem.getAttribute( name, name.toLowerCase() === \"type\" ? 1 : 2 );\n\t\t}\n\t} );\n}\n\n// Support: IE<9\n// Use defaultValue in place of getAttribute(\"value\")\nif ( !support.attributes || !assert( function( el ) {\n\tel.innerHTML = \"<input/>\";\n\tel.firstChild.setAttribute( \"value\", \"\" );\n\treturn el.firstChild.getAttribute( \"value\" ) === \"\";\n} ) ) {\n\taddHandle( \"value\", function( elem, _name, isXML ) {\n\t\tif ( !isXML && elem.nodeName.toLowerCase() === \"input\" ) {\n\t\t\treturn elem.defaultValue;\n\t\t}\n\t} );\n}\n\n// Support: IE<9\n// Use getAttributeNode to fetch booleans when getAttribute lies\nif ( !assert( function( el ) {\n\treturn el.getAttribute( \"disabled\" ) == null;\n} ) ) {\n\taddHandle( booleans, function( elem, name, isXML ) {\n\t\tvar val;\n\t\tif ( !isXML ) {\n\t\t\treturn elem[ name ] === true ? name.toLowerCase() :\n\t\t\t\t( val = elem.getAttributeNode( name ) ) && val.specified ?\n\t\t\t\t\tval.value :\n\t\t\t\t\tnull;\n\t\t}\n\t} );\n}\n\nreturn Sizzle;\n\n} )( window );\n\n\n\njQuery.find = Sizzle;\njQuery.expr = Sizzle.selectors;\n\n// Deprecated\njQuery.expr[ \":\" ] = jQuery.expr.pseudos;\njQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;\njQuery.text = Sizzle.getText;\njQuery.isXMLDoc = Sizzle.isXML;\njQuery.contains = Sizzle.contains;\njQuery.escapeSelector = Sizzle.escape;\n\n\n\n\nvar dir = function( elem, dir, until ) {\n\tvar matched = [],\n\t\ttruncate = until !== undefined;\n\n\twhile ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {\n\t\tif ( elem.nodeType === 1 ) {\n\t\t\tif ( truncate && jQuery( elem ).is( until ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmatched.push( elem );\n\t\t}\n\t}\n\treturn matched;\n};\n\n\nvar siblings = function( n, elem ) {\n\tvar matched = [];\n\n\tfor ( ; n; n = n.nextSibling ) {\n\t\tif ( n.nodeType === 1 && n !== elem ) {\n\t\t\tmatched.push( n );\n\t\t}\n\t}\n\n\treturn matched;\n};\n\n\nvar rneedsContext = jQuery.expr.match.needsContext;\n\n\n\nfunction nodeName( elem, name ) {\n\n\treturn elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();\n\n}\nvar rsingleTag = ( /^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i );\n\n\n\n// Implement the identical functionality for filter and not\nfunction winnow( elements, qualifier, not ) {\n\tif ( isFunction( qualifier ) ) {\n\t\treturn jQuery.grep( elements, function( elem, i ) {\n\t\t\treturn !!qualifier.call( elem, i, elem ) !== not;\n\t\t} );\n\t}\n\n\t// Single element\n\tif ( qualifier.nodeType ) {\n\t\treturn jQuery.grep( elements, function( elem ) {\n\t\t\treturn ( elem === qualifier ) !== not;\n\t\t} );\n\t}\n\n\t// Arraylike of elements (jQuery, arguments, Array)\n\tif ( typeof qualifier !== \"string\" ) {\n\t\treturn jQuery.grep( elements, function( elem ) {\n\t\t\treturn ( indexOf.call( qualifier, elem ) > -1 ) !== not;\n\t\t} );\n\t}\n\n\t// Filtered directly for both simple and complex selectors\n\treturn jQuery.filter( qualifier, elements, not );\n}\n\njQuery.filter = function( expr, elems, not ) {\n\tvar elem = elems[ 0 ];\n\n\tif ( not ) {\n\t\texpr = \":not(\" + expr + \")\";\n\t}\n\n\tif ( elems.length === 1 && elem.nodeType === 1 ) {\n\t\treturn jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];\n\t}\n\n\treturn jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {\n\t\treturn elem.nodeType === 1;\n\t} ) );\n};\n\njQuery.fn.extend( {\n\tfind: function( selector ) {\n\t\tvar i, ret,\n\t\t\tlen = this.length,\n\t\t\tself = this;\n\n\t\tif ( typeof selector !== \"string\" ) {\n\t\t\treturn this.pushStack( jQuery( selector ).filter( function() {\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tif ( jQuery.contains( self[ i ], this ) ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ) );\n\t\t}\n\n\t\tret = this.pushStack( [] );\n\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tjQuery.find( selector, self[ i ], ret );\n\t\t}\n\n\t\treturn len > 1 ? jQuery.uniqueSort( ret ) : ret;\n\t},\n\tfilter: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], false ) );\n\t},\n\tnot: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], true ) );\n\t},\n\tis: function( selector ) {\n\t\treturn !!winnow(\n\t\t\tthis,\n\n\t\t\t// If this is a positional/relative selector, check membership in the returned set\n\t\t\t// so $(\"p:first\").is(\"p:last\") won't return true for a doc with two \"p\".\n\t\t\ttypeof selector === \"string\" && rneedsContext.test( selector ) ?\n\t\t\t\tjQuery( selector ) :\n\t\t\t\tselector || [],\n\t\t\tfalse\n\t\t).length;\n\t}\n} );\n\n\n// Initialize a jQuery object\n\n\n// A central reference to the root jQuery(document)\nvar rootjQuery,\n\n\t// A simple way to check for HTML strings\n\t// Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)\n\t// Strict HTML recognition (trac-11290: must start with <)\n\t// Shortcut simple #id case for speed\n\trquickExpr = /^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/,\n\n\tinit = jQuery.fn.init = function( selector, context, root ) {\n\t\tvar match, elem;\n\n\t\t// HANDLE: $(\"\"), $(null), $(undefined), $(false)\n\t\tif ( !selector ) {\n\t\t\treturn this;\n\t\t}\n\n\t\t// Method init() accepts an alternate rootjQuery\n\t\t// so migrate can support jQuery.sub (gh-2101)\n\t\troot = root || rootjQuery;\n\n\t\t// Handle HTML strings\n\t\tif ( typeof selector === \"string\" ) {\n\t\t\tif ( selector[ 0 ] === \"<\" &&\n\t\t\t\tselector[ selector.length - 1 ] === \">\" &&\n\t\t\t\tselector.length >= 3 ) {\n\n\t\t\t\t// Assume that strings that start and end with <> are HTML and skip the regex check\n\t\t\t\tmatch = [ null, selector, null ];\n\n\t\t\t} else {\n\t\t\t\tmatch = rquickExpr.exec( selector );\n\t\t\t}\n\n\t\t\t// Match html or make sure no context is specified for #id\n\t\t\tif ( match && ( match[ 1 ] || !context ) ) {\n\n\t\t\t\t// HANDLE: $(html) -> $(array)\n\t\t\t\tif ( match[ 1 ] ) {\n\t\t\t\t\tcontext = context instanceof jQuery ? context[ 0 ] : context;\n\n\t\t\t\t\t// Option to run scripts is true for back-compat\n\t\t\t\t\t// Intentionally let the error be thrown if parseHTML is not present\n\t\t\t\t\tjQuery.merge( this, jQuery.parseHTML(\n\t\t\t\t\t\tmatch[ 1 ],\n\t\t\t\t\t\tcontext && context.nodeType ? context.ownerDocument || context : document,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t) );\n\n\t\t\t\t\t// HANDLE: $(html, props)\n\t\t\t\t\tif ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {\n\t\t\t\t\t\tfor ( match in context ) {\n\n\t\t\t\t\t\t\t// Properties of context are called as methods if possible\n\t\t\t\t\t\t\tif ( isFunction( this[ match ] ) ) {\n\t\t\t\t\t\t\t\tthis[ match ]( context[ match ] );\n\n\t\t\t\t\t\t\t// ...and otherwise set as attributes\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.attr( match, context[ match ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this;\n\n\t\t\t\t// HANDLE: $(#id)\n\t\t\t\t} else {\n\t\t\t\t\telem = document.getElementById( match[ 2 ] );\n\n\t\t\t\t\tif ( elem ) {\n\n\t\t\t\t\t\t// Inject the element directly into the jQuery object\n\t\t\t\t\t\tthis[ 0 ] = elem;\n\t\t\t\t\t\tthis.length = 1;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\n\t\t\t// HANDLE: $(expr, $(...))\n\t\t\t} else if ( !context || context.jquery ) {\n\t\t\t\treturn ( context || root ).find( selector );\n\n\t\t\t// HANDLE: $(expr, context)\n\t\t\t// (which is just equivalent to: $(context).find(expr)\n\t\t\t} else {\n\t\t\t\treturn this.constructor( context ).find( selector );\n\t\t\t}\n\n\t\t// HANDLE: $(DOMElement)\n\t\t} else if ( selector.nodeType ) {\n\t\t\tthis[ 0 ] = selector;\n\t\t\tthis.length = 1;\n\t\t\treturn this;\n\n\t\t// HANDLE: $(function)\n\t\t// Shortcut for document ready\n\t\t} else if ( isFunction( selector ) ) {\n\t\t\treturn root.ready !== undefined ?\n\t\t\t\troot.ready( selector ) :\n\n\t\t\t\t// Execute immediately if ready is not present\n\t\t\t\tselector( jQuery );\n\t\t}\n\n\t\treturn jQuery.makeArray( selector, this );\n\t};\n\n// Give the init function the jQuery prototype for later instantiation\ninit.prototype = jQuery.fn;\n\n// Initialize central reference\nrootjQuery = jQuery( document );\n\n\nvar rparentsprev = /^(?:parents|prev(?:Until|All))/,\n\n\t// Methods guaranteed to produce a unique set when starting from a unique set\n\tguaranteedUnique = {\n\t\tchildren: true,\n\t\tcontents: true,\n\t\tnext: true,\n\t\tprev: true\n\t};\n\njQuery.fn.extend( {\n\thas: function( target ) {\n\t\tvar targets = jQuery( target, this ),\n\t\t\tl = targets.length;\n\n\t\treturn this.filter( function() {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tif ( jQuery.contains( this, targets[ i ] ) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\tclosest: function( selectors, context ) {\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\tl = this.length,\n\t\t\tmatched = [],\n\t\t\ttargets = typeof selectors !== \"string\" && jQuery( selectors );\n\n\t\t// Positional selectors never match, since there's no _selection_ context\n\t\tif ( !rneedsContext.test( selectors ) ) {\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tfor ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {\n\n\t\t\t\t\t// Always skip document fragments\n\t\t\t\t\tif ( cur.nodeType < 11 && ( targets ?\n\t\t\t\t\t\ttargets.index( cur ) > -1 :\n\n\t\t\t\t\t\t// Don't pass non-elements to Sizzle\n\t\t\t\t\t\tcur.nodeType === 1 &&\n\t\t\t\t\t\t\tjQuery.find.matchesSelector( cur, selectors ) ) ) {\n\n\t\t\t\t\t\tmatched.push( cur );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );\n\t},\n\n\t// Determine the position of an element within the set\n\tindex: function( elem ) {\n\n\t\t// No argument, return index in parent\n\t\tif ( !elem ) {\n\t\t\treturn ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;\n\t\t}\n\n\t\t// Index in selector\n\t\tif ( typeof elem === \"string\" ) {\n\t\t\treturn indexOf.call( jQuery( elem ), this[ 0 ] );\n\t\t}\n\n\t\t// Locate the position of the desired element\n\t\treturn indexOf.call( this,\n\n\t\t\t// If it receives a jQuery object, the first element is used\n\t\t\telem.jquery ? elem[ 0 ] : elem\n\t\t);\n\t},\n\n\tadd: function( selector, context ) {\n\t\treturn this.pushStack(\n\t\t\tjQuery.uniqueSort(\n\t\t\t\tjQuery.merge( this.get(), jQuery( selector, context ) )\n\t\t\t)\n\t\t);\n\t},\n\n\taddBack: function( selector ) {\n\t\treturn this.add( selector == null ?\n\t\t\tthis.prevObject : this.prevObject.filter( selector )\n\t\t);\n\t}\n} );\n\nfunction sibling( cur, dir ) {\n\twhile ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}\n\treturn cur;\n}\n\njQuery.each( {\n\tparent: function( elem ) {\n\t\tvar parent = elem.parentNode;\n\t\treturn parent && parent.nodeType !== 11 ? parent : null;\n\t},\n\tparents: function( elem ) {\n\t\treturn dir( elem, \"parentNode\" );\n\t},\n\tparentsUntil: function( elem, _i, until ) {\n\t\treturn dir( elem, \"parentNode\", until );\n\t},\n\tnext: function( elem ) {\n\t\treturn sibling( elem, \"nextSibling\" );\n\t},\n\tprev: function( elem ) {\n\t\treturn sibling( elem, \"previousSibling\" );\n\t},\n\tnextAll: function( elem ) {\n\t\treturn dir( elem, \"nextSibling\" );\n\t},\n\tprevAll: function( elem ) {\n\t\treturn dir( elem, \"previousSibling\" );\n\t},\n\tnextUntil: function( elem, _i, until ) {\n\t\treturn dir( elem, \"nextSibling\", until );\n\t},\n\tprevUntil: function( elem, _i, until ) {\n\t\treturn dir( elem, \"previousSibling\", until );\n\t},\n\tsiblings: function( elem ) {\n\t\treturn siblings( ( elem.parentNode || {} ).firstChild, elem );\n\t},\n\tchildren: function( elem ) {\n\t\treturn siblings( elem.firstChild );\n\t},\n\tcontents: function( elem ) {\n\t\tif ( elem.contentDocument != null &&\n\n\t\t\t// Support: IE 11+\n\t\t\t// <object> elements with no `data` attribute has an object\n\t\t\t// `contentDocument` with a `null` prototype.\n\t\t\tgetProto( elem.contentDocument ) ) {\n\n\t\t\treturn elem.contentDocument;\n\t\t}\n\n\t\t// Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only\n\t\t// Treat the template element as a regular one in browsers that\n\t\t// don't support it.\n\t\tif ( nodeName( elem, \"template\" ) ) {\n\t\t\telem = elem.content || elem;\n\t\t}\n\n\t\treturn jQuery.merge( [], elem.childNodes );\n\t}\n}, function( name, fn ) {\n\tjQuery.fn[ name ] = function( until, selector ) {\n\t\tvar matched = jQuery.map( this, fn, until );\n\n\t\tif ( name.slice( -5 ) !== \"Until\" ) {\n\t\t\tselector = until;\n\t\t}\n\n\t\tif ( selector && typeof selector === \"string\" ) {\n\t\t\tmatched = jQuery.filter( selector, matched );\n\t\t}\n\n\t\tif ( this.length > 1 ) {\n\n\t\t\t// Remove duplicates\n\t\t\tif ( !guaranteedUnique[ name ] ) {\n\t\t\t\tjQuery.uniqueSort( matched );\n\t\t\t}\n\n\t\t\t// Reverse order for parents* and prev-derivatives\n\t\t\tif ( rparentsprev.test( name ) ) {\n\t\t\t\tmatched.reverse();\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched );\n\t};\n} );\nvar rnothtmlwhite = ( /[^\\x20\\t\\r\\n\\f]+/g );\n\n\n\n// Convert String-formatted options into Object-formatted ones\nfunction createOptions( options ) {\n\tvar object = {};\n\tjQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {\n\t\tobject[ flag ] = true;\n\t} );\n\treturn object;\n}\n\n/*\n * Create a callback list using the following parameters:\n *\n *\toptions: an optional list of space-separated options that will change how\n *\t\t\tthe callback list behaves or a more traditional option object\n *\n * By default a callback list will act like an event callback list and can be\n * \"fired\" multiple times.\n *\n * Possible options:\n *\n *\tonce:\t\t\twill ensure the callback list can only be fired once (like a Deferred)\n *\n *\tmemory:\t\t\twill keep track of previous values and will call any callback added\n *\t\t\t\t\tafter the list has been fired right away with the latest \"memorized\"\n *\t\t\t\t\tvalues (like a Deferred)\n *\n *\tunique:\t\t\twill ensure a callback can only be added once (no duplicate in the list)\n *\n *\tstopOnFalse:\tinterrupt callings when a callback returns false\n *\n */\njQuery.Callbacks = function( options ) {\n\n\t// Convert options from String-formatted to Object-formatted if needed\n\t// (we check in cache first)\n\toptions = typeof options === \"string\" ?\n\t\tcreateOptions( options ) :\n\t\tjQuery.extend( {}, options );\n\n\tvar // Flag to know if list is currently firing\n\t\tfiring,\n\n\t\t// Last fire value for non-forgettable lists\n\t\tmemory,\n\n\t\t// Flag to know if list was already fired\n\t\tfired,\n\n\t\t// Flag to prevent firing\n\t\tlocked,\n\n\t\t// Actual callback list\n\t\tlist = [],\n\n\t\t// Queue of execution data for repeatable lists\n\t\tqueue = [],\n\n\t\t// Index of currently firing callback (modified by add/remove as needed)\n\t\tfiringIndex = -1,\n\n\t\t// Fire callbacks\n\t\tfire = function() {\n\n\t\t\t// Enforce single-firing\n\t\t\tlocked = locked || options.once;\n\n\t\t\t// Execute callbacks for all pending executions,\n\t\t\t// respecting firingIndex overrides and runtime changes\n\t\t\tfired = firing = true;\n\t\t\tfor ( ; queue.length; firingIndex = -1 ) {\n\t\t\t\tmemory = queue.shift();\n\t\t\t\twhile ( ++firingIndex < list.length ) {\n\n\t\t\t\t\t// Run callback and check for early termination\n\t\t\t\t\tif ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&\n\t\t\t\t\t\toptions.stopOnFalse ) {\n\n\t\t\t\t\t\t// Jump to end and forget the data so .add doesn't re-fire\n\t\t\t\t\t\tfiringIndex = list.length;\n\t\t\t\t\t\tmemory = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Forget the data if we're done with it\n\t\t\tif ( !options.memory ) {\n\t\t\t\tmemory = false;\n\t\t\t}\n\n\t\t\tfiring = false;\n\n\t\t\t// Clean up if we're done firing for good\n\t\t\tif ( locked ) {\n\n\t\t\t\t// Keep an empty list if we have data for future add calls\n\t\t\t\tif ( memory ) {\n\t\t\t\t\tlist = [];\n\n\t\t\t\t// Otherwise, this object is spent\n\t\t\t\t} else {\n\t\t\t\t\tlist = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Actual Callbacks object\n\t\tself = {\n\n\t\t\t// Add a callback or a collection of callbacks to the list\n\t\t\tadd: function() {\n\t\t\t\tif ( list ) {\n\n\t\t\t\t\t// If we have memory from a past run, we should fire after adding\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfiringIndex = list.length - 1;\n\t\t\t\t\t\tqueue.push( memory );\n\t\t\t\t\t}\n\n\t\t\t\t\t( function add( args ) {\n\t\t\t\t\t\tjQuery.each( args, function( _, arg ) {\n\t\t\t\t\t\t\tif ( isFunction( arg ) ) {\n\t\t\t\t\t\t\t\tif ( !options.unique || !self.has( arg ) ) {\n\t\t\t\t\t\t\t\t\tlist.push( arg );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( arg && arg.length && toType( arg ) !== \"string\" ) {\n\n\t\t\t\t\t\t\t\t// Inspect recursively\n\t\t\t\t\t\t\t\tadd( arg );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )( arguments );\n\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Remove a callback from the list\n\t\t\tremove: function() {\n\t\t\t\tjQuery.each( arguments, function( _, arg ) {\n\t\t\t\t\tvar index;\n\t\t\t\t\twhile ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {\n\t\t\t\t\t\tlist.splice( index, 1 );\n\n\t\t\t\t\t\t// Handle firing indexes\n\t\t\t\t\t\tif ( index <= firingIndex ) {\n\t\t\t\t\t\t\tfiringIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Check if a given callback is in the list.\n\t\t\t// If no argument is given, return whether or not list has callbacks attached.\n\t\t\thas: function( fn ) {\n\t\t\t\treturn fn ?\n\t\t\t\t\tjQuery.inArray( fn, list ) > -1 :\n\t\t\t\t\tlist.length > 0;\n\t\t\t},\n\n\t\t\t// Remove all callbacks from the list\n\t\t\tempty: function() {\n\t\t\t\tif ( list ) {\n\t\t\t\t\tlist = [];\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Disable .fire and .add\n\t\t\t// Abort any current/pending executions\n\t\t\t// Clear all callbacks and values\n\t\t\tdisable: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tlist = memory = \"\";\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tdisabled: function() {\n\t\t\t\treturn !list;\n\t\t\t},\n\n\t\t\t// Disable .fire\n\t\t\t// Also disable .add unless we have memory (since it would have no effect)\n\t\t\t// Abort any pending executions\n\t\t\tlock: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tif ( !memory && !firing ) {\n\t\t\t\t\tlist = memory = \"\";\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tlocked: function() {\n\t\t\t\treturn !!locked;\n\t\t\t},\n\n\t\t\t// Call all callbacks with the given context and arguments\n\t\t\tfireWith: function( context, args ) {\n\t\t\t\tif ( !locked ) {\n\t\t\t\t\targs = args || [];\n\t\t\t\t\targs = [ context, args.slice ? args.slice() : args ];\n\t\t\t\t\tqueue.push( args );\n\t\t\t\t\tif ( !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Call all the callbacks with the given arguments\n\t\t\tfire: function() {\n\t\t\t\tself.fireWith( this, arguments );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// To know if the callbacks have already been called at least once\n\t\t\tfired: function() {\n\t\t\t\treturn !!fired;\n\t\t\t}\n\t\t};\n\n\treturn self;\n};\n\n\nfunction Identity( v ) {\n\treturn v;\n}\nfunction Thrower( ex ) {\n\tthrow ex;\n}\n\nfunction adoptValue( value, resolve, reject, noValue ) {\n\tvar method;\n\n\ttry {\n\n\t\t// Check for promise aspect first to privilege synchronous behavior\n\t\tif ( value && isFunction( ( method = value.promise ) ) ) {\n\t\t\tmethod.call( value ).done( resolve ).fail( reject );\n\n\t\t// Other thenables\n\t\t} else if ( value && isFunction( ( method = value.then ) ) ) {\n\t\t\tmethod.call( value, resolve, reject );\n\n\t\t// Other non-thenables\n\t\t} else {\n\n\t\t\t// Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:\n\t\t\t// * false: [ value ].slice( 0 ) => resolve( value )\n\t\t\t// * true: [ value ].slice( 1 ) => resolve()\n\t\t\tresolve.apply( undefined, [ value ].slice( noValue ) );\n\t\t}\n\n\t// For Promises/A+, convert exceptions into rejections\n\t// Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in\n\t// Deferred#then to conditionally suppress rejection.\n\t} catch ( value ) {\n\n\t\t// Support: Android 4.0 only\n\t\t// Strict mode functions invoked without .call/.apply get global-object context\n\t\treject.apply( undefined, [ value ] );\n\t}\n}\n\njQuery.extend( {\n\n\tDeferred: function( func ) {\n\t\tvar tuples = [\n\n\t\t\t\t// action, add listener, callbacks,\n\t\t\t\t// ... .then handlers, argument index, [final state]\n\t\t\t\t[ \"notify\", \"progress\", jQuery.Callbacks( \"memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"memory\" ), 2 ],\n\t\t\t\t[ \"resolve\", \"done\", jQuery.Callbacks( \"once memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"once memory\" ), 0, \"resolved\" ],\n\t\t\t\t[ \"reject\", \"fail\", jQuery.Callbacks( \"once memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"once memory\" ), 1, \"rejected\" ]\n\t\t\t],\n\t\t\tstate = \"pending\",\n\t\t\tpromise = {\n\t\t\t\tstate: function() {\n\t\t\t\t\treturn state;\n\t\t\t\t},\n\t\t\t\talways: function() {\n\t\t\t\t\tdeferred.done( arguments ).fail( arguments );\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\t\t\t\t\"catch\": function( fn ) {\n\t\t\t\t\treturn promise.then( null, fn );\n\t\t\t\t},\n\n\t\t\t\t// Keep pipe for back-compat\n\t\t\t\tpipe: function( /* fnDone, fnFail, fnProgress */ ) {\n\t\t\t\t\tvar fns = arguments;\n\n\t\t\t\t\treturn jQuery.Deferred( function( newDefer ) {\n\t\t\t\t\t\tjQuery.each( tuples, function( _i, tuple ) {\n\n\t\t\t\t\t\t\t// Map tuples (progress, done, fail) to arguments (done, fail, progress)\n\t\t\t\t\t\t\tvar fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];\n\n\t\t\t\t\t\t\t// deferred.progress(function() { bind to newDefer or newDefer.notify })\n\t\t\t\t\t\t\t// deferred.done(function() { bind to newDefer or newDefer.resolve })\n\t\t\t\t\t\t\t// deferred.fail(function() { bind to newDefer or newDefer.reject })\n\t\t\t\t\t\t\tdeferred[ tuple[ 1 ] ]( function() {\n\t\t\t\t\t\t\t\tvar returned = fn && fn.apply( this, arguments );\n\t\t\t\t\t\t\t\tif ( returned && isFunction( returned.promise ) ) {\n\t\t\t\t\t\t\t\t\treturned.promise()\n\t\t\t\t\t\t\t\t\t\t.progress( newDefer.notify )\n\t\t\t\t\t\t\t\t\t\t.done( newDefer.resolve )\n\t\t\t\t\t\t\t\t\t\t.fail( newDefer.reject );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tnewDefer[ tuple[ 0 ] + \"With\" ](\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t\tfn ? [ returned ] : arguments\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tfns = null;\n\t\t\t\t\t} ).promise();\n\t\t\t\t},\n\t\t\t\tthen: function( onFulfilled, onRejected, onProgress ) {\n\t\t\t\t\tvar maxDepth = 0;\n\t\t\t\t\tfunction resolve( depth, deferred, handler, special ) {\n\t\t\t\t\t\treturn function() {\n\t\t\t\t\t\t\tvar that = this,\n\t\t\t\t\t\t\t\targs = arguments,\n\t\t\t\t\t\t\t\tmightThrow = function() {\n\t\t\t\t\t\t\t\t\tvar returned, then;\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.3\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-59\n\t\t\t\t\t\t\t\t\t// Ignore double-resolution attempts\n\t\t\t\t\t\t\t\t\tif ( depth < maxDepth ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturned = handler.apply( that, args );\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.1\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-48\n\t\t\t\t\t\t\t\t\tif ( returned === deferred.promise() ) {\n\t\t\t\t\t\t\t\t\t\tthrow new TypeError( \"Thenable self-resolution\" );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ sections 2.3.3.1, 3.5\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-54\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-75\n\t\t\t\t\t\t\t\t\t// Retrieve `then` only once\n\t\t\t\t\t\t\t\t\tthen = returned &&\n\n\t\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.4\n\t\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-64\n\t\t\t\t\t\t\t\t\t\t// Only check objects and functions for thenability\n\t\t\t\t\t\t\t\t\t\t( typeof returned === \"object\" ||\n\t\t\t\t\t\t\t\t\t\t\ttypeof returned === \"function\" ) &&\n\t\t\t\t\t\t\t\t\t\treturned.then;\n\n\t\t\t\t\t\t\t\t\t// Handle a returned thenable\n\t\t\t\t\t\t\t\t\tif ( isFunction( then ) ) {\n\n\t\t\t\t\t\t\t\t\t\t// Special processors (notify) just wait for resolution\n\t\t\t\t\t\t\t\t\t\tif ( special ) {\n\t\t\t\t\t\t\t\t\t\t\tthen.call(\n\t\t\t\t\t\t\t\t\t\t\t\treturned,\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Thrower, special )\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t// Normal processors (resolve) also hook into progress\n\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t// ...and disregard older resolution values\n\t\t\t\t\t\t\t\t\t\t\tmaxDepth++;\n\n\t\t\t\t\t\t\t\t\t\t\tthen.call(\n\t\t\t\t\t\t\t\t\t\t\t\treturned,\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Thrower, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdeferred.notifyWith )\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Handle all other returned values\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t// Only substitute handlers pass on context\n\t\t\t\t\t\t\t\t\t\t// and multiple values (non-spec behavior)\n\t\t\t\t\t\t\t\t\t\tif ( handler !== Identity ) {\n\t\t\t\t\t\t\t\t\t\t\tthat = undefined;\n\t\t\t\t\t\t\t\t\t\t\targs = [ returned ];\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Process the value(s)\n\t\t\t\t\t\t\t\t\t\t// Default process is resolve\n\t\t\t\t\t\t\t\t\t\t( special || deferred.resolveWith )( that, args );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t// Only normal processors (resolve) catch and reject exceptions\n\t\t\t\t\t\t\t\tprocess = special ?\n\t\t\t\t\t\t\t\t\tmightThrow :\n\t\t\t\t\t\t\t\t\tfunction() {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tmightThrow();\n\t\t\t\t\t\t\t\t\t\t} catch ( e ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( jQuery.Deferred.exceptionHook ) {\n\t\t\t\t\t\t\t\t\t\t\t\tjQuery.Deferred.exceptionHook( e,\n\t\t\t\t\t\t\t\t\t\t\t\t\tprocess.stackTrace );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.4.1\n\t\t\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-61\n\t\t\t\t\t\t\t\t\t\t\t// Ignore post-resolution exceptions\n\t\t\t\t\t\t\t\t\t\t\tif ( depth + 1 >= maxDepth ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t// Only substitute handlers pass on context\n\t\t\t\t\t\t\t\t\t\t\t\t// and multiple values (non-spec behavior)\n\t\t\t\t\t\t\t\t\t\t\t\tif ( handler !== Thrower ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthat = undefined;\n\t\t\t\t\t\t\t\t\t\t\t\t\targs = [ e ];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tdeferred.rejectWith( that, args );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.1\n\t\t\t\t\t\t\t// https://promisesaplus.com/#point-57\n\t\t\t\t\t\t\t// Re-resolve promises immediately to dodge false rejection from\n\t\t\t\t\t\t\t// subsequent errors\n\t\t\t\t\t\t\tif ( depth ) {\n\t\t\t\t\t\t\t\tprocess();\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t// Call an optional hook to record the stack, in case of exception\n\t\t\t\t\t\t\t\t// since it's otherwise lost when execution goes async\n\t\t\t\t\t\t\t\tif ( jQuery.Deferred.getStackHook ) {\n\t\t\t\t\t\t\t\t\tprocess.stackTrace = jQuery.Deferred.getStackHook();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\twindow.setTimeout( process );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn jQuery.Deferred( function( newDefer ) {\n\n\t\t\t\t\t\t// progress_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 0 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tisFunction( onProgress ) ?\n\t\t\t\t\t\t\t\t\tonProgress :\n\t\t\t\t\t\t\t\t\tIdentity,\n\t\t\t\t\t\t\t\tnewDefer.notifyWith\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// fulfilled_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 1 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tisFunction( onFulfilled ) ?\n\t\t\t\t\t\t\t\t\tonFulfilled :\n\t\t\t\t\t\t\t\t\tIdentity\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// rejected_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 2 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tisFunction( onRejected ) ?\n\t\t\t\t\t\t\t\t\tonRejected :\n\t\t\t\t\t\t\t\t\tThrower\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} ).promise();\n\t\t\t\t},\n\n\t\t\t\t// Get a promise for this deferred\n\t\t\t\t// If obj is provided, the promise aspect is added to the object\n\t\t\t\tpromise: function( obj ) {\n\t\t\t\t\treturn obj != null ? jQuery.extend( obj, promise ) : promise;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdeferred = {};\n\n\t\t// Add list-specific methods\n\t\tjQuery.each( tuples, function( i, tuple ) {\n\t\t\tvar list = tuple[ 2 ],\n\t\t\t\tstateString = tuple[ 5 ];\n\n\t\t\t// promise.progress = list.add\n\t\t\t// promise.done = list.add\n\t\t\t// promise.fail = list.add\n\t\t\tpromise[ tuple[ 1 ] ] = list.add;\n\n\t\t\t// Handle state\n\t\t\tif ( stateString ) {\n\t\t\t\tlist.add(\n\t\t\t\t\tfunction() {\n\n\t\t\t\t\t\t// state = \"resolved\" (i.e., fulfilled)\n\t\t\t\t\t\t// state = \"rejected\"\n\t\t\t\t\t\tstate = stateString;\n\t\t\t\t\t},\n\n\t\t\t\t\t// rejected_callbacks.disable\n\t\t\t\t\t// fulfilled_callbacks.disable\n\t\t\t\t\ttuples[ 3 - i ][ 2 ].disable,\n\n\t\t\t\t\t// rejected_handlers.disable\n\t\t\t\t\t// fulfilled_handlers.disable\n\t\t\t\t\ttuples[ 3 - i ][ 3 ].disable,\n\n\t\t\t\t\t// progress_callbacks.lock\n\t\t\t\t\ttuples[ 0 ][ 2 ].lock,\n\n\t\t\t\t\t// progress_handlers.lock\n\t\t\t\t\ttuples[ 0 ][ 3 ].lock\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// progress_handlers.fire\n\t\t\t// fulfilled_handlers.fire\n\t\t\t// rejected_handlers.fire\n\t\t\tlist.add( tuple[ 3 ].fire );\n\n\t\t\t// deferred.notify = function() { deferred.notifyWith(...) }\n\t\t\t// deferred.resolve = function() { deferred.resolveWith(...) }\n\t\t\t// deferred.reject = function() { deferred.rejectWith(...) }\n\t\t\tdeferred[ tuple[ 0 ] ] = function() {\n\t\t\t\tdeferred[ tuple[ 0 ] + \"With\" ]( this === deferred ? undefined : this, arguments );\n\t\t\t\treturn this;\n\t\t\t};\n\n\t\t\t// deferred.notifyWith = list.fireWith\n\t\t\t// deferred.resolveWith = list.fireWith\n\t\t\t// deferred.rejectWith = list.fireWith\n\t\t\tdeferred[ tuple[ 0 ] + \"With\" ] = list.fireWith;\n\t\t} );\n\n\t\t// Make the deferred a promise\n\t\tpromise.promise( deferred );\n\n\t\t// Call given func if any\n\t\tif ( func ) {\n\t\t\tfunc.call( deferred, deferred );\n\t\t}\n\n\t\t// All done!\n\t\treturn deferred;\n\t},\n\n\t// Deferred helper\n\twhen: function( singleValue ) {\n\t\tvar\n\n\t\t\t// count of uncompleted subordinates\n\t\t\tremaining = arguments.length,\n\n\t\t\t// count of unprocessed arguments\n\t\t\ti = remaining,\n\n\t\t\t// subordinate fulfillment data\n\t\t\tresolveContexts = Array( i ),\n\t\t\tresolveValues = slice.call( arguments ),\n\n\t\t\t// the primary Deferred\n\t\t\tprimary = jQuery.Deferred(),\n\n\t\t\t// subordinate callback factory\n\t\t\tupdateFunc = function( i ) {\n\t\t\t\treturn function( value ) {\n\t\t\t\t\tresolveContexts[ i ] = this;\n\t\t\t\t\tresolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;\n\t\t\t\t\tif ( !( --remaining ) ) {\n\t\t\t\t\t\tprimary.resolveWith( resolveContexts, resolveValues );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t};\n\n\t\t// Single- and empty arguments are adopted like Promise.resolve\n\t\tif ( remaining <= 1 ) {\n\t\t\tadoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,\n\t\t\t\t!remaining );\n\n\t\t\t// Use .then() to unwrap secondary thenables (cf. gh-3000)\n\t\t\tif ( primary.state() === \"pending\" ||\n\t\t\t\tisFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {\n\n\t\t\t\treturn primary.then();\n\t\t\t}\n\t\t}\n\n\t\t// Multiple arguments are aggregated like Promise.all array elements\n\t\twhile ( i-- ) {\n\t\t\tadoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );\n\t\t}\n\n\t\treturn primary.promise();\n\t}\n} );\n\n\n// These usually indicate a programmer mistake during development,\n// warn about them ASAP rather than swallowing them by default.\nvar rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;\n\njQuery.Deferred.exceptionHook = function( error, stack ) {\n\n\t// Support: IE 8 - 9 only\n\t// Console exists when dev tools are open, which can happen at any time\n\tif ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {\n\t\twindow.console.warn( \"jQuery.Deferred exception: \" + error.message, error.stack, stack );\n\t}\n};\n\n\n\n\njQuery.readyException = function( error ) {\n\twindow.setTimeout( function() {\n\t\tthrow error;\n\t} );\n};\n\n\n\n\n// The deferred used on DOM ready\nvar readyList = jQuery.Deferred();\n\njQuery.fn.ready = function( fn ) {\n\n\treadyList\n\t\t.then( fn )\n\n\t\t// Wrap jQuery.readyException in a function so that the lookup\n\t\t// happens at the time of error handling instead of callback\n\t\t// registration.\n\t\t.catch( function( error ) {\n\t\t\tjQuery.readyException( error );\n\t\t} );\n\n\treturn this;\n};\n\njQuery.extend( {\n\n\t// Is the DOM ready to be used? Set to true once it occurs.\n\tisReady: false,\n\n\t// A counter to track how many items to wait for before\n\t// the ready event fires. See trac-6781\n\treadyWait: 1,\n\n\t// Handle when the DOM is ready\n\tready: function( wait ) {\n\n\t\t// Abort if there are pending holds or we're already ready\n\t\tif ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Remember that the DOM is ready\n\t\tjQuery.isReady = true;\n\n\t\t// If a normal DOM Ready event fired, decrement, and wait if need be\n\t\tif ( wait !== true && --jQuery.readyWait > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there are functions bound, to execute\n\t\treadyList.resolveWith( document, [ jQuery ] );\n\t}\n} );\n\njQuery.ready.then = readyList.then;\n\n// The ready event handler and self cleanup method\nfunction completed() {\n\tdocument.removeEventListener( \"DOMContentLoaded\", completed );\n\twindow.removeEventListener( \"load\", completed );\n\tjQuery.ready();\n}\n\n// Catch cases where $(document).ready() is called\n// after the browser event has already occurred.\n// Support: IE <=9 - 10 only\n// Older IE sometimes signals \"interactive\" too soon\nif ( document.readyState === \"complete\" ||\n\t( document.readyState !== \"loading\" && !document.documentElement.doScroll ) ) {\n\n\t// Handle it asynchronously to allow scripts the opportunity to delay ready\n\twindow.setTimeout( jQuery.ready );\n\n} else {\n\n\t// Use the handy event callback\n\tdocument.addEventListener( \"DOMContentLoaded\", completed );\n\n\t// A fallback to window.onload, that will always work\n\twindow.addEventListener( \"load\", completed );\n}\n\n\n\n\n// Multifunctional method to get and set values of a collection\n// The value/s can optionally be executed if it's a function\nvar access = function( elems, fn, key, value, chainable, emptyGet, raw ) {\n\tvar i = 0,\n\t\tlen = elems.length,\n\t\tbulk = key == null;\n\n\t// Sets many values\n\tif ( toType( key ) === \"object\" ) {\n\t\tchainable = true;\n\t\tfor ( i in key ) {\n\t\t\taccess( elems, fn, i, key[ i ], true, emptyGet, raw );\n\t\t}\n\n\t// Sets one value\n\t} else if ( value !== undefined ) {\n\t\tchainable = true;\n\n\t\tif ( !isFunction( value ) ) {\n\t\t\traw = true;\n\t\t}\n\n\t\tif ( bulk ) {\n\n\t\t\t// Bulk operations run against the entire set\n\t\t\tif ( raw ) {\n\t\t\t\tfn.call( elems, value );\n\t\t\t\tfn = null;\n\n\t\t\t// ...except when executing function values\n\t\t\t} else {\n\t\t\t\tbulk = fn;\n\t\t\t\tfn = function( elem, _key, value ) {\n\t\t\t\t\treturn bulk.call( jQuery( elem ), value );\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( fn ) {\n\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\tfn(\n\t\t\t\t\telems[ i ], key, raw ?\n\t\t\t\t\t\tvalue :\n\t\t\t\t\t\tvalue.call( elems[ i ], i, fn( elems[ i ], key ) )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( chainable ) {\n\t\treturn elems;\n\t}\n\n\t// Gets\n\tif ( bulk ) {\n\t\treturn fn.call( elems );\n\t}\n\n\treturn len ? fn( elems[ 0 ], key ) : emptyGet;\n};\n\n\n// Matches dashed string for camelizing\nvar rmsPrefix = /^-ms-/,\n\trdashAlpha = /-([a-z])/g;\n\n// Used by camelCase as callback to replace()\nfunction fcamelCase( _all, letter ) {\n\treturn letter.toUpperCase();\n}\n\n// Convert dashed to camelCase; used by the css and data modules\n// Support: IE <=9 - 11, Edge 12 - 15\n// Microsoft forgot to hump their vendor prefix (trac-9572)\nfunction camelCase( string ) {\n\treturn string.replace( rmsPrefix, \"ms-\" ).replace( rdashAlpha, fcamelCase );\n}\nvar acceptData = function( owner ) {\n\n\t// Accepts only:\n\t//  - Node\n\t//    - Node.ELEMENT_NODE\n\t//    - Node.DOCUMENT_NODE\n\t//  - Object\n\t//    - Any\n\treturn owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );\n};\n\n\n\n\nfunction Data() {\n\tthis.expando = jQuery.expando + Data.uid++;\n}\n\nData.uid = 1;\n\nData.prototype = {\n\n\tcache: function( owner ) {\n\n\t\t// Check if the owner object already has a cache\n\t\tvar value = owner[ this.expando ];\n\n\t\t// If not, create one\n\t\tif ( !value ) {\n\t\t\tvalue = {};\n\n\t\t\t// We can accept data for non-element nodes in modern browsers,\n\t\t\t// but we should not, see trac-8335.\n\t\t\t// Always return an empty object.\n\t\t\tif ( acceptData( owner ) ) {\n\n\t\t\t\t// If it is a node unlikely to be stringify-ed or looped over\n\t\t\t\t// use plain assignment\n\t\t\t\tif ( owner.nodeType ) {\n\t\t\t\t\towner[ this.expando ] = value;\n\n\t\t\t\t// Otherwise secure it in a non-enumerable property\n\t\t\t\t// configurable must be true to allow the property to be\n\t\t\t\t// deleted when data is removed\n\t\t\t\t} else {\n\t\t\t\t\tObject.defineProperty( owner, this.expando, {\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\tconfigurable: true\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t},\n\tset: function( owner, data, value ) {\n\t\tvar prop,\n\t\t\tcache = this.cache( owner );\n\n\t\t// Handle: [ owner, key, value ] args\n\t\t// Always use camelCase key (gh-2257)\n\t\tif ( typeof data === \"string\" ) {\n\t\t\tcache[ camelCase( data ) ] = value;\n\n\t\t// Handle: [ owner, { properties } ] args\n\t\t} else {\n\n\t\t\t// Copy the properties one-by-one to the cache object\n\t\t\tfor ( prop in data ) {\n\t\t\t\tcache[ camelCase( prop ) ] = data[ prop ];\n\t\t\t}\n\t\t}\n\t\treturn cache;\n\t},\n\tget: function( owner, key ) {\n\t\treturn key === undefined ?\n\t\t\tthis.cache( owner ) :\n\n\t\t\t// Always use camelCase key (gh-2257)\n\t\t\towner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];\n\t},\n\taccess: function( owner, key, value ) {\n\n\t\t// In cases where either:\n\t\t//\n\t\t//   1. No key was specified\n\t\t//   2. A string key was specified, but no value provided\n\t\t//\n\t\t// Take the \"read\" path and allow the get method to determine\n\t\t// which value to return, respectively either:\n\t\t//\n\t\t//   1. The entire cache object\n\t\t//   2. The data stored at the key\n\t\t//\n\t\tif ( key === undefined ||\n\t\t\t\t( ( key && typeof key === \"string\" ) && value === undefined ) ) {\n\n\t\t\treturn this.get( owner, key );\n\t\t}\n\n\t\t// When the key is not a string, or both a key and value\n\t\t// are specified, set or extend (existing objects) with either:\n\t\t//\n\t\t//   1. An object of properties\n\t\t//   2. A key and value\n\t\t//\n\t\tthis.set( owner, key, value );\n\n\t\t// Since the \"set\" path can have two possible entry points\n\t\t// return the expected data based on which path was taken[*]\n\t\treturn value !== undefined ? value : key;\n\t},\n\tremove: function( owner, key ) {\n\t\tvar i,\n\t\t\tcache = owner[ this.expando ];\n\n\t\tif ( cache === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( key !== undefined ) {\n\n\t\t\t// Support array or space separated string of keys\n\t\t\tif ( Array.isArray( key ) ) {\n\n\t\t\t\t// If key is an array of keys...\n\t\t\t\t// We always set camelCase keys, so remove that.\n\t\t\t\tkey = key.map( camelCase );\n\t\t\t} else {\n\t\t\t\tkey = camelCase( key );\n\n\t\t\t\t// If a key with the spaces exists, use it.\n\t\t\t\t// Otherwise, create an array by matching non-whitespace\n\t\t\t\tkey = key in cache ?\n\t\t\t\t\t[ key ] :\n\t\t\t\t\t( key.match( rnothtmlwhite ) || [] );\n\t\t\t}\n\n\t\t\ti = key.length;\n\n\t\t\twhile ( i-- ) {\n\t\t\t\tdelete cache[ key[ i ] ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove the expando if there's no more data\n\t\tif ( key === undefined || jQuery.isEmptyObject( cache ) ) {\n\n\t\t\t// Support: Chrome <=35 - 45\n\t\t\t// Webkit & Blink performance suffers when deleting properties\n\t\t\t// from DOM nodes, so set to undefined instead\n\t\t\t// https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)\n\t\t\tif ( owner.nodeType ) {\n\t\t\t\towner[ this.expando ] = undefined;\n\t\t\t} else {\n\t\t\t\tdelete owner[ this.expando ];\n\t\t\t}\n\t\t}\n\t},\n\thasData: function( owner ) {\n\t\tvar cache = owner[ this.expando ];\n\t\treturn cache !== undefined && !jQuery.isEmptyObject( cache );\n\t}\n};\nvar dataPriv = new Data();\n\nvar dataUser = new Data();\n\n\n\n//\tImplementation Summary\n//\n//\t1. Enforce API surface and semantic compatibility with 1.9.x branch\n//\t2. Improve the module's maintainability by reducing the storage\n//\t\tpaths to a single mechanism.\n//\t3. Use the same single mechanism to support \"private\" and \"user\" data.\n//\t4. _Never_ expose \"private\" data to user code (TODO: Drop _data, _removeData)\n//\t5. Avoid exposing implementation details on user objects (eg. expando properties)\n//\t6. Provide a clear path for implementation upgrade to WeakMap in 2014\n\nvar rbrace = /^(?:\\{[\\w\\W]*\\}|\\[[\\w\\W]*\\])$/,\n\trmultiDash = /[A-Z]/g;\n\nfunction getData( data ) {\n\tif ( data === \"true\" ) {\n\t\treturn true;\n\t}\n\n\tif ( data === \"false\" ) {\n\t\treturn false;\n\t}\n\n\tif ( data === \"null\" ) {\n\t\treturn null;\n\t}\n\n\t// Only convert to a number if it doesn't change the string\n\tif ( data === +data + \"\" ) {\n\t\treturn +data;\n\t}\n\n\tif ( rbrace.test( data ) ) {\n\t\treturn JSON.parse( data );\n\t}\n\n\treturn data;\n}\n\nfunction dataAttr( elem, key, data ) {\n\tvar name;\n\n\t// If nothing was found internally, try to fetch any\n\t// data from the HTML5 data-* attribute\n\tif ( data === undefined && elem.nodeType === 1 ) {\n\t\tname = \"data-\" + key.replace( rmultiDash, \"-$&\" ).toLowerCase();\n\t\tdata = elem.getAttribute( name );\n\n\t\tif ( typeof data === \"string\" ) {\n\t\t\ttry {\n\t\t\t\tdata = getData( data );\n\t\t\t} catch ( e ) {}\n\n\t\t\t// Make sure we set the data so it isn't changed later\n\t\t\tdataUser.set( elem, key, data );\n\t\t} else {\n\t\t\tdata = undefined;\n\t\t}\n\t}\n\treturn data;\n}\n\njQuery.extend( {\n\thasData: function( elem ) {\n\t\treturn dataUser.hasData( elem ) || dataPriv.hasData( elem );\n\t},\n\n\tdata: function( elem, name, data ) {\n\t\treturn dataUser.access( elem, name, data );\n\t},\n\n\tremoveData: function( elem, name ) {\n\t\tdataUser.remove( elem, name );\n\t},\n\n\t// TODO: Now that all calls to _data and _removeData have been replaced\n\t// with direct calls to dataPriv methods, these can be deprecated.\n\t_data: function( elem, name, data ) {\n\t\treturn dataPriv.access( elem, name, data );\n\t},\n\n\t_removeData: function( elem, name ) {\n\t\tdataPriv.remove( elem, name );\n\t}\n} );\n\njQuery.fn.extend( {\n\tdata: function( key, value ) {\n\t\tvar i, name, data,\n\t\t\telem = this[ 0 ],\n\t\t\tattrs = elem && elem.attributes;\n\n\t\t// Gets all values\n\t\tif ( key === undefined ) {\n\t\t\tif ( this.length ) {\n\t\t\t\tdata = dataUser.get( elem );\n\n\t\t\t\tif ( elem.nodeType === 1 && !dataPriv.get( elem, \"hasDataAttrs\" ) ) {\n\t\t\t\t\ti = attrs.length;\n\t\t\t\t\twhile ( i-- ) {\n\n\t\t\t\t\t\t// Support: IE 11 only\n\t\t\t\t\t\t// The attrs elements can be null (trac-14894)\n\t\t\t\t\t\tif ( attrs[ i ] ) {\n\t\t\t\t\t\t\tname = attrs[ i ].name;\n\t\t\t\t\t\t\tif ( name.indexOf( \"data-\" ) === 0 ) {\n\t\t\t\t\t\t\t\tname = camelCase( name.slice( 5 ) );\n\t\t\t\t\t\t\t\tdataAttr( elem, name, data[ name ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdataPriv.set( elem, \"hasDataAttrs\", true );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\n\t\t// Sets multiple values\n\t\tif ( typeof key === \"object\" ) {\n\t\t\treturn this.each( function() {\n\t\t\t\tdataUser.set( this, key );\n\t\t\t} );\n\t\t}\n\n\t\treturn access( this, function( value ) {\n\t\t\tvar data;\n\n\t\t\t// The calling jQuery object (element matches) is not empty\n\t\t\t// (and therefore has an element appears at this[ 0 ]) and the\n\t\t\t// `value` parameter was not undefined. An empty jQuery object\n\t\t\t// will result in `undefined` for elem = this[ 0 ] which will\n\t\t\t// throw an exception if an attempt to read a data cache is made.\n\t\t\tif ( elem && value === undefined ) {\n\n\t\t\t\t// Attempt to get data from the cache\n\t\t\t\t// The key will always be camelCased in Data\n\t\t\t\tdata = dataUser.get( elem, key );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// Attempt to \"discover\" the data in\n\t\t\t\t// HTML5 custom data-* attrs\n\t\t\t\tdata = dataAttr( elem, key );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// We tried really hard, but the data doesn't exist.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the data...\n\t\t\tthis.each( function() {\n\n\t\t\t\t// We always store the camelCased key\n\t\t\t\tdataUser.set( this, key, value );\n\t\t\t} );\n\t\t}, null, value, arguments.length > 1, null, true );\n\t},\n\n\tremoveData: function( key ) {\n\t\treturn this.each( function() {\n\t\t\tdataUser.remove( this, key );\n\t\t} );\n\t}\n} );\n\n\njQuery.extend( {\n\tqueue: function( elem, type, data ) {\n\t\tvar queue;\n\n\t\tif ( elem ) {\n\t\t\ttype = ( type || \"fx\" ) + \"queue\";\n\t\t\tqueue = dataPriv.get( elem, type );\n\n\t\t\t// Speed up dequeue by getting out quickly if this is just a lookup\n\t\t\tif ( data ) {\n\t\t\t\tif ( !queue || Array.isArray( data ) ) {\n\t\t\t\t\tqueue = dataPriv.access( elem, type, jQuery.makeArray( data ) );\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push( data );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn queue || [];\n\t\t}\n\t},\n\n\tdequeue: function( elem, type ) {\n\t\ttype = type || \"fx\";\n\n\t\tvar queue = jQuery.queue( elem, type ),\n\t\t\tstartLength = queue.length,\n\t\t\tfn = queue.shift(),\n\t\t\thooks = jQuery._queueHooks( elem, type ),\n\t\t\tnext = function() {\n\t\t\t\tjQuery.dequeue( elem, type );\n\t\t\t};\n\n\t\t// If the fx queue is dequeued, always remove the progress sentinel\n\t\tif ( fn === \"inprogress\" ) {\n\t\t\tfn = queue.shift();\n\t\t\tstartLength--;\n\t\t}\n\n\t\tif ( fn ) {\n\n\t\t\t// Add a progress sentinel to prevent the fx queue from being\n\t\t\t// automatically dequeued\n\t\t\tif ( type === \"fx\" ) {\n\t\t\t\tqueue.unshift( \"inprogress\" );\n\t\t\t}\n\n\t\t\t// Clear up the last queue stop function\n\t\t\tdelete hooks.stop;\n\t\t\tfn.call( elem, next, hooks );\n\t\t}\n\n\t\tif ( !startLength && hooks ) {\n\t\t\thooks.empty.fire();\n\t\t}\n\t},\n\n\t// Not public - generate a queueHooks object, or return the current one\n\t_queueHooks: function( elem, type ) {\n\t\tvar key = type + \"queueHooks\";\n\t\treturn dataPriv.get( elem, key ) || dataPriv.access( elem, key, {\n\t\t\tempty: jQuery.Callbacks( \"once memory\" ).add( function() {\n\t\t\t\tdataPriv.remove( elem, [ type + \"queue\", key ] );\n\t\t\t} )\n\t\t} );\n\t}\n} );\n\njQuery.fn.extend( {\n\tqueue: function( type, data ) {\n\t\tvar setter = 2;\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tdata = type;\n\t\t\ttype = \"fx\";\n\t\t\tsetter--;\n\t\t}\n\n\t\tif ( arguments.length < setter ) {\n\t\t\treturn jQuery.queue( this[ 0 ], type );\n\t\t}\n\n\t\treturn data === undefined ?\n\t\t\tthis :\n\t\t\tthis.each( function() {\n\t\t\t\tvar queue = jQuery.queue( this, type, data );\n\n\t\t\t\t// Ensure a hooks for this queue\n\t\t\t\tjQuery._queueHooks( this, type );\n\n\t\t\t\tif ( type === \"fx\" && queue[ 0 ] !== \"inprogress\" ) {\n\t\t\t\t\tjQuery.dequeue( this, type );\n\t\t\t\t}\n\t\t\t} );\n\t},\n\tdequeue: function( type ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.dequeue( this, type );\n\t\t} );\n\t},\n\tclearQueue: function( type ) {\n\t\treturn this.queue( type || \"fx\", [] );\n\t},\n\n\t// Get a promise resolved when queues of a certain type\n\t// are emptied (fx is the type by default)\n\tpromise: function( type, obj ) {\n\t\tvar tmp,\n\t\t\tcount = 1,\n\t\t\tdefer = jQuery.Deferred(),\n\t\t\telements = this,\n\t\t\ti = this.length,\n\t\t\tresolve = function() {\n\t\t\t\tif ( !( --count ) ) {\n\t\t\t\t\tdefer.resolveWith( elements, [ elements ] );\n\t\t\t\t}\n\t\t\t};\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tobj = type;\n\t\t\ttype = undefined;\n\t\t}\n\t\ttype = type || \"fx\";\n\n\t\twhile ( i-- ) {\n\t\t\ttmp = dataPriv.get( elements[ i ], type + \"queueHooks\" );\n\t\t\tif ( tmp && tmp.empty ) {\n\t\t\t\tcount++;\n\t\t\t\ttmp.empty.add( resolve );\n\t\t\t}\n\t\t}\n\t\tresolve();\n\t\treturn defer.promise( obj );\n\t}\n} );\nvar pnum = ( /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/ ).source;\n\nvar rcssNum = new RegExp( \"^(?:([+-])=|)(\" + pnum + \")([a-z%]*)$\", \"i\" );\n\n\nvar cssExpand = [ \"Top\", \"Right\", \"Bottom\", \"Left\" ];\n\nvar documentElement = document.documentElement;\n\n\n\n\tvar isAttached = function( elem ) {\n\t\t\treturn jQuery.contains( elem.ownerDocument, elem );\n\t\t},\n\t\tcomposed = { composed: true };\n\n\t// Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only\n\t// Check attachment across shadow DOM boundaries when possible (gh-3504)\n\t// Support: iOS 10.0-10.2 only\n\t// Early iOS 10 versions support `attachShadow` but not `getRootNode`,\n\t// leading to errors. We need to check for `getRootNode`.\n\tif ( documentElement.getRootNode ) {\n\t\tisAttached = function( elem ) {\n\t\t\treturn jQuery.contains( elem.ownerDocument, elem ) ||\n\t\t\t\telem.getRootNode( composed ) === elem.ownerDocument;\n\t\t};\n\t}\nvar isHiddenWithinTree = function( elem, el ) {\n\n\t\t// isHiddenWithinTree might be called from jQuery#filter function;\n\t\t// in that case, element will be second argument\n\t\telem = el || elem;\n\n\t\t// Inline style trumps all\n\t\treturn elem.style.display === \"none\" ||\n\t\t\telem.style.display === \"\" &&\n\n\t\t\t// Otherwise, check computed style\n\t\t\t// Support: Firefox <=43 - 45\n\t\t\t// Disconnected elements can have computed display: none, so first confirm that elem is\n\t\t\t// in the document.\n\t\t\tisAttached( elem ) &&\n\n\t\t\tjQuery.css( elem, \"display\" ) === \"none\";\n\t};\n\n\n\nfunction adjustCSS( elem, prop, valueParts, tween ) {\n\tvar adjusted, scale,\n\t\tmaxIterations = 20,\n\t\tcurrentValue = tween ?\n\t\t\tfunction() {\n\t\t\t\treturn tween.cur();\n\t\t\t} :\n\t\t\tfunction() {\n\t\t\t\treturn jQuery.css( elem, prop, \"\" );\n\t\t\t},\n\t\tinitial = currentValue(),\n\t\tunit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? \"\" : \"px\" ),\n\n\t\t// Starting value computation is required for potential unit mismatches\n\t\tinitialInUnit = elem.nodeType &&\n\t\t\t( jQuery.cssNumber[ prop ] || unit !== \"px\" && +initial ) &&\n\t\t\trcssNum.exec( jQuery.css( elem, prop ) );\n\n\tif ( initialInUnit && initialInUnit[ 3 ] !== unit ) {\n\n\t\t// Support: Firefox <=54\n\t\t// Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)\n\t\tinitial = initial / 2;\n\n\t\t// Trust units reported by jQuery.css\n\t\tunit = unit || initialInUnit[ 3 ];\n\n\t\t// Iteratively approximate from a nonzero starting point\n\t\tinitialInUnit = +initial || 1;\n\n\t\twhile ( maxIterations-- ) {\n\n\t\t\t// Evaluate and update our best guess (doubling guesses that zero out).\n\t\t\t// Finish if the scale equals or crosses 1 (making the old*new product non-positive).\n\t\t\tjQuery.style( elem, prop, initialInUnit + unit );\n\t\t\tif ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {\n\t\t\t\tmaxIterations = 0;\n\t\t\t}\n\t\t\tinitialInUnit = initialInUnit / scale;\n\n\t\t}\n\n\t\tinitialInUnit = initialInUnit * 2;\n\t\tjQuery.style( elem, prop, initialInUnit + unit );\n\n\t\t// Make sure we update the tween properties later on\n\t\tvalueParts = valueParts || [];\n\t}\n\n\tif ( valueParts ) {\n\t\tinitialInUnit = +initialInUnit || +initial || 0;\n\n\t\t// Apply relative offset (+=/-=) if specified\n\t\tadjusted = valueParts[ 1 ] ?\n\t\t\tinitialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :\n\t\t\t+valueParts[ 2 ];\n\t\tif ( tween ) {\n\t\t\ttween.unit = unit;\n\t\t\ttween.start = initialInUnit;\n\t\t\ttween.end = adjusted;\n\t\t}\n\t}\n\treturn adjusted;\n}\n\n\nvar defaultDisplayMap = {};\n\nfunction getDefaultDisplay( elem ) {\n\tvar temp,\n\t\tdoc = elem.ownerDocument,\n\t\tnodeName = elem.nodeName,\n\t\tdisplay = defaultDisplayMap[ nodeName ];\n\n\tif ( display ) {\n\t\treturn display;\n\t}\n\n\ttemp = doc.body.appendChild( doc.createElement( nodeName ) );\n\tdisplay = jQuery.css( temp, \"display\" );\n\n\ttemp.parentNode.removeChild( temp );\n\n\tif ( display === \"none\" ) {\n\t\tdisplay = \"block\";\n\t}\n\tdefaultDisplayMap[ nodeName ] = display;\n\n\treturn display;\n}\n\nfunction showHide( elements, show ) {\n\tvar display, elem,\n\t\tvalues = [],\n\t\tindex = 0,\n\t\tlength = elements.length;\n\n\t// Determine new display value for elements that need to change\n\tfor ( ; index < length; index++ ) {\n\t\telem = elements[ index ];\n\t\tif ( !elem.style ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdisplay = elem.style.display;\n\t\tif ( show ) {\n\n\t\t\t// Since we force visibility upon cascade-hidden elements, an immediate (and slow)\n\t\t\t// check is required in this first loop unless we have a nonempty display value (either\n\t\t\t// inline or about-to-be-restored)\n\t\t\tif ( display === \"none\" ) {\n\t\t\t\tvalues[ index ] = dataPriv.get( elem, \"display\" ) || null;\n\t\t\t\tif ( !values[ index ] ) {\n\t\t\t\t\telem.style.display = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( elem.style.display === \"\" && isHiddenWithinTree( elem ) ) {\n\t\t\t\tvalues[ index ] = getDefaultDisplay( elem );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( display !== \"none\" ) {\n\t\t\t\tvalues[ index ] = \"none\";\n\n\t\t\t\t// Remember what we're overwriting\n\t\t\t\tdataPriv.set( elem, \"display\", display );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Set the display of the elements in a second loop to avoid constant reflow\n\tfor ( index = 0; index < length; index++ ) {\n\t\tif ( values[ index ] != null ) {\n\t\t\telements[ index ].style.display = values[ index ];\n\t\t}\n\t}\n\n\treturn elements;\n}\n\njQuery.fn.extend( {\n\tshow: function() {\n\t\treturn showHide( this, true );\n\t},\n\thide: function() {\n\t\treturn showHide( this );\n\t},\n\ttoggle: function( state ) {\n\t\tif ( typeof state === \"boolean\" ) {\n\t\t\treturn state ? this.show() : this.hide();\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tif ( isHiddenWithinTree( this ) ) {\n\t\t\t\tjQuery( this ).show();\n\t\t\t} else {\n\t\t\t\tjQuery( this ).hide();\n\t\t\t}\n\t\t} );\n\t}\n} );\nvar rcheckableType = ( /^(?:checkbox|radio)$/i );\n\nvar rtagName = ( /<([a-z][^\\/\\0>\\x20\\t\\r\\n\\f]*)/i );\n\nvar rscriptType = ( /^$|^module$|\\/(?:java|ecma)script/i );\n\n\n\n( function() {\n\tvar fragment = document.createDocumentFragment(),\n\t\tdiv = fragment.appendChild( document.createElement( \"div\" ) ),\n\t\tinput = document.createElement( \"input\" );\n\n\t// Support: Android 4.0 - 4.3 only\n\t// Check state lost if the name is set (trac-11217)\n\t// Support: Windows Web Apps (WWA)\n\t// `name` and `type` must use .setAttribute for WWA (trac-14901)\n\tinput.setAttribute( \"type\", \"radio\" );\n\tinput.setAttribute( \"checked\", \"checked\" );\n\tinput.setAttribute( \"name\", \"t\" );\n\n\tdiv.appendChild( input );\n\n\t// Support: Android <=4.1 only\n\t// Older WebKit doesn't clone checked state correctly in fragments\n\tsupport.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;\n\n\t// Support: IE <=11 only\n\t// Make sure textarea (and checkbox) defaultValue is properly cloned\n\tdiv.innerHTML = \"<textarea>x</textarea>\";\n\tsupport.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;\n\n\t// Support: IE <=9 only\n\t// IE <=9 replaces <option> tags with their contents when inserted outside of\n\t// the select element.\n\tdiv.innerHTML = \"<option></option>\";\n\tsupport.option = !!div.lastChild;\n} )();\n\n\n// We have to close these tags to support XHTML (trac-13200)\nvar wrapMap = {\n\n\t// XHTML parsers do not magically insert elements in the\n\t// same way that tag soup parsers do. So we cannot shorten\n\t// this by omitting <tbody> or other required elements.\n\tthead: [ 1, \"<table>\", \"</table>\" ],\n\tcol: [ 2, \"<table><colgroup>\", \"</colgroup></table>\" ],\n\ttr: [ 2, \"<table><tbody>\", \"</tbody></table>\" ],\n\ttd: [ 3, \"<table><tbody><tr>\", \"</tr></tbody></table>\" ],\n\n\t_default: [ 0, \"\", \"\" ]\n};\n\nwrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;\nwrapMap.th = wrapMap.td;\n\n// Support: IE <=9 only\nif ( !support.option ) {\n\twrapMap.optgroup = wrapMap.option = [ 1, \"<select multiple='multiple'>\", \"</select>\" ];\n}\n\n\nfunction getAll( context, tag ) {\n\n\t// Support: IE <=9 - 11 only\n\t// Use typeof to avoid zero-argument method invocation on host objects (trac-15151)\n\tvar ret;\n\n\tif ( typeof context.getElementsByTagName !== \"undefined\" ) {\n\t\tret = context.getElementsByTagName( tag || \"*\" );\n\n\t} else if ( typeof context.querySelectorAll !== \"undefined\" ) {\n\t\tret = context.querySelectorAll( tag || \"*\" );\n\n\t} else {\n\t\tret = [];\n\t}\n\n\tif ( tag === undefined || tag && nodeName( context, tag ) ) {\n\t\treturn jQuery.merge( [ context ], ret );\n\t}\n\n\treturn ret;\n}\n\n\n// Mark scripts as having already been evaluated\nfunction setGlobalEval( elems, refElements ) {\n\tvar i = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\tdataPriv.set(\n\t\t\telems[ i ],\n\t\t\t\"globalEval\",\n\t\t\t!refElements || dataPriv.get( refElements[ i ], \"globalEval\" )\n\t\t);\n\t}\n}\n\n\nvar rhtml = /<|&#?\\w+;/;\n\nfunction buildFragment( elems, context, scripts, selection, ignored ) {\n\tvar elem, tmp, tag, wrap, attached, j,\n\t\tfragment = context.createDocumentFragment(),\n\t\tnodes = [],\n\t\ti = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\telem = elems[ i ];\n\n\t\tif ( elem || elem === 0 ) {\n\n\t\t\t// Add nodes directly\n\t\t\tif ( toType( elem ) === \"object\" ) {\n\n\t\t\t\t// Support: Android <=4.0 only, PhantomJS 1 only\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );\n\n\t\t\t// Convert non-html into a text node\n\t\t\t} else if ( !rhtml.test( elem ) ) {\n\t\t\t\tnodes.push( context.createTextNode( elem ) );\n\n\t\t\t// Convert html into DOM nodes\n\t\t\t} else {\n\t\t\t\ttmp = tmp || fragment.appendChild( context.createElement( \"div\" ) );\n\n\t\t\t\t// Deserialize a standard representation\n\t\t\t\ttag = ( rtagName.exec( elem ) || [ \"\", \"\" ] )[ 1 ].toLowerCase();\n\t\t\t\twrap = wrapMap[ tag ] || wrapMap._default;\n\t\t\t\ttmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];\n\n\t\t\t\t// Descend through wrappers to the right content\n\t\t\t\tj = wrap[ 0 ];\n\t\t\t\twhile ( j-- ) {\n\t\t\t\t\ttmp = tmp.lastChild;\n\t\t\t\t}\n\n\t\t\t\t// Support: Android <=4.0 only, PhantomJS 1 only\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, tmp.childNodes );\n\n\t\t\t\t// Remember the top-level container\n\t\t\t\ttmp = fragment.firstChild;\n\n\t\t\t\t// Ensure the created nodes are orphaned (trac-12392)\n\t\t\t\ttmp.textContent = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove wrapper from fragment\n\tfragment.textContent = \"\";\n\n\ti = 0;\n\twhile ( ( elem = nodes[ i++ ] ) ) {\n\n\t\t// Skip elements already in the context collection (trac-4087)\n\t\tif ( selection && jQuery.inArray( elem, selection ) > -1 ) {\n\t\t\tif ( ignored ) {\n\t\t\t\tignored.push( elem );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tattached = isAttached( elem );\n\n\t\t// Append to fragment\n\t\ttmp = getAll( fragment.appendChild( elem ), \"script\" );\n\n\t\t// Preserve script evaluation history\n\t\tif ( attached ) {\n\t\t\tsetGlobalEval( tmp );\n\t\t}\n\n\t\t// Capture executables\n\t\tif ( scripts ) {\n\t\t\tj = 0;\n\t\t\twhile ( ( elem = tmp[ j++ ] ) ) {\n\t\t\t\tif ( rscriptType.test( elem.type || \"\" ) ) {\n\t\t\t\t\tscripts.push( elem );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn fragment;\n}\n\n\nvar rtypenamespace = /^([^.]*)(?:\\.(.+)|)/;\n\nfunction returnTrue() {\n\treturn true;\n}\n\nfunction returnFalse() {\n\treturn false;\n}\n\n// Support: IE <=9 - 11+\n// focus() and blur() are asynchronous, except when they are no-op.\n// So expect focus to be synchronous when the element is already active,\n// and blur to be synchronous when the element is not already active.\n// (focus and blur are always synchronous in other supported browsers,\n// this just defines when we can count on it).\nfunction expectSync( elem, type ) {\n\treturn ( elem === safeActiveElement() ) === ( type === \"focus\" );\n}\n\n// Support: IE <=9 only\n// Accessing document.activeElement can throw unexpectedly\n// https://bugs.jquery.com/ticket/13393\nfunction safeActiveElement() {\n\ttry {\n\t\treturn document.activeElement;\n\t} catch ( err ) { }\n}\n\nfunction on( elem, types, selector, data, fn, one ) {\n\tvar origFn, type;\n\n\t// Types can be a map of types/handlers\n\tif ( typeof types === \"object\" ) {\n\n\t\t// ( types-Object, selector, data )\n\t\tif ( typeof selector !== \"string\" ) {\n\n\t\t\t// ( types-Object, data )\n\t\t\tdata = data || selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tfor ( type in types ) {\n\t\t\ton( elem, type, selector, data, types[ type ], one );\n\t\t}\n\t\treturn elem;\n\t}\n\n\tif ( data == null && fn == null ) {\n\n\t\t// ( types, fn )\n\t\tfn = selector;\n\t\tdata = selector = undefined;\n\t} else if ( fn == null ) {\n\t\tif ( typeof selector === \"string\" ) {\n\n\t\t\t// ( types, selector, fn )\n\t\t\tfn = data;\n\t\t\tdata = undefined;\n\t\t} else {\n\n\t\t\t// ( types, data, fn )\n\t\t\tfn = data;\n\t\t\tdata = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t}\n\tif ( fn === false ) {\n\t\tfn = returnFalse;\n\t} else if ( !fn ) {\n\t\treturn elem;\n\t}\n\n\tif ( one === 1 ) {\n\t\torigFn = fn;\n\t\tfn = function( event ) {\n\n\t\t\t// Can use an empty set, since event contains the info\n\t\t\tjQuery().off( event );\n\t\t\treturn origFn.apply( this, arguments );\n\t\t};\n\n\t\t// Use same guid so caller can remove using origFn\n\t\tfn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );\n\t}\n\treturn elem.each( function() {\n\t\tjQuery.event.add( this, types, fn, data, selector );\n\t} );\n}\n\n/*\n * Helper functions for managing events -- not part of the public interface.\n * Props to Dean Edwards' addEvent library for many of the ideas.\n */\njQuery.event = {\n\n\tglobal: {},\n\n\tadd: function( elem, types, handler, data, selector ) {\n\n\t\tvar handleObjIn, eventHandle, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.get( elem );\n\n\t\t// Only attach events to objects that accept data\n\t\tif ( !acceptData( elem ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Caller can pass in an object of custom data in lieu of the handler\n\t\tif ( handler.handler ) {\n\t\t\thandleObjIn = handler;\n\t\t\thandler = handleObjIn.handler;\n\t\t\tselector = handleObjIn.selector;\n\t\t}\n\n\t\t// Ensure that invalid selectors throw exceptions at attach time\n\t\t// Evaluate against documentElement in case elem is a non-element node (e.g., document)\n\t\tif ( selector ) {\n\t\t\tjQuery.find.matchesSelector( documentElement, selector );\n\t\t}\n\n\t\t// Make sure that the handler has a unique ID, used to find/remove it later\n\t\tif ( !handler.guid ) {\n\t\t\thandler.guid = jQuery.guid++;\n\t\t}\n\n\t\t// Init the element's event structure and main handler, if this is the first\n\t\tif ( !( events = elemData.events ) ) {\n\t\t\tevents = elemData.events = Object.create( null );\n\t\t}\n\t\tif ( !( eventHandle = elemData.handle ) ) {\n\t\t\teventHandle = elemData.handle = function( e ) {\n\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== \"undefined\" && jQuery.event.triggered !== e.type ?\n\t\t\t\t\tjQuery.event.dispatch.apply( elem, arguments ) : undefined;\n\t\t\t};\n\t\t}\n\n\t\t// Handle multiple events separated by a space\n\t\ttypes = ( types || \"\" ).match( rnothtmlwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// There *must* be a type, no attaching namespace-only handlers\n\t\t\tif ( !type ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If event changes its type, use the special event handlers for the changed type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// If selector defined, determine special event api type, otherwise given type\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\n\t\t\t// Update special based on newly reset type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// handleObj is passed to all event handlers\n\t\t\thandleObj = jQuery.extend( {\n\t\t\t\ttype: type,\n\t\t\t\torigType: origType,\n\t\t\t\tdata: data,\n\t\t\t\thandler: handler,\n\t\t\t\tguid: handler.guid,\n\t\t\t\tselector: selector,\n\t\t\t\tneedsContext: selector && jQuery.expr.match.needsContext.test( selector ),\n\t\t\t\tnamespace: namespaces.join( \".\" )\n\t\t\t}, handleObjIn );\n\n\t\t\t// Init the event handler queue if we're the first\n\t\t\tif ( !( handlers = events[ type ] ) ) {\n\t\t\t\thandlers = events[ type ] = [];\n\t\t\t\thandlers.delegateCount = 0;\n\n\t\t\t\t// Only use addEventListener if the special events handler returns false\n\t\t\t\tif ( !special.setup ||\n\t\t\t\t\tspecial.setup.call( elem, data, namespaces, eventHandle ) === false ) {\n\n\t\t\t\t\tif ( elem.addEventListener ) {\n\t\t\t\t\t\telem.addEventListener( type, eventHandle );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( special.add ) {\n\t\t\t\tspecial.add.call( elem, handleObj );\n\n\t\t\t\tif ( !handleObj.handler.guid ) {\n\t\t\t\t\thandleObj.handler.guid = handler.guid;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add to the element's handler list, delegates in front\n\t\t\tif ( selector ) {\n\t\t\t\thandlers.splice( handlers.delegateCount++, 0, handleObj );\n\t\t\t} else {\n\t\t\t\thandlers.push( handleObj );\n\t\t\t}\n\n\t\t\t// Keep track of which events have ever been used, for event optimization\n\t\t\tjQuery.event.global[ type ] = true;\n\t\t}\n\n\t},\n\n\t// Detach an event or set of events from an element\n\tremove: function( elem, types, handler, selector, mappedTypes ) {\n\n\t\tvar j, origCount, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.hasData( elem ) && dataPriv.get( elem );\n\n\t\tif ( !elemData || !( events = elemData.events ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Once for each type.namespace in types; type may be omitted\n\t\ttypes = ( types || \"\" ).match( rnothtmlwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// Unbind all events (on this namespace, if provided) for the element\n\t\t\tif ( !type ) {\n\t\t\t\tfor ( type in events ) {\n\t\t\t\t\tjQuery.event.remove( elem, type + types[ t ], handler, selector, true );\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\t\t\thandlers = events[ type ] || [];\n\t\t\ttmp = tmp[ 2 ] &&\n\t\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" );\n\n\t\t\t// Remove matching events\n\t\t\torigCount = j = handlers.length;\n\t\t\twhile ( j-- ) {\n\t\t\t\thandleObj = handlers[ j ];\n\n\t\t\t\tif ( ( mappedTypes || origType === handleObj.origType ) &&\n\t\t\t\t\t( !handler || handler.guid === handleObj.guid ) &&\n\t\t\t\t\t( !tmp || tmp.test( handleObj.namespace ) ) &&\n\t\t\t\t\t( !selector || selector === handleObj.selector ||\n\t\t\t\t\t\tselector === \"**\" && handleObj.selector ) ) {\n\t\t\t\t\thandlers.splice( j, 1 );\n\n\t\t\t\t\tif ( handleObj.selector ) {\n\t\t\t\t\t\thandlers.delegateCount--;\n\t\t\t\t\t}\n\t\t\t\t\tif ( special.remove ) {\n\t\t\t\t\t\tspecial.remove.call( elem, handleObj );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove generic event handler if we removed something and no more handlers exist\n\t\t\t// (avoids potential for endless recursion during removal of special event handlers)\n\t\t\tif ( origCount && !handlers.length ) {\n\t\t\t\tif ( !special.teardown ||\n\t\t\t\t\tspecial.teardown.call( elem, namespaces, elemData.handle ) === false ) {\n\n\t\t\t\t\tjQuery.removeEvent( elem, type, elemData.handle );\n\t\t\t\t}\n\n\t\t\t\tdelete events[ type ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove data and the expando if it's no longer used\n\t\tif ( jQuery.isEmptyObject( events ) ) {\n\t\t\tdataPriv.remove( elem, \"handle events\" );\n\t\t}\n\t},\n\n\tdispatch: function( nativeEvent ) {\n\n\t\tvar i, j, ret, matched, handleObj, handlerQueue,\n\t\t\targs = new Array( arguments.length ),\n\n\t\t\t// Make a writable jQuery.Event from the native event object\n\t\t\tevent = jQuery.event.fix( nativeEvent ),\n\n\t\t\thandlers = (\n\t\t\t\tdataPriv.get( this, \"events\" ) || Object.create( null )\n\t\t\t)[ event.type ] || [],\n\t\t\tspecial = jQuery.event.special[ event.type ] || {};\n\n\t\t// Use the fix-ed jQuery.Event rather than the (read-only) native event\n\t\targs[ 0 ] = event;\n\n\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\targs[ i ] = arguments[ i ];\n\t\t}\n\n\t\tevent.delegateTarget = this;\n\n\t\t// Call the preDispatch hook for the mapped type, and let it bail if desired\n\t\tif ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine handlers\n\t\thandlerQueue = jQuery.event.handlers.call( this, event, handlers );\n\n\t\t// Run delegates first; they may want to stop propagation beneath us\n\t\ti = 0;\n\t\twhile ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {\n\t\t\tevent.currentTarget = matched.elem;\n\n\t\t\tj = 0;\n\t\t\twhile ( ( handleObj = matched.handlers[ j++ ] ) &&\n\t\t\t\t!event.isImmediatePropagationStopped() ) {\n\n\t\t\t\t// If the event is namespaced, then each handler is only invoked if it is\n\t\t\t\t// specially universal or its namespaces are a superset of the event's.\n\t\t\t\tif ( !event.rnamespace || handleObj.namespace === false ||\n\t\t\t\t\tevent.rnamespace.test( handleObj.namespace ) ) {\n\n\t\t\t\t\tevent.handleObj = handleObj;\n\t\t\t\t\tevent.data = handleObj.data;\n\n\t\t\t\t\tret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||\n\t\t\t\t\t\thandleObj.handler ).apply( matched.elem, args );\n\n\t\t\t\t\tif ( ret !== undefined ) {\n\t\t\t\t\t\tif ( ( event.result = ret ) === false ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Call the postDispatch hook for the mapped type\n\t\tif ( special.postDispatch ) {\n\t\t\tspecial.postDispatch.call( this, event );\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\thandlers: function( event, handlers ) {\n\t\tvar i, handleObj, sel, matchedHandlers, matchedSelectors,\n\t\t\thandlerQueue = [],\n\t\t\tdelegateCount = handlers.delegateCount,\n\t\t\tcur = event.target;\n\n\t\t// Find delegate handlers\n\t\tif ( delegateCount &&\n\n\t\t\t// Support: IE <=9\n\t\t\t// Black-hole SVG <use> instance trees (trac-13180)\n\t\t\tcur.nodeType &&\n\n\t\t\t// Support: Firefox <=42\n\t\t\t// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)\n\t\t\t// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click\n\t\t\t// Support: IE 11 only\n\t\t\t// ...but not arrow key \"clicks\" of radio inputs, which can have `button` -1 (gh-2343)\n\t\t\t!( event.type === \"click\" && event.button >= 1 ) ) {\n\n\t\t\tfor ( ; cur !== this; cur = cur.parentNode || this ) {\n\n\t\t\t\t// Don't check non-elements (trac-13208)\n\t\t\t\t// Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)\n\t\t\t\tif ( cur.nodeType === 1 && !( event.type === \"click\" && cur.disabled === true ) ) {\n\t\t\t\t\tmatchedHandlers = [];\n\t\t\t\t\tmatchedSelectors = {};\n\t\t\t\t\tfor ( i = 0; i < delegateCount; i++ ) {\n\t\t\t\t\t\thandleObj = handlers[ i ];\n\n\t\t\t\t\t\t// Don't conflict with Object.prototype properties (trac-13203)\n\t\t\t\t\t\tsel = handleObj.selector + \" \";\n\n\t\t\t\t\t\tif ( matchedSelectors[ sel ] === undefined ) {\n\t\t\t\t\t\t\tmatchedSelectors[ sel ] = handleObj.needsContext ?\n\t\t\t\t\t\t\t\tjQuery( sel, this ).index( cur ) > -1 :\n\t\t\t\t\t\t\t\tjQuery.find( sel, this, null, [ cur ] ).length;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( matchedSelectors[ sel ] ) {\n\t\t\t\t\t\t\tmatchedHandlers.push( handleObj );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( matchedHandlers.length ) {\n\t\t\t\t\t\thandlerQueue.push( { elem: cur, handlers: matchedHandlers } );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add the remaining (directly-bound) handlers\n\t\tcur = this;\n\t\tif ( delegateCount < handlers.length ) {\n\t\t\thandlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );\n\t\t}\n\n\t\treturn handlerQueue;\n\t},\n\n\taddProp: function( name, hook ) {\n\t\tObject.defineProperty( jQuery.Event.prototype, name, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\n\t\t\tget: isFunction( hook ) ?\n\t\t\t\tfunction() {\n\t\t\t\t\tif ( this.originalEvent ) {\n\t\t\t\t\t\treturn hook( this.originalEvent );\n\t\t\t\t\t}\n\t\t\t\t} :\n\t\t\t\tfunction() {\n\t\t\t\t\tif ( this.originalEvent ) {\n\t\t\t\t\t\treturn this.originalEvent[ name ];\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\tset: function( value ) {\n\t\t\t\tObject.defineProperty( this, name, {\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t\tvalue: value\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t},\n\n\tfix: function( originalEvent ) {\n\t\treturn originalEvent[ jQuery.expando ] ?\n\t\t\toriginalEvent :\n\t\t\tnew jQuery.Event( originalEvent );\n\t},\n\n\tspecial: {\n\t\tload: {\n\n\t\t\t// Prevent triggered image.load events from bubbling to window.load\n\t\t\tnoBubble: true\n\t\t},\n\t\tclick: {\n\n\t\t\t// Utilize native event to ensure correct state for checkable inputs\n\t\t\tsetup: function( data ) {\n\n\t\t\t\t// For mutual compressibility with _default, replace `this` access with a local var.\n\t\t\t\t// `|| data` is dead code meant only to preserve the variable through minification.\n\t\t\t\tvar el = this || data;\n\n\t\t\t\t// Claim the first handler\n\t\t\t\tif ( rcheckableType.test( el.type ) &&\n\t\t\t\t\tel.click && nodeName( el, \"input\" ) ) {\n\n\t\t\t\t\t// dataPriv.set( el, \"click\", ... )\n\t\t\t\t\tleverageNative( el, \"click\", returnTrue );\n\t\t\t\t}\n\n\t\t\t\t// Return false to allow normal processing in the caller\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\ttrigger: function( data ) {\n\n\t\t\t\t// For mutual compressibility with _default, replace `this` access with a local var.\n\t\t\t\t// `|| data` is dead code meant only to preserve the variable through minification.\n\t\t\t\tvar el = this || data;\n\n\t\t\t\t// Force setup before triggering a click\n\t\t\t\tif ( rcheckableType.test( el.type ) &&\n\t\t\t\t\tel.click && nodeName( el, \"input\" ) ) {\n\n\t\t\t\t\tleverageNative( el, \"click\" );\n\t\t\t\t}\n\n\t\t\t\t// Return non-false to allow normal event-path propagation\n\t\t\t\treturn true;\n\t\t\t},\n\n\t\t\t// For cross-browser consistency, suppress native .click() on links\n\t\t\t// Also prevent it if we're currently inside a leveraged native-event stack\n\t\t\t_default: function( event ) {\n\t\t\t\tvar target = event.target;\n\t\t\t\treturn rcheckableType.test( target.type ) &&\n\t\t\t\t\ttarget.click && nodeName( target, \"input\" ) &&\n\t\t\t\t\tdataPriv.get( target, \"click\" ) ||\n\t\t\t\t\tnodeName( target, \"a\" );\n\t\t\t}\n\t\t},\n\n\t\tbeforeunload: {\n\t\t\tpostDispatch: function( event ) {\n\n\t\t\t\t// Support: Firefox 20+\n\t\t\t\t// Firefox doesn't alert if the returnValue field is not set.\n\t\t\t\tif ( event.result !== undefined && event.originalEvent ) {\n\t\t\t\t\tevent.originalEvent.returnValue = event.result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Ensure the presence of an event listener that handles manually-triggered\n// synthetic events by interrupting progress until reinvoked in response to\n// *native* events that it fires directly, ensuring that state changes have\n// already occurred before other listeners are invoked.\nfunction leverageNative( el, type, expectSync ) {\n\n\t// Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add\n\tif ( !expectSync ) {\n\t\tif ( dataPriv.get( el, type ) === undefined ) {\n\t\t\tjQuery.event.add( el, type, returnTrue );\n\t\t}\n\t\treturn;\n\t}\n\n\t// Register the controller as a special universal handler for all event namespaces\n\tdataPriv.set( el, type, false );\n\tjQuery.event.add( el, type, {\n\t\tnamespace: false,\n\t\thandler: function( event ) {\n\t\t\tvar notAsync, result,\n\t\t\t\tsaved = dataPriv.get( this, type );\n\n\t\t\tif ( ( event.isTrigger & 1 ) && this[ type ] ) {\n\n\t\t\t\t// Interrupt processing of the outer synthetic .trigger()ed event\n\t\t\t\t// Saved data should be false in such cases, but might be a leftover capture object\n\t\t\t\t// from an async native handler (gh-4350)\n\t\t\t\tif ( !saved.length ) {\n\n\t\t\t\t\t// Store arguments for use when handling the inner native event\n\t\t\t\t\t// There will always be at least one argument (an event object), so this array\n\t\t\t\t\t// will not be confused with a leftover capture object.\n\t\t\t\t\tsaved = slice.call( arguments );\n\t\t\t\t\tdataPriv.set( this, type, saved );\n\n\t\t\t\t\t// Trigger the native event and capture its result\n\t\t\t\t\t// Support: IE <=9 - 11+\n\t\t\t\t\t// focus() and blur() are asynchronous\n\t\t\t\t\tnotAsync = expectSync( this, type );\n\t\t\t\t\tthis[ type ]();\n\t\t\t\t\tresult = dataPriv.get( this, type );\n\t\t\t\t\tif ( saved !== result || notAsync ) {\n\t\t\t\t\t\tdataPriv.set( this, type, false );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = {};\n\t\t\t\t\t}\n\t\t\t\t\tif ( saved !== result ) {\n\n\t\t\t\t\t\t// Cancel the outer synthetic event\n\t\t\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Support: Chrome 86+\n\t\t\t\t\t\t// In Chrome, if an element having a focusout handler is blurred by\n\t\t\t\t\t\t// clicking outside of it, it invokes the handler synchronously. If\n\t\t\t\t\t\t// that handler calls `.remove()` on the element, the data is cleared,\n\t\t\t\t\t\t// leaving `result` undefined. We need to guard against this.\n\t\t\t\t\t\treturn result && result.value;\n\t\t\t\t\t}\n\n\t\t\t\t// If this is an inner synthetic event for an event with a bubbling surrogate\n\t\t\t\t// (focus or blur), assume that the surrogate already propagated from triggering the\n\t\t\t\t// native event and prevent that from happening again here.\n\t\t\t\t// This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the\n\t\t\t\t// bubbling surrogate propagates *after* the non-bubbling base), but that seems\n\t\t\t\t// less bad than duplication.\n\t\t\t\t} else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t}\n\n\t\t\t// If this is a native event triggered above, everything is now in order\n\t\t\t// Fire an inner synthetic event with the original arguments\n\t\t\t} else if ( saved.length ) {\n\n\t\t\t\t// ...and capture the result\n\t\t\t\tdataPriv.set( this, type, {\n\t\t\t\t\tvalue: jQuery.event.trigger(\n\n\t\t\t\t\t\t// Support: IE <=9 - 11+\n\t\t\t\t\t\t// Extend with the prototype to reset the above stopImmediatePropagation()\n\t\t\t\t\t\tjQuery.extend( saved[ 0 ], jQuery.Event.prototype ),\n\t\t\t\t\t\tsaved.slice( 1 ),\n\t\t\t\t\t\tthis\n\t\t\t\t\t)\n\t\t\t\t} );\n\n\t\t\t\t// Abort handling of the native event\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t}\n\t\t}\n\t} );\n}\n\njQuery.removeEvent = function( elem, type, handle ) {\n\n\t// This \"if\" is needed for plain objects\n\tif ( elem.removeEventListener ) {\n\t\telem.removeEventListener( type, handle );\n\t}\n};\n\njQuery.Event = function( src, props ) {\n\n\t// Allow instantiation without the 'new' keyword\n\tif ( !( this instanceof jQuery.Event ) ) {\n\t\treturn new jQuery.Event( src, props );\n\t}\n\n\t// Event object\n\tif ( src && src.type ) {\n\t\tthis.originalEvent = src;\n\t\tthis.type = src.type;\n\n\t\t// Events bubbling up the document may have been marked as prevented\n\t\t// by a handler lower down the tree; reflect the correct value.\n\t\tthis.isDefaultPrevented = src.defaultPrevented ||\n\t\t\t\tsrc.defaultPrevented === undefined &&\n\n\t\t\t\t// Support: Android <=2.3 only\n\t\t\t\tsrc.returnValue === false ?\n\t\t\treturnTrue :\n\t\t\treturnFalse;\n\n\t\t// Create target properties\n\t\t// Support: Safari <=6 - 7 only\n\t\t// Target should not be a text node (trac-504, trac-13143)\n\t\tthis.target = ( src.target && src.target.nodeType === 3 ) ?\n\t\t\tsrc.target.parentNode :\n\t\t\tsrc.target;\n\n\t\tthis.currentTarget = src.currentTarget;\n\t\tthis.relatedTarget = src.relatedTarget;\n\n\t// Event type\n\t} else {\n\t\tthis.type = src;\n\t}\n\n\t// Put explicitly provided properties onto the event object\n\tif ( props ) {\n\t\tjQuery.extend( this, props );\n\t}\n\n\t// Create a timestamp if incoming event doesn't have one\n\tthis.timeStamp = src && src.timeStamp || Date.now();\n\n\t// Mark it as fixed\n\tthis[ jQuery.expando ] = true;\n};\n\n// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding\n// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html\njQuery.Event.prototype = {\n\tconstructor: jQuery.Event,\n\tisDefaultPrevented: returnFalse,\n\tisPropagationStopped: returnFalse,\n\tisImmediatePropagationStopped: returnFalse,\n\tisSimulated: false,\n\n\tpreventDefault: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isDefaultPrevented = returnTrue;\n\n\t\tif ( e && !this.isSimulated ) {\n\t\t\te.preventDefault();\n\t\t}\n\t},\n\tstopPropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isPropagationStopped = returnTrue;\n\n\t\tif ( e && !this.isSimulated ) {\n\t\t\te.stopPropagation();\n\t\t}\n\t},\n\tstopImmediatePropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isImmediatePropagationStopped = returnTrue;\n\n\t\tif ( e && !this.isSimulated ) {\n\t\t\te.stopImmediatePropagation();\n\t\t}\n\n\t\tthis.stopPropagation();\n\t}\n};\n\n// Includes all common event props including KeyEvent and MouseEvent specific props\njQuery.each( {\n\taltKey: true,\n\tbubbles: true,\n\tcancelable: true,\n\tchangedTouches: true,\n\tctrlKey: true,\n\tdetail: true,\n\teventPhase: true,\n\tmetaKey: true,\n\tpageX: true,\n\tpageY: true,\n\tshiftKey: true,\n\tview: true,\n\t\"char\": true,\n\tcode: true,\n\tcharCode: true,\n\tkey: true,\n\tkeyCode: true,\n\tbutton: true,\n\tbuttons: true,\n\tclientX: true,\n\tclientY: true,\n\toffsetX: true,\n\toffsetY: true,\n\tpointerId: true,\n\tpointerType: true,\n\tscreenX: true,\n\tscreenY: true,\n\ttargetTouches: true,\n\ttoElement: true,\n\ttouches: true,\n\twhich: true\n}, jQuery.event.addProp );\n\njQuery.each( { focus: \"focusin\", blur: \"focusout\" }, function( type, delegateType ) {\n\tjQuery.event.special[ type ] = {\n\n\t\t// Utilize native event if possible so blur/focus sequence is correct\n\t\tsetup: function() {\n\n\t\t\t// Claim the first handler\n\t\t\t// dataPriv.set( this, \"focus\", ... )\n\t\t\t// dataPriv.set( this, \"blur\", ... )\n\t\t\tleverageNative( this, type, expectSync );\n\n\t\t\t// Return false to allow normal processing in the caller\n\t\t\treturn false;\n\t\t},\n\t\ttrigger: function() {\n\n\t\t\t// Force setup before trigger\n\t\t\tleverageNative( this, type );\n\n\t\t\t// Return non-false to allow normal event-path propagation\n\t\t\treturn true;\n\t\t},\n\n\t\t// Suppress native focus or blur if we're currently inside\n\t\t// a leveraged native-event stack\n\t\t_default: function( event ) {\n\t\t\treturn dataPriv.get( event.target, type );\n\t\t},\n\n\t\tdelegateType: delegateType\n\t};\n} );\n\n// Create mouseenter/leave events using mouseover/out and event-time checks\n// so that event delegation works in jQuery.\n// Do the same for pointerenter/pointerleave and pointerover/pointerout\n//\n// Support: Safari 7 only\n// Safari sends mouseenter too often; see:\n// https://bugs.chromium.org/p/chromium/issues/detail?id=470258\n// for the description of the bug (it existed in older Chrome versions as well).\njQuery.each( {\n\tmouseenter: \"mouseover\",\n\tmouseleave: \"mouseout\",\n\tpointerenter: \"pointerover\",\n\tpointerleave: \"pointerout\"\n}, function( orig, fix ) {\n\tjQuery.event.special[ orig ] = {\n\t\tdelegateType: fix,\n\t\tbindType: fix,\n\n\t\thandle: function( event ) {\n\t\t\tvar ret,\n\t\t\t\ttarget = this,\n\t\t\t\trelated = event.relatedTarget,\n\t\t\t\thandleObj = event.handleObj;\n\n\t\t\t// For mouseenter/leave call the handler if related is outside the target.\n\t\t\t// NB: No relatedTarget if the mouse left/entered the browser window\n\t\t\tif ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {\n\t\t\t\tevent.type = handleObj.origType;\n\t\t\t\tret = handleObj.handler.apply( this, arguments );\n\t\t\t\tevent.type = fix;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t};\n} );\n\njQuery.fn.extend( {\n\n\ton: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn );\n\t},\n\tone: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn, 1 );\n\t},\n\toff: function( types, selector, fn ) {\n\t\tvar handleObj, type;\n\t\tif ( types && types.preventDefault && types.handleObj ) {\n\n\t\t\t// ( event )  dispatched jQuery.Event\n\t\t\thandleObj = types.handleObj;\n\t\t\tjQuery( types.delegateTarget ).off(\n\t\t\t\thandleObj.namespace ?\n\t\t\t\t\thandleObj.origType + \".\" + handleObj.namespace :\n\t\t\t\t\thandleObj.origType,\n\t\t\t\thandleObj.selector,\n\t\t\t\thandleObj.handler\n\t\t\t);\n\t\t\treturn this;\n\t\t}\n\t\tif ( typeof types === \"object\" ) {\n\n\t\t\t// ( types-object [, selector] )\n\t\t\tfor ( type in types ) {\n\t\t\t\tthis.off( type, selector, types[ type ] );\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\tif ( selector === false || typeof selector === \"function\" ) {\n\n\t\t\t// ( types [, fn] )\n\t\t\tfn = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tif ( fn === false ) {\n\t\t\tfn = returnFalse;\n\t\t}\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.remove( this, types, fn, selector );\n\t\t} );\n\t}\n} );\n\n\nvar\n\n\t// Support: IE <=10 - 11, Edge 12 - 13 only\n\t// In IE/Edge using regex groups here causes severe slowdowns.\n\t// See https://connect.microsoft.com/IE/feedback/details/1736512/\n\trnoInnerhtml = /<script|<style|<link/i,\n\n\t// checked=\"checked\" or checked\n\trchecked = /checked\\s*(?:[^=]|=\\s*.checked.)/i,\n\n\trcleanScript = /^\\s*<!\\[CDATA\\[|\\]\\]>\\s*$/g;\n\n// Prefer a tbody over its parent table for containing new rows\nfunction manipulationTarget( elem, content ) {\n\tif ( nodeName( elem, \"table\" ) &&\n\t\tnodeName( content.nodeType !== 11 ? content : content.firstChild, \"tr\" ) ) {\n\n\t\treturn jQuery( elem ).children( \"tbody\" )[ 0 ] || elem;\n\t}\n\n\treturn elem;\n}\n\n// Replace/restore the type attribute of script elements for safe DOM manipulation\nfunction disableScript( elem ) {\n\telem.type = ( elem.getAttribute( \"type\" ) !== null ) + \"/\" + elem.type;\n\treturn elem;\n}\nfunction restoreScript( elem ) {\n\tif ( ( elem.type || \"\" ).slice( 0, 5 ) === \"true/\" ) {\n\t\telem.type = elem.type.slice( 5 );\n\t} else {\n\t\telem.removeAttribute( \"type\" );\n\t}\n\n\treturn elem;\n}\n\nfunction cloneCopyEvent( src, dest ) {\n\tvar i, l, type, pdataOld, udataOld, udataCur, events;\n\n\tif ( dest.nodeType !== 1 ) {\n\t\treturn;\n\t}\n\n\t// 1. Copy private data: events, handlers, etc.\n\tif ( dataPriv.hasData( src ) ) {\n\t\tpdataOld = dataPriv.get( src );\n\t\tevents = pdataOld.events;\n\n\t\tif ( events ) {\n\t\t\tdataPriv.remove( dest, \"handle events\" );\n\n\t\t\tfor ( type in events ) {\n\t\t\t\tfor ( i = 0, l = events[ type ].length; i < l; i++ ) {\n\t\t\t\t\tjQuery.event.add( dest, type, events[ type ][ i ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Copy user data\n\tif ( dataUser.hasData( src ) ) {\n\t\tudataOld = dataUser.access( src );\n\t\tudataCur = jQuery.extend( {}, udataOld );\n\n\t\tdataUser.set( dest, udataCur );\n\t}\n}\n\n// Fix IE bugs, see support tests\nfunction fixInput( src, dest ) {\n\tvar nodeName = dest.nodeName.toLowerCase();\n\n\t// Fails to persist the checked state of a cloned checkbox or radio button.\n\tif ( nodeName === \"input\" && rcheckableType.test( src.type ) ) {\n\t\tdest.checked = src.checked;\n\n\t// Fails to return the selected option to the default selected state when cloning options\n\t} else if ( nodeName === \"input\" || nodeName === \"textarea\" ) {\n\t\tdest.defaultValue = src.defaultValue;\n\t}\n}\n\nfunction domManip( collection, args, callback, ignored ) {\n\n\t// Flatten any nested arrays\n\targs = flat( args );\n\n\tvar fragment, first, scripts, hasScripts, node, doc,\n\t\ti = 0,\n\t\tl = collection.length,\n\t\tiNoClone = l - 1,\n\t\tvalue = args[ 0 ],\n\t\tvalueIsFunction = isFunction( value );\n\n\t// We can't cloneNode fragments that contain checked, in WebKit\n\tif ( valueIsFunction ||\n\t\t\t( l > 1 && typeof value === \"string\" &&\n\t\t\t\t!support.checkClone && rchecked.test( value ) ) ) {\n\t\treturn collection.each( function( index ) {\n\t\t\tvar self = collection.eq( index );\n\t\t\tif ( valueIsFunction ) {\n\t\t\t\targs[ 0 ] = value.call( this, index, self.html() );\n\t\t\t}\n\t\t\tdomManip( self, args, callback, ignored );\n\t\t} );\n\t}\n\n\tif ( l ) {\n\t\tfragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );\n\t\tfirst = fragment.firstChild;\n\n\t\tif ( fragment.childNodes.length === 1 ) {\n\t\t\tfragment = first;\n\t\t}\n\n\t\t// Require either new content or an interest in ignored elements to invoke the callback\n\t\tif ( first || ignored ) {\n\t\t\tscripts = jQuery.map( getAll( fragment, \"script\" ), disableScript );\n\t\t\thasScripts = scripts.length;\n\n\t\t\t// Use the original fragment for the last item\n\t\t\t// instead of the first because it can end up\n\t\t\t// being emptied incorrectly in certain situations (trac-8070).\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tnode = fragment;\n\n\t\t\t\tif ( i !== iNoClone ) {\n\t\t\t\t\tnode = jQuery.clone( node, true, true );\n\n\t\t\t\t\t// Keep references to cloned scripts for later restoration\n\t\t\t\t\tif ( hasScripts ) {\n\n\t\t\t\t\t\t// Support: Android <=4.0 only, PhantomJS 1 only\n\t\t\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\t\t\tjQuery.merge( scripts, getAll( node, \"script\" ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcallback.call( collection[ i ], node, i );\n\t\t\t}\n\n\t\t\tif ( hasScripts ) {\n\t\t\t\tdoc = scripts[ scripts.length - 1 ].ownerDocument;\n\n\t\t\t\t// Reenable scripts\n\t\t\t\tjQuery.map( scripts, restoreScript );\n\n\t\t\t\t// Evaluate executable scripts on first document insertion\n\t\t\t\tfor ( i = 0; i < hasScripts; i++ ) {\n\t\t\t\t\tnode = scripts[ i ];\n\t\t\t\t\tif ( rscriptType.test( node.type || \"\" ) &&\n\t\t\t\t\t\t!dataPriv.access( node, \"globalEval\" ) &&\n\t\t\t\t\t\tjQuery.contains( doc, node ) ) {\n\n\t\t\t\t\t\tif ( node.src && ( node.type || \"\" ).toLowerCase()  !== \"module\" ) {\n\n\t\t\t\t\t\t\t// Optional AJAX dependency, but won't run scripts if not present\n\t\t\t\t\t\t\tif ( jQuery._evalUrl && !node.noModule ) {\n\t\t\t\t\t\t\t\tjQuery._evalUrl( node.src, {\n\t\t\t\t\t\t\t\t\tnonce: node.nonce || node.getAttribute( \"nonce\" )\n\t\t\t\t\t\t\t\t}, doc );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// Unwrap a CDATA section containing script contents. This shouldn't be\n\t\t\t\t\t\t\t// needed as in XML documents they're already not visible when\n\t\t\t\t\t\t\t// inspecting element contents and in HTML documents they have no\n\t\t\t\t\t\t\t// meaning but we're preserving that logic for backwards compatibility.\n\t\t\t\t\t\t\t// This will be removed completely in 4.0. See gh-4904.\n\t\t\t\t\t\t\tDOMEval( node.textContent.replace( rcleanScript, \"\" ), node, doc );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn collection;\n}\n\nfunction remove( elem, selector, keepData ) {\n\tvar node,\n\t\tnodes = selector ? jQuery.filter( selector, elem ) : elem,\n\t\ti = 0;\n\n\tfor ( ; ( node = nodes[ i ] ) != null; i++ ) {\n\t\tif ( !keepData && node.nodeType === 1 ) {\n\t\t\tjQuery.cleanData( getAll( node ) );\n\t\t}\n\n\t\tif ( node.parentNode ) {\n\t\t\tif ( keepData && isAttached( node ) ) {\n\t\t\t\tsetGlobalEval( getAll( node, \"script\" ) );\n\t\t\t}\n\t\t\tnode.parentNode.removeChild( node );\n\t\t}\n\t}\n\n\treturn elem;\n}\n\njQuery.extend( {\n\thtmlPrefilter: function( html ) {\n\t\treturn html;\n\t},\n\n\tclone: function( elem, dataAndEvents, deepDataAndEvents ) {\n\t\tvar i, l, srcElements, destElements,\n\t\t\tclone = elem.cloneNode( true ),\n\t\t\tinPage = isAttached( elem );\n\n\t\t// Fix IE cloning issues\n\t\tif ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&\n\t\t\t\t!jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2\n\t\t\tdestElements = getAll( clone );\n\t\t\tsrcElements = getAll( elem );\n\n\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\tfixInput( srcElements[ i ], destElements[ i ] );\n\t\t\t}\n\t\t}\n\n\t\t// Copy the events from the original to the clone\n\t\tif ( dataAndEvents ) {\n\t\t\tif ( deepDataAndEvents ) {\n\t\t\t\tsrcElements = srcElements || getAll( elem );\n\t\t\t\tdestElements = destElements || getAll( clone );\n\n\t\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\t\tcloneCopyEvent( srcElements[ i ], destElements[ i ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcloneCopyEvent( elem, clone );\n\t\t\t}\n\t\t}\n\n\t\t// Preserve script evaluation history\n\t\tdestElements = getAll( clone, \"script\" );\n\t\tif ( destElements.length > 0 ) {\n\t\t\tsetGlobalEval( destElements, !inPage && getAll( elem, \"script\" ) );\n\t\t}\n\n\t\t// Return the cloned set\n\t\treturn clone;\n\t},\n\n\tcleanData: function( elems ) {\n\t\tvar data, elem, type,\n\t\t\tspecial = jQuery.event.special,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {\n\t\t\tif ( acceptData( elem ) ) {\n\t\t\t\tif ( ( data = elem[ dataPriv.expando ] ) ) {\n\t\t\t\t\tif ( data.events ) {\n\t\t\t\t\t\tfor ( type in data.events ) {\n\t\t\t\t\t\t\tif ( special[ type ] ) {\n\t\t\t\t\t\t\t\tjQuery.event.remove( elem, type );\n\n\t\t\t\t\t\t\t// This is a shortcut to avoid jQuery.event.remove's overhead\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tjQuery.removeEvent( elem, type, data.handle );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Support: Chrome <=35 - 45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataPriv.expando ] = undefined;\n\t\t\t\t}\n\t\t\t\tif ( elem[ dataUser.expando ] ) {\n\n\t\t\t\t\t// Support: Chrome <=35 - 45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataUser.expando ] = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n} );\n\njQuery.fn.extend( {\n\tdetach: function( selector ) {\n\t\treturn remove( this, selector, true );\n\t},\n\n\tremove: function( selector ) {\n\t\treturn remove( this, selector );\n\t},\n\n\ttext: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\treturn value === undefined ?\n\t\t\t\tjQuery.text( this ) :\n\t\t\t\tthis.empty().each( function() {\n\t\t\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\t\t\tthis.textContent = value;\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t}, null, value, arguments.length );\n\t},\n\n\tappend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.appendChild( elem );\n\t\t\t}\n\t\t} );\n\t},\n\n\tprepend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.insertBefore( elem, target.firstChild );\n\t\t\t}\n\t\t} );\n\t},\n\n\tbefore: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this );\n\t\t\t}\n\t\t} );\n\t},\n\n\tafter: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this.nextSibling );\n\t\t\t}\n\t\t} );\n\t},\n\n\tempty: function() {\n\t\tvar elem,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = this[ i ] ) != null; i++ ) {\n\t\t\tif ( elem.nodeType === 1 ) {\n\n\t\t\t\t// Prevent memory leaks\n\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\n\t\t\t\t// Remove any remaining nodes\n\t\t\t\telem.textContent = \"\";\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tclone: function( dataAndEvents, deepDataAndEvents ) {\n\t\tdataAndEvents = dataAndEvents == null ? false : dataAndEvents;\n\t\tdeepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;\n\n\t\treturn this.map( function() {\n\t\t\treturn jQuery.clone( this, dataAndEvents, deepDataAndEvents );\n\t\t} );\n\t},\n\n\thtml: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\tvar elem = this[ 0 ] || {},\n\t\t\t\ti = 0,\n\t\t\t\tl = this.length;\n\n\t\t\tif ( value === undefined && elem.nodeType === 1 ) {\n\t\t\t\treturn elem.innerHTML;\n\t\t\t}\n\n\t\t\t// See if we can take a shortcut and just use innerHTML\n\t\t\tif ( typeof value === \"string\" && !rnoInnerhtml.test( value ) &&\n\t\t\t\t!wrapMap[ ( rtagName.exec( value ) || [ \"\", \"\" ] )[ 1 ].toLowerCase() ] ) {\n\n\t\t\t\tvalue = jQuery.htmlPrefilter( value );\n\n\t\t\t\ttry {\n\t\t\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\t\t\telem = this[ i ] || {};\n\n\t\t\t\t\t\t// Remove element nodes and prevent memory leaks\n\t\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\t\t\t\t\t\t\telem.innerHTML = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\telem = 0;\n\n\t\t\t\t// If using innerHTML throws an exception, use the fallback method\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\tif ( elem ) {\n\t\t\t\tthis.empty().append( value );\n\t\t\t}\n\t\t}, null, value, arguments.length );\n\t},\n\n\treplaceWith: function() {\n\t\tvar ignored = [];\n\n\t\t// Make the changes, replacing each non-ignored context element with the new content\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tvar parent = this.parentNode;\n\n\t\t\tif ( jQuery.inArray( this, ignored ) < 0 ) {\n\t\t\t\tjQuery.cleanData( getAll( this ) );\n\t\t\t\tif ( parent ) {\n\t\t\t\t\tparent.replaceChild( elem, this );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Force callback invocation\n\t\t}, ignored );\n\t}\n} );\n\njQuery.each( {\n\tappendTo: \"append\",\n\tprependTo: \"prepend\",\n\tinsertBefore: \"before\",\n\tinsertAfter: \"after\",\n\treplaceAll: \"replaceWith\"\n}, function( name, original ) {\n\tjQuery.fn[ name ] = function( selector ) {\n\t\tvar elems,\n\t\t\tret = [],\n\t\t\tinsert = jQuery( selector ),\n\t\t\tlast = insert.length - 1,\n\t\t\ti = 0;\n\n\t\tfor ( ; i <= last; i++ ) {\n\t\t\telems = i === last ? this : this.clone( true );\n\t\t\tjQuery( insert[ i ] )[ original ]( elems );\n\n\t\t\t// Support: Android <=4.0 only, PhantomJS 1 only\n\t\t\t// .get() because push.apply(_, arraylike) throws on ancient WebKit\n\t\t\tpush.apply( ret, elems.get() );\n\t\t}\n\n\t\treturn this.pushStack( ret );\n\t};\n} );\nvar rnumnonpx = new RegExp( \"^(\" + pnum + \")(?!px)[a-z%]+$\", \"i\" );\n\nvar rcustomProp = /^--/;\n\n\nvar getStyles = function( elem ) {\n\n\t\t// Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)\n\t\t// IE throws on elements created in popups\n\t\t// FF meanwhile throws on frame elements through \"defaultView.getComputedStyle\"\n\t\tvar view = elem.ownerDocument.defaultView;\n\n\t\tif ( !view || !view.opener ) {\n\t\t\tview = window;\n\t\t}\n\n\t\treturn view.getComputedStyle( elem );\n\t};\n\nvar swap = function( elem, options, callback ) {\n\tvar ret, name,\n\t\told = {};\n\n\t// Remember the old values, and insert the new ones\n\tfor ( name in options ) {\n\t\told[ name ] = elem.style[ name ];\n\t\telem.style[ name ] = options[ name ];\n\t}\n\n\tret = callback.call( elem );\n\n\t// Revert the old values\n\tfor ( name in options ) {\n\t\telem.style[ name ] = old[ name ];\n\t}\n\n\treturn ret;\n};\n\n\nvar rboxStyle = new RegExp( cssExpand.join( \"|\" ), \"i\" );\n\nvar whitespace = \"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\";\n\n\nvar rtrimCSS = new RegExp(\n\t\"^\" + whitespace + \"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\" + whitespace + \"+$\",\n\t\"g\"\n);\n\n\n\n\n( function() {\n\n\t// Executing both pixelPosition & boxSizingReliable tests require only one layout\n\t// so they're executed at the same time to save the second computation.\n\tfunction computeStyleTests() {\n\n\t\t// This is a singleton, we need to execute it only once\n\t\tif ( !div ) {\n\t\t\treturn;\n\t\t}\n\n\t\tcontainer.style.cssText = \"position:absolute;left:-11111px;width:60px;\" +\n\t\t\t\"margin-top:1px;padding:0;border:0\";\n\t\tdiv.style.cssText =\n\t\t\t\"position:relative;display:block;box-sizing:border-box;overflow:scroll;\" +\n\t\t\t\"margin:auto;border:1px;padding:1px;\" +\n\t\t\t\"width:60%;top:1%\";\n\t\tdocumentElement.appendChild( container ).appendChild( div );\n\n\t\tvar divStyle = window.getComputedStyle( div );\n\t\tpixelPositionVal = divStyle.top !== \"1%\";\n\n\t\t// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44\n\t\treliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;\n\n\t\t// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3\n\t\t// Some styles come back with percentage values, even though they shouldn't\n\t\tdiv.style.right = \"60%\";\n\t\tpixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;\n\n\t\t// Support: IE 9 - 11 only\n\t\t// Detect misreporting of content dimensions for box-sizing:border-box elements\n\t\tboxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;\n\n\t\t// Support: IE 9 only\n\t\t// Detect overflow:scroll screwiness (gh-3699)\n\t\t// Support: Chrome <=64\n\t\t// Don't get tricked when zoom affects offsetWidth (gh-4029)\n\t\tdiv.style.position = \"absolute\";\n\t\tscrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;\n\n\t\tdocumentElement.removeChild( container );\n\n\t\t// Nullify the div so it wouldn't be stored in the memory and\n\t\t// it will also be a sign that checks already performed\n\t\tdiv = null;\n\t}\n\n\tfunction roundPixelMeasures( measure ) {\n\t\treturn Math.round( parseFloat( measure ) );\n\t}\n\n\tvar pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,\n\t\treliableTrDimensionsVal, reliableMarginLeftVal,\n\t\tcontainer = document.createElement( \"div\" ),\n\t\tdiv = document.createElement( \"div\" );\n\n\t// Finish early in limited (non-browser) environments\n\tif ( !div.style ) {\n\t\treturn;\n\t}\n\n\t// Support: IE <=9 - 11 only\n\t// Style of cloned element affects source element cloned (trac-8908)\n\tdiv.style.backgroundClip = \"content-box\";\n\tdiv.cloneNode( true ).style.backgroundClip = \"\";\n\tsupport.clearCloneStyle = div.style.backgroundClip === \"content-box\";\n\n\tjQuery.extend( support, {\n\t\tboxSizingReliable: function() {\n\t\t\tcomputeStyleTests();\n\t\t\treturn boxSizingReliableVal;\n\t\t},\n\t\tpixelBoxStyles: function() {\n\t\t\tcomputeStyleTests();\n\t\t\treturn pixelBoxStylesVal;\n\t\t},\n\t\tpixelPosition: function() {\n\t\t\tcomputeStyleTests();\n\t\t\treturn pixelPositionVal;\n\t\t},\n\t\treliableMarginLeft: function() {\n\t\t\tcomputeStyleTests();\n\t\t\treturn reliableMarginLeftVal;\n\t\t},\n\t\tscrollboxSize: function() {\n\t\t\tcomputeStyleTests();\n\t\t\treturn scrollboxSizeVal;\n\t\t},\n\n\t\t// Support: IE 9 - 11+, Edge 15 - 18+\n\t\t// IE/Edge misreport `getComputedStyle` of table rows with width/height\n\t\t// set in CSS while `offset*` properties report correct values.\n\t\t// Behavior in IE 9 is more subtle than in newer versions & it passes\n\t\t// some versions of this test; make sure not to make it pass there!\n\t\t//\n\t\t// Support: Firefox 70+\n\t\t// Only Firefox includes border widths\n\t\t// in computed dimensions. (gh-4529)\n\t\treliableTrDimensions: function() {\n\t\t\tvar table, tr, trChild, trStyle;\n\t\t\tif ( reliableTrDimensionsVal == null ) {\n\t\t\t\ttable = document.createElement( \"table\" );\n\t\t\t\ttr = document.createElement( \"tr\" );\n\t\t\t\ttrChild = document.createElement( \"div\" );\n\n\t\t\t\ttable.style.cssText = \"position:absolute;left:-11111px;border-collapse:separate\";\n\t\t\t\ttr.style.cssText = \"border:1px solid\";\n\n\t\t\t\t// Support: Chrome 86+\n\t\t\t\t// Height set through cssText does not get applied.\n\t\t\t\t// Computed height then comes back as 0.\n\t\t\t\ttr.style.height = \"1px\";\n\t\t\t\ttrChild.style.height = \"9px\";\n\n\t\t\t\t// Support: Android 8 Chrome 86+\n\t\t\t\t// In our bodyBackground.html iframe,\n\t\t\t\t// display for all div elements is set to \"inline\",\n\t\t\t\t// which causes a problem only in Android 8 Chrome 86.\n\t\t\t\t// Ensuring the div is display: block\n\t\t\t\t// gets around this issue.\n\t\t\t\ttrChild.style.display = \"block\";\n\n\t\t\t\tdocumentElement\n\t\t\t\t\t.appendChild( table )\n\t\t\t\t\t.appendChild( tr )\n\t\t\t\t\t.appendChild( trChild );\n\n\t\t\t\ttrStyle = window.getComputedStyle( tr );\n\t\t\t\treliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +\n\t\t\t\t\tparseInt( trStyle.borderTopWidth, 10 ) +\n\t\t\t\t\tparseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;\n\n\t\t\t\tdocumentElement.removeChild( table );\n\t\t\t}\n\t\t\treturn reliableTrDimensionsVal;\n\t\t}\n\t} );\n} )();\n\n\nfunction curCSS( elem, name, computed ) {\n\tvar width, minWidth, maxWidth, ret,\n\t\tisCustomProp = rcustomProp.test( name ),\n\n\t\t// Support: Firefox 51+\n\t\t// Retrieving style before computed somehow\n\t\t// fixes an issue with getting wrong values\n\t\t// on detached elements\n\t\tstyle = elem.style;\n\n\tcomputed = computed || getStyles( elem );\n\n\t// getPropertyValue is needed for:\n\t//   .css('filter') (IE 9 only, trac-12537)\n\t//   .css('--customProperty) (gh-3144)\n\tif ( computed ) {\n\n\t\t// Support: IE <=9 - 11+\n\t\t// IE only supports `\"float\"` in `getPropertyValue`; in computed styles\n\t\t// it's only available as `\"cssFloat\"`. We no longer modify properties\n\t\t// sent to `.css()` apart from camelCasing, so we need to check both.\n\t\t// Normally, this would create difference in behavior: if\n\t\t// `getPropertyValue` returns an empty string, the value returned\n\t\t// by `.css()` would be `undefined`. This is usually the case for\n\t\t// disconnected elements. However, in IE even disconnected elements\n\t\t// with no styles return `\"none\"` for `getPropertyValue( \"float\" )`\n\t\tret = computed.getPropertyValue( name ) || computed[ name ];\n\n\t\tif ( isCustomProp && ret ) {\n\n\t\t\t// Support: Firefox 105+, Chrome <=105+\n\t\t\t// Spec requires trimming whitespace for custom properties (gh-4926).\n\t\t\t// Firefox only trims leading whitespace. Chrome just collapses\n\t\t\t// both leading & trailing whitespace to a single space.\n\t\t\t//\n\t\t\t// Fall back to `undefined` if empty string returned.\n\t\t\t// This collapses a missing definition with property defined\n\t\t\t// and set to an empty string but there's no standard API\n\t\t\t// allowing us to differentiate them without a performance penalty\n\t\t\t// and returning `undefined` aligns with older jQuery.\n\t\t\t//\n\t\t\t// rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED\n\t\t\t// as whitespace while CSS does not, but this is not a problem\n\t\t\t// because CSS preprocessing replaces them with U+000A LINE FEED\n\t\t\t// (which *is* CSS whitespace)\n\t\t\t// https://www.w3.org/TR/css-syntax-3/#input-preprocessing\n\t\t\tret = ret.replace( rtrimCSS, \"$1\" ) || undefined;\n\t\t}\n\n\t\tif ( ret === \"\" && !isAttached( elem ) ) {\n\t\t\tret = jQuery.style( elem, name );\n\t\t}\n\n\t\t// A tribute to the \"awesome hack by Dean Edwards\"\n\t\t// Android Browser returns percentage for some values,\n\t\t// but width seems to be reliably pixels.\n\t\t// This is against the CSSOM draft spec:\n\t\t// https://drafts.csswg.org/cssom/#resolved-values\n\t\tif ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {\n\n\t\t\t// Remember the original values\n\t\t\twidth = style.width;\n\t\t\tminWidth = style.minWidth;\n\t\t\tmaxWidth = style.maxWidth;\n\n\t\t\t// Put in the new values to get a computed value out\n\t\t\tstyle.minWidth = style.maxWidth = style.width = ret;\n\t\t\tret = computed.width;\n\n\t\t\t// Revert the changed values\n\t\t\tstyle.width = width;\n\t\t\tstyle.minWidth = minWidth;\n\t\t\tstyle.maxWidth = maxWidth;\n\t\t}\n\t}\n\n\treturn ret !== undefined ?\n\n\t\t// Support: IE <=9 - 11 only\n\t\t// IE returns zIndex value as an integer.\n\t\tret + \"\" :\n\t\tret;\n}\n\n\nfunction addGetHookIf( conditionFn, hookFn ) {\n\n\t// Define the hook, we'll check on the first run if it's really needed.\n\treturn {\n\t\tget: function() {\n\t\t\tif ( conditionFn() ) {\n\n\t\t\t\t// Hook not needed (or it's not possible to use it due\n\t\t\t\t// to missing dependency), remove it.\n\t\t\t\tdelete this.get;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Hook needed; redefine it so that the support test is not executed again.\n\t\t\treturn ( this.get = hookFn ).apply( this, arguments );\n\t\t}\n\t};\n}\n\n\nvar cssPrefixes = [ \"Webkit\", \"Moz\", \"ms\" ],\n\temptyStyle = document.createElement( \"div\" ).style,\n\tvendorProps = {};\n\n// Return a vendor-prefixed property or undefined\nfunction vendorPropName( name ) {\n\n\t// Check for vendor prefixed names\n\tvar capName = name[ 0 ].toUpperCase() + name.slice( 1 ),\n\t\ti = cssPrefixes.length;\n\n\twhile ( i-- ) {\n\t\tname = cssPrefixes[ i ] + capName;\n\t\tif ( name in emptyStyle ) {\n\t\t\treturn name;\n\t\t}\n\t}\n}\n\n// Return a potentially-mapped jQuery.cssProps or vendor prefixed property\nfunction finalPropName( name ) {\n\tvar final = jQuery.cssProps[ name ] || vendorProps[ name ];\n\n\tif ( final ) {\n\t\treturn final;\n\t}\n\tif ( name in emptyStyle ) {\n\t\treturn name;\n\t}\n\treturn vendorProps[ name ] = vendorPropName( name ) || name;\n}\n\n\nvar\n\n\t// Swappable if display is none or starts with table\n\t// except \"table\", \"table-cell\", or \"table-caption\"\n\t// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display\n\trdisplayswap = /^(none|table(?!-c[ea]).+)/,\n\tcssShow = { position: \"absolute\", visibility: \"hidden\", display: \"block\" },\n\tcssNormalTransform = {\n\t\tletterSpacing: \"0\",\n\t\tfontWeight: \"400\"\n\t};\n\nfunction setPositiveNumber( _elem, value, subtract ) {\n\n\t// Any relative (+/-) values have already been\n\t// normalized at this point\n\tvar matches = rcssNum.exec( value );\n\treturn matches ?\n\n\t\t// Guard against undefined \"subtract\", e.g., when used as in cssHooks\n\t\tMath.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || \"px\" ) :\n\t\tvalue;\n}\n\nfunction boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {\n\tvar i = dimension === \"width\" ? 1 : 0,\n\t\textra = 0,\n\t\tdelta = 0;\n\n\t// Adjustment may not be necessary\n\tif ( box === ( isBorderBox ? \"border\" : \"content\" ) ) {\n\t\treturn 0;\n\t}\n\n\tfor ( ; i < 4; i += 2 ) {\n\n\t\t// Both box models exclude margin\n\t\tif ( box === \"margin\" ) {\n\t\t\tdelta += jQuery.css( elem, box + cssExpand[ i ], true, styles );\n\t\t}\n\n\t\t// If we get here with a content-box, we're seeking \"padding\" or \"border\" or \"margin\"\n\t\tif ( !isBorderBox ) {\n\n\t\t\t// Add padding\n\t\t\tdelta += jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\n\t\t\t// For \"border\" or \"margin\", add border\n\t\t\tif ( box !== \"padding\" ) {\n\t\t\t\tdelta += jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\n\t\t\t// But still keep track of it otherwise\n\t\t\t} else {\n\t\t\t\textra += jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\n\t\t// If we get here with a border-box (content + padding + border), we're seeking \"content\" or\n\t\t// \"padding\" or \"margin\"\n\t\t} else {\n\n\t\t\t// For \"content\", subtract padding\n\t\t\tif ( box === \"content\" ) {\n\t\t\t\tdelta -= jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\t\t\t}\n\n\t\t\t// For \"content\" or \"padding\", subtract border\n\t\t\tif ( box !== \"margin\" ) {\n\t\t\t\tdelta -= jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Account for positive content-box scroll gutter when requested by providing computedVal\n\tif ( !isBorderBox && computedVal >= 0 ) {\n\n\t\t// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border\n\t\t// Assuming integer scroll gutter, subtract the rest and round down\n\t\tdelta += Math.max( 0, Math.ceil(\n\t\t\telem[ \"offset\" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -\n\t\t\tcomputedVal -\n\t\t\tdelta -\n\t\t\textra -\n\t\t\t0.5\n\n\t\t// If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter\n\t\t// Use an explicit zero to avoid NaN (gh-3964)\n\t\t) ) || 0;\n\t}\n\n\treturn delta;\n}\n\nfunction getWidthOrHeight( elem, dimension, extra ) {\n\n\t// Start with computed style\n\tvar styles = getStyles( elem ),\n\n\t\t// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).\n\t\t// Fake content-box until we know it's needed to know the true value.\n\t\tboxSizingNeeded = !support.boxSizingReliable() || extra,\n\t\tisBorderBox = boxSizingNeeded &&\n\t\t\tjQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\",\n\t\tvalueIsBorderBox = isBorderBox,\n\n\t\tval = curCSS( elem, dimension, styles ),\n\t\toffsetProp = \"offset\" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );\n\n\t// Support: Firefox <=54\n\t// Return a confounding non-pixel value or feign ignorance, as appropriate.\n\tif ( rnumnonpx.test( val ) ) {\n\t\tif ( !extra ) {\n\t\t\treturn val;\n\t\t}\n\t\tval = \"auto\";\n\t}\n\n\n\t// Support: IE 9 - 11 only\n\t// Use offsetWidth/offsetHeight for when box sizing is unreliable.\n\t// In those cases, the computed value can be trusted to be border-box.\n\tif ( ( !support.boxSizingReliable() && isBorderBox ||\n\n\t\t// Support: IE 10 - 11+, Edge 15 - 18+\n\t\t// IE/Edge misreport `getComputedStyle` of table rows with width/height\n\t\t// set in CSS while `offset*` properties report correct values.\n\t\t// Interestingly, in some cases IE 9 doesn't suffer from this issue.\n\t\t!support.reliableTrDimensions() && nodeName( elem, \"tr\" ) ||\n\n\t\t// Fall back to offsetWidth/offsetHeight when value is \"auto\"\n\t\t// This happens for inline elements with no explicit setting (gh-3571)\n\t\tval === \"auto\" ||\n\n\t\t// Support: Android <=4.1 - 4.3 only\n\t\t// Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)\n\t\t!parseFloat( val ) && jQuery.css( elem, \"display\", false, styles ) === \"inline\" ) &&\n\n\t\t// Make sure the element is visible & connected\n\t\telem.getClientRects().length ) {\n\n\t\tisBorderBox = jQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\";\n\n\t\t// Where available, offsetWidth/offsetHeight approximate border box dimensions.\n\t\t// Where not available (e.g., SVG), assume unreliable box-sizing and interpret the\n\t\t// retrieved value as a content box dimension.\n\t\tvalueIsBorderBox = offsetProp in elem;\n\t\tif ( valueIsBorderBox ) {\n\t\t\tval = elem[ offsetProp ];\n\t\t}\n\t}\n\n\t// Normalize \"\" and auto\n\tval = parseFloat( val ) || 0;\n\n\t// Adjust for the element's box model\n\treturn ( val +\n\t\tboxModelAdjustment(\n\t\t\telem,\n\t\t\tdimension,\n\t\t\textra || ( isBorderBox ? \"border\" : \"content\" ),\n\t\t\tvalueIsBorderBox,\n\t\t\tstyles,\n\n\t\t\t// Provide the current computed size to request scroll gutter calculation (gh-3589)\n\t\t\tval\n\t\t)\n\t) + \"px\";\n}\n\njQuery.extend( {\n\n\t// Add in style property hooks for overriding the default\n\t// behavior of getting and setting a style property\n\tcssHooks: {\n\t\topacity: {\n\t\t\tget: function( elem, computed ) {\n\t\t\t\tif ( computed ) {\n\n\t\t\t\t\t// We should always get a number back from opacity\n\t\t\t\t\tvar ret = curCSS( elem, \"opacity\" );\n\t\t\t\t\treturn ret === \"\" ? \"1\" : ret;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t// Don't automatically add \"px\" to these possibly-unitless properties\n\tcssNumber: {\n\t\t\"animationIterationCount\": true,\n\t\t\"columnCount\": true,\n\t\t\"fillOpacity\": true,\n\t\t\"flexGrow\": true,\n\t\t\"flexShrink\": true,\n\t\t\"fontWeight\": true,\n\t\t\"gridArea\": true,\n\t\t\"gridColumn\": true,\n\t\t\"gridColumnEnd\": true,\n\t\t\"gridColumnStart\": true,\n\t\t\"gridRow\": true,\n\t\t\"gridRowEnd\": true,\n\t\t\"gridRowStart\": true,\n\t\t\"lineHeight\": true,\n\t\t\"opacity\": true,\n\t\t\"order\": true,\n\t\t\"orphans\": true,\n\t\t\"widows\": true,\n\t\t\"zIndex\": true,\n\t\t\"zoom\": true\n\t},\n\n\t// Add in properties whose names you wish to fix before\n\t// setting or getting the value\n\tcssProps: {},\n\n\t// Get and set the style property on a DOM Node\n\tstyle: function( elem, name, value, extra ) {\n\n\t\t// Don't set styles on text and comment nodes\n\t\tif ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure that we're working with the right name\n\t\tvar ret, type, hooks,\n\t\t\torigName = camelCase( name ),\n\t\t\tisCustomProp = rcustomProp.test( name ),\n\t\t\tstyle = elem.style;\n\n\t\t// Make sure that we're working with the right name. We don't\n\t\t// want to query the value if it is a CSS custom property\n\t\t// since they are user-defined.\n\t\tif ( !isCustomProp ) {\n\t\t\tname = finalPropName( origName );\n\t\t}\n\n\t\t// Gets hook for the prefixed version, then unprefixed version\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// Check if we're setting a value\n\t\tif ( value !== undefined ) {\n\t\t\ttype = typeof value;\n\n\t\t\t// Convert \"+=\" or \"-=\" to relative numbers (trac-7345)\n\t\t\tif ( type === \"string\" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {\n\t\t\t\tvalue = adjustCSS( elem, name, ret );\n\n\t\t\t\t// Fixes bug trac-9237\n\t\t\t\ttype = \"number\";\n\t\t\t}\n\n\t\t\t// Make sure that null and NaN values aren't set (trac-7116)\n\t\t\tif ( value == null || value !== value ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If a number was passed in, add the unit (except for certain CSS properties)\n\t\t\t// The isCustomProp check can be removed in jQuery 4.0 when we only auto-append\n\t\t\t// \"px\" to a few hardcoded values.\n\t\t\tif ( type === \"number\" && !isCustomProp ) {\n\t\t\t\tvalue += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? \"\" : \"px\" );\n\t\t\t}\n\n\t\t\t// background-* props affect original clone's values\n\t\t\tif ( !support.clearCloneStyle && value === \"\" && name.indexOf( \"background\" ) === 0 ) {\n\t\t\t\tstyle[ name ] = \"inherit\";\n\t\t\t}\n\n\t\t\t// If a hook was provided, use that value, otherwise just set the specified value\n\t\t\tif ( !hooks || !( \"set\" in hooks ) ||\n\t\t\t\t( value = hooks.set( elem, value, extra ) ) !== undefined ) {\n\n\t\t\t\tif ( isCustomProp ) {\n\t\t\t\t\tstyle.setProperty( name, value );\n\t\t\t\t} else {\n\t\t\t\t\tstyle[ name ] = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// If a hook was provided get the non-computed value from there\n\t\t\tif ( hooks && \"get\" in hooks &&\n\t\t\t\t( ret = hooks.get( elem, false, extra ) ) !== undefined ) {\n\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t// Otherwise just get the value from the style object\n\t\t\treturn style[ name ];\n\t\t}\n\t},\n\n\tcss: function( elem, name, extra, styles ) {\n\t\tvar val, num, hooks,\n\t\t\torigName = camelCase( name ),\n\t\t\tisCustomProp = rcustomProp.test( name );\n\n\t\t// Make sure that we're working with the right name. We don't\n\t\t// want to modify the value if it is a CSS custom property\n\t\t// since they are user-defined.\n\t\tif ( !isCustomProp ) {\n\t\t\tname = finalPropName( origName );\n\t\t}\n\n\t\t// Try prefixed name followed by the unprefixed name\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// If a hook was provided get the computed value from there\n\t\tif ( hooks && \"get\" in hooks ) {\n\t\t\tval = hooks.get( elem, true, extra );\n\t\t}\n\n\t\t// Otherwise, if a way to get the computed value exists, use that\n\t\tif ( val === undefined ) {\n\t\t\tval = curCSS( elem, name, styles );\n\t\t}\n\n\t\t// Convert \"normal\" to computed value\n\t\tif ( val === \"normal\" && name in cssNormalTransform ) {\n\t\t\tval = cssNormalTransform[ name ];\n\t\t}\n\n\t\t// Make numeric if forced or a qualifier was provided and val looks numeric\n\t\tif ( extra === \"\" || extra ) {\n\t\t\tnum = parseFloat( val );\n\t\t\treturn extra === true || isFinite( num ) ? num || 0 : val;\n\t\t}\n\n\t\treturn val;\n\t}\n} );\n\njQuery.each( [ \"height\", \"width\" ], function( _i, dimension ) {\n\tjQuery.cssHooks[ dimension ] = {\n\t\tget: function( elem, computed, extra ) {\n\t\t\tif ( computed ) {\n\n\t\t\t\t// Certain elements can have dimension info if we invisibly show them\n\t\t\t\t// but it must have a current display style that would benefit\n\t\t\t\treturn rdisplayswap.test( jQuery.css( elem, \"display\" ) ) &&\n\n\t\t\t\t\t// Support: Safari 8+\n\t\t\t\t\t// Table columns in Safari have non-zero offsetWidth & zero\n\t\t\t\t\t// getBoundingClientRect().width unless display is changed.\n\t\t\t\t\t// Support: IE <=11 only\n\t\t\t\t\t// Running getBoundingClientRect on a disconnected node\n\t\t\t\t\t// in IE throws an error.\n\t\t\t\t\t( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?\n\t\t\t\t\tswap( elem, cssShow, function() {\n\t\t\t\t\t\treturn getWidthOrHeight( elem, dimension, extra );\n\t\t\t\t\t} ) :\n\t\t\t\t\tgetWidthOrHeight( elem, dimension, extra );\n\t\t\t}\n\t\t},\n\n\t\tset: function( elem, value, extra ) {\n\t\t\tvar matches,\n\t\t\t\tstyles = getStyles( elem ),\n\n\t\t\t\t// Only read styles.position if the test has a chance to fail\n\t\t\t\t// to avoid forcing a reflow.\n\t\t\t\tscrollboxSizeBuggy = !support.scrollboxSize() &&\n\t\t\t\t\tstyles.position === \"absolute\",\n\n\t\t\t\t// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)\n\t\t\t\tboxSizingNeeded = scrollboxSizeBuggy || extra,\n\t\t\t\tisBorderBox = boxSizingNeeded &&\n\t\t\t\t\tjQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\",\n\t\t\t\tsubtract = extra ?\n\t\t\t\t\tboxModelAdjustment(\n\t\t\t\t\t\telem,\n\t\t\t\t\t\tdimension,\n\t\t\t\t\t\textra,\n\t\t\t\t\t\tisBorderBox,\n\t\t\t\t\t\tstyles\n\t\t\t\t\t) :\n\t\t\t\t\t0;\n\n\t\t\t// Account for unreliable border-box dimensions by comparing offset* to computed and\n\t\t\t// faking a content-box to get border and padding (gh-3699)\n\t\t\tif ( isBorderBox && scrollboxSizeBuggy ) {\n\t\t\t\tsubtract -= Math.ceil(\n\t\t\t\t\telem[ \"offset\" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -\n\t\t\t\t\tparseFloat( styles[ dimension ] ) -\n\t\t\t\t\tboxModelAdjustment( elem, dimension, \"border\", false, styles ) -\n\t\t\t\t\t0.5\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Convert to pixels if value adjustment is needed\n\t\t\tif ( subtract && ( matches = rcssNum.exec( value ) ) &&\n\t\t\t\t( matches[ 3 ] || \"px\" ) !== \"px\" ) {\n\n\t\t\t\telem.style[ dimension ] = value;\n\t\t\t\tvalue = jQuery.css( elem, dimension );\n\t\t\t}\n\n\t\t\treturn setPositiveNumber( elem, value, subtract );\n\t\t}\n\t};\n} );\n\njQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,\n\tfunction( elem, computed ) {\n\t\tif ( computed ) {\n\t\t\treturn ( parseFloat( curCSS( elem, \"marginLeft\" ) ) ||\n\t\t\t\telem.getBoundingClientRect().left -\n\t\t\t\t\tswap( elem, { marginLeft: 0 }, function() {\n\t\t\t\t\t\treturn elem.getBoundingClientRect().left;\n\t\t\t\t\t} )\n\t\t\t) + \"px\";\n\t\t}\n\t}\n);\n\n// These hooks are used by animate to expand properties\njQuery.each( {\n\tmargin: \"\",\n\tpadding: \"\",\n\tborder: \"Width\"\n}, function( prefix, suffix ) {\n\tjQuery.cssHooks[ prefix + suffix ] = {\n\t\texpand: function( value ) {\n\t\t\tvar i = 0,\n\t\t\t\texpanded = {},\n\n\t\t\t\t// Assumes a single number if not a string\n\t\t\t\tparts = typeof value === \"string\" ? value.split( \" \" ) : [ value ];\n\n\t\t\tfor ( ; i < 4; i++ ) {\n\t\t\t\texpanded[ prefix + cssExpand[ i ] + suffix ] =\n\t\t\t\t\tparts[ i ] || parts[ i - 2 ] || parts[ 0 ];\n\t\t\t}\n\n\t\t\treturn expanded;\n\t\t}\n\t};\n\n\tif ( prefix !== \"margin\" ) {\n\t\tjQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;\n\t}\n} );\n\njQuery.fn.extend( {\n\tcss: function( name, value ) {\n\t\treturn access( this, function( elem, name, value ) {\n\t\t\tvar styles, len,\n\t\t\t\tmap = {},\n\t\t\t\ti = 0;\n\n\t\t\tif ( Array.isArray( name ) ) {\n\t\t\t\tstyles = getStyles( elem );\n\t\t\t\tlen = name.length;\n\n\t\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\t\tmap[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}\n\n\t\t\treturn value !== undefined ?\n\t\t\t\tjQuery.style( elem, name, value ) :\n\t\t\t\tjQuery.css( elem, name );\n\t\t}, name, value, arguments.length > 1 );\n\t}\n} );\n\n\nfunction Tween( elem, options, prop, end, easing ) {\n\treturn new Tween.prototype.init( elem, options, prop, end, easing );\n}\njQuery.Tween = Tween;\n\nTween.prototype = {\n\tconstructor: Tween,\n\tinit: function( elem, options, prop, end, easing, unit ) {\n\t\tthis.elem = elem;\n\t\tthis.prop = prop;\n\t\tthis.easing = easing || jQuery.easing._default;\n\t\tthis.options = options;\n\t\tthis.start = this.now = this.cur();\n\t\tthis.end = end;\n\t\tthis.unit = unit || ( jQuery.cssNumber[ prop ] ? \"\" : \"px\" );\n\t},\n\tcur: function() {\n\t\tvar hooks = Tween.propHooks[ this.prop ];\n\n\t\treturn hooks && hooks.get ?\n\t\t\thooks.get( this ) :\n\t\t\tTween.propHooks._default.get( this );\n\t},\n\trun: function( percent ) {\n\t\tvar eased,\n\t\t\thooks = Tween.propHooks[ this.prop ];\n\n\t\tif ( this.options.duration ) {\n\t\t\tthis.pos = eased = jQuery.easing[ this.easing ](\n\t\t\t\tpercent, this.options.duration * percent, 0, 1, this.options.duration\n\t\t\t);\n\t\t} else {\n\t\t\tthis.pos = eased = percent;\n\t\t}\n\t\tthis.now = ( this.end - this.start ) * eased + this.start;\n\n\t\tif ( this.options.step ) {\n\t\t\tthis.options.step.call( this.elem, this.now, this );\n\t\t}\n\n\t\tif ( hooks && hooks.set ) {\n\t\t\thooks.set( this );\n\t\t} else {\n\t\t\tTween.propHooks._default.set( this );\n\t\t}\n\t\treturn this;\n\t}\n};\n\nTween.prototype.init.prototype = Tween.prototype;\n\nTween.propHooks = {\n\t_default: {\n\t\tget: function( tween ) {\n\t\t\tvar result;\n\n\t\t\t// Use a property on the element directly when it is not a DOM element,\n\t\t\t// or when there is no matching style property that exists.\n\t\t\tif ( tween.elem.nodeType !== 1 ||\n\t\t\t\ttween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {\n\t\t\t\treturn tween.elem[ tween.prop ];\n\t\t\t}\n\n\t\t\t// Passing an empty string as a 3rd parameter to .css will automatically\n\t\t\t// attempt a parseFloat and fallback to a string if the parse fails.\n\t\t\t// Simple values such as \"10px\" are parsed to Float;\n\t\t\t// complex values such as \"rotate(1rad)\" are returned as-is.\n\t\t\tresult = jQuery.css( tween.elem, tween.prop, \"\" );\n\n\t\t\t// Empty strings, null, undefined and \"auto\" are converted to 0.\n\t\t\treturn !result || result === \"auto\" ? 0 : result;\n\t\t},\n\t\tset: function( tween ) {\n\n\t\t\t// Use step hook for back compat.\n\t\t\t// Use cssHook if its there.\n\t\t\t// Use .style if available and use plain properties where available.\n\t\t\tif ( jQuery.fx.step[ tween.prop ] ) {\n\t\t\t\tjQuery.fx.step[ tween.prop ]( tween );\n\t\t\t} else if ( tween.elem.nodeType === 1 && (\n\t\t\t\tjQuery.cssHooks[ tween.prop ] ||\n\t\t\t\t\ttween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {\n\t\t\t\tjQuery.style( tween.elem, tween.prop, tween.now + tween.unit );\n\t\t\t} else {\n\t\t\t\ttween.elem[ tween.prop ] = tween.now;\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Support: IE <=9 only\n// Panic based approach to setting things on disconnected nodes\nTween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {\n\tset: function( tween ) {\n\t\tif ( tween.elem.nodeType && tween.elem.parentNode ) {\n\t\t\ttween.elem[ tween.prop ] = tween.now;\n\t\t}\n\t}\n};\n\njQuery.easing = {\n\tlinear: function( p ) {\n\t\treturn p;\n\t},\n\tswing: function( p ) {\n\t\treturn 0.5 - Math.cos( p * Math.PI ) / 2;\n\t},\n\t_default: \"swing\"\n};\n\njQuery.fx = Tween.prototype.init;\n\n// Back compat <1.8 extension point\njQuery.fx.step = {};\n\n\n\n\nvar\n\tfxNow, inProgress,\n\trfxtypes = /^(?:toggle|show|hide)$/,\n\trrun = /queueHooks$/;\n\nfunction schedule() {\n\tif ( inProgress ) {\n\t\tif ( document.hidden === false && window.requestAnimationFrame ) {\n\t\t\twindow.requestAnimationFrame( schedule );\n\t\t} else {\n\t\t\twindow.setTimeout( schedule, jQuery.fx.interval );\n\t\t}\n\n\t\tjQuery.fx.tick();\n\t}\n}\n\n// Animations created synchronously will run synchronously\nfunction createFxNow() {\n\twindow.setTimeout( function() {\n\t\tfxNow = undefined;\n\t} );\n\treturn ( fxNow = Date.now() );\n}\n\n// Generate parameters to create a standard animation\nfunction genFx( type, includeWidth ) {\n\tvar which,\n\t\ti = 0,\n\t\tattrs = { height: type };\n\n\t// If we include width, step value is 1 to do all cssExpand values,\n\t// otherwise step value is 2 to skip over Left and Right\n\tincludeWidth = includeWidth ? 1 : 0;\n\tfor ( ; i < 4; i += 2 - includeWidth ) {\n\t\twhich = cssExpand[ i ];\n\t\tattrs[ \"margin\" + which ] = attrs[ \"padding\" + which ] = type;\n\t}\n\n\tif ( includeWidth ) {\n\t\tattrs.opacity = attrs.width = type;\n\t}\n\n\treturn attrs;\n}\n\nfunction createTween( value, prop, animation ) {\n\tvar tween,\n\t\tcollection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ \"*\" ] ),\n\t\tindex = 0,\n\t\tlength = collection.length;\n\tfor ( ; index < length; index++ ) {\n\t\tif ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {\n\n\t\t\t// We're done with this property\n\t\t\treturn tween;\n\t\t}\n\t}\n}\n\nfunction defaultPrefilter( elem, props, opts ) {\n\tvar prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,\n\t\tisBox = \"width\" in props || \"height\" in props,\n\t\tanim = this,\n\t\torig = {},\n\t\tstyle = elem.style,\n\t\thidden = elem.nodeType && isHiddenWithinTree( elem ),\n\t\tdataShow = dataPriv.get( elem, \"fxshow\" );\n\n\t// Queue-skipping animations hijack the fx hooks\n\tif ( !opts.queue ) {\n\t\thooks = jQuery._queueHooks( elem, \"fx\" );\n\t\tif ( hooks.unqueued == null ) {\n\t\t\thooks.unqueued = 0;\n\t\t\toldfire = hooks.empty.fire;\n\t\t\thooks.empty.fire = function() {\n\t\t\t\tif ( !hooks.unqueued ) {\n\t\t\t\t\toldfire();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\thooks.unqueued++;\n\n\t\tanim.always( function() {\n\n\t\t\t// Ensure the complete handler is called before this completes\n\t\t\tanim.always( function() {\n\t\t\t\thooks.unqueued--;\n\t\t\t\tif ( !jQuery.queue( elem, \"fx\" ).length ) {\n\t\t\t\t\thooks.empty.fire();\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t}\n\n\t// Detect show/hide animations\n\tfor ( prop in props ) {\n\t\tvalue = props[ prop ];\n\t\tif ( rfxtypes.test( value ) ) {\n\t\t\tdelete props[ prop ];\n\t\t\ttoggle = toggle || value === \"toggle\";\n\t\t\tif ( value === ( hidden ? \"hide\" : \"show\" ) ) {\n\n\t\t\t\t// Pretend to be hidden if this is a \"show\" and\n\t\t\t\t// there is still data from a stopped show/hide\n\t\t\t\tif ( value === \"show\" && dataShow && dataShow[ prop ] !== undefined ) {\n\t\t\t\t\thidden = true;\n\n\t\t\t\t// Ignore all other no-op show/hide data\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\torig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );\n\t\t}\n\t}\n\n\t// Bail out if this is a no-op like .hide().hide()\n\tpropTween = !jQuery.isEmptyObject( props );\n\tif ( !propTween && jQuery.isEmptyObject( orig ) ) {\n\t\treturn;\n\t}\n\n\t// Restrict \"overflow\" and \"display\" styles during box animations\n\tif ( isBox && elem.nodeType === 1 ) {\n\n\t\t// Support: IE <=9 - 11, Edge 12 - 15\n\t\t// Record all 3 overflow attributes because IE does not infer the shorthand\n\t\t// from identically-valued overflowX and overflowY and Edge just mirrors\n\t\t// the overflowX value there.\n\t\topts.overflow = [ style.overflow, style.overflowX, style.overflowY ];\n\n\t\t// Identify a display type, preferring old show/hide data over the CSS cascade\n\t\trestoreDisplay = dataShow && dataShow.display;\n\t\tif ( restoreDisplay == null ) {\n\t\t\trestoreDisplay = dataPriv.get( elem, \"display\" );\n\t\t}\n\t\tdisplay = jQuery.css( elem, \"display\" );\n\t\tif ( display === \"none\" ) {\n\t\t\tif ( restoreDisplay ) {\n\t\t\t\tdisplay = restoreDisplay;\n\t\t\t} else {\n\n\t\t\t\t// Get nonempty value(s) by temporarily forcing visibility\n\t\t\t\tshowHide( [ elem ], true );\n\t\t\t\trestoreDisplay = elem.style.display || restoreDisplay;\n\t\t\t\tdisplay = jQuery.css( elem, \"display\" );\n\t\t\t\tshowHide( [ elem ] );\n\t\t\t}\n\t\t}\n\n\t\t// Animate inline elements as inline-block\n\t\tif ( display === \"inline\" || display === \"inline-block\" && restoreDisplay != null ) {\n\t\t\tif ( jQuery.css( elem, \"float\" ) === \"none\" ) {\n\n\t\t\t\t// Restore the original display value at the end of pure show/hide animations\n\t\t\t\tif ( !propTween ) {\n\t\t\t\t\tanim.done( function() {\n\t\t\t\t\t\tstyle.display = restoreDisplay;\n\t\t\t\t\t} );\n\t\t\t\t\tif ( restoreDisplay == null ) {\n\t\t\t\t\t\tdisplay = style.display;\n\t\t\t\t\t\trestoreDisplay = display === \"none\" ? \"\" : display;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstyle.display = \"inline-block\";\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( opts.overflow ) {\n\t\tstyle.overflow = \"hidden\";\n\t\tanim.always( function() {\n\t\t\tstyle.overflow = opts.overflow[ 0 ];\n\t\t\tstyle.overflowX = opts.overflow[ 1 ];\n\t\t\tstyle.overflowY = opts.overflow[ 2 ];\n\t\t} );\n\t}\n\n\t// Implement show/hide animations\n\tpropTween = false;\n\tfor ( prop in orig ) {\n\n\t\t// General show/hide setup for this element animation\n\t\tif ( !propTween ) {\n\t\t\tif ( dataShow ) {\n\t\t\t\tif ( \"hidden\" in dataShow ) {\n\t\t\t\t\thidden = dataShow.hidden;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdataShow = dataPriv.access( elem, \"fxshow\", { display: restoreDisplay } );\n\t\t\t}\n\n\t\t\t// Store hidden/visible for toggle so `.stop().toggle()` \"reverses\"\n\t\t\tif ( toggle ) {\n\t\t\t\tdataShow.hidden = !hidden;\n\t\t\t}\n\n\t\t\t// Show elements before animating them\n\t\t\tif ( hidden ) {\n\t\t\t\tshowHide( [ elem ], true );\n\t\t\t}\n\n\t\t\t/* eslint-disable no-loop-func */\n\n\t\t\tanim.done( function() {\n\n\t\t\t\t/* eslint-enable no-loop-func */\n\n\t\t\t\t// The final step of a \"hide\" animation is actually hiding the element\n\t\t\t\tif ( !hidden ) {\n\t\t\t\t\tshowHide( [ elem ] );\n\t\t\t\t}\n\t\t\t\tdataPriv.remove( elem, \"fxshow\" );\n\t\t\t\tfor ( prop in orig ) {\n\t\t\t\t\tjQuery.style( elem, prop, orig[ prop ] );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Per-property setup\n\t\tpropTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );\n\t\tif ( !( prop in dataShow ) ) {\n\t\t\tdataShow[ prop ] = propTween.start;\n\t\t\tif ( hidden ) {\n\t\t\t\tpropTween.end = propTween.start;\n\t\t\t\tpropTween.start = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction propFilter( props, specialEasing ) {\n\tvar index, name, easing, value, hooks;\n\n\t// camelCase, specialEasing and expand cssHook pass\n\tfor ( index in props ) {\n\t\tname = camelCase( index );\n\t\teasing = specialEasing[ name ];\n\t\tvalue = props[ index ];\n\t\tif ( Array.isArray( value ) ) {\n\t\t\teasing = value[ 1 ];\n\t\t\tvalue = props[ index ] = value[ 0 ];\n\t\t}\n\n\t\tif ( index !== name ) {\n\t\t\tprops[ name ] = value;\n\t\t\tdelete props[ index ];\n\t\t}\n\n\t\thooks = jQuery.cssHooks[ name ];\n\t\tif ( hooks && \"expand\" in hooks ) {\n\t\t\tvalue = hooks.expand( value );\n\t\t\tdelete props[ name ];\n\n\t\t\t// Not quite $.extend, this won't overwrite existing keys.\n\t\t\t// Reusing 'index' because we have the correct \"name\"\n\t\t\tfor ( index in value ) {\n\t\t\t\tif ( !( index in props ) ) {\n\t\t\t\t\tprops[ index ] = value[ index ];\n\t\t\t\t\tspecialEasing[ index ] = easing;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tspecialEasing[ name ] = easing;\n\t\t}\n\t}\n}\n\nfunction Animation( elem, properties, options ) {\n\tvar result,\n\t\tstopped,\n\t\tindex = 0,\n\t\tlength = Animation.prefilters.length,\n\t\tdeferred = jQuery.Deferred().always( function() {\n\n\t\t\t// Don't match elem in the :animated selector\n\t\t\tdelete tick.elem;\n\t\t} ),\n\t\ttick = function() {\n\t\t\tif ( stopped ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tvar currentTime = fxNow || createFxNow(),\n\t\t\t\tremaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),\n\n\t\t\t\t// Support: Android 2.3 only\n\t\t\t\t// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)\n\t\t\t\ttemp = remaining / animation.duration || 0,\n\t\t\t\tpercent = 1 - temp,\n\t\t\t\tindex = 0,\n\t\t\t\tlength = animation.tweens.length;\n\n\t\t\tfor ( ; index < length; index++ ) {\n\t\t\t\tanimation.tweens[ index ].run( percent );\n\t\t\t}\n\n\t\t\tdeferred.notifyWith( elem, [ animation, percent, remaining ] );\n\n\t\t\t// If there's more to do, yield\n\t\t\tif ( percent < 1 && length ) {\n\t\t\t\treturn remaining;\n\t\t\t}\n\n\t\t\t// If this was an empty animation, synthesize a final progress notification\n\t\t\tif ( !length ) {\n\t\t\t\tdeferred.notifyWith( elem, [ animation, 1, 0 ] );\n\t\t\t}\n\n\t\t\t// Resolve the animation and report its conclusion\n\t\t\tdeferred.resolveWith( elem, [ animation ] );\n\t\t\treturn false;\n\t\t},\n\t\tanimation = deferred.promise( {\n\t\t\telem: elem,\n\t\t\tprops: jQuery.extend( {}, properties ),\n\t\t\topts: jQuery.extend( true, {\n\t\t\t\tspecialEasing: {},\n\t\t\t\teasing: jQuery.easing._default\n\t\t\t}, options ),\n\t\t\toriginalProperties: properties,\n\t\t\toriginalOptions: options,\n\t\t\tstartTime: fxNow || createFxNow(),\n\t\t\tduration: options.duration,\n\t\t\ttweens: [],\n\t\t\tcreateTween: function( prop, end ) {\n\t\t\t\tvar tween = jQuery.Tween( elem, animation.opts, prop, end,\n\t\t\t\t\tanimation.opts.specialEasing[ prop ] || animation.opts.easing );\n\t\t\t\tanimation.tweens.push( tween );\n\t\t\t\treturn tween;\n\t\t\t},\n\t\t\tstop: function( gotoEnd ) {\n\t\t\t\tvar index = 0,\n\n\t\t\t\t\t// If we are going to the end, we want to run all the tweens\n\t\t\t\t\t// otherwise we skip this part\n\t\t\t\t\tlength = gotoEnd ? animation.tweens.length : 0;\n\t\t\t\tif ( stopped ) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t\tstopped = true;\n\t\t\t\tfor ( ; index < length; index++ ) {\n\t\t\t\t\tanimation.tweens[ index ].run( 1 );\n\t\t\t\t}\n\n\t\t\t\t// Resolve when we played the last frame; otherwise, reject\n\t\t\t\tif ( gotoEnd ) {\n\t\t\t\t\tdeferred.notifyWith( elem, [ animation, 1, 0 ] );\n\t\t\t\t\tdeferred.resolveWith( elem, [ animation, gotoEnd ] );\n\t\t\t\t} else {\n\t\t\t\t\tdeferred.rejectWith( elem, [ animation, gotoEnd ] );\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t}\n\t\t} ),\n\t\tprops = animation.props;\n\n\tpropFilter( props, animation.opts.specialEasing );\n\n\tfor ( ; index < length; index++ ) {\n\t\tresult = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );\n\t\tif ( result ) {\n\t\t\tif ( isFunction( result.stop ) ) {\n\t\t\t\tjQuery._queueHooks( animation.elem, animation.opts.queue ).stop =\n\t\t\t\t\tresult.stop.bind( result );\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tjQuery.map( props, createTween, animation );\n\n\tif ( isFunction( animation.opts.start ) ) {\n\t\tanimation.opts.start.call( elem, animation );\n\t}\n\n\t// Attach callbacks from options\n\tanimation\n\t\t.progress( animation.opts.progress )\n\t\t.done( animation.opts.done, animation.opts.complete )\n\t\t.fail( animation.opts.fail )\n\t\t.always( animation.opts.always );\n\n\tjQuery.fx.timer(\n\t\tjQuery.extend( tick, {\n\t\t\telem: elem,\n\t\t\tanim: animation,\n\t\t\tqueue: animation.opts.queue\n\t\t} )\n\t);\n\n\treturn animation;\n}\n\njQuery.Animation = jQuery.extend( Animation, {\n\n\ttweeners: {\n\t\t\"*\": [ function( prop, value ) {\n\t\t\tvar tween = this.createTween( prop, value );\n\t\t\tadjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );\n\t\t\treturn tween;\n\t\t} ]\n\t},\n\n\ttweener: function( props, callback ) {\n\t\tif ( isFunction( props ) ) {\n\t\t\tcallback = props;\n\t\t\tprops = [ \"*\" ];\n\t\t} else {\n\t\t\tprops = props.match( rnothtmlwhite );\n\t\t}\n\n\t\tvar prop,\n\t\t\tindex = 0,\n\t\t\tlength = props.length;\n\n\t\tfor ( ; index < length; index++ ) {\n\t\t\tprop = props[ index ];\n\t\t\tAnimation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];\n\t\t\tAnimation.tweeners[ prop ].unshift( callback );\n\t\t}\n\t},\n\n\tprefilters: [ defaultPrefilter ],\n\n\tprefilter: function( callback, prepend ) {\n\t\tif ( prepend ) {\n\t\t\tAnimation.prefilters.unshift( callback );\n\t\t} else {\n\t\t\tAnimation.prefilters.push( callback );\n\t\t}\n\t}\n} );\n\njQuery.speed = function( speed, easing, fn ) {\n\tvar opt = speed && typeof speed === \"object\" ? jQuery.extend( {}, speed ) : {\n\t\tcomplete: fn || !fn && easing ||\n\t\t\tisFunction( speed ) && speed,\n\t\tduration: speed,\n\t\teasing: fn && easing || easing && !isFunction( easing ) && easing\n\t};\n\n\t// Go to the end state if fx are off\n\tif ( jQuery.fx.off ) {\n\t\topt.duration = 0;\n\n\t} else {\n\t\tif ( typeof opt.duration !== \"number\" ) {\n\t\t\tif ( opt.duration in jQuery.fx.speeds ) {\n\t\t\t\topt.duration = jQuery.fx.speeds[ opt.duration ];\n\n\t\t\t} else {\n\t\t\t\topt.duration = jQuery.fx.speeds._default;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Normalize opt.queue - true/undefined/null -> \"fx\"\n\tif ( opt.queue == null || opt.queue === true ) {\n\t\topt.queue = \"fx\";\n\t}\n\n\t// Queueing\n\topt.old = opt.complete;\n\n\topt.complete = function() {\n\t\tif ( isFunction( opt.old ) ) {\n\t\t\topt.old.call( this );\n\t\t}\n\n\t\tif ( opt.queue ) {\n\t\t\tjQuery.dequeue( this, opt.queue );\n\t\t}\n\t};\n\n\treturn opt;\n};\n\njQuery.fn.extend( {\n\tfadeTo: function( speed, to, easing, callback ) {\n\n\t\t// Show any hidden elements after setting opacity to 0\n\t\treturn this.filter( isHiddenWithinTree ).css( \"opacity\", 0 ).show()\n\n\t\t\t// Animate to the value specified\n\t\t\t.end().animate( { opacity: to }, speed, easing, callback );\n\t},\n\tanimate: function( prop, speed, easing, callback ) {\n\t\tvar empty = jQuery.isEmptyObject( prop ),\n\t\t\toptall = jQuery.speed( speed, easing, callback ),\n\t\t\tdoAnimation = function() {\n\n\t\t\t\t// Operate on a copy of prop so per-property easing won't be lost\n\t\t\t\tvar anim = Animation( this, jQuery.extend( {}, prop ), optall );\n\n\t\t\t\t// Empty animations, or finishing resolves immediately\n\t\t\t\tif ( empty || dataPriv.get( this, \"finish\" ) ) {\n\t\t\t\t\tanim.stop( true );\n\t\t\t\t}\n\t\t\t};\n\n\t\tdoAnimation.finish = doAnimation;\n\n\t\treturn empty || optall.queue === false ?\n\t\t\tthis.each( doAnimation ) :\n\t\t\tthis.queue( optall.queue, doAnimation );\n\t},\n\tstop: function( type, clearQueue, gotoEnd ) {\n\t\tvar stopQueue = function( hooks ) {\n\t\t\tvar stop = hooks.stop;\n\t\t\tdelete hooks.stop;\n\t\t\tstop( gotoEnd );\n\t\t};\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tgotoEnd = clearQueue;\n\t\t\tclearQueue = type;\n\t\t\ttype = undefined;\n\t\t}\n\t\tif ( clearQueue ) {\n\t\t\tthis.queue( type || \"fx\", [] );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar dequeue = true,\n\t\t\t\tindex = type != null && type + \"queueHooks\",\n\t\t\t\ttimers = jQuery.timers,\n\t\t\t\tdata = dataPriv.get( this );\n\n\t\t\tif ( index ) {\n\t\t\t\tif ( data[ index ] && data[ index ].stop ) {\n\t\t\t\t\tstopQueue( data[ index ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( index in data ) {\n\t\t\t\t\tif ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {\n\t\t\t\t\t\tstopQueue( data[ index ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor ( index = timers.length; index--; ) {\n\t\t\t\tif ( timers[ index ].elem === this &&\n\t\t\t\t\t( type == null || timers[ index ].queue === type ) ) {\n\n\t\t\t\t\ttimers[ index ].anim.stop( gotoEnd );\n\t\t\t\t\tdequeue = false;\n\t\t\t\t\ttimers.splice( index, 1 );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Start the next in the queue if the last step wasn't forced.\n\t\t\t// Timers currently will call their complete callbacks, which\n\t\t\t// will dequeue but only if they were gotoEnd.\n\t\t\tif ( dequeue || !gotoEnd ) {\n\t\t\t\tjQuery.dequeue( this, type );\n\t\t\t}\n\t\t} );\n\t},\n\tfinish: function( type ) {\n\t\tif ( type !== false ) {\n\t\t\ttype = type || \"fx\";\n\t\t}\n\t\treturn this.each( function() {\n\t\t\tvar index,\n\t\t\t\tdata = dataPriv.get( this ),\n\t\t\t\tqueue = data[ type + \"queue\" ],\n\t\t\t\thooks = data[ type + \"queueHooks\" ],\n\t\t\t\ttimers = jQuery.timers,\n\t\t\t\tlength = queue ? queue.length : 0;\n\n\t\t\t// Enable finishing flag on private data\n\t\t\tdata.finish = true;\n\n\t\t\t// Empty the queue first\n\t\t\tjQuery.queue( this, type, [] );\n\n\t\t\tif ( hooks && hooks.stop ) {\n\t\t\t\thooks.stop.call( this, true );\n\t\t\t}\n\n\t\t\t// Look for any active animations, and finish them\n\t\t\tfor ( index = timers.length; index--; ) {\n\t\t\t\tif ( timers[ index ].elem === this && timers[ index ].queue === type ) {\n\t\t\t\t\ttimers[ index ].anim.stop( true );\n\t\t\t\t\ttimers.splice( index, 1 );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Look for any animations in the old queue and finish them\n\t\t\tfor ( index = 0; index < length; index++ ) {\n\t\t\t\tif ( queue[ index ] && queue[ index ].finish ) {\n\t\t\t\t\tqueue[ index ].finish.call( this );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Turn off finishing flag\n\t\t\tdelete data.finish;\n\t\t} );\n\t}\n} );\n\njQuery.each( [ \"toggle\", \"show\", \"hide\" ], function( _i, name ) {\n\tvar cssFn = jQuery.fn[ name ];\n\tjQuery.fn[ name ] = function( speed, easing, callback ) {\n\t\treturn speed == null || typeof speed === \"boolean\" ?\n\t\t\tcssFn.apply( this, arguments ) :\n\t\t\tthis.animate( genFx( name, true ), speed, easing, callback );\n\t};\n} );\n\n// Generate shortcuts for custom animations\njQuery.each( {\n\tslideDown: genFx( \"show\" ),\n\tslideUp: genFx( \"hide\" ),\n\tslideToggle: genFx( \"toggle\" ),\n\tfadeIn: { opacity: \"show\" },\n\tfadeOut: { opacity: \"hide\" },\n\tfadeToggle: { opacity: \"toggle\" }\n}, function( name, props ) {\n\tjQuery.fn[ name ] = function( speed, easing, callback ) {\n\t\treturn this.animate( props, speed, easing, callback );\n\t};\n} );\n\njQuery.timers = [];\njQuery.fx.tick = function() {\n\tvar timer,\n\t\ti = 0,\n\t\ttimers = jQuery.timers;\n\n\tfxNow = Date.now();\n\n\tfor ( ; i < timers.length; i++ ) {\n\t\ttimer = timers[ i ];\n\n\t\t// Run the timer and safely remove it when done (allowing for external removal)\n\t\tif ( !timer() && timers[ i ] === timer ) {\n\t\t\ttimers.splice( i--, 1 );\n\t\t}\n\t}\n\n\tif ( !timers.length ) {\n\t\tjQuery.fx.stop();\n\t}\n\tfxNow = undefined;\n};\n\njQuery.fx.timer = function( timer ) {\n\tjQuery.timers.push( timer );\n\tjQuery.fx.start();\n};\n\njQuery.fx.interval = 13;\njQuery.fx.start = function() {\n\tif ( inProgress ) {\n\t\treturn;\n\t}\n\n\tinProgress = true;\n\tschedule();\n};\n\njQuery.fx.stop = function() {\n\tinProgress = null;\n};\n\njQuery.fx.speeds = {\n\tslow: 600,\n\tfast: 200,\n\n\t// Default speed\n\t_default: 400\n};\n\n\n// Based off of the plugin by Clint Helfers, with permission.\njQuery.fn.delay = function( time, type ) {\n\ttime = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;\n\ttype = type || \"fx\";\n\n\treturn this.queue( type, function( next, hooks ) {\n\t\tvar timeout = window.setTimeout( next, time );\n\t\thooks.stop = function() {\n\t\t\twindow.clearTimeout( timeout );\n\t\t};\n\t} );\n};\n\n\n( function() {\n\tvar input = document.createElement( \"input\" ),\n\t\tselect = document.createElement( \"select\" ),\n\t\topt = select.appendChild( document.createElement( \"option\" ) );\n\n\tinput.type = \"checkbox\";\n\n\t// Support: Android <=4.3 only\n\t// Default value for a checkbox should be \"on\"\n\tsupport.checkOn = input.value !== \"\";\n\n\t// Support: IE <=11 only\n\t// Must access selectedIndex to make default options select\n\tsupport.optSelected = opt.selected;\n\n\t// Support: IE <=11 only\n\t// An input loses its value after becoming a radio\n\tinput = document.createElement( \"input\" );\n\tinput.value = \"t\";\n\tinput.type = \"radio\";\n\tsupport.radioValue = input.value === \"t\";\n} )();\n\n\nvar boolHook,\n\tattrHandle = jQuery.expr.attrHandle;\n\njQuery.fn.extend( {\n\tattr: function( name, value ) {\n\t\treturn access( this, jQuery.attr, name, value, arguments.length > 1 );\n\t},\n\n\tremoveAttr: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.removeAttr( this, name );\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tattr: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set attributes on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Fallback to prop when attributes are not supported\n\t\tif ( typeof elem.getAttribute === \"undefined\" ) {\n\t\t\treturn jQuery.prop( elem, name, value );\n\t\t}\n\n\t\t// Attribute hooks are determined by the lowercase version\n\t\t// Grab necessary hook if one is defined\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\t\t\thooks = jQuery.attrHooks[ name.toLowerCase() ] ||\n\t\t\t\t( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( value === null ) {\n\t\t\t\tjQuery.removeAttr( elem, name );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\telem.setAttribute( name, value + \"\" );\n\t\t\treturn value;\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tret = jQuery.find.attr( elem, name );\n\n\t\t// Non-existent attributes return null, we normalize to undefined\n\t\treturn ret == null ? undefined : ret;\n\t},\n\n\tattrHooks: {\n\t\ttype: {\n\t\t\tset: function( elem, value ) {\n\t\t\t\tif ( !support.radioValue && value === \"radio\" &&\n\t\t\t\t\tnodeName( elem, \"input\" ) ) {\n\t\t\t\t\tvar val = elem.value;\n\t\t\t\t\telem.setAttribute( \"type\", value );\n\t\t\t\t\tif ( val ) {\n\t\t\t\t\t\telem.value = val;\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremoveAttr: function( elem, value ) {\n\t\tvar name,\n\t\t\ti = 0,\n\n\t\t\t// Attribute names can contain non-HTML whitespace characters\n\t\t\t// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2\n\t\t\tattrNames = value && value.match( rnothtmlwhite );\n\n\t\tif ( attrNames && elem.nodeType === 1 ) {\n\t\t\twhile ( ( name = attrNames[ i++ ] ) ) {\n\t\t\t\telem.removeAttribute( name );\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Hooks for boolean attributes\nboolHook = {\n\tset: function( elem, value, name ) {\n\t\tif ( value === false ) {\n\n\t\t\t// Remove boolean attributes when set to false\n\t\t\tjQuery.removeAttr( elem, name );\n\t\t} else {\n\t\t\telem.setAttribute( name, name );\n\t\t}\n\t\treturn name;\n\t}\n};\n\njQuery.each( jQuery.expr.match.bool.source.match( /\\w+/g ), function( _i, name ) {\n\tvar getter = attrHandle[ name ] || jQuery.find.attr;\n\n\tattrHandle[ name ] = function( elem, name, isXML ) {\n\t\tvar ret, handle,\n\t\t\tlowercaseName = name.toLowerCase();\n\n\t\tif ( !isXML ) {\n\n\t\t\t// Avoid an infinite loop by temporarily removing this function from the getter\n\t\t\thandle = attrHandle[ lowercaseName ];\n\t\t\tattrHandle[ lowercaseName ] = ret;\n\t\t\tret = getter( elem, name, isXML ) != null ?\n\t\t\t\tlowercaseName :\n\t\t\t\tnull;\n\t\t\tattrHandle[ lowercaseName ] = handle;\n\t\t}\n\t\treturn ret;\n\t};\n} );\n\n\n\n\nvar rfocusable = /^(?:input|select|textarea|button)$/i,\n\trclickable = /^(?:a|area)$/i;\n\njQuery.fn.extend( {\n\tprop: function( name, value ) {\n\t\treturn access( this, jQuery.prop, name, value, arguments.length > 1 );\n\t},\n\n\tremoveProp: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tdelete this[ jQuery.propFix[ name ] || name ];\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tprop: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set properties on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// Fix name and attach hooks\n\t\t\tname = jQuery.propFix[ name ] || name;\n\t\t\thooks = jQuery.propHooks[ name ];\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\treturn ( elem[ name ] = value );\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\treturn elem[ name ];\n\t},\n\n\tpropHooks: {\n\t\ttabIndex: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\t// Support: IE <=9 - 11 only\n\t\t\t\t// elem.tabIndex doesn't always return the\n\t\t\t\t// correct value when it hasn't been explicitly set\n\t\t\t\t// Use proper attribute retrieval (trac-12072)\n\t\t\t\tvar tabindex = jQuery.find.attr( elem, \"tabindex\" );\n\n\t\t\t\tif ( tabindex ) {\n\t\t\t\t\treturn parseInt( tabindex, 10 );\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\trfocusable.test( elem.nodeName ) ||\n\t\t\t\t\trclickable.test( elem.nodeName ) &&\n\t\t\t\t\telem.href\n\t\t\t\t) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t},\n\n\tpropFix: {\n\t\t\"for\": \"htmlFor\",\n\t\t\"class\": \"className\"\n\t}\n} );\n\n// Support: IE <=11 only\n// Accessing the selectedIndex property\n// forces the browser to respect setting selected\n// on the option\n// The getter ensures a default option is selected\n// when in an optgroup\n// eslint rule \"no-unused-expressions\" is disabled for this code\n// since it considers such accessions noop\nif ( !support.optSelected ) {\n\tjQuery.propHooks.selected = {\n\t\tget: function( elem ) {\n\n\t\t\t/* eslint no-unused-expressions: \"off\" */\n\n\t\t\tvar parent = elem.parentNode;\n\t\t\tif ( parent && parent.parentNode ) {\n\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\tset: function( elem ) {\n\n\t\t\t/* eslint no-unused-expressions: \"off\" */\n\n\t\t\tvar parent = elem.parentNode;\n\t\t\tif ( parent ) {\n\t\t\t\tparent.selectedIndex;\n\n\t\t\t\tif ( parent.parentNode ) {\n\t\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\njQuery.each( [\n\t\"tabIndex\",\n\t\"readOnly\",\n\t\"maxLength\",\n\t\"cellSpacing\",\n\t\"cellPadding\",\n\t\"rowSpan\",\n\t\"colSpan\",\n\t\"useMap\",\n\t\"frameBorder\",\n\t\"contentEditable\"\n], function() {\n\tjQuery.propFix[ this.toLowerCase() ] = this;\n} );\n\n\n\n\n\t// Strip and collapse whitespace according to HTML spec\n\t// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace\n\tfunction stripAndCollapse( value ) {\n\t\tvar tokens = value.match( rnothtmlwhite ) || [];\n\t\treturn tokens.join( \" \" );\n\t}\n\n\nfunction getClass( elem ) {\n\treturn elem.getAttribute && elem.getAttribute( \"class\" ) || \"\";\n}\n\nfunction classesToArray( value ) {\n\tif ( Array.isArray( value ) ) {\n\t\treturn value;\n\t}\n\tif ( typeof value === \"string\" ) {\n\t\treturn value.match( rnothtmlwhite ) || [];\n\t}\n\treturn [];\n}\n\njQuery.fn.extend( {\n\taddClass: function( value ) {\n\t\tvar classNames, cur, curValue, className, i, finalValue;\n\n\t\tif ( isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).addClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tclassNames = classesToArray( value );\n\n\t\tif ( classNames.length ) {\n\t\t\treturn this.each( function() {\n\t\t\t\tcurValue = getClass( this );\n\t\t\t\tcur = this.nodeType === 1 && ( \" \" + stripAndCollapse( curValue ) + \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tfor ( i = 0; i < classNames.length; i++ ) {\n\t\t\t\t\t\tclassName = classNames[ i ];\n\t\t\t\t\t\tif ( cur.indexOf( \" \" + className + \" \" ) < 0 ) {\n\t\t\t\t\t\t\tcur += className + \" \";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = stripAndCollapse( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\tthis.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tremoveClass: function( value ) {\n\t\tvar classNames, cur, curValue, className, i, finalValue;\n\n\t\tif ( isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( !arguments.length ) {\n\t\t\treturn this.attr( \"class\", \"\" );\n\t\t}\n\n\t\tclassNames = classesToArray( value );\n\n\t\tif ( classNames.length ) {\n\t\t\treturn this.each( function() {\n\t\t\t\tcurValue = getClass( this );\n\n\t\t\t\t// This expression is here for better compressibility (see addClass)\n\t\t\t\tcur = this.nodeType === 1 && ( \" \" + stripAndCollapse( curValue ) + \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tfor ( i = 0; i < classNames.length; i++ ) {\n\t\t\t\t\t\tclassName = classNames[ i ];\n\n\t\t\t\t\t\t// Remove *all* instances\n\t\t\t\t\t\twhile ( cur.indexOf( \" \" + className + \" \" ) > -1 ) {\n\t\t\t\t\t\t\tcur = cur.replace( \" \" + className + \" \", \" \" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = stripAndCollapse( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\tthis.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttoggleClass: function( value, stateVal ) {\n\t\tvar classNames, className, i, self,\n\t\t\ttype = typeof value,\n\t\t\tisValidValue = type === \"string\" || Array.isArray( value );\n\n\t\tif ( isFunction( value ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).toggleClass(\n\t\t\t\t\tvalue.call( this, i, getClass( this ), stateVal ),\n\t\t\t\t\tstateVal\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\tif ( typeof stateVal === \"boolean\" && isValidValue ) {\n\t\t\treturn stateVal ? this.addClass( value ) : this.removeClass( value );\n\t\t}\n\n\t\tclassNames = classesToArray( value );\n\n\t\treturn this.each( function() {\n\t\t\tif ( isValidValue ) {\n\n\t\t\t\t// Toggle individual class names\n\t\t\t\tself = jQuery( this );\n\n\t\t\t\tfor ( i = 0; i < classNames.length; i++ ) {\n\t\t\t\t\tclassName = classNames[ i ];\n\n\t\t\t\t\t// Check each className given, space separated list\n\t\t\t\t\tif ( self.hasClass( className ) ) {\n\t\t\t\t\t\tself.removeClass( className );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tself.addClass( className );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t// Toggle whole class name\n\t\t\t} else if ( value === undefined || type === \"boolean\" ) {\n\t\t\t\tclassName = getClass( this );\n\t\t\t\tif ( className ) {\n\n\t\t\t\t\t// Store className if set\n\t\t\t\t\tdataPriv.set( this, \"__className__\", className );\n\t\t\t\t}\n\n\t\t\t\t// If the element has a class name or if we're passed `false`,\n\t\t\t\t// then remove the whole classname (if there was one, the above saved it).\n\t\t\t\t// Otherwise bring back whatever was previously saved (if anything),\n\t\t\t\t// falling back to the empty string if nothing was stored.\n\t\t\t\tif ( this.setAttribute ) {\n\t\t\t\t\tthis.setAttribute( \"class\",\n\t\t\t\t\t\tclassName || value === false ?\n\t\t\t\t\t\t\t\"\" :\n\t\t\t\t\t\t\tdataPriv.get( this, \"__className__\" ) || \"\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\thasClass: function( selector ) {\n\t\tvar className, elem,\n\t\t\ti = 0;\n\n\t\tclassName = \" \" + selector + \" \";\n\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\tif ( elem.nodeType === 1 &&\n\t\t\t\t( \" \" + stripAndCollapse( getClass( elem ) ) + \" \" ).indexOf( className ) > -1 ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n} );\n\n\n\n\nvar rreturn = /\\r/g;\n\njQuery.fn.extend( {\n\tval: function( value ) {\n\t\tvar hooks, ret, valueIsFunction,\n\t\t\telem = this[ 0 ];\n\n\t\tif ( !arguments.length ) {\n\t\t\tif ( elem ) {\n\t\t\t\thooks = jQuery.valHooks[ elem.type ] ||\n\t\t\t\t\tjQuery.valHooks[ elem.nodeName.toLowerCase() ];\n\n\t\t\t\tif ( hooks &&\n\t\t\t\t\t\"get\" in hooks &&\n\t\t\t\t\t( ret = hooks.get( elem, \"value\" ) ) !== undefined\n\t\t\t\t) {\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\t\tret = elem.value;\n\n\t\t\t\t// Handle most common string cases\n\t\t\t\tif ( typeof ret === \"string\" ) {\n\t\t\t\t\treturn ret.replace( rreturn, \"\" );\n\t\t\t\t}\n\n\t\t\t\t// Handle cases where value is null/undef or number\n\t\t\t\treturn ret == null ? \"\" : ret;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tvalueIsFunction = isFunction( value );\n\n\t\treturn this.each( function( i ) {\n\t\t\tvar val;\n\n\t\t\tif ( this.nodeType !== 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( valueIsFunction ) {\n\t\t\t\tval = value.call( this, i, jQuery( this ).val() );\n\t\t\t} else {\n\t\t\t\tval = value;\n\t\t\t}\n\n\t\t\t// Treat null/undefined as \"\"; convert numbers to string\n\t\t\tif ( val == null ) {\n\t\t\t\tval = \"\";\n\n\t\t\t} else if ( typeof val === \"number\" ) {\n\t\t\t\tval += \"\";\n\n\t\t\t} else if ( Array.isArray( val ) ) {\n\t\t\t\tval = jQuery.map( val, function( value ) {\n\t\t\t\t\treturn value == null ? \"\" : value + \"\";\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];\n\n\t\t\t// If set returns undefined, fall back to normal setting\n\t\t\tif ( !hooks || !( \"set\" in hooks ) || hooks.set( this, val, \"value\" ) === undefined ) {\n\t\t\t\tthis.value = val;\n\t\t\t}\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tvalHooks: {\n\t\toption: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\tvar val = jQuery.find.attr( elem, \"value\" );\n\t\t\t\treturn val != null ?\n\t\t\t\t\tval :\n\n\t\t\t\t\t// Support: IE <=10 - 11 only\n\t\t\t\t\t// option.text throws exceptions (trac-14686, trac-14858)\n\t\t\t\t\t// Strip and collapse whitespace\n\t\t\t\t\t// https://html.spec.whatwg.org/#strip-and-collapse-whitespace\n\t\t\t\t\tstripAndCollapse( jQuery.text( elem ) );\n\t\t\t}\n\t\t},\n\t\tselect: {\n\t\t\tget: function( elem ) {\n\t\t\t\tvar value, option, i,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tindex = elem.selectedIndex,\n\t\t\t\t\tone = elem.type === \"select-one\",\n\t\t\t\t\tvalues = one ? null : [],\n\t\t\t\t\tmax = one ? index + 1 : options.length;\n\n\t\t\t\tif ( index < 0 ) {\n\t\t\t\t\ti = max;\n\n\t\t\t\t} else {\n\t\t\t\t\ti = one ? index : 0;\n\t\t\t\t}\n\n\t\t\t\t// Loop through all the selected options\n\t\t\t\tfor ( ; i < max; i++ ) {\n\t\t\t\t\toption = options[ i ];\n\n\t\t\t\t\t// Support: IE <=9 only\n\t\t\t\t\t// IE8-9 doesn't update selected after form reset (trac-2551)\n\t\t\t\t\tif ( ( option.selected || i === index ) &&\n\n\t\t\t\t\t\t\t// Don't return options that are disabled or in a disabled optgroup\n\t\t\t\t\t\t\t!option.disabled &&\n\t\t\t\t\t\t\t( !option.parentNode.disabled ||\n\t\t\t\t\t\t\t\t!nodeName( option.parentNode, \"optgroup\" ) ) ) {\n\n\t\t\t\t\t\t// Get the specific value for the option\n\t\t\t\t\t\tvalue = jQuery( option ).val();\n\n\t\t\t\t\t\t// We don't need an array for one selects\n\t\t\t\t\t\tif ( one ) {\n\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Multi-Selects return an array\n\t\t\t\t\t\tvalues.push( value );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\t\t\t},\n\n\t\t\tset: function( elem, value ) {\n\t\t\t\tvar optionSet, option,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tvalues = jQuery.makeArray( value ),\n\t\t\t\t\ti = options.length;\n\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\toption = options[ i ];\n\n\t\t\t\t\t/* eslint-disable no-cond-assign */\n\n\t\t\t\t\tif ( option.selected =\n\t\t\t\t\t\tjQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1\n\t\t\t\t\t) {\n\t\t\t\t\t\toptionSet = true;\n\t\t\t\t\t}\n\n\t\t\t\t\t/* eslint-enable no-cond-assign */\n\t\t\t\t}\n\n\t\t\t\t// Force browsers to behave consistently when non-matching value is set\n\t\t\t\tif ( !optionSet ) {\n\t\t\t\t\telem.selectedIndex = -1;\n\t\t\t\t}\n\t\t\t\treturn values;\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Radios and checkboxes getter/setter\njQuery.each( [ \"radio\", \"checkbox\" ], function() {\n\tjQuery.valHooks[ this ] = {\n\t\tset: function( elem, value ) {\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\treturn ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );\n\t\t\t}\n\t\t}\n\t};\n\tif ( !support.checkOn ) {\n\t\tjQuery.valHooks[ this ].get = function( elem ) {\n\t\t\treturn elem.getAttribute( \"value\" ) === null ? \"on\" : elem.value;\n\t\t};\n\t}\n} );\n\n\n\n\n// Return jQuery for attributes-only inclusion\n\n\nsupport.focusin = \"onfocusin\" in window;\n\n\nvar rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,\n\tstopPropagationCallback = function( e ) {\n\t\te.stopPropagation();\n\t};\n\njQuery.extend( jQuery.event, {\n\n\ttrigger: function( event, data, elem, onlyHandlers ) {\n\n\t\tvar i, cur, tmp, bubbleType, ontype, handle, special, lastElement,\n\t\t\teventPath = [ elem || document ],\n\t\t\ttype = hasOwn.call( event, \"type\" ) ? event.type : event,\n\t\t\tnamespaces = hasOwn.call( event, \"namespace\" ) ? event.namespace.split( \".\" ) : [];\n\n\t\tcur = lastElement = tmp = elem = elem || document;\n\n\t\t// Don't do events on text and comment nodes\n\t\tif ( elem.nodeType === 3 || elem.nodeType === 8 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// focus/blur morphs to focusin/out; ensure we're not firing them right now\n\t\tif ( rfocusMorph.test( type + jQuery.event.triggered ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( type.indexOf( \".\" ) > -1 ) {\n\n\t\t\t// Namespaced trigger; create a regexp to match event type in handle()\n\t\t\tnamespaces = type.split( \".\" );\n\t\t\ttype = namespaces.shift();\n\t\t\tnamespaces.sort();\n\t\t}\n\t\tontype = type.indexOf( \":\" ) < 0 && \"on\" + type;\n\n\t\t// Caller can pass in a jQuery.Event object, Object, or just an event type string\n\t\tevent = event[ jQuery.expando ] ?\n\t\t\tevent :\n\t\t\tnew jQuery.Event( type, typeof event === \"object\" && event );\n\n\t\t// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)\n\t\tevent.isTrigger = onlyHandlers ? 2 : 3;\n\t\tevent.namespace = namespaces.join( \".\" );\n\t\tevent.rnamespace = event.namespace ?\n\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" ) :\n\t\t\tnull;\n\n\t\t// Clean up the event in case it is being reused\n\t\tevent.result = undefined;\n\t\tif ( !event.target ) {\n\t\t\tevent.target = elem;\n\t\t}\n\n\t\t// Clone any incoming data and prepend the event, creating the handler arg list\n\t\tdata = data == null ?\n\t\t\t[ event ] :\n\t\t\tjQuery.makeArray( data, [ event ] );\n\n\t\t// Allow special events to draw outside the lines\n\t\tspecial = jQuery.event.special[ type ] || {};\n\t\tif ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine event propagation path in advance, per W3C events spec (trac-9951)\n\t\t// Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)\n\t\tif ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {\n\n\t\t\tbubbleType = special.delegateType || type;\n\t\t\tif ( !rfocusMorph.test( bubbleType + type ) ) {\n\t\t\t\tcur = cur.parentNode;\n\t\t\t}\n\t\t\tfor ( ; cur; cur = cur.parentNode ) {\n\t\t\t\teventPath.push( cur );\n\t\t\t\ttmp = cur;\n\t\t\t}\n\n\t\t\t// Only add window if we got to document (e.g., not plain obj or detached DOM)\n\t\t\tif ( tmp === ( elem.ownerDocument || document ) ) {\n\t\t\t\teventPath.push( tmp.defaultView || tmp.parentWindow || window );\n\t\t\t}\n\t\t}\n\n\t\t// Fire handlers on the event path\n\t\ti = 0;\n\t\twhile ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {\n\t\t\tlastElement = cur;\n\t\t\tevent.type = i > 1 ?\n\t\t\t\tbubbleType :\n\t\t\t\tspecial.bindType || type;\n\n\t\t\t// jQuery handler\n\t\t\thandle = ( dataPriv.get( cur, \"events\" ) || Object.create( null ) )[ event.type ] &&\n\t\t\t\tdataPriv.get( cur, \"handle\" );\n\t\t\tif ( handle ) {\n\t\t\t\thandle.apply( cur, data );\n\t\t\t}\n\n\t\t\t// Native handler\n\t\t\thandle = ontype && cur[ ontype ];\n\t\t\tif ( handle && handle.apply && acceptData( cur ) ) {\n\t\t\t\tevent.result = handle.apply( cur, data );\n\t\t\t\tif ( event.result === false ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tevent.type = type;\n\n\t\t// If nobody prevented the default action, do it now\n\t\tif ( !onlyHandlers && !event.isDefaultPrevented() ) {\n\n\t\t\tif ( ( !special._default ||\n\t\t\t\tspecial._default.apply( eventPath.pop(), data ) === false ) &&\n\t\t\t\tacceptData( elem ) ) {\n\n\t\t\t\t// Call a native DOM method on the target with the same name as the event.\n\t\t\t\t// Don't do default actions on window, that's where global variables be (trac-6170)\n\t\t\t\tif ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {\n\n\t\t\t\t\t// Don't re-trigger an onFOO event when we call its FOO() method\n\t\t\t\t\ttmp = elem[ ontype ];\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prevent re-triggering of the same event, since we already bubbled it above\n\t\t\t\t\tjQuery.event.triggered = type;\n\n\t\t\t\t\tif ( event.isPropagationStopped() ) {\n\t\t\t\t\t\tlastElement.addEventListener( type, stopPropagationCallback );\n\t\t\t\t\t}\n\n\t\t\t\t\telem[ type ]();\n\n\t\t\t\t\tif ( event.isPropagationStopped() ) {\n\t\t\t\t\t\tlastElement.removeEventListener( type, stopPropagationCallback );\n\t\t\t\t\t}\n\n\t\t\t\t\tjQuery.event.triggered = undefined;\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = tmp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\t// Piggyback on a donor event to simulate a different one\n\t// Used only for `focus(in | out)` events\n\tsimulate: function( type, elem, event ) {\n\t\tvar e = jQuery.extend(\n\t\t\tnew jQuery.Event(),\n\t\t\tevent,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t\tisSimulated: true\n\t\t\t}\n\t\t);\n\n\t\tjQuery.event.trigger( e, null, elem );\n\t}\n\n} );\n\njQuery.fn.extend( {\n\n\ttrigger: function( type, data ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.trigger( type, data, this );\n\t\t} );\n\t},\n\ttriggerHandler: function( type, data ) {\n\t\tvar elem = this[ 0 ];\n\t\tif ( elem ) {\n\t\t\treturn jQuery.event.trigger( type, data, elem, true );\n\t\t}\n\t}\n} );\n\n\n// Support: Firefox <=44\n// Firefox doesn't have focus(in | out) events\n// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787\n//\n// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1\n// focus(in | out) events fire after focus & blur events,\n// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order\n// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857\nif ( !support.focusin ) {\n\tjQuery.each( { focus: \"focusin\", blur: \"focusout\" }, function( orig, fix ) {\n\n\t\t// Attach a single capturing handler on the document while someone wants focusin/focusout\n\t\tvar handler = function( event ) {\n\t\t\tjQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );\n\t\t};\n\n\t\tjQuery.event.special[ fix ] = {\n\t\t\tsetup: function() {\n\n\t\t\t\t// Handle: regular nodes (via `this.ownerDocument`), window\n\t\t\t\t// (via `this.document`) & document (via `this`).\n\t\t\t\tvar doc = this.ownerDocument || this.document || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix );\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.addEventListener( orig, handler, true );\n\t\t\t\t}\n\t\t\t\tdataPriv.access( doc, fix, ( attaches || 0 ) + 1 );\n\t\t\t},\n\t\t\tteardown: function() {\n\t\t\t\tvar doc = this.ownerDocument || this.document || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix ) - 1;\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.removeEventListener( orig, handler, true );\n\t\t\t\t\tdataPriv.remove( doc, fix );\n\n\t\t\t\t} else {\n\t\t\t\t\tdataPriv.access( doc, fix, attaches );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t} );\n}\nvar location = window.location;\n\nvar nonce = { guid: Date.now() };\n\nvar rquery = ( /\\?/ );\n\n\n\n// Cross-browser xml parsing\njQuery.parseXML = function( data ) {\n\tvar xml, parserErrorElem;\n\tif ( !data || typeof data !== \"string\" ) {\n\t\treturn null;\n\t}\n\n\t// Support: IE 9 - 11 only\n\t// IE throws on parseFromString with invalid input.\n\ttry {\n\t\txml = ( new window.DOMParser() ).parseFromString( data, \"text/xml\" );\n\t} catch ( e ) {}\n\n\tparserErrorElem = xml && xml.getElementsByTagName( \"parsererror\" )[ 0 ];\n\tif ( !xml || parserErrorElem ) {\n\t\tjQuery.error( \"Invalid XML: \" + (\n\t\t\tparserErrorElem ?\n\t\t\t\tjQuery.map( parserErrorElem.childNodes, function( el ) {\n\t\t\t\t\treturn el.textContent;\n\t\t\t\t} ).join( \"\\n\" ) :\n\t\t\t\tdata\n\t\t) );\n\t}\n\treturn xml;\n};\n\n\nvar\n\trbracket = /\\[\\]$/,\n\trCRLF = /\\r?\\n/g,\n\trsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,\n\trsubmittable = /^(?:input|select|textarea|keygen)/i;\n\nfunction buildParams( prefix, obj, traditional, add ) {\n\tvar name;\n\n\tif ( Array.isArray( obj ) ) {\n\n\t\t// Serialize array item.\n\t\tjQuery.each( obj, function( i, v ) {\n\t\t\tif ( traditional || rbracket.test( prefix ) ) {\n\n\t\t\t\t// Treat each array item as a scalar.\n\t\t\t\tadd( prefix, v );\n\n\t\t\t} else {\n\n\t\t\t\t// Item is non-scalar (array or object), encode its numeric index.\n\t\t\t\tbuildParams(\n\t\t\t\t\tprefix + \"[\" + ( typeof v === \"object\" && v != null ? i : \"\" ) + \"]\",\n\t\t\t\t\tv,\n\t\t\t\t\ttraditional,\n\t\t\t\t\tadd\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t} else if ( !traditional && toType( obj ) === \"object\" ) {\n\n\t\t// Serialize object item.\n\t\tfor ( name in obj ) {\n\t\t\tbuildParams( prefix + \"[\" + name + \"]\", obj[ name ], traditional, add );\n\t\t}\n\n\t} else {\n\n\t\t// Serialize scalar item.\n\t\tadd( prefix, obj );\n\t}\n}\n\n// Serialize an array of form elements or a set of\n// key/values into a query string\njQuery.param = function( a, traditional ) {\n\tvar prefix,\n\t\ts = [],\n\t\tadd = function( key, valueOrFunction ) {\n\n\t\t\t// If value is a function, invoke it and use its return value\n\t\t\tvar value = isFunction( valueOrFunction ) ?\n\t\t\t\tvalueOrFunction() :\n\t\t\t\tvalueOrFunction;\n\n\t\t\ts[ s.length ] = encodeURIComponent( key ) + \"=\" +\n\t\t\t\tencodeURIComponent( value == null ? \"\" : value );\n\t\t};\n\n\tif ( a == null ) {\n\t\treturn \"\";\n\t}\n\n\t// If an array was passed in, assume that it is an array of form elements.\n\tif ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {\n\n\t\t// Serialize the form elements\n\t\tjQuery.each( a, function() {\n\t\t\tadd( this.name, this.value );\n\t\t} );\n\n\t} else {\n\n\t\t// If traditional, encode the \"old\" way (the way 1.3.2 or older\n\t\t// did it), otherwise encode params recursively.\n\t\tfor ( prefix in a ) {\n\t\t\tbuildParams( prefix, a[ prefix ], traditional, add );\n\t\t}\n\t}\n\n\t// Return the resulting serialization\n\treturn s.join( \"&\" );\n};\n\njQuery.fn.extend( {\n\tserialize: function() {\n\t\treturn jQuery.param( this.serializeArray() );\n\t},\n\tserializeArray: function() {\n\t\treturn this.map( function() {\n\n\t\t\t// Can add propHook for \"elements\" to filter or add form elements\n\t\t\tvar elements = jQuery.prop( this, \"elements\" );\n\t\t\treturn elements ? jQuery.makeArray( elements ) : this;\n\t\t} ).filter( function() {\n\t\t\tvar type = this.type;\n\n\t\t\t// Use .is( \":disabled\" ) so that fieldset[disabled] works\n\t\t\treturn this.name && !jQuery( this ).is( \":disabled\" ) &&\n\t\t\t\trsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&\n\t\t\t\t( this.checked || !rcheckableType.test( type ) );\n\t\t} ).map( function( _i, elem ) {\n\t\t\tvar val = jQuery( this ).val();\n\n\t\t\tif ( val == null ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ( Array.isArray( val ) ) {\n\t\t\t\treturn jQuery.map( val, function( val ) {\n\t\t\t\t\treturn { name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn { name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t} ).get();\n\t}\n} );\n\n\nvar\n\tr20 = /%20/g,\n\trhash = /#.*$/,\n\trantiCache = /([?&])_=[^&]*/,\n\trheaders = /^(.*?):[ \\t]*([^\\r\\n]*)$/mg,\n\n\t// trac-7653, trac-8125, trac-8152: local protocol detection\n\trlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,\n\trnoContent = /^(?:GET|HEAD)$/,\n\trprotocol = /^\\/\\//,\n\n\t/* Prefilters\n\t * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)\n\t * 2) These are called:\n\t *    - BEFORE asking for a transport\n\t *    - AFTER param serialization (s.data is a string if s.processData is true)\n\t * 3) key is the dataType\n\t * 4) the catchall symbol \"*\" can be used\n\t * 5) execution will start with transport dataType and THEN continue down to \"*\" if needed\n\t */\n\tprefilters = {},\n\n\t/* Transports bindings\n\t * 1) key is the dataType\n\t * 2) the catchall symbol \"*\" can be used\n\t * 3) selection will start with transport dataType and THEN go to \"*\" if needed\n\t */\n\ttransports = {},\n\n\t// Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression\n\tallTypes = \"*/\".concat( \"*\" ),\n\n\t// Anchor tag for parsing the document origin\n\toriginAnchor = document.createElement( \"a\" );\n\noriginAnchor.href = location.href;\n\n// Base \"constructor\" for jQuery.ajaxPrefilter and jQuery.ajaxTransport\nfunction addToPrefiltersOrTransports( structure ) {\n\n\t// dataTypeExpression is optional and defaults to \"*\"\n\treturn function( dataTypeExpression, func ) {\n\n\t\tif ( typeof dataTypeExpression !== \"string\" ) {\n\t\t\tfunc = dataTypeExpression;\n\t\t\tdataTypeExpression = \"*\";\n\t\t}\n\n\t\tvar dataType,\n\t\t\ti = 0,\n\t\t\tdataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];\n\n\t\tif ( isFunction( func ) ) {\n\n\t\t\t// For each dataType in the dataTypeExpression\n\t\t\twhile ( ( dataType = dataTypes[ i++ ] ) ) {\n\n\t\t\t\t// Prepend if requested\n\t\t\t\tif ( dataType[ 0 ] === \"+\" ) {\n\t\t\t\t\tdataType = dataType.slice( 1 ) || \"*\";\n\t\t\t\t\t( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );\n\n\t\t\t\t// Otherwise append\n\t\t\t\t} else {\n\t\t\t\t\t( structure[ dataType ] = structure[ dataType ] || [] ).push( func );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\n// Base inspection function for prefilters and transports\nfunction inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {\n\n\tvar inspected = {},\n\t\tseekingTransport = ( structure === transports );\n\n\tfunction inspect( dataType ) {\n\t\tvar selected;\n\t\tinspected[ dataType ] = true;\n\t\tjQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {\n\t\t\tvar dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );\n\t\t\tif ( typeof dataTypeOrTransport === \"string\" &&\n\t\t\t\t!seekingTransport && !inspected[ dataTypeOrTransport ] ) {\n\n\t\t\t\toptions.dataTypes.unshift( dataTypeOrTransport );\n\t\t\t\tinspect( dataTypeOrTransport );\n\t\t\t\treturn false;\n\t\t\t} else if ( seekingTransport ) {\n\t\t\t\treturn !( selected = dataTypeOrTransport );\n\t\t\t}\n\t\t} );\n\t\treturn selected;\n\t}\n\n\treturn inspect( options.dataTypes[ 0 ] ) || !inspected[ \"*\" ] && inspect( \"*\" );\n}\n\n// A special extend for ajax options\n// that takes \"flat\" options (not to be deep extended)\n// Fixes trac-9887\nfunction ajaxExtend( target, src ) {\n\tvar key, deep,\n\t\tflatOptions = jQuery.ajaxSettings.flatOptions || {};\n\n\tfor ( key in src ) {\n\t\tif ( src[ key ] !== undefined ) {\n\t\t\t( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];\n\t\t}\n\t}\n\tif ( deep ) {\n\t\tjQuery.extend( true, target, deep );\n\t}\n\n\treturn target;\n}\n\n/* Handles responses to an ajax request:\n * - finds the right dataType (mediates between content-type and expected dataType)\n * - returns the corresponding response\n */\nfunction ajaxHandleResponses( s, jqXHR, responses ) {\n\n\tvar ct, type, finalDataType, firstDataType,\n\t\tcontents = s.contents,\n\t\tdataTypes = s.dataTypes;\n\n\t// Remove auto dataType and get content-type in the process\n\twhile ( dataTypes[ 0 ] === \"*\" ) {\n\t\tdataTypes.shift();\n\t\tif ( ct === undefined ) {\n\t\t\tct = s.mimeType || jqXHR.getResponseHeader( \"Content-Type\" );\n\t\t}\n\t}\n\n\t// Check if we're dealing with a known content-type\n\tif ( ct ) {\n\t\tfor ( type in contents ) {\n\t\t\tif ( contents[ type ] && contents[ type ].test( ct ) ) {\n\t\t\t\tdataTypes.unshift( type );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check to see if we have a response for the expected dataType\n\tif ( dataTypes[ 0 ] in responses ) {\n\t\tfinalDataType = dataTypes[ 0 ];\n\t} else {\n\n\t\t// Try convertible dataTypes\n\t\tfor ( type in responses ) {\n\t\t\tif ( !dataTypes[ 0 ] || s.converters[ type + \" \" + dataTypes[ 0 ] ] ) {\n\t\t\t\tfinalDataType = type;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !firstDataType ) {\n\t\t\t\tfirstDataType = type;\n\t\t\t}\n\t\t}\n\n\t\t// Or just use first one\n\t\tfinalDataType = finalDataType || firstDataType;\n\t}\n\n\t// If we found a dataType\n\t// We add the dataType to the list if needed\n\t// and return the corresponding response\n\tif ( finalDataType ) {\n\t\tif ( finalDataType !== dataTypes[ 0 ] ) {\n\t\t\tdataTypes.unshift( finalDataType );\n\t\t}\n\t\treturn responses[ finalDataType ];\n\t}\n}\n\n/* Chain conversions given the request and the original response\n * Also sets the responseXXX fields on the jqXHR instance\n */\nfunction ajaxConvert( s, response, jqXHR, isSuccess ) {\n\tvar conv2, current, conv, tmp, prev,\n\t\tconverters = {},\n\n\t\t// Work with a copy of dataTypes in case we need to modify it for conversion\n\t\tdataTypes = s.dataTypes.slice();\n\n\t// Create converters map with lowercased keys\n\tif ( dataTypes[ 1 ] ) {\n\t\tfor ( conv in s.converters ) {\n\t\t\tconverters[ conv.toLowerCase() ] = s.converters[ conv ];\n\t\t}\n\t}\n\n\tcurrent = dataTypes.shift();\n\n\t// Convert to each sequential dataType\n\twhile ( current ) {\n\n\t\tif ( s.responseFields[ current ] ) {\n\t\t\tjqXHR[ s.responseFields[ current ] ] = response;\n\t\t}\n\n\t\t// Apply the dataFilter if provided\n\t\tif ( !prev && isSuccess && s.dataFilter ) {\n\t\t\tresponse = s.dataFilter( response, s.dataType );\n\t\t}\n\n\t\tprev = current;\n\t\tcurrent = dataTypes.shift();\n\n\t\tif ( current ) {\n\n\t\t\t// There's only work to do if current dataType is non-auto\n\t\t\tif ( current === \"*\" ) {\n\n\t\t\t\tcurrent = prev;\n\n\t\t\t// Convert response if prev dataType is non-auto and differs from current\n\t\t\t} else if ( prev !== \"*\" && prev !== current ) {\n\n\t\t\t\t// Seek a direct converter\n\t\t\t\tconv = converters[ prev + \" \" + current ] || converters[ \"* \" + current ];\n\n\t\t\t\t// If none found, seek a pair\n\t\t\t\tif ( !conv ) {\n\t\t\t\t\tfor ( conv2 in converters ) {\n\n\t\t\t\t\t\t// If conv2 outputs current\n\t\t\t\t\t\ttmp = conv2.split( \" \" );\n\t\t\t\t\t\tif ( tmp[ 1 ] === current ) {\n\n\t\t\t\t\t\t\t// If prev can be converted to accepted input\n\t\t\t\t\t\t\tconv = converters[ prev + \" \" + tmp[ 0 ] ] ||\n\t\t\t\t\t\t\t\tconverters[ \"* \" + tmp[ 0 ] ];\n\t\t\t\t\t\t\tif ( conv ) {\n\n\t\t\t\t\t\t\t\t// Condense equivalence converters\n\t\t\t\t\t\t\t\tif ( conv === true ) {\n\t\t\t\t\t\t\t\t\tconv = converters[ conv2 ];\n\n\t\t\t\t\t\t\t\t// Otherwise, insert the intermediate dataType\n\t\t\t\t\t\t\t\t} else if ( converters[ conv2 ] !== true ) {\n\t\t\t\t\t\t\t\t\tcurrent = tmp[ 0 ];\n\t\t\t\t\t\t\t\t\tdataTypes.unshift( tmp[ 1 ] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Apply converter (if not an equivalence)\n\t\t\t\tif ( conv !== true ) {\n\n\t\t\t\t\t// Unless errors are allowed to bubble, catch and return them\n\t\t\t\t\tif ( conv && s.throws ) {\n\t\t\t\t\t\tresponse = conv( response );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresponse = conv( response );\n\t\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tstate: \"parsererror\",\n\t\t\t\t\t\t\t\terror: conv ? e : \"No conversion from \" + prev + \" to \" + current\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { state: \"success\", data: response };\n}\n\njQuery.extend( {\n\n\t// Counter for holding the number of active queries\n\tactive: 0,\n\n\t// Last-Modified header cache for next request\n\tlastModified: {},\n\tetag: {},\n\n\tajaxSettings: {\n\t\turl: location.href,\n\t\ttype: \"GET\",\n\t\tisLocal: rlocalProtocol.test( location.protocol ),\n\t\tglobal: true,\n\t\tprocessData: true,\n\t\tasync: true,\n\t\tcontentType: \"application/x-www-form-urlencoded; charset=UTF-8\",\n\n\t\t/*\n\t\ttimeout: 0,\n\t\tdata: null,\n\t\tdataType: null,\n\t\tusername: null,\n\t\tpassword: null,\n\t\tcache: null,\n\t\tthrows: false,\n\t\ttraditional: false,\n\t\theaders: {},\n\t\t*/\n\n\t\taccepts: {\n\t\t\t\"*\": allTypes,\n\t\t\ttext: \"text/plain\",\n\t\t\thtml: \"text/html\",\n\t\t\txml: \"application/xml, text/xml\",\n\t\t\tjson: \"application/json, text/javascript\"\n\t\t},\n\n\t\tcontents: {\n\t\t\txml: /\\bxml\\b/,\n\t\t\thtml: /\\bhtml/,\n\t\t\tjson: /\\bjson\\b/\n\t\t},\n\n\t\tresponseFields: {\n\t\t\txml: \"responseXML\",\n\t\t\ttext: \"responseText\",\n\t\t\tjson: \"responseJSON\"\n\t\t},\n\n\t\t// Data converters\n\t\t// Keys separate source (or catchall \"*\") and destination types with a single space\n\t\tconverters: {\n\n\t\t\t// Convert anything to text\n\t\t\t\"* text\": String,\n\n\t\t\t// Text to html (true = no transformation)\n\t\t\t\"text html\": true,\n\n\t\t\t// Evaluate text as a json expression\n\t\t\t\"text json\": JSON.parse,\n\n\t\t\t// Parse text as xml\n\t\t\t\"text xml\": jQuery.parseXML\n\t\t},\n\n\t\t// For options that shouldn't be deep extended:\n\t\t// you can add your own custom options here if\n\t\t// and when you create one that shouldn't be\n\t\t// deep extended (see ajaxExtend)\n\t\tflatOptions: {\n\t\t\turl: true,\n\t\t\tcontext: true\n\t\t}\n\t},\n\n\t// Creates a full fledged settings object into target\n\t// with both ajaxSettings and settings fields.\n\t// If target is omitted, writes into ajaxSettings.\n\tajaxSetup: function( target, settings ) {\n\t\treturn settings ?\n\n\t\t\t// Building a settings object\n\t\t\tajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :\n\n\t\t\t// Extending ajaxSettings\n\t\t\tajaxExtend( jQuery.ajaxSettings, target );\n\t},\n\n\tajaxPrefilter: addToPrefiltersOrTransports( prefilters ),\n\tajaxTransport: addToPrefiltersOrTransports( transports ),\n\n\t// Main method\n\tajax: function( url, options ) {\n\n\t\t// If url is an object, simulate pre-1.5 signature\n\t\tif ( typeof url === \"object\" ) {\n\t\t\toptions = url;\n\t\t\turl = undefined;\n\t\t}\n\n\t\t// Force options to be an object\n\t\toptions = options || {};\n\n\t\tvar transport,\n\n\t\t\t// URL without anti-cache param\n\t\t\tcacheURL,\n\n\t\t\t// Response headers\n\t\t\tresponseHeadersString,\n\t\t\tresponseHeaders,\n\n\t\t\t// timeout handle\n\t\t\ttimeoutTimer,\n\n\t\t\t// Url cleanup var\n\t\t\turlAnchor,\n\n\t\t\t// Request state (becomes false upon send and true upon completion)\n\t\t\tcompleted,\n\n\t\t\t// To know if global events are to be dispatched\n\t\t\tfireGlobals,\n\n\t\t\t// Loop variable\n\t\t\ti,\n\n\t\t\t// uncached part of the url\n\t\t\tuncached,\n\n\t\t\t// Create the final options object\n\t\t\ts = jQuery.ajaxSetup( {}, options ),\n\n\t\t\t// Callbacks context\n\t\t\tcallbackContext = s.context || s,\n\n\t\t\t// Context for global events is callbackContext if it is a DOM node or jQuery collection\n\t\t\tglobalEventContext = s.context &&\n\t\t\t\t( callbackContext.nodeType || callbackContext.jquery ) ?\n\t\t\t\tjQuery( callbackContext ) :\n\t\t\t\tjQuery.event,\n\n\t\t\t// Deferreds\n\t\t\tdeferred = jQuery.Deferred(),\n\t\t\tcompleteDeferred = jQuery.Callbacks( \"once memory\" ),\n\n\t\t\t// Status-dependent callbacks\n\t\t\tstatusCode = s.statusCode || {},\n\n\t\t\t// Headers (they are sent all at once)\n\t\t\trequestHeaders = {},\n\t\t\trequestHeadersNames = {},\n\n\t\t\t// Default abort message\n\t\t\tstrAbort = \"canceled\",\n\n\t\t\t// Fake xhr\n\t\t\tjqXHR = {\n\t\t\t\treadyState: 0,\n\n\t\t\t\t// Builds headers hashtable if needed\n\t\t\t\tgetResponseHeader: function( key ) {\n\t\t\t\t\tvar match;\n\t\t\t\t\tif ( completed ) {\n\t\t\t\t\t\tif ( !responseHeaders ) {\n\t\t\t\t\t\t\tresponseHeaders = {};\n\t\t\t\t\t\t\twhile ( ( match = rheaders.exec( responseHeadersString ) ) ) {\n\t\t\t\t\t\t\t\tresponseHeaders[ match[ 1 ].toLowerCase() + \" \" ] =\n\t\t\t\t\t\t\t\t\t( responseHeaders[ match[ 1 ].toLowerCase() + \" \" ] || [] )\n\t\t\t\t\t\t\t\t\t\t.concat( match[ 2 ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmatch = responseHeaders[ key.toLowerCase() + \" \" ];\n\t\t\t\t\t}\n\t\t\t\t\treturn match == null ? null : match.join( \", \" );\n\t\t\t\t},\n\n\t\t\t\t// Raw string\n\t\t\t\tgetAllResponseHeaders: function() {\n\t\t\t\t\treturn completed ? responseHeadersString : null;\n\t\t\t\t},\n\n\t\t\t\t// Caches the header\n\t\t\t\tsetRequestHeader: function( name, value ) {\n\t\t\t\t\tif ( completed == null ) {\n\t\t\t\t\t\tname = requestHeadersNames[ name.toLowerCase() ] =\n\t\t\t\t\t\t\trequestHeadersNames[ name.toLowerCase() ] || name;\n\t\t\t\t\t\trequestHeaders[ name ] = value;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Overrides response content-type header\n\t\t\t\toverrideMimeType: function( type ) {\n\t\t\t\t\tif ( completed == null ) {\n\t\t\t\t\t\ts.mimeType = type;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Status-dependent callbacks\n\t\t\t\tstatusCode: function( map ) {\n\t\t\t\t\tvar code;\n\t\t\t\t\tif ( map ) {\n\t\t\t\t\t\tif ( completed ) {\n\n\t\t\t\t\t\t\t// Execute the appropriate callbacks\n\t\t\t\t\t\t\tjqXHR.always( map[ jqXHR.status ] );\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// Lazy-add the new callbacks in a way that preserves old ones\n\t\t\t\t\t\t\tfor ( code in map ) {\n\t\t\t\t\t\t\t\tstatusCode[ code ] = [ statusCode[ code ], map[ code ] ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Cancel the request\n\t\t\t\tabort: function( statusText ) {\n\t\t\t\t\tvar finalText = statusText || strAbort;\n\t\t\t\t\tif ( transport ) {\n\t\t\t\t\t\ttransport.abort( finalText );\n\t\t\t\t\t}\n\t\t\t\t\tdone( 0, finalText );\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t};\n\n\t\t// Attach deferreds\n\t\tdeferred.promise( jqXHR );\n\n\t\t// Add protocol if not provided (prefilters might expect it)\n\t\t// Handle falsy url in the settings object (trac-10093: consistency with old signature)\n\t\t// We also use the url parameter if available\n\t\ts.url = ( ( url || s.url || location.href ) + \"\" )\n\t\t\t.replace( rprotocol, location.protocol + \"//\" );\n\n\t\t// Alias method option to type as per ticket trac-12004\n\t\ts.type = options.method || options.type || s.method || s.type;\n\n\t\t// Extract dataTypes list\n\t\ts.dataTypes = ( s.dataType || \"*\" ).toLowerCase().match( rnothtmlwhite ) || [ \"\" ];\n\n\t\t// A cross-domain request is in order when the origin doesn't match the current origin.\n\t\tif ( s.crossDomain == null ) {\n\t\t\turlAnchor = document.createElement( \"a\" );\n\n\t\t\t// Support: IE <=8 - 11, Edge 12 - 15\n\t\t\t// IE throws exception on accessing the href property if url is malformed,\n\t\t\t// e.g. http://example.com:80x/\n\t\t\ttry {\n\t\t\t\turlAnchor.href = s.url;\n\n\t\t\t\t// Support: IE <=8 - 11 only\n\t\t\t\t// Anchor's host property isn't correctly set when s.url is relative\n\t\t\t\turlAnchor.href = urlAnchor.href;\n\t\t\t\ts.crossDomain = originAnchor.protocol + \"//\" + originAnchor.host !==\n\t\t\t\t\turlAnchor.protocol + \"//\" + urlAnchor.host;\n\t\t\t} catch ( e ) {\n\n\t\t\t\t// If there is an error parsing the URL, assume it is crossDomain,\n\t\t\t\t// it can be rejected by the transport if it is invalid\n\t\t\t\ts.crossDomain = true;\n\t\t\t}\n\t\t}\n\n\t\t// Convert data if not already a string\n\t\tif ( s.data && s.processData && typeof s.data !== \"string\" ) {\n\t\t\ts.data = jQuery.param( s.data, s.traditional );\n\t\t}\n\n\t\t// Apply prefilters\n\t\tinspectPrefiltersOrTransports( prefilters, s, options, jqXHR );\n\n\t\t// If request was aborted inside a prefilter, stop there\n\t\tif ( completed ) {\n\t\t\treturn jqXHR;\n\t\t}\n\n\t\t// We can fire global events as of now if asked to\n\t\t// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)\n\t\tfireGlobals = jQuery.event && s.global;\n\n\t\t// Watch for a new set of requests\n\t\tif ( fireGlobals && jQuery.active++ === 0 ) {\n\t\t\tjQuery.event.trigger( \"ajaxStart\" );\n\t\t}\n\n\t\t// Uppercase the type\n\t\ts.type = s.type.toUpperCase();\n\n\t\t// Determine if request has content\n\t\ts.hasContent = !rnoContent.test( s.type );\n\n\t\t// Save the URL in case we're toying with the If-Modified-Since\n\t\t// and/or If-None-Match header later on\n\t\t// Remove hash to simplify url manipulation\n\t\tcacheURL = s.url.replace( rhash, \"\" );\n\n\t\t// More options handling for requests with no content\n\t\tif ( !s.hasContent ) {\n\n\t\t\t// Remember the hash so we can put it back\n\t\t\tuncached = s.url.slice( cacheURL.length );\n\n\t\t\t// If data is available and should be processed, append data to url\n\t\t\tif ( s.data && ( s.processData || typeof s.data === \"string\" ) ) {\n\t\t\t\tcacheURL += ( rquery.test( cacheURL ) ? \"&\" : \"?\" ) + s.data;\n\n\t\t\t\t// trac-9682: remove data so that it's not used in an eventual retry\n\t\t\t\tdelete s.data;\n\t\t\t}\n\n\t\t\t// Add or update anti-cache param if needed\n\t\t\tif ( s.cache === false ) {\n\t\t\t\tcacheURL = cacheURL.replace( rantiCache, \"$1\" );\n\t\t\t\tuncached = ( rquery.test( cacheURL ) ? \"&\" : \"?\" ) + \"_=\" + ( nonce.guid++ ) +\n\t\t\t\t\tuncached;\n\t\t\t}\n\n\t\t\t// Put hash and anti-cache on the URL that will be requested (gh-1732)\n\t\t\ts.url = cacheURL + uncached;\n\n\t\t// Change '%20' to '+' if this is encoded form body content (gh-2658)\n\t\t} else if ( s.data && s.processData &&\n\t\t\t( s.contentType || \"\" ).indexOf( \"application/x-www-form-urlencoded\" ) === 0 ) {\n\t\t\ts.data = s.data.replace( r20, \"+\" );\n\t\t}\n\n\t\t// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.\n\t\tif ( s.ifModified ) {\n\t\t\tif ( jQuery.lastModified[ cacheURL ] ) {\n\t\t\t\tjqXHR.setRequestHeader( \"If-Modified-Since\", jQuery.lastModified[ cacheURL ] );\n\t\t\t}\n\t\t\tif ( jQuery.etag[ cacheURL ] ) {\n\t\t\t\tjqXHR.setRequestHeader( \"If-None-Match\", jQuery.etag[ cacheURL ] );\n\t\t\t}\n\t\t}\n\n\t\t// Set the correct header, if data is being sent\n\t\tif ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {\n\t\t\tjqXHR.setRequestHeader( \"Content-Type\", s.contentType );\n\t\t}\n\n\t\t// Set the Accepts header for the server, depending on the dataType\n\t\tjqXHR.setRequestHeader(\n\t\t\t\"Accept\",\n\t\t\ts.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?\n\t\t\t\ts.accepts[ s.dataTypes[ 0 ] ] +\n\t\t\t\t\t( s.dataTypes[ 0 ] !== \"*\" ? \", \" + allTypes + \"; q=0.01\" : \"\" ) :\n\t\t\t\ts.accepts[ \"*\" ]\n\t\t);\n\n\t\t// Check for headers option\n\t\tfor ( i in s.headers ) {\n\t\t\tjqXHR.setRequestHeader( i, s.headers[ i ] );\n\t\t}\n\n\t\t// Allow custom headers/mimetypes and early abort\n\t\tif ( s.beforeSend &&\n\t\t\t( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {\n\n\t\t\t// Abort if not done already and return\n\t\t\treturn jqXHR.abort();\n\t\t}\n\n\t\t// Aborting is no longer a cancellation\n\t\tstrAbort = \"abort\";\n\n\t\t// Install callbacks on deferreds\n\t\tcompleteDeferred.add( s.complete );\n\t\tjqXHR.done( s.success );\n\t\tjqXHR.fail( s.error );\n\n\t\t// Get transport\n\t\ttransport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );\n\n\t\t// If no transport, we auto-abort\n\t\tif ( !transport ) {\n\t\t\tdone( -1, \"No Transport\" );\n\t\t} else {\n\t\t\tjqXHR.readyState = 1;\n\n\t\t\t// Send global event\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( \"ajaxSend\", [ jqXHR, s ] );\n\t\t\t}\n\n\t\t\t// If request was aborted inside ajaxSend, stop there\n\t\t\tif ( completed ) {\n\t\t\t\treturn jqXHR;\n\t\t\t}\n\n\t\t\t// Timeout\n\t\t\tif ( s.async && s.timeout > 0 ) {\n\t\t\t\ttimeoutTimer = window.setTimeout( function() {\n\t\t\t\t\tjqXHR.abort( \"timeout\" );\n\t\t\t\t}, s.timeout );\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tcompleted = false;\n\t\t\t\ttransport.send( requestHeaders, done );\n\t\t\t} catch ( e ) {\n\n\t\t\t\t// Rethrow post-completion exceptions\n\t\t\t\tif ( completed ) {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\n\t\t\t\t// Propagate others as results\n\t\t\t\tdone( -1, e );\n\t\t\t}\n\t\t}\n\n\t\t// Callback for when everything is done\n\t\tfunction done( status, nativeStatusText, responses, headers ) {\n\t\t\tvar isSuccess, success, error, response, modified,\n\t\t\t\tstatusText = nativeStatusText;\n\n\t\t\t// Ignore repeat invocations\n\t\t\tif ( completed ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcompleted = true;\n\n\t\t\t// Clear timeout if it exists\n\t\t\tif ( timeoutTimer ) {\n\t\t\t\twindow.clearTimeout( timeoutTimer );\n\t\t\t}\n\n\t\t\t// Dereference transport for early garbage collection\n\t\t\t// (no matter how long the jqXHR object will be used)\n\t\t\ttransport = undefined;\n\n\t\t\t// Cache response headers\n\t\t\tresponseHeadersString = headers || \"\";\n\n\t\t\t// Set readyState\n\t\t\tjqXHR.readyState = status > 0 ? 4 : 0;\n\n\t\t\t// Determine if successful\n\t\t\tisSuccess = status >= 200 && status < 300 || status === 304;\n\n\t\t\t// Get response data\n\t\t\tif ( responses ) {\n\t\t\t\tresponse = ajaxHandleResponses( s, jqXHR, responses );\n\t\t\t}\n\n\t\t\t// Use a noop converter for missing script but not if jsonp\n\t\t\tif ( !isSuccess &&\n\t\t\t\tjQuery.inArray( \"script\", s.dataTypes ) > -1 &&\n\t\t\t\tjQuery.inArray( \"json\", s.dataTypes ) < 0 ) {\n\t\t\t\ts.converters[ \"text script\" ] = function() {};\n\t\t\t}\n\n\t\t\t// Convert no matter what (that way responseXXX fields are always set)\n\t\t\tresponse = ajaxConvert( s, response, jqXHR, isSuccess );\n\n\t\t\t// If successful, handle type chaining\n\t\t\tif ( isSuccess ) {\n\n\t\t\t\t// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.\n\t\t\t\tif ( s.ifModified ) {\n\t\t\t\t\tmodified = jqXHR.getResponseHeader( \"Last-Modified\" );\n\t\t\t\t\tif ( modified ) {\n\t\t\t\t\t\tjQuery.lastModified[ cacheURL ] = modified;\n\t\t\t\t\t}\n\t\t\t\t\tmodified = jqXHR.getResponseHeader( \"etag\" );\n\t\t\t\t\tif ( modified ) {\n\t\t\t\t\t\tjQuery.etag[ cacheURL ] = modified;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// if no content\n\t\t\t\tif ( status === 204 || s.type === \"HEAD\" ) {\n\t\t\t\t\tstatusText = \"nocontent\";\n\n\t\t\t\t// if not modified\n\t\t\t\t} else if ( status === 304 ) {\n\t\t\t\t\tstatusText = \"notmodified\";\n\n\t\t\t\t// If we have data, let's convert it\n\t\t\t\t} else {\n\t\t\t\t\tstatusText = response.state;\n\t\t\t\t\tsuccess = response.data;\n\t\t\t\t\terror = response.error;\n\t\t\t\t\tisSuccess = !error;\n\t\t\t\t}\n\t\t\t} else {\n\n\t\t\t\t// Extract error from statusText and normalize for non-aborts\n\t\t\t\terror = statusText;\n\t\t\t\tif ( status || !statusText ) {\n\t\t\t\t\tstatusText = \"error\";\n\t\t\t\t\tif ( status < 0 ) {\n\t\t\t\t\t\tstatus = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Set data for the fake xhr object\n\t\t\tjqXHR.status = status;\n\t\t\tjqXHR.statusText = ( nativeStatusText || statusText ) + \"\";\n\n\t\t\t// Success/Error\n\t\t\tif ( isSuccess ) {\n\t\t\t\tdeferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );\n\t\t\t} else {\n\t\t\t\tdeferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );\n\t\t\t}\n\n\t\t\t// Status-dependent callbacks\n\t\t\tjqXHR.statusCode( statusCode );\n\t\t\tstatusCode = undefined;\n\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( isSuccess ? \"ajaxSuccess\" : \"ajaxError\",\n\t\t\t\t\t[ jqXHR, s, isSuccess ? success : error ] );\n\t\t\t}\n\n\t\t\t// Complete\n\t\t\tcompleteDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );\n\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( \"ajaxComplete\", [ jqXHR, s ] );\n\n\t\t\t\t// Handle the global AJAX counter\n\t\t\t\tif ( !( --jQuery.active ) ) {\n\t\t\t\t\tjQuery.event.trigger( \"ajaxStop\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jqXHR;\n\t},\n\n\tgetJSON: function( url, data, callback ) {\n\t\treturn jQuery.get( url, data, callback, \"json\" );\n\t},\n\n\tgetScript: function( url, callback ) {\n\t\treturn jQuery.get( url, undefined, callback, \"script\" );\n\t}\n} );\n\njQuery.each( [ \"get\", \"post\" ], function( _i, method ) {\n\tjQuery[ method ] = function( url, data, callback, type ) {\n\n\t\t// Shift arguments if data argument was omitted\n\t\tif ( isFunction( data ) ) {\n\t\t\ttype = type || callback;\n\t\t\tcallback = data;\n\t\t\tdata = undefined;\n\t\t}\n\n\t\t// The url can be an options object (which then must have .url)\n\t\treturn jQuery.ajax( jQuery.extend( {\n\t\t\turl: url,\n\t\t\ttype: method,\n\t\t\tdataType: type,\n\t\t\tdata: data,\n\t\t\tsuccess: callback\n\t\t}, jQuery.isPlainObject( url ) && url ) );\n\t};\n} );\n\njQuery.ajaxPrefilter( function( s ) {\n\tvar i;\n\tfor ( i in s.headers ) {\n\t\tif ( i.toLowerCase() === \"content-type\" ) {\n\t\t\ts.contentType = s.headers[ i ] || \"\";\n\t\t}\n\t}\n} );\n\n\njQuery._evalUrl = function( url, options, doc ) {\n\treturn jQuery.ajax( {\n\t\turl: url,\n\n\t\t// Make this explicit, since user can override this through ajaxSetup (trac-11264)\n\t\ttype: \"GET\",\n\t\tdataType: \"script\",\n\t\tcache: true,\n\t\tasync: false,\n\t\tglobal: false,\n\n\t\t// Only evaluate the response if it is successful (gh-4126)\n\t\t// dataFilter is not invoked for failure responses, so using it instead\n\t\t// of the default converter is kludgy but it works.\n\t\tconverters: {\n\t\t\t\"text script\": function() {}\n\t\t},\n\t\tdataFilter: function( response ) {\n\t\t\tjQuery.globalEval( response, options, doc );\n\t\t}\n\t} );\n};\n\n\njQuery.fn.extend( {\n\twrapAll: function( html ) {\n\t\tvar wrap;\n\n\t\tif ( this[ 0 ] ) {\n\t\t\tif ( isFunction( html ) ) {\n\t\t\t\thtml = html.call( this[ 0 ] );\n\t\t\t}\n\n\t\t\t// The elements to wrap the target around\n\t\t\twrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );\n\n\t\t\tif ( this[ 0 ].parentNode ) {\n\t\t\t\twrap.insertBefore( this[ 0 ] );\n\t\t\t}\n\n\t\t\twrap.map( function() {\n\t\t\t\tvar elem = this;\n\n\t\t\t\twhile ( elem.firstElementChild ) {\n\t\t\t\t\telem = elem.firstElementChild;\n\t\t\t\t}\n\n\t\t\t\treturn elem;\n\t\t\t} ).append( this );\n\t\t}\n\n\t\treturn this;\n\t},\n\n\twrapInner: function( html ) {\n\t\tif ( isFunction( html ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).wrapInner( html.call( this, i ) );\n\t\t\t} );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar self = jQuery( this ),\n\t\t\t\tcontents = self.contents();\n\n\t\t\tif ( contents.length ) {\n\t\t\t\tcontents.wrapAll( html );\n\n\t\t\t} else {\n\t\t\t\tself.append( html );\n\t\t\t}\n\t\t} );\n\t},\n\n\twrap: function( html ) {\n\t\tvar htmlIsFunction = isFunction( html );\n\n\t\treturn this.each( function( i ) {\n\t\t\tjQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );\n\t\t} );\n\t},\n\n\tunwrap: function( selector ) {\n\t\tthis.parent( selector ).not( \"body\" ).each( function() {\n\t\t\tjQuery( this ).replaceWith( this.childNodes );\n\t\t} );\n\t\treturn this;\n\t}\n} );\n\n\njQuery.expr.pseudos.hidden = function( elem ) {\n\treturn !jQuery.expr.pseudos.visible( elem );\n};\njQuery.expr.pseudos.visible = function( elem ) {\n\treturn !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );\n};\n\n\n\n\njQuery.ajaxSettings.xhr = function() {\n\ttry {\n\t\treturn new window.XMLHttpRequest();\n\t} catch ( e ) {}\n};\n\nvar xhrSuccessStatus = {\n\n\t\t// File protocol always yields status code 0, assume 200\n\t\t0: 200,\n\n\t\t// Support: IE <=9 only\n\t\t// trac-1450: sometimes IE returns 1223 when it should be 204\n\t\t1223: 204\n\t},\n\txhrSupported = jQuery.ajaxSettings.xhr();\n\nsupport.cors = !!xhrSupported && ( \"withCredentials\" in xhrSupported );\nsupport.ajax = xhrSupported = !!xhrSupported;\n\njQuery.ajaxTransport( function( options ) {\n\tvar callback, errorCallback;\n\n\t// Cross domain only allowed if supported through XMLHttpRequest\n\tif ( support.cors || xhrSupported && !options.crossDomain ) {\n\t\treturn {\n\t\t\tsend: function( headers, complete ) {\n\t\t\t\tvar i,\n\t\t\t\t\txhr = options.xhr();\n\n\t\t\t\txhr.open(\n\t\t\t\t\toptions.type,\n\t\t\t\t\toptions.url,\n\t\t\t\t\toptions.async,\n\t\t\t\t\toptions.username,\n\t\t\t\t\toptions.password\n\t\t\t\t);\n\n\t\t\t\t// Apply custom fields if provided\n\t\t\t\tif ( options.xhrFields ) {\n\t\t\t\t\tfor ( i in options.xhrFields ) {\n\t\t\t\t\t\txhr[ i ] = options.xhrFields[ i ];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Override mime type if needed\n\t\t\t\tif ( options.mimeType && xhr.overrideMimeType ) {\n\t\t\t\t\txhr.overrideMimeType( options.mimeType );\n\t\t\t\t}\n\n\t\t\t\t// X-Requested-With header\n\t\t\t\t// For cross-domain requests, seeing as conditions for a preflight are\n\t\t\t\t// akin to a jigsaw puzzle, we simply never set it to be sure.\n\t\t\t\t// (it can always be set on a per-request basis or even using ajaxSetup)\n\t\t\t\t// For same-domain requests, won't change header if already provided.\n\t\t\t\tif ( !options.crossDomain && !headers[ \"X-Requested-With\" ] ) {\n\t\t\t\t\theaders[ \"X-Requested-With\" ] = \"XMLHttpRequest\";\n\t\t\t\t}\n\n\t\t\t\t// Set headers\n\t\t\t\tfor ( i in headers ) {\n\t\t\t\t\txhr.setRequestHeader( i, headers[ i ] );\n\t\t\t\t}\n\n\t\t\t\t// Callback\n\t\t\t\tcallback = function( type ) {\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\t\tcallback = errorCallback = xhr.onload =\n\t\t\t\t\t\t\t\txhr.onerror = xhr.onabort = xhr.ontimeout =\n\t\t\t\t\t\t\t\t\txhr.onreadystatechange = null;\n\n\t\t\t\t\t\t\tif ( type === \"abort\" ) {\n\t\t\t\t\t\t\t\txhr.abort();\n\t\t\t\t\t\t\t} else if ( type === \"error\" ) {\n\n\t\t\t\t\t\t\t\t// Support: IE <=9 only\n\t\t\t\t\t\t\t\t// On a manual native abort, IE9 throws\n\t\t\t\t\t\t\t\t// errors on any property access that is not readyState\n\t\t\t\t\t\t\t\tif ( typeof xhr.status !== \"number\" ) {\n\t\t\t\t\t\t\t\t\tcomplete( 0, \"error\" );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcomplete(\n\n\t\t\t\t\t\t\t\t\t\t// File: protocol always yields status 0; see trac-8605, trac-14207\n\t\t\t\t\t\t\t\t\t\txhr.status,\n\t\t\t\t\t\t\t\t\t\txhr.statusText\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcomplete(\n\t\t\t\t\t\t\t\t\txhrSuccessStatus[ xhr.status ] || xhr.status,\n\t\t\t\t\t\t\t\t\txhr.statusText,\n\n\t\t\t\t\t\t\t\t\t// Support: IE <=9 only\n\t\t\t\t\t\t\t\t\t// IE9 has no XHR2 but throws on binary (trac-11426)\n\t\t\t\t\t\t\t\t\t// For XHR2 non-text, let the caller handle it (gh-2498)\n\t\t\t\t\t\t\t\t\t( xhr.responseType || \"text\" ) !== \"text\"  ||\n\t\t\t\t\t\t\t\t\ttypeof xhr.responseText !== \"string\" ?\n\t\t\t\t\t\t\t\t\t\t{ binary: xhr.response } :\n\t\t\t\t\t\t\t\t\t\t{ text: xhr.responseText },\n\t\t\t\t\t\t\t\t\txhr.getAllResponseHeaders()\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t};\n\n\t\t\t\t// Listen to events\n\t\t\t\txhr.onload = callback();\n\t\t\t\terrorCallback = xhr.onerror = xhr.ontimeout = callback( \"error\" );\n\n\t\t\t\t// Support: IE 9 only\n\t\t\t\t// Use onreadystatechange to replace onabort\n\t\t\t\t// to handle uncaught aborts\n\t\t\t\tif ( xhr.onabort !== undefined ) {\n\t\t\t\t\txhr.onabort = errorCallback;\n\t\t\t\t} else {\n\t\t\t\t\txhr.onreadystatechange = function() {\n\n\t\t\t\t\t\t// Check readyState before timeout as it changes\n\t\t\t\t\t\tif ( xhr.readyState === 4 ) {\n\n\t\t\t\t\t\t\t// Allow onerror to be called first,\n\t\t\t\t\t\t\t// but that will not handle a native abort\n\t\t\t\t\t\t\t// Also, save errorCallback to a variable\n\t\t\t\t\t\t\t// as xhr.onerror cannot be accessed\n\t\t\t\t\t\t\twindow.setTimeout( function() {\n\t\t\t\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\t\t\t\terrorCallback();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Create the abort callback\n\t\t\t\tcallback = callback( \"abort\" );\n\n\t\t\t\ttry {\n\n\t\t\t\t\t// Do send the request (this may raise an exception)\n\t\t\t\t\txhr.send( options.hasContent && options.data || null );\n\t\t\t\t} catch ( e ) {\n\n\t\t\t\t\t// trac-14683: Only rethrow if this hasn't been notified as an error yet\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tabort: function() {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n} );\n\n\n\n\n// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)\njQuery.ajaxPrefilter( function( s ) {\n\tif ( s.crossDomain ) {\n\t\ts.contents.script = false;\n\t}\n} );\n\n// Install script dataType\njQuery.ajaxSetup( {\n\taccepts: {\n\t\tscript: \"text/javascript, application/javascript, \" +\n\t\t\t\"application/ecmascript, application/x-ecmascript\"\n\t},\n\tcontents: {\n\t\tscript: /\\b(?:java|ecma)script\\b/\n\t},\n\tconverters: {\n\t\t\"text script\": function( text ) {\n\t\t\tjQuery.globalEval( text );\n\t\t\treturn text;\n\t\t}\n\t}\n} );\n\n// Handle cache's special case and crossDomain\njQuery.ajaxPrefilter( \"script\", function( s ) {\n\tif ( s.cache === undefined ) {\n\t\ts.cache = false;\n\t}\n\tif ( s.crossDomain ) {\n\t\ts.type = \"GET\";\n\t}\n} );\n\n// Bind script tag hack transport\njQuery.ajaxTransport( \"script\", function( s ) {\n\n\t// This transport only deals with cross domain or forced-by-attrs requests\n\tif ( s.crossDomain || s.scriptAttrs ) {\n\t\tvar script, callback;\n\t\treturn {\n\t\t\tsend: function( _, complete ) {\n\t\t\t\tscript = jQuery( \"<script>\" )\n\t\t\t\t\t.attr( s.scriptAttrs || {} )\n\t\t\t\t\t.prop( { charset: s.scriptCharset, src: s.url } )\n\t\t\t\t\t.on( \"load error\", callback = function( evt ) {\n\t\t\t\t\t\tscript.remove();\n\t\t\t\t\t\tcallback = null;\n\t\t\t\t\t\tif ( evt ) {\n\t\t\t\t\t\t\tcomplete( evt.type === \"error\" ? 404 : 200, evt.type );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t// Use native DOM manipulation to avoid our domManip AJAX trickery\n\t\t\t\tdocument.head.appendChild( script[ 0 ] );\n\t\t\t},\n\t\t\tabort: function() {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n} );\n\n\n\n\nvar oldCallbacks = [],\n\trjsonp = /(=)\\?(?=&|$)|\\?\\?/;\n\n// Default jsonp settings\njQuery.ajaxSetup( {\n\tjsonp: \"callback\",\n\tjsonpCallback: function() {\n\t\tvar callback = oldCallbacks.pop() || ( jQuery.expando + \"_\" + ( nonce.guid++ ) );\n\t\tthis[ callback ] = true;\n\t\treturn callback;\n\t}\n} );\n\n// Detect, normalize options and install callbacks for jsonp requests\njQuery.ajaxPrefilter( \"json jsonp\", function( s, originalSettings, jqXHR ) {\n\n\tvar callbackName, overwritten, responseContainer,\n\t\tjsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?\n\t\t\t\"url\" :\n\t\t\ttypeof s.data === \"string\" &&\n\t\t\t\t( s.contentType || \"\" )\n\t\t\t\t\t.indexOf( \"application/x-www-form-urlencoded\" ) === 0 &&\n\t\t\t\trjsonp.test( s.data ) && \"data\"\n\t\t);\n\n\t// Handle iff the expected data type is \"jsonp\" or we have a parameter to set\n\tif ( jsonProp || s.dataTypes[ 0 ] === \"jsonp\" ) {\n\n\t\t// Get callback name, remembering preexisting value associated with it\n\t\tcallbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?\n\t\t\ts.jsonpCallback() :\n\t\t\ts.jsonpCallback;\n\n\t\t// Insert callback into url or form data\n\t\tif ( jsonProp ) {\n\t\t\ts[ jsonProp ] = s[ jsonProp ].replace( rjsonp, \"$1\" + callbackName );\n\t\t} else if ( s.jsonp !== false ) {\n\t\t\ts.url += ( rquery.test( s.url ) ? \"&\" : \"?\" ) + s.jsonp + \"=\" + callbackName;\n\t\t}\n\n\t\t// Use data converter to retrieve json after script execution\n\t\ts.converters[ \"script json\" ] = function() {\n\t\t\tif ( !responseContainer ) {\n\t\t\t\tjQuery.error( callbackName + \" was not called\" );\n\t\t\t}\n\t\t\treturn responseContainer[ 0 ];\n\t\t};\n\n\t\t// Force json dataType\n\t\ts.dataTypes[ 0 ] = \"json\";\n\n\t\t// Install callback\n\t\toverwritten = window[ callbackName ];\n\t\twindow[ callbackName ] = function() {\n\t\t\tresponseContainer = arguments;\n\t\t};\n\n\t\t// Clean-up function (fires after converters)\n\t\tjqXHR.always( function() {\n\n\t\t\t// If previous value didn't exist - remove it\n\t\t\tif ( overwritten === undefined ) {\n\t\t\t\tjQuery( window ).removeProp( callbackName );\n\n\t\t\t// Otherwise restore preexisting value\n\t\t\t} else {\n\t\t\t\twindow[ callbackName ] = overwritten;\n\t\t\t}\n\n\t\t\t// Save back as free\n\t\t\tif ( s[ callbackName ] ) {\n\n\t\t\t\t// Make sure that re-using the options doesn't screw things around\n\t\t\t\ts.jsonpCallback = originalSettings.jsonpCallback;\n\n\t\t\t\t// Save the callback name for future use\n\t\t\t\toldCallbacks.push( callbackName );\n\t\t\t}\n\n\t\t\t// Call if it was a function and we have a response\n\t\t\tif ( responseContainer && isFunction( overwritten ) ) {\n\t\t\t\toverwritten( responseContainer[ 0 ] );\n\t\t\t}\n\n\t\t\tresponseContainer = overwritten = undefined;\n\t\t} );\n\n\t\t// Delegate to script\n\t\treturn \"script\";\n\t}\n} );\n\n\n\n\n// Support: Safari 8 only\n// In Safari 8 documents created via document.implementation.createHTMLDocument\n// collapse sibling forms: the second one becomes a child of the first one.\n// Because of that, this security measure has to be disabled in Safari 8.\n// https://bugs.webkit.org/show_bug.cgi?id=137337\nsupport.createHTMLDocument = ( function() {\n\tvar body = document.implementation.createHTMLDocument( \"\" ).body;\n\tbody.innerHTML = \"<form></form><form></form>\";\n\treturn body.childNodes.length === 2;\n} )();\n\n\n// Argument \"data\" should be string of html\n// context (optional): If specified, the fragment will be created in this context,\n// defaults to document\n// keepScripts (optional): If true, will include scripts passed in the html string\njQuery.parseHTML = function( data, context, keepScripts ) {\n\tif ( typeof data !== \"string\" ) {\n\t\treturn [];\n\t}\n\tif ( typeof context === \"boolean\" ) {\n\t\tkeepScripts = context;\n\t\tcontext = false;\n\t}\n\n\tvar base, parsed, scripts;\n\n\tif ( !context ) {\n\n\t\t// Stop scripts or inline event handlers from being executed immediately\n\t\t// by using document.implementation\n\t\tif ( support.createHTMLDocument ) {\n\t\t\tcontext = document.implementation.createHTMLDocument( \"\" );\n\n\t\t\t// Set the base href for the created document\n\t\t\t// so any parsed elements with URLs\n\t\t\t// are based on the document's URL (gh-2965)\n\t\t\tbase = context.createElement( \"base\" );\n\t\t\tbase.href = document.location.href;\n\t\t\tcontext.head.appendChild( base );\n\t\t} else {\n\t\t\tcontext = document;\n\t\t}\n\t}\n\n\tparsed = rsingleTag.exec( data );\n\tscripts = !keepScripts && [];\n\n\t// Single tag\n\tif ( parsed ) {\n\t\treturn [ context.createElement( parsed[ 1 ] ) ];\n\t}\n\n\tparsed = buildFragment( [ data ], context, scripts );\n\n\tif ( scripts && scripts.length ) {\n\t\tjQuery( scripts ).remove();\n\t}\n\n\treturn jQuery.merge( [], parsed.childNodes );\n};\n\n\n/**\n * Load a url into a page\n */\njQuery.fn.load = function( url, params, callback ) {\n\tvar selector, type, response,\n\t\tself = this,\n\t\toff = url.indexOf( \" \" );\n\n\tif ( off > -1 ) {\n\t\tselector = stripAndCollapse( url.slice( off ) );\n\t\turl = url.slice( 0, off );\n\t}\n\n\t// If it's a function\n\tif ( isFunction( params ) ) {\n\n\t\t// We assume that it's the callback\n\t\tcallback = params;\n\t\tparams = undefined;\n\n\t// Otherwise, build a param string\n\t} else if ( params && typeof params === \"object\" ) {\n\t\ttype = \"POST\";\n\t}\n\n\t// If we have elements to modify, make the request\n\tif ( self.length > 0 ) {\n\t\tjQuery.ajax( {\n\t\t\turl: url,\n\n\t\t\t// If \"type\" variable is undefined, then \"GET\" method will be used.\n\t\t\t// Make value of this field explicit since\n\t\t\t// user can override it through ajaxSetup method\n\t\t\ttype: type || \"GET\",\n\t\t\tdataType: \"html\",\n\t\t\tdata: params\n\t\t} ).done( function( responseText ) {\n\n\t\t\t// Save response for use in complete callback\n\t\t\tresponse = arguments;\n\n\t\t\tself.html( selector ?\n\n\t\t\t\t// If a selector was specified, locate the right elements in a dummy div\n\t\t\t\t// Exclude scripts to avoid IE 'Permission Denied' errors\n\t\t\t\tjQuery( \"<div>\" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :\n\n\t\t\t\t// Otherwise use the full result\n\t\t\t\tresponseText );\n\n\t\t// If the request succeeds, this function gets \"data\", \"status\", \"jqXHR\"\n\t\t// but they are ignored because response was set above.\n\t\t// If it fails, this function gets \"jqXHR\", \"status\", \"error\"\n\t\t} ).always( callback && function( jqXHR, status ) {\n\t\t\tself.each( function() {\n\t\t\t\tcallback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );\n\t\t\t} );\n\t\t} );\n\t}\n\n\treturn this;\n};\n\n\n\n\njQuery.expr.pseudos.animated = function( elem ) {\n\treturn jQuery.grep( jQuery.timers, function( fn ) {\n\t\treturn elem === fn.elem;\n\t} ).length;\n};\n\n\n\n\njQuery.offset = {\n\tsetOffset: function( elem, options, i ) {\n\t\tvar curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,\n\t\t\tposition = jQuery.css( elem, \"position\" ),\n\t\t\tcurElem = jQuery( elem ),\n\t\t\tprops = {};\n\n\t\t// Set position first, in-case top/left are set even on static elem\n\t\tif ( position === \"static\" ) {\n\t\t\telem.style.position = \"relative\";\n\t\t}\n\n\t\tcurOffset = curElem.offset();\n\t\tcurCSSTop = jQuery.css( elem, \"top\" );\n\t\tcurCSSLeft = jQuery.css( elem, \"left\" );\n\t\tcalculatePosition = ( position === \"absolute\" || position === \"fixed\" ) &&\n\t\t\t( curCSSTop + curCSSLeft ).indexOf( \"auto\" ) > -1;\n\n\t\t// Need to be able to calculate position if either\n\t\t// top or left is auto and position is either absolute or fixed\n\t\tif ( calculatePosition ) {\n\t\t\tcurPosition = curElem.position();\n\t\t\tcurTop = curPosition.top;\n\t\t\tcurLeft = curPosition.left;\n\n\t\t} else {\n\t\t\tcurTop = parseFloat( curCSSTop ) || 0;\n\t\t\tcurLeft = parseFloat( curCSSLeft ) || 0;\n\t\t}\n\n\t\tif ( isFunction( options ) ) {\n\n\t\t\t// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)\n\t\t\toptions = options.call( elem, i, jQuery.extend( {}, curOffset ) );\n\t\t}\n\n\t\tif ( options.top != null ) {\n\t\t\tprops.top = ( options.top - curOffset.top ) + curTop;\n\t\t}\n\t\tif ( options.left != null ) {\n\t\t\tprops.left = ( options.left - curOffset.left ) + curLeft;\n\t\t}\n\n\t\tif ( \"using\" in options ) {\n\t\t\toptions.using.call( elem, props );\n\n\t\t} else {\n\t\t\tcurElem.css( props );\n\t\t}\n\t}\n};\n\njQuery.fn.extend( {\n\n\t// offset() relates an element's border box to the document origin\n\toffset: function( options ) {\n\n\t\t// Preserve chaining for setter\n\t\tif ( arguments.length ) {\n\t\t\treturn options === undefined ?\n\t\t\t\tthis :\n\t\t\t\tthis.each( function( i ) {\n\t\t\t\t\tjQuery.offset.setOffset( this, options, i );\n\t\t\t\t} );\n\t\t}\n\n\t\tvar rect, win,\n\t\t\telem = this[ 0 ];\n\n\t\tif ( !elem ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Return zeros for disconnected and hidden (display: none) elements (gh-2310)\n\t\t// Support: IE <=11 only\n\t\t// Running getBoundingClientRect on a\n\t\t// disconnected node in IE throws an error\n\t\tif ( !elem.getClientRects().length ) {\n\t\t\treturn { top: 0, left: 0 };\n\t\t}\n\n\t\t// Get document-relative position by adding viewport scroll to viewport-relative gBCR\n\t\trect = elem.getBoundingClientRect();\n\t\twin = elem.ownerDocument.defaultView;\n\t\treturn {\n\t\t\ttop: rect.top + win.pageYOffset,\n\t\t\tleft: rect.left + win.pageXOffset\n\t\t};\n\t},\n\n\t// position() relates an element's margin box to its offset parent's padding box\n\t// This corresponds to the behavior of CSS absolute positioning\n\tposition: function() {\n\t\tif ( !this[ 0 ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar offsetParent, offset, doc,\n\t\t\telem = this[ 0 ],\n\t\t\tparentOffset = { top: 0, left: 0 };\n\n\t\t// position:fixed elements are offset from the viewport, which itself always has zero offset\n\t\tif ( jQuery.css( elem, \"position\" ) === \"fixed\" ) {\n\n\t\t\t// Assume position:fixed implies availability of getBoundingClientRect\n\t\t\toffset = elem.getBoundingClientRect();\n\n\t\t} else {\n\t\t\toffset = this.offset();\n\n\t\t\t// Account for the *real* offset parent, which can be the document or its root element\n\t\t\t// when a statically positioned element is identified\n\t\t\tdoc = elem.ownerDocument;\n\t\t\toffsetParent = elem.offsetParent || doc.documentElement;\n\t\t\twhile ( offsetParent &&\n\t\t\t\t( offsetParent === doc.body || offsetParent === doc.documentElement ) &&\n\t\t\t\tjQuery.css( offsetParent, \"position\" ) === \"static\" ) {\n\n\t\t\t\toffsetParent = offsetParent.parentNode;\n\t\t\t}\n\t\t\tif ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {\n\n\t\t\t\t// Incorporate borders into its offset, since they are outside its content origin\n\t\t\t\tparentOffset = jQuery( offsetParent ).offset();\n\t\t\t\tparentOffset.top += jQuery.css( offsetParent, \"borderTopWidth\", true );\n\t\t\t\tparentOffset.left += jQuery.css( offsetParent, \"borderLeftWidth\", true );\n\t\t\t}\n\t\t}\n\n\t\t// Subtract parent offsets and element margins\n\t\treturn {\n\t\t\ttop: offset.top - parentOffset.top - jQuery.css( elem, \"marginTop\", true ),\n\t\t\tleft: offset.left - parentOffset.left - jQuery.css( elem, \"marginLeft\", true )\n\t\t};\n\t},\n\n\t// This method will return documentElement in the following cases:\n\t// 1) For the element inside the iframe without offsetParent, this method will return\n\t//    documentElement of the parent window\n\t// 2) For the hidden or detached element\n\t// 3) For body or html element, i.e. in case of the html node - it will return itself\n\t//\n\t// but those exceptions were never presented as a real life use-cases\n\t// and might be considered as more preferable results.\n\t//\n\t// This logic, however, is not guaranteed and can change at any point in the future\n\toffsetParent: function() {\n\t\treturn this.map( function() {\n\t\t\tvar offsetParent = this.offsetParent;\n\n\t\t\twhile ( offsetParent && jQuery.css( offsetParent, \"position\" ) === \"static\" ) {\n\t\t\t\toffsetParent = offsetParent.offsetParent;\n\t\t\t}\n\n\t\t\treturn offsetParent || documentElement;\n\t\t} );\n\t}\n} );\n\n// Create scrollLeft and scrollTop methods\njQuery.each( { scrollLeft: \"pageXOffset\", scrollTop: \"pageYOffset\" }, function( method, prop ) {\n\tvar top = \"pageYOffset\" === prop;\n\n\tjQuery.fn[ method ] = function( val ) {\n\t\treturn access( this, function( elem, method, val ) {\n\n\t\t\t// Coalesce documents and windows\n\t\t\tvar win;\n\t\t\tif ( isWindow( elem ) ) {\n\t\t\t\twin = elem;\n\t\t\t} else if ( elem.nodeType === 9 ) {\n\t\t\t\twin = elem.defaultView;\n\t\t\t}\n\n\t\t\tif ( val === undefined ) {\n\t\t\t\treturn win ? win[ prop ] : elem[ method ];\n\t\t\t}\n\n\t\t\tif ( win ) {\n\t\t\t\twin.scrollTo(\n\t\t\t\t\t!top ? val : win.pageXOffset,\n\t\t\t\t\ttop ? val : win.pageYOffset\n\t\t\t\t);\n\n\t\t\t} else {\n\t\t\t\telem[ method ] = val;\n\t\t\t}\n\t\t}, method, val, arguments.length );\n\t};\n} );\n\n// Support: Safari <=7 - 9.1, Chrome <=37 - 49\n// Add the top/left cssHooks using jQuery.fn.position\n// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084\n// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347\n// getComputedStyle returns percent when specified for top/left/bottom/right;\n// rather than make the css module depend on the offset module, just check for it here\njQuery.each( [ \"top\", \"left\" ], function( _i, prop ) {\n\tjQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,\n\t\tfunction( elem, computed ) {\n\t\t\tif ( computed ) {\n\t\t\t\tcomputed = curCSS( elem, prop );\n\n\t\t\t\t// If curCSS returns percentage, fallback to offset\n\t\t\t\treturn rnumnonpx.test( computed ) ?\n\t\t\t\t\tjQuery( elem ).position()[ prop ] + \"px\" :\n\t\t\t\t\tcomputed;\n\t\t\t}\n\t\t}\n\t);\n} );\n\n\n// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods\njQuery.each( { Height: \"height\", Width: \"width\" }, function( name, type ) {\n\tjQuery.each( {\n\t\tpadding: \"inner\" + name,\n\t\tcontent: type,\n\t\t\"\": \"outer\" + name\n\t}, function( defaultExtra, funcName ) {\n\n\t\t// Margin is only for outerHeight, outerWidth\n\t\tjQuery.fn[ funcName ] = function( margin, value ) {\n\t\t\tvar chainable = arguments.length && ( defaultExtra || typeof margin !== \"boolean\" ),\n\t\t\t\textra = defaultExtra || ( margin === true || value === true ? \"margin\" : \"border\" );\n\n\t\t\treturn access( this, function( elem, type, value ) {\n\t\t\t\tvar doc;\n\n\t\t\t\tif ( isWindow( elem ) ) {\n\n\t\t\t\t\t// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)\n\t\t\t\t\treturn funcName.indexOf( \"outer\" ) === 0 ?\n\t\t\t\t\t\telem[ \"inner\" + name ] :\n\t\t\t\t\t\telem.document.documentElement[ \"client\" + name ];\n\t\t\t\t}\n\n\t\t\t\t// Get document width or height\n\t\t\t\tif ( elem.nodeType === 9 ) {\n\t\t\t\t\tdoc = elem.documentElement;\n\n\t\t\t\t\t// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],\n\t\t\t\t\t// whichever is greatest\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\telem.body[ \"scroll\" + name ], doc[ \"scroll\" + name ],\n\t\t\t\t\t\telem.body[ \"offset\" + name ], doc[ \"offset\" + name ],\n\t\t\t\t\t\tdoc[ \"client\" + name ]\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn value === undefined ?\n\n\t\t\t\t\t// Get width or height on the element, requesting but not forcing parseFloat\n\t\t\t\t\tjQuery.css( elem, type, extra ) :\n\n\t\t\t\t\t// Set width or height on the element\n\t\t\t\t\tjQuery.style( elem, type, value, extra );\n\t\t\t}, type, chainable ? margin : undefined, chainable );\n\t\t};\n\t} );\n} );\n\n\njQuery.each( [\n\t\"ajaxStart\",\n\t\"ajaxStop\",\n\t\"ajaxComplete\",\n\t\"ajaxError\",\n\t\"ajaxSuccess\",\n\t\"ajaxSend\"\n], function( _i, type ) {\n\tjQuery.fn[ type ] = function( fn ) {\n\t\treturn this.on( type, fn );\n\t};\n} );\n\n\n\n\njQuery.fn.extend( {\n\n\tbind: function( types, data, fn ) {\n\t\treturn this.on( types, null, data, fn );\n\t},\n\tunbind: function( types, fn ) {\n\t\treturn this.off( types, null, fn );\n\t},\n\n\tdelegate: function( selector, types, data, fn ) {\n\t\treturn this.on( types, selector, data, fn );\n\t},\n\tundelegate: function( selector, types, fn ) {\n\n\t\t// ( namespace ) or ( selector, types [, fn] )\n\t\treturn arguments.length === 1 ?\n\t\t\tthis.off( selector, \"**\" ) :\n\t\t\tthis.off( types, selector || \"**\", fn );\n\t},\n\n\thover: function( fnOver, fnOut ) {\n\t\treturn this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );\n\t}\n} );\n\njQuery.each(\n\t( \"blur focus focusin focusout resize scroll click dblclick \" +\n\t\"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave \" +\n\t\"change select submit keydown keypress keyup contextmenu\" ).split( \" \" ),\n\tfunction( _i, name ) {\n\n\t\t// Handle event binding\n\t\tjQuery.fn[ name ] = function( data, fn ) {\n\t\t\treturn arguments.length > 0 ?\n\t\t\t\tthis.on( name, null, data, fn ) :\n\t\t\t\tthis.trigger( name );\n\t\t};\n\t}\n);\n\n\n\n\n// Support: Android <=4.0 only\n// Make sure we trim BOM and NBSP\n// Require that the \"whitespace run\" starts from a non-whitespace\n// to avoid O(N^2) behavior when the engine would try matching \"\\s+$\" at each space position.\nvar rtrim = /^[\\s\\uFEFF\\xA0]+|([^\\s\\uFEFF\\xA0])[\\s\\uFEFF\\xA0]+$/g;\n\n// Bind a function to a context, optionally partially applying any\n// arguments.\n// jQuery.proxy is deprecated to promote standards (specifically Function#bind)\n// However, it is not slated for removal any time soon\njQuery.proxy = function( fn, context ) {\n\tvar tmp, args, proxy;\n\n\tif ( typeof context === \"string\" ) {\n\t\ttmp = fn[ context ];\n\t\tcontext = fn;\n\t\tfn = tmp;\n\t}\n\n\t// Quick check to determine if target is callable, in the spec\n\t// this throws a TypeError, but we will just return undefined.\n\tif ( !isFunction( fn ) ) {\n\t\treturn undefined;\n\t}\n\n\t// Simulated bind\n\targs = slice.call( arguments, 2 );\n\tproxy = function() {\n\t\treturn fn.apply( context || this, args.concat( slice.call( arguments ) ) );\n\t};\n\n\t// Set the guid of unique handler to the same of original handler, so it can be removed\n\tproxy.guid = fn.guid = fn.guid || jQuery.guid++;\n\n\treturn proxy;\n};\n\njQuery.holdReady = function( hold ) {\n\tif ( hold ) {\n\t\tjQuery.readyWait++;\n\t} else {\n\t\tjQuery.ready( true );\n\t}\n};\njQuery.isArray = Array.isArray;\njQuery.parseJSON = JSON.parse;\njQuery.nodeName = nodeName;\njQuery.isFunction = isFunction;\njQuery.isWindow = isWindow;\njQuery.camelCase = camelCase;\njQuery.type = toType;\n\njQuery.now = Date.now;\n\njQuery.isNumeric = function( obj ) {\n\n\t// As of jQuery 3.0, isNumeric is limited to\n\t// strings and numbers (primitives or objects)\n\t// that can be coerced to finite numbers (gh-2662)\n\tvar type = jQuery.type( obj );\n\treturn ( type === \"number\" || type === \"string\" ) &&\n\n\t\t// parseFloat NaNs numeric-cast false positives (\"\")\n\t\t// ...but misinterprets leading-number strings, particularly hex literals (\"0x...\")\n\t\t// subtraction forces infinities to NaN\n\t\t!isNaN( obj - parseFloat( obj ) );\n};\n\njQuery.trim = function( text ) {\n\treturn text == null ?\n\t\t\"\" :\n\t\t( text + \"\" ).replace( rtrim, \"$1\" );\n};\n\n\n\n// Register as a named AMD module, since jQuery can be concatenated with other\n// files that may use define, but not via a proper concatenation script that\n// understands anonymous AMD modules. A named AMD is safest and most robust\n// way to register. Lowercase jquery is used because AMD module names are\n// derived from file names, and jQuery is normally delivered in a lowercase\n// file name. Do this after creating the global so that if an AMD module wants\n// to call noConflict to hide this version of jQuery, it will work.\n\n// Note that for maximum portability, libraries that are not jQuery should\n// declare themselves as anonymous modules, and avoid setting a global if an\n// AMD loader is present. jQuery is a special case. For more information, see\n// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon\n\nif ( typeof define === \"function\" && define.amd ) {\n\tdefine( \"jquery\", [], function() {\n\t\treturn jQuery;\n\t} );\n}\n\n\n\n\nvar\n\n\t// Map over jQuery in case of overwrite\n\t_jQuery = window.jQuery,\n\n\t// Map over the $ in case of overwrite\n\t_$ = window.$;\n\njQuery.noConflict = function( deep ) {\n\tif ( window.$ === jQuery ) {\n\t\twindow.$ = _$;\n\t}\n\n\tif ( deep && window.jQuery === jQuery ) {\n\t\twindow.jQuery = _jQuery;\n\t}\n\n\treturn jQuery;\n};\n\n// Expose jQuery and $ identifiers, even in AMD\n// (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)\n// and CommonJS for browser emulators (trac-13566)\nif ( typeof noGlobal === \"undefined\" ) {\n\twindow.jQuery = window.$ = jQuery;\n}\n\n\n\n\nreturn jQuery;\n} );\n"
  },
  {
    "path": "app/assets/javascripts/pghero/nouislider.js",
    "content": "(function (global, factory) {\n    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n    typeof define === 'function' && define.amd ? define(['exports'], factory) :\n    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.noUiSlider = {}));\n})(this, (function (exports) { 'use strict';\n\n    exports.PipsMode = void 0;\n    (function (PipsMode) {\n        PipsMode[\"Range\"] = \"range\";\n        PipsMode[\"Steps\"] = \"steps\";\n        PipsMode[\"Positions\"] = \"positions\";\n        PipsMode[\"Count\"] = \"count\";\n        PipsMode[\"Values\"] = \"values\";\n    })(exports.PipsMode || (exports.PipsMode = {}));\n    exports.PipsType = void 0;\n    (function (PipsType) {\n        PipsType[PipsType[\"None\"] = -1] = \"None\";\n        PipsType[PipsType[\"NoValue\"] = 0] = \"NoValue\";\n        PipsType[PipsType[\"LargeValue\"] = 1] = \"LargeValue\";\n        PipsType[PipsType[\"SmallValue\"] = 2] = \"SmallValue\";\n    })(exports.PipsType || (exports.PipsType = {}));\n    //region Helper Methods\n    function isValidFormatter(entry) {\n        return isValidPartialFormatter(entry) && typeof entry.from === \"function\";\n    }\n    function isValidPartialFormatter(entry) {\n        // partial formatters only need a to function and not a from function\n        return typeof entry === \"object\" && typeof entry.to === \"function\";\n    }\n    function removeElement(el) {\n        el.parentElement.removeChild(el);\n    }\n    function isSet(value) {\n        return value !== null && value !== undefined;\n    }\n    // Bindable version\n    function preventDefault(e) {\n        e.preventDefault();\n    }\n    // Removes duplicates from an array.\n    function unique(array) {\n        return array.filter(function (a) {\n            return !this[a] ? (this[a] = true) : false;\n        }, {});\n    }\n    // Round a value to the closest 'to'.\n    function closest(value, to) {\n        return Math.round(value / to) * to;\n    }\n    // Current position of an element relative to the document.\n    function offset(elem, orientation) {\n        var rect = elem.getBoundingClientRect();\n        var doc = elem.ownerDocument;\n        var docElem = doc.documentElement;\n        var pageOffset = getPageOffset(doc);\n        // getBoundingClientRect contains left scroll in Chrome on Android.\n        // I haven't found a feature detection that proves this. Worst case\n        // scenario on mis-match: the 'tap' feature on horizontal sliders breaks.\n        if (/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)) {\n            pageOffset.x = 0;\n        }\n        return orientation ? rect.top + pageOffset.y - docElem.clientTop : rect.left + pageOffset.x - docElem.clientLeft;\n    }\n    // Checks whether a value is numerical.\n    function isNumeric(a) {\n        return typeof a === \"number\" && !isNaN(a) && isFinite(a);\n    }\n    // Sets a class and removes it after [duration] ms.\n    function addClassFor(element, className, duration) {\n        if (duration > 0) {\n            addClass(element, className);\n            setTimeout(function () {\n                removeClass(element, className);\n            }, duration);\n        }\n    }\n    // Limits a value to 0 - 100\n    function limit(a) {\n        return Math.max(Math.min(a, 100), 0);\n    }\n    // Wraps a variable as an array, if it isn't one yet.\n    // Note that an input array is returned by reference!\n    function asArray(a) {\n        return Array.isArray(a) ? a : [a];\n    }\n    // Counts decimals\n    function countDecimals(numStr) {\n        numStr = String(numStr);\n        var pieces = numStr.split(\".\");\n        return pieces.length > 1 ? pieces[1].length : 0;\n    }\n    // http://youmightnotneedjquery.com/#add_class\n    function addClass(el, className) {\n        if (el.classList && !/\\s/.test(className)) {\n            el.classList.add(className);\n        }\n        else {\n            el.className += \" \" + className;\n        }\n    }\n    // http://youmightnotneedjquery.com/#remove_class\n    function removeClass(el, className) {\n        if (el.classList && !/\\s/.test(className)) {\n            el.classList.remove(className);\n        }\n        else {\n            el.className = el.className.replace(new RegExp(\"(^|\\\\b)\" + className.split(\" \").join(\"|\") + \"(\\\\b|$)\", \"gi\"), \" \");\n        }\n    }\n    // https://plainjs.com/javascript/attributes/adding-removing-and-testing-for-classes-9/\n    function hasClass(el, className) {\n        return el.classList ? el.classList.contains(className) : new RegExp(\"\\\\b\" + className + \"\\\\b\").test(el.className);\n    }\n    // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes\n    function getPageOffset(doc) {\n        var supportPageOffset = window.pageXOffset !== undefined;\n        var isCSS1Compat = (doc.compatMode || \"\") === \"CSS1Compat\";\n        var x = supportPageOffset\n            ? window.pageXOffset\n            : isCSS1Compat\n                ? doc.documentElement.scrollLeft\n                : doc.body.scrollLeft;\n        var y = supportPageOffset\n            ? window.pageYOffset\n            : isCSS1Compat\n                ? doc.documentElement.scrollTop\n                : doc.body.scrollTop;\n        return {\n            x: x,\n            y: y,\n        };\n    }\n    // we provide a function to compute constants instead\n    // of accessing window.* as soon as the module needs it\n    // so that we do not compute anything if not needed\n    function getActions() {\n        // Determine the events to bind. IE11 implements pointerEvents without\n        // a prefix, which breaks compatibility with the IE10 implementation.\n        return window.navigator.pointerEnabled\n            ? {\n                start: \"pointerdown\",\n                move: \"pointermove\",\n                end: \"pointerup\",\n            }\n            : window.navigator.msPointerEnabled\n                ? {\n                    start: \"MSPointerDown\",\n                    move: \"MSPointerMove\",\n                    end: \"MSPointerUp\",\n                }\n                : {\n                    start: \"mousedown touchstart\",\n                    move: \"mousemove touchmove\",\n                    end: \"mouseup touchend\",\n                };\n    }\n    // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n    // Issue #785\n    function getSupportsPassive() {\n        var supportsPassive = false;\n        /* eslint-disable */\n        try {\n            var opts = Object.defineProperty({}, \"passive\", {\n                get: function () {\n                    supportsPassive = true;\n                },\n            });\n            // @ts-ignore\n            window.addEventListener(\"test\", null, opts);\n        }\n        catch (e) { }\n        /* eslint-enable */\n        return supportsPassive;\n    }\n    function getSupportsTouchActionNone() {\n        return window.CSS && CSS.supports && CSS.supports(\"touch-action\", \"none\");\n    }\n    //endregion\n    //region Range Calculation\n    // Determine the size of a sub-range in relation to a full range.\n    function subRangeRatio(pa, pb) {\n        return 100 / (pb - pa);\n    }\n    // (percentage) How many percent is this value of this range?\n    function fromPercentage(range, value, startRange) {\n        return (value * 100) / (range[startRange + 1] - range[startRange]);\n    }\n    // (percentage) Where is this value on this range?\n    function toPercentage(range, value) {\n        return fromPercentage(range, range[0] < 0 ? value + Math.abs(range[0]) : value - range[0], 0);\n    }\n    // (value) How much is this percentage on this range?\n    function isPercentage(range, value) {\n        return (value * (range[1] - range[0])) / 100 + range[0];\n    }\n    function getJ(value, arr) {\n        var j = 1;\n        while (value >= arr[j]) {\n            j += 1;\n        }\n        return j;\n    }\n    // (percentage) Input a value, find where, on a scale of 0-100, it applies.\n    function toStepping(xVal, xPct, value) {\n        if (value >= xVal.slice(-1)[0]) {\n            return 100;\n        }\n        var j = getJ(value, xVal);\n        var va = xVal[j - 1];\n        var vb = xVal[j];\n        var pa = xPct[j - 1];\n        var pb = xPct[j];\n        return pa + toPercentage([va, vb], value) / subRangeRatio(pa, pb);\n    }\n    // (value) Input a percentage, find where it is on the specified range.\n    function fromStepping(xVal, xPct, value) {\n        // There is no range group that fits 100\n        if (value >= 100) {\n            return xVal.slice(-1)[0];\n        }\n        var j = getJ(value, xPct);\n        var va = xVal[j - 1];\n        var vb = xVal[j];\n        var pa = xPct[j - 1];\n        var pb = xPct[j];\n        return isPercentage([va, vb], (value - pa) * subRangeRatio(pa, pb));\n    }\n    // (percentage) Get the step that applies at a certain value.\n    function getStep(xPct, xSteps, snap, value) {\n        if (value === 100) {\n            return value;\n        }\n        var j = getJ(value, xPct);\n        var a = xPct[j - 1];\n        var b = xPct[j];\n        // If 'snap' is set, steps are used as fixed points on the slider.\n        if (snap) {\n            // Find the closest position, a or b.\n            if (value - a > (b - a) / 2) {\n                return b;\n            }\n            return a;\n        }\n        if (!xSteps[j - 1]) {\n            return value;\n        }\n        return xPct[j - 1] + closest(value - xPct[j - 1], xSteps[j - 1]);\n    }\n    //endregion\n    //region Spectrum\n    var Spectrum = /** @class */ (function () {\n        function Spectrum(entry, snap, singleStep) {\n            this.xPct = [];\n            this.xVal = [];\n            this.xSteps = [];\n            this.xNumSteps = [];\n            this.xHighestCompleteStep = [];\n            this.xSteps = [singleStep || false];\n            this.xNumSteps = [false];\n            this.snap = snap;\n            var index;\n            var ordered = [];\n            // Map the object keys to an array.\n            Object.keys(entry).forEach(function (index) {\n                ordered.push([asArray(entry[index]), index]);\n            });\n            // Sort all entries by value (numeric sort).\n            ordered.sort(function (a, b) {\n                return a[0][0] - b[0][0];\n            });\n            // Convert all entries to subranges.\n            for (index = 0; index < ordered.length; index++) {\n                this.handleEntryPoint(ordered[index][1], ordered[index][0]);\n            }\n            // Store the actual step values.\n            // xSteps is sorted in the same order as xPct and xVal.\n            this.xNumSteps = this.xSteps.slice(0);\n            // Convert all numeric steps to the percentage of the subrange they represent.\n            for (index = 0; index < this.xNumSteps.length; index++) {\n                this.handleStepPoint(index, this.xNumSteps[index]);\n            }\n        }\n        Spectrum.prototype.getDistance = function (value) {\n            var distances = [];\n            for (var index = 0; index < this.xNumSteps.length - 1; index++) {\n                distances[index] = fromPercentage(this.xVal, value, index);\n            }\n            return distances;\n        };\n        // Calculate the percentual distance over the whole scale of ranges.\n        // direction: 0 = backwards / 1 = forwards\n        Spectrum.prototype.getAbsoluteDistance = function (value, distances, direction) {\n            var xPct_index = 0;\n            // Calculate range where to start calculation\n            if (value < this.xPct[this.xPct.length - 1]) {\n                while (value > this.xPct[xPct_index + 1]) {\n                    xPct_index++;\n                }\n            }\n            else if (value === this.xPct[this.xPct.length - 1]) {\n                xPct_index = this.xPct.length - 2;\n            }\n            // If looking backwards and the value is exactly at a range separator then look one range further\n            if (!direction && value === this.xPct[xPct_index + 1]) {\n                xPct_index++;\n            }\n            if (distances === null) {\n                distances = [];\n            }\n            var start_factor;\n            var rest_factor = 1;\n            var rest_rel_distance = distances[xPct_index];\n            var range_pct = 0;\n            var rel_range_distance = 0;\n            var abs_distance_counter = 0;\n            var range_counter = 0;\n            // Calculate what part of the start range the value is\n            if (direction) {\n                start_factor = (value - this.xPct[xPct_index]) / (this.xPct[xPct_index + 1] - this.xPct[xPct_index]);\n            }\n            else {\n                start_factor = (this.xPct[xPct_index + 1] - value) / (this.xPct[xPct_index + 1] - this.xPct[xPct_index]);\n            }\n            // Do until the complete distance across ranges is calculated\n            while (rest_rel_distance > 0) {\n                // Calculate the percentage of total range\n                range_pct = this.xPct[xPct_index + 1 + range_counter] - this.xPct[xPct_index + range_counter];\n                // Detect if the margin, padding or limit is larger then the current range and calculate\n                if (distances[xPct_index + range_counter] * rest_factor + 100 - start_factor * 100 > 100) {\n                    // If larger then take the percentual distance of the whole range\n                    rel_range_distance = range_pct * start_factor;\n                    // Rest factor of relative percentual distance still to be calculated\n                    rest_factor = (rest_rel_distance - 100 * start_factor) / distances[xPct_index + range_counter];\n                    // Set start factor to 1 as for next range it does not apply.\n                    start_factor = 1;\n                }\n                else {\n                    // If smaller or equal then take the percentual distance of the calculate percentual part of that range\n                    rel_range_distance = ((distances[xPct_index + range_counter] * range_pct) / 100) * rest_factor;\n                    // No rest left as the rest fits in current range\n                    rest_factor = 0;\n                }\n                if (direction) {\n                    abs_distance_counter = abs_distance_counter - rel_range_distance;\n                    // Limit range to first range when distance becomes outside of minimum range\n                    if (this.xPct.length + range_counter >= 1) {\n                        range_counter--;\n                    }\n                }\n                else {\n                    abs_distance_counter = abs_distance_counter + rel_range_distance;\n                    // Limit range to last range when distance becomes outside of maximum range\n                    if (this.xPct.length - range_counter >= 1) {\n                        range_counter++;\n                    }\n                }\n                // Rest of relative percentual distance still to be calculated\n                rest_rel_distance = distances[xPct_index + range_counter] * rest_factor;\n            }\n            return value + abs_distance_counter;\n        };\n        Spectrum.prototype.toStepping = function (value) {\n            value = toStepping(this.xVal, this.xPct, value);\n            return value;\n        };\n        Spectrum.prototype.fromStepping = function (value) {\n            return fromStepping(this.xVal, this.xPct, value);\n        };\n        Spectrum.prototype.getStep = function (value) {\n            value = getStep(this.xPct, this.xSteps, this.snap, value);\n            return value;\n        };\n        Spectrum.prototype.getDefaultStep = function (value, isDown, size) {\n            var j = getJ(value, this.xPct);\n            // When at the top or stepping down, look at the previous sub-range\n            if (value === 100 || (isDown && value === this.xPct[j - 1])) {\n                j = Math.max(j - 1, 1);\n            }\n            return (this.xVal[j] - this.xVal[j - 1]) / size;\n        };\n        Spectrum.prototype.getNearbySteps = function (value) {\n            var j = getJ(value, this.xPct);\n            return {\n                stepBefore: {\n                    startValue: this.xVal[j - 2],\n                    step: this.xNumSteps[j - 2],\n                    highestStep: this.xHighestCompleteStep[j - 2],\n                },\n                thisStep: {\n                    startValue: this.xVal[j - 1],\n                    step: this.xNumSteps[j - 1],\n                    highestStep: this.xHighestCompleteStep[j - 1],\n                },\n                stepAfter: {\n                    startValue: this.xVal[j],\n                    step: this.xNumSteps[j],\n                    highestStep: this.xHighestCompleteStep[j],\n                },\n            };\n        };\n        Spectrum.prototype.countStepDecimals = function () {\n            var stepDecimals = this.xNumSteps.map(countDecimals);\n            return Math.max.apply(null, stepDecimals);\n        };\n        Spectrum.prototype.hasNoSize = function () {\n            return this.xVal[0] === this.xVal[this.xVal.length - 1];\n        };\n        // Outside testing\n        Spectrum.prototype.convert = function (value) {\n            return this.getStep(this.toStepping(value));\n        };\n        Spectrum.prototype.handleEntryPoint = function (index, value) {\n            var percentage;\n            // Covert min/max syntax to 0 and 100.\n            if (index === \"min\") {\n                percentage = 0;\n            }\n            else if (index === \"max\") {\n                percentage = 100;\n            }\n            else {\n                percentage = parseFloat(index);\n            }\n            // Check for correct input.\n            if (!isNumeric(percentage) || !isNumeric(value[0])) {\n                throw new Error(\"noUiSlider: 'range' value isn't numeric.\");\n            }\n            // Store values.\n            this.xPct.push(percentage);\n            this.xVal.push(value[0]);\n            var value1 = Number(value[1]);\n            // NaN will evaluate to false too, but to keep\n            // logging clear, set step explicitly. Make sure\n            // not to override the 'step' setting with false.\n            if (!percentage) {\n                if (!isNaN(value1)) {\n                    this.xSteps[0] = value1;\n                }\n            }\n            else {\n                this.xSteps.push(isNaN(value1) ? false : value1);\n            }\n            this.xHighestCompleteStep.push(0);\n        };\n        Spectrum.prototype.handleStepPoint = function (i, n) {\n            // Ignore 'false' stepping.\n            if (!n) {\n                return;\n            }\n            // Step over zero-length ranges (#948);\n            if (this.xVal[i] === this.xVal[i + 1]) {\n                this.xSteps[i] = this.xHighestCompleteStep[i] = this.xVal[i];\n                return;\n            }\n            // Factor to range ratio\n            this.xSteps[i] =\n                fromPercentage([this.xVal[i], this.xVal[i + 1]], n, 0) / subRangeRatio(this.xPct[i], this.xPct[i + 1]);\n            var totalSteps = (this.xVal[i + 1] - this.xVal[i]) / this.xNumSteps[i];\n            var highestStep = Math.ceil(Number(totalSteps.toFixed(3)) - 1);\n            var step = this.xVal[i] + this.xNumSteps[i] * highestStep;\n            this.xHighestCompleteStep[i] = step;\n        };\n        return Spectrum;\n    }());\n    //endregion\n    //region Options\n    /*\tEvery input option is tested and parsed. This will prevent\n        endless validation in internal methods. These tests are\n        structured with an item for every option available. An\n        option can be marked as required by setting the 'r' flag.\n        The testing function is provided with three arguments:\n            - The provided value for the option;\n            - A reference to the options object;\n            - The name for the option;\n\n        The testing function returns false when an error is detected,\n        or true when everything is OK. It can also modify the option\n        object, to make sure all values can be correctly looped elsewhere. */\n    //region Defaults\n    var defaultFormatter = {\n        to: function (value) {\n            return value === undefined ? \"\" : value.toFixed(2);\n        },\n        from: Number,\n    };\n    var cssClasses = {\n        target: \"target\",\n        base: \"base\",\n        origin: \"origin\",\n        handle: \"handle\",\n        handleLower: \"handle-lower\",\n        handleUpper: \"handle-upper\",\n        touchArea: \"touch-area\",\n        horizontal: \"horizontal\",\n        vertical: \"vertical\",\n        background: \"background\",\n        connect: \"connect\",\n        connects: \"connects\",\n        ltr: \"ltr\",\n        rtl: \"rtl\",\n        textDirectionLtr: \"txt-dir-ltr\",\n        textDirectionRtl: \"txt-dir-rtl\",\n        draggable: \"draggable\",\n        drag: \"state-drag\",\n        tap: \"state-tap\",\n        active: \"active\",\n        tooltip: \"tooltip\",\n        pips: \"pips\",\n        pipsHorizontal: \"pips-horizontal\",\n        pipsVertical: \"pips-vertical\",\n        marker: \"marker\",\n        markerHorizontal: \"marker-horizontal\",\n        markerVertical: \"marker-vertical\",\n        markerNormal: \"marker-normal\",\n        markerLarge: \"marker-large\",\n        markerSub: \"marker-sub\",\n        value: \"value\",\n        valueHorizontal: \"value-horizontal\",\n        valueVertical: \"value-vertical\",\n        valueNormal: \"value-normal\",\n        valueLarge: \"value-large\",\n        valueSub: \"value-sub\",\n    };\n    // Namespaces of internal event listeners\n    var INTERNAL_EVENT_NS = {\n        tooltips: \".__tooltips\",\n        aria: \".__aria\",\n    };\n    //endregion\n    function testStep(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'step' is not numeric.\");\n        }\n        // The step option can still be used to set stepping\n        // for linear sliders. Overwritten if set in 'range'.\n        parsed.singleStep = entry;\n    }\n    function testKeyboardPageMultiplier(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'keyboardPageMultiplier' is not numeric.\");\n        }\n        parsed.keyboardPageMultiplier = entry;\n    }\n    function testKeyboardMultiplier(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'keyboardMultiplier' is not numeric.\");\n        }\n        parsed.keyboardMultiplier = entry;\n    }\n    function testKeyboardDefaultStep(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'keyboardDefaultStep' is not numeric.\");\n        }\n        parsed.keyboardDefaultStep = entry;\n    }\n    function testRange(parsed, entry) {\n        // Filter incorrect input.\n        if (typeof entry !== \"object\" || Array.isArray(entry)) {\n            throw new Error(\"noUiSlider: 'range' is not an object.\");\n        }\n        // Catch missing start or end.\n        if (entry.min === undefined || entry.max === undefined) {\n            throw new Error(\"noUiSlider: Missing 'min' or 'max' in 'range'.\");\n        }\n        parsed.spectrum = new Spectrum(entry, parsed.snap || false, parsed.singleStep);\n    }\n    function testStart(parsed, entry) {\n        entry = asArray(entry);\n        // Validate input. Values aren't tested, as the public .val method\n        // will always provide a valid location.\n        if (!Array.isArray(entry) || !entry.length) {\n            throw new Error(\"noUiSlider: 'start' option is incorrect.\");\n        }\n        // Store the number of handles.\n        parsed.handles = entry.length;\n        // When the slider is initialized, the .val method will\n        // be called with the start options.\n        parsed.start = entry;\n    }\n    function testSnap(parsed, entry) {\n        if (typeof entry !== \"boolean\") {\n            throw new Error(\"noUiSlider: 'snap' option must be a boolean.\");\n        }\n        // Enforce 100% stepping within subranges.\n        parsed.snap = entry;\n    }\n    function testAnimate(parsed, entry) {\n        if (typeof entry !== \"boolean\") {\n            throw new Error(\"noUiSlider: 'animate' option must be a boolean.\");\n        }\n        // Enforce 100% stepping within subranges.\n        parsed.animate = entry;\n    }\n    function testAnimationDuration(parsed, entry) {\n        if (typeof entry !== \"number\") {\n            throw new Error(\"noUiSlider: 'animationDuration' option must be a number.\");\n        }\n        parsed.animationDuration = entry;\n    }\n    function testConnect(parsed, entry) {\n        var connect = [false];\n        var i;\n        // Map legacy options\n        if (entry === \"lower\") {\n            entry = [true, false];\n        }\n        else if (entry === \"upper\") {\n            entry = [false, true];\n        }\n        // Handle boolean options\n        if (entry === true || entry === false) {\n            for (i = 1; i < parsed.handles; i++) {\n                connect.push(entry);\n            }\n            connect.push(false);\n        }\n        // Reject invalid input\n        else if (!Array.isArray(entry) || !entry.length || entry.length !== parsed.handles + 1) {\n            throw new Error(\"noUiSlider: 'connect' option doesn't match handle count.\");\n        }\n        else {\n            connect = entry;\n        }\n        parsed.connect = connect;\n    }\n    function testOrientation(parsed, entry) {\n        // Set orientation to an a numerical value for easy\n        // array selection.\n        switch (entry) {\n            case \"horizontal\":\n                parsed.ort = 0;\n                break;\n            case \"vertical\":\n                parsed.ort = 1;\n                break;\n            default:\n                throw new Error(\"noUiSlider: 'orientation' option is invalid.\");\n        }\n    }\n    function testMargin(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'margin' option must be numeric.\");\n        }\n        // Issue #582\n        if (entry === 0) {\n            return;\n        }\n        parsed.margin = parsed.spectrum.getDistance(entry);\n    }\n    function testLimit(parsed, entry) {\n        if (!isNumeric(entry)) {\n            throw new Error(\"noUiSlider: 'limit' option must be numeric.\");\n        }\n        parsed.limit = parsed.spectrum.getDistance(entry);\n        if (!parsed.limit || parsed.handles < 2) {\n            throw new Error(\"noUiSlider: 'limit' option is only supported on linear sliders with 2 or more handles.\");\n        }\n    }\n    function testPadding(parsed, entry) {\n        var index;\n        if (!isNumeric(entry) && !Array.isArray(entry)) {\n            throw new Error(\"noUiSlider: 'padding' option must be numeric or array of exactly 2 numbers.\");\n        }\n        if (Array.isArray(entry) && !(entry.length === 2 || isNumeric(entry[0]) || isNumeric(entry[1]))) {\n            throw new Error(\"noUiSlider: 'padding' option must be numeric or array of exactly 2 numbers.\");\n        }\n        if (entry === 0) {\n            return;\n        }\n        if (!Array.isArray(entry)) {\n            entry = [entry, entry];\n        }\n        // 'getDistance' returns false for invalid values.\n        parsed.padding = [parsed.spectrum.getDistance(entry[0]), parsed.spectrum.getDistance(entry[1])];\n        for (index = 0; index < parsed.spectrum.xNumSteps.length - 1; index++) {\n            // last \"range\" can't contain step size as it is purely an endpoint.\n            if (parsed.padding[0][index] < 0 || parsed.padding[1][index] < 0) {\n                throw new Error(\"noUiSlider: 'padding' option must be a positive number(s).\");\n            }\n        }\n        var totalPadding = entry[0] + entry[1];\n        var firstValue = parsed.spectrum.xVal[0];\n        var lastValue = parsed.spectrum.xVal[parsed.spectrum.xVal.length - 1];\n        if (totalPadding / (lastValue - firstValue) > 1) {\n            throw new Error(\"noUiSlider: 'padding' option must not exceed 100% of the range.\");\n        }\n    }\n    function testDirection(parsed, entry) {\n        // Set direction as a numerical value for easy parsing.\n        // Invert connection for RTL sliders, so that the proper\n        // handles get the connect/background classes.\n        switch (entry) {\n            case \"ltr\":\n                parsed.dir = 0;\n                break;\n            case \"rtl\":\n                parsed.dir = 1;\n                break;\n            default:\n                throw new Error(\"noUiSlider: 'direction' option was not recognized.\");\n        }\n    }\n    function testBehaviour(parsed, entry) {\n        // Make sure the input is a string.\n        if (typeof entry !== \"string\") {\n            throw new Error(\"noUiSlider: 'behaviour' must be a string containing options.\");\n        }\n        // Check if the string contains any keywords.\n        // None are required.\n        var tap = entry.indexOf(\"tap\") >= 0;\n        var drag = entry.indexOf(\"drag\") >= 0;\n        var fixed = entry.indexOf(\"fixed\") >= 0;\n        var snap = entry.indexOf(\"snap\") >= 0;\n        var hover = entry.indexOf(\"hover\") >= 0;\n        var unconstrained = entry.indexOf(\"unconstrained\") >= 0;\n        var dragAll = entry.indexOf(\"drag-all\") >= 0;\n        var smoothSteps = entry.indexOf(\"smooth-steps\") >= 0;\n        if (fixed) {\n            if (parsed.handles !== 2) {\n                throw new Error(\"noUiSlider: 'fixed' behaviour must be used with 2 handles\");\n            }\n            // Use margin to enforce fixed state\n            testMargin(parsed, parsed.start[1] - parsed.start[0]);\n        }\n        if (unconstrained && (parsed.margin || parsed.limit)) {\n            throw new Error(\"noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit\");\n        }\n        parsed.events = {\n            tap: tap || snap,\n            drag: drag,\n            dragAll: dragAll,\n            smoothSteps: smoothSteps,\n            fixed: fixed,\n            snap: snap,\n            hover: hover,\n            unconstrained: unconstrained,\n        };\n    }\n    function testTooltips(parsed, entry) {\n        if (entry === false) {\n            return;\n        }\n        if (entry === true || isValidPartialFormatter(entry)) {\n            parsed.tooltips = [];\n            for (var i = 0; i < parsed.handles; i++) {\n                parsed.tooltips.push(entry);\n            }\n        }\n        else {\n            entry = asArray(entry);\n            if (entry.length !== parsed.handles) {\n                throw new Error(\"noUiSlider: must pass a formatter for all handles.\");\n            }\n            entry.forEach(function (formatter) {\n                if (typeof formatter !== \"boolean\" && !isValidPartialFormatter(formatter)) {\n                    throw new Error(\"noUiSlider: 'tooltips' must be passed a formatter or 'false'.\");\n                }\n            });\n            parsed.tooltips = entry;\n        }\n    }\n    function testHandleAttributes(parsed, entry) {\n        if (entry.length !== parsed.handles) {\n            throw new Error(\"noUiSlider: must pass a attributes for all handles.\");\n        }\n        parsed.handleAttributes = entry;\n    }\n    function testAriaFormat(parsed, entry) {\n        if (!isValidPartialFormatter(entry)) {\n            throw new Error(\"noUiSlider: 'ariaFormat' requires 'to' method.\");\n        }\n        parsed.ariaFormat = entry;\n    }\n    function testFormat(parsed, entry) {\n        if (!isValidFormatter(entry)) {\n            throw new Error(\"noUiSlider: 'format' requires 'to' and 'from' methods.\");\n        }\n        parsed.format = entry;\n    }\n    function testKeyboardSupport(parsed, entry) {\n        if (typeof entry !== \"boolean\") {\n            throw new Error(\"noUiSlider: 'keyboardSupport' option must be a boolean.\");\n        }\n        parsed.keyboardSupport = entry;\n    }\n    function testDocumentElement(parsed, entry) {\n        // This is an advanced option. Passed values are used without validation.\n        parsed.documentElement = entry;\n    }\n    function testCssPrefix(parsed, entry) {\n        if (typeof entry !== \"string\" && entry !== false) {\n            throw new Error(\"noUiSlider: 'cssPrefix' must be a string or `false`.\");\n        }\n        parsed.cssPrefix = entry;\n    }\n    function testCssClasses(parsed, entry) {\n        if (typeof entry !== \"object\") {\n            throw new Error(\"noUiSlider: 'cssClasses' must be an object.\");\n        }\n        if (typeof parsed.cssPrefix === \"string\") {\n            parsed.cssClasses = {};\n            Object.keys(entry).forEach(function (key) {\n                parsed.cssClasses[key] = parsed.cssPrefix + entry[key];\n            });\n        }\n        else {\n            parsed.cssClasses = entry;\n        }\n    }\n    // Test all developer settings and parse to assumption-safe values.\n    function testOptions(options) {\n        // To prove a fix for #537, freeze options here.\n        // If the object is modified, an error will be thrown.\n        // Object.freeze(options);\n        var parsed = {\n            margin: null,\n            limit: null,\n            padding: null,\n            animate: true,\n            animationDuration: 300,\n            ariaFormat: defaultFormatter,\n            format: defaultFormatter,\n        };\n        // Tests are executed in the order they are presented here.\n        var tests = {\n            step: { r: false, t: testStep },\n            keyboardPageMultiplier: { r: false, t: testKeyboardPageMultiplier },\n            keyboardMultiplier: { r: false, t: testKeyboardMultiplier },\n            keyboardDefaultStep: { r: false, t: testKeyboardDefaultStep },\n            start: { r: true, t: testStart },\n            connect: { r: true, t: testConnect },\n            direction: { r: true, t: testDirection },\n            snap: { r: false, t: testSnap },\n            animate: { r: false, t: testAnimate },\n            animationDuration: { r: false, t: testAnimationDuration },\n            range: { r: true, t: testRange },\n            orientation: { r: false, t: testOrientation },\n            margin: { r: false, t: testMargin },\n            limit: { r: false, t: testLimit },\n            padding: { r: false, t: testPadding },\n            behaviour: { r: true, t: testBehaviour },\n            ariaFormat: { r: false, t: testAriaFormat },\n            format: { r: false, t: testFormat },\n            tooltips: { r: false, t: testTooltips },\n            keyboardSupport: { r: true, t: testKeyboardSupport },\n            documentElement: { r: false, t: testDocumentElement },\n            cssPrefix: { r: true, t: testCssPrefix },\n            cssClasses: { r: true, t: testCssClasses },\n            handleAttributes: { r: false, t: testHandleAttributes },\n        };\n        var defaults = {\n            connect: false,\n            direction: \"ltr\",\n            behaviour: \"tap\",\n            orientation: \"horizontal\",\n            keyboardSupport: true,\n            cssPrefix: \"noUi-\",\n            cssClasses: cssClasses,\n            keyboardPageMultiplier: 5,\n            keyboardMultiplier: 1,\n            keyboardDefaultStep: 10,\n        };\n        // AriaFormat defaults to regular format, if any.\n        if (options.format && !options.ariaFormat) {\n            options.ariaFormat = options.format;\n        }\n        // Run all options through a testing mechanism to ensure correct\n        // input. It should be noted that options might get modified to\n        // be handled properly. E.g. wrapping integers in arrays.\n        Object.keys(tests).forEach(function (name) {\n            // If the option isn't set, but it is required, throw an error.\n            if (!isSet(options[name]) && defaults[name] === undefined) {\n                if (tests[name].r) {\n                    throw new Error(\"noUiSlider: '\" + name + \"' is required.\");\n                }\n                return;\n            }\n            tests[name].t(parsed, !isSet(options[name]) ? defaults[name] : options[name]);\n        });\n        // Forward pips options\n        parsed.pips = options.pips;\n        // All recent browsers accept unprefixed transform.\n        // We need -ms- for IE9 and -webkit- for older Android;\n        // Assume use of -webkit- if unprefixed and -ms- are not supported.\n        // https://caniuse.com/#feat=transforms2d\n        var d = document.createElement(\"div\");\n        var msPrefix = d.style.msTransform !== undefined;\n        var noPrefix = d.style.transform !== undefined;\n        parsed.transformRule = noPrefix ? \"transform\" : msPrefix ? \"msTransform\" : \"webkitTransform\";\n        // Pips don't move, so we can place them using left/top.\n        var styles = [\n            [\"left\", \"top\"],\n            [\"right\", \"bottom\"],\n        ];\n        parsed.style = styles[parsed.dir][parsed.ort];\n        return parsed;\n    }\n    //endregion\n    function scope(target, options, originalOptions) {\n        var actions = getActions();\n        var supportsTouchActionNone = getSupportsTouchActionNone();\n        var supportsPassive = supportsTouchActionNone && getSupportsPassive();\n        // All variables local to 'scope' are prefixed with 'scope_'\n        // Slider DOM Nodes\n        var scope_Target = target;\n        var scope_Base;\n        var scope_Handles;\n        var scope_Connects;\n        var scope_Pips;\n        var scope_Tooltips;\n        // Slider state values\n        var scope_Spectrum = options.spectrum;\n        var scope_Values = [];\n        var scope_Locations = [];\n        var scope_HandleNumbers = [];\n        var scope_ActiveHandlesCount = 0;\n        var scope_Events = {};\n        // Document Nodes\n        var scope_Document = target.ownerDocument;\n        var scope_DocumentElement = options.documentElement || scope_Document.documentElement;\n        var scope_Body = scope_Document.body;\n        // For horizontal sliders in standard ltr documents,\n        // make .noUi-origin overflow to the left so the document doesn't scroll.\n        var scope_DirOffset = scope_Document.dir === \"rtl\" || options.ort === 1 ? 0 : 100;\n        // Creates a node, adds it to target, returns the new node.\n        function addNodeTo(addTarget, className) {\n            var div = scope_Document.createElement(\"div\");\n            if (className) {\n                addClass(div, className);\n            }\n            addTarget.appendChild(div);\n            return div;\n        }\n        // Append a origin to the base\n        function addOrigin(base, handleNumber) {\n            var origin = addNodeTo(base, options.cssClasses.origin);\n            var handle = addNodeTo(origin, options.cssClasses.handle);\n            addNodeTo(handle, options.cssClasses.touchArea);\n            handle.setAttribute(\"data-handle\", String(handleNumber));\n            if (options.keyboardSupport) {\n                // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex\n                // 0 = focusable and reachable\n                handle.setAttribute(\"tabindex\", \"0\");\n                handle.addEventListener(\"keydown\", function (event) {\n                    return eventKeydown(event, handleNumber);\n                });\n            }\n            if (options.handleAttributes !== undefined) {\n                var attributes_1 = options.handleAttributes[handleNumber];\n                Object.keys(attributes_1).forEach(function (attribute) {\n                    handle.setAttribute(attribute, attributes_1[attribute]);\n                });\n            }\n            handle.setAttribute(\"role\", \"slider\");\n            handle.setAttribute(\"aria-orientation\", options.ort ? \"vertical\" : \"horizontal\");\n            if (handleNumber === 0) {\n                addClass(handle, options.cssClasses.handleLower);\n            }\n            else if (handleNumber === options.handles - 1) {\n                addClass(handle, options.cssClasses.handleUpper);\n            }\n            origin.handle = handle;\n            return origin;\n        }\n        // Insert nodes for connect elements\n        function addConnect(base, add) {\n            if (!add) {\n                return false;\n            }\n            return addNodeTo(base, options.cssClasses.connect);\n        }\n        // Add handles to the slider base.\n        function addElements(connectOptions, base) {\n            var connectBase = addNodeTo(base, options.cssClasses.connects);\n            scope_Handles = [];\n            scope_Connects = [];\n            scope_Connects.push(addConnect(connectBase, connectOptions[0]));\n            // [::::O====O====O====]\n            // connectOptions = [0, 1, 1, 1]\n            for (var i = 0; i < options.handles; i++) {\n                // Keep a list of all added handles.\n                scope_Handles.push(addOrigin(base, i));\n                scope_HandleNumbers[i] = i;\n                scope_Connects.push(addConnect(connectBase, connectOptions[i + 1]));\n            }\n        }\n        // Initialize a single slider.\n        function addSlider(addTarget) {\n            // Apply classes and data to the target.\n            addClass(addTarget, options.cssClasses.target);\n            if (options.dir === 0) {\n                addClass(addTarget, options.cssClasses.ltr);\n            }\n            else {\n                addClass(addTarget, options.cssClasses.rtl);\n            }\n            if (options.ort === 0) {\n                addClass(addTarget, options.cssClasses.horizontal);\n            }\n            else {\n                addClass(addTarget, options.cssClasses.vertical);\n            }\n            var textDirection = getComputedStyle(addTarget).direction;\n            if (textDirection === \"rtl\") {\n                addClass(addTarget, options.cssClasses.textDirectionRtl);\n            }\n            else {\n                addClass(addTarget, options.cssClasses.textDirectionLtr);\n            }\n            return addNodeTo(addTarget, options.cssClasses.base);\n        }\n        function addTooltip(handle, handleNumber) {\n            if (!options.tooltips || !options.tooltips[handleNumber]) {\n                return false;\n            }\n            return addNodeTo(handle.firstChild, options.cssClasses.tooltip);\n        }\n        function isSliderDisabled() {\n            return scope_Target.hasAttribute(\"disabled\");\n        }\n        // Disable the slider dragging if any handle is disabled\n        function isHandleDisabled(handleNumber) {\n            var handleOrigin = scope_Handles[handleNumber];\n            return handleOrigin.hasAttribute(\"disabled\");\n        }\n        function disable(handleNumber) {\n            if (handleNumber !== null && handleNumber !== undefined) {\n                scope_Handles[handleNumber].setAttribute(\"disabled\", \"\");\n                scope_Handles[handleNumber].handle.removeAttribute(\"tabindex\");\n            }\n            else {\n                scope_Target.setAttribute(\"disabled\", \"\");\n                scope_Handles.forEach(function (handle) {\n                    handle.handle.removeAttribute(\"tabindex\");\n                });\n            }\n        }\n        function enable(handleNumber) {\n            if (handleNumber !== null && handleNumber !== undefined) {\n                scope_Handles[handleNumber].removeAttribute(\"disabled\");\n                scope_Handles[handleNumber].handle.setAttribute(\"tabindex\", \"0\");\n            }\n            else {\n                scope_Target.removeAttribute(\"disabled\");\n                scope_Handles.forEach(function (handle) {\n                    handle.removeAttribute(\"disabled\");\n                    handle.handle.setAttribute(\"tabindex\", \"0\");\n                });\n            }\n        }\n        function removeTooltips() {\n            if (scope_Tooltips) {\n                removeEvent(\"update\" + INTERNAL_EVENT_NS.tooltips);\n                scope_Tooltips.forEach(function (tooltip) {\n                    if (tooltip) {\n                        removeElement(tooltip);\n                    }\n                });\n                scope_Tooltips = null;\n            }\n        }\n        // The tooltips option is a shorthand for using the 'update' event.\n        function tooltips() {\n            removeTooltips();\n            // Tooltips are added with options.tooltips in original order.\n            scope_Tooltips = scope_Handles.map(addTooltip);\n            bindEvent(\"update\" + INTERNAL_EVENT_NS.tooltips, function (values, handleNumber, unencoded) {\n                if (!scope_Tooltips || !options.tooltips) {\n                    return;\n                }\n                if (scope_Tooltips[handleNumber] === false) {\n                    return;\n                }\n                var formattedValue = values[handleNumber];\n                if (options.tooltips[handleNumber] !== true) {\n                    formattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n                }\n                scope_Tooltips[handleNumber].innerHTML = formattedValue;\n            });\n        }\n        function aria() {\n            removeEvent(\"update\" + INTERNAL_EVENT_NS.aria);\n            bindEvent(\"update\" + INTERNAL_EVENT_NS.aria, function (values, handleNumber, unencoded, tap, positions) {\n                // Update Aria Values for all handles, as a change in one changes min and max values for the next.\n                scope_HandleNumbers.forEach(function (index) {\n                    var handle = scope_Handles[index];\n                    var min = checkHandlePosition(scope_Locations, index, 0, true, true, true);\n                    var max = checkHandlePosition(scope_Locations, index, 100, true, true, true);\n                    var now = positions[index];\n                    // Formatted value for display\n                    var text = String(options.ariaFormat.to(unencoded[index]));\n                    // Map to slider range values\n                    min = scope_Spectrum.fromStepping(min).toFixed(1);\n                    max = scope_Spectrum.fromStepping(max).toFixed(1);\n                    now = scope_Spectrum.fromStepping(now).toFixed(1);\n                    handle.children[0].setAttribute(\"aria-valuemin\", min);\n                    handle.children[0].setAttribute(\"aria-valuemax\", max);\n                    handle.children[0].setAttribute(\"aria-valuenow\", now);\n                    handle.children[0].setAttribute(\"aria-valuetext\", text);\n                });\n            });\n        }\n        function getGroup(pips) {\n            // Use the range.\n            if (pips.mode === exports.PipsMode.Range || pips.mode === exports.PipsMode.Steps) {\n                return scope_Spectrum.xVal;\n            }\n            if (pips.mode === exports.PipsMode.Count) {\n                if (pips.values < 2) {\n                    throw new Error(\"noUiSlider: 'values' (>= 2) required for mode 'count'.\");\n                }\n                // Divide 0 - 100 in 'count' parts.\n                var interval = pips.values - 1;\n                var spread = 100 / interval;\n                var values = [];\n                // List these parts and have them handled as 'positions'.\n                while (interval--) {\n                    values[interval] = interval * spread;\n                }\n                values.push(100);\n                return mapToRange(values, pips.stepped);\n            }\n            if (pips.mode === exports.PipsMode.Positions) {\n                // Map all percentages to on-range values.\n                return mapToRange(pips.values, pips.stepped);\n            }\n            if (pips.mode === exports.PipsMode.Values) {\n                // If the value must be stepped, it needs to be converted to a percentage first.\n                if (pips.stepped) {\n                    return pips.values.map(function (value) {\n                        // Convert to percentage, apply step, return to value.\n                        return scope_Spectrum.fromStepping(scope_Spectrum.getStep(scope_Spectrum.toStepping(value)));\n                    });\n                }\n                // Otherwise, we can simply use the values.\n                return pips.values;\n            }\n            return []; // pips.mode = never\n        }\n        function mapToRange(values, stepped) {\n            return values.map(function (value) {\n                return scope_Spectrum.fromStepping(stepped ? scope_Spectrum.getStep(value) : value);\n            });\n        }\n        function generateSpread(pips) {\n            function safeIncrement(value, increment) {\n                // Avoid floating point variance by dropping the smallest decimal places.\n                return Number((value + increment).toFixed(7));\n            }\n            var group = getGroup(pips);\n            var indexes = {};\n            var firstInRange = scope_Spectrum.xVal[0];\n            var lastInRange = scope_Spectrum.xVal[scope_Spectrum.xVal.length - 1];\n            var ignoreFirst = false;\n            var ignoreLast = false;\n            var prevPct = 0;\n            // Create a copy of the group, sort it and filter away all duplicates.\n            group = unique(group.slice().sort(function (a, b) {\n                return a - b;\n            }));\n            // Make sure the range starts with the first element.\n            if (group[0] !== firstInRange) {\n                group.unshift(firstInRange);\n                ignoreFirst = true;\n            }\n            // Likewise for the last one.\n            if (group[group.length - 1] !== lastInRange) {\n                group.push(lastInRange);\n                ignoreLast = true;\n            }\n            group.forEach(function (current, index) {\n                // Get the current step and the lower + upper positions.\n                var step;\n                var i;\n                var q;\n                var low = current;\n                var high = group[index + 1];\n                var newPct;\n                var pctDifference;\n                var pctPos;\n                var type;\n                var steps;\n                var realSteps;\n                var stepSize;\n                var isSteps = pips.mode === exports.PipsMode.Steps;\n                // When using 'steps' mode, use the provided steps.\n                // Otherwise, we'll step on to the next subrange.\n                if (isSteps) {\n                    step = scope_Spectrum.xNumSteps[index];\n                }\n                // Default to a 'full' step.\n                if (!step) {\n                    step = high - low;\n                }\n                // If high is undefined we are at the last subrange. Make sure it iterates once (#1088)\n                if (high === undefined) {\n                    high = low;\n                }\n                // Make sure step isn't 0, which would cause an infinite loop (#654)\n                step = Math.max(step, 0.0000001);\n                // Find all steps in the subrange.\n                for (i = low; i <= high; i = safeIncrement(i, step)) {\n                    // Get the percentage value for the current step,\n                    // calculate the size for the subrange.\n                    newPct = scope_Spectrum.toStepping(i);\n                    pctDifference = newPct - prevPct;\n                    steps = pctDifference / (pips.density || 1);\n                    realSteps = Math.round(steps);\n                    // This ratio represents the amount of percentage-space a point indicates.\n                    // For a density 1 the points/percentage = 1. For density 2, that percentage needs to be re-divided.\n                    // Round the percentage offset to an even number, then divide by two\n                    // to spread the offset on both sides of the range.\n                    stepSize = pctDifference / realSteps;\n                    // Divide all points evenly, adding the correct number to this subrange.\n                    // Run up to <= so that 100% gets a point, event if ignoreLast is set.\n                    for (q = 1; q <= realSteps; q += 1) {\n                        // The ratio between the rounded value and the actual size might be ~1% off.\n                        // Correct the percentage offset by the number of points\n                        // per subrange. density = 1 will result in 100 points on the\n                        // full range, 2 for 50, 4 for 25, etc.\n                        pctPos = prevPct + q * stepSize;\n                        indexes[pctPos.toFixed(5)] = [scope_Spectrum.fromStepping(pctPos), 0];\n                    }\n                    // Determine the point type.\n                    type = group.indexOf(i) > -1 ? exports.PipsType.LargeValue : isSteps ? exports.PipsType.SmallValue : exports.PipsType.NoValue;\n                    // Enforce the 'ignoreFirst' option by overwriting the type for 0.\n                    if (!index && ignoreFirst && i !== high) {\n                        type = 0;\n                    }\n                    if (!(i === high && ignoreLast)) {\n                        // Mark the 'type' of this point. 0 = plain, 1 = real value, 2 = step value.\n                        indexes[newPct.toFixed(5)] = [i, type];\n                    }\n                    // Update the percentage count.\n                    prevPct = newPct;\n                }\n            });\n            return indexes;\n        }\n        function addMarking(spread, filterFunc, formatter) {\n            var _a, _b;\n            var element = scope_Document.createElement(\"div\");\n            var valueSizeClasses = (_a = {},\n                _a[exports.PipsType.None] = \"\",\n                _a[exports.PipsType.NoValue] = options.cssClasses.valueNormal,\n                _a[exports.PipsType.LargeValue] = options.cssClasses.valueLarge,\n                _a[exports.PipsType.SmallValue] = options.cssClasses.valueSub,\n                _a);\n            var markerSizeClasses = (_b = {},\n                _b[exports.PipsType.None] = \"\",\n                _b[exports.PipsType.NoValue] = options.cssClasses.markerNormal,\n                _b[exports.PipsType.LargeValue] = options.cssClasses.markerLarge,\n                _b[exports.PipsType.SmallValue] = options.cssClasses.markerSub,\n                _b);\n            var valueOrientationClasses = [options.cssClasses.valueHorizontal, options.cssClasses.valueVertical];\n            var markerOrientationClasses = [options.cssClasses.markerHorizontal, options.cssClasses.markerVertical];\n            addClass(element, options.cssClasses.pips);\n            addClass(element, options.ort === 0 ? options.cssClasses.pipsHorizontal : options.cssClasses.pipsVertical);\n            function getClasses(type, source) {\n                var a = source === options.cssClasses.value;\n                var orientationClasses = a ? valueOrientationClasses : markerOrientationClasses;\n                var sizeClasses = a ? valueSizeClasses : markerSizeClasses;\n                return source + \" \" + orientationClasses[options.ort] + \" \" + sizeClasses[type];\n            }\n            function addSpread(offset, value, type) {\n                // Apply the filter function, if it is set.\n                type = filterFunc ? filterFunc(value, type) : type;\n                if (type === exports.PipsType.None) {\n                    return;\n                }\n                // Add a marker for every point\n                var node = addNodeTo(element, false);\n                node.className = getClasses(type, options.cssClasses.marker);\n                node.style[options.style] = offset + \"%\";\n                // Values are only appended for points marked '1' or '2'.\n                if (type > exports.PipsType.NoValue) {\n                    node = addNodeTo(element, false);\n                    node.className = getClasses(type, options.cssClasses.value);\n                    node.setAttribute(\"data-value\", String(value));\n                    node.style[options.style] = offset + \"%\";\n                    node.innerHTML = String(formatter.to(value));\n                }\n            }\n            // Append all points.\n            Object.keys(spread).forEach(function (offset) {\n                addSpread(offset, spread[offset][0], spread[offset][1]);\n            });\n            return element;\n        }\n        function removePips() {\n            if (scope_Pips) {\n                removeElement(scope_Pips);\n                scope_Pips = null;\n            }\n        }\n        function pips(pips) {\n            // Fix #669\n            removePips();\n            var spread = generateSpread(pips);\n            var filter = pips.filter;\n            var format = pips.format || {\n                to: function (value) {\n                    return String(Math.round(value));\n                },\n            };\n            scope_Pips = scope_Target.appendChild(addMarking(spread, filter, format));\n            return scope_Pips;\n        }\n        // Shorthand for base dimensions.\n        function baseSize() {\n            var rect = scope_Base.getBoundingClientRect();\n            var alt = (\"offset\" + [\"Width\", \"Height\"][options.ort]);\n            return options.ort === 0 ? rect.width || scope_Base[alt] : rect.height || scope_Base[alt];\n        }\n        // Handler for attaching events trough a proxy.\n        function attachEvent(events, element, callback, data) {\n            // This function can be used to 'filter' events to the slider.\n            // element is a node, not a nodeList\n            var method = function (event) {\n                var e = fixEvent(event, data.pageOffset, data.target || element);\n                // fixEvent returns false if this event has a different target\n                // when handling (multi-) touch events;\n                if (!e) {\n                    return false;\n                }\n                // doNotReject is passed by all end events to make sure released touches\n                // are not rejected, leaving the slider \"stuck\" to the cursor;\n                if (isSliderDisabled() && !data.doNotReject) {\n                    return false;\n                }\n                // Stop if an active 'tap' transition is taking place.\n                if (hasClass(scope_Target, options.cssClasses.tap) && !data.doNotReject) {\n                    return false;\n                }\n                // Ignore right or middle clicks on start #454\n                if (events === actions.start && e.buttons !== undefined && e.buttons > 1) {\n                    return false;\n                }\n                // Ignore right or middle clicks on start #454\n                if (data.hover && e.buttons) {\n                    return false;\n                }\n                // 'supportsPassive' is only true if a browser also supports touch-action: none in CSS.\n                // iOS safari does not, so it doesn't get to benefit from passive scrolling. iOS does support\n                // touch-action: manipulation, but that allows panning, which breaks\n                // sliders after zooming/on non-responsive pages.\n                // See: https://bugs.webkit.org/show_bug.cgi?id=133112\n                if (!supportsPassive) {\n                    e.preventDefault();\n                }\n                e.calcPoint = e.points[options.ort];\n                // Call the event handler with the event [ and additional data ].\n                callback(e, data);\n                return;\n            };\n            var methods = [];\n            // Bind a closure on the target for every event type.\n            events.split(\" \").forEach(function (eventName) {\n                element.addEventListener(eventName, method, supportsPassive ? { passive: true } : false);\n                methods.push([eventName, method]);\n            });\n            return methods;\n        }\n        // Provide a clean event with standardized offset values.\n        function fixEvent(e, pageOffset, eventTarget) {\n            // Filter the event to register the type, which can be\n            // touch, mouse or pointer. Offset changes need to be\n            // made on an event specific basis.\n            var touch = e.type.indexOf(\"touch\") === 0;\n            var mouse = e.type.indexOf(\"mouse\") === 0;\n            var pointer = e.type.indexOf(\"pointer\") === 0;\n            var x = 0;\n            var y = 0;\n            // IE10 implemented pointer events with a prefix;\n            if (e.type.indexOf(\"MSPointer\") === 0) {\n                pointer = true;\n            }\n            // Erroneous events seem to be passed in occasionally on iOS/iPadOS after user finishes interacting with\n            // the slider. They appear to be of type MouseEvent, yet they don't have usual properties set. Ignore\n            // events that have no touches or buttons associated with them. (#1057, #1079, #1095)\n            if (e.type === \"mousedown\" && !e.buttons && !e.touches) {\n                return false;\n            }\n            // The only thing one handle should be concerned about is the touches that originated on top of it.\n            if (touch) {\n                // Returns true if a touch originated on the target.\n                var isTouchOnTarget = function (checkTouch) {\n                    var target = checkTouch.target;\n                    return (target === eventTarget ||\n                        eventTarget.contains(target) ||\n                        (e.composed && e.composedPath().shift() === eventTarget));\n                };\n                // In the case of touchstart events, we need to make sure there is still no more than one\n                // touch on the target so we look amongst all touches.\n                if (e.type === \"touchstart\") {\n                    var targetTouches = Array.prototype.filter.call(e.touches, isTouchOnTarget);\n                    // Do not support more than one touch per handle.\n                    if (targetTouches.length > 1) {\n                        return false;\n                    }\n                    x = targetTouches[0].pageX;\n                    y = targetTouches[0].pageY;\n                }\n                else {\n                    // In the other cases, find on changedTouches is enough.\n                    var targetTouch = Array.prototype.find.call(e.changedTouches, isTouchOnTarget);\n                    // Cancel if the target touch has not moved.\n                    if (!targetTouch) {\n                        return false;\n                    }\n                    x = targetTouch.pageX;\n                    y = targetTouch.pageY;\n                }\n            }\n            pageOffset = pageOffset || getPageOffset(scope_Document);\n            if (mouse || pointer) {\n                x = e.clientX + pageOffset.x;\n                y = e.clientY + pageOffset.y;\n            }\n            e.pageOffset = pageOffset;\n            e.points = [x, y];\n            e.cursor = mouse || pointer; // Fix #435\n            return e;\n        }\n        // Translate a coordinate in the document to a percentage on the slider\n        function calcPointToPercentage(calcPoint) {\n            var location = calcPoint - offset(scope_Base, options.ort);\n            var proposal = (location * 100) / baseSize();\n            // Clamp proposal between 0% and 100%\n            // Out-of-bound coordinates may occur when .noUi-base pseudo-elements\n            // are used (e.g. contained handles feature)\n            proposal = limit(proposal);\n            return options.dir ? 100 - proposal : proposal;\n        }\n        // Find handle closest to a certain percentage on the slider\n        function getClosestHandle(clickedPosition) {\n            var smallestDifference = 100;\n            var handleNumber = false;\n            scope_Handles.forEach(function (handle, index) {\n                // Disabled handles are ignored\n                if (isHandleDisabled(index)) {\n                    return;\n                }\n                var handlePosition = scope_Locations[index];\n                var differenceWithThisHandle = Math.abs(handlePosition - clickedPosition);\n                // Initial state\n                var clickAtEdge = differenceWithThisHandle === 100 && smallestDifference === 100;\n                // Difference with this handle is smaller than the previously checked handle\n                var isCloser = differenceWithThisHandle < smallestDifference;\n                var isCloserAfter = differenceWithThisHandle <= smallestDifference && clickedPosition > handlePosition;\n                if (isCloser || isCloserAfter || clickAtEdge) {\n                    handleNumber = index;\n                    smallestDifference = differenceWithThisHandle;\n                }\n            });\n            return handleNumber;\n        }\n        // Fire 'end' when a mouse or pen leaves the document.\n        function documentLeave(event, data) {\n            if (event.type === \"mouseout\" &&\n                event.target.nodeName === \"HTML\" &&\n                event.relatedTarget === null) {\n                eventEnd(event, data);\n            }\n        }\n        // Handle movement on document for handle and range drag.\n        function eventMove(event, data) {\n            // Fix #498\n            // Check value of .buttons in 'start' to work around a bug in IE10 mobile (data.buttonsProperty).\n            // https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero\n            // IE9 has .buttons and .which zero on mousemove.\n            // Firefox breaks the spec MDN defines.\n            if (navigator.appVersion.indexOf(\"MSIE 9\") === -1 && event.buttons === 0 && data.buttonsProperty !== 0) {\n                return eventEnd(event, data);\n            }\n            // Check if we are moving up or down\n            var movement = (options.dir ? -1 : 1) * (event.calcPoint - data.startCalcPoint);\n            // Convert the movement into a percentage of the slider width/height\n            var proposal = (movement * 100) / data.baseSize;\n            moveHandles(movement > 0, proposal, data.locations, data.handleNumbers, data.connect);\n        }\n        // Unbind move events on document, call callbacks.\n        function eventEnd(event, data) {\n            // The handle is no longer active, so remove the class.\n            if (data.handle) {\n                removeClass(data.handle, options.cssClasses.active);\n                scope_ActiveHandlesCount -= 1;\n            }\n            // Unbind the move and end events, which are added on 'start'.\n            data.listeners.forEach(function (c) {\n                scope_DocumentElement.removeEventListener(c[0], c[1]);\n            });\n            if (scope_ActiveHandlesCount === 0) {\n                // Remove dragging class.\n                removeClass(scope_Target, options.cssClasses.drag);\n                setZindex();\n                // Remove cursor styles and text-selection events bound to the body.\n                if (event.cursor) {\n                    scope_Body.style.cursor = \"\";\n                    scope_Body.removeEventListener(\"selectstart\", preventDefault);\n                }\n            }\n            if (options.events.smoothSteps) {\n                data.handleNumbers.forEach(function (handleNumber) {\n                    setHandle(handleNumber, scope_Locations[handleNumber], true, true, false, false);\n                });\n                data.handleNumbers.forEach(function (handleNumber) {\n                    fireEvent(\"update\", handleNumber);\n                });\n            }\n            data.handleNumbers.forEach(function (handleNumber) {\n                fireEvent(\"change\", handleNumber);\n                fireEvent(\"set\", handleNumber);\n                fireEvent(\"end\", handleNumber);\n            });\n        }\n        // Bind move events on document.\n        function eventStart(event, data) {\n            // Ignore event if any handle is disabled\n            if (data.handleNumbers.some(isHandleDisabled)) {\n                return;\n            }\n            var handle;\n            if (data.handleNumbers.length === 1) {\n                var handleOrigin = scope_Handles[data.handleNumbers[0]];\n                handle = handleOrigin.children[0];\n                scope_ActiveHandlesCount += 1;\n                // Mark the handle as 'active' so it can be styled.\n                addClass(handle, options.cssClasses.active);\n            }\n            // A drag should never propagate up to the 'tap' event.\n            event.stopPropagation();\n            // Record the event listeners.\n            var listeners = [];\n            // Attach the move and end events.\n            var moveEvent = attachEvent(actions.move, scope_DocumentElement, eventMove, {\n                // The event target has changed so we need to propagate the original one so that we keep\n                // relying on it to extract target touches.\n                target: event.target,\n                handle: handle,\n                connect: data.connect,\n                listeners: listeners,\n                startCalcPoint: event.calcPoint,\n                baseSize: baseSize(),\n                pageOffset: event.pageOffset,\n                handleNumbers: data.handleNumbers,\n                buttonsProperty: event.buttons,\n                locations: scope_Locations.slice(),\n            });\n            var endEvent = attachEvent(actions.end, scope_DocumentElement, eventEnd, {\n                target: event.target,\n                handle: handle,\n                listeners: listeners,\n                doNotReject: true,\n                handleNumbers: data.handleNumbers,\n            });\n            var outEvent = attachEvent(\"mouseout\", scope_DocumentElement, documentLeave, {\n                target: event.target,\n                handle: handle,\n                listeners: listeners,\n                doNotReject: true,\n                handleNumbers: data.handleNumbers,\n            });\n            // We want to make sure we pushed the listeners in the listener list rather than creating\n            // a new one as it has already been passed to the event handlers.\n            listeners.push.apply(listeners, moveEvent.concat(endEvent, outEvent));\n            // Text selection isn't an issue on touch devices,\n            // so adding cursor styles can be skipped.\n            if (event.cursor) {\n                // Prevent the 'I' cursor and extend the range-drag cursor.\n                scope_Body.style.cursor = getComputedStyle(event.target).cursor;\n                // Mark the target with a dragging state.\n                if (scope_Handles.length > 1) {\n                    addClass(scope_Target, options.cssClasses.drag);\n                }\n                // Prevent text selection when dragging the handles.\n                // In noUiSlider <= 9.2.0, this was handled by calling preventDefault on mouse/touch start/move,\n                // which is scroll blocking. The selectstart event is supported by FireFox starting from version 52,\n                // meaning the only holdout is iOS Safari. This doesn't matter: text selection isn't triggered there.\n                // The 'cursor' flag is false.\n                // See: http://caniuse.com/#search=selectstart\n                scope_Body.addEventListener(\"selectstart\", preventDefault, false);\n            }\n            data.handleNumbers.forEach(function (handleNumber) {\n                fireEvent(\"start\", handleNumber);\n            });\n        }\n        // Move closest handle to tapped location.\n        function eventTap(event) {\n            // The tap event shouldn't propagate up\n            event.stopPropagation();\n            var proposal = calcPointToPercentage(event.calcPoint);\n            var handleNumber = getClosestHandle(proposal);\n            // Tackle the case that all handles are 'disabled'.\n            if (handleNumber === false) {\n                return;\n            }\n            // Flag the slider as it is now in a transitional state.\n            // Transition takes a configurable amount of ms (default 300). Re-enable the slider after that.\n            if (!options.events.snap) {\n                addClassFor(scope_Target, options.cssClasses.tap, options.animationDuration);\n            }\n            setHandle(handleNumber, proposal, true, true);\n            setZindex();\n            fireEvent(\"slide\", handleNumber, true);\n            fireEvent(\"update\", handleNumber, true);\n            if (!options.events.snap) {\n                fireEvent(\"change\", handleNumber, true);\n                fireEvent(\"set\", handleNumber, true);\n            }\n            else {\n                eventStart(event, { handleNumbers: [handleNumber] });\n            }\n        }\n        // Fires a 'hover' event for a hovered mouse/pen position.\n        function eventHover(event) {\n            var proposal = calcPointToPercentage(event.calcPoint);\n            var to = scope_Spectrum.getStep(proposal);\n            var value = scope_Spectrum.fromStepping(to);\n            Object.keys(scope_Events).forEach(function (targetEvent) {\n                if (\"hover\" === targetEvent.split(\".\")[0]) {\n                    scope_Events[targetEvent].forEach(function (callback) {\n                        callback.call(scope_Self, value);\n                    });\n                }\n            });\n        }\n        // Handles keydown on focused handles\n        // Don't move the document when pressing arrow keys on focused handles\n        function eventKeydown(event, handleNumber) {\n            if (isSliderDisabled() || isHandleDisabled(handleNumber)) {\n                return false;\n            }\n            var horizontalKeys = [\"Left\", \"Right\"];\n            var verticalKeys = [\"Down\", \"Up\"];\n            var largeStepKeys = [\"PageDown\", \"PageUp\"];\n            var edgeKeys = [\"Home\", \"End\"];\n            if (options.dir && !options.ort) {\n                // On an right-to-left slider, the left and right keys act inverted\n                horizontalKeys.reverse();\n            }\n            else if (options.ort && !options.dir) {\n                // On a top-to-bottom slider, the up and down keys act inverted\n                verticalKeys.reverse();\n                largeStepKeys.reverse();\n            }\n            // Strip \"Arrow\" for IE compatibility. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key\n            var key = event.key.replace(\"Arrow\", \"\");\n            var isLargeDown = key === largeStepKeys[0];\n            var isLargeUp = key === largeStepKeys[1];\n            var isDown = key === verticalKeys[0] || key === horizontalKeys[0] || isLargeDown;\n            var isUp = key === verticalKeys[1] || key === horizontalKeys[1] || isLargeUp;\n            var isMin = key === edgeKeys[0];\n            var isMax = key === edgeKeys[1];\n            if (!isDown && !isUp && !isMin && !isMax) {\n                return true;\n            }\n            event.preventDefault();\n            var to;\n            if (isUp || isDown) {\n                var direction = isDown ? 0 : 1;\n                var steps = getNextStepsForHandle(handleNumber);\n                var step = steps[direction];\n                // At the edge of a slider, do nothing\n                if (step === null) {\n                    return false;\n                }\n                // No step set, use the default of 10% of the sub-range\n                if (step === false) {\n                    step = scope_Spectrum.getDefaultStep(scope_Locations[handleNumber], isDown, options.keyboardDefaultStep);\n                }\n                if (isLargeUp || isLargeDown) {\n                    step *= options.keyboardPageMultiplier;\n                }\n                else {\n                    step *= options.keyboardMultiplier;\n                }\n                // Step over zero-length ranges (#948);\n                step = Math.max(step, 0.0000001);\n                // Decrement for down steps\n                step = (isDown ? -1 : 1) * step;\n                to = scope_Values[handleNumber] + step;\n            }\n            else if (isMax) {\n                // End key\n                to = options.spectrum.xVal[options.spectrum.xVal.length - 1];\n            }\n            else {\n                // Home key\n                to = options.spectrum.xVal[0];\n            }\n            setHandle(handleNumber, scope_Spectrum.toStepping(to), true, true);\n            fireEvent(\"slide\", handleNumber);\n            fireEvent(\"update\", handleNumber);\n            fireEvent(\"change\", handleNumber);\n            fireEvent(\"set\", handleNumber);\n            return false;\n        }\n        // Attach events to several slider parts.\n        function bindSliderEvents(behaviour) {\n            // Attach the standard drag event to the handles.\n            if (!behaviour.fixed) {\n                scope_Handles.forEach(function (handle, index) {\n                    // These events are only bound to the visual handle\n                    // element, not the 'real' origin element.\n                    attachEvent(actions.start, handle.children[0], eventStart, {\n                        handleNumbers: [index],\n                    });\n                });\n            }\n            // Attach the tap event to the slider base.\n            if (behaviour.tap) {\n                attachEvent(actions.start, scope_Base, eventTap, {});\n            }\n            // Fire hover events\n            if (behaviour.hover) {\n                attachEvent(actions.move, scope_Base, eventHover, {\n                    hover: true,\n                });\n            }\n            // Make the range draggable.\n            if (behaviour.drag) {\n                scope_Connects.forEach(function (connect, index) {\n                    if (connect === false || index === 0 || index === scope_Connects.length - 1) {\n                        return;\n                    }\n                    var handleBefore = scope_Handles[index - 1];\n                    var handleAfter = scope_Handles[index];\n                    var eventHolders = [connect];\n                    var handlesToDrag = [handleBefore, handleAfter];\n                    var handleNumbersToDrag = [index - 1, index];\n                    addClass(connect, options.cssClasses.draggable);\n                    // When the range is fixed, the entire range can\n                    // be dragged by the handles. The handle in the first\n                    // origin will propagate the start event upward,\n                    // but it needs to be bound manually on the other.\n                    if (behaviour.fixed) {\n                        eventHolders.push(handleBefore.children[0]);\n                        eventHolders.push(handleAfter.children[0]);\n                    }\n                    if (behaviour.dragAll) {\n                        handlesToDrag = scope_Handles;\n                        handleNumbersToDrag = scope_HandleNumbers;\n                    }\n                    eventHolders.forEach(function (eventHolder) {\n                        attachEvent(actions.start, eventHolder, eventStart, {\n                            handles: handlesToDrag,\n                            handleNumbers: handleNumbersToDrag,\n                            connect: connect,\n                        });\n                    });\n                });\n            }\n        }\n        // Attach an event to this slider, possibly including a namespace\n        function bindEvent(namespacedEvent, callback) {\n            scope_Events[namespacedEvent] = scope_Events[namespacedEvent] || [];\n            scope_Events[namespacedEvent].push(callback);\n            // If the event bound is 'update,' fire it immediately for all handles.\n            if (namespacedEvent.split(\".\")[0] === \"update\") {\n                scope_Handles.forEach(function (a, index) {\n                    fireEvent(\"update\", index);\n                });\n            }\n        }\n        function isInternalNamespace(namespace) {\n            return namespace === INTERNAL_EVENT_NS.aria || namespace === INTERNAL_EVENT_NS.tooltips;\n        }\n        // Undo attachment of event\n        function removeEvent(namespacedEvent) {\n            var event = namespacedEvent && namespacedEvent.split(\".\")[0];\n            var namespace = event ? namespacedEvent.substring(event.length) : namespacedEvent;\n            Object.keys(scope_Events).forEach(function (bind) {\n                var tEvent = bind.split(\".\")[0];\n                var tNamespace = bind.substring(tEvent.length);\n                if ((!event || event === tEvent) && (!namespace || namespace === tNamespace)) {\n                    // only delete protected internal event if intentional\n                    if (!isInternalNamespace(tNamespace) || namespace === tNamespace) {\n                        delete scope_Events[bind];\n                    }\n                }\n            });\n        }\n        // External event handling\n        function fireEvent(eventName, handleNumber, tap) {\n            Object.keys(scope_Events).forEach(function (targetEvent) {\n                var eventType = targetEvent.split(\".\")[0];\n                if (eventName === eventType) {\n                    scope_Events[targetEvent].forEach(function (callback) {\n                        callback.call(\n                        // Use the slider public API as the scope ('this')\n                        scope_Self, \n                        // Return values as array, so arg_1[arg_2] is always valid.\n                        scope_Values.map(options.format.to), \n                        // Handle index, 0 or 1\n                        handleNumber, \n                        // Un-formatted slider values\n                        scope_Values.slice(), \n                        // Event is fired by tap, true or false\n                        tap || false, \n                        // Left offset of the handle, in relation to the slider\n                        scope_Locations.slice(), \n                        // add the slider public API to an accessible parameter when this is unavailable\n                        scope_Self);\n                    });\n                }\n            });\n        }\n        // Split out the handle positioning logic so the Move event can use it, too\n        function checkHandlePosition(reference, handleNumber, to, lookBackward, lookForward, getValue, smoothSteps) {\n            var distance;\n            // For sliders with multiple handles, limit movement to the other handle.\n            // Apply the margin option by adding it to the handle positions.\n            if (scope_Handles.length > 1 && !options.events.unconstrained) {\n                if (lookBackward && handleNumber > 0) {\n                    distance = scope_Spectrum.getAbsoluteDistance(reference[handleNumber - 1], options.margin, false);\n                    to = Math.max(to, distance);\n                }\n                if (lookForward && handleNumber < scope_Handles.length - 1) {\n                    distance = scope_Spectrum.getAbsoluteDistance(reference[handleNumber + 1], options.margin, true);\n                    to = Math.min(to, distance);\n                }\n            }\n            // The limit option has the opposite effect, limiting handles to a\n            // maximum distance from another. Limit must be > 0, as otherwise\n            // handles would be unmovable.\n            if (scope_Handles.length > 1 && options.limit) {\n                if (lookBackward && handleNumber > 0) {\n                    distance = scope_Spectrum.getAbsoluteDistance(reference[handleNumber - 1], options.limit, false);\n                    to = Math.min(to, distance);\n                }\n                if (lookForward && handleNumber < scope_Handles.length - 1) {\n                    distance = scope_Spectrum.getAbsoluteDistance(reference[handleNumber + 1], options.limit, true);\n                    to = Math.max(to, distance);\n                }\n            }\n            // The padding option keeps the handles a certain distance from the\n            // edges of the slider. Padding must be > 0.\n            if (options.padding) {\n                if (handleNumber === 0) {\n                    distance = scope_Spectrum.getAbsoluteDistance(0, options.padding[0], false);\n                    to = Math.max(to, distance);\n                }\n                if (handleNumber === scope_Handles.length - 1) {\n                    distance = scope_Spectrum.getAbsoluteDistance(100, options.padding[1], true);\n                    to = Math.min(to, distance);\n                }\n            }\n            if (!smoothSteps) {\n                to = scope_Spectrum.getStep(to);\n            }\n            // Limit percentage to the 0 - 100 range\n            to = limit(to);\n            // Return false if handle can't move\n            if (to === reference[handleNumber] && !getValue) {\n                return false;\n            }\n            return to;\n        }\n        // Uses slider orientation to create CSS rules. a = base value;\n        function inRuleOrder(v, a) {\n            var o = options.ort;\n            return (o ? a : v) + \", \" + (o ? v : a);\n        }\n        // Moves handle(s) by a percentage\n        // (bool, % to move, [% where handle started, ...], [index in scope_Handles, ...])\n        function moveHandles(upward, proposal, locations, handleNumbers, connect) {\n            var proposals = locations.slice();\n            // Store first handle now, so we still have it in case handleNumbers is reversed\n            var firstHandle = handleNumbers[0];\n            var smoothSteps = options.events.smoothSteps;\n            var b = [!upward, upward];\n            var f = [upward, !upward];\n            // Copy handleNumbers so we don't change the dataset\n            handleNumbers = handleNumbers.slice();\n            // Check to see which handle is 'leading'.\n            // If that one can't move the second can't either.\n            if (upward) {\n                handleNumbers.reverse();\n            }\n            // Step 1: get the maximum percentage that any of the handles can move\n            if (handleNumbers.length > 1) {\n                handleNumbers.forEach(function (handleNumber, o) {\n                    var to = checkHandlePosition(proposals, handleNumber, proposals[handleNumber] + proposal, b[o], f[o], false, smoothSteps);\n                    // Stop if one of the handles can't move.\n                    if (to === false) {\n                        proposal = 0;\n                    }\n                    else {\n                        proposal = to - proposals[handleNumber];\n                        proposals[handleNumber] = to;\n                    }\n                });\n            }\n            // If using one handle, check backward AND forward\n            else {\n                b = f = [true];\n            }\n            var state = false;\n            // Step 2: Try to set the handles with the found percentage\n            handleNumbers.forEach(function (handleNumber, o) {\n                state =\n                    setHandle(handleNumber, locations[handleNumber] + proposal, b[o], f[o], false, smoothSteps) || state;\n            });\n            // Step 3: If a handle moved, fire events\n            if (state) {\n                handleNumbers.forEach(function (handleNumber) {\n                    fireEvent(\"update\", handleNumber);\n                    fireEvent(\"slide\", handleNumber);\n                });\n                // If target is a connect, then fire drag event\n                if (connect != undefined) {\n                    fireEvent(\"drag\", firstHandle);\n                }\n            }\n        }\n        // Takes a base value and an offset. This offset is used for the connect bar size.\n        // In the initial design for this feature, the origin element was 1% wide.\n        // Unfortunately, a rounding bug in Chrome makes it impossible to implement this feature\n        // in this manner: https://bugs.chromium.org/p/chromium/issues/detail?id=798223\n        function transformDirection(a, b) {\n            return options.dir ? 100 - a - b : a;\n        }\n        // Updates scope_Locations and scope_Values, updates visual state\n        function updateHandlePosition(handleNumber, to) {\n            // Update locations.\n            scope_Locations[handleNumber] = to;\n            // Convert the value to the slider stepping/range.\n            scope_Values[handleNumber] = scope_Spectrum.fromStepping(to);\n            var translation = transformDirection(to, 0) - scope_DirOffset;\n            var translateRule = \"translate(\" + inRuleOrder(translation + \"%\", \"0\") + \")\";\n            scope_Handles[handleNumber].style[options.transformRule] = translateRule;\n            updateConnect(handleNumber);\n            updateConnect(handleNumber + 1);\n        }\n        // Handles before the slider middle are stacked later = higher,\n        // Handles after the middle later is lower\n        // [[7] [8] .......... | .......... [5] [4]\n        function setZindex() {\n            scope_HandleNumbers.forEach(function (handleNumber) {\n                var dir = scope_Locations[handleNumber] > 50 ? -1 : 1;\n                var zIndex = 3 + (scope_Handles.length + dir * handleNumber);\n                scope_Handles[handleNumber].style.zIndex = String(zIndex);\n            });\n        }\n        // Test suggested values and apply margin, step.\n        // if exactInput is true, don't run checkHandlePosition, then the handle can be placed in between steps (#436)\n        function setHandle(handleNumber, to, lookBackward, lookForward, exactInput, smoothSteps) {\n            if (!exactInput) {\n                to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false, smoothSteps);\n            }\n            if (to === false) {\n                return false;\n            }\n            updateHandlePosition(handleNumber, to);\n            return true;\n        }\n        // Updates style attribute for connect nodes\n        function updateConnect(index) {\n            // Skip connects set to false\n            if (!scope_Connects[index]) {\n                return;\n            }\n            var l = 0;\n            var h = 100;\n            if (index !== 0) {\n                l = scope_Locations[index - 1];\n            }\n            if (index !== scope_Connects.length - 1) {\n                h = scope_Locations[index];\n            }\n            // We use two rules:\n            // 'translate' to change the left/top offset;\n            // 'scale' to change the width of the element;\n            // As the element has a width of 100%, a translation of 100% is equal to 100% of the parent (.noUi-base)\n            var connectWidth = h - l;\n            var translateRule = \"translate(\" + inRuleOrder(transformDirection(l, connectWidth) + \"%\", \"0\") + \")\";\n            var scaleRule = \"scale(\" + inRuleOrder(connectWidth / 100, \"1\") + \")\";\n            scope_Connects[index].style[options.transformRule] =\n                translateRule + \" \" + scaleRule;\n        }\n        // Parses value passed to .set method. Returns current value if not parse-able.\n        function resolveToValue(to, handleNumber) {\n            // Setting with null indicates an 'ignore'.\n            // Inputting 'false' is invalid.\n            if (to === null || to === false || to === undefined) {\n                return scope_Locations[handleNumber];\n            }\n            // If a formatted number was passed, attempt to decode it.\n            if (typeof to === \"number\") {\n                to = String(to);\n            }\n            to = options.format.from(to);\n            if (to !== false) {\n                to = scope_Spectrum.toStepping(to);\n            }\n            // If parsing the number failed, use the current value.\n            if (to === false || isNaN(to)) {\n                return scope_Locations[handleNumber];\n            }\n            return to;\n        }\n        // Set the slider value.\n        function valueSet(input, fireSetEvent, exactInput) {\n            var values = asArray(input);\n            var isInit = scope_Locations[0] === undefined;\n            // Event fires by default\n            fireSetEvent = fireSetEvent === undefined ? true : fireSetEvent;\n            // Animation is optional.\n            // Make sure the initial values were set before using animated placement.\n            if (options.animate && !isInit) {\n                addClassFor(scope_Target, options.cssClasses.tap, options.animationDuration);\n            }\n            // First pass, without lookAhead but with lookBackward. Values are set from left to right.\n            scope_HandleNumbers.forEach(function (handleNumber) {\n                setHandle(handleNumber, resolveToValue(values[handleNumber], handleNumber), true, false, exactInput);\n            });\n            var i = scope_HandleNumbers.length === 1 ? 0 : 1;\n            // Spread handles evenly across the slider if the range has no size (min=max)\n            if (isInit && scope_Spectrum.hasNoSize()) {\n                exactInput = true;\n                scope_Locations[0] = 0;\n                if (scope_HandleNumbers.length > 1) {\n                    var space_1 = 100 / (scope_HandleNumbers.length - 1);\n                    scope_HandleNumbers.forEach(function (handleNumber) {\n                        scope_Locations[handleNumber] = handleNumber * space_1;\n                    });\n                }\n            }\n            // Secondary passes. Now that all base values are set, apply constraints.\n            // Iterate all handles to ensure constraints are applied for the entire slider (Issue #1009)\n            for (; i < scope_HandleNumbers.length; ++i) {\n                scope_HandleNumbers.forEach(function (handleNumber) {\n                    setHandle(handleNumber, scope_Locations[handleNumber], true, true, exactInput);\n                });\n            }\n            setZindex();\n            scope_HandleNumbers.forEach(function (handleNumber) {\n                fireEvent(\"update\", handleNumber);\n                // Fire the event only for handles that received a new value, as per #579\n                if (values[handleNumber] !== null && fireSetEvent) {\n                    fireEvent(\"set\", handleNumber);\n                }\n            });\n        }\n        // Reset slider to initial values\n        function valueReset(fireSetEvent) {\n            valueSet(options.start, fireSetEvent);\n        }\n        // Set value for a single handle\n        function valueSetHandle(handleNumber, value, fireSetEvent, exactInput) {\n            // Ensure numeric input\n            handleNumber = Number(handleNumber);\n            if (!(handleNumber >= 0 && handleNumber < scope_HandleNumbers.length)) {\n                throw new Error(\"noUiSlider: invalid handle number, got: \" + handleNumber);\n            }\n            // Look both backward and forward, since we don't want this handle to \"push\" other handles (#960);\n            // The exactInput argument can be used to ignore slider stepping (#436)\n            setHandle(handleNumber, resolveToValue(value, handleNumber), true, true, exactInput);\n            fireEvent(\"update\", handleNumber);\n            if (fireSetEvent) {\n                fireEvent(\"set\", handleNumber);\n            }\n        }\n        // Get the slider value.\n        function valueGet(unencoded) {\n            if (unencoded === void 0) { unencoded = false; }\n            if (unencoded) {\n                // return a copy of the raw values\n                return scope_Values.length === 1 ? scope_Values[0] : scope_Values.slice(0);\n            }\n            var values = scope_Values.map(options.format.to);\n            // If only one handle is used, return a single value.\n            if (values.length === 1) {\n                return values[0];\n            }\n            return values;\n        }\n        // Removes classes from the root and empties it.\n        function destroy() {\n            // remove protected internal listeners\n            removeEvent(INTERNAL_EVENT_NS.aria);\n            removeEvent(INTERNAL_EVENT_NS.tooltips);\n            Object.keys(options.cssClasses).forEach(function (key) {\n                removeClass(scope_Target, options.cssClasses[key]);\n            });\n            while (scope_Target.firstChild) {\n                scope_Target.removeChild(scope_Target.firstChild);\n            }\n            delete scope_Target.noUiSlider;\n        }\n        function getNextStepsForHandle(handleNumber) {\n            var location = scope_Locations[handleNumber];\n            var nearbySteps = scope_Spectrum.getNearbySteps(location);\n            var value = scope_Values[handleNumber];\n            var increment = nearbySteps.thisStep.step;\n            var decrement = null;\n            // If snapped, directly use defined step value\n            if (options.snap) {\n                return [\n                    value - nearbySteps.stepBefore.startValue || null,\n                    nearbySteps.stepAfter.startValue - value || null,\n                ];\n            }\n            // If the next value in this step moves into the next step,\n            // the increment is the start of the next step - the current value\n            if (increment !== false) {\n                if (value + increment > nearbySteps.stepAfter.startValue) {\n                    increment = nearbySteps.stepAfter.startValue - value;\n                }\n            }\n            // If the value is beyond the starting point\n            if (value > nearbySteps.thisStep.startValue) {\n                decrement = nearbySteps.thisStep.step;\n            }\n            else if (nearbySteps.stepBefore.step === false) {\n                decrement = false;\n            }\n            // If a handle is at the start of a step, it always steps back into the previous step first\n            else {\n                decrement = value - nearbySteps.stepBefore.highestStep;\n            }\n            // Now, if at the slider edges, there is no in/decrement\n            if (location === 100) {\n                increment = null;\n            }\n            else if (location === 0) {\n                decrement = null;\n            }\n            // As per #391, the comparison for the decrement step can have some rounding issues.\n            var stepDecimals = scope_Spectrum.countStepDecimals();\n            // Round per #391\n            if (increment !== null && increment !== false) {\n                increment = Number(increment.toFixed(stepDecimals));\n            }\n            if (decrement !== null && decrement !== false) {\n                decrement = Number(decrement.toFixed(stepDecimals));\n            }\n            return [decrement, increment];\n        }\n        // Get the current step size for the slider.\n        function getNextSteps() {\n            return scope_HandleNumbers.map(getNextStepsForHandle);\n        }\n        // Updatable: margin, limit, padding, step, range, animate, snap\n        function updateOptions(optionsToUpdate, fireSetEvent) {\n            // Spectrum is created using the range, snap, direction and step options.\n            // 'snap' and 'step' can be updated.\n            // If 'snap' and 'step' are not passed, they should remain unchanged.\n            var v = valueGet();\n            var updateAble = [\n                \"margin\",\n                \"limit\",\n                \"padding\",\n                \"range\",\n                \"animate\",\n                \"snap\",\n                \"step\",\n                \"format\",\n                \"pips\",\n                \"tooltips\",\n            ];\n            // Only change options that we're actually passed to update.\n            updateAble.forEach(function (name) {\n                // Check for undefined. null removes the value.\n                if (optionsToUpdate[name] !== undefined) {\n                    originalOptions[name] = optionsToUpdate[name];\n                }\n            });\n            var newOptions = testOptions(originalOptions);\n            // Load new options into the slider state\n            updateAble.forEach(function (name) {\n                if (optionsToUpdate[name] !== undefined) {\n                    options[name] = newOptions[name];\n                }\n            });\n            scope_Spectrum = newOptions.spectrum;\n            // Limit, margin and padding depend on the spectrum but are stored outside of it. (#677)\n            options.margin = newOptions.margin;\n            options.limit = newOptions.limit;\n            options.padding = newOptions.padding;\n            // Update pips, removes existing.\n            if (options.pips) {\n                pips(options.pips);\n            }\n            else {\n                removePips();\n            }\n            // Update tooltips, removes existing.\n            if (options.tooltips) {\n                tooltips();\n            }\n            else {\n                removeTooltips();\n            }\n            // Invalidate the current positioning so valueSet forces an update.\n            scope_Locations = [];\n            valueSet(isSet(optionsToUpdate.start) ? optionsToUpdate.start : v, fireSetEvent);\n        }\n        // Initialization steps\n        function setupSlider() {\n            // Create the base element, initialize HTML and set classes.\n            // Add handles and connect elements.\n            scope_Base = addSlider(scope_Target);\n            addElements(options.connect, scope_Base);\n            // Attach user events.\n            bindSliderEvents(options.events);\n            // Use the public value method to set the start values.\n            valueSet(options.start);\n            if (options.pips) {\n                pips(options.pips);\n            }\n            if (options.tooltips) {\n                tooltips();\n            }\n            aria();\n        }\n        setupSlider();\n        var scope_Self = {\n            destroy: destroy,\n            steps: getNextSteps,\n            on: bindEvent,\n            off: removeEvent,\n            get: valueGet,\n            set: valueSet,\n            setHandle: valueSetHandle,\n            reset: valueReset,\n            disable: disable,\n            enable: enable,\n            // Exposed for unit testing, don't use this in your application.\n            __moveHandles: function (upward, proposal, handleNumbers) {\n                moveHandles(upward, proposal, scope_Locations, handleNumbers);\n            },\n            options: originalOptions,\n            updateOptions: updateOptions,\n            target: scope_Target,\n            removePips: removePips,\n            removeTooltips: removeTooltips,\n            getPositions: function () {\n                return scope_Locations.slice();\n            },\n            getTooltips: function () {\n                return scope_Tooltips;\n            },\n            getOrigins: function () {\n                return scope_Handles;\n            },\n            pips: pips, // Issue #594\n        };\n        return scope_Self;\n    }\n    // Run the standard initializer\n    function initialize(target, originalOptions) {\n        if (!target || !target.nodeName) {\n            throw new Error(\"noUiSlider: create requires a single element, got: \" + target);\n        }\n        // Throw an error if the slider was already initialized.\n        if (target.noUiSlider) {\n            throw new Error(\"noUiSlider: Slider was already initialized.\");\n        }\n        // Test the options and create the slider environment;\n        var options = testOptions(originalOptions);\n        var api = scope(target, options, originalOptions);\n        target.noUiSlider = api;\n        return api;\n    }\n    var nouislider = {\n        // Exposed for unit testing, don't use this in your application.\n        __spectrum: Spectrum,\n        // A reference to the default classes, allows global changes.\n        // Use the cssClasses option for changes to one slider.\n        cssClasses: cssClasses,\n        create: initialize,\n    };\n\n    exports.create = initialize;\n    exports.cssClasses = cssClasses;\n    exports[\"default\"] = nouislider;\n\n    Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n"
  },
  {
    "path": "app/assets/stylesheets/pghero/application.css",
    "content": "/*\n *= require ./nouislider\n *= require ./arduino-light\n *= require_self\n */\n\nhtml {\n  box-sizing: border-box;\n  font-size: 14px;\n}\n\n*, *:before, *:after {\n  box-sizing: inherit;\n}\n\nbody {\n  margin: 0;\n  padding: 20px;\n  background-color: #eee;\n}\n\nbody {\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n  line-height: 1.4;\n  color: #333;\n}\n\na, a:visited, a:active {\n  color: #428bca;\n  text-decoration: none;\n}\n\na:hover {\n  text-decoration: underline;\n}\n\ntable {\n  width: 100%;\n  border-collapse: collapse;\n  border-spacing: 0;\n  table-layout: fixed;\n}\n\nth {\n  text-align: left;\n  border-bottom: solid 2px #ddd;\n}\n\nh1 {\n  font-size: 20px;\n  font-weight: bold;\n}\n\nh2 {\n  font-size: 16px;\n  font-weight: bold;\n}\n\nh1 small {\n  font-weight: normal;\n  font-size: 14px;\n  color: #999;\n}\n\nh1, h2, p, ul, hr, table, pre {\n  margin-top: 0;\n  margin-bottom: 1rem;\n}\n\n.field {\n  margin-bottom: 0.5rem;\n}\n\nh3 {\n  text-align: center;\n}\n\nul {\n  list-style-type: disc;\n  padding-left: 20px;\n}\n\nul.nav {\n  list-style-type: none;\n  padding: 0;\n  margin: 0;\n}\n\ntable td, table th {\n  padding: 8px;\n}\n\ntd {\n  border-top: solid 1px #ddd;\n  vertical-align: top;\n}\n\npre {\n  background-color: #eee;\n  padding: 10px;\n  white-space: pre-wrap;\n  word-break: break-word;\n  margin-top: 0;\n}\n\ntextarea {\n  width: 100%;\n  height: 120px;\n  border: solid 1px #ddd;\n  padding: 10px;\n  font-size: inherit;\n}\n\nhr {\n  border: none;\n  height: 0;\n  border-top: solid 1px #ddd;\n}\n\n.container {\n  max-width: 1000px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n.text-muted {\n  color: #999;\n}\n\n.text-right {\n  text-align: right;\n}\n\n.percent {\n  color: #999;\n  font-size: 12px;\n  margin-left: 6px;\n}\n\n.btn-explain {\n  background: none;\n  border: none;\n  padding: 0;\n  font: inherit;\n  cursor: pointer;\n  color: #999;\n  font-size: 12px;\n  line-height: 20px;\n  margin-left: 6px;\n}\n\n.btn-explain:hover {\n  text-decoration: underline;\n}\n\n.user {\n  color: #999;\n  font-size: 12px;\n  float: right;\n  line-height: 20px;\n}\n\n.user a {\n  color: inherit;\n}\n\n.tiny {\n  font-size: 12px;\n  margin-left: 6px;\n}\n\n#status, .content, .alert {\n  margin-bottom: 20px;\n}\n\n.content {\n  padding: 20px 20px 1px 20px;\n  background-color: #fff;\n}\n\n.queries td {\n  vertical-align: middle;\n}\n\n#status div {\n  margin-bottom: 0;\n}\n\n#slider-container {\n  padding: 6px 8px 14px 8px;\n}\n\n.queries-table th a, .space-table th a {\n  color: inherit;\n}\n\n#slider {\n  margin: 0px 14px 18px 14px;\n}\n\n#range-start {\n  min-height: 20px;\n}\n\n#range-end {\n  float: right;\n}\n\n.queries-info {\n  text-align: center;\n  margin-top: 40px;\n}\n\n/* nav */\n\n.nav a {\n  color: #333;\n  text-decoration: none;\n  display: block;\n  padding: 12px 20px;\n}\n\n.nav li.active a {\n  background-color: #ddd;\n}\n\n.nav a:hover {\n  background-color: #ddd;\n}\n\n.nav li.active-database a {\n  color: #999;\n}\n\n.nav-header {\n  font-weight: bold;\n  color: #333;\n  padding: 12px 20px 12px 0;\n  margin: 0;\n}\n\n/* buttons */\n\n.btn {\n  display: inline-block;\n  border: none;\n  color: #fff;\n  padding: 12px 20px;\n  font-size: inherit;\n  font-family: inherit;\n  line-height: 1;\n  cursor: pointer;\n  outline: none;\n  margin: 0;\n  -webkit-appearance: none;\n  -webkit-border-radius: 0;\n}\n\n.btn-danger {\n  background-color: #d9534f;\n}\n\n.btn-info {\n  background-color: #5bc0de;\n}\n\n/* alerts */\n\n.alert {\n  padding: 12px 20px;\n  color: #fff;\n}\n\n.alert-info {\n  background-color: #5bc0de;\n}\n\n.alert-success {\n  background-color: #5cb85c;\n}\n\n.alert-warning {\n  background-color: #f0ad4e;\n}\n\n.alert-danger {\n  background-color: #d9534f;\n}\n\n.alert a {\n  color: #fff;\n  text-decoration: none;\n}\n\n.button_to, .button_to div {\n  display: inline;\n}\n\n/*\n  Simple Grid\n  Learn More - http://dallasbass.com/simple-grid-a-lightweight-responsive-css-grid/\n  Project Page - http://thisisdallas.github.com/Simple-Grid/\n  Author - Dallas Bass\n  Site - dallasbass.com\n*/\n\n*, *:after, *:before {\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n}\n\nbody {\n  margin: 0px;\n}\n\n[class*='col-'] {\n  float: left;\n  padding-right: 20px;\n}\n\n[class*='col-']:last-of-type {\n  padding-right: 0px;\n}\n\n.grid {\n  width: 100%;\n\n  margin: 0 auto;\n  overflow: hidden;\n}\n\n.grid:after {\n  content: \"\";\n  display: table;\n  clear: both;\n}\n\n.grid-pad {\n  padding: 20px 0 0px 20px;\n}\n\n.grid-pad > [class*='col-']:last-of-type {\n  padding-right: 20px;\n}\n\n.push-right {\n  float: right;\n}\n\n/* Content Columns */\n\n.col-1-1 {\n  width: 100%;\n}\n.col-2-3, .col-8-12 {\n  width: 66.66%;\n}\n\n.col-1-2, .col-6-12 {\n  width: 50%;\n}\n\n.col-1-3, .col-4-12 {\n  width: 33.33%;\n}\n\n.col-1-4, .col-3-12 {\n  width: 25%;\n}\n\n.col-1-5 {\n  width: 20%;\n}\n\n.col-1-6, .col-2-12 {\n  width: 16.667%;\n}\n\n.col-1-7 {\n  width: 14.28%;\n}\n\n.col-1-8 {\n  width: 12.5%;\n}\n\n.col-1-9 {\n  width: 11.1%;\n}\n\n.col-1-10 {\n  width: 10%;\n}\n\n.col-1-11 {\n  width: 9.09%;\n}\n\n.col-1-12 {\n  width: 8.33%\n}\n\n/* Layout Columns */\n\n.col-11-12 {\n  width: 91.66%\n}\n\n.col-10-12 {\n  width: 83.333%;\n}\n\n.col-9-12 {\n  width: 75%;\n}\n\n.col-5-12 {\n  width: 41.66%;\n}\n\n.col-7-12 {\n  width: 58.33%\n}\n\n@media handheld, only screen and (max-width: 767px) {\n\n\n  .grid {\n    width: 100%;\n    min-width: 0;\n    margin-left: 0px;\n    margin-right: 0px;\n    padding-left: 0px;\n    padding-right: 0px;\n  }\n\n  [class*='col-'] {\n    width: auto;\n    float: none;\n    margin-left: 0px;\n    margin-right: 0px;\n    margin-top: 10px;\n    margin-bottom: 10px;\n    padding-right: 0px;\n    padding-left: 0px;\n  }\n}\n\n.noUi-connect {\n  box-shadow: none;\n  background: #5bc0de;\n}\n\n.noUi-handle {\n  box-shadow: none;\n}\n\n.noUi-target {\n  box-shadow: none;\n  border-color: #eee;\n}\n\n.noUi-background {\n  box-shadow: none;\n  background-color: #eee;\n}\n\n.noUi-origin {\n  border-radius: 0;\n}\n\n#periods {\n  text-align: center;\n}\n\n#periods a {\n  margin-right: 20px;\n}\n\n.chart {\n  height: 300px;\n  line-height: 300px;\n  text-align: center;\n  color: #999;\n  margin-bottom: 20px;\n}\n\n.pie-chart {\n  height: 260px;\n  line-height: 260px;\n}\n\n.unused-index {\n  color: #f0ad4e;\n  font-size: 11px;\n  font-weight: bold;\n}\n\n.primary-key {\n  color: #f0ad4e;\n  font-size: 11px;\n  font-weight: bold;\n}\n\n.origins-table {\n  table-layout: auto;\n}\n\n.origin {\n  word-break: break-word;\n  width: 90%;\n}\n\n.origin-pct {\n  text-align: right;\n  width: 10%;\n}\n\n.duplicate-indexes td {\n  padding: 15px 0 5px 0;\n}\n\n.duplicate-indexes pre {\n  margin-top: 10px;\n}\n\n.no-outline:focus {\n  outline: none;\n}\n\n.width-10 {\n  width: 10%;\n}\n\n.width-15 {\n  width: 15%;\n}\n\n.width-20 {\n  width: 20%;\n}\n\n.width-25 {\n  width: 25%;\n}\n\n.width-33 {\n  width: 33.33%;\n}\n\n.right-5 {\n  margin-right: 5px;\n}\n\n.query-row {\n  border-top: none;\n  padding: 0;\n}\n\n.query-pre {\n  margin-top: 1em;\n}\n\n.query-code {\n  max-height: 230px;\n  overflow: hidden;\n}\n\n.break-all {\n  word-break: break-all;\n}\n\n.migration {\n  display: none;\n}\n\n.migration pre {\n  overflow: scroll;\n  white-space: pre;\n  word-break: normal;\n}\n\n.space-index {\n  font-style: italic;\n}\n\na.relation-link {\n  color: inherit;\n}\n\n.push-left {\n  float: left;\n}\n\n.clear-both {\n  clear: both;\n}\n\n.create-index {\n  color: #eee;\n  background-color: #333;\n}\n\n.hide {\n  display: none;\n}\n\n.show-details {\n  float: right;\n  color: #f0ad4e;\n  margin-top: 0px;\n  padding: 10px;\n  cursor: pointer;\n}\n\n.details pre {\n  color: #f0ad4e;\n  background-color: #333;\n}\n"
  },
  {
    "path": "app/assets/stylesheets/pghero/arduino-light.css",
    "content": "/*\n\nArduino® Light Theme - Stefania Mellai <s.mellai@arduino.cc>\n\n*/\n\n.hljs {\n  display: block;\n  overflow-x: auto;\n}\n\n.hljs,\n.hljs-subst {\n  color: #434f54;\n}\n\n.hljs-keyword,\n.hljs-attribute,\n.hljs-selector-tag,\n.hljs-doctag,\n.hljs-name {\n  color: #00979D;\n}\n\n.hljs-built_in,\n.hljs-literal,\n.hljs-bullet,\n.hljs-code,\n.hljs-addition {\n  color: #D35400;\n}\n\n.hljs-regexp,\n.hljs-symbol,\n.hljs-variable,\n.hljs-template-variable,\n.hljs-link,\n.hljs-selector-attr,\n.hljs-selector-pseudo {\n  color: #00979D;\n}\n\n.hljs-type,\n.hljs-string,\n.hljs-selector-id,\n.hljs-selector-class,\n.hljs-quote,\n.hljs-template-tag,\n.hljs-deletion {\n  color: #005C5F;\n}\n\n.hljs-title,\n.hljs-section {\n  color: #880000;\n  font-weight: bold;\n}\n\n.hljs-comment {\n  color: #777;\n}\n\n.hljs-meta-keyword {\n  color: #728E00;\n}\n\n.hljs-meta {\n  color: #728E00;\n  color: #434f54;\n}\n\n.hljs-emphasis {\n  font-style: italic;\n}\n\n.hljs-strong {\n  font-weight: bold;\n}\n\n.hljs-function {\n  color: #728E00;\n}\n\n.hljs-number {\n  color: #8A7B52;\n}\n"
  },
  {
    "path": "app/assets/stylesheets/pghero/nouislider.css",
    "content": "/* Functional styling;\n * These styles are required for noUiSlider to function.\n * You don't need to change these rules to apply your design.\n */\n.noUi-target,\n.noUi-target * {\n  -webkit-touch-callout: none;\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n  -webkit-user-select: none;\n  -ms-touch-action: none;\n  touch-action: none;\n  -ms-user-select: none;\n  -moz-user-select: none;\n  user-select: none;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n}\n.noUi-target {\n  position: relative;\n}\n.noUi-base,\n.noUi-connects {\n  width: 100%;\n  height: 100%;\n  position: relative;\n  z-index: 1;\n}\n/* Wrapper for all connect elements.\n */\n.noUi-connects {\n  overflow: hidden;\n  z-index: 0;\n}\n.noUi-connect,\n.noUi-origin {\n  will-change: transform;\n  position: absolute;\n  z-index: 1;\n  top: 0;\n  right: 0;\n  height: 100%;\n  width: 100%;\n  -ms-transform-origin: 0 0;\n  -webkit-transform-origin: 0 0;\n  -webkit-transform-style: preserve-3d;\n  transform-origin: 0 0;\n  transform-style: flat;\n}\n/* Offset direction\n */\n.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin {\n  left: 0;\n  right: auto;\n}\n/* Give origins 0 height/width so they don't interfere with clicking the\n * connect elements.\n */\n.noUi-vertical .noUi-origin {\n  top: -100%;\n  width: 0;\n}\n.noUi-horizontal .noUi-origin {\n  height: 0;\n}\n.noUi-handle {\n  -webkit-backface-visibility: hidden;\n  backface-visibility: hidden;\n  position: absolute;\n}\n.noUi-touch-area {\n  height: 100%;\n  width: 100%;\n}\n.noUi-state-tap .noUi-connect,\n.noUi-state-tap .noUi-origin {\n  -webkit-transition: transform 0.3s;\n  transition: transform 0.3s;\n}\n.noUi-state-drag * {\n  cursor: inherit !important;\n}\n/* Slider size and handle placement;\n */\n.noUi-horizontal {\n  height: 18px;\n}\n.noUi-horizontal .noUi-handle {\n  width: 34px;\n  height: 28px;\n  right: -17px;\n  top: -6px;\n}\n.noUi-vertical {\n  width: 18px;\n}\n.noUi-vertical .noUi-handle {\n  width: 28px;\n  height: 34px;\n  right: -6px;\n  bottom: -17px;\n}\n.noUi-txt-dir-rtl.noUi-horizontal .noUi-handle {\n  left: -17px;\n  right: auto;\n}\n/* Styling;\n * Giving the connect element a border radius causes issues with using transform: scale\n */\n.noUi-target {\n  background: #FAFAFA;\n  border-radius: 4px;\n  border: 1px solid #D3D3D3;\n  box-shadow: inset 0 1px 1px #F0F0F0, 0 3px 6px -5px #BBB;\n}\n.noUi-connects {\n  border-radius: 3px;\n}\n.noUi-connect {\n  background: #3FB8AF;\n}\n/* Handles and cursors;\n */\n.noUi-draggable {\n  cursor: ew-resize;\n}\n.noUi-vertical .noUi-draggable {\n  cursor: ns-resize;\n}\n.noUi-handle {\n  border: 1px solid #D9D9D9;\n  border-radius: 3px;\n  background: #FFF;\n  cursor: default;\n  box-shadow: inset 0 0 1px #FFF, inset 0 1px 7px #EBEBEB, 0 3px 6px -3px #BBB;\n}\n.noUi-active {\n  box-shadow: inset 0 0 1px #FFF, inset 0 1px 7px #DDD, 0 3px 6px -3px #BBB;\n}\n/* Handle stripes;\n */\n.noUi-handle:before,\n.noUi-handle:after {\n  content: \"\";\n  display: block;\n  position: absolute;\n  height: 14px;\n  width: 1px;\n  background: #E8E7E6;\n  left: 14px;\n  top: 6px;\n}\n.noUi-handle:after {\n  left: 17px;\n}\n.noUi-vertical .noUi-handle:before,\n.noUi-vertical .noUi-handle:after {\n  width: 14px;\n  height: 1px;\n  left: 6px;\n  top: 14px;\n}\n.noUi-vertical .noUi-handle:after {\n  top: 17px;\n}\n/* Disabled state;\n */\n[disabled] .noUi-connect {\n  background: #B8B8B8;\n}\n[disabled].noUi-target,\n[disabled].noUi-handle,\n[disabled] .noUi-handle {\n  cursor: not-allowed;\n}\n/* Base;\n *\n */\n.noUi-pips,\n.noUi-pips * {\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n}\n.noUi-pips {\n  position: absolute;\n  color: #999;\n}\n/* Values;\n *\n */\n.noUi-value {\n  position: absolute;\n  white-space: nowrap;\n  text-align: center;\n}\n.noUi-value-sub {\n  color: #ccc;\n  font-size: 10px;\n}\n/* Markings;\n *\n */\n.noUi-marker {\n  position: absolute;\n  background: #CCC;\n}\n.noUi-marker-sub {\n  background: #AAA;\n}\n.noUi-marker-large {\n  background: #AAA;\n}\n/* Horizontal layout;\n *\n */\n.noUi-pips-horizontal {\n  padding: 10px 0;\n  height: 80px;\n  top: 100%;\n  left: 0;\n  width: 100%;\n}\n.noUi-value-horizontal {\n  -webkit-transform: translate(-50%, 50%);\n  transform: translate(-50%, 50%);\n}\n.noUi-rtl .noUi-value-horizontal {\n  -webkit-transform: translate(50%, 50%);\n  transform: translate(50%, 50%);\n}\n.noUi-marker-horizontal.noUi-marker {\n  margin-left: -1px;\n  width: 2px;\n  height: 5px;\n}\n.noUi-marker-horizontal.noUi-marker-sub {\n  height: 10px;\n}\n.noUi-marker-horizontal.noUi-marker-large {\n  height: 15px;\n}\n/* Vertical layout;\n *\n */\n.noUi-pips-vertical {\n  padding: 0 10px;\n  height: 100%;\n  top: 0;\n  left: 100%;\n}\n.noUi-value-vertical {\n  -webkit-transform: translate(0, -50%);\n  transform: translate(0, -50%);\n  padding-left: 25px;\n}\n.noUi-rtl .noUi-value-vertical {\n  -webkit-transform: translate(0, 50%);\n  transform: translate(0, 50%);\n}\n.noUi-marker-vertical.noUi-marker {\n  width: 5px;\n  height: 2px;\n  margin-top: -1px;\n}\n.noUi-marker-vertical.noUi-marker-sub {\n  width: 10px;\n}\n.noUi-marker-vertical.noUi-marker-large {\n  width: 15px;\n}\n.noUi-tooltip {\n  display: block;\n  position: absolute;\n  border: 1px solid #D9D9D9;\n  border-radius: 3px;\n  background: #fff;\n  color: #000;\n  padding: 5px;\n  text-align: center;\n  white-space: nowrap;\n}\n.noUi-horizontal .noUi-tooltip {\n  -webkit-transform: translate(-50%, 0);\n  transform: translate(-50%, 0);\n  left: 50%;\n  bottom: 120%;\n}\n.noUi-vertical .noUi-tooltip {\n  -webkit-transform: translate(0, -50%);\n  transform: translate(0, -50%);\n  top: 50%;\n  right: 120%;\n}\n.noUi-horizontal .noUi-origin > .noUi-tooltip {\n  -webkit-transform: translate(50%, 0);\n  transform: translate(50%, 0);\n  left: auto;\n  bottom: 10px;\n}\n.noUi-vertical .noUi-origin > .noUi-tooltip {\n  -webkit-transform: translate(0, -18px);\n  transform: translate(0, -18px);\n  top: auto;\n  right: 28px;\n}\n"
  },
  {
    "path": "app/controllers/pg_hero/home_controller.rb",
    "content": "module PgHero\n  class HomeController < ActionController::Base\n    http_basic_authenticate_with name: PgHero.username, password: PgHero.password if PgHero.password\n\n    protect_from_forgery with: :exception\n\n    before_action :check_api\n    before_action :set_database\n    before_action :set_query_stats_enabled\n    before_action :set_show_details, only: [:index, :queries, :show_query]\n    before_action :ensure_query_stats, only: [:queries]\n\n    if PgHero.config[\"override_csp\"]\n      # note: this does not take into account asset hosts\n      # which can be a string with %d or a proc\n      # https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html\n      # users should set CSP manually if needed\n      # see https://github.com/ankane/pghero/issues/297\n      after_action do\n        response.headers[\"Content-Security-Policy\"] = \"default-src 'self' 'unsafe-inline'\"\n      end\n    end\n\n    layout \"pg_hero/application\"\n\n    def index\n      @title = \"Overview\"\n      @extended = params[:extended]\n\n      if @replica\n        @replication_lag = @database.replication_lag\n        @good_replication_lag = @replication_lag ? @replication_lag < 5 : true\n      else\n        @inactive_replication_slots = @database.replication_slots.select { |r| !r[:active] }\n      end\n\n      @walsender_queries, long_running_queries = @database.long_running_queries.partition { |q| q[:backend_type] == \"walsender\" }\n      @autovacuum_queries, @long_running_queries = long_running_queries.partition { |q| q[:query].starts_with?(\"autovacuum:\") }\n\n      connection_states = @database.connection_states\n      @total_connections = connection_states.values.sum\n      @idle_connections = connection_states[\"idle in transaction\"].to_i\n\n      @good_total_connections = @total_connections < @database.total_connections_threshold\n      @good_idle_connections = @idle_connections < 100\n\n      @transaction_id_danger = @database.transaction_id_danger(threshold: 1500000000)\n\n      sequences, @sequences_timeout = rescue_timeout([]) { @database.sequences }\n      @readable_sequences, @unreadable_sequences = sequences.partition { |s| s[:readable] }\n\n      @sequence_danger = @database.sequence_danger(threshold: (params[:sequence_threshold] || 0.9).to_f, sequences: @readable_sequences)\n\n      @indexes, @indexes_timeout =\n        if @sequences_timeout\n          # skip indexes for faster loading\n          [[], true]\n        else\n          rescue_timeout([]) { @database.indexes }\n        end\n      @invalid_indexes = @database.invalid_indexes(indexes: @indexes)\n      @invalid_constraints = @database.invalid_constraints\n      @duplicate_indexes = @database.duplicate_indexes(indexes: @indexes)\n\n      if @query_stats_enabled\n        @query_stats = @database.query_stats(historical: true, start_at: 3.hours.ago)\n        @slow_queries = @database.slow_queries(query_stats: @query_stats)\n        set_suggested_indexes((params[:min_average_time] || 20).to_f, (params[:min_calls] || 50).to_i)\n      else\n        @query_stats_available = @database.query_stats_available?\n        @query_stats_extension_enabled = @database.query_stats_extension_enabled? if @query_stats_available\n        @suggested_indexes = []\n      end\n\n      if @extended\n        @index_hit_rate = @database.index_hit_rate || 0\n        @table_hit_rate = @database.table_hit_rate || 0\n        @good_cache_rate = @table_hit_rate >= @database.cache_hit_rate_threshold / 100.0 && @index_hit_rate >= @database.cache_hit_rate_threshold / 100.0\n        @unused_indexes = @database.unused_indexes(max_scans: 0)\n      end\n\n      @show_migrations = PgHero.show_migrations\n    end\n\n    def space\n      @title = \"Space\"\n      @days = (params[:days] || 7).to_i\n      @database_size = @database.database_size\n      @only_tables = params[:tables].present?\n      @relation_sizes, @sizes_timeout = rescue_timeout([]) { @only_tables ? @database.table_sizes : @database.relation_sizes }\n      @space_stats_enabled = @database.space_stats_enabled? && !@only_tables\n      if @space_stats_enabled\n        space_growth = @database.space_growth(days: @days, relation_sizes: @relation_sizes)\n        @growth_bytes_by_relation = space_growth.to_h { |r| [[r[:schema], r[:relation]], r[:growth_bytes]] }\n        if params[:sort] == \"growth\"\n          @relation_sizes.sort_by! { |r| s = @growth_bytes_by_relation[[r[:schema], r[:relation]]]; [s ? 0 : 1, -s.to_i, r[:schema], r[:relation]] }\n        end\n      end\n\n      if params[:sort] == \"name\"\n        @relation_sizes.sort_by! { |r| r[:relation] || r[:table] }\n      end\n\n      @header_options = @only_tables ? {tables: \"t\"} : {}\n\n      across = params[:across].to_s.split(\",\")\n      @unused_indexes = @database.unused_indexes(max_scans: 0, across: across)\n      @unused_index_names = Set.new(@unused_indexes.map { |r| r[:index] })\n      @show_migrations = PgHero.show_migrations\n      @system_stats_enabled = @database.system_stats_enabled?\n      @index_bloat = [] # @database.index_bloat\n    end\n\n    def relation_space\n      @schema = params[:schema] || \"public\"\n      @relation = params[:relation]\n      @title = @relation\n      relation_space_stats = @database.relation_space_stats(@relation, schema: @schema)\n      @chart_data = [{name: \"Value\", data: relation_space_stats.map { |r| [r[:captured_at].change(sec: 0), r[:size_bytes].to_i] }, library: chart_library_options}]\n    end\n\n    def index_bloat\n      @title = \"Index Bloat\"\n      @index_bloat = @database.index_bloat\n      @show_sql = params[:sql]\n    end\n\n    def live_queries\n      @title = \"Live Queries\"\n      @running_queries = @database.running_queries(all: true)\n      @vacuum_progress = @database.vacuum_progress.index_by { |q| q[:pid] }\n\n      if params[:state]\n        @running_queries.select! { |q| q[:state] == params[:state] }\n      end\n    end\n\n    def queries\n      @title = \"Queries\"\n      @sort = %w(average_time calls).include?(params[:sort]) ? params[:sort] : nil\n      @min_average_time = params[:min_average_time] ? params[:min_average_time].to_i : nil\n      @min_calls = params[:min_calls] ? params[:min_calls].to_i : nil\n\n      if @historical_query_stats_enabled\n        begin\n          @start_at = params[:start_at] ? Time.zone.parse(params[:start_at]) : 24.hours.ago\n          @end_at = Time.zone.parse(params[:end_at]) if params[:end_at]\n        rescue\n          @error = true\n        end\n      end\n\n      @query_stats =\n        if @historical_query_stats_enabled && !request.xhr?\n          []\n        else\n          @database.query_stats(\n            historical: true,\n            start_at: @start_at,\n            end_at: @end_at,\n            sort: @sort,\n            min_average_time: @min_average_time,\n            min_calls: @min_calls\n          )\n        end\n\n      if !@historical_query_stats_enabled || request.xhr?\n        set_suggested_indexes\n      else\n        @debug = params[:debug].present?\n      end\n\n      # fix back button issue with caching\n      response.headers[\"Cache-Control\"] = \"must-revalidate, no-store, no-cache, private\"\n      if request.xhr?\n        render layout: false, partial: \"queries_table\", locals: {queries: @query_stats, xhr: true}\n      end\n    end\n\n    def show_query\n      @query_hash = params[:query_hash].to_i\n      @user = params[:user].to_s\n      @title = @query_hash\n\n      stats = @database.query_stats(historical: true, query_hash: @query_hash, start_at: 24.hours.ago).find { |qs| qs[:user] == @user }\n      if stats\n        @query = stats[:query]\n        @explainable_query = stats[:explainable_query]\n\n        if @show_details\n          query_hash_stats = @database.query_hash_stats(@query_hash, user: @user, current: true)\n\n          @chart_data = [{name: \"Value\", data: query_hash_stats.map { |r| [r[:captured_at].change(sec: 0), (r[:total_minutes] * 60 * 1000).round] }, library: chart_library_options}]\n          @chart2_data = [{name: \"Value\", data: query_hash_stats.map { |r| [r[:captured_at].change(sec: 0), r[:average_time].round(1)] }, library: chart_library_options}]\n          @chart3_data = [{name: \"Value\", data: query_hash_stats.map { |r| [r[:captured_at].change(sec: 0), r[:calls]] }, library: chart_library_options}]\n\n          @origins = query_hash_stats.group_by { |r| r[:origin].to_s }.to_h { |k, v| [k, v.size] }\n          @total_count = query_hash_stats.size\n        end\n\n        @tables = PgQuery.parse(@query).tables rescue []\n        @tables.sort!\n\n        if @tables.any?\n          @row_counts = @database.table_stats(table: @tables).to_h { |i| [i[:table], i[:estimated_rows]] }\n          indexes, @indexes_timeout = rescue_timeout([]) { @database.indexes }\n          @indexes_by_table = indexes.group_by { |i| i[:table] }\n        end\n      else\n        render_text \"Unknown query\", status: :not_found\n      end\n    end\n\n    def system\n      @title = \"System\"\n      @periods = {\n        \"1 hour\" => {duration: 1.hour, period: 60.seconds},\n        \"1 day\" => {duration: 1.day, period: 10.minutes},\n        \"1 week\" => {duration: 1.week, period: 30.minutes},\n        \"2 weeks\" => {duration: 2.weeks, period: 1.hours}\n      }\n      if @database.system_stats_provider == :azure\n        # doesn't support 10, just 5 and 15\n        @periods[\"1 day\"][:period] = 15.minutes\n      end\n\n      @duration = (params[:duration] || 1.hour).to_i\n      @period = (params[:period] || 60.seconds).to_i\n\n      if @duration / @period > 1440\n        render_text \"Too many data points\", status: :bad_request\n      elsif @period % 60 != 0\n        render_text \"Period must be a multiple of 60\", status: :bad_request\n      end\n    end\n\n    def cpu_usage\n      render json: [{name: \"CPU\", data: @database.cpu_usage(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options}]\n    end\n\n    def connection_stats\n      render json: [{name: \"Connections\", data: @database.connection_stats(**system_params), library: chart_library_options}]\n    end\n\n    def replication_lag_stats\n      render json: [{name: \"Lag\", data: @database.replication_lag_stats(**system_params), library: chart_library_options}]\n    end\n\n    def load_stats\n      stats =\n        case @database.system_stats_provider\n        when :azure\n          if @database.send(:azure_flexible_server?)\n            [\n              {name: \"Read IOPS\", data: @database.read_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options},\n              {name: \"Write IOPS\", data: @database.write_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options}\n            ]\n          else\n            [\n              {name: \"IO Consumption\", data: @database.azure_stats(\"io_consumption_percent\", **system_params), library: chart_library_options}\n            ]\n          end\n        when :gcp\n          [\n            {name: \"Read Ops\", data: @database.read_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options},\n            {name: \"Write Ops\", data: @database.write_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options}\n          ]\n        else\n          [\n            {name: \"Read IOPS\", data: @database.read_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options},\n            {name: \"Write IOPS\", data: @database.write_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options}\n          ]\n        end\n      render json: stats\n    end\n\n    def free_space_stats\n      render json: [\n        {name: \"Free Space\", data: @database.free_space_stats(duration: 14.days, period: 1.hour), library: chart_library_options}\n      ]\n    end\n\n    def explain\n      unless @explain_enabled\n        render_text \"Explain not enabled\", status: :bad_request\n        return\n      end\n\n      @title = \"Explain\"\n      @query = params[:query]\n      @explain_analyze_enabled = PgHero.explain_mode == \"analyze\"\n\n      # TODO use get + token instead of post so users can share links\n      # need to prevent CSRF and DoS\n      if request.post? && @query.present?\n        begin\n          generic_plan = @database.server_version_num >= 160000 && @query.include?(\"$1\")\n\n          explain_options =\n            case params[:commit]\n            when \"Analyze\"\n              {analyze: true}\n            when \"Visualize\"\n              if @explain_analyze_enabled && !generic_plan\n                {analyze: true, costs: true, verbose: true, buffers: true, format: \"json\"}\n              else\n                {costs: true, verbose: true, format: \"json\"}\n              end\n            else\n              {}\n            end\n\n          explain_options[:generic_plan] = true if generic_plan\n\n          if explain_options[:analyze] && !@explain_analyze_enabled\n            render_text \"Explain analyze not enabled\", status: :bad_request\n            return\n          end\n\n          @explanation = @database.explain_v2(@query, **explain_options)\n          @suggested_index = @database.suggested_indexes(queries: [@query]).first if @database.suggested_indexes_enabled?\n          @visualize = params[:commit] == \"Visualize\"\n        rescue ActiveRecord::StatementInvalid => e\n          message = e.message\n          @error =\n            if message == \"Unsafe statement\"\n              \"Unsafe statement\"\n            elsif message.start_with?(\"PG::UndefinedParameter\")\n              \"Can't explain queries with bind parameters\"\n            elsif message.include?(\"EXPLAIN options ANALYZE and GENERIC_PLAN cannot be used together\")\n              \"Can't analyze queries with bind parameters\"\n            elsif message.start_with?(\"PG::SyntaxError\")\n              \"Syntax error with query\"\n            elsif message.start_with?(\"PG::QueryCanceled\")\n              \"Query timed out\"\n            else\n              # default to a generic message\n              # since data can be extracted through the Postgres error message\n              \"Error explaining query\"\n            end\n        end\n      end\n    end\n\n    def tune\n      @title = \"Tune\"\n      @settings = @database.settings\n      @autovacuum_settings = @database.autovacuum_settings if params[:autovacuum]\n    end\n\n    def connections\n      @title = \"Connections\"\n      connections = @database.connections\n\n      @total_connections = connections.count\n      @connection_sources = group_connections(connections, [:database, :user, :source, :ip])\n      @connections_by_database = group_connections_by_key(connections, :database)\n      @connections_by_user = group_connections_by_key(connections, :user)\n\n      if params[:security] && @database.server_version_num >= 90500\n        connections.each do |connection|\n          connection[:ssl_status] =\n            if connection[:ssl]\n              # no way to tell if client used verify-full\n              # so connection may not be actually secure\n              \"SSL\"\n            else\n              # variety of reasons for no SSL\n              if !connection[:database].present?\n                \"Internal Process\"\n              elsif !connection[:ip]\n                if connection[:state]\n                  \"Socket\"\n                else\n                  # tcp or socket, don't have permission to tell\n                  \"No SSL\"\n                end\n              else\n                # tcp\n                # could separate out localhost since this should be safe\n                \"No SSL\"\n              end\n            end\n        end\n\n        @connections_by_ssl_status = group_connections_by_key(connections, :ssl_status)\n      end\n    end\n\n    def maintenance\n      @title = \"Maintenance\"\n      @maintenance_info = @database.maintenance_info\n      @time_zone = PgHero.time_zone\n      @show_dead_rows = params[:dead_rows]\n    end\n\n    def kill\n      if @database.kill(params[:pid])\n        redirect_backward notice: \"Query killed\"\n      else\n        redirect_backward notice: \"Query no longer running\"\n      end\n    end\n\n    def kill_long_running_queries\n      @database.kill_long_running_queries\n      redirect_backward notice: \"Queries killed\"\n    end\n\n    def kill_all\n      @database.kill_all\n      redirect_backward notice: \"Connections killed\"\n    end\n\n    def enable_query_stats\n      @database.enable_query_stats\n      redirect_backward notice: \"Query stats enabled\"\n    rescue ActiveRecord::StatementInvalid\n      redirect_backward alert: \"The database user does not have permission to enable query stats\"\n    end\n\n    # TODO disable if historical query stats enabled?\n    def reset_query_stats\n      success =\n        if @database.server_version_num >= 120000\n          @database.reset_query_stats\n        else\n          @database.reset_instance_query_stats\n        end\n\n      if success\n        redirect_backward notice: \"Query stats reset\"\n      else\n        redirect_backward alert: \"The database user does not have permission to reset query stats\"\n      end\n    end\n\n    protected\n\n    def redirect_backward(**options)\n      redirect_back fallback_location: root_path, **options\n    end\n\n    def set_database\n      @databases = PgHero.databases.values\n      if params[:database]\n        # don't do direct lookup, since you don't want to call to_sym on user input\n        @database = @databases.find { |d| d.id == params[:database] }\n      elsif @databases.size > 1\n        redirect_to url_for(controller: controller_name, action: action_name, database: @databases.first.id)\n      else\n        @database = @databases.first\n      end\n    end\n\n    def default_url_options\n      {database: params[:database]}\n    end\n\n    def set_query_stats_enabled\n      @query_stats_enabled = @database.query_stats_enabled?\n      @system_stats_enabled = @database.system_stats_enabled?\n      @replica = @database.replica?\n      @explain_enabled = PgHero.explain_enabled?\n    end\n\n    def set_suggested_indexes(min_average_time = 0, min_calls = 0)\n      if @database.suggested_indexes_enabled? && !@indexes\n        @indexes, @indexes_timeout = rescue_timeout([]) { @database.indexes }\n      end\n\n      @suggested_indexes_by_query =\n        if !@indexes_timeout && @database.suggested_indexes_enabled?\n          @database.suggested_indexes_by_query(query_stats: @query_stats.select { |qs| qs[:average_time] >= min_average_time && qs[:calls] >= min_calls }, indexes: @indexes)\n        else\n          {}\n        end\n\n      @suggested_indexes = @database.suggested_indexes(suggested_indexes_by_query: @suggested_indexes_by_query)\n      @query_stats_by_query = @query_stats.index_by { |q| q[:query] }\n      @debug = params[:debug].present?\n    end\n\n    def system_params\n      {\n        duration: params[:duration],\n        period: params[:period],\n        series: true\n      }.delete_if { |_, v| v.nil? }\n    end\n\n    def chart_library_options\n      {pointRadius: 0, pointHoverRadius: 0, pointHitRadius: 5, borderWidth: 4}\n    end\n\n    def set_show_details\n      @historical_query_stats_enabled = @query_stats_enabled && @database.historical_query_stats_enabled?\n      @show_details = @historical_query_stats_enabled && @database.supports_query_hash?\n    end\n\n    def group_connections(connections, keys)\n      connections\n        .group_by { |conn| conn.slice(*keys) }\n        .map { |k, v| k.merge(total_connections: v.count) }\n        .sort_by { |v| [-v[:total_connections]] + keys.map { |k| v[k].to_s } }\n    end\n\n    def group_connections_by_key(connections, key)\n      group_connections(connections, [key]).map { |v| [v[key], v[:total_connections]] }.to_h\n    end\n\n    def check_api\n      if Rails.application.config.try(:api_only)\n        render_text \"No support for Rails API. See https://github.com/pghero/pghero for a standalone app.\", status:  :internal_server_error\n      end\n    end\n\n    def render_text(message, status:)\n      render plain: message, status: status\n    end\n\n    def ensure_query_stats\n      unless @query_stats_enabled\n        redirect_to root_path, alert: \"Query stats not enabled\"\n      end\n    end\n\n    # rescue QueryCanceled for case when\n    # statement timeout is less than lock timeout\n    def rescue_timeout(default)\n      [yield, false]\n    rescue ActiveRecord::LockWaitTimeout, ActiveRecord::QueryCanceled\n      [default, true]\n    end\n  end\nend\n"
  },
  {
    "path": "app/helpers/pg_hero/home_helper.rb",
    "content": "module PgHero\n  module HomeHelper\n    def pghero_pretty_ident(table, schema: nil)\n      ident = table\n      if schema && schema != \"public\"\n        ident = \"#{schema}.#{table}\"\n      end\n      if /\\A[a-z0-9_]+\\z/.match?(ident)\n        ident\n      else\n        @database.quote_ident(ident)\n      end\n    end\n\n    def pghero_js_value(value)\n      json_escape(value.to_json(root: false)).html_safe\n    end\n\n    def pghero_remove_index(query)\n      if query[:columns]\n        columns = query[:columns].map(&:to_sym)\n        columns = columns.first if columns.size == 1\n      end\n      ret = String.new(\"remove_index #{query[:table].to_sym.inspect}\")\n      ret << \", name: #{(query[:name] || query[:index]).to_s.inspect}\"\n      ret << \", column: #{columns.inspect}\" if columns\n      ret\n    end\n\n    def pghero_formatted_vacuum_times(time)\n      content_tag(:span, title: pghero_formatted_date_time(time)) do\n        \"#{time_ago_in_words(time, include_seconds: true).sub(/(over|about|almost) /, \"\").sub(\"less than\", \"<\")} ago\"\n      end\n    end\n\n    def pghero_formatted_date_time(time)\n      l time.in_time_zone(@time_zone), format: :long\n    end\n  end\nend\n"
  },
  {
    "path": "app/views/layouts/pg_hero/application.html.erb",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <title><%= [@databases.size > 1 ? @database.name : \"PgHero\", @title].compact.join(\" / \") %></title>\n\n    <meta charset=\"utf-8\" />\n    <%= favicon_link_tag \"pghero/favicon.png\" %>\n    <% if defined?(Propshaft::Railtie) && Rails.application.assets.is_a?(Propshaft::Assembly) %>\n      <%= stylesheet_link_tag \"pghero/nouislider\", \"pghero/arduino-light\", \"pghero/application\" %>\n      <%= javascript_include_tag \"pghero/jquery\", \"pghero/nouislider\", \"pghero/Chart.bundle\", \"pghero/chartkick\", \"pghero/highlight.min\", \"pghero/application\", nonce: true %>\n    <% else %>\n      <%= stylesheet_link_tag \"pghero/application\" %>\n      <%= javascript_include_tag \"pghero/application\", nonce: true %>\n    <% end %>\n  </head>\n  <body>\n    <div class=\"container\">\n      <div class=\"alert alert-<%= alert ? \"danger\" : \"info\" %>\">\n        <% if alert %>\n          <%= alert %>\n        <% elsif notice %>\n          <%= notice %>\n        <% elsif Rails.env.development? %>\n          Do not use development information to make decisions about your production environment\n        <% else %>\n          <%= link_to \"PgHero\", root_path %>\n        <% end %>\n      </div>\n\n      <div class=\"grid\">\n        <div class=\"col-3-12\">\n          <% if @databases.size > 1 %>\n            <p class=\"nav-header\"><%= @database.name %></p>\n          <% end %>\n\n          <ul class=\"nav\">\n            <!-- poor man's active_link_to -->\n            <li class=\"<%= controller.action_name == \"index\" ? \"active\" : \"\" %>\"><%= link_to \"Overview\", root_path %></li>\n            <% if @system_stats_enabled %>\n              <li class=\"<%= controller.action_name == \"system\" ? \"active\" : \"\" %>\"><%= link_to \"System\", system_path %></li>\n            <% end %>\n            <% if @query_stats_enabled %>\n              <li class=\"<%= controller.action_name == \"queries\" ? \"active\" : \"\" %>\"><%= link_to \"Queries\", queries_path %></li>\n            <% end %>\n            <li class=\"<%= controller.action_name == \"space\" ? \"active\" : \"\" %>\"><%= link_to \"Space\", space_path %></li>\n            <li class=\"<%= controller.action_name == \"connections\" ? \"active\" : \"\" %>\"><%= link_to \"Connections\", connections_path %></li>\n            <li class=\"<%= controller.action_name == \"live_queries\" ? \"active\" : \"\" %>\"><%= link_to \"Live Queries\", live_queries_path %></li>\n            <% unless @database.replica? %>\n              <li class=\"<%= controller.action_name == \"maintenance\" ? \"active\" : \"\" %>\"><%= link_to \"Maintenance\", maintenance_path %></li>\n            <% end %>\n            <% if @explain_enabled %>\n              <li class=\"<%= controller.action_name == \"explain\" ? \"active\" : \"\" %>\"><%= link_to \"Explain\", explain_path %></li>\n            <% end %>\n            <li class=\"<%= controller.action_name == \"tune\" ? \"active\" : \"\" %>\"><%= link_to \"Tune\", tune_path %></li>\n          </ul>\n\n          <% if @databases.size > 1 %>\n            <p class=\"nav-header\">Databases</p>\n            <ul class=\"nav\">\n              <% @databases.each do |database| %>\n                <li class=\"<%= (\"active-database\" if @database.id == database.id) %>\">\n                  <%= link_to database.name, action_name == \"show_query\" ? root_path(database: database.id) : {database: database.id} %>\n                </li>\n              <% end %>\n            </ul>\n          <% end %>\n        </div>\n\n        <div class=\"col-9-12\">\n          <%= yield %>\n        </div>\n      </div>\n    </div>\n  </body>\n</html>\n"
  },
  {
    "path": "app/views/pg_hero/home/_connections_table.html.erb",
    "content": "<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Top Sources</th>\n      <th class=\"width-20\">Connections</th>\n    </tr>\n  </thead>\n  <tbody>\n    <% connection_sources.each do |source| %>\n      <tr>\n        <td><%= source[:source] %> <div class=\"text-muted\"><%= [source[:user], source[:database], source[:ip]].compact.join(\" - \") %></div></td>\n        <td><%= number_with_delimiter(source[:total_connections]) %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n"
  },
  {
    "path": "app/views/pg_hero/home/_live_queries_table.html.erb",
    "content": "<table class=\"table queries\">\n  <thead>\n    <tr>\n      <th class=\"width-25\">Pid</th>\n      <th class=\"width-25\">Duration</th>\n      <th class=\"width-25\">State</th>\n      <th class=\"width-25\"></th>\n    </tr>\n  </thead>\n  <tbody>\n    <% queries.reverse.each do |query| %>\n      <tr>\n        <td><%= query[:pid] %></td>\n        <td>\n          <% if query[:duration_ms] %>\n            <% sec = query[:duration_ms] / 1000.0 %>\n            <% if sec < 1.minute %>\n              <%= sec.round(1) %> s\n            <% elsif sec < 1.day %>\n              <%= Time.at(sec).utc.strftime(\"%H:%M:%S\") %>\n            <% else %>\n              <% days = (sec / 1.day).floor %>\n              <%= days %>d <%= Time.at(sec - days.days).utc.strftime(\"%H:%M:%S\") %>\n            <% end %>\n          <% end %>\n        </td>\n        <td>\n          <%= query[:state] %>\n          <% if vacuum_progress[query[:pid]] %>\n            <br />\n            <strong><%= vacuum_progress[query[:pid]][:phase] %></strong>\n          <% end %>\n        </td>\n        <td class=\"text-right\">\n          <% unless @database.filter_data %>\n            <%= button_to \"Explain\", explain_path, params: {query: query[:query]}, form: {target: \"_blank\"}, class: \"btn btn-info\" %>\n          <% end %>\n          <%= button_to \"Kill\", kill_path(pid: query[:pid]), class: \"btn btn-danger\" %>\n        </td>\n      </tr>\n      <tr>\n        <td colspan=\"4\" class=\"query-row\">\n          <%= query[:source] %> <span class=\"text-muted\"><%= query[:user] %></span>\n          <pre class=\"query-pre\"><code><%= query[:query] %></code></pre>\n        </td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<%= javascript_tag nonce: true do %>\n  highlightQueries();\n<% end %>\n"
  },
  {
    "path": "app/views/pg_hero/home/_queries_table.html.erb",
    "content": "<table class=\"table queries-table\">\n  <% unless local_assigns[:xhr] %>\n    <thead>\n      <tr>\n        <th class=\"width-33\"><%= local_assigns[:sort_headers] ? link_to(\"Total Time\", {sort: nil}, data: {sort: nil}) : \"Total Time\" %></th>\n        <th class=\"width-33\"><%= local_assigns[:sort_headers] ? link_to(\"Average Time\", {sort: \"average_time\"}, data: {sort: \"average_time\"}) : \"Average Time\" %></th>\n        <th class=\"width-33\"><%= local_assigns[:sort_headers] ? link_to(\"Calls\", {sort: \"calls\"}, data: {sort: \"calls\"}) : \"Calls\" %></th>\n      </tr>\n    </thead>\n  <% end %>\n  <tbody id=\"queries\">\n    <% if queries.empty? %>\n      <tr>\n        <td colspan=\"3\">\n          <p class=\"queries-info text-muted\">\n            <% if local_assigns[:xhr] %>\n              No data available for this time.\n            <% else %>\n              ...\n            <% end %>\n          </p>\n        </td>\n      </tr>\n    <% end %>\n    <% queries.each do |query| %>\n      <tr>\n        <td>\n          <%= number_with_delimiter(query[:total_minutes].round) %> min\n          <span class=\"percent\">\n            <% percent = query[:total_percent] %>\n            <% if percent > 1 %>\n              <%= percent.round %>%\n            <% elsif percent > 0.1 %>\n              <%= percent.round(1) %>%\n            <% else %>\n              &lt; 0.1%\n            <% end %>\n          </span>\n        </td>\n        <td>\n          <%= number_with_delimiter(query[:average_time].round) %> ms\n        </td>\n        <td>\n          <%= number_with_delimiter(query[:calls]) %>\n\n          <span class=\"user\">\n            <% if query[:user] %>\n              <%= query[:user] %>\n              <% if @show_details %>\n                &middot;\n              <% end %>\n            <% end %>\n            <% if @show_details && query[:query_hash] %>\n              <%= link_to \"details\", show_query_path(query[:query_hash], user: query[:user]), target: \"_blank\" %>\n            <% end %>\n          </span>\n        </td>\n      </tr>\n      <tr>\n        <td colspan=\"3\" class=\"query-row\">\n          <pre><code class=\"query-code\"><%= query[:query] %></code></pre>\n          <% if query[:query] == \"<insufficient privilege>\" %>\n            <p class=\"text-muted\">For security reasons, only superusers can see queries executed by other users.</p>\n          <% end %>\n          <% if local_assigns[:suggested_indexes] != false && (details = @suggested_indexes_by_query[query[:query]]) && (details[:index] || @debug) %>\n            <%= render partial: \"suggested_index\", locals: {index: details[:index], details: details} %>\n          <% end %>\n        </td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n"
  },
  {
    "path": "app/views/pg_hero/home/_query_stats_slider.html.erb",
    "content": "<div id=\"slider-container\">\n  <div id=\"slider\"></div>\n  <div id=\"range-end\"></div>\n  <div id=\"range-start\"></div>\n</div>\n\n<%= javascript_tag nonce: true do %>\n  var sort = <%= pghero_js_value(@sort) %>;\n  var minAverageTime = <%= pghero_js_value(@min_average_time) %>;\n  var minCalls = <%= pghero_js_value(@min_calls) %>;\n  var debug = <%= pghero_js_value(@debug) %>;\n  var startAt = <%= pghero_js_value(params[:start_at] ? @start_at.to_i * 1000 : nil) %>;\n  var endAt = <%= pghero_js_value(@end_at.to_i * 1000) %>;\n\n  initSlider();\n<% end %>\n"
  },
  {
    "path": "app/views/pg_hero/home/_suggested_index.html.erb",
    "content": "<% if index && !details[:covering_index] %>\n  <% unless @debug %>\n    <div class=\"show-details\">Details</div>\n  <% end %>\n  <code><pre class=\"create-index\">CREATE INDEX CONCURRENTLY ON <%= index[:table] %><% if index[:using] %> USING <%= index[:using] %><% end %> (<%= index[:columns].join(\", \") %>)</pre></code>\n<% end %>\n<div class=\"details<%= \" hide\" unless @debug %>\">\n  <code><pre><% if details[:explanation] %><%= details[:explanation] %>\n<% end %><% if details[:row_estimates] %>Rows: <%= details[:rows] %>\n<% if details[:row_progression] %>Row progression: <%= details[:row_progression].to_a.join(\", \") %>\n<% end %>\n\nRow estimates\n<%= details[:row_estimates].to_a.map { |k, v| \"- #{k}: #{v}\" }.join(\"\\n\") %><% end %><% if details[:table_indexes] %>\n\nExisting indexes\n<% details[:table_indexes].sort_by { |i| [i[:primary] ? 0 : 1, i[:columns]] }.each do |i3| %>- <%= i3[:columns].join(\", \") %><% if i3[:using] != \"btree\" %> <%= i3[:using].to_s.upcase %><% end %><% if i3[:primary] %> PRIMARY<% elsif i3[:unique] %> UNIQUE<% end %>\n<% end %><% end %></pre></code>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/connections.html.erb",
    "content": "<div class=\"content\">\n  <h1>Connections</h1>\n\n  <p><%= pluralize(@total_connections, \"connection\") %></p>\n\n  <% if @total_connections > 0 %>\n    <h3>By Database</h3>\n\n    <div id=\"chart-1\" class=\"chart pie-chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.PieChart(\"chart-1\", <%= pghero_js_value(@connections_by_database) %>);\n    <% end %>\n\n    <h3>By User</h3>\n\n    <div id=\"chart-2\" class=\"chart pie-chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.PieChart(\"chart-2\", <%= pghero_js_value(@connections_by_user) %>);\n    <% end %>\n\n    <% if @connections_by_ssl_status %>\n      <h3>By Security</h3>\n\n      <div id=\"chart-3\" class=\"chart pie-chart\">Loading...</div>\n      <%= javascript_tag nonce: true do %>\n        new Chartkick.PieChart(\"chart-3\", <%= pghero_js_value(@connections_by_ssl_status) %>);\n      <% end %>\n    <% end %>\n\n    <%= render partial: \"connections_table\", locals: {connection_sources: @connection_sources} %>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/explain.html.erb",
    "content": "<div class=\"content\">\n  <h1>Explain</h1>\n\n  <%= form_tag explain_path do %>\n    <div class=\"field\"><%= text_area_tag :query, @query, placeholder: \"Enter a SQL query\" %></div>\n    <p>\n      <%= submit_tag \"Explain\", class: \"btn btn-info right-5\" %>\n      <% if @explain_analyze_enabled %>\n        <%= submit_tag \"Analyze\", class: \"btn btn-danger right-5\" %>\n      <% end %>\n      <%= submit_tag \"Visualize\", class: \"btn btn-danger\" %>\n    </p>\n  <% end %>\n\n  <% if @explanation %>\n    <% if @visualize %>\n      <p>Paste the output below into the <%= link_to \"explain visualizer\", PgHero.visualize_url, target: \"_blank\" %></p>\n    <% end %>\n    <pre><code><%= @explanation %></code></pre>\n    <% unless @visualize %>\n      <p><%= link_to \"See how to interpret this\", \"https://www.postgresql.org/docs/current/static/using-explain.html\", target: \"_blank\" %></p>\n    <% end %>\n    <% if (index = @suggested_index) %>\n      <%= render partial: \"suggested_index\", locals: {index: index, details: index[:details]} %>\n    <% end %>\n  <% elsif @error %>\n    <div class=\"alert alert-danger\"><%= @error %></div>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/index.html.erb",
    "content": "<div id=\"status\">\n  <% if @replica %>\n    <div class=\"alert alert-<%= @good_replication_lag ? \"success\" : \"warning\" %>\">\n      <% if @replication_lag %>\n        <% if @good_replication_lag %>\n          Healthy replication lag\n        <% else %>\n          High replication lag\n        <% end %>\n        <span class=\"tiny\"><%= number_with_delimiter((@replication_lag * 1000).round) %> ms</span>\n      <% else %>\n        Replication lag not supported\n      <% end %>\n    </div>\n  <% elsif @inactive_replication_slots.any? %>\n    <div class=\"alert alert-warning\">\n      <%= pluralize(@inactive_replication_slots.size, \"inactive replication slot\") %>\n    </div>\n  <% end %>\n  <div class=\"alert alert-<%= @long_running_queries.empty? ? \"success\" : \"warning\" %>\">\n    <% if @long_running_queries.any? %>\n      <%= pluralize(@long_running_queries.size, \"long running query\") %>\n    <% else %>\n      No long running queries\n    <% end %>\n    <% if @autovacuum_queries.any? %>\n      <span class=\"tiny\"><%= @autovacuum_queries.size %> autovacuum</span>\n    <% end %>\n    <% if @walsender_queries.any? %>\n      <span class=\"tiny\"><%= @walsender_queries.size %> walsender</span>\n    <% end %>\n  </div>\n  <% if @extended %>\n    <div class=\"alert alert-<%= @good_cache_rate ? \"success\" : \"warning\" %>\">\n      <% if @good_cache_rate %>\n        Cache hit rate above <%= @database.cache_hit_rate_threshold %>%\n      <% else %>\n        Low cache hit rate\n      <% end %>\n    </div>\n  <% end %>\n  <div class=\"alert alert-<%= @good_total_connections && @good_idle_connections ? \"success\" : \"warning\" %>\">\n    <% if !@good_total_connections %>\n      High number of connections <span class=\"tiny\"><%= @total_connections %></span>\n    <% elsif !@good_idle_connections %>\n      High number of connections idle in transaction <span class=\"tiny\"><%= @idle_connections %></span>\n    <% else %>\n      Connections healthy <span class=\"tiny\"><%= @total_connections %></span>\n    <% end %>\n  </div>\n  <div class=\"alert alert-<%= @transaction_id_danger.empty? ? \"success\" : \"warning\" %>\">\n    <% if @transaction_id_danger.any? %>\n      <%= pluralize(@transaction_id_danger.size, \"table\") %> not vacuuming properly\n    <% else %>\n      Vacuuming healthy\n    <% end %>\n  </div>\n  <div class=\"alert alert-<%= @sequence_danger && @sequence_danger.empty? && !@sequences_timeout ? \"success\" : \"warning\" %>\">\n    <% if @sequence_danger.any? %>\n      <%= pluralize(@sequence_danger.size, \"column\") %> approaching overflow\n    <% elsif @sequences_timeout %>\n      Sequences not available (system catalog locked)\n    <% else %>\n      No columns near integer overflow\n    <% end %>\n    <% if @unreadable_sequences.any? %>\n      (<%= link_to pluralize(@unreadable_sequences.size, \"unreadable sequence\", \"unreadable sequences\"), {unreadable: \"t\"} %>)\n    <% end %>\n  </div>\n  <div class=\"alert alert-<%= @invalid_indexes.empty? && @invalid_constraints.empty? ? \"success\" : \"warning\" %>\">\n    <% if @invalid_indexes.empty? && @invalid_constraints.empty?  %>\n      No invalid indexes or constraints\n    <% else %>\n      <% if @invalid_indexes.any? %>\n        <%= pluralize(@invalid_indexes.size, \"invalid index\", \"invalid indexes\") %>\n      <% end %>\n      <% if @invalid_constraints.any? %>\n        <% if @invalid_indexes.any? %>and<% end %>\n        <%= pluralize(@invalid_constraints.size, \"invalid constraint\", \"invalid constraints\") %>\n      <% end %>\n    <% end %>\n  </div>\n  <% if @duplicate_indexes %>\n    <div class=\"alert alert-<%= @duplicate_indexes.empty? ? \"success\" : \"warning\" %>\">\n      <% if @duplicate_indexes.any? %>\n        <%= pluralize(@duplicate_indexes.size, \"duplicate index\", \"duplicate indexes\") %>\n      <% else %>\n        No duplicate indexes\n      <% end %>\n    </div>\n  <% end %>\n  <% if @database.suggested_indexes_enabled? %>\n    <div class=\"alert alert-<%= @suggested_indexes.empty? ? \"success\" : \"warning\" %>\">\n      <% if @suggested_indexes.any? %>\n        <%= pluralize(@suggested_indexes.size, \"suggested index\", \"suggested indexes\") %>\n      <% else %>\n        No suggested indexes\n      <% end %>\n    </div>\n  <% end %>\n  <div class=\"alert alert-<%= @query_stats_enabled && @slow_queries.empty? ? \"success\" : \"warning\" %>\">\n    <% if !@query_stats_enabled %>\n      Query stats must be enabled for slow queries\n    <% elsif @slow_queries.any? %>\n      <%= pluralize(@slow_queries.size, \"slow query\") %>\n    <% else %>\n      No slow queries\n    <% end %>\n  </div>\n  <% if @extended %>\n    <div class=\"alert alert-<%= @unused_indexes.empty? ? \"success\" : \"warning\" %>\">\n      <% if @unused_indexes.any? %>\n        <%= pluralize(@unused_indexes.size, \"unused index\", \"unused indexes\") %>\n      <% else %>\n        No unused indexes\n      <% end %>\n    </div>\n  <% end %>\n</div>\n\n<% if params[:unreadable] && @unreadable_sequences.any? %>\n  <div class=\"content\">\n    <h1>Unreadable Sequences</h1>\n\n    <p>This is likely due to missing privileges. Make sure your user has the SELECT privilege for each sequence.</p>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th class=\"width-33\">Column</th>\n          <th>Sequence</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @unreadable_sequences.each do |sequence| %>\n          <tr>\n            <td>\n              <%= sequence[:table] %>.<%= sequence[:column] %>\n              <% if sequence[:table_schema] != \"public\" %>\n                <span class=\"text-muted\"><%= sequence[:table_schema] %></span>\n              <% end %>\n            </td>\n            <td>\n              <% if sequence[:sequence] %>\n                <%= sequence[:sequence] %>\n                <% if sequence[:schema] && sequence[:schema] != \"public\" %>\n                  <span class=\"text-muted\"><%= sequence[:schema] %></span>\n                <% end %>\n              <% else %>\n                Unable to parse: <%= sequence[:default_value] %>\n              <% end %>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @replica && !@good_replication_lag %>\n  <div class=\"content\">\n    <h1>High Replication Lag</h1>\n\n    <p><%= pluralize(@replication_lag.round, \"second\") %></p>\n  </div>\n<% end %>\n\n<% if @inactive_replication_slots && @inactive_replication_slots.any? %>\n  <div class=\"content\">\n    <h1>Inactive Replication Slots</h1>\n    <p>Inactive replication slots can cause a lot of disk space to be consumed.</p>\n    <p>For each, run:</p>\n    <pre><code>SELECT pg_drop_replication_slot('slot_name');</code></pre>\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Name</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @inactive_replication_slots.each do |slot| %>\n          <tr>\n            <td><%= slot[:slot_name] %></td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @long_running_queries.any? %>\n  <div class=\"content\">\n    <%= button_to \"Kill All\", kill_long_running_queries_path, class: \"btn btn-danger\", style: \"float: right;\" %>\n    <h1>Long Running Queries</h1>\n\n    <p>We recommend setting a statement timeout on all non-superusers with:</p>\n\n    <pre><code>ALTER ROLE &lt;user&gt; SET statement_timeout TO '60s';</code></pre>\n\n    <%= render partial: \"live_queries_table\", locals: {queries: @long_running_queries, vacuum_progress: {}} %>\n  </div>\n<% end %>\n\n<% if @extended && !@good_cache_rate %>\n  <div class=\"content\">\n    <h1>Low Cache Hit Rate</h1>\n\n    <p>\n      Index Hit Rate: <%= (@index_hit_rate * 100).round(1) %>%\n      <br />\n      Table Hit Rate: <%= (@table_hit_rate * 100).round(1) %>%\n    </p>\n\n    <p>\n      The cache hit rate <%= link_to \"should be above 99%\", \"https://devcenter.heroku.com/articles/understanding-postgres-data-caching\", target: \"_blank\" %> in most cases.  You can often increase this by adding more memory.\n      <!-- TODO better suggestions -->\n    </p>\n  </div>\n<% end %>\n\n<% if !@good_total_connections %>\n  <div class=\"content\">\n    <h1>High Number of Connections</h1>\n    <p><%= pluralize(@total_connections, \"connection\") %></p>\n\n    <p><%= link_to \"Use connection pooling\", \"https://www.craigkerstiens.com/2014/05/22/postgres-and-connection-pooling/\", target: \"_blank\" %> for better performance. <%= link_to \"PgBouncer\", \"https://wiki.postgresql.org/wiki/PgBouncer\", target: \"_blank\" %> is a solid option.</p>\n\n    <%= render partial: \"connections_table\", locals: {connection_sources: @database.connection_sources.first(10)} %>\n  </div>\n<% end %>\n\n<% if !@good_idle_connections %>\n  <div class=\"content\">\n    <h1>High Number of Connections Idle in Transaction</h1>\n    <p><%= pluralize(@idle_connections, \"connection\") %> idle in transaction</p>\n    <p>Avoid opening transactions and doing work outside the database.</p>\n    <p><%= link_to \"View queries\", live_queries_path(state: \"idle in transaction\") %></p>\n  </div>\n<% end %>\n\n<% if @transaction_id_danger.any? %>\n  <div class=\"content\">\n    <h2>Vacuuming Needed</h2>\n    <p>The database <strong>will shutdown</strong> when there are fewer than 1,000,000 transactions left. <%= link_to \"Read more\", \"https://www.postgresql.org/docs/current/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND\", target: \"_blank\" %>.</p>\n\n    <p>Try <%= link_to \"tuning autovacuum\", \"https://blog.2ndquadrant.com/autovacuum-tuning-basics/\", target: \"_blank\" %> - specifically autovacuum_vacuum_cost_limit.</p>\n\n    <p>If that doesn’t work, for each table, run:</p>\n    <pre><code>VACUUM FREEZE VERBOSE table;</code></pre>\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Table</th>\n          <th class=\"width-20\">Transactions Left</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @transaction_id_danger.each do |query| %>\n          <tr>\n            <td>\n              <%= query[:table] %>\n              <% if query[:schema] != \"public\" %>\n                <span class=\"text-muted\"><%= query[:schema] %></span>\n              <% end %>\n            </td>\n            <td><%= number_with_delimiter(query[:transactions_left]) %></td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @sequence_danger && @sequence_danger.any? %>\n  <div class=\"content\">\n    <h2>Columns Near Overflow</h2>\n    <p>Consider changing columns to bigint to support a larger range of values.</p>\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Column</th>\n          <th class=\"width-20\">Type</th>\n          <th class=\"width-20\">Values Left</th>\n          <th class=\"width-10\">% Left</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @sequence_danger.sort_by { |s| [s[:table], s[:column]] }.each do |query| %>\n          <tr>\n            <td>\n              <%= query[:table] %>.<%= query[:column] %>\n              <% if query[:table_schema] != \"public\" %>\n                <span class=\"text-muted\"><%= query[:table_schema] %></span>\n              <% end %>\n            </td>\n            <td>\n              <%= query[:column_type] %>\n            </td>\n            <td>\n              <%= number_with_delimiter(query[:max_value] - query[:last_value]) %>\n            </td>\n            <td>\n              <%= number_to_percentage((query[:max_value] - query[:last_value]) * 100.0 / query[:max_value], precision: 2, significant: true) %>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @invalid_indexes.any? %>\n  <div class=\"content\">\n    <h1>Invalid Indexes</h1>\n\n    <p>These indexes exist, but can’t be used. You should recreate them.</p>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Name</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @invalid_indexes.each do |index| %>\n          <tr>\n            <td>\n              <%= index[:name] %>\n              <% if index[:schema] != \"public\" %>\n                <span class=\"text-muted\"><%= index[:schema] %></span>\n              <% end %>\n            </td>\n          </tr>\n          <tr>\n            <td class=\"query-row\">\n              <pre><code>DROP INDEX CONCURRENTLY <%= pghero_pretty_ident(index[:name], schema: index[:schema]) %>;\n<%= index[:definition].sub(\"CREATE INDEX \", \"CREATE INDEX CONCURRENTLY \") %>;</code></pre>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @invalid_constraints.any? %>\n  <div class=\"content\">\n    <h1>Invalid Constraints</h1>\n\n    <p>These constraints are marked as <code>NOT VALID</code>. You should validate them.</p>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Name</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @invalid_constraints.each do |constraint| %>\n          <tr>\n            <td>\n              <%= constraint[:name] %>\n              <% if constraint[:schema] != \"public\" %>\n                <span class=\"text-muted\"><%= constraint[:schema] %></span>\n              <% end %>\n            </td>\n          </tr>\n          <tr>\n            <td class=\"query-row\">\n              <pre><code>ALTER TABLE <%= pghero_pretty_ident(constraint[:table], schema: constraint[:schema]) %> VALIDATE CONSTRAINT <%= pghero_pretty_ident(constraint[:name]) %>;</code></pre>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @duplicate_indexes && @duplicate_indexes.any? %>\n  <div class=\"content\">\n    <h1>Duplicate Indexes</h1>\n\n    <p>\n      These indexes exist, but aren’t needed. Remove them\n      <% if @show_migrations %>\n      <a href=\"#\" class=\"migration-link\">with a migration</a>\n      <% end %>\n      for faster writes.\n    </p>\n\n    <div class=\"migration\">\n      <pre>rails generate migration remove_unneeded_indexes</pre>\n      <p>And paste</p>\n      <pre><% @duplicate_indexes.each do |query| %>\n<%= pghero_remove_index(query[:unneeded_index]) %><% end %></pre>\n    </div>\n\n    <table class=\"table duplicate-indexes\">\n      <thead>\n        <tr>\n          <th>Details</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @duplicate_indexes.each do |index| %>\n          <% unneeded_index = index[:unneeded_index] %>\n          <% covering_index = index[:covering_index] %>\n          <tr>\n            <td>\n              On <%= unneeded_index[:table] %>\n              <pre><%= unneeded_index[:name] %> (<%= unneeded_index[:columns].join(\", \") %>)</pre>\n              is covered by\n              <pre><%= covering_index[:name] %> (<%= covering_index[:columns].join(\", \") %>)</pre>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<% if @suggested_indexes.any? %>\n  <div class=\"content\">\n    <h1>Suggested Indexes</h1>\n    <p>\n      Add indexes to speed up queries.\n      <% if @show_migrations %>\n      Here’s a\n      <a href=\"#\" class=\"migration-link\">migration</a> to help.\n      <% end %>\n    </p>\n\n    <div class=\"migration\">\n      <pre>rails generate migration add_suggested_indexes</pre>\n      <p>And paste</p>\n      <pre>commit_db_transaction\n<% @suggested_indexes.each do |index| %>\n<% if index[:using] && index[:using] != \"btree\" %>\nadd_index <%= index[:table].to_sym.inspect %>, <%= index[:columns].first.inspect %>, using: <%= index[:using].inspect %>, algorithm: :concurrently\n<% else %>\nadd_index <%= index[:table].to_sym.inspect %>, [<%= index[:columns].map(&:to_sym).map(&:inspect).join(\", \") %>], algorithm: :concurrently<% end %>\n<% end %></pre>\n    </div>\n\n    <% @suggested_indexes.each_with_index do |index, i| %>\n      <hr />\n      <%= render partial: \"suggested_index\", locals: {index: index, details: index[:details]} %>\n      <p>to speed up</p>\n      <%= render partial: \"queries_table\", locals: {queries: index[:queries].map { |q| @query_stats_by_query[q] }, suggested_indexes: false} %>\n    <% end %>\n  </div>\n<% end %>\n\n<% if !@query_stats_enabled %>\n  <div class=\"content\">\n    <h1>Query Stats</h1>\n\n    <% if @query_stats_available && !@query_stats_extension_enabled %>\n      <p>\n        Query stats are available but not enabled.\n        <%= button_to \"Enable\", enable_query_stats_path, class: \"btn btn-info\" %>\n      </p>\n    <% else %>\n      <p>Make them available by adding the following lines to <code>postgresql.conf</code>:</p>\n      <pre>shared_preload_libraries = 'pg_stat_statements'\npg_stat_statements.track = all</pre>\n      <p>Restart the server for the changes to take effect.</p>\n    <% end %>\n  </div>\n<% end %>\n\n<% if @query_stats_enabled && @slow_queries.any? %>\n  <div class=\"content\">\n    <h1>Slow Queries</h1>\n\n    <p>Slow queries take <%= @database.slow_query_ms %> ms or more on average and have been called at least <%= @database.slow_query_calls %> times.</p>\n    <p><%= link_to \"Explain queries\", explain_path %> to see where to add indexes.</p>\n\n    <%= render partial: \"queries_table\", locals: {queries: @slow_queries} %>\n  </div>\n<% end %>\n\n<% if @extended && @unused_indexes.any? %>\n  <div class=\"content\">\n    <h1>Unused Indexes</h1>\n\n    <p>\n      Unused indexes cause unnecessary overhead. Remove them\n      <% if @show_migrations %>\n        <a href=\"#\" class=\"migration-link\">with a migration</a>\n      <% end %>\n      for faster writes.\n    </p>\n\n    <div class=\"migration\">\n      <pre>rails generate migration remove_unused_indexes</pre>\n      <p>And paste</p>\n      <pre><% @unused_indexes.each do |query| %>\n<%= pghero_remove_index(query)%><% end %></pre>\n    </div>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Name</th>\n          <th class=\"width-20\">Index Size</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @unused_indexes.each do |query| %>\n          <tr>\n            <td><%= query[:index] %><div class=\"text-muted\">on <%= query[:table] %></div></td>\n            <td><%= query[:size] %></td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  </div>\n<% end %>\n\n<%= javascript_tag nonce: true do %>\n  highlightQueries();\n<% end %>\n"
  },
  {
    "path": "app/views/pg_hero/home/index_bloat.html.erb",
    "content": "<div class=\"content\">\n  <h1>Index Bloat</h1>\n\n  <% if @index_bloat.any? %>\n\n    <p>Indexes can become <%= link_to \"bloated over time\", \"https://www.compose.com/articles/postgresql-bloat-origins-monitoring-and-managing/\", target: \"_blank\" %>. Recreate them to remove bloat.</p>\n\n    <p>For each index, run:</p>\n    <pre><code>CREATE INDEX CONCURRENTLY new_index ...;\nANALYZE table;\nDROP INDEX CONCURRENTLY index;\nANALYZE table;\nALTER INDEX new_index RENAME TO index;</code></pre>\n\n    <p>\n      <% if @show_sql %>\n        <%= link_to \"Hide SQL\", {} %>\n      <% else %>\n        <%= link_to \"Show SQL\", {sql: \"t\"} %>\n      <% end %>\n      for each index\n    </p>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Index</th>\n          <th class=\"width-15\">Bloat</th>\n          <th class=\"width-15\">Size</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @index_bloat.each do |index| %>\n          <tr>\n            <td>\n              <span class=\"break-all\"><%= index[:index] %></span>\n              <% if index[:primary] %>\n                <span class=\"primary-key\">PRIMARY</span>\n              <% end %>\n            </td>\n            <td><%= PgHero.pretty_size(index[:bloat_bytes]) %></td>\n            <td><%= PgHero.pretty_size(index[:index_bytes]) %></td>\n          </tr>\n          <% if @show_sql && !index[:primary] %>\n            <tr>\n              <td colspan=\"3\" class=\"query-row\">\n                <% new_index = \"new_#{index[:index]}\".first(63) %>\n                <pre><code><%= index[:definition].sub(\" INDEX \", \" INDEX CONCURRENTLY \\n    \").sub(index[:index], new_index) %>;\n\nANALYZE <%= pghero_pretty_ident(index[:table], schema: index[:schema]) %>;\n\nDROP INDEX CONCURRENTLY\n    <%= pghero_pretty_ident(index[:index]) %>;\n\nANALYZE <%= pghero_pretty_ident(index[:table], schema: index[:schema]) %>;\n\nALTER INDEX <%= pghero_pretty_ident(new_index) %>\n    RENAME TO <%= pghero_pretty_ident(index[:index]) %>;</code></pre>\n              </td>\n            </tr>\n          <% end %>\n        <% end %>\n      </tbody>\n    </table>\n  <% else %>\n    <p>No significant index bloat!</p>\n  <% end %>\n</div>\n\n<%= javascript_tag nonce: true do %>\n  highlightQueries();\n<% end %>\n"
  },
  {
    "path": "app/views/pg_hero/home/live_queries.html.erb",
    "content": "<div class=\"content\">\n  <h1>Live Queries</h1>\n\n  <p><%= pluralize(@running_queries.size, \"query\") %></p>\n\n  <%= render partial: \"live_queries_table\", locals: {queries: @running_queries, vacuum_progress: @vacuum_progress} %>\n\n  <p><%= button_to \"Kill all connections\", kill_all_path, class: \"btn btn-danger\" %></p>\n\n  <p class=\"text-muted\">You may need to restart your app servers afterwards.</p>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/maintenance.html.erb",
    "content": "<div class=\"content\">\n  <h1>Maintenance</h1>\n\n  <table class=\"table\">\n    <thead>\n      <tr>\n        <th>Table</th>\n        <th class=\"width-20\">Last Vacuum</th>\n        <th class=\"width-20\">Last Analyze</th>\n        <% if @show_dead_rows %>\n          <th class=\"width-20\">Dead Rows</th>\n        <% end %>\n      </tr>\n    </thead>\n    <tbody>\n      <% @maintenance_info.each do |table| %>\n        <tr>\n          <td>\n            <%= table[:table] %>\n            <% if table[:schema] != \"public\" %>\n              <span class=\"text-muted\"><%= table[:schema] %></span>\n            <% end %>\n          </td>\n          <td>\n            <% time = [table[:last_autovacuum], table[:last_vacuum]].compact.max %>\n            <% if time %>\n              <%= pghero_formatted_vacuum_times(time) %>\n            <% else %>\n              <span class=\"text-muted\">Unknown</span>\n            <% end %>\n          </td>\n          <td>\n            <% time = [table[:last_autoanalyze], table[:last_analyze]].compact.max %>\n            <% if time %>\n              <%= pghero_formatted_vacuum_times(time) %>\n            <% else %>\n              <span class=\"text-muted\">Unknown</span>\n            <% end %>\n          </td>\n          <% if @show_dead_rows %>\n            <td>\n              <% if table[:live_rows] != 0 %>\n                <%# use live rows only for denominator to make it easier to compare with autovacuum_vacuum_scale_factor %>\n                <%# it's not a true percentage, since it can go above 100% %>\n                <%= (100.0 * table[:dead_rows] / table[:live_rows]).round %>%\n              <% else %>\n                <span class=\"text-muted\">Unknown</span>\n              <% end %>\n            </td>\n          <% end %>\n        </tr>\n      <% end %>\n    </tbody>\n  </table>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/queries.html.erb",
    "content": "<div class=\"content\">\n  <% if @query_stats_enabled && !@historical_query_stats_enabled %>\n    <%= button_to \"Reset\", reset_query_stats_path, class: \"btn btn-danger\", style: \"float: right;\" %>\n  <% end %>\n\n  <% if !@historical_query_stats_enabled %>\n    <h1 class=\"push-left\">Queries</h1>\n  <% end %>\n\n  <% if @historical_query_stats_enabled %>\n    <%= render partial: \"query_stats_slider\" %>\n  <% elsif @database.query_stats_table_exists? && (columns = @database.missing_query_stats_columns).any? %>\n    <div class=\"clear-both\">\n      <p>Add missing columns to re-enable historical query stats.</p>\n      <pre><code><% @database.missing_query_stats_columns.each do |column| %>ALTER TABLE pghero_query_stats ADD COLUMN \"<%= column %>\" <%= column == \"query_hash\" ? \"bigint\" : \"text\" %>;\n<% end %></code></pre>\n      <p>Then restart the web server.</p>\n    </div>\n  <% end %>\n\n  <% if @query_stats_enabled %>\n    <% if @error %>\n      <div class=\"alert alert-danger\">Cannot understand start or end time.</div>\n    <% elsif @query_stats.any? || @historical_query_stats_enabled %>\n      <%= render partial: \"queries_table\", locals: {queries: @query_stats, sort_headers: true} %>\n      <%= javascript_tag nonce: true do %>\n        highlightQueries();\n      <% end %>\n    <% else %>\n      <p>Stats are not available yet. Come back soon!</p>\n    <% end %>\n  <% else %>\n    <p>Query stats are not enabled.</p>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/relation_space.html.erb",
    "content": "<div class=\"content\">\n  <h1>\n    <%= @relation %>\n    <% if @schema != \"public\" %>\n      <small><%= @schema %></small>\n    <% end %>\n  </h1>\n\n  <h1>Size</h1>\n  <div id=\"chart-1\" class=\"chart\">Loading...</div>\n  <%= javascript_tag nonce: true do %>\n    new Chartkick.LineChart(\"chart-1\", <%= pghero_js_value(@chart_data) %>, {colors: [\"#5bc0de\"], legend: false, min: null, bytes: true, library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/show_query.html.erb",
    "content": "<div class=\"content\">\n  <pre><code class=\"query-code\"><%= @query %></code></pre>\n  <%= javascript_tag nonce: true do %>\n    highlightQueries()\n  <% end %>\n\n  <% if @explain_enabled && @explainable_query %>\n    <p>\n      <%= button_to \"Explain\", explain_path, params: {query: @explainable_query}, form: {target: \"_blank\"}, class: \"btn btn-info\" %>\n    </p>\n  <% end %>\n\n  <% if @origins && @origins.keys.select { |k| k.length > 0 }.any? %>\n    <table class=\"origins-table\">\n      <thead>\n        <tr>\n          <th colspan=\"2\">\n            <div class=\"push-right\">Approx. Time</div>\n            Origin\n          </th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @origins.sort_by { |o, c| [-c, o.to_s] }.each do |origin, count| %>\n          <tr>\n            <td class=\"origin\">\n              <% if origin.length > 0 %>\n                <%= origin %>\n              <% else %>\n                <span class=\"text-muted\">Unknown</span>\n              <% end %>\n            </td>\n            <td class=\"origin-pct\">\n              <% pct = (100.0 * count / @total_count).round %>\n              <% if pct == 0 %>\n                &lt; 1%\n              <% else %>\n                <%= pct %>%\n              <% end %>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  <% end %>\n\n  <!-- chart -->\n  <% if @chart_data %>\n    <h1>Total Time <small>ms</small></h1>\n    <div id=\"chart-1\" class=\"chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.LineChart(\"chart-1\", <%= pghero_js_value(@chart_data) %>, {colors: [\"#5bc0de\"], legend: false, library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n    <% end %>\n\n    <h1>Average Time <small>ms</small></h1>\n    <div id=\"chart-2\" class=\"chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.LineChart(\"chart-2\", <%= pghero_js_value(@chart2_data) %>, {colors: [\"#5bc0de\"], legend: false, library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n    <% end %>\n\n    <h1>Calls</h1>\n    <div id=\"chart-3\" class=\"chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.LineChart(\"chart-3\", <%= pghero_js_value(@chart3_data) %>, {colors: [\"#5bc0de\"], legend: false, library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n    <% end %>\n  <% else %>\n    <p>\n      Enable\n      <%= link_to \"historical query stats\", \"https://github.com/ankane/pghero\", target: \"_blank\" %>\n      to see more details\n    </p>\n  <% end %>\n\n  <!-- table info -->\n  <% if @tables.any? %>\n    <h1>Tables</h1>\n    <table>\n      <thead>\n        <tr>\n          <th class=\"width-25\">Name</th>\n          <th class=\"width-25\">Rows</th>\n          <th>Indexes</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @tables.each do |table| %>\n          <tr>\n            <td><%= table %></td>\n            <td><%= number_with_delimiter(@row_counts[table]) if @row_counts[table] %></td>\n            <td>\n              <% if @indexes_timeout %>\n                Not available\n              <% else %>\n                <ul>\n                  <% @indexes_by_table[table].to_a.sort_by { |i| [i[:primary] ? 0 : 1, i[:columns]] }.each do |i3| %>\n                    <li>\n                      <%= i3[:columns].join(\", \") %><% if i3[:using] != \"btree\" %>\n                      <%= i3[:using].to_s.upcase %><% end %>\n                      <% if i3[:primary] %> PRIMARY<% elsif i3[:unique] %> UNIQUE<% end %>\n                    </li>\n                  <% end %>\n                </ul>\n              <% end %>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/space.html.erb",
    "content": "<div class=\"content\">\n  <h1>Space</h1>\n\n  <p>Database Size: <%= @database_size %></p>\n\n  <% if @system_stats_enabled %>\n    <div id=\"chart-1\" class=\"chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.LineChart(\"chart-1\", <%= pghero_js_value(free_space_stats_path) %>, {colors: [\"#5bc0de\"], bytes: true, library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n    <% end %>\n  <% end %>\n\n  <!--\n  <% if @index_bloat.any? %>\n    <p>Check out <%= link_to \"index bloat\", index_bloat_path %> for an easy way to reclaim space.</p>\n  <% end %>\n  -->\n\n  <% if @unused_indexes.any? %>\n    <p>\n      <%= pluralize(@unused_indexes.size, \"unused index\") %>. Remove them\n      <% if @show_migrations %>\n        <a href=\"#\" class=\"migration-link\">with a migration</a>\n      <% end %>\n      for faster writes.\n\n      <% if @database.replicating? %>\n        Check they aren’t used on replicas.\n      <% end %>\n    </p>\n\n    <div class=\"migration\">\n      <pre>rails generate migration remove_unused_indexes</pre>\n      <p>And paste</p>\n      <pre><% @unused_indexes.sort_by { |q| [-q[:size_bytes], q[:index]] }.each do |query| %>\n<%= pghero_remove_index(query) %><% end %></pre>\n    </div>\n  <% end %>\n\n  <% if @sizes_timeout %>\n    <p>Breakdown not available (system catalog locked)</p>\n  <% else %>\n    <table class=\"table space-table\">\n      <thead>\n        <tr>\n          <th><%= link_to (@only_tables ? \"Table\" : \"Relation\"), @header_options.merge(sort: \"name\") %></th>\n          <th class=\"width-15\"><%= link_to \"Size\", @header_options %></th>\n          <% if @space_stats_enabled %>\n            <th class=\"width-15\"><%= link_to \"#{@days}d Growth\", @header_options.merge(sort: \"growth\") %></th>\n          <% end %>\n        </tr>\n      </thead>\n      <tbody>\n        <% @relation_sizes.each do |query| %>\n          <tr>\n            <td class=\"<%= query[:type] == \"index\" ? \"space-index\" : \"\" %>\">\n              <span class=\"break-all\">\n                <% name = query[:relation] || query[:table] %>\n                <% if @space_stats_enabled %>\n                  <%= link_to name, relation_space_path(name, schema: query[:schema]), target: \"_blank\", class: \"relation-link\" %>\n                <% else %>\n                  <%= name %>\n                <% end %>\n              </span>\n              <% if query[:schema] != \"public\" %>\n                <span class=\"text-muted\"><%= query[:schema] %></span>\n              <% end %>\n              <% if @unused_index_names.include?(query[:relation]) %>\n                <span class=\"unused-index\">UNUSED</span>\n              <% end %>\n            </td>\n            <td><%= query[:size] %></td>\n            <% if @space_stats_enabled %>\n              <td>\n                <% if @growth_bytes_by_relation[[query[:schema], query[:relation]]] %>\n                  <% if @growth_bytes_by_relation[[query[:schema], query[:relation]]] < 0 %>-<% end %><%= PgHero.pretty_size(@growth_bytes_by_relation[[query[:schema], query[:relation]]].abs) %>\n                <% else %>\n                  <span class=\"text-muted\">Unknown</span>\n                <% end %>\n              </td>\n            <% end %>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/system.html.erb",
    "content": "<div class=\"content\">\n  <p id=\"periods\">\n    <% @periods.each do |name, options| %>\n      <%= link_to name, system_path(params: options) %>\n    <% end %>\n  </p>\n  <% path_options = {params: {duration: @duration, period: @period}} %>\n\n  <h1>CPU</h1>\n  <div id=\"chart-1\" class=\"chart\">Loading...</div>\n  <%= javascript_tag nonce: true do %>\n    new Chartkick.LineChart(\"chart-1\", <%= pghero_js_value(cpu_usage_path(path_options)) %>, {max: 100, colors: [\"#5bc0de\"], suffix: \"%\", library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n  <% end %>\n\n  <h1>Load</h1>\n  <div id=\"chart-2\" class=\"chart\">Loading...</div>\n  <%= javascript_tag nonce: true do %>\n    new Chartkick.LineChart(\"chart-2\", <%= pghero_js_value(load_stats_path(path_options)) %>, {colors: [\"#5bc0de\", \"#d9534f\"], library: {plugins: {tooltip: {intersect: false, mode: \"nearest\"}}}})\n  <% end %>\n\n  <h1>Connections</h1>\n  <div id=\"chart-3\" class=\"chart\">Loading...</div>\n  <%= javascript_tag nonce: true do %>\n    new Chartkick.LineChart(\"chart-3\", <%= pghero_js_value(connection_stats_path(path_options)) %>, {colors: [\"#5bc0de\"], library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n  <% end %>\n\n  <% if @database.replica? %>\n    <h1>Replication Lag</h1>\n    <div id=\"chart-4\" class=\"chart\">Loading...</div>\n    <%= javascript_tag nonce: true do %>\n      new Chartkick.LineChart(\"chart-4\", <%= pghero_js_value(replication_lag_stats_path(path_options)) %>, {colors: [\"#5bc0de\"], library: {plugins: {tooltip: {intersect: false, mode: \"index\"}}}})\n    <% end %>\n  <% end %>\n</div>\n"
  },
  {
    "path": "app/views/pg_hero/home/tune.html.erb",
    "content": "<div class=\"content\">\n  <h1>Tune</h1>\n\n  <table class=\"table\">\n    <thead>\n      <tr>\n        <th>Setting</th>\n        <th class=\"width-20\">Value</th>\n      </tr>\n    </thead>\n    <tbody>\n      <% @settings.each do |setting, value| %>\n        <tr>\n          <td><%= setting %></td>\n          <td><%= value %></td>\n        </tr>\n      <% end %>\n    </tbody>\n  </table>\n\n  <% version_parts = @database.server_version.split(\" \").first.split(\".\") %>\n  <p>Check out <%= link_to \"PgTune\", \"https://pgtune.leopard.in.ua/\", target: \"_blank\" %> for recommendations. DB version is <%= version_parts[0].to_i >= 10 ? version_parts[0] : version_parts.first(2).join(\".\") %>.</p>\n</div>\n\n<% if @autovacuum_settings %>\n  <div class=\"content\">\n    <h1>Autovacuum</h1>\n\n    <table class=\"table\">\n      <thead>\n        <tr>\n          <th>Setting</th>\n          <th class=\"width-20\">Value</th>\n        </tr>\n      </thead>\n      <tbody>\n        <% @autovacuum_settings.each do |setting, value| %>\n          <tr>\n            <td><%= setting %></td>\n            <td>\n              <%= value %>\n              <% if setting == :autovacuum_vacuum_cost_limit && value == \"-1\" %>\n                <span class=\"text-muted\"><%= @database.vacuum_settings[:vacuum_cost_limit] %></span>\n              <% end %>\n            </td>\n          </tr>\n        <% end %>\n      </tbody>\n    </table>\n\n    <p>Check out <%= link_to \"Autovacuum Tuning Basics\", \"https://blog.2ndquadrant.com/autovacuum-tuning-basics/\", target: \"_blank\" %> for recommendations.</p>\n  </div>\n<% end %>\n"
  },
  {
    "path": "config/routes.rb",
    "content": "PgHero::Engine.routes.draw do\n  scope \"(:database)\", constraints: proc { |req| (PgHero.config[\"databases\"].keys + [nil]).include?(req.params[:database]) } do\n    get \"space\", to: \"home#space\"\n    get \"space/:relation\", to: \"home#relation_space\", as: :relation_space\n    get \"index_bloat\", to: \"home#index_bloat\"\n    get \"live_queries\", to: \"home#live_queries\"\n    get \"queries\", to: \"home#queries\"\n    get \"queries/:query_hash\", to: \"home#show_query\", as: :show_query\n    get \"system\", to: \"home#system\"\n    get \"cpu_usage\", to: \"home#cpu_usage\"\n    get \"connection_stats\", to: \"home#connection_stats\"\n    get \"replication_lag_stats\", to: \"home#replication_lag_stats\"\n    get \"load_stats\", to: \"home#load_stats\"\n    get \"free_space_stats\", to: \"home#free_space_stats\"\n    get \"explain\", to: \"home#explain\"\n    get \"tune\", to: \"home#tune\"\n    get \"connections\", to: \"home#connections\"\n    get \"maintenance\", to: \"home#maintenance\"\n    post \"kill\", to: \"home#kill\"\n    post \"kill_long_running_queries\", to: \"home#kill_long_running_queries\"\n    post \"kill_all\", to: \"home#kill_all\"\n    post \"enable_query_stats\", to: \"home#enable_query_stats\"\n    post \"explain\", to: \"home#explain\"\n    post \"reset_query_stats\", to: \"home#reset_query_stats\"\n\n    # legacy routes\n    get \"system_stats\" => redirect(\"system\")\n    get \"query_stats\" => redirect(\"queries\")\n\n    root to: \"home#index\"\n  end\nend\n"
  },
  {
    "path": "gemfiles/activerecord71.gemfile",
    "content": "source \"https://rubygems.org\"\n\ngemspec path: \"..\"\n\ngem \"rake\"\ngem \"minitest\"\ngem \"activerecord\", \"~> 7.1.0\"\ngem \"combustion\"\ngem \"pg\"\ngem \"pg_query\", \"~> 2\"\ngem \"google-protobuf\", \"< 4\"\n"
  },
  {
    "path": "gemfiles/activerecord72.gemfile",
    "content": "source \"https://rubygems.org\"\n\ngemspec path: \"..\"\n\ngem \"rake\"\ngem \"minitest\"\ngem \"activerecord\", \"~> 7.2.0\"\ngem \"combustion\"\ngem \"pg\"\ngem \"pg_query\", \"~> 4\"\ngem \"google-protobuf\", \"< 4\"\n"
  },
  {
    "path": "gemfiles/activerecord80.gemfile",
    "content": "source \"https://rubygems.org\"\n\ngemspec path: \"..\"\n\ngem \"rake\"\ngem \"minitest\"\ngem \"activerecord\", \"~> 8.0.0\"\ngem \"combustion\"\ngem \"pg\"\ngem \"pg_query\"\n"
  },
  {
    "path": "guides/Contributing.md",
    "content": "# Contributing\n\n```sh\ngit clone https://github.com/ankane/pghero.git\ngit clone https://github.com/pghero/pghero.git pghero-dev\ncd pghero-dev\ngit checkout dev\ncreatedb pghero_dev\nexport DATABASE_URL=postgres:///pghero_dev\nbundle exec rails generate pghero:query_stats\nbundle exec rails generate pghero:space_stats\nbundle exec rails db:migrate\nforeman start\n```\n\nAnd visit [http://localhost:5000](http://localhost:5000)\n"
  },
  {
    "path": "guides/Docker.md",
    "content": "# PgHero Docker\n\n## Installation\n\nPgHero is available on [Docker Hub](https://hub.docker.com/r/ankane/pghero/).\n\n```sh\ndocker pull ankane/pghero\n```\n\nStart the dashboard:\n\n```sh\ndocker run -ti -e DATABASE_URL=postgres://user:password@hostname:5432/dbname -p 8080:8080 ankane/pghero\n```\n\nUse URL-encoding for any special characters in the username or password. For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires `--add-host=host.docker.internal:host-gateway`).\n\nThen visit [http://localhost:8080](http://localhost:8080).\n\n## Authentication\n\nAdd basic authentication with:\n\n```sh\ndocker run -e PGHERO_USERNAME=link -e PGHERO_PASSWORD=hyrule ...\n```\n\nOr use a reverse proxy like [OAuth2 Proxy](https://github.com/oauth2-proxy/oauth2-proxy), Amazon’s [ALB Authentication](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html), or Google’s [Identity-Aware Proxy](https://cloud.google.com/iap/).\n\n## Query Stats\n\nQuery stats can be enabled from the dashboard. If you run into issues, [view the guide](Query-Stats.md).\n\n## Historical Query Stats\n\nTo track query stats over time, create a table to store them.\n\n```sql\nCREATE TABLE \"pghero_query_stats\" (\n  \"id\" bigserial primary key,\n  \"database\" text,\n  \"user\" text,\n  \"query\" text,\n  \"query_hash\" bigint,\n  \"total_time\" float,\n  \"calls\" bigint,\n  \"captured_at\" timestamp\n);\nCREATE INDEX ON \"pghero_query_stats\" (\"database\", \"captured_at\");\n```\n\nThis table can be in the current database or another database. If another database, pass the `PGHERO_STATS_DATABASE_URL` environment variable with commands.\n\nSchedule the task below to run every 5 minutes.\n\n```sh\ndocker run -ti -e DATABASE_URL=... ankane/pghero bin/rake pghero:capture_query_stats\n```\n\nAfter this, a time range slider will appear on the Queries tab.\n\nThe query stats table can grow large over time. Remove old stats with:\n\n```sh\ndocker run -ti -e DATABASE_URL=... ankane/pghero bin/rake pghero:clean_query_stats KEEP_DAYS=14\n```\n\n## Historical Space Stats\n\nTo track space stats over time, create a table to store them.\n\n```sql\nCREATE TABLE \"pghero_space_stats\" (\n  \"id\" bigserial primary key,\n  \"database\" text,\n  \"schema\" text,\n  \"relation\" text,\n  \"size\" bigint,\n  \"captured_at\" timestamp\n);\nCREATE INDEX ON \"pghero_space_stats\" (\"database\", \"captured_at\");\n```\n\nSchedule the task below to run once a day.\n\n```sh\ndocker run -ti -e DATABASE_URL=... ankane/pghero bin/rake pghero:capture_space_stats\n```\n\nRemove old stats with:\n\n```sh\ndocker run -ti -e DATABASE_URL=... ankane/pghero bin/rake pghero:clean_space_stats KEEP_DAYS=90\n```\n\n## System Stats\n\nCPU usage, IOPS, and other stats are available for:\n\n- [Amazon RDS](#amazon-rds)\n- [Google Cloud SQL](#google-cloud-sql)\n- [Azure Database](#azure-database)\n\nHeroku and Digital Ocean do not currently have an API for database metrics.\n\n### Amazon RDS\n\nSet these variables:\n\n```sh\nAWS_ACCESS_KEY_ID=my-access-key\nAWS_SECRET_ACCESS_KEY=my-secret\nAWS_REGION=us-east-1\nPGHERO_DB_INSTANCE_IDENTIFIER=my-instance\n```\n\nThis requires the following IAM policy:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"cloudwatch:GetMetricStatistics\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n### Google Cloud SQL\n\nSet these variables:\n\n```sh\nGOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json\nPGHERO_GCP_DATABASE_ID=my-project:my-instance\n```\n\nThis requires the Monitoring Viewer role.\n\n### Azure Database\n\n[Get your credentials](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) and add these variables to your environment:\n\n```sh\nAZURE_TENANT_ID=...\nAZURE_CLIENT_ID=...\nAZURE_CLIENT_SECRET=...\nAZURE_SUBSCRIPTION_ID=...\n```\n\nFinally, set your database resource URI:\n\n```sh\nPGHERO_AZURE_RESOURCE_ID=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.DBforPostgreSQL/servers/<database-id>\n```\n\nThis requires the Monitoring Reader role.\n\n## Customization & Multiple Databases\n\nCreate a `pghero.yml` file with:\n\n```yml\ndatabases:\n  main:\n    url: <%= ENV[\"DATABASE_URL\"] %>\n\n    # System stats\n    # aws_db_instance_identifier: my-instance\n    # gcp_database_id: my-project:my-instance\n    # azure_resource_id: my-resource-id\n\n  # Add more databases\n  # other:\n  #   url: <%= ENV[\"OTHER_DATABASE_URL\"] %>\n\n# Minimum time for long running queries\n# long_running_query_sec: 60\n\n# Minimum average time for slow queries\n# slow_query_ms: 20\n\n# Minimum calls for slow queries\n# slow_query_calls: 100\n\n# Minimum connections for high connections warning\n# total_connections_threshold: 500\n\n# Explain functionality\n# explain: true / false / analyze\n\n# Statement timeout for explain\n# explain_timeout_sec: 10\n\n# Visualize URL for explain\n# visualize_url: https://...\n\n# Time zone\n# time_zone: \"Pacific Time (US & Canada)\"\n```\n\nCreate a `Dockerfile` with:\n\n```Dockerfile\nFROM ankane/pghero\n\nCOPY pghero.yml /app/config/pghero.yml\n```\n\nAnd build your image:\n\n```sh\ndocker build -t my-pghero .\n```\n\nWith Postgres < 12, if multiple databases are in the same instance and use historical query stats, PgHero should be configured to capture them together.\n\n```yml\ndatabases:\n  primary:\n    url: ...\n  other:\n    url: ...\n    capture_query_stats: primary\n```\n\n## Deployment\n\n### Health Checks\n\nUse the `/health` endpoint for health checks. Status code `200` indicates healthy.\n\n### Kubernetes\n\nIf you are planning to run on Kubernetes with a config file, you don’t need to create a new image. You can make use of ConfigMaps to mount the config file. Create a ConfigMap like this:\n\n```yaml\n---\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: pghero\ndata:\n  pghero.yml: |-\n    databases:\n      main:\n        url: <%= ENV[\"DATABASE_URL\"] %>\n\n      # Add more databases\n      # other:\n      #   url: <%= ENV[\"OTHER_DATABASE_URL\"] %>\n\n    # Minimum time for long running queries\n    # long_running_query_sec: 60\n\n    # Minimum average time for slow queries\n    # slow_query_ms: 20\n\n    # Minimum calls for slow queries\n    # slow_query_calls: 100\n\n    # Minimum connections for high connections warning\n    # total_connections_threshold: 500\n\n    # Explain functionality\n    # explain: true / false / analyze\n\n    # Statement timeout for explain\n    # explain_timeout_sec: 10\n\n    # Visualize URL for explain\n    # visualize_url: https://...\n\n    # Time zone\n    # time_zone: \"Pacific Time (US & Canada)\"\n```\n\nThen launch the pod with the following config:\n\n```yaml\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: pghero\n  labels:\n    app: pghero\nspec:\n  selector:\n    matchLabels:\n      app: pghero\n  replicas: 1\n  template:\n    metadata:\n      labels:\n        app: pghero\n    spec:\n      containers:\n      - name: pghero\n        image: ankane/pghero\n        imagePullPolicy: Always\n        volumeMounts:\n        - name: pghero-configmap\n          mountPath: /app/config/pghero.yml\n          readOnly: true\n          subPath: pghero.yml\n      volumes:\n      - name: pghero-configmap\n        configMap:\n          defaultMode: 0644\n          name: pghero\n```\n\n## Permissions\n\nWe recommend [setting up a dedicated user](Permissions.md) for PgHero.\n\n## Credits\n\nThanks to [Brian Morton](https://github.com/bmorton) for the [original Docker image](https://github.com/bmorton/pghero_solo).\n"
  },
  {
    "path": "guides/Linux.md",
    "content": "# PgHero Linux\n\n## Installation\n\n- [Ubuntu](#ubuntu)\n- [Debian](#debian)\n\n### Ubuntu\n\n```sh\nwget -qO- https://dl.packager.io/srv/pghero/pghero/key | sudo apt-key add -\nsudo wget -O /etc/apt/sources.list.d/pghero.list \\\n  https://dl.packager.io/srv/pghero/pghero/master/installer/ubuntu/$(. /etc/os-release && echo $VERSION_ID).repo\nsudo apt-get update\nsudo apt-get -y install pghero\n```\n\nSupports Ubuntu 22.04 (Jammy) and 24.04 (Noble)\n\n### Debian\n\n```sh\nsudo apt-get -y install apt-transport-https\nwget -qO- https://dl.packager.io/srv/pghero/pghero/key | sudo apt-key add -\nsudo wget -O /etc/apt/sources.list.d/pghero.list \\\n  https://dl.packager.io/srv/pghero/pghero/master/installer/debian/$(. /etc/os-release && echo $VERSION_ID).repo\nsudo apt-get update\nsudo apt-get -y install pghero\n```\n\nSupports Debian 11 (Bullseye) and 12 (Bookworm)\n\n## Setup\n\nAdd your database. Use URL-encoding for any special characters in the username or password.\n\n```sh\nsudo pghero config:set DATABASE_URL=postgres://user:password@hostname:5432/dbname\n```\n\nStart the server\n\n```sh\nsudo pghero config:set PORT=3001\nsudo pghero config:set RAILS_LOG_TO_STDOUT=disabled\nsudo pghero scale web=1\n```\n\nConfirm it’s running with:\n\n```sh\ncurl -v http://localhost:3001/\n```\n\nTo open to the outside world, add a proxy. Here’s how to do it with Nginx on Ubuntu.\n\n```sh\nsudo apt-get install -y nginx\ncat | sudo tee /etc/nginx/sites-available/default <<EOF\nserver {\n  listen          80;\n  server_name     \"\";\n  location / {\n    proxy_pass    http://localhost:3001;\n  }\n}\nEOF\nsudo service nginx restart\n```\n\nTo run under a subpath, also set:\n\n```sh\nsudo pghero config:set RAILS_RELATIVE_URL_ROOT=my-path\n```\n\n## Authentication\n\nAdd basic authentication with:\n\n```sh\nsudo pghero config:set PGHERO_USERNAME=link\nsudo pghero config:set PGHERO_PASSWORD=hyrule\n```\n\nOr use a reverse proxy like [OAuth2 Proxy](https://github.com/oauth2-proxy/oauth2-proxy), Amazon’s [ALB Authentication](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html), or Google’s [Identity-Aware Proxy](https://cloud.google.com/iap/).\n\n## Management\n\n```sh\nsudo service pghero status\nsudo service pghero start\nsudo service pghero stop\nsudo service pghero restart\n```\n\nView logs\n\n```sh\nsudo pghero logs\n```\n\n## Query Stats\n\nQuery stats can be enabled from the dashboard. If you run into issues, [view the guide](Query-Stats.md).\n\n## Historical Query Stats\n\nTo track query stats over time, create a table to store them.\n\n```sql\nCREATE TABLE \"pghero_query_stats\" (\n  \"id\" bigserial primary key,\n  \"database\" text,\n  \"user\" text,\n  \"query\" text,\n  \"query_hash\" bigint,\n  \"total_time\" float,\n  \"calls\" bigint,\n  \"captured_at\" timestamp\n);\nCREATE INDEX ON \"pghero_query_stats\" (\"database\", \"captured_at\");\n```\n\nThis table can be in the current database or another database. If another database, run:\n\n```sh\nsudo pghero config:set PGHERO_STATS_DATABASE_URL=...\n```\n\nSchedule the task below to run every 5 minutes.\n\n```sh\nsudo pghero run rake pghero:capture_query_stats\n```\n\nAfter this, a time range slider will appear on the Queries tab.\n\nThe query stats table can grow large over time. Remove old stats with:\n\n```sh\nsudo pghero run rake pghero:clean_query_stats KEEP_DAYS=14\n```\n\n## Historical Space Stats\n\nTo track space stats over time, create a table to store them.\n\n```sql\nCREATE TABLE \"pghero_space_stats\" (\n  \"id\" bigserial primary key,\n  \"database\" text,\n  \"schema\" text,\n  \"relation\" text,\n  \"size\" bigint,\n  \"captured_at\" timestamp\n);\nCREATE INDEX ON \"pghero_space_stats\" (\"database\", \"captured_at\");\n```\n\nSchedule the task below to run once a day.\n\n```sh\nsudo pghero run rake pghero:capture_space_stats\n```\n\nRemove old stats with:\n\n```sh\nsudo pghero run rake pghero:clean_space_stats KEEP_DAYS=90\n```\n\n## System Stats\n\nCPU usage, IOPS, and other stats are available for:\n\n- [Amazon RDS](#amazon-rds)\n- [Google Cloud SQL](#google-cloud-sql)\n- [Azure Database](#azure-database)\n\nHeroku and Digital Ocean do not currently have an API for database metrics.\n\n### Amazon RDS\n\nAdd these variables to your environment:\n\n```sh\nsudo pghero config:set AWS_ACCESS_KEY_ID=my-access-key\nsudo pghero config:set AWS_SECRET_ACCESS_KEY=my-secret\nsudo pghero config:set AWS_REGION=us-east-1\nsudo pghero config:set PGHERO_DB_INSTANCE_IDENTIFIER=my-instance\n```\n\nThis requires the following IAM policy:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"cloudwatch:GetMetricStatistics\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n### Google Cloud SQL\n\nAdd these variables to your environment:\n\n```sh\nsudo pghero config:set GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json\nsudo pghero config:set PGHERO_GCP_DATABASE_ID=my-project:my-instance\n```\n\nThis requires the Monitoring Viewer role.\n\n### Azure Database\n\n[Get your credentials](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) and add these variables to your environment:\n\n```sh\nAZURE_TENANT_ID=...\nAZURE_CLIENT_ID=...\nAZURE_CLIENT_SECRET=...\nAZURE_SUBSCRIPTION_ID=...\n```\n\nFinally, set your database resource URI:\n\n```sh\nPGHERO_AZURE_RESOURCE_ID=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.DBforPostgreSQL/servers/<database-id>\n```\n\nThis requires the Monitoring Reader role.\n\n## Multiple Databases\n\nCreate a `pghero.yml` with:\n\n```yml\ndatabases:\n  primary:\n    url: postgres://...\n  replica:\n    url: postgres://...\n```\n\nMore information about [connection parameters](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS)\n\nAnd run:\n\n```sh\ncat pghero.yml | sudo pghero run sh -c \"cat > config/pghero.yml\"\nsudo service pghero restart\n```\n\nWith Postgres < 12, if multiple databases are in the same instance and use historical query stats, PgHero should be configured to capture them together.\n\n```yml\ndatabases:\n  primary:\n    url: ...\n  other:\n    url: ...\n    capture_query_stats: primary\n```\n\n## Permissions\n\nWe recommend [setting up a dedicated user](Permissions.md) for PgHero.\n\n## Customize\n\nMinimum time for long running queries\n\n```sh\nsudo pghero config:set PGHERO_LONG_RUNNING_QUERY_SEC=60 # default\n```\n\nMinimum average time for slow queries\n\n```sh\nsudo pghero config:set PGHERO_SLOW_QUERY_MS=20 # default\n```\n\nMinimum calls for slow queries\n\n```sh\nsudo pghero config:set PGHERO_SLOW_QUERY_CALLS=100 # default\n```\n\nMinimum connections for high connections warning\n\n```sh\nsudo pghero config:set PGHERO_TOTAL_CONNECTIONS_THRESHOLD=500 # default\n```\n\nStatement timeout for explain\n\n```sh\nsudo pghero config:set PGHERO_EXPLAIN_TIMEOUT_SEC=10 # default\n```\n\nVisualize URL for explain\n\n```sh\nsudo pghero config:set PGHERO_VISUALIZE_URL=https://...\n```\n\n## Upgrading\n\nUbuntu and Debian\n\n```sh\nsudo apt-get update\nsudo apt-get install --only-upgrade pghero\nsudo service pghero restart\n```\n\nCentOS and RHEL\n\n```sh\nsudo yum update\nsudo yum install pghero\nsudo service pghero restart\n```\n\nSUSE\n\n```sh\nsudo zypper update pghero\nsudo service pghero restart\n```\n\n## Credits\n\n:heart: Made possible by [Packager](https://packager.io/)\n"
  },
  {
    "path": "guides/Permissions.md",
    "content": "# Permissions\n\nFor security, Postgres doesn’t allow you to see queries from other users without being a superuser. However, you likely don’t want to run PgHero as a superuser. You can use `SECURITY DEFINER` to give non-superusers access to superuser functions.\n\nWith a superuser, run:\n\n```sql\nCREATE SCHEMA pghero;\n\n-- view queries\nCREATE OR REPLACE FUNCTION pghero.pg_stat_activity() RETURNS SETOF pg_stat_activity AS\n$$\n  SELECT * FROM pg_catalog.pg_stat_activity;\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\nCREATE VIEW pghero.pg_stat_activity AS SELECT * FROM pghero.pg_stat_activity();\n\n-- kill queries\nCREATE OR REPLACE FUNCTION pghero.pg_terminate_backend(pid int) RETURNS boolean AS\n$$\n  SELECT * FROM pg_catalog.pg_terminate_backend(pid);\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\n-- query stats\nCREATE OR REPLACE FUNCTION pghero.pg_stat_statements() RETURNS SETOF pg_stat_statements AS\n$$\n  SELECT * FROM public.pg_stat_statements;\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\nCREATE VIEW pghero.pg_stat_statements AS SELECT * FROM pghero.pg_stat_statements();\n\n-- query stats reset\nCREATE OR REPLACE FUNCTION pghero.pg_stat_statements_reset() RETURNS void AS\n$$\n  SELECT public.pg_stat_statements_reset();\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\n-- improved query stats reset for Postgres 12+ - delete for earlier versions\nCREATE OR REPLACE FUNCTION pghero.pg_stat_statements_reset(userid oid, dbid oid, queryid bigint) RETURNS void AS\n$$\n  SELECT public.pg_stat_statements_reset(userid, dbid, queryid);\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\n-- suggested indexes\nCREATE OR REPLACE FUNCTION pghero.pg_stats() RETURNS\nTABLE(schemaname name, tablename name, attname name, null_frac real, avg_width integer, n_distinct real) AS\n$$\n  SELECT schemaname, tablename, attname, null_frac, avg_width, n_distinct FROM pg_catalog.pg_stats;\n$$ LANGUAGE sql VOLATILE SECURITY DEFINER;\n\nCREATE VIEW pghero.pg_stats AS SELECT * FROM pghero.pg_stats();\n\n-- create user\nCREATE ROLE pghero WITH LOGIN ENCRYPTED PASSWORD 'secret';\nGRANT CONNECT ON DATABASE <dbname> TO pghero;\nALTER ROLE pghero SET search_path = pghero, pg_catalog, public;\nALTER ROLE pghero SET lock_timeout = '1s';\nGRANT USAGE ON SCHEMA pghero TO pghero;\nGRANT SELECT ON ALL TABLES IN SCHEMA pghero TO pghero;\n\n-- grant permissions for current sequences\nGRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO pghero;\n\n-- grant permissions for future sequences\nALTER DEFAULT PRIVILEGES FOR ROLE <migrations-user> IN SCHEMA public GRANT SELECT ON SEQUENCES TO pghero;\n```\n\n## Thanks\n\nA big thanks to [pganalyze](https://github.com/pganalyze/collector#setting-up-a-restricted-monitoring-user) for coming up with this approach for their collector.\n"
  },
  {
    "path": "guides/Query-Stats.md",
    "content": "# Query Stats\n\nThe [pg_stat_statements module](https://www.postgresql.org/docs/current/static/pgstatstatements.html) is used for query stats.\n\n## Installation\n\nIf you have trouble enabling query stats from the dashboard, try doing it manually.\n\nAdd the following to your `postgresql.conf`:\n\n```conf\nshared_preload_libraries = 'pg_stat_statements'\npg_stat_statements.track = all\npg_stat_statements.max = 10000\ntrack_activity_query_size = 2048\n```\n\nThen restart PostgreSQL. As a superuser from the `psql` console, run:\n\n```psql\nCREATE EXTENSION pg_stat_statements;\n```\n\n#### Amazon RDS\n\nChange `shared_preload_libraries` to `pg_stat_statements` in your [Parameter Group](https://console.aws.amazon.com/rds/home?region=us-east-1#parameter-groups:) and restart the database instance.\n\nAs a superuser from the `psql` console, run:\n\n```psql\nCREATE EXTENSION pg_stat_statements;\n```\n\n## Common Issues\n\n#### pg_stat_statements must be loaded via shared_preload_libraries\n\nFollow the instructions above.\n\n#### The database user does not have permission to ...\n\nThe database user is not a superuser.  You can manually enable stats from the `psql` console with:\n\n```psql\nCREATE EXTENSION pg_stat_statements;\n```\n\nand reset stats with:\n\n```psql\nSELECT pg_stat_statements_reset();\n```\n\n#### Queries show up as `<insufficient privilege>`\n\nFor security reasons, only superusers can see queries executed by other users.\n\n#### ERROR: column \"total_plan_time\" / \"queryid\" does not exist\n\nUpdate the `pg_stat_statements` extension with:\n\n```sql\nALTER EXTENSION pg_stat_statements UPDATE;\n```\n"
  },
  {
    "path": "guides/Rails.md",
    "content": "# PgHero Rails\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"pghero\"\n```\n\nAnd mount the dashboard in your `config/routes.rb`:\n\n```ruby\nmount PgHero::Engine, at: \"pghero\"\n```\n\nBe sure to [secure the dashboard](#authentication) in production.\n\n### Suggested Indexes\n\nPgHero can suggest indexes to add. To enable, add to your Gemfile:\n\n```ruby\ngem \"pg_query\", \">= 2\"\n```\n\nand make sure [query stats](#query-stats) are enabled. Read about how it works [here](Suggested-Indexes.md).\n\n## Authentication\n\nFor basic authentication, set the following variables in your environment or an initializer.\n\n```ruby\nENV[\"PGHERO_USERNAME\"] = \"link\"\nENV[\"PGHERO_PASSWORD\"] = \"hyrule\"\n```\n\nFor Devise, use:\n\n```ruby\nauthenticate :user, -> (user) { user.admin? } do\n  mount PgHero::Engine, at: \"pghero\"\nend\n```\n\n## Query Stats\n\nQuery stats can be enabled from the dashboard. If you run into issues, [view the guide](Query-Stats.md).\n\n## Historical Query Stats\n\nTo track query stats over time, run:\n\n```sh\nrails generate pghero:query_stats\nrails db:migrate\n```\n\nAnd schedule the task below to run every 5 minutes.\n\n```sh\nrake pghero:capture_query_stats\n```\n\nOr with a scheduler like Clockwork, use:\n\n```ruby\nPgHero.capture_query_stats\n```\n\nAfter this, a time range slider will appear on the Queries tab.\n\nThe query stats table can grow large over time. Remove old stats with:\n\n```sh\nrake pghero:clean_query_stats KEEP_DAYS=14\n```\n\nor:\n\n```rb\nPgHero.clean_query_stats(before: 14.days.ago)\n```\n\nBy default, query stats are stored in your app’s database. Change this with:\n\n```ruby\nENV[\"PGHERO_STATS_DATABASE_URL\"]\n```\n\n## Historical Space Stats\n\nTo track space stats over time, run:\n\n```sh\nrails generate pghero:space_stats\nrails db:migrate\n```\n\nAnd schedule the task below to run once a day.\n\n```sh\nrake pghero:capture_space_stats\n```\n\nOr with a scheduler like Clockwork, use:\n\n```ruby\nPgHero.capture_space_stats\n```\n\nRemove old stats with:\n\n```sh\nrake pghero:clean_space_stats KEEP_DAYS=90\n```\n\nor:\n\n```rb\nPgHero.clean_space_stats(before: 90.days.ago)\n```\n\n## System Stats\n\nCPU usage, IOPS, and other stats are available for:\n\n- [Amazon RDS](#amazon-rds)\n- [Google Cloud SQL](#google-cloud-sql)\n- [Azure Database](#azure-database)\n\nHeroku and Digital Ocean do not currently have an API for database metrics.\n\n### Amazon RDS\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"aws-sdk-cloudwatch\"\n```\n\nBy default, your application’s AWS credentials are used. To use separate credentials, add these variables to your environment:\n\n```sh\nPGHERO_ACCESS_KEY_ID=my-access-key\nPGHERO_SECRET_ACCESS_KEY=my-secret\nPGHERO_REGION=us-east-1\n```\n\nFinally, specify your DB instance identifier.\n\n```sh\nPGHERO_DB_INSTANCE_IDENTIFIER=my-instance\n```\n\nThis requires the following IAM policy:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"cloudwatch:GetMetricStatistics\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n### Google Cloud SQL\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"google-cloud-monitoring-v3\"\n```\n\nEnable the [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) and set up your credentials:\n\n```sh\nGOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json\n```\n\nFinally, specify your database id:\n\n```sh\nPGHERO_GCP_DATABASE_ID=my-project:my-instance\n```\n\nThis requires the Monitoring Viewer role.\n\n### Azure Database\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"azure_mgmt_monitor\"\n```\n\n[Get your credentials](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) and add these variables to your environment:\n\n```sh\nAZURE_TENANT_ID=...\nAZURE_CLIENT_ID=...\nAZURE_CLIENT_SECRET=...\nAZURE_SUBSCRIPTION_ID=...\n```\n\nFinally, set your database resource URI:\n\n```sh\nPGHERO_AZURE_RESOURCE_ID=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.DBforPostgreSQL/servers/<database-id>\n```\n\nThis requires the Monitoring Reader role.\n\n## Customization & Multiple Databases\n\nTo customize PgHero, create `config/pghero.yml` with:\n\n```sh\nrails generate pghero:config\n```\n\nThis allows you to specify multiple databases and change thresholds. Thresholds can be set globally or per-database.\n\nWith Postgres < 12, if multiple databases are in the same instance and use historical query stats, PgHero should be configured to capture them together.\n\n```yml\ndatabases:\n  primary:\n    url: ...\n  other:\n    url: ...\n    capture_query_stats: primary\n```\n\n## Permissions\n\nWe recommend [setting up a dedicated user](Permissions.md) for PgHero.\n\n## Methods\n\nInsights\n\n```ruby\nPgHero.running_queries\nPgHero.long_running_queries\nPgHero.index_usage\nPgHero.invalid_indexes\nPgHero.missing_indexes\nPgHero.unused_indexes\nPgHero.unused_tables\nPgHero.database_size\nPgHero.relation_sizes\nPgHero.index_hit_rate\nPgHero.table_hit_rate\nPgHero.total_connections\n```\n\nKill queries\n\n```ruby\nPgHero.kill(pid)\nPgHero.kill_long_running_queries\nPgHero.kill_all\n```\n\nQuery stats\n\n```ruby\nPgHero.query_stats_enabled?\nPgHero.enable_query_stats\nPgHero.disable_query_stats\nPgHero.reset_query_stats\nPgHero.query_stats\nPgHero.slow_queries\n```\n\nSuggested indexes\n\n```ruby\nPgHero.suggested_indexes\nPgHero.best_index(query)\n```\n\nSecurity\n\n```ruby\nPgHero.ssl_used?\n```\n\nReplication\n\n```ruby\nPgHero.replica?\nPgHero.replication_lag\n```\n\nIf you have multiple databases, specify a database with:\n\n```ruby\nPgHero.databases[\"db2\"].running_queries\n```\n\n## Users\n\n**Note:** It’s unsafe to pass user input to these commands.\n\nCreate a user\n\n```ruby\nPgHero.create_user(\"link\")\n# {password: \"zbTrNHk2tvMgNabFgCo0ws7T\"}\n```\n\nThis generates and returns a secure password.  The user has full access to the `public` schema.\n\nRead-only access\n\n```ruby\nPgHero.create_user(\"epona\", readonly: true)\n```\n\nSet the password\n\n```ruby\nPgHero.create_user(\"zelda\", password: \"hyrule\")\n```\n\nGrant access to only certain tables\n\n```ruby\nPgHero.create_user(\"navi\", tables: [\"triforce\"])\n```\n\nDrop a user\n\n```ruby\nPgHero.drop_user(\"ganondorf\")\n```\n"
  },
  {
    "path": "guides/Suggested-Indexes.md",
    "content": "# How PgHero Suggests Indexes\n\n1. Get the most time-consuming queries from [pg_stat_statements](https://www.postgresql.org/docs/current/static/pgstatstatements.html).\n\n2. Parse queries with [pg_query](https://github.com/lfittl/pg_query).  Look for a single table with a `WHERE` clause that consists of only `=`, `IN`, `IS NULL` or `IS NOT NULL` and/or an `ORDER BY` clause.\n\n3. Use the [pg_stats](https://www.postgresql.org/docs/current/static/view-pg-stats.html) view to get estimates about distinct rows and percent of `NULL` values for each column.\n\n4. For each column in the `WHERE` clause, sort by the highest [cardinality](https://en.wikipedia.org/wiki/Cardinality_(SQL_statements)) (most unique values). This allows the database to narrow its search the fastest. Perform [row estimation](https://www.postgresql.org/docs/current/static/row-estimation-examples.html) to get the expected number of rows as we add columns to the index.\n\n5. Continue this process with columns in the `ORDER BY` clause.\n\n6. To make sure we don’t add useless columns, stop once we narrow it down to 50 rows in steps 5 or 6. Also, recheck the last columns to make sure they add value.\n\n7. Profit :moneybag:\n\n## TODO\n\n- examples\n"
  },
  {
    "path": "lib/generators/pghero/config_generator.rb",
    "content": "require \"rails/generators\"\n\nmodule Pghero\n  module Generators\n    class ConfigGenerator < Rails::Generators::Base\n      source_root File.join(__dir__, \"templates\")\n\n      def create_initializer\n        template \"config.yml\", \"config/pghero.yml\"\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/generators/pghero/query_stats_generator.rb",
    "content": "require \"rails/generators\"\nrequire \"rails/generators/active_record\"\n\nmodule Pghero\n  module Generators\n    class QueryStatsGenerator < Rails::Generators::Base\n      include ActiveRecord::Generators::Migration\n      source_root File.join(__dir__, \"templates\")\n\n      def copy_migration\n        migration_template \"query_stats.rb\", \"db/migrate/create_pghero_query_stats.rb\", migration_version: migration_version\n      end\n\n      def migration_version\n        \"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]\"\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/generators/pghero/space_stats_generator.rb",
    "content": "require \"rails/generators\"\nrequire \"rails/generators/active_record\"\n\nmodule Pghero\n  module Generators\n    class SpaceStatsGenerator < Rails::Generators::Base\n      include ActiveRecord::Generators::Migration\n      source_root File.join(__dir__, \"templates\")\n\n      def copy_migration\n        migration_template \"space_stats.rb\", \"db/migrate/create_pghero_space_stats.rb\", migration_version: migration_version\n      end\n\n      def migration_version\n        \"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]\"\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/generators/pghero/templates/config.yml.tt",
    "content": "databases:\n  primary:\n    # Database URL (defaults to app database)\n    # url: <%%= ENV[\"DATABASE_URL\"] %>\n\n    # System stats\n    # aws_db_instance_identifier: my-instance\n    # gcp_database_id: my-project:my-instance\n    # azure_resource_id: my-resource-id\n\n  # Add more databases\n  # other:\n  #   url: <%%= ENV[\"OTHER_DATABASE_URL\"] %>\n\n# Minimum time for long running queries\n# long_running_query_sec: 60\n\n# Minimum average time for slow queries\n# slow_query_ms: 20\n\n# Minimum calls for slow queries\n# slow_query_calls: 100\n\n# Minimum connections for high connections warning\n# total_connections_threshold: 500\n\n# Explain functionality\n# explain: true / false / analyze\n\n# Statement timeout for explain\n# explain_timeout_sec: 10\n\n# Visualize URL for explain\n# visualize_url: https://...\n\n# Time zone (defaults to app time zone)\n# time_zone: \"Pacific Time (US & Canada)\"\n\n# Basic authentication\n# username: admin\n# password: <%%= ENV[\"PGHERO_PASSWORD\"] %>\n\n# Stats database URL (defaults to app database)\n# stats_database_url: <%%= ENV[\"PGHERO_STATS_DATABASE_URL\"] %>\n\n# AWS configuration (defaults to app AWS config)\n# aws_access_key_id: <%%= ENV[\"AWS_ACCESS_KEY_ID\"] %>\n# aws_secret_access_key: <%%= ENV[\"AWS_SECRET_ACCESS_KEY\"] %>\n# aws_region: us-east-1\n\n# Filter data from queries (experimental)\n# filter_data: true\n"
  },
  {
    "path": "lib/generators/pghero/templates/query_stats.rb.tt",
    "content": "class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>\n  def change\n    create_table :pghero_query_stats do |t|\n      t.text :database\n      t.text :user\n      t.text :query\n      t.integer :query_hash, limit: 8\n      t.float :total_time\n      t.integer :calls, limit: 8\n      t.timestamp :captured_at\n    end\n\n    add_index :pghero_query_stats, [:database, :captured_at]\n  end\nend\n"
  },
  {
    "path": "lib/generators/pghero/templates/space_stats.rb.tt",
    "content": "class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>\n  def change\n    create_table :pghero_space_stats do |t|\n      t.text :database\n      t.text :schema\n      t.text :relation\n      t.integer :size, limit: 8\n      t.timestamp :captured_at\n    end\n\n    add_index :pghero_space_stats, [:database, :captured_at]\n  end\nend\n"
  },
  {
    "path": "lib/pghero/connection.rb",
    "content": "module PgHero\n  class Connection < ActiveRecord::Base\n    self.abstract_class = true\n  end\nend\n"
  },
  {
    "path": "lib/pghero/database.rb",
    "content": "module PgHero\n  class Database\n    include Methods::Basic\n    include Methods::Connections\n    include Methods::Constraints\n    include Methods::Explain\n    include Methods::Indexes\n    include Methods::Kill\n    include Methods::Maintenance\n    include Methods::Queries\n    include Methods::QueryStats\n    include Methods::Replication\n    include Methods::Sequences\n    include Methods::Settings\n    include Methods::Space\n    include Methods::SuggestedIndexes\n    include Methods::System\n    include Methods::Tables\n    include Methods::Users\n\n    attr_reader :id, :config\n\n    def initialize(id, config)\n      @id = id\n      @config = config || {}\n\n      # preload model to ensure only one connection pool\n      # this doesn't actually start any connections\n      @adapter_checked = false\n      @connection_model = build_connection_model\n    end\n\n    def name\n      @name ||= @config[\"name\"] || id.titleize\n    end\n\n    def capture_query_stats?\n      config[\"capture_query_stats\"] != false\n    end\n\n    def cache_hit_rate_threshold\n      (config[\"cache_hit_rate_threshold\"] || PgHero.config[\"cache_hit_rate_threshold\"] || PgHero.cache_hit_rate_threshold).to_i\n    end\n\n    def total_connections_threshold\n      (config[\"total_connections_threshold\"] || PgHero.config[\"total_connections_threshold\"] || PgHero.total_connections_threshold).to_i\n    end\n\n    def slow_query_ms\n      (config[\"slow_query_ms\"] || PgHero.config[\"slow_query_ms\"] || PgHero.slow_query_ms).to_i\n    end\n\n    def slow_query_calls\n      (config[\"slow_query_calls\"] || PgHero.config[\"slow_query_calls\"] || PgHero.slow_query_calls).to_i\n    end\n\n    def explain_timeout_sec\n      (config[\"explain_timeout_sec\"] || PgHero.config[\"explain_timeout_sec\"] || PgHero.explain_timeout_sec).to_f\n    end\n\n    def long_running_query_sec\n      (config[\"long_running_query_sec\"] || PgHero.config[\"long_running_query_sec\"] || PgHero.long_running_query_sec).to_i\n    end\n\n    # defaults to 100 megabytes\n    def index_bloat_bytes\n      (config[\"index_bloat_bytes\"] || PgHero.config[\"index_bloat_bytes\"] || 104857600).to_i\n    end\n\n    def aws_access_key_id\n      config[\"aws_access_key_id\"] || PgHero.config[\"aws_access_key_id\"] || ENV[\"PGHERO_ACCESS_KEY_ID\"] || ENV[\"AWS_ACCESS_KEY_ID\"]\n    end\n\n    def aws_secret_access_key\n      config[\"aws_secret_access_key\"] || PgHero.config[\"aws_secret_access_key\"] || ENV[\"PGHERO_SECRET_ACCESS_KEY\"] || ENV[\"AWS_SECRET_ACCESS_KEY\"]\n    end\n\n    def aws_region\n      config[\"aws_region\"] || PgHero.config[\"aws_region\"] || ENV[\"PGHERO_REGION\"] || ENV[\"AWS_REGION\"] || (defined?(Aws) && Aws.config[:region]) || \"us-east-1\"\n    end\n\n    # environment variable is only used if no config file\n    def aws_db_instance_identifier\n      @aws_db_instance_identifier ||= config[\"aws_db_instance_identifier\"] || config[\"db_instance_identifier\"]\n    end\n\n    # environment variable is only used if no config file\n    def gcp_database_id\n      @gcp_database_id ||= config[\"gcp_database_id\"]\n    end\n\n    # environment variable is only used if no config file\n    def azure_resource_id\n      @azure_resource_id ||= config[\"azure_resource_id\"]\n    end\n\n    # must check keys for booleans\n    def filter_data\n      unless defined?(@filter_data)\n        @filter_data =\n          if config.key?(\"filter_data\")\n            config[\"filter_data\"]\n          elsif PgHero.config.key?(\"filter_data\")\n            PgHero.config.key?(\"filter_data\")\n          else\n            PgHero.filter_data\n          end\n\n        if @filter_data\n          begin\n            require \"pg_query\"\n          rescue LoadError\n            raise Error, \"pg_query required for filter_data\"\n          end\n        end\n      end\n\n      @filter_data\n    end\n\n    private\n\n    # check adapter lazily\n    def connection_model\n      unless @adapter_checked\n        # rough check for Postgres adapter\n        # keep this message generic so it's useful\n        # when empty url set in Docker image pghero.yml\n        unless @connection_model.connection_db_config.adapter.to_s.match?(/postg/i)\n          raise Error, \"Invalid connection URL\"\n        end\n        @adapter_checked = true\n      end\n\n      @connection_model\n    end\n\n    # just return the model\n    # do not start a connection\n    def build_connection_model\n      url = config[\"url\"]\n\n      # resolve spec\n      if !url && config[\"spec\"]\n        config_options = {env_name: PgHero.env, PgHero.spec_name_key => config[\"spec\"], PgHero.include_replicas_key => true}\n        resolved = ActiveRecord::Base.configurations.configs_for(**config_options)\n        raise Error, \"Spec not found: #{config[\"spec\"]}\" unless resolved\n        url = resolved.configuration_hash\n      end\n\n      url = url.dup\n\n      Class.new(PgHero::Connection) do\n        def self.name\n          \"PgHero::Connection::Database#{object_id}\"\n        end\n\n        case url\n        when String\n          url = \"#{url}#{url.include?(\"?\") ? \"&\" : \"?\"}connect_timeout=5\" unless url.include?(\"connect_timeout=\")\n        when Hash\n          url[:connect_timeout] ||= 5\n        end\n        establish_connection url if url\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/engine.rb",
    "content": "module PgHero\n  class Engine < ::Rails::Engine\n    isolate_namespace PgHero\n\n    initializer \"pghero\", group: :all do |app|\n      # check if Rails api mode\n      if app.config.respond_to?(:assets) && defined?(Sprockets)\n        if Sprockets::VERSION.to_i >= 4\n          app.config.assets.precompile << \"pghero/application.js\"\n          app.config.assets.precompile << \"pghero/application.css\"\n          app.config.assets.precompile << \"pghero/favicon.png\"\n        else\n          # use a proc instead of a string\n          app.config.assets.precompile << proc { |path| path == \"pghero/application.js\" }\n          app.config.assets.precompile << proc { |path| path == \"pghero/application.css\" }\n          app.config.assets.precompile << proc { |path| path == \"pghero/favicon.png\" }\n        end\n      end\n\n      file_config = PgHero.file_config || {}\n      PgHero.time_zone = file_config[\"time_zone\"] if file_config[\"time_zone\"]\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/basic.rb",
    "content": "module PgHero\n  module Methods\n    module Basic\n      def ssl_used?\n        ssl_used = nil\n        with_transaction(rollback: true) do\n          begin\n            execute(\"CREATE EXTENSION IF NOT EXISTS sslinfo\")\n          rescue ActiveRecord::StatementInvalid\n            # not superuser\n          end\n          ssl_used = select_one(\"SELECT ssl_is_used()\")\n        end\n        ssl_used\n      end\n\n      def database_name\n        select_one(\"SELECT current_database()\")\n      end\n\n      def current_user\n        select_one(\"SELECT current_user\")\n      end\n\n      def server_version\n        @server_version ||= select_one(\"SHOW server_version\")\n      end\n\n      def server_version_num\n        @server_version_num ||= select_one(\"SHOW server_version_num\").to_i\n      end\n\n      def quote_ident(value)\n        with_connection { |c| c.quote_column_name(value) }\n      end\n\n      private\n\n      def select_all(sql, stats: false, query_columns: [])\n        with_connection(stats: stats) do |conn|\n          select_all_leased(sql, conn: conn, query_columns: query_columns)\n        end\n      end\n\n      def select_all_leased(sql, conn:, query_columns:)\n        # squish for logs\n        retries = 0\n        begin\n          result = conn.select_all(add_source(squish(sql)))\n          if ActiveRecord::VERSION::MAJOR >= 8\n            result = result.to_a.map(&:symbolize_keys)\n          else\n            result = result.map(&:symbolize_keys)\n          end\n          if filter_data\n            query_columns.each do |column|\n              result.each do |row|\n                begin\n                  row[column] = PgQuery.normalize(row[column])\n                rescue PgQuery::ParseError\n                  # try replacing \"interval $1\" with \"$1::interval\"\n                  # see https://github.com/lfittl/pg_query/issues/169 for more info\n                  # this is not ideal since it changes the query slightly\n                  # we could skip normalization\n                  # but this has a very small chance of data leakage\n                  begin\n                    row[column] = PgQuery.normalize(row[column].gsub(/\\binterval\\s+(\\$\\d+)\\b/i, \"\\\\1::interval\"))\n                  rescue PgQuery::ParseError\n                    row[column] = \"<unable to filter data>\"\n                  end\n                end\n              end\n            end\n          end\n          result\n        rescue ActiveRecord::StatementInvalid => e\n          # fix for random internal errors\n          if e.message.include?(\"PG::InternalError\") && retries < 2\n            retries += 1\n            sleep(0.1)\n            retry\n          else\n            raise e\n          end\n        end\n      end\n\n      def select_all_stats(sql, **options)\n        select_all(sql, **options, stats: true)\n      end\n\n      def select_all_size(sql)\n        result = select_all(sql)\n        result.each do |row|\n          row[:size] = PgHero.pretty_size(row[:size_bytes])\n        end\n        result\n      end\n\n      def select_one(sql)\n        select_all(sql).first.values.first\n      end\n\n      def execute(sql)\n        with_connection { |c| c.execute(add_source(sql)) }\n      end\n\n      def with_connection(stats: false, &block)\n        model = stats ? ::PgHero::Stats : connection_model\n        model.connection_pool.with_connection(&block)\n      end\n\n      def squish(str)\n        str.to_s.squish\n      end\n\n      def add_source(sql)\n        \"#{sql} /*pghero*/\"\n      end\n\n      def quote(value)\n        with_connection { |c| c.quote(value) }\n      end\n\n      def quote_table_name(value)\n        with_connection { |c| c.quote_table_name(value) }\n      end\n\n      def quote_column_name(value)\n        with_connection { |c| c.quote_column_name(value) }\n      end\n\n      def unquote(part)\n        if part && part.start_with?('\"')\n          part[1..-2]\n        else\n          part\n        end\n      end\n\n      def with_transaction(lock_timeout: nil, statement_timeout: nil, rollback: false)\n        connection_model.transaction do\n          select_all \"SET LOCAL statement_timeout = #{statement_timeout.to_i}\" if statement_timeout\n          select_all \"SET LOCAL lock_timeout = #{lock_timeout.to_i}\" if lock_timeout\n          yield\n          raise ActiveRecord::Rollback if rollback\n        end\n      end\n\n      def table_exists?(table)\n        with_connection(stats: true) { |c| c.table_exists?(table) }\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/connections.rb",
    "content": "module PgHero\n  module Methods\n    module Connections\n      def connections\n        if server_version_num >= 90500\n          select_all <<~SQL\n            SELECT\n              pg_stat_activity.pid,\n              datname AS database,\n              usename AS user,\n              application_name AS source,\n              client_addr AS ip,\n              state,\n              ssl\n            FROM\n              pg_stat_activity\n            LEFT JOIN\n              pg_stat_ssl ON pg_stat_activity.pid = pg_stat_ssl.pid\n            ORDER BY\n              pg_stat_activity.pid\n          SQL\n        else\n          select_all <<~SQL\n            SELECT\n              pid,\n              datname AS database,\n              usename AS user,\n              application_name AS source,\n              client_addr AS ip,\n              state\n            FROM\n              pg_stat_activity\n            ORDER BY\n              pid\n          SQL\n        end\n      end\n\n      def total_connections\n        select_one(\"SELECT COUNT(*) FROM pg_stat_activity\")\n      end\n\n      def connection_states\n        states = select_all <<~SQL\n          SELECT\n            state,\n            COUNT(*) AS connections\n          FROM\n            pg_stat_activity\n          GROUP BY\n            1\n          ORDER BY\n            2 DESC, 1\n        SQL\n\n        states.to_h { |s| [s[:state], s[:connections]] }\n      end\n\n      def connection_sources\n        select_all <<~SQL\n          SELECT\n            datname AS database,\n            usename AS user,\n            application_name AS source,\n            client_addr AS ip,\n            COUNT(*) AS total_connections\n          FROM\n            pg_stat_activity\n          GROUP BY\n            1, 2, 3, 4\n          ORDER BY\n            5 DESC, 1, 2, 3, 4\n        SQL\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/constraints.rb",
    "content": "module PgHero\n  module Methods\n    module Constraints\n      # referenced fields can be nil\n      # as not all constraints are foreign keys\n      def invalid_constraints\n        select_all <<~SQL\n          SELECT\n            nsp.nspname AS schema,\n            rel.relname AS table,\n            con.conname AS name,\n            fnsp.nspname AS referenced_schema,\n            frel.relname AS referenced_table\n          FROM\n            pg_catalog.pg_constraint con\n          INNER JOIN\n            pg_catalog.pg_class rel ON rel.oid = con.conrelid\n          LEFT JOIN\n            pg_catalog.pg_class frel ON frel.oid = con.confrelid\n          LEFT JOIN\n            pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace\n          LEFT JOIN\n            pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace\n          WHERE\n            con.convalidated = 'f'\n        SQL\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/explain.rb",
    "content": "module PgHero\n  module Methods\n    module Explain\n      # TODO remove in 4.0\n      # note: this method is not affected by the explain option\n      def explain(sql)\n        sql = squish(sql)\n        explanation = nil\n\n        # use transaction for safety\n        with_transaction(statement_timeout: (explain_timeout_sec * 1000).round, rollback: true) do\n          if (sql.delete_suffix(\";\").include?(\";\") || sql.upcase.include?(\"COMMIT\")) && !explain_safe?\n            raise ActiveRecord::StatementInvalid, \"Unsafe statement\"\n          end\n          explanation = execute(\"EXPLAIN #{sql}\").map { |v| v[\"QUERY PLAN\"] }.join(\"\\n\")\n        end\n\n        explanation\n      end\n\n      # TODO rename to explain in 4.0\n      # note: this method is not affected by the explain option\n      def explain_v2(sql, analyze: nil, verbose: nil, costs: nil, settings: nil, generic_plan: nil, buffers: nil, wal: nil, timing: nil, summary: nil, format: \"text\")\n        options = []\n        add_explain_option(options, \"ANALYZE\", analyze)\n        add_explain_option(options, \"VERBOSE\", verbose)\n        add_explain_option(options, \"SETTINGS\", settings)\n        add_explain_option(options, \"GENERIC_PLAN\", generic_plan)\n        add_explain_option(options, \"COSTS\", costs)\n        add_explain_option(options, \"BUFFERS\", buffers)\n        add_explain_option(options, \"WAL\", wal)\n        add_explain_option(options, \"TIMING\", timing)\n        add_explain_option(options, \"SUMMARY\", summary)\n        options << \"FORMAT #{explain_format(format)}\"\n\n        explain(\"(#{options.join(\", \")}) #{sql}\")\n      end\n\n      private\n\n      def explain_safe?\n        select_all(\"SELECT 1; SELECT 1\")\n        false\n      rescue ActiveRecord::StatementInvalid\n        true\n      end\n\n      def add_explain_option(options, name, value)\n        unless value.nil?\n          options << \"#{name}#{value ? \"\" : \" FALSE\"}\"\n        end\n      end\n\n      # important! validate format to prevent injection\n      def explain_format(format)\n        if [\"text\", \"xml\", \"json\", \"yaml\"].include?(format)\n          format.upcase\n        else\n          raise ArgumentError, \"Unknown format\"\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/indexes.rb",
    "content": "module PgHero\n  module Methods\n    module Indexes\n      def index_hit_rate\n        select_one <<~SQL\n          SELECT\n            (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read), 0) AS rate\n          FROM\n            pg_statio_user_indexes\n        SQL\n      end\n\n      def index_caching\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            indexrelname AS index,\n            CASE WHEN idx_blks_hit + idx_blks_read = 0 THEN\n              0\n            ELSE\n              ROUND(1.0 * idx_blks_hit / (idx_blks_hit + idx_blks_read), 2)\n            END AS hit_rate\n          FROM\n            pg_statio_user_indexes\n          ORDER BY\n            3 DESC, 1\n        SQL\n      end\n\n      def index_usage\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            CASE idx_scan\n              WHEN 0 THEN 'Insufficient data'\n              ELSE (100 * idx_scan / (seq_scan + idx_scan))::text\n            END percent_of_times_index_used,\n            n_live_tup AS estimated_rows\n          FROM\n            pg_stat_user_tables\n          ORDER BY\n            n_live_tup DESC,\n            relname ASC\n         SQL\n      end\n\n      def missing_indexes\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            CASE idx_scan\n              WHEN 0 THEN 'Insufficient data'\n              ELSE (100 * idx_scan / (seq_scan + idx_scan))::text\n            END percent_of_times_index_used,\n            n_live_tup AS estimated_rows\n          FROM\n            pg_stat_user_tables\n          WHERE\n            idx_scan > 0\n            AND (100 * idx_scan / (seq_scan + idx_scan)) < 95\n            AND n_live_tup >= 10000\n          ORDER BY\n            n_live_tup DESC,\n            relname ASC\n         SQL\n      end\n\n      def unused_indexes(max_scans: 50, across: [])\n        result = select_all_size <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            indexrelname AS index,\n            pg_relation_size(i.indexrelid) AS size_bytes,\n            idx_scan as index_scans\n          FROM\n            pg_stat_user_indexes ui\n          INNER JOIN\n            pg_index i ON ui.indexrelid = i.indexrelid\n          WHERE\n            NOT indisunique\n            AND idx_scan <= #{max_scans.to_i}\n          ORDER BY\n            pg_relation_size(i.indexrelid) DESC,\n            relname ASC\n        SQL\n\n        across.each do |database_id|\n          database = PgHero.databases.values.find { |d| d.id == database_id }\n          raise PgHero::Error, \"Database not found: #{database_id}\" unless database\n          across_result = Set.new(database.unused_indexes(max_scans: max_scans).map { |v| [v[:schema], v[:index]] })\n          result.select! { |v| across_result.include?([v[:schema], v[:index]]) }\n        end\n\n        result\n      end\n\n      def reset_stats\n        execute(\"SELECT pg_stat_reset()\")\n        true\n      end\n\n      def last_stats_reset_time\n        select_one <<~SQL\n          SELECT\n            pg_stat_get_db_stat_reset_time(oid) AS reset_time\n          FROM\n            pg_database\n          WHERE\n            datname = current_database()\n        SQL\n      end\n\n      def invalid_indexes(indexes: nil)\n        indexes = (indexes || self.indexes).select { |i| !i[:valid] && !i[:creating] }\n        indexes.each do |index|\n          # map name -> index for backward compatibility\n          index[:index] = index[:name]\n        end\n        indexes\n      end\n\n      # TODO parse array properly\n      # https://stackoverflow.com/questions/2204058/list-columns-with-indexes-in-postgresql\n      def indexes\n        indexes = select_all(<<~SQL\n          SELECT\n            schemaname AS schema,\n            t.relname AS table,\n            ix.relname AS name,\n            regexp_replace(pg_get_indexdef(i.indexrelid), '^[^\\\\(]*\\\\((.*)\\\\)$', '\\\\1') AS columns,\n            regexp_replace(pg_get_indexdef(i.indexrelid), '.* USING ([^ ]*) \\\\(.*', '\\\\1') AS using,\n            indisunique AS unique,\n            indisprimary AS primary,\n            indisvalid AS valid,\n            indexprs::text,\n            indpred::text,\n            pg_get_indexdef(i.indexrelid) AS definition\n          FROM\n            pg_index i\n          INNER JOIN\n            pg_class t ON t.oid = i.indrelid\n          INNER JOIN\n            pg_class ix ON ix.oid = i.indexrelid\n          LEFT JOIN\n            pg_stat_user_indexes ui ON ui.indexrelid = i.indexrelid\n          WHERE\n            schemaname IS NOT NULL\n          ORDER BY\n            1, 2\n        SQL\n        ).map { |v| v[:columns] = v[:columns].sub(\") WHERE (\", \" WHERE \").split(\", \").map { |c| unquote(c) }; v }\n\n        # determine if any invalid indexes being created\n        # hacky, but works for simple cases\n        # can be a race condition, but that's fine\n        invalid_indexes = indexes.select { |i| !i[:valid] }\n        if invalid_indexes.any?\n          create_index_queries = running_queries.select { |q| /\\s*CREATE\\s+INDEX\\s+CONCURRENTLY\\s+/i.match(q[:query]) }\n          invalid_indexes.each do |index|\n            index[:creating] = create_index_queries.any? { |q| q[:query].include?(index[:table]) && index[:columns].all? { |c| q[:query].include?(c) } }\n          end\n        end\n\n        indexes\n      end\n\n      def duplicate_indexes(indexes: nil)\n        dup_indexes = []\n\n        indexes_by_table = (indexes || self.indexes).group_by { |i| [i[:schema], i[:table]] }\n        indexes_by_table.values.flatten.select { |i| i[:valid] && !i[:primary] && !i[:unique] }.each do |index|\n          covering_index = indexes_by_table[[index[:schema], index[:table]]].find { |i| i[:valid] && i[:name] != index[:name] && index_covers?(i[:columns], index[:columns]) && i[:using] == index[:using] && i[:indexprs] == index[:indexprs] && i[:indpred] == index[:indpred] }\n          if covering_index && (covering_index[:columns] != index[:columns] || index[:name] > covering_index[:name] || covering_index[:primary] || covering_index[:unique])\n            dup_indexes << {unneeded_index: index, covering_index: covering_index}\n          end\n        end\n\n        dup_indexes.sort_by { |i| ui = i[:unneeded_index]; [ui[:table], ui[:columns]] }\n      end\n\n      # https://gist.github.com/mbanck/9976015/71888a24e464e2f772182a7eb54f15a125edf398\n      # thanks @jberkus and @mbanck\n      def index_bloat(min_size: nil)\n        min_size ||= index_bloat_bytes\n        select_all <<~SQL\n          WITH btree_index_atts AS (\n            SELECT\n              nspname, relname, reltuples, relpages, indrelid, relam,\n              regexp_split_to_table(indkey::text, ' ')::smallint AS attnum,\n              indexrelid as index_oid\n            FROM\n              pg_index\n            JOIN\n              pg_class ON pg_class.oid = pg_index.indexrelid\n            JOIN\n              pg_namespace ON pg_namespace.oid = pg_class.relnamespace\n            JOIN\n              pg_am ON pg_class.relam = pg_am.oid\n            WHERE\n              pg_am.amname = 'btree'\n          ),\n          index_item_sizes AS (\n            SELECT\n              i.nspname,\n              i.relname,\n              i.reltuples,\n              i.relpages,\n              i.relam,\n              (quote_ident(s.schemaname) || '.' || quote_ident(s.tablename))::regclass AS starelid,\n              a.attrelid AS table_oid, index_oid,\n              current_setting('block_size')::numeric AS bs,\n              /* MAXALIGN: 4 on 32bits, 8 on 64bits (and mingw32 ?) */\n              CASE\n                WHEN version() ~ 'mingw32' OR version() ~ '64-bit' THEN 8\n                ELSE 4\n              END AS maxalign,\n              24 AS pagehdr,\n              /* per tuple header: add index_attribute_bm if some cols are null-able */\n              CASE WHEN max(coalesce(s.null_frac,0)) = 0\n                THEN 2\n                ELSE 6\n              END AS index_tuple_hdr,\n              /* data len: we remove null values save space using it fractionnal part from stats */\n              sum( (1-coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 2048) ) AS nulldatawidth\n            FROM\n              pg_attribute AS a\n            JOIN\n              pg_stats AS s ON (quote_ident(s.schemaname) || '.' || quote_ident(s.tablename))::regclass=a.attrelid AND s.attname = a.attname\n            JOIN\n              btree_index_atts AS i ON i.indrelid = a.attrelid AND a.attnum = i.attnum\n            WHERE\n              a.attnum > 0\n            GROUP BY\n              1, 2, 3, 4, 5, 6, 7, 8, 9\n          ),\n          index_aligned AS (\n            SELECT\n              maxalign,\n              bs,\n              nspname,\n              relname AS index_name,\n              reltuples,\n              relpages,\n              relam,\n              table_oid,\n              index_oid,\n              ( 2 +\n                maxalign - CASE /* Add padding to the index tuple header to align on MAXALIGN */\n                  WHEN index_tuple_hdr%maxalign = 0 THEN maxalign\n                  ELSE index_tuple_hdr%maxalign\n                END\n              + nulldatawidth + maxalign - CASE /* Add padding to the data to align on MAXALIGN */\n                  WHEN nulldatawidth::integer%maxalign = 0 THEN maxalign\n                  ELSE nulldatawidth::integer%maxalign\n                END\n              )::numeric AS nulldatahdrwidth, pagehdr\n            FROM\n              index_item_sizes AS s1\n          ),\n          otta_calc AS (\n            SELECT\n              bs,\n              nspname,\n              table_oid,\n              index_oid,\n              index_name,\n              relpages,\n              coalesce(\n                ceil((reltuples*(4+nulldatahdrwidth))/(bs-pagehdr::float)) +\n                CASE WHEN am.amname IN ('hash','btree') THEN 1 ELSE 0 END , 0 /* btree and hash have a metadata reserved block */\n              ) AS otta\n            FROM\n              index_aligned AS s2\n            LEFT JOIN\n              pg_am am ON s2.relam = am.oid\n          ),\n          raw_bloat AS (\n            SELECT\n              nspname,\n              c.relname AS table_name,\n              index_name,\n              bs*(sub.relpages)::bigint AS totalbytes,\n              CASE\n                WHEN sub.relpages <= otta THEN 0\n                ELSE bs*(sub.relpages-otta)::bigint END\n                AS wastedbytes,\n              CASE\n                WHEN sub.relpages <= otta\n                THEN 0 ELSE bs*(sub.relpages-otta)::bigint * 100 / (bs*(sub.relpages)::bigint) END\n                AS realbloat,\n              pg_relation_size(sub.table_oid) as table_bytes,\n              stat.idx_scan as index_scans,\n              stat.indexrelid\n            FROM\n              otta_calc AS sub\n            JOIN\n              pg_class AS c ON c.oid=sub.table_oid\n            JOIN\n              pg_stat_user_indexes AS stat ON sub.index_oid = stat.indexrelid\n          )\n          SELECT\n            nspname AS schema,\n            table_name AS table,\n            index_name AS index,\n            wastedbytes AS bloat_bytes,\n            totalbytes AS index_bytes,\n            pg_get_indexdef(rb.indexrelid) AS definition,\n            indisprimary AS primary\n          FROM\n            raw_bloat rb\n          INNER JOIN\n            pg_index i ON i.indexrelid = rb.indexrelid\n          WHERE\n            wastedbytes >= #{min_size.to_i}\n          ORDER BY\n            wastedbytes DESC,\n            index_name\n        SQL\n      end\n\n      protected\n\n      def index_covers?(indexed_columns, columns)\n        indexed_columns.first(columns.size) == columns\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/kill.rb",
    "content": "module PgHero\n  module Methods\n    module Kill\n      def kill(pid)\n        select_one(\"SELECT pg_terminate_backend(#{pid.to_i})\")\n      end\n\n      def kill_long_running_queries(min_duration: nil)\n        running_queries(min_duration: min_duration || long_running_query_sec).each { |query| kill(query[:pid]) }\n        true\n      end\n\n      def kill_all\n        select_all <<~SQL\n          SELECT\n            pg_terminate_backend(pid)\n          FROM\n            pg_stat_activity\n          WHERE\n            pid <> pg_backend_pid()\n            AND query <> '<insufficient privilege>'\n            AND datname = current_database()\n        SQL\n        true\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/maintenance.rb",
    "content": "module PgHero\n  module Methods\n    module Maintenance\n      # https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND\n      # \"the system will shut down and refuse to start any new transactions\n      # once there are fewer than 1 million transactions left until wraparound\"\n      # warn when 10,000,000 transactions left\n      def transaction_id_danger(threshold: 10000000, max_value: 2146483648)\n        max_value = max_value.to_i\n        threshold = threshold.to_i\n\n        select_all <<~SQL\n          SELECT\n            n.nspname AS schema,\n            c.relname AS table,\n            #{quote(max_value)} - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid)) AS transactions_left\n          FROM\n            pg_class c\n          INNER JOIN\n            pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n          LEFT JOIN\n            pg_class t ON c.reltoastrelid = t.oid\n          WHERE\n            c.relkind = 'r'\n            AND (#{quote(max_value)} - GREATEST(AGE(c.relfrozenxid), AGE(t.relfrozenxid))) < #{quote(threshold)}\n          ORDER BY\n           3, 1, 2\n        SQL\n      end\n\n      def autovacuum_danger\n        max_value = select_one(\"SHOW autovacuum_freeze_max_age\").to_i\n        transaction_id_danger(threshold: 2000000, max_value: max_value)\n      end\n\n      def vacuum_progress\n        if server_version_num >= 90600\n          select_all <<~SQL\n            SELECT\n              pid,\n              phase\n            FROM\n              pg_stat_progress_vacuum\n            WHERE\n              datname = current_database()\n          SQL\n        else\n          []\n        end\n      end\n\n      def maintenance_info\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            last_vacuum,\n            last_autovacuum,\n            last_analyze,\n            last_autoanalyze,\n            n_dead_tup AS dead_rows,\n            n_live_tup AS live_rows\n          FROM\n            pg_stat_user_tables\n          ORDER BY\n            1, 2\n        SQL\n      end\n\n      def analyze(table, verbose: false)\n        execute \"ANALYZE #{verbose ? \"VERBOSE \" : \"\"}#{quote_table_name(table)}\"\n        true\n      end\n\n      def analyze_tables(verbose: false, min_size: nil, tables: nil)\n        tables = table_stats(table: tables).reject { |s| %w(information_schema pg_catalog).include?(s[:schema]) }\n        tables = tables.select { |s| s[:size_bytes] > min_size } if min_size\n        tables.map { |s| s.slice(:schema, :table) }.each do |stats|\n          begin\n            with_transaction(lock_timeout: 5000, statement_timeout: 120000) do\n              analyze \"#{stats[:schema]}.#{stats[:table]}\", verbose: verbose\n            end\n            success = true\n          rescue ActiveRecord::StatementInvalid => e\n            $stderr.puts e.message\n            success = false\n          end\n          stats[:success] = success\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/queries.rb",
    "content": "module PgHero\n  module Methods\n    module Queries\n      def running_queries(min_duration: nil, all: false)\n        query = <<~SQL\n          SELECT\n            pid,\n            state,\n            application_name AS source,\n            age(NOW(), COALESCE(query_start, xact_start)) AS duration,\n            #{server_version_num >= 90600 ? \"(wait_event IS NOT NULL) AS waiting\" : \"waiting\"},\n            query,\n            COALESCE(query_start, xact_start) AS started_at,\n            EXTRACT(EPOCH FROM NOW() - COALESCE(query_start, xact_start)) * 1000.0 AS duration_ms,\n            usename AS user,\n            #{server_version_num >= 100000 ? \"backend_type\" : \"NULL AS backend_type\"}\n          FROM\n            pg_stat_activity\n          WHERE\n            state <> 'idle'\n            AND pid <> pg_backend_pid()\n            AND datname = current_database()\n            #{min_duration ? \"AND NOW() - COALESCE(query_start, xact_start) > interval '#{min_duration.to_i} seconds'\" : nil}\n            #{all ? nil : \"AND query <> '<insufficient privilege>'\"}\n          ORDER BY\n            COALESCE(query_start, xact_start) DESC\n        SQL\n\n        select_all(query, query_columns: [:query])\n      end\n\n      def long_running_queries\n        running_queries(min_duration: long_running_query_sec)\n      end\n\n      # from https://wiki.postgresql.org/wiki/Lock_Monitoring\n      # and https://big-elephants.com/2013-09/exploring-query-locks-in-postgres/\n      def blocked_queries\n        query = <<~SQL\n          SELECT\n            COALESCE(blockingl.relation::regclass::text,blockingl.locktype) as locked_item,\n            blockeda.pid AS blocked_pid,\n            blockeda.usename AS blocked_user,\n            blockeda.query as blocked_query,\n            age(now(), blockeda.query_start) AS blocked_duration,\n            blockedl.mode as blocked_mode,\n            blockinga.pid AS blocking_pid,\n            blockinga.usename AS blocking_user,\n            blockinga.state AS state_of_blocking_process,\n            blockinga.query AS current_or_recent_query_in_blocking_process,\n            age(now(), blockinga.query_start) AS blocking_duration,\n            blockingl.mode as blocking_mode\n          FROM\n            pg_catalog.pg_locks blockedl\n          LEFT JOIN\n            pg_stat_activity blockeda ON blockedl.pid = blockeda.pid\n          LEFT JOIN\n            pg_catalog.pg_locks blockingl ON blockedl.pid != blockingl.pid AND (\n              blockingl.transactionid = blockedl.transactionid\n              OR (blockingl.relation = blockedl.relation AND blockingl.locktype = blockedl.locktype)\n            )\n          LEFT JOIN\n            pg_stat_activity blockinga ON blockingl.pid = blockinga.pid AND blockinga.datid = blockeda.datid\n          WHERE\n            NOT blockedl.granted\n            AND blockeda.query <> '<insufficient privilege>'\n            AND blockeda.datname = current_database()\n          ORDER BY\n            blocked_duration DESC\n        SQL\n\n        select_all(query, query_columns: [:blocked_query, :current_or_recent_query_in_blocking_process])\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/query_stats.rb",
    "content": "module PgHero\n  module Methods\n    module QueryStats\n      def query_stats(historical: false, start_at: nil, end_at: nil, min_average_time: nil, min_calls: nil, **options)\n        current_query_stats = historical && end_at && end_at < Time.now ? [] : current_query_stats(**options)\n        historical_query_stats = historical && historical_query_stats_enabled? ? historical_query_stats(start_at: start_at, end_at: end_at, **options) : []\n\n        query_stats = combine_query_stats((current_query_stats + historical_query_stats).group_by { |q| [q[:query_hash], q[:user]] })\n        query_stats = combine_query_stats(query_stats.group_by { |q| [normalize_query(q[:query]), q[:user]] })\n\n        # add percentages\n        all_queries_total_minutes = [current_query_stats, historical_query_stats].sum { |s| (s.first || {})[:all_queries_total_minutes] || 0 }\n        query_stats.each do |query|\n          query[:average_time] = query[:total_minutes] * 1000 * 60 / query[:calls]\n          query[:total_percent] = query[:total_minutes] * 100.0 / all_queries_total_minutes\n        end\n\n        sort = options[:sort] || \"total_minutes\"\n        query_stats = query_stats.sort_by { |q| -q[sort.to_sym] }.first(100)\n        if min_average_time\n          query_stats.reject! { |q| q[:average_time] < min_average_time }\n        end\n        if min_calls\n          query_stats.reject! { |q| q[:calls] < min_calls }\n        end\n        query_stats\n      end\n\n      def query_stats_available?\n        select_one(\"SELECT COUNT(*) AS count FROM pg_available_extensions WHERE name = 'pg_stat_statements'\") > 0\n      end\n\n      # only cache if true\n      def query_stats_enabled?\n        @query_stats_enabled ||= query_stats_readable?\n      end\n\n      def query_stats_extension_enabled?\n        select_one(\"SELECT COUNT(*) AS count FROM pg_extension WHERE extname = 'pg_stat_statements'\") > 0\n      end\n\n      def query_stats_readable?\n        select_all(\"SELECT * FROM pg_stat_statements LIMIT 1\")\n        true\n      rescue ActiveRecord::StatementInvalid\n        false\n      end\n\n      def enable_query_stats\n        execute(\"CREATE EXTENSION IF NOT EXISTS pg_stat_statements\")\n        true\n      end\n\n      def disable_query_stats\n        execute(\"DROP EXTENSION IF EXISTS pg_stat_statements\")\n        true\n      end\n\n      def reset_query_stats(**options)\n        raise PgHero::Error, \"Use reset_instance_query_stats to pass database\" if options.delete(:database)\n        reset_instance_query_stats(**options, database: database_name)\n      end\n\n      # resets query stats for the entire instance\n      # it's possible to reset stats for a specific\n      # database, user or query hash in Postgres 12+\n      def reset_instance_query_stats(database: nil, user: nil, query_hash: nil, raise_errors: false)\n        if database || user || query_hash\n          raise PgHero::Error, \"Requires PostgreSQL 12+\" if server_version_num < 120000\n\n          if database\n            database_id = execute(\"SELECT oid FROM pg_database WHERE datname = #{quote(database)}\").first.try(:[], \"oid\")\n            raise PgHero::Error, \"Database not found: #{database}\" unless database_id\n          else\n            database_id = 0\n          end\n\n          if user\n            user_id = execute(\"SELECT usesysid FROM pg_user WHERE usename = #{quote(user)}\").first.try(:[], \"usesysid\")\n            raise PgHero::Error, \"User not found: #{user}\" unless user_id\n          else\n            user_id = 0\n          end\n\n          if query_hash\n            query_id = query_hash.to_i\n            # may not be needed\n            # but not intuitive that all query hashes are reset with 0\n            raise PgHero::Error, \"Invalid query hash: #{query_hash}\" if query_id == 0\n          else\n            query_id = 0\n          end\n\n          execute(\"SELECT pg_stat_statements_reset(#{quote(user_id.to_i)}, #{quote(database_id.to_i)}, #{quote(query_id.to_i)})\")\n        else\n          execute(\"SELECT pg_stat_statements_reset()\")\n        end\n        true\n      rescue ActiveRecord::StatementInvalid => e\n        raise e if raise_errors\n        false\n      end\n\n      # https://stackoverflow.com/questions/20582500/how-to-check-if-a-table-exists-in-a-given-schema\n      def historical_query_stats_enabled?\n        # TODO use schema from config\n        # make sure primary database is PostgreSQL first\n        query_stats_table_exists? && capture_query_stats? && !missing_query_stats_columns.any?\n      end\n\n      def query_stats_table_exists?\n        table_exists?(\"pghero_query_stats\")\n      end\n\n      def missing_query_stats_columns\n        %w(query_hash user) - PgHero::QueryStats.column_names\n      end\n\n      def supports_query_hash?\n        server_version_num >= 90400\n      end\n\n      # resetting query stats will reset across the entire Postgres instance in Postgres < 12\n      # this is problematic if multiple PgHero databases use the same Postgres instance\n      #\n      # to get around this, we capture queries for every Postgres database before we\n      # reset query stats for the Postgres instance with the `capture_query_stats` option\n      def capture_query_stats(raise_errors: false)\n        return if config[\"capture_query_stats\"] && config[\"capture_query_stats\"] != true\n\n        # get all databases that use same query stats and build mapping\n        mapping = {id => database_name}\n        PgHero.databases.select { |_, d| d.config[\"capture_query_stats\"] == id }.each do |_, d|\n          mapping[d.id] = d.database_name\n        end\n\n        now = Time.now\n\n        query_stats = {}\n        mapping.each do |database_id, database_name|\n          query_stats[database_id] = query_stats(limit: 1000000, database: database_name)\n        end\n\n        query_stats = query_stats.select { |_, v| v.any? }\n\n        # nothing to do\n        return if query_stats.empty?\n\n        # reset individual databases for Postgres 12+ instance\n        if server_version_num >= 120000\n          query_stats.each do |db_id, db_query_stats|\n            if reset_instance_query_stats(database: mapping[db_id], raise_errors: raise_errors)\n              insert_query_stats(db_id, db_query_stats, now)\n            end\n          end\n        else\n          if reset_instance_query_stats(raise_errors: raise_errors)\n            query_stats.each do |db_id, db_query_stats|\n              insert_query_stats(db_id, db_query_stats, now)\n            end\n          end\n        end\n      end\n\n      def clean_query_stats(before: nil)\n        before ||= 14.days.ago\n        PgHero::QueryStats.where(database: id).where(\"captured_at < ?\", before).delete_all\n      end\n\n      def slow_queries(query_stats: nil, **options)\n        query_stats ||= self.query_stats(**options)\n        query_stats.select { |q| q[:calls].to_i >= slow_query_calls.to_i && q[:average_time].to_f >= slow_query_ms.to_f }\n      end\n\n      def query_hash_stats(query_hash, user: nil, current: false)\n        if historical_query_stats_enabled? && supports_query_hash?\n          start_at = 24.hours.ago\n          stats = select_all_stats <<~SQL\n            SELECT\n              captured_at,\n              total_time / 1000 / 60 AS total_minutes,\n              (total_time / calls) AS average_time,\n              calls,\n              (SELECT regexp_matches(query, '.*/\\\\*(.+?)\\\\*/'))[1] AS origin\n            FROM\n              pghero_query_stats\n            WHERE\n              database = #{quote(id)}\n              AND captured_at >= #{quote(start_at)}\n              AND query_hash = #{quote(query_hash)}\n              #{user ? \"AND \\\"user\\\" = #{quote(user)}\" : \"\"}\n            ORDER BY\n              1 ASC\n          SQL\n          if current\n            captured_at = Time.current\n            current_stats = current_query_stats(query_hash: query_hash, user: user, origin: true)\n            current_stats.each do |r|\n              r[:captured_at] = captured_at\n            end\n            stats += current_stats\n          end\n          stats\n        else\n          raise NotEnabled, \"Query hash stats not enabled\"\n        end\n      end\n\n      private\n\n      # http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/\n      def current_query_stats(limit: nil, sort: nil, database: nil, query_hash: nil, user: nil, origin: false)\n        if query_stats_enabled?\n          limit ||= 100\n          sort ||= \"total_minutes\"\n          total_time = server_version_num >= 130000 ? \"(total_plan_time + total_exec_time)\" : \"total_time\"\n          query = <<~SQL\n            WITH query_stats AS (\n              SELECT\n                LEFT(query, 10000) AS query,\n                #{supports_query_hash? ? \"queryid\" : \"md5(query)\"} AS query_hash,\n                rolname AS user,\n                (#{total_time} / 1000 / 60) AS total_minutes,\n                (#{total_time} / calls) AS average_time,\n                calls\n              FROM\n                pg_stat_statements\n              INNER JOIN\n                pg_database ON pg_database.oid = pg_stat_statements.dbid\n              INNER JOIN\n                pg_roles ON pg_roles.oid = pg_stat_statements.userid\n              WHERE\n                calls > 0 AND\n                pg_database.datname = #{database ? quote(database) : \"current_database()\"}\n                #{query_hash ? \"AND queryid = #{quote(query_hash)}\" : nil}\n                #{user ? \"AND rolname = #{quote(user)}\" : nil}\n            )\n            SELECT\n              query,\n              query AS explainable_query,\n              #{origin ? \"(SELECT regexp_matches(query, '.*/\\\\*(.+?)\\\\*/'))[1] AS origin,\" : nil}\n              query_hash,\n              query_stats.user,\n              total_minutes,\n              average_time,\n              calls,\n              total_minutes * 100.0 / (SELECT SUM(total_minutes) FROM query_stats) AS total_percent,\n              (SELECT SUM(total_minutes) FROM query_stats) AS all_queries_total_minutes\n            FROM\n              query_stats\n            ORDER BY\n              #{quote_column_name(sort)} DESC\n            LIMIT #{limit.to_i}\n          SQL\n\n          # we may be able to skip query_columns\n          # in more recent versions of Postgres\n          # as pg_stat_statements should be already normalized\n          select_all(query, query_columns: [:query, :explainable_query])\n        else\n          raise NotEnabled, \"Query stats not enabled\"\n        end\n      end\n\n      def historical_query_stats(sort: nil, start_at: nil, end_at: nil, query_hash: nil)\n        if historical_query_stats_enabled?\n          sort ||= \"total_minutes\"\n          query = <<~SQL\n            WITH query_stats AS (\n              SELECT\n                #{supports_query_hash? ? \"query_hash\" : \"md5(query)\"} AS query_hash,\n                pghero_query_stats.user AS user,\n                array_agg(LEFT(query, 10000) ORDER BY REPLACE(LEFT(query, 1000), '?', '!') COLLATE \"C\" ASC) AS query,\n                (SUM(total_time) / 1000 / 60) AS total_minutes,\n                (SUM(total_time) / SUM(calls)) AS average_time,\n                SUM(calls) AS calls\n              FROM\n                pghero_query_stats\n              WHERE\n                database = #{quote(id)}\n                #{supports_query_hash? ? \"AND query_hash IS NOT NULL\" : \"\"}\n                #{start_at ? \"AND captured_at >= #{quote(start_at)}\" : \"\"}\n                #{end_at ? \"AND captured_at <= #{quote(end_at)}\" : \"\"}\n                #{query_hash ? \"AND query_hash = #{quote(query_hash)}\" : \"\"}\n              GROUP BY\n                1, 2\n            )\n            SELECT\n              query_hash,\n              query_stats.user,\n              query[1] AS query,\n              query[array_length(query, 1)] AS explainable_query,\n              total_minutes,\n              average_time,\n              calls,\n              total_minutes * 100.0 / (SELECT SUM(total_minutes) FROM query_stats) AS total_percent,\n              (SELECT SUM(total_minutes) FROM query_stats) AS all_queries_total_minutes\n            FROM\n              query_stats\n            ORDER BY\n              #{quote_column_name(sort)} DESC\n            LIMIT 100\n          SQL\n\n          # we can skip query_columns if all stored data is normalized\n          # for now, assume it's not\n          select_all_stats(query, query_columns: [:query, :explainable_query])\n        else\n          raise NotEnabled, \"Historical query stats not enabled\"\n        end\n      end\n\n      def combine_query_stats(grouped_stats)\n        query_stats = []\n        grouped_stats.each do |_, stats2|\n          value = {\n            query: (stats2.find { |s| s[:query] } || {})[:query],\n            user: (stats2.find { |s| s[:user] } || {})[:user],\n            query_hash: (stats2.find { |s| s[:query_hash] } || {})[:query_hash],\n            total_minutes: stats2.sum { |s| s[:total_minutes] },\n            calls: stats2.sum { |s| s[:calls] }.to_i,\n            all_queries_total_minutes: stats2.sum { |s| s[:all_queries_total_minutes] }\n          }\n          value[:total_percent] = value[:total_minutes] * 100.0 / value[:all_queries_total_minutes]\n          value[:explainable_query] = stats2.map { |s| s[:explainable_query] }.find { |q| q && explainable?(q) }\n          query_stats << value\n        end\n        query_stats\n      end\n\n      def explainable?(query)\n        query =~ /select/i && (server_version_num >= 160000 || (!query.include?(\"?)\") && !query.include?(\"= ?\") && !query.include?(\"$1\") && query !~ /limit \\?/i))\n      end\n\n      # removes comments\n      # combines ?, ?, ? => ?\n      def normalize_query(query)\n        squish(query.to_s.gsub(/\\?(, ?\\?)+/, \"?\").gsub(/\\/\\*.+?\\*\\//, \"\"))\n      end\n\n      def insert_query_stats(db_id, db_query_stats, now)\n        values =\n          db_query_stats.map do |qs|\n            {\n              database: db_id,\n              query: qs[:query],\n              total_time: qs[:total_minutes] * 60 * 1000,\n              calls: qs[:calls],\n              captured_at: now,\n              query_hash: supports_query_hash? ? qs[:query_hash] : nil,\n              user: qs[:user]\n            }\n          end\n        PgHero::QueryStats.insert_all!(values)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/replication.rb",
    "content": "module PgHero\n  module Methods\n    module Replication\n      def replica?\n        unless defined?(@replica)\n          @replica = select_one(\"SELECT pg_is_in_recovery()\")\n        end\n        @replica\n      end\n\n      # https://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com\n      def replication_lag\n        with_feature_support(:replication_lag) do\n          lag_condition =\n            if server_version_num >= 100000\n              \"pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn()\"\n            else\n              \"pg_last_xlog_receive_location() = pg_last_xlog_replay_location()\"\n            end\n\n          select_one <<~SQL\n            SELECT\n              CASE\n                WHEN NOT pg_is_in_recovery() OR #{lag_condition} THEN 0\n                ELSE EXTRACT (EPOCH FROM NOW() - pg_last_xact_replay_timestamp())\n              END\n            AS replication_lag\n          SQL\n        end\n      end\n\n      def replication_slots\n        if server_version_num >= 90400\n          with_feature_support(:replication_slots, []) do\n            select_all <<~SQL\n              SELECT\n                slot_name,\n                database,\n                active\n              FROM pg_replication_slots\n            SQL\n          end\n        else\n          []\n        end\n      end\n\n      def replicating?\n        with_feature_support(:replicating?, false) do\n          select_all(\"SELECT state FROM pg_stat_replication\").any?\n        end\n      end\n\n      private\n\n      def feature_support\n        @feature_support ||= {}\n      end\n\n      def with_feature_support(cache_key, default = nil)\n        # cache feature support to minimize errors in logs\n        return default if feature_support[cache_key] == false\n\n        begin\n          yield\n        rescue ActiveRecord::StatementInvalid => e\n          raise unless e.message.start_with?(\"PG::FeatureNotSupported:\")\n          feature_support[cache_key] = false\n          default\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/sequences.rb",
    "content": "module PgHero\n  module Methods\n    module Sequences\n      def sequences\n        # get columns with default values\n        # use pg_get_expr to get correct default value\n        # it's what information_schema.columns uses\n        # also, exclude temporary tables to prevent error\n        # when accessing across sessions\n        sequences = select_all <<~SQL\n          SELECT\n            n.nspname AS table_schema,\n            c.relname AS table,\n            attname AS column,\n            format_type(a.atttypid, a.atttypmod) AS column_type,\n            pg_get_expr(d.adbin, d.adrelid) AS default_value\n          FROM\n            pg_catalog.pg_attribute a\n          INNER JOIN\n            pg_catalog.pg_class c ON c.oid = a.attrelid\n          INNER JOIN\n            pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n          INNER JOIN\n            pg_catalog.pg_attrdef d ON (a.attrelid, a.attnum) = (d.adrelid,  d.adnum)\n          WHERE\n            NOT a.attisdropped\n            AND a.attnum > 0\n            AND pg_get_expr(d.adbin, d.adrelid) LIKE 'nextval%'\n            AND n.nspname NOT LIKE 'pg\\\\_temp\\\\_%'\n        SQL\n\n        # parse out sequence\n        sequences.each do |column|\n          column[:max_value] = column[:column_type] == 'integer' ? 2147483647 : 9223372036854775807\n\n          column[:schema], column[:sequence] = parse_default_value(column[:default_value])\n          column.delete(:default_value) if column[:sequence]\n        end\n\n        add_sequence_attributes(sequences)\n\n        last_value = {}\n        sequences.select { |s| s[:readable] }.map { |s| [s[:schema], s[:sequence]] }.uniq.each_slice(1024) do |slice|\n          sql = slice.map { |s| \"SELECT last_value FROM #{quote_ident(s[0])}.#{quote_ident(s[1])}\" }.join(\" UNION ALL \")\n\n          select_all(sql).zip(slice) do |row, seq|\n            last_value[seq] = row[:last_value]\n          end\n        end\n\n        sequences.select { |s| s[:readable] }.each do |seq|\n          seq[:last_value] = last_value[[seq[:schema], seq[:sequence]]]\n        end\n\n        # use to_s for unparsable sequences\n        sequences.sort_by { |s| s[:sequence].to_s }\n      end\n\n      def sequence_danger(threshold: 0.9, sequences: nil)\n        sequences ||= self.sequences\n        sequences.select { |s| s[:last_value] && s[:last_value] / s[:max_value].to_f > threshold }.sort_by { |s| s[:max_value] - s[:last_value] }\n      end\n\n      private\n\n      # can parse\n      # nextval('id_seq'::regclass)\n      # nextval(('id_seq'::text)::regclass)\n      def parse_default_value(default_value)\n        m = /^nextval\\('(.+)'\\:\\:regclass\\)$/.match(default_value)\n        m = /^nextval\\(\\('(.+)'\\:\\:text\\)\\:\\:regclass\\)$/.match(default_value) unless m\n        if m\n          unquote_ident(m[1])\n        else\n          []\n        end\n      end\n\n      def unquote_ident(value)\n        schema, seq = value.split(\".\")\n        unless seq\n          seq = schema\n          schema = nil\n        end\n        [unquote(schema), unquote(seq)]\n      end\n\n      # adds readable attribute to all sequences\n      # also adds schema if missing\n      def add_sequence_attributes(sequences)\n        # fetch data\n        sequence_attributes = select_all <<~SQL\n          SELECT\n            n.nspname AS schema,\n            c.relname AS sequence,\n            has_sequence_privilege(c.oid, 'SELECT') AS readable\n          FROM\n            pg_class c\n          INNER JOIN\n            pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n          WHERE\n            c.relkind = 'S'\n            AND n.nspname NOT IN ('pg_catalog', 'information_schema')\n        SQL\n\n        # first populate missing schemas\n        missing_schema = sequences.select { |s| s[:schema].nil? && s[:sequence] }\n        if missing_schema.any?\n          sequence_schemas = sequence_attributes.group_by { |s| s[:sequence] }\n\n          missing_schema.each do |sequence|\n            schemas = sequence_schemas[sequence[:sequence]] || []\n\n            if schemas.size == 1\n              sequence[:schema] = schemas[0][:schema]\n            end\n            # otherwise, do nothing, will be marked as unreadable\n            # TODO better message for multiple schemas\n          end\n        end\n\n        # then populate attributes\n        readable = sequence_attributes.to_h { |s| [[s[:schema], s[:sequence]], s[:readable]] }\n        sequences.each do |sequence|\n          sequence[:readable] = readable[[sequence[:schema], sequence[:sequence]]] || false\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/settings.rb",
    "content": "module PgHero\n  module Methods\n    module Settings\n      def settings\n        names =\n          if server_version_num >= 100000\n            %i(\n              max_connections shared_buffers effective_cache_size maintenance_work_mem\n              checkpoint_completion_target wal_buffers default_statistics_target\n              random_page_cost effective_io_concurrency work_mem huge_pages\n              min_wal_size max_wal_size\n            )\n          elsif server_version_num >= 90500\n            %i(\n              max_connections shared_buffers effective_cache_size work_mem\n              maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target\n              wal_buffers default_statistics_target\n            )\n          else\n            %i(\n              max_connections shared_buffers effective_cache_size work_mem\n              maintenance_work_mem checkpoint_segments checkpoint_completion_target\n              wal_buffers default_statistics_target\n            )\n          end\n        fetch_settings(names)\n      end\n\n      def autovacuum_settings\n        fetch_settings %i(autovacuum autovacuum_max_workers autovacuum_vacuum_cost_limit autovacuum_vacuum_scale_factor autovacuum_analyze_scale_factor)\n      end\n\n      def vacuum_settings\n        fetch_settings %i(vacuum_cost_limit)\n      end\n\n      private\n\n      def fetch_settings(names)\n        names.to_h { |name| [name, select_one(\"SHOW #{name}\")] }\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/space.rb",
    "content": "module PgHero\n  module Methods\n    module Space\n      def database_size\n        PgHero.pretty_size select_one(\"SELECT pg_database_size(current_database())\")\n      end\n\n      def relation_sizes\n        select_all_size <<~SQL\n          SELECT\n            n.nspname AS schema,\n            c.relname AS relation,\n            CASE c.relkind WHEN 'r' THEN 'table' WHEN 'm' then 'matview' ELSE 'index' END AS type,\n            pg_table_size(c.oid) AS size_bytes\n          FROM\n            pg_class c\n          LEFT JOIN\n            pg_namespace n ON n.oid = c.relnamespace\n          WHERE\n            n.nspname NOT IN ('pg_catalog', 'information_schema')\n            AND n.nspname !~ '^pg_toast'\n            AND c.relkind IN ('r', 'm', 'i')\n          ORDER BY\n            pg_table_size(c.oid) DESC,\n            2 ASC\n        SQL\n      end\n\n      def table_sizes\n        select_all_size <<~SQL\n          SELECT\n            n.nspname AS schema,\n            c.relname AS table,\n            pg_total_relation_size(c.oid) AS size_bytes\n          FROM\n            pg_class c\n          LEFT JOIN\n            pg_namespace n ON n.oid = c.relnamespace\n          WHERE\n            n.nspname NOT IN ('pg_catalog', 'information_schema')\n            AND n.nspname !~ '^pg_toast'\n            AND c.relkind = 'r'\n          ORDER BY\n            pg_total_relation_size(c.oid) DESC,\n            2 ASC\n        SQL\n      end\n\n      def space_growth(days: 7, relation_sizes: nil)\n        if space_stats_enabled?\n          relation_sizes ||= self.relation_sizes\n          sizes = relation_sizes.to_h { |r| [[r[:schema], r[:relation]], r[:size_bytes]] }\n          start_at = days.days.ago\n\n          stats = select_all_stats <<~SQL\n            WITH t AS (\n              SELECT\n                schema,\n                relation,\n                array_agg(size ORDER BY captured_at) AS sizes\n              FROM\n                pghero_space_stats\n              WHERE\n                database = #{quote(id)}\n                AND captured_at >= #{quote(start_at)}\n              GROUP BY\n                1, 2\n            )\n            SELECT\n              schema,\n              relation,\n              sizes[1] AS size_bytes\n            FROM\n              t\n            ORDER BY\n              1, 2\n          SQL\n\n          stats.each do |r|\n            relation = [r[:schema], r[:relation]]\n            if sizes[relation]\n              r[:growth_bytes] = sizes[relation] - r[:size_bytes]\n            end\n            r.delete(:size_bytes)\n          end\n          stats\n        else\n          raise NotEnabled, \"Space stats not enabled\"\n        end\n      end\n\n      def relation_space_stats(relation, schema: \"public\")\n        if space_stats_enabled?\n          relation_sizes ||= self.relation_sizes\n          sizes = relation_sizes.map { |r| [[r[:schema], r[:relation]], r[:size_bytes]] }.to_h\n          start_at = 30.days.ago\n\n          stats = select_all_stats <<~SQL\n            SELECT\n              captured_at,\n              size AS size_bytes\n            FROM\n              pghero_space_stats\n            WHERE\n              database = #{quote(id)}\n              AND captured_at >= #{quote(start_at)}\n              AND schema = #{quote(schema)}\n              AND relation = #{quote(relation)}\n            ORDER BY\n              1 ASC\n          SQL\n\n          stats << {\n            captured_at: Time.now,\n            size_bytes: sizes[[schema, relation]].to_i\n          }\n        else\n          raise NotEnabled, \"Space stats not enabled\"\n        end\n      end\n\n      def capture_space_stats\n        now = Time.now\n        values =\n          relation_sizes.map do |rs|\n            {\n              database: id,\n              schema: rs[:schema],\n              relation: rs[:relation],\n              size: rs[:size_bytes].to_i,\n              captured_at: now\n            }\n          end\n        PgHero::SpaceStats.insert_all!(values) if values.any?\n      end\n\n      def clean_space_stats(before: nil)\n        before ||= 90.days.ago\n        PgHero::SpaceStats.where(database: id).where(\"captured_at < ?\", before).delete_all\n      end\n\n      def space_stats_enabled?\n        table_exists?(\"pghero_space_stats\")\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/suggested_indexes.rb",
    "content": "module PgHero\n  module Methods\n    module SuggestedIndexes\n      def suggested_indexes_enabled?\n        defined?(PgQuery) && Gem::Version.new(PgQuery::VERSION) >= Gem::Version.new(\"2\") && query_stats_enabled?\n      end\n\n      # TODO clean this mess\n      def suggested_indexes_by_query(queries: nil, query_stats: nil, indexes: nil)\n        best_indexes = {}\n\n        if suggested_indexes_enabled?\n          # get most time-consuming queries\n          queries ||= (query_stats || self.query_stats(historical: true, start_at: 24.hours.ago)).map { |qs| qs[:query] }\n\n          # get best indexes for queries\n          best_indexes = best_index_helper(queries)\n\n          if best_indexes.any?\n            existing_columns = Hash.new { |hash, key| hash[key] = Hash.new { |hash2, key2| hash2[key2] = [] } }\n            indexes ||= self.indexes\n            indexes.group_by { |g| g[:using] }.each do |group, inds|\n              inds.each do |i|\n                existing_columns[group][i[:table]] << i[:columns]\n              end\n            end\n            indexes_by_table = indexes.group_by { |i| i[:table] }\n\n            best_indexes.each do |_query, best_index|\n              if best_index[:found]\n                index = best_index[:index]\n                best_index[:table_indexes] = indexes_by_table[index[:table]].to_a\n\n                # indexes of same type\n                indexes = existing_columns[index[:using] || \"btree\"][index[:table]]\n\n                if best_index[:structure][:sort].empty?\n                  # gist indexes without an opclass\n                  # (opclass is part of column name, so columns won't match if opclass present)\n                  indexes += existing_columns[\"gist\"][index[:table]]\n\n                  # hash indexes work for equality\n                  indexes += existing_columns[\"hash\"][index[:table]] if best_index[:structure][:where].all? { |v| v[:op] == \"=\" }\n\n                  # brin indexes work for all\n                  indexes += existing_columns[\"brin\"][index[:table]]\n                end\n\n                covering_index = indexes.find { |e| index_covers?(e.map { |v| v.delete_suffix(\" inet_ops\") }, index[:columns]) }\n                if covering_index\n                  best_index[:covering_index] = covering_index\n                  best_index[:explanation] = \"Covered by index on (#{covering_index.join(\", \")})\"\n                end\n              end\n            end\n          end\n        else\n          raise NotEnabled, \"Suggested indexes not enabled\"\n        end\n\n        best_indexes\n      end\n\n      def suggested_indexes(suggested_indexes_by_query: nil, **options)\n        indexes = []\n\n        (suggested_indexes_by_query || self.suggested_indexes_by_query(**options)).select { |_s, i| i[:found] && !i[:covering_index] }.group_by { |_s, i| i[:index] }.each do |index, group|\n          details = {}\n          group.map(&:second).each do |g|\n            details = details.except(:index).deep_merge(g)\n          end\n          indexes << index.merge(queries: group.map(&:first), details: details)\n        end\n\n        indexes.sort_by { |i| [i[:table], i[:columns]] }\n      end\n\n      def autoindex(create: false)\n        suggested_indexes.each do |index|\n          p index\n          if create\n            with_connection do |connection|\n              connection.execute(\"CREATE INDEX CONCURRENTLY ON #{quote_table_name(index[:table])} (#{index[:columns].map { |c| quote_column_name(c) }.join(\",\")})\")\n            end\n          end\n        end\n      end\n\n      def best_index(statement)\n        best_index_helper([statement])[statement]\n      end\n\n      private\n\n      def best_index_helper(statements)\n        indexes = {}\n\n        # see if this is a query we understand and can use\n        parts = {}\n        statements.each do |statement|\n          parts[statement] = best_index_structure(statement)\n        end\n\n        # get stats about columns for relevant tables\n        tables = parts.values.map { |t| t[:table] }.uniq\n        # TODO get schema from query structure, then try search path\n        schema = PgHero.connection_config(connection_model)[:schema] || \"public\"\n        if tables.any?\n          row_stats = table_stats(table: tables, schema: schema).to_h { |i| [i[:table], i[:estimated_rows]] }\n          col_stats = column_stats(table: tables, schema: schema).group_by { |i| i[:table] }\n        end\n\n        # find best index based on query structure and column stats\n        parts.each do |statement, structure|\n          index = {found: false}\n\n          if structure[:error]\n            index[:explanation] = structure[:error]\n          elsif structure[:table].start_with?(\"pg_\")\n            index[:explanation] = \"System table\"\n          else\n            index[:structure] = structure\n\n            table = structure[:table]\n            where = structure[:where].uniq\n            sort = structure[:sort]\n\n            total_rows = row_stats[table].to_i\n            index[:rows] = total_rows\n\n            ranks = col_stats[table].to_a.to_h { |r| [r[:column], r] }\n            columns = (where + sort).map { |c| c[:column] }.uniq\n\n            if columns.any?\n              if columns.all? { |c| ranks[c] }\n                first_desc = sort.index { |c| c[:direction] == \"desc\" }\n                sort = sort.first(first_desc + 1) if first_desc\n                where = where.sort_by { |c| [row_estimates(ranks[c[:column]], total_rows, total_rows, c[:op]), c[:column]] } + sort\n\n                index[:row_estimates] = where.to_h { |c| [\"#{c[:column]} (#{c[:op] || \"sort\"})\", row_estimates(ranks[c[:column]], total_rows, total_rows, c[:op]).round] }\n\n                # no index needed if less than 500 rows\n                if total_rows >= 500\n\n                  if [\"~~\", \"~~*\"].include?(where.first[:op])\n                    index[:found] = true\n                    index[:row_progression] = [total_rows, index[:row_estimates].values.first]\n                    index[:index] = {table: table, columns: [\"#{where.first[:column]} gist_trgm_ops\"], using: \"gist\"}\n                  else\n                    # if most values are unique, no need to index others\n                    rows_left = total_rows\n                    final_where = []\n                    prev_rows_left = [rows_left]\n                    where.reject { |c| [\"~~\", \"~~*\"].include?(c[:op]) }.each do |c|\n                      next if final_where.include?(c[:column])\n                      final_where << c[:column]\n                      rows_left = row_estimates(ranks[c[:column]], total_rows, rows_left, c[:op])\n                      prev_rows_left << rows_left\n                      if rows_left < 50 || final_where.size >= 2 || [\">\", \">=\", \"<\", \"<=\", \"~~\", \"~~*\", \"BETWEEN\"].include?(c[:op])\n                        break\n                      end\n                    end\n\n                    index[:row_progression] = prev_rows_left.map(&:round)\n\n                    # if the last indexes don't give us much, don't include\n                    prev_rows_left.reverse!\n                    (prev_rows_left.size - 1).times do |i|\n                      if prev_rows_left[i] > prev_rows_left[i + 1] * 0.3\n                        final_where.pop\n                      else\n                        break\n                      end\n                    end\n\n                    if final_where.any?\n                      index[:found] = true\n                      index[:index] = {table: table, columns: final_where}\n                    end\n                  end\n                else\n                  index[:explanation] = \"No index needed if less than 500 rows\"\n                end\n              else\n                index[:explanation] = \"Stats not found\"\n              end\n            else\n              index[:explanation] = \"No columns to index\"\n            end\n          end\n\n          indexes[statement] = index\n        end\n\n        indexes\n      end\n\n      def best_index_structure(statement)\n        return {error: \"Empty statement\"} if statement.to_s.empty?\n        return {error: \"Too large\"} if statement.to_s.length > 10000\n\n        begin\n          tree = PgQuery.parse(statement).tree\n        rescue PgQuery::ParseError\n          return {error: \"Parse error\"}\n        end\n\n        return {error: \"Unknown structure\"} unless tree.stmts.size == 1\n\n        tree = tree.stmts.first.stmt\n\n        table = parse_table(tree) rescue nil\n        unless table\n          error =\n            case tree.node\n            when :insert_stmt\n              \"INSERT statement\"\n            when :variable_set_stmt\n              \"SET statement\"\n            when :select_stmt\n              if (tree.select_stmt.from_clause.first.join_expr rescue false)\n                \"JOIN not supported yet\"\n              end\n            end\n          return {error: error || \"Unknown structure\"}\n        end\n\n        select = tree[tree.node.to_s]\n        where = (select.where_clause ? parse_where(select.where_clause) : []) rescue nil\n        return {error: \"Unknown structure\"} unless where\n\n        sort = (select.sort_clause ? parse_sort(select.sort_clause) : []) rescue []\n\n        {table: table, where: where, sort: sort}\n      end\n\n      # TODO better row estimation\n      # https://www.postgresql.org/docs/current/static/row-estimation-examples.html\n      def row_estimates(stats, total_rows, rows_left, op)\n        case op\n        when \"null\"\n          rows_left * stats[:null_frac].to_f\n        when \"not_null\"\n          rows_left * (1 - stats[:null_frac].to_f)\n        else\n          rows_left *= (1 - stats[:null_frac].to_f)\n          ret =\n            if stats[:n_distinct].to_f == 0\n              0\n            elsif stats[:n_distinct].to_f < 0\n              if total_rows > 0\n                (-1 / stats[:n_distinct].to_f) * (rows_left / total_rows.to_f)\n              else\n                0\n              end\n            else\n              rows_left / stats[:n_distinct].to_f\n            end\n\n          case op\n          when \">\", \">=\", \"<\", \"<=\", \"~~\", \"~~*\", \"BETWEEN\"\n            (rows_left + ret) / 10.0 # TODO better approximation\n          when \"<>\"\n            rows_left - ret\n          else\n            ret\n          end\n        end\n      end\n\n      def parse_table(tree)\n        case tree.node\n        when :select_stmt\n          tree.select_stmt.from_clause.first.range_var.relname\n        when :delete_stmt\n          tree.delete_stmt.relation.relname\n        when :update_stmt\n          tree.update_stmt.relation.relname\n        end\n      end\n\n      # TODO capture values\n      def parse_where(tree)\n        aexpr = tree.a_expr\n\n        if tree.bool_expr\n          if tree.bool_expr.boolop == :AND_EXPR\n            tree.bool_expr.args.flat_map { |v| parse_where(v) }\n          else\n            raise \"Not Implemented\"\n          end\n        elsif aexpr && [\"=\", \"<>\", \">\", \">=\", \"<\", \"<=\", \"~~\", \"~~*\", \"BETWEEN\"].include?(aexpr.name.first.string.send(str_method))\n          [{column: aexpr.lexpr.column_ref.fields.last.string.send(str_method), op: aexpr.name.first.string.send(str_method)}]\n        elsif tree.null_test\n          op = tree.null_test.nulltesttype == :IS_NOT_NULL ? \"not_null\" : \"null\"\n          [{column: tree.null_test.arg.column_ref.fields.last.string.send(str_method), op: op}]\n        else\n          raise \"Not Implemented\"\n        end\n      end\n\n      def str_method\n        @str_method ||= Gem::Version.new(PgQuery::VERSION) >= Gem::Version.new(\"4\") ? :sval : :str\n      end\n\n      def parse_sort(sort_clause)\n        sort_clause.map do |v|\n          {\n            column: v.sort_by.node.column_ref.fields.last.string.send(str_method),\n            direction: v.sort_by.sortby_dir == :SORTBY_DESC ? \"desc\" : \"asc\"\n          }\n        end\n      end\n\n      def column_stats(schema: nil, table: nil)\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            tablename AS table,\n            attname AS column,\n            null_frac,\n            n_distinct\n          FROM\n            pg_stats\n          WHERE\n            schemaname = #{quote(schema)}\n            #{table ? \"AND tablename IN (#{Array(table).map { |t| quote(t) }.join(\", \")})\" : \"\"}\n          ORDER BY\n            1, 2, 3\n        SQL\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/system.rb",
    "content": "module PgHero\n  module Methods\n    module System\n      def system_stats_enabled?\n        !system_stats_provider.nil?\n      end\n\n      def system_stats_provider\n        if aws_db_instance_identifier\n          :aws\n        elsif gcp_database_id\n          :gcp\n        elsif azure_resource_id\n          :azure\n        end\n      end\n\n      def cpu_usage(**options)\n        system_stats(:cpu, **options)\n      end\n\n      def connection_stats(**options)\n        system_stats(:connections, **options)\n      end\n\n      def replication_lag_stats(**options)\n        system_stats(:replication_lag, **options)\n      end\n\n      def read_iops_stats(**options)\n        system_stats(:read_iops, **options)\n      end\n\n      def write_iops_stats(**options)\n        system_stats(:write_iops, **options)\n      end\n\n      def free_space_stats(**options)\n        system_stats(:free_space, **options)\n      end\n\n      def rds_stats(metric_name, duration: nil, period: nil, offset: nil, series: false)\n        if system_stats_enabled?\n          aws_options = {region: aws_region}\n          if aws_access_key_id\n            aws_options[:access_key_id] = aws_access_key_id\n            aws_options[:secret_access_key] = aws_secret_access_key\n          end\n\n          client = Aws::CloudWatch::Client.new(aws_options)\n\n          duration = (duration || 1.hour).to_i\n          period = (period || 1.minute).to_i\n          offset = (offset || 0).to_i\n          end_time = Time.at(((Time.now - offset).to_f / period).ceil * period)\n          start_time = end_time - duration\n\n          resp = client.get_metric_statistics(\n            namespace: \"AWS/RDS\",\n            metric_name: metric_name,\n            dimensions: [{name: \"DBInstanceIdentifier\", value: aws_db_instance_identifier}],\n            start_time: start_time.iso8601,\n            end_time: end_time.iso8601,\n            period: period,\n            statistics: [\"Average\"]\n          )\n          data = {}\n          resp[:datapoints].sort_by { |d| d[:timestamp] }.each do |d|\n            data[d[:timestamp]] = d[:average]\n          end\n\n          add_missing_data(data, start_time, end_time, period) if series\n\n          data\n        else\n          raise NotEnabled, \"System stats not enabled\"\n        end\n      end\n\n      def azure_stats(metric_name, duration: nil, period: nil, offset: nil, series: false)\n        # TODO DRY with RDS stats\n        duration = (duration || 1.hour).to_i\n        period = (period || 1.minute).to_i\n        offset = (offset || 0).to_i\n        end_time = Time.at(((Time.now - offset).to_f / period).ceil * period)\n        start_time = end_time - duration\n\n        interval =\n          case period\n          when 60\n            \"PT1M\"\n          when 300\n            \"PT5M\"\n          when 900\n            \"PT15M\"\n          when 1800\n            \"PT30M\"\n          when 3600\n            \"PT1H\"\n          else\n            raise Error, \"Unsupported period\"\n          end\n\n        client = Azure::Monitor::Profiles::Latest::Mgmt::Client.new\n        # call utc to convert +00:00 to Z\n        timespan = \"#{start_time.utc.iso8601}/#{end_time.utc.iso8601}\"\n        results = client.metrics.list(\n          azure_resource_id,\n          metricnames: metric_name,\n          aggregation: \"Average\",\n          timespan: timespan,\n          interval: interval\n        )\n\n        data = {}\n        result = results.value.first\n        if result\n          result.timeseries.first.data.each do |point|\n            data[point.time_stamp.to_time] = point.average\n          end\n        end\n\n        add_missing_data(data, start_time, end_time, period) if series\n\n        data\n      end\n\n      private\n\n      def gcp_stats(metric_name, duration: nil, period: nil, offset: nil, series: false)\n        # TODO DRY with RDS stats\n        duration = (duration || 1.hour).to_i\n        period = (period || 1.minute).to_i\n        offset = (offset || 0).to_i\n        end_time = Time.at(((Time.now - offset).to_f / period).ceil * period)\n        start_time = end_time - duration\n\n        # validate input since we need to interpolate below\n        raise Error, \"Invalid metric name\" unless /\\A[a-z\\/_]+\\z/i.match?(metric_name)\n        raise Error, \"Invalid database id\" unless /\\A[a-z0-9\\-:]+\\z/i.match?(gcp_database_id)\n\n        # we handle four situations:\n        # 1. google-cloud-monitoring-v3\n        # 2. google-cloud-monitoring >= 1\n        # 3. google-cloud-monitoring < 1\n        # 4. google-apis-monitoring_v3\n        begin\n          require \"google/cloud/monitoring/v3\"\n        rescue LoadError\n          begin\n            require \"google/cloud/monitoring\"\n          rescue LoadError\n            require \"google/apis/monitoring_v3\"\n          end\n        end\n\n        # for situations 1 and 2\n        # Google::Cloud::Monitoring.metric_service is documented\n        # but doesn't work for situation 1\n        if defined?(Google::Cloud::Monitoring::V3::MetricService::Client)\n          client = Google::Cloud::Monitoring::V3::MetricService::Client.new\n\n          interval = Google::Cloud::Monitoring::V3::TimeInterval.new\n          interval.end_time = Google::Protobuf::Timestamp.new(seconds: end_time.to_i)\n          # subtract period to make sure we get first data point\n          interval.start_time = Google::Protobuf::Timestamp.new(seconds: (start_time - period).to_i)\n\n          aggregation = Google::Cloud::Monitoring::V3::Aggregation.new\n          # may be better to use ALIGN_NEXT_OLDER for space stats to show most recent data point\n          # stick with average for now to match AWS\n          aggregation.per_series_aligner = Google::Cloud::Monitoring::V3::Aggregation::Aligner::ALIGN_MEAN\n          aggregation.alignment_period = period\n\n          results = client.list_time_series({\n            name: \"projects/#{gcp_database_id.split(\":\").first}\",\n            filter: \"metric.type = \\\"cloudsql.googleapis.com/database/#{metric_name}\\\" AND resource.label.database_id = \\\"#{gcp_database_id}\\\"\",\n            interval: interval,\n            view: Google::Cloud::Monitoring::V3::ListTimeSeriesRequest::TimeSeriesView::FULL,\n            aggregation: aggregation\n          })\n        elsif defined?(Google::Cloud::Monitoring)\n          require \"google/cloud/monitoring\"\n\n          client = Google::Cloud::Monitoring::Metric.new\n\n          interval = Google::Monitoring::V3::TimeInterval.new\n          interval.end_time = Google::Protobuf::Timestamp.new(seconds: end_time.to_i)\n          # subtract period to make sure we get first data point\n          interval.start_time = Google::Protobuf::Timestamp.new(seconds: (start_time - period).to_i)\n\n          aggregation = Google::Monitoring::V3::Aggregation.new\n          # may be better to use ALIGN_NEXT_OLDER for space stats to show most recent data point\n          # stick with average for now to match AWS\n          aggregation.per_series_aligner = Google::Monitoring::V3::Aggregation::Aligner::ALIGN_MEAN\n          aggregation.alignment_period = period\n\n          results = client.list_time_series(\n            \"projects/#{gcp_database_id.split(\":\").first}\",\n            \"metric.type = \\\"cloudsql.googleapis.com/database/#{metric_name}\\\" AND resource.label.database_id = \\\"#{gcp_database_id}\\\"\",\n            interval,\n            Google::Monitoring::V3::ListTimeSeriesRequest::TimeSeriesView::FULL,\n            aggregation: aggregation\n          )\n        else\n          client = Google::Apis::MonitoringV3::MonitoringService.new\n\n          scope = Google::Apis::MonitoringV3::AUTH_MONITORING_READ\n          client.authorization = Google::Auth.get_application_default([scope])\n\n          # default logging is very verbose, but use app default\n          results = client.list_project_time_series(\n            \"projects/#{gcp_database_id.split(\":\").first}\",\n            filter: \"metric.type = \\\"cloudsql.googleapis.com/database/#{metric_name}\\\" AND resource.label.database_id = \\\"#{gcp_database_id}\\\"\",\n            interval_start_time: (start_time - period).iso8601,\n            interval_end_time: end_time.iso8601,\n            view: 0, # full\n            aggregation_alignment_period: \"#{period}s\",\n            aggregation_per_series_aligner: 12 # mean\n          ).time_series\n        end\n\n        data = {}\n        result = results.first\n        if result\n          result.points.each do |point|\n            time = point.interval.start_time\n            # string with google-apis-monitoring_v3\n            time = time.is_a?(String) ? Time.parse(time) : Time.at(time.seconds)\n            value = point.value.double_value\n            value *= 100 if metric_name == \"cpu/utilization\"\n            data[time] = value\n          end\n        end\n\n        add_missing_data(data, start_time, end_time, period) if series\n\n        data\n      end\n\n      def system_stats(metric_key, **options)\n        case system_stats_provider\n        when :aws\n          metrics = {\n            cpu: \"CPUUtilization\",\n            connections: \"DatabaseConnections\",\n            replication_lag: \"ReplicaLag\",\n            read_iops: \"ReadIOPS\",\n            write_iops: \"WriteIOPS\",\n            free_space: \"FreeStorageSpace\"\n          }\n          rds_stats(metrics[metric_key], **options)\n        when :gcp\n          if metric_key == :free_space\n            quota = gcp_stats(\"disk/quota\", **options)\n            used = gcp_stats(\"disk/bytes_used\", **options)\n            free_space(quota, used)\n          else\n            metrics = {\n              cpu: \"cpu/utilization\",\n              connections: \"postgresql/num_backends\",\n              replication_lag: \"replication/replica_lag\",\n              read_iops: \"disk/read_ops_count\",\n              write_iops: \"disk/write_ops_count\"\n            }\n            gcp_stats(metrics[metric_key], **options)\n          end\n        when :azure\n          if metric_key == :free_space\n            quota = azure_stats(\"storage_limit\", **options)\n            used = azure_stats(\"storage_used\", **options)\n            free_space(quota, used)\n          else\n            replication_lag_stat = azure_flexible_server? ? \"physical_replication_delay_in_seconds\" : \"pg_replica_log_delay_in_seconds\"\n            metrics = {\n              cpu: \"cpu_percent\",\n              connections: \"active_connections\",\n              replication_lag: replication_lag_stat,\n              read_iops: \"read_iops\", # flexible server only\n              write_iops: \"write_iops\" # flexible server only\n            }\n            raise Error, \"Metric not supported\" unless metrics[metric_key]\n            azure_stats(metrics[metric_key], **options)\n          end\n        else\n          raise NotEnabled, \"System stats not enabled\"\n        end\n      end\n\n      def azure_flexible_server?\n        azure_resource_id.include?(\"/Microsoft.DBforPostgreSQL/flexibleServers/\")\n      end\n\n      # only use data points included in both series\n      # this also eliminates need to align Time.now\n      def free_space(quota, used)\n        data = {}\n        quota.each do |k, v|\n          data[k] = v - used[k] if v && used[k]\n        end\n        data\n      end\n\n      def add_missing_data(data, start_time, end_time, period)\n        time = start_time\n        while time < end_time\n          data[time] ||= nil\n          time += period\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/tables.rb",
    "content": "module PgHero\n  module Methods\n    module Tables\n      def table_hit_rate\n        select_one <<~SQL\n          SELECT\n            sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read), 0) AS rate\n          FROM\n            pg_statio_user_tables\n        SQL\n      end\n\n      def table_caching\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            CASE WHEN heap_blks_hit + heap_blks_read = 0 THEN\n              0\n            ELSE\n              ROUND(1.0 * heap_blks_hit / (heap_blks_hit + heap_blks_read), 2)\n            END AS hit_rate\n          FROM\n            pg_statio_user_tables\n          ORDER BY\n            2 DESC, 1\n        SQL\n      end\n\n      def unused_tables\n        select_all <<~SQL\n          SELECT\n            schemaname AS schema,\n            relname AS table,\n            n_live_tup AS estimated_rows\n          FROM\n            pg_stat_user_tables\n          WHERE\n            idx_scan = 0\n          ORDER BY\n            n_live_tup DESC,\n            relname ASC\n         SQL\n      end\n\n      def table_stats(schema: nil, table: nil)\n        select_all <<~SQL\n          SELECT\n            nspname AS schema,\n            relname AS table,\n            reltuples::bigint AS estimated_rows,\n            pg_total_relation_size(pg_class.oid) AS size_bytes\n          FROM\n            pg_class\n          INNER JOIN\n            pg_namespace ON pg_namespace.oid = pg_class.relnamespace\n          WHERE\n            relkind = 'r'\n            #{schema ? \"AND nspname = #{quote(schema)}\" : nil}\n            #{table ? \"AND relname IN (#{Array(table).map { |t| quote(t) }.join(\", \")})\" : nil}\n          ORDER BY\n            1, 2\n        SQL\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/methods/users.rb",
    "content": "module PgHero\n  module Methods\n    module Users\n      # documented as unsafe to pass user input\n      # identifiers are now quoted, but still not officially supported\n      def create_user(user, password: nil, schema: \"public\", database: nil, readonly: false, tables: nil)\n        password ||= random_password\n        database ||= PgHero.connection_config(connection_model)[:database]\n\n        user = quote_ident(user)\n        schema = quote_ident(schema)\n        database = quote_ident(database)\n\n        commands =\n          [\n            \"CREATE ROLE #{user} LOGIN PASSWORD #{quote(password)}\",\n            \"GRANT CONNECT ON DATABASE #{database} TO #{user}\",\n            \"GRANT USAGE ON SCHEMA #{schema} TO #{user}\"\n          ]\n        if readonly\n          if tables\n            commands.concat table_grant_commands(\"SELECT\", tables, user)\n          else\n            commands << \"GRANT SELECT ON ALL TABLES IN SCHEMA #{schema} TO #{user}\"\n            commands << \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT SELECT ON TABLES TO #{user}\"\n          end\n        else\n          if tables\n            commands.concat table_grant_commands(\"ALL PRIVILEGES\", tables, user)\n          else\n            commands << \"GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{schema} TO #{user}\"\n            commands << \"GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA #{schema} TO #{user}\"\n            commands << \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT ALL PRIVILEGES ON TABLES TO #{user}\"\n            commands << \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT ALL PRIVILEGES ON SEQUENCES TO #{user}\"\n          end\n        end\n\n        # run commands\n        connection_model.transaction do\n          commands.each do |command|\n            execute command\n          end\n        end\n\n        {password: password}\n      end\n\n      # documented as unsafe to pass user input\n      # identifiers are now quoted, but still not officially supported\n      def drop_user(user, schema: \"public\", database: nil)\n        database ||= PgHero.connection_config(connection_model)[:database]\n\n        user = quote_ident(user)\n        schema = quote_ident(schema)\n        database = quote_ident(database)\n\n        # thanks shiftb\n        commands =\n          [\n            \"REVOKE CONNECT ON DATABASE #{database} FROM #{user}\",\n            \"REVOKE USAGE ON SCHEMA #{schema} FROM #{user}\",\n            \"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{schema} FROM #{user}\",\n            \"REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA #{schema} FROM #{user}\",\n            \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE SELECT ON TABLES FROM #{user}\",\n            \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE SELECT ON SEQUENCES FROM #{user}\",\n            \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE ALL ON SEQUENCES FROM #{user}\",\n            \"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE ALL ON TABLES FROM #{user}\",\n            \"DROP ROLE #{user}\"\n          ]\n\n        # run commands\n        connection_model.transaction do\n          commands.each do |command|\n            execute command\n          end\n        end\n\n        true\n      end\n\n      private\n\n      def random_password\n        require \"securerandom\"\n        SecureRandom.base64(40).delete(\"+/=\")[0...24]\n      end\n\n      def table_grant_commands(privilege, tables, quoted_user)\n        tables.map do |table|\n          \"GRANT #{privilege} ON TABLE #{quote_ident(table)} TO #{quoted_user}\"\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/pghero/query_stats.rb",
    "content": "module PgHero\n  class QueryStats < Stats\n    self.table_name = \"pghero_query_stats\"\n  end\nend\n"
  },
  {
    "path": "lib/pghero/space_stats.rb",
    "content": "module PgHero\n  class SpaceStats < Stats\n    self.table_name = \"pghero_space_stats\"\n  end\nend\n"
  },
  {
    "path": "lib/pghero/stats.rb",
    "content": "module PgHero\n  class Stats < ActiveRecord::Base\n    self.abstract_class = true\n    establish_connection PgHero.stats_database_url if PgHero.stats_database_url\n  end\nend\n"
  },
  {
    "path": "lib/pghero/version.rb",
    "content": "module PgHero\n  VERSION = \"3.7.0\"\nend\n"
  },
  {
    "path": "lib/pghero.rb",
    "content": "# dependencies\nrequire \"active_support\"\n\n# stdlib\nrequire \"forwardable\"\n\n# methods\nrequire_relative \"pghero/methods/basic\"\nrequire_relative \"pghero/methods/connections\"\nrequire_relative \"pghero/methods/constraints\"\nrequire_relative \"pghero/methods/explain\"\nrequire_relative \"pghero/methods/indexes\"\nrequire_relative \"pghero/methods/kill\"\nrequire_relative \"pghero/methods/maintenance\"\nrequire_relative \"pghero/methods/queries\"\nrequire_relative \"pghero/methods/query_stats\"\nrequire_relative \"pghero/methods/replication\"\nrequire_relative \"pghero/methods/sequences\"\nrequire_relative \"pghero/methods/settings\"\nrequire_relative \"pghero/methods/space\"\nrequire_relative \"pghero/methods/suggested_indexes\"\nrequire_relative \"pghero/methods/system\"\nrequire_relative \"pghero/methods/tables\"\nrequire_relative \"pghero/methods/users\"\n\nrequire_relative \"pghero/database\"\nrequire_relative \"pghero/engine\" if defined?(Rails)\nrequire_relative \"pghero/version\"\n\nmodule PgHero\n  autoload :Connection, \"pghero/connection\"\n  autoload :Stats, \"pghero/stats\"\n  autoload :QueryStats, \"pghero/query_stats\"\n  autoload :SpaceStats, \"pghero/space_stats\"\n\n  class Error < StandardError; end\n  class NotEnabled < Error; end\n\n  MUTEX = Mutex.new\n\n  # settings\n  class << self\n    attr_accessor :long_running_query_sec, :slow_query_ms, :slow_query_calls, :explain_timeout_sec, :total_connections_threshold, :cache_hit_rate_threshold, :env, :show_migrations, :config_path, :filter_data\n  end\n  self.long_running_query_sec = (ENV[\"PGHERO_LONG_RUNNING_QUERY_SEC\"] || 60).to_i\n  self.slow_query_ms = (ENV[\"PGHERO_SLOW_QUERY_MS\"] || 20).to_i\n  self.slow_query_calls = (ENV[\"PGHERO_SLOW_QUERY_CALLS\"] || 100).to_i\n  self.explain_timeout_sec = (ENV[\"PGHERO_EXPLAIN_TIMEOUT_SEC\"] || 10).to_f\n  self.total_connections_threshold = (ENV[\"PGHERO_TOTAL_CONNECTIONS_THRESHOLD\"] || 500).to_i\n  self.cache_hit_rate_threshold = 99\n  self.env = ENV[\"RAILS_ENV\"] || ENV[\"RACK_ENV\"] || \"development\"\n  self.show_migrations = true\n  self.config_path = ENV[\"PGHERO_CONFIG_PATH\"] || \"config/pghero.yml\"\n  self.filter_data = ENV[\"PGHERO_FILTER_DATA\"].to_s.size > 0\n\n  class << self\n    extend Forwardable\n    def_delegators :primary_database, :aws_access_key_id, :analyze, :analyze_tables, :autoindex, :autovacuum_danger,\n      :best_index, :blocked_queries, :connections, :connection_sources, :connection_states, :connection_stats,\n      :cpu_usage, :create_user, :database_size, :aws_db_instance_identifier, :disable_query_stats, :drop_user,\n      :duplicate_indexes, :enable_query_stats, :explain, :historical_query_stats_enabled?, :index_caching,\n      :index_hit_rate, :index_usage, :indexes, :invalid_constraints, :invalid_indexes, :kill, :kill_all, :kill_long_running_queries,\n      :last_stats_reset_time, :long_running_queries, :maintenance_info, :missing_indexes, :query_stats,\n      :query_stats_available?, :query_stats_enabled?, :query_stats_extension_enabled?, :query_stats_readable?,\n      :rds_stats, :read_iops_stats, :aws_region, :relation_sizes, :replica?, :replication_lag, :replication_lag_stats,\n      :reset_query_stats, :reset_stats, :running_queries, :aws_secret_access_key, :sequence_danger, :sequences, :settings,\n      :slow_queries, :space_growth, :ssl_used?, :suggested_indexes, :suggested_indexes_by_query,\n      :suggested_indexes_enabled?, :system_stats_enabled?, :table_caching, :table_hit_rate, :table_stats,\n      :total_connections, :transaction_id_danger, :unused_indexes, :unused_tables, :write_iops_stats\n\n    def time_zone=(time_zone)\n      @time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]\n    end\n\n    def time_zone\n      @time_zone || Time.zone\n    end\n\n    # use method instead of attr_accessor to ensure\n    # this works if variable set after PgHero is loaded\n    def username\n      @username ||= (file_config || {})[\"username\"] || ENV[\"PGHERO_USERNAME\"]\n    end\n\n    # use method instead of attr_accessor to ensure\n    # this works if variable set after PgHero is loaded\n    def password\n      @password ||= (file_config || {})[\"password\"] || ENV[\"PGHERO_PASSWORD\"]\n    end\n\n    # config pattern for https://github.com/ankane/pghero/issues/424\n    def stats_database_url\n      @stats_database_url ||= (file_config || {})[\"stats_database_url\"] || ENV[\"PGHERO_STATS_DATABASE_URL\"]\n    end\n\n    # private\n    def explain_enabled?\n      explain_mode.nil? || explain_mode == true || explain_mode == \"analyze\"\n    end\n\n    # private\n    def explain_mode\n      @config[\"explain\"]\n    end\n\n    def visualize_url\n      @visualize_url ||= config[\"visualize_url\"] || ENV[\"PGHERO_VISUALIZE_URL\"] || \"https://tatiyants.com/pev/#/plans/new\"\n    end\n\n    def config\n      @config ||= file_config || default_config\n    end\n\n    # private\n    def file_config\n      unless defined?(@file_config)\n        require \"erb\"\n        require \"yaml\"\n\n        path = config_path\n\n        config_file_exists = File.exist?(path)\n\n        config = YAML.safe_load(ERB.new(File.read(path)).result, aliases: true) if config_file_exists\n        config ||= {}\n\n        @file_config =\n          if config[env]\n            config[env]\n          elsif config[\"databases\"] # preferred format\n            config\n          elsif config_file_exists\n            raise \"Invalid config file\"\n          else\n            nil\n          end\n      end\n\n      @file_config\n    end\n\n    # private\n    def default_config\n      databases = {}\n\n      unless ENV[\"PGHERO_DATABASE_URL\"]\n        ActiveRecord::Base.configurations.configs_for(env_name: env, include_replicas_key => true).each do |db|\n          databases[db.send(spec_name_key)] = {\"spec\" => db.send(spec_name_key)}\n        end\n      end\n\n      if databases.empty?\n        databases[\"primary\"] = {\n          \"url\" => ENV[\"PGHERO_DATABASE_URL\"]\n        }\n      end\n\n      if databases.size == 1\n        databases.values.first.merge!(\n          \"aws_db_instance_identifier\" => ENV[\"PGHERO_DB_INSTANCE_IDENTIFIER\"],\n          \"gcp_database_id\" => ENV[\"PGHERO_GCP_DATABASE_ID\"],\n          \"azure_resource_id\" => ENV[\"PGHERO_AZURE_RESOURCE_ID\"]\n        )\n      end\n\n      {\n        \"databases\" => databases\n      }\n    end\n\n    # ensure we only have one copy of databases\n    # so there's only one connection pool per database\n    def databases\n      unless defined?(@databases)\n        # only use mutex on initialization\n        MUTEX.synchronize do\n          # return if another process initialized while we were waiting\n          return @databases if defined?(@databases)\n\n          @databases = config[\"databases\"].map { |id, c| [id.to_sym, Database.new(id, c)] }.to_h\n        end\n      end\n\n      @databases\n    end\n\n    def primary_database\n      databases.values.first\n    end\n\n    def capture_query_stats(verbose: false)\n      each_database do |database|\n        next unless database.capture_query_stats?\n        puts \"Capturing query stats for #{database.id}...\" if verbose\n        database.capture_query_stats(raise_errors: true)\n      end\n    end\n\n    def capture_space_stats(verbose: false)\n      each_database do |database|\n        puts \"Capturing space stats for #{database.id}...\" if verbose\n        database.capture_space_stats\n      end\n    end\n\n    def analyze_all(**options)\n      each_database do |database|\n        next if database.replica?\n        database.analyze_tables(**options)\n      end\n    end\n\n    def autoindex_all(create: false, verbose: true)\n      each_database do |database|\n        puts \"Autoindexing #{database.id}...\" if verbose\n        database.autoindex(create: create)\n      end\n    end\n\n    def pretty_size(value)\n      ActiveSupport::NumberHelper.number_to_human_size(value, precision: 3)\n    end\n\n    # delete previous stats\n    # go database by database to use an index\n    # stats for old databases are not cleaned up since we can't use an index\n    def clean_query_stats(before: nil)\n      each_database do |database|\n        database.clean_query_stats(before: before)\n      end\n    end\n\n    def clean_space_stats(before: nil)\n      each_database do |database|\n        database.clean_space_stats(before: before)\n      end\n    end\n\n    # private\n    def connection_config(model)\n      model.connection_db_config.configuration_hash\n    end\n\n    # private\n    def spec_name_key\n      :name\n    end\n\n    # private\n    def include_replicas_key\n      :include_hidden\n    end\n\n    private\n\n    def each_database\n      first_error = nil\n\n      databases.each do |_, database|\n        begin\n          yield database\n        rescue => e\n          puts \"#{e.class.name}: #{e.message}\"\n          puts\n          first_error ||= e\n        end\n      end\n\n      raise first_error if first_error\n\n      true\n    end\n  end\nend\n"
  },
  {
    "path": "lib/tasks/pghero.rake",
    "content": "namespace :pghero do\n  desc \"Capture query stats\"\n  task capture_query_stats: :environment do\n    PgHero.capture_query_stats(verbose: true)\n  end\n\n  desc \"Capture space stats\"\n  task capture_space_stats: :environment do\n    PgHero.capture_space_stats(verbose: true)\n  end\n\n  desc \"Analyze tables\"\n  task analyze: :environment do\n    PgHero.analyze_all(verbose: true, min_size: ENV[\"MIN_SIZE_GB\"].to_f.gigabytes)\n  end\n\n  desc \"Autoindex tables\"\n  task autoindex: :environment do\n    PgHero.autoindex_all(verbose: true, create: true)\n  end\n\n  desc \"Remove old query stats\"\n  task clean_query_stats: :environment do\n    puts \"Deleting old query stats...\"\n    options = {}\n    options[:before] = Float(ENV[\"KEEP_DAYS\"]).days.ago if ENV[\"KEEP_DAYS\"].present?\n    PgHero.clean_query_stats(**options)\n  end\n\n  desc \"Remove old space stats\"\n  task clean_space_stats: :environment do\n    puts \"Deleting old space stats...\"\n    options = {}\n    options[:before] = Float(ENV[\"KEEP_DAYS\"]).days.ago if ENV[\"KEEP_DAYS\"].present?\n    PgHero.clean_space_stats(**options)\n  end\nend\n"
  },
  {
    "path": "licenses/LICENSE-chart.js.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014-2022 Chart.js Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-chartjs-adapter-date-fns.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2019 Chart.js Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-chartkick.js.txt",
    "content": "Copyright (c) 2013-2021 Andrew Kane\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-date-fns.txt",
    "content": "MIT License\n\nCopyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-highlight.js.txt",
    "content": "BSD 3-Clause License\n\nCopyright (c) 2006, Ivan Sagalaev.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\n* Neither the name of the copyright holder nor the names of its\n  contributors may be used to endorse or promote products derived from\n  this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "licenses/LICENSE-jquery.txt",
    "content": "Copyright OpenJS Foundation and other contributors, https://openjsf.org/\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-kurkle-color.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2018-2021 Jukka Kurkela\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/LICENSE-nouislider.txt",
    "content": "MIT License\n\nCopyright (c) 2019 Léon Gersen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "pghero.gemspec",
    "content": "require_relative \"lib/pghero/version\"\n\nGem::Specification.new do |spec|\n  spec.name          = \"pghero\"\n  spec.version       = PgHero::VERSION\n  spec.summary       = \"A performance dashboard for Postgres\"\n  spec.homepage      = \"https://github.com/ankane/pghero\"\n  spec.license       = \"MIT\"\n\n  spec.author        = \"Andrew Kane\"\n  spec.email         = \"andrew@ankane.org\"\n\n  spec.files         = Dir[\"*.{md,txt}\", \"{app,config,lib,licenses}/**/*\"]\n  spec.require_path  = \"lib\"\n\n  spec.required_ruby_version = \">= 3.2\"\n\n  spec.add_dependency \"activerecord\", \">= 7.1\"\nend\n"
  },
  {
    "path": "test/basic_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass BasicTest < Minitest::Test\n  def test_ssl_used?\n    refute database.ssl_used?\n  end\n\n  def test_database_name\n    assert_equal \"pghero_test\", database.database_name\n  end\n\n  def test_server_version\n    assert_kind_of String, database.server_version\n  end\n\n  def test_server_version_num\n    assert_kind_of Integer, database.server_version_num\n  end\nend\n"
  },
  {
    "path": "test/best_index_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass BestIndexTest < Minitest::Test\n  def test_where\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id = 1\"\n  end\n\n  def test_all_values\n    index = database.best_index(\"SELECT * FROM users WHERE login_attempts = 1 ORDER BY created_at\")\n    expected = {\n      found: true,\n      structure: {table: \"users\", where: [{column: \"login_attempts\", op: \"=\"}], sort: [{column: \"created_at\", direction: \"asc\"}]},\n      index: {table: \"users\", columns: [\"login_attempts\", \"created_at\"]},\n      rows: 5000,\n      row_estimates: {\"login_attempts (=)\" => 167, \"created_at (sort)\" => 1},\n      row_progression: [5000, 167, 0]\n    }\n    assert_equal expected, index\n  end\n\n  def test_where_multiple_columns\n    assert_best_index ({table: \"users\", columns: [\"city_id\", \"login_attempts\"]}), \"SELECT * FROM users WHERE city_id = 1 and login_attempts = 2\"\n  end\n\n  def test_where_unique\n    assert_best_index ({table: \"users\", columns: [\"email\"]}), \"SELECT * FROM users WHERE city_id = 1 AND email = 'person2@example.org'\"\n  end\n\n  def test_order\n    assert_best_index ({table: \"users\", columns: [\"created_at\"]}), \"SELECT * FROM users ORDER BY created_at\"\n  end\n\n  def test_order_multiple\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\", \"created_at\"]}), \"SELECT * FROM users ORDER BY login_attempts, created_at\"\n  end\n\n  def test_order_multiple_direction\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\"]}), \"SELECT * FROM users ORDER BY login_attempts DESC, created_at\"\n  end\n\n  def test_order_multiple_unique\n    assert_best_index ({table: \"users\", columns: [\"id\"]}), \"SELECT * FROM users ORDER BY id, created_at\"\n  end\n\n  def test_where_unique_order\n    assert_best_index ({table: \"users\", columns: [\"email\"]}), \"SELECT * FROM users WHERE email = 'person2@example.org' ORDER BY created_at\"\n  end\n\n  def test_where_order\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\", \"created_at\"]}), \"SELECT * FROM users WHERE login_attempts = 1 ORDER BY created_at\"\n  end\n\n  def test_where_order_unknown\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\"]}), \"SELECT * FROM users WHERE login_attempts = 1 ORDER BY NOW()\"\n  end\n\n  def test_where_in\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id IN (1, 2)\"\n  end\n\n  def test_like\n    assert_best_index ({table: \"users\", columns: [\"email gist_trgm_ops\"], using: \"gist\"}), \"SELECT * FROM users WHERE email LIKE $1\"\n  end\n\n  def test_like_where\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id = $1 AND email LIKE $2\"\n  end\n\n  def test_like_where2\n    assert_best_index ({table: \"users\", columns: [\"email gist_trgm_ops\"], using: \"gist\"}), \"SELECT * FROM users WHERE email LIKE $1 AND active = $2\"\n  end\n\n  def test_ilike\n    assert_best_index ({table: \"users\", columns: [\"email gist_trgm_ops\"], using: \"gist\"}), \"SELECT * FROM users WHERE email ILIKE $1\"\n  end\n\n  def test_not_equals\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\"]}), \"SELECT * FROM users WHERE city_id != $1 and login_attempts = 2\"\n  end\n\n  def test_not_in\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\"]}), \"SELECT * FROM users WHERE city_id NOT IN ($1) and login_attempts = 2\"\n  end\n\n  def test_between\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id BETWEEN 1 AND 2\"\n  end\n\n  def test_multiple_range\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id > $1 and login_attempts > $2\"\n  end\n\n  def test_where_prepared\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id = $1\"\n  end\n\n  def test_where_normalized\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"SELECT * FROM users WHERE city_id = $1\"\n  end\n\n  def test_is_null\n    assert_best_index ({table: \"users\", columns: [\"zip_code\"]}), \"SELECT * FROM users WHERE zip_code IS NULL\"\n  end\n\n  def test_is_null_equal\n    assert_best_index ({table: \"users\", columns: [\"zip_code\", \"login_attempts\"]}), \"SELECT * FROM users WHERE zip_code IS NULL AND login_attempts = $1\"\n  end\n\n  def test_is_not_null\n    assert_best_index ({table: \"users\", columns: [\"login_attempts\"]}), \"SELECT * FROM users WHERE zip_code IS NOT NULL AND login_attempts = $1\"\n  end\n\n  def test_update\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"UPDATE users SET email = 'test' WHERE city_id = 1\"\n  end\n\n  def test_delete\n    assert_best_index ({table: \"users\", columns: [\"city_id\"]}), \"DELETE FROM users WHERE city_id = 1\"\n  end\n\n  def test_parse_error\n    assert_no_index \"Parse error\", \"SELECT *123'\"\n  end\n\n  def test_stats_not_found\n    assert_no_index \"Stats not found\", \"SELECT * FROM non_existent_table WHERE id = 1\"\n  end\n\n  def test_unknown_structure\n    assert_no_index \"Unknown structure\", \"SELECT NOW()\"\n  end\n\n  def test_where_or\n    assert_no_index \"Unknown structure\", \"SELECT FROM users WHERE login_attempts = 0 OR login_attempts = 1\"\n  end\n\n  def test_where_nested_or\n    assert_no_index \"Unknown structure\", \"SELECT FROM users WHERE city_id = 1 AND (login_attempts = 0 OR login_attempts = 1)\"\n  end\n\n  def test_multiple_tables\n    assert_no_index \"JOIN not supported yet\", \"SELECT * FROM users INNER JOIN cities ON cities.id = users.city_id\"\n  end\n\n  def test_no_columns\n    assert_no_index \"No columns to index\", \"SELECT * FROM users\"\n  end\n\n  def test_small_table\n    assert_no_index \"No index needed if less than 500 rows\", \"SELECT * FROM states WHERE name = 'State 1'\"\n  end\n\n  def test_system_table\n    assert_no_index \"System table\", \"SELECT COUNT(*) AS count FROM pg_extension WHERE extname = $1\"\n  end\n\n  def test_insert\n    assert_no_index \"INSERT statement\", \"INSERT INTO users (login_attempts) VALUES (1)\"\n  end\n\n  def test_set\n    assert_no_index \"SET statement\", \"set client_encoding to 'UTF8'\"\n  end\n\n  def test_empty_statement\n    assert_no_index \"Empty statement\", nil\n  end\n\n  protected\n\n  def assert_best_index(expected, statement)\n    index = database.best_index(statement)\n    assert_nil index[:explanation]\n    assert index[:found]\n    assert_equal expected, index[:index]\n  end\n\n  def assert_no_index(explanation, statement)\n    index = database.best_index(statement)\n    assert !index[:found]\n    assert_equal explanation, index[:explanation]\n  end\nend\n"
  },
  {
    "path": "test/config_generator_test.rb",
    "content": "require_relative \"test_helper\"\n\nrequire \"generators/pghero/config_generator\"\n\nclass ConfigGeneratorTest < Rails::Generators::TestCase\n  tests Pghero::Generators::ConfigGenerator\n  destination File.expand_path(\"../tmp\", __dir__)\n  setup :prepare_destination\n\n  def test_works\n    run_generator\n    assert_file \"config/pghero.yml\", /databases/\n  end\nend\n"
  },
  {
    "path": "test/connections_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ConnectionsTest < Minitest::Test\n  def test_connections\n    assert_kind_of Array, database.connections\n  end\n\n  def test_total_connections\n    assert_kind_of Integer, database.total_connections\n  end\n\n  def test_connection_states\n    assert_kind_of Hash, database.connection_states\n  end\n\n  def test_connection_sources\n    assert_kind_of Array, database.connection_sources\n  end\nend\n"
  },
  {
    "path": "test/constraints_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ConstraintsTest < Minitest::Test\n  def test_invalid_constraints\n    assert_equal [], database.invalid_constraints\n  end\nend\n"
  },
  {
    "path": "test/controller_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ControllerTest < ActionDispatch::IntegrationTest\n  def test_index\n    get pg_hero.root_path\n    assert_response :success\n  end\n\n  def test_space\n    get pg_hero.space_path\n    assert_response :success\n  end\n\n  def test_relation_space\n    get pg_hero.relation_space_path(relation: \"users\")\n    assert_response :success\n  end\n\n  def test_index_bloat\n    get pg_hero.index_bloat_path\n    assert_response :success\n  end\n\n  def test_live_queries\n    get pg_hero.live_queries_path\n    assert_response :success\n  end\n\n  def test_queries\n    get pg_hero.queries_path\n    assert_response :success\n  end\n\n  def test_show_query\n    get pg_hero.show_query_path(query_hash: 123)\n    assert_response :not_found\n  end\n\n  def test_system\n    get pg_hero.system_path\n    assert_response :success\n  end\n\n  def test_explain\n    get pg_hero.explain_path\n    assert_response :success\n  end\n\n  def test_explain_not_enabled\n    with_explain(false) do\n      get pg_hero.explain_path\n    end\n    assert_response :bad_request\n    assert_match \"Explain not enabled\", response.body\n  end\n\n  def test_explain_only\n    post pg_hero.explain_path, params: {query: \"SELECT 1\"}\n    assert_response :success\n    assert_match \"Result  (cost=0.00..0.01 rows=1 width=4)\", response.body\n    refute_match(/Planning Time/i, response.body)\n    refute_match(/Execution Time/i, response.body)\n  end\n\n  def test_explain_only_normalized\n    post pg_hero.explain_path, params: {query: \"SELECT $1\"}\n    assert_response :success\n    if explain_normalized?\n      assert_match \"Result  (cost=0.00..0.01 rows=1 width=32)\", response.body\n      refute_match(/Planning Time/i, response.body)\n      refute_match(/Execution Time/i, response.body)\n    else\n      assert_match \"Can&#39;t explain queries with bind parameters\", response.body\n    end\n  end\n\n  def test_explain_only_not_enabled\n    with_explain(false) do\n      post pg_hero.explain_path, params: {query: \"SELECT 1\"}\n    end\n    assert_response :bad_request\n    assert_match \"Explain not enabled\", response.body\n  end\n\n  def test_explain_only_analyze\n    post pg_hero.explain_path, params: {query: \"ANALYZE SELECT 1\"}\n    assert_response :success\n    assert_match \"Syntax error with query\", response.body\n    refute_match(/Planning Time/i, response.body)\n    refute_match(/Execution Time/i, response.body)\n  end\n\n  def test_explain_analyze\n    with_explain(\"analyze\") do\n      post pg_hero.explain_path, params: {query: \"SELECT 1\", commit: \"Analyze\"}\n    end\n    assert_response :success\n    assert_match \"(actual time=\", response.body\n    assert_match(/Planning Time/i, response.body)\n    assert_match(/Execution Time/i, response.body)\n  end\n\n  def test_explain_analyze_normalized\n    with_explain(\"analyze\") do\n      post pg_hero.explain_path, params: {query: \"SELECT $1\", commit: \"Analyze\"}\n    end\n    assert_response :success\n    if explain_normalized?\n      assert_match \"Can&#39;t analyze queries with bind parameters\", response.body\n    else\n      assert_match \"Can&#39;t explain queries with bind parameters\", response.body\n    end\n  end\n\n  def test_explain_analyze_timeout\n    with_explain(\"analyze\") do\n      with_explain_timeout(0.01) do\n        post pg_hero.explain_path, params: {query: \"SELECT pg_sleep(1)\", commit: \"Analyze\"}\n      end\n    end\n    assert_response :success\n    assert_match \"Query timed out\", response.body\n  end\n\n  def test_explain_analyze_not_enabled\n    post pg_hero.explain_path, params: {query: \"SELECT 1\", commit: \"Analyze\"}\n    assert_response :bad_request\n    assert_match \"Explain analyze not enabled\", response.body\n  end\n\n  def test_explain_visualize\n    post pg_hero.explain_path, params: {query: \"SELECT 1\", commit: \"Visualize\"}\n    assert_response :success\n    assert_match \"https://tatiyants.com/pev/#/plans/new\", response.body\n    assert_match \"&quot;Node Type&quot;: &quot;Result&quot;\", response.body\n    refute_match \"Actual Total Time\", response.body\n  end\n\n  def test_explain_visualize_analyze\n    with_explain(\"analyze\") do\n      post pg_hero.explain_path, params: {query: \"SELECT 1\", commit: \"Visualize\"}\n    end\n    assert_response :success\n    assert_match \"https://tatiyants.com/pev/#/plans/new\", response.body\n    assert_match \"&quot;Node Type&quot;: &quot;Result&quot;\", response.body\n    assert_match \"Actual Total Time\", response.body\n  end\n\n  def test_explain_visualize_normalized\n    with_explain(\"analyze\") do\n      post pg_hero.explain_path, params: {query: \"SELECT $1\", commit: \"Visualize\"}\n    end\n    assert_response :success\n\n    if explain_normalized?\n      assert_match \"https://tatiyants.com/pev/#/plans/new\", response.body\n      assert_match \"&quot;Node Type&quot;: &quot;Result&quot;\", response.body\n      refute_match \"Actual Total Time\", response.body\n    else\n      assert_match \"Can&#39;t explain queries with bind parameters\", response.body\n    end\n  end\n\n  def test_tune\n    get pg_hero.tune_path\n    assert_response :success\n  end\n\n  def test_connections\n    get pg_hero.connections_path\n    assert_response :success\n  end\n\n  def test_maintenance\n    get pg_hero.maintenance_path\n    assert_response :success\n  end\n\n  # prevent warning for now\n  # def test_kill\n  #   post pg_hero.kill_path(pid: 1_000_000_000)\n  #   assert_redirected_to \"/\"\n  # end\n\n  def test_reset_query_stats\n    post pg_hero.reset_query_stats_path\n    assert_redirected_to \"/\"\n  end\nend\n"
  },
  {
    "path": "test/database_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass DatabaseTest < Minitest::Test\n  def test_id\n    assert_equal \"primary\", database.id\n  end\n\n  def test_name\n    assert_equal \"Primary\", database.name\n  end\nend\n"
  },
  {
    "path": "test/explain_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ExplainTest < Minitest::Test\n  def setup\n    City.delete_all\n  end\n\n  def test_explain\n    assert_match \"Result\", database.explain(\"SELECT 1\")\n  end\n\n  def test_explain_analyze\n    City.create!\n    assert_equal 1, City.count\n    database.explain(\"ANALYZE DELETE FROM cities\")\n    assert_equal 1, City.count\n  end\n\n  def test_explain_statement_timeout\n    with_explain_timeout(0.1) do\n      # raises ActiveRecord::QueryCanceled in Active Record 5.2+\n      error = assert_raises(ActiveRecord::StatementInvalid) do\n        database.explain(\"ANALYZE SELECT pg_sleep(1)\")\n      end\n      assert_match \"canceling statement due to statement timeout\", error.message\n    end\n  end\n\n  def test_explain_multiple_statements\n    City.create!\n    assert_raises(ActiveRecord::StatementInvalid) { database.explain(\"ANALYZE DELETE FROM cities; DELETE FROM cities; COMMIT\") }\n  end\n\n  def test_explain_v2\n    database.explain_v2(\"SELECT 1\")\n\n    # not affected by explain option\n    with_explain(false) do\n      database.explain_v2(\"SELECT 1\")\n    end\n  end\n\n  def test_explain_v2_analyze\n    database.explain_v2(\"SELECT 1\", analyze: true)\n\n    error = assert_raises(ActiveRecord::StatementInvalid) do\n      database.explain_v2(\"ANALYZE SELECT 1\")\n    end\n    assert_match 'syntax error at or near \"ANALYZE\"', error.message\n\n    # not affected by explain option\n    with_explain(true) do\n      database.explain_v2(\"SELECT 1\", analyze: true)\n    end\n  end\n\n  def test_explain_v2_generic_plan\n    assert_raises(ActiveRecord::StatementInvalid) do\n      database.explain_v2(\"SELECT $1\")\n    end\n\n    if explain_normalized?\n      assert_match \"Result\", database.explain_v2(\"SELECT $1\", generic_plan: true)\n    end\n  end\n\n  def test_explain_v2_format_text\n    assert_match \"Result  (cost=\", database.explain_v2(\"SELECT 1\", format: \"text\")\n  end\n\n  def test_explain_v2_format_json\n    assert_match '\"Node Type\": \"Result\"', database.explain_v2(\"SELECT 1\", format: \"json\")\n  end\n\n  def test_explain_v2_format_xml\n    assert_match \"<Node-Type>Result</Node-Type>\", database.explain_v2(\"SELECT 1\", format: \"xml\")\n  end\n\n  def test_explain_v2_format_yaml\n    assert_match 'Node Type: \"Result\"', database.explain_v2(\"SELECT 1\", format: \"yaml\")\n  end\n\n  def test_explain_v2_format_bad\n    error = assert_raises(ArgumentError) do\n      database.explain_v2(\"SELECT 1\", format: \"bad\")\n    end\n    assert_equal \"Unknown format\", error.message\n  end\nend\n"
  },
  {
    "path": "test/indexes_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass IndexesTest < Minitest::Test\n  def test_index_hit_rate\n    database.index_hit_rate\n    assert true\n  end\n\n  def test_index_caching\n    assert database.index_caching\n  end\n\n  def test_index_usage\n    assert database.index_usage\n  end\n\n  def test_missing_indexes\n    assert database.missing_indexes\n  end\n\n  def test_unused_indexes\n    assert database.unused_indexes\n  end\n\n  def test_reset_stats\n    assert database.reset_stats\n  end\n\n  def test_last_stats_reset_time\n    database.last_stats_reset_time\n    assert true\n  end\n\n  def test_invalid_indexes\n    assert_equal [], database.invalid_indexes\n  end\n\n  def test_indexes\n    assert database.indexes.find { |i| i[:name] == \"cities_pkey\" }\n  end\n\n  def test_duplicate_indexes\n    assert database.duplicate_indexes.find { |i| i[:unneeded_index][:name] == \"index_users_on_id\" }\n  end\n\n  def test_index_bloat\n    assert_equal [], database.index_bloat\n    assert database.index_bloat(min_size: 0).find { |i| i[:index] == \"index_users_on_updated_at\" }\n  end\nend\n"
  },
  {
    "path": "test/internal/app/assets/config/manifest.js",
    "content": ""
  },
  {
    "path": "test/internal/config/database.yml",
    "content": "test:\n  adapter:  postgresql\n  database: pghero_test\n"
  },
  {
    "path": "test/internal/config/routes.rb",
    "content": "Rails.application.routes.draw do\n  mount PgHero::Engine, at: \"/\"\nend\n"
  },
  {
    "path": "test/internal/db/schema.rb",
    "content": "ActiveRecord::Schema.define do\n  enable_extension \"pg_stat_statements\"\n  enable_extension \"pg_trgm\"\n  enable_extension \"ltree\"\n\n  create_table :pghero_query_stats, force: true do |t|\n    t.text :database\n    t.text :user\n    t.text :query\n    t.integer :query_hash, limit: 8\n    t.float :total_time\n    t.integer :calls, limit: 8\n    t.timestamp :captured_at\n    t.index [:database, :captured_at]\n  end\n\n  create_table :pghero_space_stats, force: true do |t|\n    t.text :database\n    t.text :schema\n    t.text :relation\n    t.integer :size, limit: 8\n    t.timestamp :captured_at\n    t.index [:database, :captured_at]\n  end\n\n  create_table :cities, force: true do |t|\n    t.string :name\n  end\n\n  create_table :states, force: true do |t|\n    t.string :name\n  end\n\n  create_table :users, force: :cascade do |t|\n    t.integer :city_id\n    t.integer :login_attempts\n    t.string :email\n    t.string :zip_code\n    t.boolean :active\n    t.string :country\n    t.column :tree_path, :ltree\n    t.column :range, :int4range\n    t.column :last_known_ip, :inet\n    t.column :metadata, :jsonb\n    t.timestamp :created_at\n    t.timestamp :updated_at\n    t.index :id # duplicate index\n    t.index :updated_at\n    t.index :login_attempts, using: :hash\n    t.index \"country gist_trgm_ops\", using: :gist\n    t.index :tree_path, using: :gist\n    t.index :range, using: :gist\n    t.index :created_at, using: :brin\n    t.index \"last_known_ip inet_ops\", using: :gist\n    t.index :metadata, using: :gin\n  end\nend\n"
  },
  {
    "path": "test/kill_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass KillTest < Minitest::Test\n  def test_kill\n    # prevent warning for now\n    # refute database.kill(1_000_000_000)\n  end\n\n  def test_kill_long_running_queries\n    assert database.kill_long_running_queries\n  end\n\n  def test_kill_all\n    # skip for now\n    # assert database.kill_all\n  end\nend\n"
  },
  {
    "path": "test/maintenance_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass MaintenanceTest < Minitest::Test\n  def test_transaction_id_danger\n    assert database.transaction_id_danger(threshold: 10000000000).any?\n    assert_equal [], database.transaction_id_danger\n  end\n\n  def test_autovacuum_danger\n    assert_equal [], database.autovacuum_danger\n  end\n\n  def test_vacuum_progress\n    assert database.vacuum_progress\n  end\n\n  def test_maintenance_info\n    assert database.maintenance_info.find { |v| v[:table] == \"cities\" }\n  end\n\n  def test_analyze\n    assert database.analyze(\"cities\")\n  end\n\n  def test_analyze_tables\n    assert database.analyze_tables\n  end\nend\n"
  },
  {
    "path": "test/module_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ModuleTest < Minitest::Test\n  def test_databases\n    assert PgHero.databases.any?\n  end\n\n  def test_connection_pool\n    1000.times do\n      [:@config, :@databases].each do |var|\n        PgHero.remove_instance_variable(var) if PgHero.instance_variable_defined?(var)\n      end\n\n      threads =\n        2.times.map do\n          Thread.new do\n            PgHero.databases[:primary].instance_variable_get(:@connection_model)\n          end\n        end\n      values = threads.map(&:value)\n      assert_same values.first, values.last\n      refute_nil values.first\n    end\n  end\n\n  def test_analyze_all\n    assert PgHero.analyze_all\n  end\n\n  def test_clean_query_stats\n    assert PgHero.clean_query_stats\n  end\n\n  def test_clean_space_stats\n    assert PgHero.clean_space_stats\n  end\nend\n"
  },
  {
    "path": "test/queries_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass QueriesTest < Minitest::Test\n  def test_running_queries\n    assert database.running_queries\n  end\n\n  def test_filter_data\n    query = \"SELECT pg_sleep(1)\"\n    # TODO manually checkout connection if needed\n    t = Thread.new { ActiveRecord::Base.connection.execute(query) }\n    sleep(0.5)\n\n    assert_equal query, database.running_queries.first[:query]\n\n    with_filter_data do\n      assert_equal \"SELECT pg_sleep($1)\", database.running_queries.first[:query]\n    end\n\n    t.join\n  end\n\n  def test_long_running_queries\n    assert database.long_running_queries\n  end\n\n  def test_blocked_queries\n    assert database.blocked_queries\n  end\n\n  def with_filter_data\n    previous_value = PgHero.filter_data\n    begin\n      PgHero.filter_data = true\n      database.remove_instance_variable(:@filter_data)\n      yield\n    ensure\n      PgHero.filter_data = previous_value\n      database.remove_instance_variable(:@filter_data)\n    end\n  end\nend\n"
  },
  {
    "path": "test/query_stats_generator_test.rb",
    "content": "require_relative \"test_helper\"\n\nrequire \"generators/pghero/query_stats_generator\"\n\nclass QueryStatsGeneratorTest < Rails::Generators::TestCase\n  tests Pghero::Generators::QueryStatsGenerator\n  destination File.expand_path(\"../tmp\", __dir__)\n  setup :prepare_destination\n\n  def test_works\n    run_generator\n    assert_migration \"db/migrate/create_pghero_query_stats.rb\", /create_table :pghero_query_stats/\n  end\nend\n"
  },
  {
    "path": "test/query_stats_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass QueryStatsTest < Minitest::Test\n  def test_query_stats\n    assert database.query_stats\n  end\n\n  def test_query_stats_available\n    assert database.query_stats_available?\n  end\n\n  def test_query_stats_enabled\n    assert database.query_stats_enabled?\n  end\n\n  def test_query_stats_extension_enabled\n    assert database.query_stats_extension_enabled?\n  end\n\n  def test_query_stats_readable?\n    assert database.query_stats_readable?\n  end\n\n  def test_enable_query_stats\n    assert database.disable_query_stats\n    assert database.enable_query_stats\n  end\n\n  def test_reset_query_stats\n    skip unless gte12?\n\n    assert database.reset_query_stats\n  end\n\n  def test_reset_instance_query_stats\n    assert database.reset_instance_query_stats\n  end\n\n  def test_reset_instance_query_stats_database\n    skip unless gte12?\n\n    assert database.reset_query_stats\n    ActiveRecord::Base.connection.select_all(\"SELECT 1\")\n    assert database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n\n    assert database.reset_instance_query_stats(database: database.database_name)\n\n    assert_equal 1, database.query_stats.size\n    refute database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n  end\n\n  def test_reset_instance_query_stats_database_invalid\n    skip unless gte12?\n\n    error = assert_raises(PgHero::Error) do\n      database.reset_instance_query_stats(database: \"pghero_test2\")\n    end\n    assert_equal \"Database not found: pghero_test2\", error.message\n  end\n\n  def test_reset_query_stats_user\n    skip unless gte12?\n\n    assert database.reset_query_stats\n    ActiveRecord::Base.connection.select_all(\"SELECT 1\")\n    assert database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n\n    assert database.reset_query_stats(user: database.current_user)\n\n    assert_equal 1, database.query_stats.size\n    refute database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n  end\n\n  def test_reset_query_stats_user_invalid\n    skip unless gte12?\n\n    error = assert_raises(PgHero::Error) do\n      database.reset_query_stats(user: \"postgres2\")\n    end\n    assert_equal \"User not found: postgres2\", error.message\n  end\n\n  def test_reset_query_stats_query_hash\n    skip unless gte12?\n\n    assert database.reset_query_stats\n    ActiveRecord::Base.connection.select_all(\"SELECT 1\")\n    ActiveRecord::Base.connection.select_all(\"SELECT 1 + 1\")\n\n    assert database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n    assert database.query_stats.any? { |qs| qs[:query] == \"SELECT $1 + $2\" }\n\n    query_hash = database.query_stats.find { |qs| qs[:query] == \"SELECT $1\" }[:query_hash]\n    assert database.reset_query_stats(query_hash: query_hash)\n\n    refute database.query_stats.any? { |qs| qs[:query] == \"SELECT $1\" }\n    assert database.query_stats.any? { |qs| qs[:query] == \"SELECT $1 + $2\" }\n  end\n\n  def test_reset_query_stats_query_hash_invalid\n    skip unless gte12?\n\n    error = assert_raises(PgHero::Error) do\n      database.reset_query_stats(query_hash: 0)\n    end\n    assert_equal \"Invalid query hash: 0\", error.message\n  end\n\n  def test_historical_query_stats_enabled\n    assert database.historical_query_stats_enabled?\n  end\n\n  def test_capture_query_stats\n    PgHero::QueryStats.delete_all\n    refute PgHero::QueryStats.any?\n    assert database.capture_query_stats\n    assert PgHero::QueryStats.any?\n    assert database.query_stats(historical: true)\n  end\n\n  def test_clean_query_stats\n    assert database.clean_query_stats\n  end\n\n  def test_slow_queries\n    assert database.slow_queries\n  end\n\n  def gte12?\n    database.server_version_num >= 120000\n  end\nend\n"
  },
  {
    "path": "test/replication_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass ReplicationTest < Minitest::Test\n  def test_replica\n    refute database.replica?\n  end\n\n  def test_replication_lag\n    assert_equal 0, database.replication_lag\n  end\n\n  def test_replication_slots\n    assert_equal [], database.replication_slots\n  end\n\n  def test_replicating\n    refute database.replicating?\n  end\nend\n"
  },
  {
    "path": "test/sequences_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass SequencesTest < Minitest::Test\n  def test_sequences\n    seq = database.sequences.find { |s| s[:sequence] == \"cities_id_seq\" }\n    assert_equal \"public\", seq[:table_schema]\n    assert_equal \"cities\", seq[:table]\n    assert_equal \"id\", seq[:column]\n    assert_equal \"bigint\", seq[:column_type]\n    assert_equal 9223372036854775807, seq[:max_value]\n    assert_equal \"public\", seq[:schema]\n    assert_equal \"cities_id_seq\", seq[:sequence]\n    assert_equal true, seq[:readable]\n  end\n\n  def test_sequences_last_value\n    last_value = database.sequences.to_h { |s| [s[:sequence], s[:last_value]] }\n    assert_equal 50, last_value[\"states_id_seq\"]\n    assert_equal 5000, last_value[\"users_id_seq\"]\n  end\n\n  def test_sequence_danger\n    assert_equal [], database.sequence_danger\n    assert database.sequence_danger(threshold: 0).find { |s| s[:sequence] == \"cities_id_seq\" }\n  end\nend\n"
  },
  {
    "path": "test/settings_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass SettingsTest < Minitest::Test\n  def test_settings\n    assert database.settings[:max_connections]\n  end\n\n  def test_autovacuum_settings\n    assert_equal \"on\", database.autovacuum_settings[:autovacuum]\n  end\n\n  def test_vacuum_settings\n    assert database.vacuum_settings[:vacuum_cost_limit]\n  end\nend\n"
  },
  {
    "path": "test/space_stats_generator_test.rb",
    "content": "require_relative \"test_helper\"\n\nrequire \"generators/pghero/space_stats_generator\"\n\nclass SpaceStatsGeneratorTest < Rails::Generators::TestCase\n  tests Pghero::Generators::SpaceStatsGenerator\n  destination File.expand_path(\"../tmp\", __dir__)\n  setup :prepare_destination\n\n  def test_works\n    run_generator\n    assert_migration \"db/migrate/create_pghero_space_stats.rb\", /create_table :pghero_space_stats/\n  end\nend\n"
  },
  {
    "path": "test/space_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass SpaceTest < Minitest::Test\n  def test_database_size\n    assert database.database_size\n  end\n\n  def test_relation_sizes\n    relation_sizes = database.relation_sizes\n    assert relation_sizes.find { |r| r[:relation] == \"users\" && r[:type] == \"table\" }\n    assert relation_sizes.find { |r| r[:relation] == \"users_pkey\" && r[:type] == \"index\" }\n    assert relation_sizes.find { |r| r[:relation] == \"all_users\" && r[:type] == \"matview\" }\n  end\n\n  def test_table_sizes\n    assert database.table_sizes\n  end\n\n  def test_space_growth\n    assert database.space_growth\n  end\n\n  def test_relation_space_stats\n    assert database.relation_space_stats(\"cities\")\n  end\n\n  def test_capture_space_stats\n    PgHero::SpaceStats.delete_all\n    refute PgHero::SpaceStats.any?\n    assert database.capture_space_stats\n    assert PgHero::SpaceStats.any?\n  end\n\n  def test_clean_space_stats\n    assert database.clean_space_stats\n  end\n\n  def test_space_stats_enabled\n    assert database.space_stats_enabled?\n  end\nend\n"
  },
  {
    "path": "test/suggested_indexes_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass SuggestedIndexesTest < Minitest::Test\n  def setup\n    if database.server_version_num >= 120000\n      database.reset_query_stats\n    else\n      database.reset_instance_query_stats\n    end\n  end\n\n  def test_suggested_indexes_enabled\n    assert database.suggested_indexes_enabled?\n  end\n\n  def test_basic\n    User.where(email: \"person1@example.org\").first\n    assert_equal [{table: \"users\", columns: [\"email\"]}], database.suggested_indexes.map { |q| q.except(:queries, :details) }\n  end\n\n  def test_existing_index\n    User.where(\"updated_at > ?\", Time.now).to_a\n    assert_equal [], database.suggested_indexes.map { |q| q.except(:queries, :details) }\n  end\n\n  def test_primary_key\n    query = \"SELECT * FROM users WHERE id = 1\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"id\"], result[:covering_index]\n  end\n\n  def test_hash\n    query = \"SELECT * FROM users WHERE login_attempts = 1\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"login_attempts\"], result[:covering_index]\n  end\n\n  def test_hash_multiple_values\n    query = \"SELECT * FROM users WHERE login_attempts IN (1, 2)\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"login_attempts\"], result[:covering_index]\n  end\n\n  def test_hash_greater_than\n    query = \"SELECT * FROM users WHERE login_attempts > 1\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_nil result[:covering_index]\n  end\n\n  def test_gist_trgm\n    query = \"SELECT * FROM users WHERE country = 'Test 1'\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_nil result[:covering_index]\n  end\n\n  def test_ltree\n    query = \"SELECT * FROM users WHERE tree_path = 'path1'\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"tree_path\"], result[:covering_index]\n  end\n\n  def test_range\n    query = \"SELECT * FROM users WHERE range = '[0, 0]'\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"range\"], result[:covering_index]\n  end\n\n  def test_inet\n    query = \"SELECT * FROM users WHERE last_known_ip = '127.0.0.1'\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"last_known_ip inet_ops\"], result[:covering_index]\n  end\n\n  def test_inet_greater_than\n    query = \"SELECT * FROM users WHERE last_known_ip > '127.0.0.1'\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"last_known_ip inet_ops\"], result[:covering_index]\n  end\n\n  def test_brin\n    query = \"SELECT * FROM users WHERE created_at = NOW()\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_equal [\"created_at\"], result[:covering_index]\n  end\n\n  def test_brin_order\n    query = \"SELECT * FROM users ORDER BY created_at LIMIT 1\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_nil result[:covering_index]\n  end\n\n  def test_gin\n    query = \"SELECT * FROM users WHERE metadata = '{}'::jsonb\"\n    result = database.suggested_indexes_by_query(queries: [query])[query]\n    assert_nil result[:covering_index]\n  end\nend\n"
  },
  {
    "path": "test/system_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass SystemTest < Minitest::Test\n  def test_system_stats_enabled\n    refute database.system_stats_enabled?\n  end\n\n  def test_system_stats_provider\n    assert_nil database.system_stats_provider\n  end\nend\n"
  },
  {
    "path": "test/tables_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass TablesTest < Minitest::Test\n  def test_table_hit_rate\n    database.table_hit_rate\n    assert true\n  end\n\n  def test_table_caching\n    assert database.table_caching\n  end\n\n  def test_unused_tables\n    assert database.unused_tables\n  end\n\n  def test_table_stats\n    assert database.table_stats\n  end\nend\n"
  },
  {
    "path": "test/test_helper.rb",
    "content": "require \"bundler/setup\"\nrequire \"combustion\"\nBundler.require(:default)\nrequire \"minitest/autorun\"\n\nclass Minitest::Test\n  def database\n    @database ||= PgHero.databases[:primary]\n  end\n\n  def with_explain(value)\n    PgHero.config.merge!({\"explain\" => value})\n    yield\n  ensure\n    PgHero.remove_instance_variable(:@config)\n  end\n\n  def with_explain_timeout(value)\n    previous_value = PgHero.explain_timeout_sec\n    begin\n      PgHero.explain_timeout_sec = value\n      yield\n    ensure\n      PgHero.explain_timeout_sec = previous_value\n    end\n  end\n\n  def explain_normalized?\n    database.server_version_num >= 160000\n  end\nend\n\nlogger = ActiveSupport::Logger.new(ENV[\"VERBOSE\"] ? STDERR : nil)\n\nCombustion.path = \"test/internal\"\nCombustion.initialize! :active_record, :action_controller do\n  config.load_defaults Rails::VERSION::STRING.to_f\n  config.action_controller.logger = logger\n  config.active_record.logger = logger\nend\n\nclass City < ActiveRecord::Base\nend\n\nclass State < ActiveRecord::Base\nend\n\nclass User < ActiveRecord::Base\nend\n\nstates =\n  50.times.map do |i|\n    {\n      name: \"State #{i}\"\n    }\n  end\nState.insert_all!(states)\nActiveRecord::Base.connection.execute(\"ANALYZE states\")\n\nusers =\n  5000.times.map do |i|\n    city_id = i % 100\n    {\n      city_id: city_id,\n      email: \"person#{i}@example.org\",\n      login_attempts: rand(30),\n      zip_code: i % 40 == 0 ? nil : \"12345\",\n      active: true,\n      country: \"Test #{rand(30)}\",\n      tree_path: \"path#{rand(30)}\",\n      range: (0..rand(5)),\n      metadata: {favorite_color: \"red\"},\n      created_at: Time.now - i.seconds,\n      updated_at: Time.now - i.seconds\n    }\n  end\nUser.insert_all!(users)\nActiveRecord::Base.connection.execute(\"ANALYZE users\")\nActiveRecord::Base.connection.execute(\"CREATE MATERIALIZED VIEW all_users AS SELECT * FROM users\")\n"
  },
  {
    "path": "test/users_test.rb",
    "content": "require_relative \"test_helper\"\n\nclass UsersTest < Minitest::Test\n  def teardown\n    database.drop_user(user)\n  end\n\n  def test_create_user\n    database.create_user(user)\n  end\n\n  def test_create_user_tables\n    database.create_user(user, tables: [\"cities\"])\n  end\n\n  def user\n    \"pghero_test_user\"\n  end\nend\n"
  }
]